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

Subversion Repositories fifo_srl_uni

[/] [fifo_srl_uni/] [trunk/] [tb_fifo_srl_uni_1.vhd] - Blame information for rev 6

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 3 aTomek1328
-------------------------------------------------------------------------------
2
-- Title      : Testbench for fifo_srl_uni.vhd
3
-- Project    : 
4
-------------------------------------------------------------------------------
5
-- File       : tb_fifo_srl_uni_1.vhd
6
-- Author     : Tomasz Turek  <tomasz.turek@gmail.com>
7
-- Company    : SzuWar INC
8
-- Created    : 09:45:13 16-03-2010
9 6 aTomek1328
-- Last update: 14:49:11 21-03-2010
10 3 aTomek1328
-- Platform   : Xilinx ISE 10.1.03
11
-- Standard   : VHDL'93
12
-------------------------------------------------------------------------------
13
-- Description: 
14
-------------------------------------------------------------------------------
15
-- Copyright (c) 2010 SzuWar INC
16
-------------------------------------------------------------------------------
17
-- Revisions  :
18
-- Date                  Version  Author  Description
19
-- 09:45:13 16-03-2010   1.0      szuwarek  Created
20
-------------------------------------------------------------------------------
21
 
22
library ieee;
23
use ieee.std_logic_1164.all;
24
use ieee.std_logic_unsigned.all;
25
use ieee.numeric_std.all;
26
 
27
 
28 5 aTomek1328
entity tb_fifo_srl_uni_1 is
29 3 aTomek1328
end entity tb_fifo_srl_uni_1;
30
 
31
architecture testbench of tb_fifo_srl_uni_1 is
32
 
33
-------------------------------------------------------------------------------
34
-- Unit Under Test --
35
-------------------------------------------------------------------------------
36
   component fifo_srl_uni is
37
 
38
      generic (
39
            iDataWidth        : integer range 1 to 32   := 17;
40
            ififoWidth        : integer range 1 to 1023 := 33;
41 6 aTomek1328
            iInputReg         : integer range 0 to 3    := 0;
42 3 aTomek1328
            iOutputReg        : integer range 0 to 3    := 2;
43
            iFullFlagOfSet    : integer range 0 to 1021 := 2;
44
            iEmptyFlagOfSet   : integer range 0 to 1021 := 5;
45
            iSizeDelayCounter : integer range 5 to 11   := 6
46
            );
47
 
48
      port (
49
            CLK_I          : in  std_logic;
50
            DATA_I         : in  std_logic_vector(iDataWidth - 1 downto 0);
51
            DATA_O         : out std_logic_vector(iDataWidth - 1 downto 0);
52
            WRITE_ENABLE_I : in  std_logic;
53
            READ_ENABLE_I  : in  std_logic;
54
            READ_VALID_O   : out std_logic;
55
            FIFO_COUNT_O   : out std_logic_vector(iSizeDelayCounter - 1 downto 0);
56
            FULL_FLAG_O    : out std_logic;
57
            EMPTY_FLAG_O   : out std_logic
58
            );
59
 
60
   end component fifo_srl_uni;
61
 
62
-------------------------------------------------------------------------------
63
-- constants --
64
-------------------------------------------------------------------------------
65
   constant iDataWidth        : integer := 16;
66 6 aTomek1328
   constant ififoWidth        : integer := 33;
67
   constant iInputReg         : integer := 3;
68
   constant iOutputReg        : integer := 3;
69 5 aTomek1328
   constant iFullFlagOfSet    : integer := 0;
70
   constant iEmptyFlagOfSet   : integer := 0;
71 6 aTomek1328
   constant iSizeDelayCounter : integer := 6;
72 3 aTomek1328
 
73 6 aTomek1328
   constant iWriteDataCounter : integer := 22;
74
   constant iReadDataCounter  : integer := 33;
75 3 aTomek1328
 
76
-------------------------------------------------------------------------------
77
-- signals --
78
-------------------------------------------------------------------------------
79
   -- IN --
80
   signal CLK_I          : std_logic := '0';
81
   signal WRITE_ENABLE_I : std_logic := '0';
82
   signal READ_ENABLE_I  : std_logic := '0';
83
   signal DATA_I         : std_logic_vector(iDataWidth - 1 downto 0) := (others => '0');
84
 
85
   -- OUT --
86
   signal DATA_O       : std_logic_vector(iDataWidth - 1 downto 0);
87
   signal READ_VALID_O : std_logic;
88
   signal FULL_FLAG_O  : std_logic;
89
   signal EMPTY_FLAG_O : std_logic;
90
   signal FIFO_COUNT_O : std_logic_vector(iSizeDelayCounter - 1 downto 0);
91
 
92
   -- others --
93
   signal v_count       : std_logic_vector(15 downto 0) := x"0000";
94 5 aTomek1328
   signal i_count_write : integer := 0;
95
   signal i_count_read : integer := 0;
96 3 aTomek1328
 
97
begin  -- architecture testbench
98
 
99
 
100
   UUT: fifo_srl_uni
101
 
102
      generic map (
103
            iDataWidth        => iDataWidth,
104
            ififoWidth        => ififoWidth,
105
            iInputReg         => iInputReg,
106
            iOutputReg        => iOutputReg,
107
            iFullFlagOfSet    => iFullFlagOfSet,
108
            iEmptyFlagOfSet   => iEmptyFlagOfSet,
109
            iSizeDelayCounter => iSizeDelayCounter
110
            )
111
 
112
      port map(
113
            CLK_I          => CLK_I,
114
            DATA_I         => DATA_I,
115
            DATA_O         => DATA_O,
116
            WRITE_ENABLE_I => WRITE_ENABLE_I,
117
            READ_ENABLE_I  => READ_ENABLE_I,
118
            READ_VALID_O   => READ_VALID_O,
119
            FIFO_COUNT_O   => FIFO_COUNT_O,
120
            FULL_FLAG_O    => FULL_FLAG_O,
121
            EMPTY_FLAG_O   => EMPTY_FLAG_O
122
            );
123
 
124
   StimulationProcess : process
125
 
126
   begin
127
 
128
      for i in 0 to 1000000 loop
129
 
130
         CLK_I <= not CLK_I;
131
 
132
         wait for 5 ns;
133
 
134
      end loop;
135
 
136
      wait;
137
 
138
   end process StimulationProcess;
139
 
140
   T0: process (CLK_I) is
141
   begin  -- process T0
142
 
143
      if rising_edge(CLK_I) then
144
 
145
         case v_count is
146
 
147 5 aTomek1328
            when x"0001" =>
148
 
149
               if (iWriteDataCounter + 1) > i_count_write then
150
 
151
                  DATA_I <= DATA_I + 1;
152
                  WRITE_ENABLE_I <= '1';
153
                  READ_ENABLE_I <= '0';
154
                  i_count_write <= i_count_write + 1;
155
 
156
               else
157 6 aTomek1328
 
158
                  DATA_I <= DATA_I;
159
                  WRITE_ENABLE_I <= '0';
160
                  READ_ENABLE_I <= '0';
161 5 aTomek1328
                  v_count <= v_count + 1;
162
 
163
               end if;
164
 
165
            when x"0002" =>
166
 
167
               DATA_I <= x"0000";
168
               WRITE_ENABLE_I <= '0';
169
               READ_ENABLE_I <= '0';
170
               v_count <= v_count + 1;
171
 
172 3 aTomek1328
            when x"0003" =>
173
 
174
               DATA_I <= x"0010";
175
               WRITE_ENABLE_I <= '1';
176
               READ_ENABLE_I <= '0';
177
               v_count <= v_count + 1;
178
 
179
            when x"0004" =>
180
 
181
               DATA_I <= x"0200";
182
               WRITE_ENABLE_I <= '1';
183
               READ_ENABLE_I <= '0';
184
               v_count <= v_count + 1;
185
 
186
            when x"0005" =>
187
 
188
               DATA_I <= x"0100";
189
               WRITE_ENABLE_I <= '1';
190 6 aTomek1328
               READ_ENABLE_I <= '1';
191 3 aTomek1328
               v_count <= v_count + 1;
192
 
193
            when x"0006" =>
194
 
195
               DATA_I <= x"0000";
196
               WRITE_ENABLE_I <= '0';
197
               READ_ENABLE_I <= '0';
198
               v_count <= v_count + 1;
199
 
200
            when x"0007" =>
201
 
202
               DATA_I <= x"0000";
203
               WRITE_ENABLE_I <= '0';
204 5 aTomek1328
               READ_ENABLE_I <= '0';
205 3 aTomek1328
               v_count <= v_count + 1;
206
 
207
            when x"0008" =>
208
 
209
               DATA_I <= x"0000";
210
               WRITE_ENABLE_I <= '0';
211
               READ_ENABLE_I <= '0';
212
               v_count <= v_count + 1;
213 5 aTomek1328
 
214
            when x"0010" =>
215
 
216
               if (iReadDataCounter + 1) > i_count_read then
217
 
218
                  DATA_I <= DATA_I;
219
                  WRITE_ENABLE_I <= '0';
220
                  READ_ENABLE_I <= '1';
221
                  i_count_read <= i_count_read + 1;
222
 
223
               else
224
 
225
                  v_count <= v_count + 1;
226
 
227
               end if;
228
 
229
            when x"0011" =>
230
 
231
               DATA_I <= x"0000";
232
               WRITE_ENABLE_I <= '0';
233
               READ_ENABLE_I <= '0';
234
               v_count <= v_count + 1;
235 3 aTomek1328
 
236
            when others =>
237
 
238
               WRITE_ENABLE_I <= WRITE_ENABLE_I;
239
               READ_ENABLE_I <= READ_ENABLE_I;
240
               v_count <= v_count + 1;
241
 
242
         end case;
243
 
244
      end if;
245
 
246
   end process T0;
247
 
248
end architecture testbench;

powered by: WebSVN 2.1.0

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