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

Subversion Repositories the_wizardry_project

[/] [the_wizardry_project/] [trunk/] [Wizardry/] [VHDL/] [Wizardry Top Level/] [Address Generation/] [JOP/] [fifo.vhd] - Blame information for rev 22

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 22 mcwaccent
--
2
--
3
--  This file is a part of JOP, the Java Optimized Processor
4
--
5
--  Copyright (C) 2001-2008, Martin Schoeberl (martin@jopdesign.com)
6
--
7
--  This program is free software: you can redistribute it and/or modify
8
--  it under the terms of the GNU General Public License as published by
9
--  the Free Software Foundation, either version 3 of the License, or
10
--  (at your option) any later version.
11
--
12
--  This program is distributed in the hope that it will be useful,
13
--  but WITHOUT ANY WARRANTY; without even the implied warranty of
14
--  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15
--  GNU General Public License for more details.
16
--
17
--  You should have received a copy of the GNU General Public License
18
--  along with this program.  If not, see <http://www.gnu.org/licenses/>.
19
--
20
 
21
 
22
--
23
--      fifo.vhd
24
--
25
--      simple fifo
26
--
27
--      uses FF and every rd or wr has to 'bubble' through the hole fifo.
28
--      
29
--      Author: Martin Schoeberl        martin.schoeberl@chello.at
30
--
31
--
32
--      resources on ACEX1K
33
--
34
--              (width+2)*depth-1 LCs
35
--
36
--
37
--      2002-01-06      first working version
38
--      2002-11-03      a signal for reaching threshold
39
--      2005-02-20      change entity order for modelsim vcom
40
--
41
 
42
library ieee;
43
use ieee.std_logic_1164.all;
44
 
45
entity fifo_elem is
46
 
47
generic (width : integer);
48
port (
49
        clk             : in std_logic;
50
        reset   : in std_logic;
51
 
52
        din             : in std_logic_vector(width-1 downto 0);
53
        dout    : out std_logic_vector(width-1 downto 0);
54
 
55
        rd              : in std_logic;
56
        wr              : in std_logic;
57
 
58
        rd_prev : out std_logic;
59
        full    : out std_logic
60
);
61
end fifo_elem;
62
 
63
architecture rtl of fifo_elem is
64
 
65
        signal buf              : std_logic_vector(width-1 downto 0);
66
        signal f                : std_logic;
67
 
68
begin
69
 
70
        dout <= buf;
71
 
72
process(clk, reset, f)
73
 
74
begin
75
 
76
        full <= f;
77
 
78
        if (reset='1') then
79
 
80
                buf <= (others => '0');
81
                f <= '0';
82
                rd_prev <= '0';
83
 
84
        elsif rising_edge(clk) then
85
 
86
                rd_prev <= '0';
87
                if f='0' then
88
                        if wr='1' then
89
                                rd_prev <= '1';
90
                                buf <= din;
91
                                f <= '1';
92
                        end if;
93
                else
94
                        if rd='1' then
95
                                f <= '0';
96
                        end if;
97
                end if;
98
 
99
        end if;
100
 
101
end process;
102
 
103
end rtl;
104
 
105
library ieee;
106
use ieee.std_logic_1164.all;
107
 
108
entity fifo is
109
 
110
generic (width : integer := 8; depth : integer := 4; thres : integer := 2);
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
        empty   : out std_logic;
122
        full    : out std_logic;
123
        half    : out std_logic
124
);
125
end fifo ;
126
 
127
architecture rtl of fifo is
128
 
129
component fifo_elem is
130
 
131
generic (width : integer);
132
port (
133
        clk             : in std_logic;
134
        reset   : in std_logic;
135
 
136
        din             : in std_logic_vector(width-1 downto 0);
137
        dout    : out std_logic_vector(width-1 downto 0);
138
 
139
        rd              : in std_logic;
140
        wr              : in std_logic;
141
 
142
        rd_prev : out std_logic;
143
        full    : out std_logic
144
);
145
end component;
146
 
147
        signal r, w, rp, f      : std_logic_vector(depth-1 downto 0);
148
        type d_array is array (0 to depth-1) of std_logic_vector(width-1 downto 0);
149
        signal di, do           : d_array;
150
 
151
 
152
 
153
begin
154
 
155
 
156
        g1: for i in 0 to depth-1 generate
157
 
158
                f1: fifo_elem generic map (width)
159
                        port map (clk, reset, di(i), do(i), r(i), w(i), rp(i), f(i));
160
 
161
                x: if i<depth-1 generate
162
                        r(i) <= rp(i+1);
163
                        w(i+1) <= f(i);
164
                        di(i+1) <= do(i);
165
                end generate;
166
 
167
        end generate;
168
 
169
        di(0) <= din;
170
        dout <= do(depth-1);
171
        w(0) <= wr;
172
        r(depth-1) <= rd;
173
 
174
        full <= f(0);
175
        half <= f(depth-thres);
176
        empty <= not f(depth-1);
177
 
178
end rtl;
179
 

powered by: WebSVN 2.1.0

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