OpenCores
URL https://opencores.org/ocsvn/astron_fifo/astron_fifo/trunk

Subversion Repositories astron_fifo

[/] [astron_fifo/] [trunk/] [tb_common_fifo_rd.vhd] - Blame information for rev 2

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 danv
-------------------------------------------------------------------------------
2
--
3
-- Copyright (C) 2009
4
-- ASTRON (Netherlands Institute for Radio Astronomy) <http://www.astron.nl/>
5
-- P.O.Box 2, 7990 AA Dwingeloo, The Netherlands
6
--
7
-- This program is free software: you can redistribute it and/or modify
8
-- it under the terms of the GNU General Public License as published by
9
-- the Free Software Foundation, either version 3 of the License, or
10
-- (at your option) any later version.
11
--
12
-- This program is distributed in the hope that it will be useful,
13
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
14
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15
-- GNU General Public License for more details.
16
--
17
-- You should have received a copy of the GNU General Public License
18
-- along with this program.  If not, see <http://www.gnu.org/licenses/>.
19
--
20
-------------------------------------------------------------------------------
21
 
22
LIBRARY IEEE, common_pkg_lib;
23
USE IEEE.std_logic_1164.ALL;
24
USE IEEE.numeric_std.ALL;
25
USE common_pkg_lib.common_pkg.ALL;
26
USE common_pkg_lib.common_lfsr_sequences_pkg.ALL;
27
USE common_pkg_lib.tb_common_pkg.ALL;
28
 
29
 
30
ENTITY tb_common_fifo_rd IS
31
  GENERIC (
32
    g_random_control : BOOLEAN := TRUE  -- use TRUE for random rd_req control
33
  );
34
END tb_common_fifo_rd;
35
 
36
-- Run -all, observe rd_dat in wave window
37
 
38
ARCHITECTURE tb OF tb_common_fifo_rd IS
39
 
40
  CONSTANT clk_period   : TIME := 10 ns;
41
  CONSTANT c_dat_w      : NATURAL := 16;
42
  CONSTANT c_fifo_rl    : NATURAL := 1;  -- FIFO has RL = 1
43
  CONSTANT c_read_rl    : NATURAL := 0;  -- show ahead FIFO has RL = 0
44
 
45
  SIGNAL rst         : STD_LOGIC;
46
  SIGNAL clk         : STD_LOGIC := '0';
47
  SIGNAL tb_end      : STD_LOGIC := '0';
48
 
49
  SIGNAL fifo_req    : STD_LOGIC;
50
  SIGNAL fifo_dat    : STD_LOGIC_VECTOR(c_dat_w-1 DOWNTO 0);
51
  SIGNAL fifo_val    : STD_LOGIC;
52
 
53
  SIGNAL rd_req      : STD_LOGIC;
54
  SIGNAL rd_dat      : STD_LOGIC_VECTOR(c_dat_w-1 DOWNTO 0);
55
  SIGNAL rd_val      : STD_LOGIC;
56
 
57
  SIGNAL enable      : STD_LOGIC := '1';
58
  SIGNAL random      : STD_LOGIC_VECTOR(31 DOWNTO 0) := (OTHERS=>'0');
59
  SIGNAL verify_en   : STD_LOGIC := '1';
60
  SIGNAL prev_rd_req : STD_LOGIC;
61
  SIGNAL prev_rd_dat : STD_LOGIC_VECTOR(c_dat_w-1 DOWNTO 0);
62
 
63
BEGIN
64
 
65
  rst <= '1', '0' AFTER clk_period*7;
66
  clk <= NOT clk OR tb_end AFTER clk_period/2;
67
  tb_end <= '0', '1' AFTER 20 us;
68
 
69
  verify_en <= '0', '1' AFTER clk_period*35;
70
 
71
  -- Model FIFO output with c_rl = 1 and counter data starting at 0
72
  proc_common_gen_data(c_fifo_rl, 0, rst, clk, enable, fifo_req, fifo_dat, fifo_val);
73
 
74
  -- Model rd_req
75
  random <= func_common_random(random) WHEN rising_edge(clk);
76
  rd_req <= random(random'HIGH) WHEN g_random_control=TRUE ELSE '1';
77
 
78
  -- Verify dut output incrementing data
79
  proc_common_verify_data(c_read_rl, clk, verify_en, rd_req, rd_val, rd_dat, prev_rd_dat);
80
 
81
  -- Verify dut output stream ready - valid relation, prev_rd_req is an auxiliary signal needed by the proc
82
  proc_common_verify_valid(c_read_rl, clk, verify_en, rd_req, prev_rd_req, rd_val);
83
 
84
 
85
  u_dut : ENTITY work.common_fifo_rd
86
  GENERIC MAP (
87
    g_dat_w => c_dat_w
88
  )
89
  PORT MAP (
90
    rst        => rst,
91
    clk        => clk,
92
    -- ST sink: RL = 1
93
    fifo_req   => fifo_req,
94
    fifo_dat   => fifo_dat,
95
    fifo_val   => fifo_val,
96
    -- ST source: RL = 0
97
    rd_req     => rd_req,
98
    rd_dat     => rd_dat,
99
    rd_val     => rd_val
100
  );
101
 
102
END tb;

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.