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

Subversion Repositories srl_fifo

[/] [srl_fifo/] [trunk/] [rtl/] [tb_srl_fifo_16.vhd] - Blame information for rev 7

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 amulcock
----------------------------------------------------------------------------
2
----                                                                                                                ----
3
----                                                                                                                ----
4
---- This file is part of the srl_fifo project                                              ----
5
---- http://www.opencores.org/cores/srl_fifo                                            ----
6
----                                                                                                                ----
7
---- Description                                                                                                ----
8
---- Implementation of srl_fifo IP core according to                    ----
9
---- srl_fifo IP core specification document.                                   ----
10
----                                                                                                                ----
11
---- To Do:                                                                                                         ----
12
----    NA                                                                                                          ----
13
----                                                                                                                ----
14
---- Author(s):                                                                                             ----
15
----   Andrew Mulcock, amulcock@opencores.org                                   ----
16
----                                                                                                                ----
17
----------------------------------------------------------------------------
18
----                                                                                                                ----
19
---- Copyright (C) 2008 Authors and OPENCORES.ORG                                       ----
20
----                                                                                                                ----
21
---- This source file may be used and distributed without                               ----
22
---- restriction provided that this copyright statement is not                  ----
23
---- removed from the file and that any derivative work contains                ----
24
---- the original copyright notice and the associated disclaimer.               ----
25
----                                                                                                                ----
26
---- This source file is free software; you can redistribute it                 ----
27
---- and/or modify it under the terms of the GNU Lesser General             ----
28
---- Public License as published by the Free Software Foundation;               ----
29
---- either version 2.1 of the License, or (at your option) any                 ----
30
---- later version.                                                                                             ----
31
----                                                                                                                ----
32
---- This source is distributed in the hope that it will be                             ----
33
---- useful, but WITHOUT ANY WARRANTY; without even the implied         ----
34
---- warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR            ----
35
---- PURPOSE. See the GNU Lesser General Public License for more                ----
36
---- details.                                                                                                   ----
37
----                                                                                                                ----
38
---- You should have received a copy of the GNU Lesser General              ----
39
---- Public License along with this source; if not, download it                 ----
40
---- from http://www.opencores.org/lgpl.shtml                                           ----
41
----                                                                                                                ----
42
----------------------------------------------------------------------------
43
--                                                                                                                      ----
44
-- CVS Revision History                                                                                 ----
45
--                                                                                                                      ----
46
-- $Log: not supported by cvs2svn $                                                                                                         ----
47
--                                                                                                                      ----
48
--
49
-- quick description
50
--
51
--  Based upon the using a shift register as a fifo which has been 
52
--   around for years ( decades ), but really came of use to VHDL 
53
--   when the Xilinx FPGA's started having SRL's. 
54
--
55
--  In my view, the definitive article on shift register logic fifo's 
56
--   comes from Mr Chapman at Xilinx, in the form of his BBFIFO
57
--    tecXeclusive article, which as at early 2008, Xilinx have
58
--     removed.
59
--
60
 
61
LIBRARY ieee;
62
USE ieee.std_logic_1164.ALL;
63
USE ieee.std_logic_unsigned.all;
64
USE ieee.numeric_std.ALL;
65
 
66
ENTITY tb_srl_fifo_16_vhd IS
67
END tb_srl_fifo_16_vhd;
68
 
69
ARCHITECTURE behavior OF tb_srl_fifo_16_vhd IS
70
 
71
constant width_tb : integer := 8;
72
 
73
        -- Component Declaration for the Unit Under Test (UUT)
74
        COMPONENT srl_fifo_16
75
    GENERIC ( width : integer := width_tb ); -- set to how wide fifo is to be
76
        PORT(
77
                data_in : IN std_logic_vector(width_tb - 1 downto 0);
78
                reset : IN std_logic;
79
                write : IN std_logic;
80
                read : IN std_logic;
81
                clk : IN std_logic;
82
                data_out : OUT std_logic_vector(width_tb - 1  downto 0);
83
                full : OUT std_logic;
84
                half_full : OUT std_logic;
85
                data_present : OUT std_logic
86
                );
87
        END COMPONENT;
88
 
89
        --Inputs
90
        SIGNAL reset :  std_logic := '0';
91
        SIGNAL write :  std_logic := '0';
92
        SIGNAL read :  std_logic := '0';
93
        SIGNAL clk :  std_logic := '0';
94
        SIGNAL data_in :  std_logic_vector(width_tb - 1 downto 0) := (others=>'0');
95
 
96
        --Outputs
97
        SIGNAL data_out :  std_logic_vector(width_tb -1  downto 0);
98
        SIGNAL full :  std_logic;
99
        SIGNAL half_full :  std_logic;
100
        SIGNAL data_present :  std_logic;
101
 
102
BEGIN
103
 
104
        -- Instantiate the Unit Under Test (UUT)
105
        uut: srl_fifo_16
106
        GENERIC MAP (
107
        width => width_tb
108
        )
109
        PORT MAP(
110
                data_in => data_in,
111
                data_out => data_out,
112
                reset => reset,
113
                write => write,
114
                read => read,
115
                full => full,
116
                half_full => half_full,
117
                data_present => data_present,
118
                clk => clk
119
        );
120
 
121
        tb : PROCESS
122
        BEGIN
123
 
124
 
125
        reset <= '1';
126
                -- Wait 100 ns for global reset to finish
127
                wait for 100 ns;
128
 
129
        wait until clk = '0';
130
        reset <= '0';
131
 
132
                -- Place stimulus here
133
 
134
    wait until clk = '0';  -- 0
135
    data_in <= X"AA";
136
    write <= '1';
137
 
138
    wait until clk = '0';   -- 1
139
    data_in <= X"55";
140
 
141
    wait until clk = '0';   -- 2
142
    data_in <= X"02";
143
    wait until clk = '0';   -- 3
144
    data_in <= X"03";
145
    wait until clk = '0';   -- 4
146
    data_in <= X"04";
147
    wait until clk = '0';   -- 5
148
    data_in <= X"05";
149
    wait until clk = '0';   -- 6
150
    data_in <= X"06";
151
    wait until clk = '0';   -- 7
152
    data_in <= X"07";
153
    wait until clk = '0';   -- 8
154
    data_in <= X"08";
155
    wait until clk = '0';   -- 9
156
    data_in <= X"09";
157
    wait until clk = '0';   -- A
158
    data_in <= X"A0";
159
    wait until clk = '0';   -- B
160
    data_in <= X"B0";
161
    wait until clk = '0';   -- C
162
    data_in <= X"C0";
163
    wait until clk = '0';   -- D
164
    data_in <= X"D0";
165
    wait until clk = '0';   -- E
166
    data_in <= X"E0";
167
    wait until clk = '0';   -- F
168
    data_in <= X"F0";
169
    wait until clk = '0';   -- no write
170
    data_in <= X"FF";
171
 
172
    wait until clk = '0';   -- write and read on full, reads first out
173
    data_in <= X"EE";
174
    read <= '1';
175
 
176
    wait until clk = '0';   -- no read or write
177
    data_in <= X"AB";
178
    read <= '0';
179
    write <= '0';
180
 
181
 
182
-- read untill empty
183
 
184
    wait until clk = '0';
185
 
186
    read <= '1';
187
    for i in 0 to 13 loop   -- read out 13 more
188
        wait until clk = '0';
189
    end loop;
190
 
191
    read <= '0';
192
    wait until clk = '0';   --  dont read, 
193
 
194
    read <= '1';
195
    wait until clk = '0';   -- read last - 1 out
196
 
197
 
198
    read <= '0';
199
    wait until clk = '0';   --  dont read, 
200
 
201
    read <= '1';
202
    wait until clk = '0';   -- read last out
203
 
204
 
205
    read <= '0';    -- stop reading
206
 
207
                wait; -- will wait forever
208
        END PROCESS;
209
 
210
-- clock gen process
211
process
212
begin
213
    wait for 1 ns;
214
    clk <= '0';
215
    wait for 1 ns;
216
    clk <= '1';
217
end process;
218
 
219
 
220
END;

powered by: WebSVN 2.1.0

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