Debian Codegraph @

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