1 |
2 |
danv |
-------------------------------------------------------------------------------
|
2 |
|
|
--
|
3 |
3 |
danv |
-- Copyright 2020
|
4 |
2 |
danv |
-- ASTRON (Netherlands Institute for Radio Astronomy) <http://www.astron.nl/>
|
5 |
|
|
-- P.O.Box 2, 7990 AA Dwingeloo, The Netherlands
|
6 |
3 |
danv |
--
|
7 |
|
|
-- Licensed under the Apache License, Version 2.0 (the "License");
|
8 |
|
|
-- you may not use this file except in compliance with the License.
|
9 |
|
|
-- You may obtain a copy of the License at
|
10 |
|
|
--
|
11 |
|
|
-- http://www.apache.org/licenses/LICENSE-2.0
|
12 |
|
|
--
|
13 |
|
|
-- Unless required by applicable law or agreed to in writing, software
|
14 |
|
|
-- distributed under the License is distributed on an "AS IS" BASIS,
|
15 |
|
|
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
16 |
|
|
-- See the License for the specific language governing permissions and
|
17 |
|
|
-- limitations under the License.
|
18 |
2 |
danv |
--
|
19 |
|
|
-------------------------------------------------------------------------------
|
20 |
|
|
|
21 |
|
|
LIBRARY IEEE, common_pkg_lib;
|
22 |
|
|
USE IEEE.std_logic_1164.ALL;
|
23 |
|
|
USE IEEE.numeric_std.ALL;
|
24 |
|
|
USE common_pkg_lib.common_pkg.ALL;
|
25 |
|
|
USE common_pkg_lib.common_lfsr_sequences_pkg.ALL;
|
26 |
|
|
USE common_pkg_lib.tb_common_pkg.ALL;
|
27 |
|
|
|
28 |
|
|
|
29 |
|
|
ENTITY tb_common_fifo_rd IS
|
30 |
|
|
GENERIC (
|
31 |
|
|
g_random_control : BOOLEAN := TRUE -- use TRUE for random rd_req control
|
32 |
|
|
);
|
33 |
|
|
END tb_common_fifo_rd;
|
34 |
|
|
|
35 |
|
|
-- Run -all, observe rd_dat in wave window
|
36 |
|
|
|
37 |
|
|
ARCHITECTURE tb OF tb_common_fifo_rd IS
|
38 |
|
|
|
39 |
|
|
CONSTANT clk_period : TIME := 10 ns;
|
40 |
|
|
CONSTANT c_dat_w : NATURAL := 16;
|
41 |
|
|
CONSTANT c_fifo_rl : NATURAL := 1; -- FIFO has RL = 1
|
42 |
|
|
CONSTANT c_read_rl : NATURAL := 0; -- show ahead FIFO has RL = 0
|
43 |
|
|
|
44 |
|
|
SIGNAL rst : STD_LOGIC;
|
45 |
|
|
SIGNAL clk : STD_LOGIC := '0';
|
46 |
|
|
SIGNAL tb_end : STD_LOGIC := '0';
|
47 |
|
|
|
48 |
|
|
SIGNAL fifo_req : STD_LOGIC;
|
49 |
|
|
SIGNAL fifo_dat : STD_LOGIC_VECTOR(c_dat_w-1 DOWNTO 0);
|
50 |
|
|
SIGNAL fifo_val : STD_LOGIC;
|
51 |
|
|
|
52 |
|
|
SIGNAL rd_req : STD_LOGIC;
|
53 |
|
|
SIGNAL rd_dat : STD_LOGIC_VECTOR(c_dat_w-1 DOWNTO 0);
|
54 |
|
|
SIGNAL rd_val : STD_LOGIC;
|
55 |
|
|
|
56 |
|
|
SIGNAL enable : STD_LOGIC := '1';
|
57 |
|
|
SIGNAL random : STD_LOGIC_VECTOR(31 DOWNTO 0) := (OTHERS=>'0');
|
58 |
|
|
SIGNAL verify_en : STD_LOGIC := '1';
|
59 |
|
|
SIGNAL prev_rd_req : STD_LOGIC;
|
60 |
|
|
SIGNAL prev_rd_dat : STD_LOGIC_VECTOR(c_dat_w-1 DOWNTO 0);
|
61 |
|
|
|
62 |
|
|
BEGIN
|
63 |
|
|
|
64 |
|
|
rst <= '1', '0' AFTER clk_period*7;
|
65 |
|
|
clk <= NOT clk OR tb_end AFTER clk_period/2;
|
66 |
|
|
tb_end <= '0', '1' AFTER 20 us;
|
67 |
|
|
|
68 |
|
|
verify_en <= '0', '1' AFTER clk_period*35;
|
69 |
|
|
|
70 |
|
|
-- Model FIFO output with c_rl = 1 and counter data starting at 0
|
71 |
|
|
proc_common_gen_data(c_fifo_rl, 0, rst, clk, enable, fifo_req, fifo_dat, fifo_val);
|
72 |
|
|
|
73 |
|
|
-- Model rd_req
|
74 |
|
|
random <= func_common_random(random) WHEN rising_edge(clk);
|
75 |
|
|
rd_req <= random(random'HIGH) WHEN g_random_control=TRUE ELSE '1';
|
76 |
|
|
|
77 |
|
|
-- Verify dut output incrementing data
|
78 |
|
|
proc_common_verify_data(c_read_rl, clk, verify_en, rd_req, rd_val, rd_dat, prev_rd_dat);
|
79 |
|
|
|
80 |
|
|
-- Verify dut output stream ready - valid relation, prev_rd_req is an auxiliary signal needed by the proc
|
81 |
|
|
proc_common_verify_valid(c_read_rl, clk, verify_en, rd_req, prev_rd_req, rd_val);
|
82 |
|
|
|
83 |
|
|
|
84 |
|
|
u_dut : ENTITY work.common_fifo_rd
|
85 |
|
|
GENERIC MAP (
|
86 |
|
|
g_dat_w => c_dat_w
|
87 |
|
|
)
|
88 |
|
|
PORT MAP (
|
89 |
|
|
rst => rst,
|
90 |
|
|
clk => clk,
|
91 |
|
|
-- ST sink: RL = 1
|
92 |
|
|
fifo_req => fifo_req,
|
93 |
|
|
fifo_dat => fifo_dat,
|
94 |
|
|
fifo_val => fifo_val,
|
95 |
|
|
-- ST source: RL = 0
|
96 |
|
|
rd_req => rd_req,
|
97 |
|
|
rd_dat => rd_dat,
|
98 |
|
|
rd_val => rd_val
|
99 |
|
|
);
|
100 |
|
|
|
101 |
|
|
END tb;
|