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

Subversion Repositories fifo_srl_uni

[/] [fifo_srl_uni/] [trunk/] [fifo_srl_uni.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      : Parametrilayze based on SRL16 shift register FIFO
3
-- Project    : 
4
-------------------------------------------------------------------------------
5
-- File       : fifo_srl_uni.vhd
6
-- Author     : Tomasz Turek  <tomasz.turek@gmail.com>
7
-- Company    : SzuWar INC
8
-- Created    : 13:27:31 14-03-2010
9 5 aTomek1328
-- Last update: 23:23:38 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
-- 13:27:31 14-03-2010   1.0      szuwarek  Created
20
-------------------------------------------------------------------------------
21
 
22
 
23
library IEEE;
24
use IEEE.STD_LOGIC_1164.ALL;
25
use ieee.std_logic_arith.all;
26
use IEEE.STD_LOGIC_UNSIGNED.all;
27
--use ieee.numeric_std.all;
28
 
29
Library UNISIM;
30
use UNISIM.vcomponents.all;
31
 
32
entity fifo_srl_uni is
33
 
34
   generic (
35
      iDataWidth        : integer range 1 to 32   := 17;
36
      ififoWidth        : integer range 1 to 1023 := 32;
37
      iInputReg         : integer range 0 to 2    := 0;
38
      iOutputReg        : integer range 0 to 3    := 2;
39
      iFullFlagOfSet    : integer range 0 to 1021 := 2;
40
      iEmptyFlagOfSet   : integer range 0 to 1021 := 5;
41
      iSizeDelayCounter : integer range 5 to 11   := 6
42
      );
43
 
44
   port (
45
      CLK_I          : in  std_logic;
46
      DATA_I         : in  std_logic_vector(iDataWidth - 1 downto 0);
47
      DATA_O         : out std_logic_vector(iDataWidth - 1 downto 0);
48
      WRITE_ENABLE_I : in  std_logic;
49
      READ_ENABLE_I  : in  std_logic;
50
      READ_VALID_O   : out std_logic;
51
      FIFO_COUNT_O   : out std_logic_vector(iSizeDelayCounter - 1 downto 0);
52
      FULL_FLAG_O    : out std_logic;
53
      EMPTY_FLAG_O   : out std_logic
54
      );
55
 
56
end entity fifo_srl_uni;
57
 
58
architecture fifo_srl_uni_rtl of fifo_srl_uni is
59
 
60
 
61
-------------------------------------------------------------------------------
62
-- functions --
63
-------------------------------------------------------------------------------
64
   function f_srl_count (constant c_fifo_size : integer) return integer is
65
 
66
      variable i_temp  : integer;
67
      variable i_count : integer;
68
 
69
   begin  -- function f_srl_count
70
 
71
      i_temp := c_fifo_size;
72
      i_count := 0;
73
 
74
      for i in 0 to 64 loop
75
 
76
         if i_temp < 1 then
77
 
78
            if i_count = 0 then
79
 
80
               i_count := i;
81
 
82
            else
83
 
84
               i_count := i_count;
85
 
86
            end if;
87
 
88
         else
89
 
90
            i_temp := i_temp - 16;
91
 
92
         end if;
93
 
94
      end loop;  -- i
95
 
96
      return i_count;
97
 
98
   end function f_srl_count;
99
 
100
-------------------------------------------------------------------------------
101
-- constants --
102
-------------------------------------------------------------------------------
103
   constant c_srl_count : integer range 0 to 64 := f_srl_count(ififoWidth);
104
 
105
-------------------------------------------------------------------------------
106
-- types --
107
-------------------------------------------------------------------------------
108
   type type_in_reg    is array (0 to iInputReg - 1)   of std_logic_vector(iDataWidth - 1 downto 0);
109
   type type_out_reg   is array (0 to iOutputReg)      of std_logic_vector(iDataWidth - 1 downto 0);
110
   type type_data_path is array (0 to c_srl_count - 1) of std_logic_vector(iDataWidth - 1 downto 0);
111
   type type_srl_path  is array (0 to c_srl_count)    of std_logic_vector(iDataWidth - 1 downto 0);
112
 
113
-------------------------------------------------------------------------------
114
-- signals --
115
-------------------------------------------------------------------------------
116
   signal v_delay_counter : std_logic_vector(iSizeDelayCounter - 1 downto 0) := (others => '0');
117
   signal v_size_counter  : std_logic_vector(iSizeDelayCounter - 1 downto 0) := (others => '0');
118
   signal v_zeros         : std_logic_vector(iSizeDelayCounter - 1 downto 0) := (others => '0');
119
   signal v_ones          : std_logic_vector(iSizeDelayCounter - 1 downto 0) := (others => '0');
120
   signal v_WRITE_ENABLE  : std_logic_vector(iInputReg downto 0);
121
   signal v_READ_ENABLE   : std_logic_vector(iOutputReg downto 0);
122
   signal i_size_counter  : integer range 0 to 1023 := 0;
123
   signal i_srl_select    : integer range 0 to 64 := 0;
124
   signal i_temp          : integer range 0 to 64;
125
   signal t_mux_in        : type_data_path;
126
   signal t_srl_in        : type_srl_path;
127
   signal t_mux_out       : type_out_reg;
128
   signal t_reg_in        : type_in_reg;
129
   signal one_delay       : std_logic := '0';
130 5 aTomek1328
   signal ce_master       : std_logic;
131
   signal full_capacity   : std_logic;
132
   signal data_valid_off  : std_logic;
133 3 aTomek1328
 
134
begin  -- architecture fifo_srl_uni_r
135
 
136
   v_zeros <= (others => '0');
137
   v_ones  <= (others => '1');
138 5 aTomek1328
-------------------------------------------------------------------------------
139
-- Input Register --
140
-------------------------------------------------------------------------------
141 3 aTomek1328
   GR0: if iInputReg = 0 generate
142
 
143
      t_srl_in(0) <= DATA_I;
144
      v_WRITE_ENABLE(0) <= WRITE_ENABLE_I;
145
 
146
   end generate GR0;
147
 
148
   GR1: if iInputReg = 1 generate
149
 
150
      t_srl_in(0) <= t_reg_in(0);
151
      v_WRITE_ENABLE(1) <= WRITE_ENABLE_I;
152
 
153
      P1: process (CLK_I) is
154
      begin  -- process P1
155
 
156
         if rising_edge(CLK_I) then
157
 
158
            t_reg_in(0) <= DATA_I;
159
            v_WRITE_ENABLE(0) <= v_WRITE_ENABLE(1);
160
 
161
         end if;
162
 
163
      end process P1;
164
 
165
   end generate GR1;
166
 
167
   GR2: if iInputReg = 2 generate
168
 
169
      t_srl_in(0) <= t_reg_in(0);
170
      v_WRITE_ENABLE(2) <= WRITE_ENABLE_I;
171
 
172
      P1: process (CLK_I) is
173
      begin  -- process P1
174
 
175
         if rising_edge(CLK_I) then
176
 
177
            t_reg_in(1) <= DATA_I;
178
            t_reg_in(0) <= t_reg_in(1);
179
            v_WRITE_ENABLE(1 downto 0) <= v_WRITE_ENABLE(2 downto 1);
180
 
181
         end if;
182
 
183
      end process P1;
184
 
185
   end generate GR2;
186 5 aTomek1328
-------------------------------------------------------------------------------
187
-- Input Register --
188
-------------------------------------------------------------------------------
189
 
190
-------------------------------------------------------------------------------
191
-- FIFO Core, SRL16E based --
192
-------------------------------------------------------------------------------
193 3 aTomek1328
   G1: for i in 0 to c_srl_count - 1 generate
194
 
195
      G0: for j in 0 to iDataWidth - 1 generate
196
 
197
         SRLC16_inst : SRLC16E
198
            port map
199
            (
200
                  Q => t_mux_in(i)(j), -- SRL data output
201
                  Q15 => t_srl_in(i+1)(j), -- Carry output (connect to next SRL)
202
                  A0 => v_delay_counter(0), -- Select[0] input
203
                  A1 => v_delay_counter(1), -- Select[1] input
204
                  A2 => v_delay_counter(2), -- Select[2] input
205
                  A3 => v_delay_counter(3), -- Select[3] input
206 5 aTomek1328
                  CE => ce_master, -- Clock enable input
207 3 aTomek1328
                  CLK => CLK_I, -- Clock input
208
                  D => t_srl_in(i)(j) -- SRL data input
209
                  );
210
 
211
      end generate G0;
212
 
213
   end generate G1;
214 5 aTomek1328
-------------------------------------------------------------------------------
215
-- FIFO Core, SRL16E based --
216
-------------------------------------------------------------------------------
217
 
218 3 aTomek1328
   i_srl_select <= conv_integer((v_delay_counter(iSizeDelayCounter - 1 downto 4)));
219
   i_size_counter <= conv_integer(v_size_counter);
220 5 aTomek1328
   ce_master <= v_WRITE_ENABLE(0) and (not full_capacity);
221
 
222 3 aTomek1328
   P0: process (CLK_I) is
223
   begin  -- process P0
224
 
225
      if rising_edge(CLK_I) then
226
 
227 5 aTomek1328
         if (v_WRITE_ENABLE(0) = '1') and (READ_ENABLE_I = '0') and (i_size_counter < ififoWidth) then
228 3 aTomek1328
 
229
            if one_delay = '1' then
230
 
231
               v_delay_counter <= v_delay_counter + 1;
232
               one_delay <= '1';
233
 
234
            else
235
 
236
               one_delay <= '1';
237
               v_delay_counter <= v_delay_counter;
238
 
239
            end if;
240
 
241
            v_size_counter <= v_size_counter + 1;
242
 
243 5 aTomek1328
         elsif (v_WRITE_ENABLE(0) = '0') and (READ_ENABLE_I = '1') and (i_size_counter > 0) then
244 3 aTomek1328
 
245
            if v_delay_counter = v_zeros then
246
 
247
               one_delay <= '0';
248
 
249
            else
250
 
251
               one_delay <= '1';
252
               v_delay_counter <= v_delay_counter - 1;
253
 
254
            end if;
255
 
256 5 aTomek1328
            v_size_counter <= v_size_counter - 1;
257 3 aTomek1328
 
258
         else
259
 
260
            v_delay_counter <= v_delay_counter;
261
            v_size_counter <= v_size_counter;
262
            one_delay <= one_delay;
263
 
264
         end if;
265 5 aTomek1328
 
266
         if i_size_counter = 0 then
267
 
268
            data_valid_off <= '1';
269
 
270
         else
271
 
272
            data_valid_off <= '0';
273
 
274
         end if;
275 3 aTomek1328
 
276
      end if;
277
 
278
   end process P0;
279
 
280 5 aTomek1328
   full_capacity <= '0' when i_size_counter < ififoWidth else '1';
281
-------------------------------------------------------------------------------
282
-- Output Register --
283
-------------------------------------------------------------------------------
284 3 aTomek1328
   t_mux_out(0) <= t_mux_in(i_srl_select);
285 5 aTomek1328
   READ_VALID_O <= v_READ_ENABLE(0) and (not data_valid_off);
286 3 aTomek1328
   FIFO_COUNT_O <= v_size_counter;
287 5 aTomek1328
 
288 3 aTomek1328
 
289
   GM0: if iOutputReg = 0 generate
290
 
291
      DATA_O <= t_mux_out(0);
292
      v_READ_ENABLE(0) <= READ_ENABLE_I;
293
 
294
   end generate GM0;
295
 
296
 
297
   GM1: if iOutputReg = 1 generate
298
 
299
      DATA_O <= t_mux_out(1);
300
      v_READ_ENABLE(1) <= READ_ENABLE_I;
301
 
302
      P2: process (CLK_I) is
303
      begin  -- process P2
304
 
305
         if rising_edge(CLK_I) then
306
 
307
            v_READ_ENABLE(0) <= v_READ_ENABLE(1);
308
            t_mux_out(1) <= t_mux_out(0);
309
 
310
         end if;
311
 
312
      end process P2;
313
 
314
   end generate GM1;
315
 
316
   GM2: if iOutputReg > 1 generate
317
 
318
      DATA_O <= t_mux_out(iOutputReg);
319
      v_READ_ENABLE(iOutputReg) <= READ_ENABLE_I;
320
 
321
      P2: process (CLK_I) is
322
      begin  -- process P2
323
 
324
         if rising_edge(CLK_I) then
325
 
326
            v_READ_ENABLE(iOutputReg - 1 downto 0) <= v_READ_ENABLE(iOutputReg downto 1);
327
            t_mux_out(1 to iOutputReg) <= t_mux_out(0 to iOutputReg - 1);
328
 
329
         end if;
330
 
331
      end process P2;
332
 
333
   end generate GM2;
334 5 aTomek1328
-------------------------------------------------------------------------------
335
-- Output Register --
336
-------------------------------------------------------------------------------
337 3 aTomek1328
 
338 5 aTomek1328
-------------------------------------------------------------------------------
339
-- Flag Generators --
340
-------------------------------------------------------------------------------
341
   EMPTY_FLAG_O <= '0' when (i_size_counter)> iEmptyFlagOfSet             else '1';
342
   FULL_FLAG_O  <= '1' when i_size_counter >= ififoWidth - iFullFlagOfSet else '0';
343
-------------------------------------------------------------------------------
344
-- Flag Generators --
345
-------------------------------------------------------------------------------
346 3 aTomek1328
 
347
end architecture fifo_srl_uni_rtl;
348
 

powered by: WebSVN 2.1.0

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