Debian Codegraph @

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

raw
1 -- Copyright (c) 2019 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
25 library rtl_work;
26
27 library altera_lnsim;
28 use altera_lnsim.altera_pll;
29
30 library wlan;
31
32 library nuand;
33 use nuand.util.all ;
34 use nuand.fifo_readwrite_p.all;
35 use nuand.common_dcfifo_p.all;
36 use nuand.bladerf_p.all;
37
38 library wlan ;
39 use wlan.wlan_p.all ;
40 use wlan.wlan_tables_p.all ;
41 use wlan.wlan_tx_p.all ;
42
43 entity wlan_fx3_gpif_tb is
44 generic (
45 -- For bladeRF2 (2x2 MIMO):
46 NUM_MIMO_STREAMS : natural := 2;
47 FIFO_READER_READ_THROTTLE : natural := 0;
48
49 ENABLE_CHANNEL_0 : std_logic := '1';
50 ENABLE_CHANNEL_1 : std_logic := '0'
51 );
52 end entity;
53
54 architecture arch of wlan_fx3_gpif_tb is
55
56 -- bladerf-hosted uses ad9361.clock (125 MHz) for rx_clock and tx_clock
57 constant SYSCLK_HALF_PERIOD : time := 1 sec * (1.0/125.0e6/2.0);
58
59 -- For reasons unknown, simulation of this system in ModelSim requires that
60 -- wrreq and data be asserted shortly before the rising clock edge. Sigh...
61 constant FIFO_WORKAROUND : time := 1 ps;
62
63 type fx3_control_t is record
64 usb_speed : std_logic;
65 tx_enable : std_logic;
66 rx_enable : std_logic;
67 meta_enable : std_logic;
68 packet : std_logic;
69 end record;
70
71 type fx3_gpif_t is record
72 gpif_in : std_logic_vector(31 downto 0);
73 gpif_out : std_logic_vector(31 downto 0);
74 gpif_oe : std_logic;
75 ctl_in : std_logic_vector(12 downto 0);
76 ctl_out : std_logic_vector(12 downto 0);
77 ctl_oe : std_logic_vector(12 downto 0);
78 end record;
79
80 signal sys_rst : std_logic := '1';
81 signal done : boolean := false;
82
83 signal fx3_pclk : std_logic := '1';
84 signal fx3_pclk_pll : std_logic := '1';
85 signal sys_clk : std_logic := '1';
86
87 signal pll_reset : std_logic := '0';
88 signal pll_locked : std_logic := '0';
89 signal fx3_control : fx3_control_t;
90 signal fx3_gpif : fx3_gpif_t;
91 signal fx3_gpif_i : std_logic_vector(31 downto 0);
92 signal fx3_ctl_i : std_logic_vector(12 downto 0);
93
94 signal loopback_i : signed(15 downto 0) := (others =>'0');
95 signal loopback_q : signed(15 downto 0) := (others =>'0');
96 signal loopback_valid : std_logic := '0';
97 signal loopback_enabled : std_logic := '0';
98
99 signal tx_clock : std_logic := '1' ;
100 signal rx_clock : std_logic := '1' ;
101
102 signal rx_sample_fifo : rx_fifo_t := RX_FIFO_T_DEFAULT;
103 signal tx_sample_fifo : tx_fifo_t := TX_FIFO_T_DEFAULT;
104 signal loopback_fifo : loopback_fifo_t := LOOPBACK_FIFO_T_DEFAULT;
105 signal rx_meta_fifo : meta_fifo_rx_t := META_FIFO_RX_T_DEFAULT;
106 signal tx_meta_fifo : meta_fifo_tx_t := META_FIFO_TX_T_DEFAULT;
107
108 signal rx_mux_i : signed(15 downto 0);
109 signal rx_mux_q : signed(15 downto 0);
110 signal rx_mux_valid : std_logic;
111
112 signal tx_timestamp : unsigned(63 downto 0) := ( others => '0' );
113 signal rx_timestamp : unsigned(63 downto 0) := ( others => '0' );
114
115 constant FX3_HALF_PERIOD : time := 1.0/(100.0e6)/2.0*1 sec ;
116 constant TX_HALF_PERIOD : time := 1.0/(40.0e6)/2.0*1 sec ;
117 constant RX_HALF_PERIOD : time := 1.0/(40.0e6)/2.0*1 sec ;
118
119 signal dac_controls : sample_controls_t(0 to NUM_MIMO_STREAMS-1) := (others => SAMPLE_CONTROL_DISABLE);
120 signal dac_streams : sample_streams_t(dac_controls'range) := (others => ZERO_SAMPLE);
121 signal adc_controls : sample_controls_t(0 to NUM_MIMO_STREAMS-1) := (others => SAMPLE_CONTROL_DISABLE);
122 signal adc_streams : sample_streams_t(adc_controls'range) := (others => ZERO_SAMPLE);
123
124 signal tx_reset : std_logic := '0';
125 signal tx_ts_reset : std_logic := '0';
126 signal rx_reset : std_logic := '0';
127 signal rx_ts_reset : std_logic := '0';
128
129 signal meta_en_tx : std_logic := '0';
130 signal meta_en_rx : std_logic := '0';
131
132 signal rx_packet_control : packet_control_t := PACKET_CONTROL_DEFAULT;
133 signal tx_packet_control : packet_control_t;
134
135 signal gain_lock : std_logic := '0';
136
137 function data_gen (count : natural) return std_logic_vector is
138 variable msw, lsw : std_logic_vector(15 downto 0);
139 begin
140 msw := std_logic_vector(to_signed(count, 16));
141 lsw := std_logic_vector(to_signed(-count, 16));
142
143 return (msw & lsw);
144 end function data_gen;
145
146 signal rx_packet_ready : std_logic;
147 signal tx_packet_ready : std_logic;
148 signal tx_packet_empty : std_logic;
149
150 type channel_history_t is
151 record
152 i : signed(15 downto 0);
153 q : signed(15 downto 0);
154 valid : std_logic ;
155 end record;
156
157 type array_channel_history_t is array(natural range <>) of channel_history_t;
158
159 --signal chan_history : array_channel_history_t( 0 to 20000);
160 signal out_i : signed(15 downto 0);
161 signal out_q : signed(15 downto 0);
162 signal out_valid : std_logic ;
163
164 signal bb : wlan_sample_t ;
165 signal sample : wlan_sample_t ;
166
167 signal rx_fopen : std_logic ;
168 signal ad_ctrl : std_logic_vector(7 downto 0);
169 begin
170
171 gain_lock <= '0';
172
173 -- ========================================================================
174 -- Brief summary of data flow
175 -- ========================================================================
176 --
177 -- Simulated samples flow from fx3_model's TX side to its RX side. The
178 -- validity of the data is checked there.
179 --
180 -- entity U_fx3_model FX3 model, TX process
181 -- signal fx3_gpif_i fx3_gpif.gpif_oe is '0'
182 -- process register_gpif
183 -- signal fx3_gpif.gpif_in Demuxed GPIF interface (FX3 -> FPGA)
184 -- entity U_fx3_gpif GPIF implementation, write side
185 -- signal tx_sample_fifo.w* TX fifo, write side
186 -- entity U_tx_sample_fifo
187 -- signal tx_sample_fifo.r* TX fifo, read side
188 -- process tx_mux
189 -- signal loopback_fifo.w* Loopback fifo, write side
190 -- entity U_rx_loopback_fifo
191 -- signal loopback_fifo.r* Loopback fifo, read side
192 -- process loopback_fifo_control
193 -- signal loopback_{i,q,valid}
194 -- process rx_mux
195 -- signal rx_mux_{i,q,valid}
196 -- entity U_fifo_writer
197 -- signal rx_sample_fifo.w* RX fifo, write side
198 -- entity U_rx_sample_fifo
199 -- signal rx_sample_fifo.r* RX fifo, read side
200 -- entity U_fx3_gpif GPIF implementation, read side
201 -- signal fx3_gpif.gpif_out Demuxed GPIF interface (FPGA -> FX3)
202 -- process register_gpif
203 -- signal fx3_gpif_i fx3_gpif.gpif_oe is '1'
204 -- entity U_fx3_model FX3 model, RX process
205
206
207 -- ========================================================================
208 -- Instantiations
209 -- ========================================================================
210
211 -- Unit under test
212 -- Clock domain: fx3_pclk_pll
213 U_fx3_gpif : entity nuand.fx3_gpif
214 port map (
215 pclk => fx3_pclk_pll,
216 reset => sys_rst,
217 usb_speed => fx3_control.usb_speed,
218 gpif_in => fx3_gpif.gpif_in,
219 gpif_out => fx3_gpif.gpif_out,
220 gpif_oe => fx3_gpif.gpif_oe,
221 ctl_in => fx3_gpif.ctl_in,
222 ctl_out => fx3_gpif.ctl_out,
223 ctl_oe => fx3_gpif.ctl_oe,
224 tx_enable => fx3_control.tx_enable,
225 rx_enable => fx3_control.rx_enable,
226 meta_enable => fx3_control.meta_enable,
227 packet_enable => fx3_control.packet,
228 tx_fifo_write => tx_sample_fifo.wreq,
229 tx_fifo_full => tx_sample_fifo.wfull,
230 tx_fifo_empty => tx_sample_fifo.wempty,
231 tx_fifo_usedw => tx_sample_fifo.wused,
232 tx_fifo_data => tx_sample_fifo.wdata,
233 tx_timestamp => tx_timestamp,
234 tx_meta_fifo_write => tx_meta_fifo.wreq,
235 tx_meta_fifo_full => tx_meta_fifo.wfull,
236 tx_meta_fifo_empty => tx_meta_fifo.wempty,
237 tx_meta_fifo_usedw => tx_meta_fifo.wused,
238 tx_meta_fifo_data => tx_meta_fifo.wdata,
239 rx_fifo_read => rx_sample_fifo.rreq,
240 rx_fifo_full => rx_sample_fifo.rfull,
241 rx_fifo_empty => rx_sample_fifo.rempty,
242 rx_fifo_usedw => rx_sample_fifo.rused,
243 rx_fifo_data => rx_sample_fifo.rdata,
244 rx_meta_fifo_read => rx_meta_fifo.rreq,
245 rx_meta_fifo_full => rx_meta_fifo.rfull,
246 rx_meta_fifo_empty => rx_meta_fifo.rempty,
247 rx_meta_fifo_usedr => rx_meta_fifo.rused,
248 rx_meta_fifo_data => rx_meta_fifo.rdata
249 );
250
251 -- Discrete control signals for fx3_gpif
252 fx3_control.usb_speed <= '0';
253 fx3_control.meta_enable <= '1';
254 fx3_control.packet <= '1';
255
256 meta_en_tx <= fx3_control.meta_enable;
257 meta_en_rx <= fx3_control.meta_enable;
258
259 increment_tx_ts : process(tx_clock)
260 variable ping : boolean := true ;
261 begin
262 if( rising_edge(tx_clock) ) then
263 ping := not ping ;
264 if( ping = true ) then
265 tx_timestamp <= tx_timestamp + 1 ;
266 end if ;
267 end if ;
268 end process ;
269
270 increment_rx_ts : process(rx_clock)
271 variable ping : boolean := true ;
272 begin
273 if( rising_edge(rx_clock) ) then
274 ping := not ping ;
275 if( ping = true ) then
276 rx_timestamp <= rx_timestamp + 1 ;
277 end if ;
278 end if ;
279 end process ;
280
281 -- Model of FX3's GPIF interface
282 -- Clock domain: fx3_pclk (source)
283 U_fx3_model : entity nuand.fx3_model(wlan_micro_packet_dma)
284 port map (
285 fx3_pclk => fx3_pclk,
286 fx3_gpif => fx3_gpif_i,
287 fx3_ctl => fx3_ctl_i,
288 fx3_uart_rxd => '0',
289 fx3_uart_txd => open,
290 fx3_uart_cts => open,
291 fx3_rx_en => '1',
292 fx3_rx_meta_en => meta_en_rx,
293 fx3_tx_en => '1',
294 fx3_tx_meta_en => meta_en_tx,
295 done => done
296 );
297
298 -- Generate phase-shifted PLL clock
299 U_fx3_pll : entity rtl_work.fx3_pll
300 port map (
301 inclk0 => fx3_pclk,
302 areset => pll_reset,
303 c0 => fx3_pclk_pll,
304 locked => pll_locked
305 );
306
307 tx_clock <= not tx_clock after TX_HALF_PERIOD ;
308 rx_clock <= not rx_clock after RX_HALF_PERIOD ;
309
310
311 -- Reset handler
312 sys_rst <= '0' after 200 ns;
313
314 -- Generate system clock
315 sys_clk <= not sys_clk after SYSCLK_HALF_PERIOD when not done else '0';
316
317
318 tx_reset <= sys_rst;
319 tx_ts_reset <= sys_rst;
320 rx_reset <= sys_rst;
321 rx_ts_reset <= sys_rst;
322
323 meta_en_tx <= fx3_control.meta_enable;
324 meta_en_rx <= fx3_control.meta_enable;
325
326 -- TX Submodule
327 U_tx : entity work.tx
328 generic map (
329 NUM_STREAMS => dac_controls'length
330 )
331 port map (
332 tx_reset => tx_reset,
333 tx_clock => tx_clock,
334 tx_enable => fx3_control.tx_enable,
335
336 meta_en => meta_en_tx,
337 timestamp_reset => tx_ts_reset,
338 usb_speed => fx3_control.usb_speed,
339 tx_underflow_led => open,
340 tx_timestamp => tx_timestamp,
341
342 -- Triggering
343 trigger_arm => '0',
344 trigger_fire => '0',
345 trigger_master => '0',
346 trigger_line => open,
347
348 -- Packet FIFO
349 packet_en => fx3_control.packet,
350 packet_empty => tx_packet_empty,
351 packet_control => tx_packet_control,
352 packet_ready => tx_packet_ready,
353
354 -- Samples from host via FX3
355 sample_fifo_wclock => fx3_pclk_pll,
356 sample_fifo_wreq => tx_sample_fifo.wreq,
357 sample_fifo_wdata => tx_sample_fifo.wdata,
358 sample_fifo_wempty => tx_sample_fifo.wempty,
359 sample_fifo_wfull => tx_sample_fifo.wfull,
360 sample_fifo_wused => tx_sample_fifo.wused,
361
362 -- Metadata from host via FX3
363 meta_fifo_wclock => fx3_pclk_pll,
364 meta_fifo_wreq => tx_meta_fifo.wreq,
365 meta_fifo_wdata => tx_meta_fifo.wdata,
366 meta_fifo_wempty => tx_meta_fifo.wempty,
367 meta_fifo_wfull => tx_meta_fifo.wfull,
368 meta_fifo_wused => tx_meta_fifo.wused,
369
370 -- Digital Loopback Interface
371 loopback_enabled => '0',
372 loopback_fifo_wdata => loopback_fifo.wdata,
373 loopback_fifo_wreq => loopback_fifo.wreq,
374 loopback_fifo_wfull => loopback_fifo.wfull,
375 loopback_fifo_wused => loopback_fifo.wused,
376
377 -- RFFE Interface
378 dac_controls => dac_controls,
379 dac_streams => dac_streams
380 );
381
382 -- RX Submodule
383 U_rx : entity work.rx
384 generic map (
385 NUM_STREAMS => adc_controls'length
386 )
387 port map (
388 rx_reset => rx_reset,
389 rx_clock => rx_clock,
390 rx_enable => fx3_control.rx_enable,
391
392 meta_en => meta_en_rx,
393 timestamp_reset => rx_ts_reset,
394 usb_speed => fx3_control.usb_speed,
395 rx_mux_sel => to_unsigned(0, 3),
396 rx_overflow_led => open,
397 rx_timestamp => rx_timestamp,
398
399 -- Triggering
400 trigger_arm => '0',
401 trigger_fire => '0',
402 trigger_master => '0',
403 trigger_line => open,
404
405 -- Packet FIFO
406 packet_en => fx3_control.packet,
407 packet_control => rx_packet_control,
408 packet_ready => rx_packet_ready,
409
410 -- Samples to host via FX3
411 sample_fifo_rclock => fx3_pclk_pll,
412 sample_fifo_raclr => not fx3_control.rx_enable,
413 sample_fifo_rreq => rx_sample_fifo.rreq,
414 sample_fifo_rdata => rx_sample_fifo.rdata,
415 sample_fifo_rempty => rx_sample_fifo.rempty,
416 sample_fifo_rfull => rx_sample_fifo.rfull,
417 sample_fifo_rused => rx_sample_fifo.rused,
418
419 -- Mini expansion signals
420 mini_exp => "00",
421
422 -- Metadata to host via FX3
423 meta_fifo_rclock => fx3_pclk_pll,
424 meta_fifo_raclr => not fx3_control.rx_enable,
425 meta_fifo_rreq => rx_meta_fifo.rreq,
426 meta_fifo_rdata => rx_meta_fifo.rdata,
427 meta_fifo_rempty => rx_meta_fifo.rempty,
428 meta_fifo_rfull => rx_meta_fifo.rfull,
429 meta_fifo_rused => rx_meta_fifo.rused,
430
431 -- Digital Loopback Interface
432 loopback_fifo_wenabled => open,
433 loopback_fifo_wreset => tx_reset,
434 loopback_fifo_wclock => tx_clock,
435 loopback_fifo_wdata => loopback_fifo.wdata,
436 loopback_fifo_wreq => loopback_fifo.wreq,
437 loopback_fifo_wfull => loopback_fifo.wfull,
438 loopback_fifo_wused => loopback_fifo.wused,
439
440 -- RFFE Interface
441 adc_controls => adc_controls,
442 adc_streams => adc_streams
443 );
444
445 -- ========================================================================
446 -- Data converters
447 -- ========================================================================
448
449 gen_dac_controls : if( NUM_MIMO_STREAMS > 1 ) generate
450 -- The TX side of the AD9361 HDL is a FIFO pull interface
451 -- that expects a readahead FIFO. It toggles the data request
452 -- signal every other cycle. This behavior is mimicked here.
453 process( tx_clock, sys_rst )
454 begin
455 if( sys_rst = '1' ) then
456 dac_controls <= (
457 0 => (enable => ENABLE_CHANNEL_0, data_req => '1'),
458 1 => (enable => ENABLE_CHANNEL_1, data_req => '1')
459 );
460 elsif( rising_edge(tx_clock) ) then
461 for i in dac_controls'range loop
462 dac_controls(i) <= (
463 enable => dac_controls(i).enable,
464 data_req => not dac_controls(i).data_req );
465 end loop;
466 end if;
467 end process;
468 else generate
469 dac_controls <= (others => SAMPLE_CONTROL_ENABLE);
470 end generate;
471
472 gen_adc_controls : if( NUM_MIMO_STREAMS > 1 ) generate
473 process( rx_clock, sys_rst )
474 variable count : natural range 0 to 10000;
475 variable rv : std_logic_vector(31 downto 0);
476 begin
477 if( sys_rst = '1' ) then
478 count := 0;
479 adc_controls <= (
480 0 => (enable => ENABLE_CHANNEL_0, data_req => '1'),
481 1 => (enable => ENABLE_CHANNEL_1, data_req => '1')
482 );
483 elsif( rising_edge(rx_clock) ) then
484 for i in adc_controls'range loop
485 adc_controls(i) <= (
486 enable => adc_controls(i).enable,
487 data_req => not adc_controls(i).data_req );
488 if( adc_controls(i).enable = '1') then
489 if( adc_streams(i).data_v = '1' ) then
490 if( count < 10000 ) then
491 count := count + 1;
492 else
493 count := 0;
494 end if;
495 rv := std_logic_vector(to_unsigned(count, 32));
496 adc_streams(i).data_i <= signed(rv(15 downto 0));
497 adc_streams(i).data_q <= signed(rv(31 downto 16));
498 end if;
499 adc_streams(i).data_v <= not adc_streams(i).data_v;
500 end if;
501 end loop;
502 end if;
503 end process;
504 else generate
505 adc_controls <= (others => SAMPLE_CONTROL_ENABLE);
506 end generate;
507
508 -- ========================================================================
509 -- Processes
510 -- ========================================================================
511
512 -- FX3 GPIF bidirectional signal control
513 -- Adapted from same process in bladerf-hosted.vhd
514 register_gpif : process(sys_rst, fx3_pclk_pll)
515 begin
516 if( sys_rst = '1' ) then
517 fx3_gpif_i <= (others => 'Z');
518 fx3_gpif.gpif_in <= (others => 'Z');
519 elsif( rising_edge(fx3_pclk_pll) ) then
520 fx3_gpif.gpif_in <= fx3_gpif_i;
521
522 if( fx3_gpif.gpif_oe = '1' ) then
523 fx3_gpif_i <= fx3_gpif.gpif_out;
524 else
525 fx3_gpif_i <= (others =>'Z');
526 end if;
527 end if;
528 end process;
529
530 -- FX3 CTL bidirectional signals
531 -- Adapted from same generator in bladerf-hosted.vhd
532 generate_ctl : for i in fx3_ctl_i'range generate
533 fx3_ctl_i(i) <= fx3_gpif.ctl_out(i) when fx3_gpif.ctl_oe(i) = '1' else 'Z';
534 end generate;
535
536 fx3_gpif.ctl_in <= fx3_ctl_i;
537
538 -- Controller for loopback FIFO
539 -- Stripped-down version of same process from rx.vhd
540 loopback_fifo_control : process( sys_rst, loopback_fifo.rclock )
541 begin
542 if( sys_rst = '1' ) then
543 loopback_enabled <= '0';
544 loopback_fifo.rreq <= '0';
545 loopback_i <= (others => '0');
546 loopback_q <= (others => '0');
547 loopback_valid <= '0';
548 elsif( rising_edge(loopback_fifo.rclock) ) then
549 loopback_enabled <= '0';
550 loopback_fifo.rreq <= '0';
551 loopback_i <= loopback_i;
552 loopback_q <= loopback_q;
553 loopback_valid <= '0';
554
555 -- Is loopback enabled?
556 loopback_enabled <= fx3_control.rx_enable;
557
558 -- Do the loopback
559 loopback_i <= resize(signed(loopback_fifo.rdata(15 downto 0)), loopback_i'length);
560 loopback_q <= resize(signed(loopback_fifo.rdata(31 downto 16)), loopback_q'length);
561 loopback_valid <= loopback_fifo.rreq and not loopback_fifo.rempty;
562
563 -- Read from the FIFO if req'd
564 loopback_fifo.rreq <= loopback_enabled and (not loopback_fifo.rempty);
565 end if;
566 end process;
567
568 -- RX multiplexer
569 -- Stripped-down version of same process from rx.vhd
570 rx_mux : process(sys_rst, sys_clk)
571 begin
572 if( sys_rst = '1' ) then
573 rx_mux_i <= (others =>'0');
574 rx_mux_q <= (others =>'0');
575 rx_mux_valid <= '0';
576 elsif( rising_edge(sys_clk) ) then
577 rx_mux_i <= loopback_i;
578 rx_mux_q <= loopback_q;
579 rx_mux_valid <= loopback_valid;
580 end if;
581 end process;
582
583 -- TX multiplexer
584 -- Stripped-down version of mimo_channel_sel_mux from tx.vhd
585 --tx_mux : process( sys_clk )
586 --begin
587 -- if( rising_edge(sys_clk) ) then
588 -- tx_sample_fifo.rreq <= not tx_sample_fifo.rempty;
589
590 -- loopback_fifo.wdata <= tx_sample_fifo.rdata;
591 -- loopback_fifo.wreq <= tx_sample_fifo.rreq and not tx_sample_fifo.rempty;
592 -- end if;
593 --end process;
594
595
596 -- ========================================================================
597 -- Validation
598 -- ========================================================================
599
600 -- Check for metavalues
601 -- We should never see metavalues written to the FIFOs
602 check_fifo_write : process (fx3_pclk_pll) is
603 begin
604 if (rising_edge(fx3_pclk_pll)) then
605 if (tx_sample_fifo.wreq = '1' and fx3_control.meta_enable = '0') then
606 for i in tx_sample_fifo.wdata'range loop
607 assert tx_sample_fifo.wdata(i) = '0' or tx_sample_fifo.wdata(i) = '1'
608 severity failure;
609 end loop;
610 end if;
611 end if;
612 end process check_fifo_write;
613
614 check_fifo_read : process (fx3_pclk_pll) is
615 begin
616 if (rising_edge(fx3_pclk_pll)) then
617 if (rx_sample_fifo.rreq = '1') then
618 for i in rx_sample_fifo.rdata'range loop
619 assert rx_sample_fifo.rdata(i) = '0' or rx_sample_fifo.rdata(i) = '1'
620 severity failure;
621 end loop;
622 end if;
623 end if;
624 end process check_fifo_read;
625
626 -- Check for fullness on FIFOs
627 assert (rx_sample_fifo.wfull = '0') report "rx_sample_fifo full (write)" severity warning;
628 assert (tx_sample_fifo.wfull = '0') report "tx_sample_fifo full (write)" severity warning;
629 assert (loopback_fifo.wfull = '0') report "loopback_fifo full (write)" severity warning;
630
631 U_wlan_top : entity wlan.wlan_top
632 port map (
633 rx_clock => rx_clock,
634 rx_reset => rx_reset,
635 rx_enable => fx3_control.rx_enable,
636
637 tx_clock => tx_clock,
638 tx_reset => tx_reset,
639 tx_enable => fx3_control.tx_enable,
640
641 config_reg => x"00000000",
642
643 packet_en => fx3_control.packet,
644
645 tx_packet_control => tx_packet_control,
646 tx_packet_empty => tx_packet_empty,
647 tx_packet_ready => tx_packet_ready,
648
649 rx_packet_control => rx_packet_control,
650 rx_packet_ready => rx_packet_ready,
651
652 tx_fifo_usedw => (others => '0' ),
653 tx_fifo_read => open,
654 tx_fifo_empty => '1',
655 tx_fifo_data => (others => '0' ),
656
657 rx_fifo_usedw => (others => '0' ),
658 rx_fifo_write => open,
659 rx_fifo_full => '0',
660 rx_fifo_data => open,
661
662 gain_inc_req => open,
663 gain_dec_req => open,
664 gain_rst_req => open,
665 gain_ack => '0',
666 gain_nack => '0',
667 gain_lock => gain_lock,
668 gain_max => '1',
669
670 tx_ota_req => open,
671 tx_ota_ack => '1',
672
673 out_i => out_i,
674 out_q => out_q,
675 out_valid => out_valid,
676
677 in_i => sample.i,
678 in_q => sample.q,
679 in_valid => sample.valid
680
681 ) ;
682
683 bb.i <= out_i;
684 bb.q <= out_q;
685
686 process(rx_clock)
687 begin
688 if(rx_reset = '1') then
689 bb.valid <= '0';
690 elsif(rising_edge(rx_clock)) then
691 bb.valid <= not bb.valid;
692 end if;
693 end process;
694
695 U_sample_saver : entity wlan.wlan_sample_saver
696 generic map (
697 FILENAME => "out"
698 ) port map (
699 clock => tx_clock,
700 fopen => '1',
701 sample => bb,
702 done => '0'
703 ) ;
704
705 U_sample_loader: entity wlan.wlan_sample_loader
706 generic map (
707 FILENAME => "rx"
708 ) port map (
709 clock => rx_clock,
710 fopen => rx_fopen,
711 sample => sample
712 );
713
714 rx_fopen <= '0', '1' after 100 ns;
715
716 --process(sys_rst, rx_clock)
717 --begin
718 -- if( sys_rst = '1' ) then
719 -- for i in chan_history'range loop
720 -- chan_history(i).i <= ( others => '0' );
721 -- chan_history(i).q <= ( others => '0' );
722 -- chan_history(i).valid <= '0' ;
723 -- end loop;
724 -- elsif( rising_edge( rx_clock ) ) then
725 -- for i in chan_history'range loop
726 -- if( i = 0 ) then
727 -- chan_history(i).i <= out_i;
728 -- chan_history(i).q <= out_q;
729 -- chan_history(i).valid <= out_valid;
730 -- else
731 -- chan_history(i) <= chan_history(i - 1);
732 -- end if;
733 -- end loop;
734 -- end if;
735 --end process;
736
737 end architecture;