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

Subversion Repositories srl_fifo

[/] [srl_fifo/] [branches/] [avendor/] [rtl/] [tb_srl_fifo_32.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_32_vhd IS
67
END tb_srl_fifo_32_vhd;
68
 
69
ARCHITECTURE behavior OF tb_srl_fifo_32_vhd IS
70
 
71
constant width_tb : integer := 8;
72
 
73
        -- Component Declaration for the Unit Under Test (UUT)
74
        COMPONENT srl_fifo_32
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_32
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
 
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';   -- 10
170
    data_in <= X"10";
171
    wait until clk = '0';   -- 11
172
    data_in <= X"11";
173
    wait until clk = '0';   -- 12
174
    data_in <= X"12";
175
    wait until clk = '0';   -- 13
176
    data_in <= X"13";
177
    wait until clk = '0';   -- 14
178
    data_in <= X"14";
179
    wait until clk = '0';   -- 15
180
    data_in <= X"15";
181
    wait until clk = '0';   -- 16
182
    data_in <= X"16";
183
    wait until clk = '0';   -- 17
184
    data_in <= X"17";
185
    wait until clk = '0';   -- 18
186
    data_in <= X"18";
187
    wait until clk = '0';   -- 19
188
    data_in <= X"19";
189
    wait until clk = '0';   -- 1A
190
    data_in <= X"1A";
191
    wait until clk = '0';   -- 1B
192
    data_in <= X"1B";
193
    wait until clk = '0';   -- 1C
194
    data_in <= X"1C";
195
    wait until clk = '0';   -- 1D
196
    data_in <= X"1D";
197
    wait until clk = '0';   -- 1E
198
    data_in <= X"1E";
199
    wait until clk = '0';   -- 1F
200
    data_in <= X"1F";
201
 
202
    wait until clk = '0';   -- no write
203
    data_in <= X"FF";
204
 
205
    wait until clk = '0';   -- write and read on full, reads first out
206
    data_in <= X"EE";
207
    read <= '1';
208
 
209
    wait until clk = '0';   -- no read or write
210
    data_in <= X"AB";
211
    read <= '0';
212
    write <= '0';
213
 
214
 
215
-- read untill empty
216
 
217
    wait until clk = '0';
218
 
219
    read <= '1';
220
    for i in 0 to 29 loop   -- read out 30 more
221
        wait until clk = '0';
222
    end loop;
223
 
224
    read <= '0';
225
    wait until clk = '0';   --  dont read, 
226
 
227
    read <= '1';
228
    wait until clk = '0';   -- read last - 1 out
229
 
230
 
231
    read <= '0';
232
    wait until clk = '0';   --  dont read, 
233
 
234
    read <= '1';
235
    wait until clk = '0';   -- read last out
236
 
237
 
238
    read <= '0';    -- stop reading
239
 
240
                wait; -- will wait forever
241
        END PROCESS;
242
 
243
-- clock gen process
244
process
245
begin
246
    wait for 1 ns;
247
    clk <= '0';
248
    wait for 1 ns;
249
    clk <= '1';
250
end process;
251
 
252
 
253
 
254
END;

powered by: WebSVN 2.1.0

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