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 5

Go to most recent revision | 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 5 aTomek1328
-- Last update: 23:36:11 20-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
            iInputReg         : integer range 0 to 2    := 0;
42
            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 5 aTomek1328
   constant ififoWidth        : integer := 8;
67 3 aTomek1328
   constant iInputReg         : integer := 0;
68
   constant iOutputReg        : integer := 1;
69 5 aTomek1328
   constant iFullFlagOfSet    : integer := 0;
70
   constant iEmptyFlagOfSet   : integer := 0;
71
   constant iSizeDelayCounter : integer := 5;
72 3 aTomek1328
 
73 5 aTomek1328
   constant iWriteDataCounter : integer := 10;
74
   constant iReadDataCounter  : integer := 13;
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
 
158
                  v_count <= v_count + 1;
159
 
160
               end if;
161
 
162
            when x"0002" =>
163
 
164
               DATA_I <= x"0000";
165
               WRITE_ENABLE_I <= '0';
166
               READ_ENABLE_I <= '0';
167
               v_count <= v_count + 1;
168
 
169 3 aTomek1328
            when x"0003" =>
170
 
171
               DATA_I <= x"0010";
172
               WRITE_ENABLE_I <= '1';
173
               READ_ENABLE_I <= '0';
174
               v_count <= v_count + 1;
175
 
176
            when x"0004" =>
177
 
178
               DATA_I <= x"0200";
179
               WRITE_ENABLE_I <= '1';
180
               READ_ENABLE_I <= '0';
181
               v_count <= v_count + 1;
182
 
183
            when x"0005" =>
184
 
185
               DATA_I <= x"0100";
186
               WRITE_ENABLE_I <= '1';
187
               READ_ENABLE_I <= '0';
188
               v_count <= v_count + 1;
189
 
190
            when x"0006" =>
191
 
192
               DATA_I <= x"0000";
193
               WRITE_ENABLE_I <= '0';
194
               READ_ENABLE_I <= '0';
195
               v_count <= v_count + 1;
196
 
197
            when x"0007" =>
198
 
199
               DATA_I <= x"0000";
200
               WRITE_ENABLE_I <= '0';
201 5 aTomek1328
               READ_ENABLE_I <= '0';
202 3 aTomek1328
               v_count <= v_count + 1;
203
 
204
            when x"0008" =>
205
 
206
               DATA_I <= x"0000";
207
               WRITE_ENABLE_I <= '0';
208
               READ_ENABLE_I <= '0';
209
               v_count <= v_count + 1;
210 5 aTomek1328
 
211
            when x"0010" =>
212
 
213
               if (iReadDataCounter + 1) > i_count_read then
214
 
215
                  DATA_I <= DATA_I;
216
                  WRITE_ENABLE_I <= '0';
217
                  READ_ENABLE_I <= '1';
218
                  i_count_read <= i_count_read + 1;
219
 
220
               else
221
 
222
                  v_count <= v_count + 1;
223
 
224
               end if;
225
 
226
            when x"0011" =>
227
 
228
               DATA_I <= x"0000";
229
               WRITE_ENABLE_I <= '0';
230
               READ_ENABLE_I <= '0';
231
               v_count <= v_count + 1;
232 3 aTomek1328
 
233
            when others =>
234
 
235
               WRITE_ENABLE_I <= WRITE_ENABLE_I;
236
               READ_ENABLE_I <= READ_ENABLE_I;
237
               v_count <= v_count + 1;
238
 
239
         end case;
240
 
241
      end if;
242
 
243
   end process T0;
244
 
245
end architecture testbench;

powered by: WebSVN 2.1.0

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