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

Subversion Repositories rise

[/] [rise/] [trunk/] [vhdl/] [fifo.vhd] - Blame information for rev 151

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 115 trinklhar
--
2
--      fifo.vhd
3
--
4
--      simple fifo
5
--
6
--      uses FF and every rd or wr has to 'bubble' through the hole fifo.
7
--      
8
--      Author: Martin Schoeberl        martin.schoeberl@chello.at
9
--
10
--
11
--      resources on ACEX1K
12
--
13
--              (width+2)*depth-1 LCs
14
--
15
--
16
--      2002-01-06      first working version
17
--      2002-11-03      a signal for reaching threshold
18
--      2005-02-20      change entity order for modelsim vcom
19
--
20
 
21
library ieee;
22
use ieee.std_logic_1164.all;
23
 
24
entity fifo_elem is
25
 
26
generic (width : integer);
27
port (
28
        clk             : in std_logic;
29
        reset   : in std_logic;
30
 
31
        din             : in std_logic_vector(width-1 downto 0);
32
        dout    : out std_logic_vector(width-1 downto 0);
33
 
34
        rd              : in std_logic;
35
        wr              : in std_logic;
36
 
37
        rd_prev : out std_logic;
38
        full    : out std_logic
39
);
40
end fifo_elem;
41
 
42
architecture rtl of fifo_elem is
43
 
44
        signal buf              : std_logic_vector(width-1 downto 0);
45
        signal f                : std_logic;
46
 
47
begin
48
 
49
        dout <= buf;
50
 
51
process(clk, reset, f)
52
 
53
begin
54
 
55
        full <= f;
56
 
57 131 jlechner
        if (reset='0') then
58 115 trinklhar
 
59
                buf <= (others => '0');
60
                f <= '0';
61
                rd_prev <= '0';
62
 
63
        elsif rising_edge(clk) then
64
 
65
                rd_prev <= '0';
66
                if f='0' then
67
                        if wr='1' then
68
                                rd_prev <= '1';
69
                                buf <= din;
70
                                f <= '1';
71
                        end if;
72
                else
73
                        if rd='1' then
74
                                f <= '0';
75
                        end if;
76
                end if;
77
 
78
        end if;
79
 
80
end process;
81
 
82
end rtl;
83
 
84
library ieee;
85
use ieee.std_logic_1164.all;
86
 
87
entity fifo is
88
 
89
generic (width : integer := 8; depth : integer := 4; thres : integer := 2);
90
port (
91
        clk             : in std_logic;
92
        reset   : in std_logic;
93
 
94
        din             : in std_logic_vector(width-1 downto 0);
95
        dout    : out std_logic_vector(width-1 downto 0);
96
 
97
        rd              : in std_logic;
98
        wr              : in std_logic;
99
 
100
        empty   : out std_logic;
101
        full    : out std_logic;
102
        half    : out std_logic
103
);
104
end fifo ;
105
 
106
architecture rtl of fifo is
107
 
108
component fifo_elem is
109
 
110
generic (width : integer);
111
port (
112
        clk             : in std_logic;
113
        reset   : in std_logic;
114
 
115
        din             : in std_logic_vector(width-1 downto 0);
116
        dout    : out std_logic_vector(width-1 downto 0);
117
 
118
        rd              : in std_logic;
119
        wr              : in std_logic;
120
 
121
        rd_prev : out std_logic;
122
        full    : out std_logic
123
);
124
end component;
125
 
126
        signal r, w, rp, f      : std_logic_vector(depth-1 downto 0);
127
        type d_array is array (0 to depth-1) of std_logic_vector(width-1 downto 0);
128
        signal di, do           : d_array;
129
 
130
 
131
 
132
begin
133
 
134
 
135
        g1: for i in 0 to depth-1 generate
136
 
137
                f1: fifo_elem generic map (width)
138
                        port map (clk, reset, di(i), do(i), r(i), w(i), rp(i), f(i));
139
 
140
                x: if i<depth-1 generate
141
                        r(i) <= rp(i+1);
142
                        w(i+1) <= f(i);
143
                        di(i+1) <= do(i);
144
                end generate;
145
 
146
        end generate;
147
 
148
        di(0) <= din;
149
        dout <= do(depth-1);
150
        w(0) <= wr;
151
        r(depth-1) <= rd;
152
 
153
        full <= f(0);
154
        half <= f(depth-thres);
155
        empty <= not f(depth-1);
156
 
157
end rtl;
158
 

powered by: WebSVN 2.1.0

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