Debian Codegraph @

hdl/fpga/platforms/bladerf-micro/vhdl/tb/bladerf_tb.vhd

raw
1 -- Copyright (c) 2013-2017 Nuand LLC
2 --
3 -- Permission is hereby granted, free of charge, to any person obtaining a copy
4 -- of this software and associated documentation files (the "Software"), to deal
5 -- in the Software without restriction, including without limitation the rights
6 -- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7 -- copies of the Software, and to permit persons to whom the Software is
8 -- furnished to do so, subject to the following conditions:
9 --
10 -- The above copyright notice and this permission notice shall be included in
11 -- all copies or substantial portions of the Software.
12 --
13 -- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14 -- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15 -- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16 -- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17 -- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18 -- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19 -- THE SOFTWARE.
20
21 library ieee ;
22 use ieee.std_logic_1164.all ;
23 use ieee.numeric_std.all ;
24 use ieee.math_real.all ;
25 use ieee.math_complex.all ;
26
27 library nuand ;
28
29 entity bladerf_tb is
30 end entity ; -- bladerf_tb
31
32 architecture arch of bladerf_tb is
33
34 constant C5_CLOCK_HALF_PERIOD : time := 1 sec * (1.0/38.4e6/2.0) ;
35 constant ADI_RX_CLOCK_HALF_PERIOD : time := 1 sec * (1.0/61.44e6/2.0);
36
37 type fx3_gpif_t is record
38 pclk : std_logic ;
39 gpif : std_logic_vector(31 downto 0) ;
40 ctl : std_logic_vector(12 downto 0) ;
41 end record ;
42
43 type fx3_uart_t is record
44 rxd : std_logic ;
45 txd : std_logic ;
46 cts : std_logic ;
47 end record ;
48
49 procedure nop( signal clock : in std_logic ; count : in natural ) is
50 begin
51 for i in 1 to count loop
52 wait until rising_edge(clock) ;
53 end loop ;
54 end procedure ;
55
56 signal c5_clock2 : std_logic := '1';
57 signal adi_rx_clock : std_logic := '1';
58 signal fx3_gpif : fx3_gpif_t;
59 signal fx3_uart : fx3_uart_t;
60
61 begin
62
63 -- Main 38.4MHz clock input
64 c5_clock2 <= not c5_clock2 after C5_CLOCK_HALF_PERIOD ;
65
66 -- AD9361 clock input
67 adi_rx_clock <= not adi_rx_clock after ADI_RX_CLOCK_HALF_PERIOD;
68
69 -- Top level of the FPGA
70 U_bladerf : entity nuand.bladerf
71 port map (
72 -- Main system clock
73 c5_clock2 => c5_clock2,
74
75 -- Si53304 clock controls
76 si_clock_sel => open,
77 c5_clock2_oe => open,
78 ufl_clock_oe => open,
79 exp_clock_oe => open,
80
81 -- VCTCXO DAC
82 dac_sclk => open,
83 dac_sdi => open,
84 dac_csn => open,
85
86 -- LEDs
87 led => open,
88
89 -- Power supply sync
90 ps_sync_1p1 => open,
91 ps_sync_1p8 => open,
92
93 -- Power monitor
94 pwr_sda => open,
95 pwr_scl => open,
96 pwr_status => '0',
97
98 -- AD9361 RX interface
99 adi_rx_clock => adi_rx_clock,
100 adi_rx_data => (others => '0'),
101 adi_rx_frame => '0',
102
103 -- RX RF switching
104 adi_rx_spdt1_v => open,
105 adi_rx_spdt2_v => open,
106
107 -- RX bias-tee enable
108 rx_bias_en => open,
109
110 -- AD9361 TX interface
111 adi_tx_clock => open,
112 adi_tx_data => open,
113 adi_tx_frame => open,
114
115 -- TX RF switching
116 adi_tx_spdt1_v => open,
117 adi_tx_spdt2_v => open,
118
119 -- TX bias-tee enable
120 tx_bias_en => open,
121
122 -- AD9361 SPI interface
123 adi_spi_sclk => open,
124 adi_spi_csn => open,
125 adi_spi_sdi => open,
126 adi_spi_sdo => '0',
127
128 -- AD9361 control interface
129 adi_reset_n => open,
130 adi_enable => open,
131 adi_txnrx => open,
132 adi_en_agc => open,
133 adi_ctrl_in => open,
134 adi_ctrl_out => (others => '0'),
135 adi_sync_in => open,
136
137 -- ADF4002 SPI interface
138 adf_sclk => open,
139 adf_csn => open,
140 adf_sdi => open,
141 adf_ce => open,
142 adf_muxout => '0',
143
144 -- FX3 GPIF Interface
145 fx3_pclk => fx3_gpif.pclk,
146 fx3_gpif => fx3_gpif.gpif,
147 fx3_ctl => fx3_gpif.ctl,
148
149 -- FX3 UART interface
150 fx3_uart_rxd => fx3_uart.rxd,
151 fx3_uart_txd => fx3_uart.txd,
152 fx3_uart_cts => fx3_uart.cts,
153
154 -- Expansion Interface
155 exp_present => '0',
156 exp_clock_req => '0',
157 exp_i2c_sda => open,
158 exp_i2c_scl => open,
159 exp_gpio => open,
160
161 -- Mini expansion
162 mini_exp1 => open,
163 mini_exp2 => open,
164
165 -- HW rev
166 hw_rev => (others => '0')
167 ) ;
168
169 -- FX3 Model
170 U_fx3 : entity nuand.fx3_model(dma)
171 port map (
172 -- GPIF
173 fx3_pclk => fx3_gpif.pclk,
174 fx3_gpif => fx3_gpif.gpif,
175 fx3_ctl => fx3_gpif.ctl,
176
177 -- UART
178 fx3_uart_rxd => fx3_uart.rxd,
179 fx3_uart_txd => fx3_uart.txd,
180 fx3_uart_cts => fx3_uart.cts,
181 fx3_rx_en => '1',
182 fx3_rx_meta_en => '1',
183 fx3_tx_en => '1',
184 fx3_tx_meta_en => '1'
185 ) ;
186
187 -- Stimulus
188 tb : process
189 begin
190 wait for 10 ms ;
191 report "-- End of simulation --" severity failure ;
192 end process ;
193
194 end architecture ; -- arch