1 |
36 |
wfjm |
-- $Id: memlib.vhd 751 2016-03-25 19:46:11Z mueller $
|
2 |
2 |
wfjm |
--
|
3 |
36 |
wfjm |
-- Copyright 2006-2016 by Walter F.J. Mueller <W.F.J.Mueller@gsi.de>
|
4 |
2 |
wfjm |
--
|
5 |
|
|
-- This program is free software; you may redistribute and/or modify it under
|
6 |
|
|
-- the terms of the GNU General Public License as published by the Free
|
7 |
|
|
-- Software Foundation, either version 2, or at your option any later version.
|
8 |
|
|
--
|
9 |
|
|
-- This program is distributed in the hope that it will be useful, but
|
10 |
|
|
-- WITHOUT ANY WARRANTY, without even the implied warranty of MERCHANTABILITY
|
11 |
|
|
-- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
12 |
|
|
-- for complete details.
|
13 |
|
|
--
|
14 |
|
|
------------------------------------------------------------------------------
|
15 |
|
|
-- Package Name: memlib
|
16 |
|
|
-- Description: Basic memory components: single/dual port synchronous and
|
17 |
|
|
-- asynchronus rams; Fifo's.
|
18 |
|
|
--
|
19 |
|
|
-- Dependencies: -
|
20 |
36 |
wfjm |
-- Tool versions: ise 8.2-14.7; viv 2014.4-2015.4; ghdl 0.18-0.33
|
21 |
2 |
wfjm |
-- Revision History:
|
22 |
|
|
-- Date Rev Version Comment
|
23 |
36 |
wfjm |
-- 2016-03-25 751 1.1 add fifo_2c_dram2
|
24 |
2 |
wfjm |
-- 2008-03-08 123 1.0.3 add ram_2swsr_xfirst_gen_unisim
|
25 |
|
|
-- 2008-03-02 122 1.0.2 change generic default for BRAM models
|
26 |
|
|
-- 2007-12-27 106 1.0.1 add fifo_2c_dram
|
27 |
|
|
-- 2007-06-03 45 1.0 Initial version
|
28 |
|
|
------------------------------------------------------------------------------
|
29 |
|
|
|
30 |
|
|
library ieee;
|
31 |
|
|
use ieee.std_logic_1164.all;
|
32 |
|
|
|
33 |
|
|
use work.slvtypes.all;
|
34 |
|
|
|
35 |
|
|
package memlib is
|
36 |
|
|
|
37 |
|
|
component ram_1swar_gen is -- RAM, 1 sync w asyn r port
|
38 |
|
|
generic (
|
39 |
|
|
AWIDTH : positive := 4; -- address port width
|
40 |
|
|
DWIDTH : positive := 16); -- data port width
|
41 |
|
|
port (
|
42 |
|
|
CLK : in slbit; -- clock
|
43 |
|
|
WE : in slbit; -- write enable
|
44 |
|
|
ADDR : in slv(AWIDTH-1 downto 0); -- address port
|
45 |
|
|
DI : in slv(DWIDTH-1 downto 0); -- data in port
|
46 |
|
|
DO : out slv(DWIDTH-1 downto 0) -- data out port
|
47 |
|
|
);
|
48 |
|
|
end component;
|
49 |
|
|
|
50 |
|
|
component ram_1swar_1ar_gen is -- RAM, 1 sync w asyn r + 1 asyn r port
|
51 |
|
|
generic (
|
52 |
|
|
AWIDTH : positive := 4; -- address port width
|
53 |
|
|
DWIDTH : positive := 16); -- data port width
|
54 |
|
|
port (
|
55 |
|
|
CLK : in slbit; -- clock
|
56 |
|
|
WE : in slbit; -- write enable (port A)
|
57 |
|
|
ADDRA : in slv(AWIDTH-1 downto 0); -- address port A
|
58 |
|
|
ADDRB : in slv(AWIDTH-1 downto 0); -- address port B
|
59 |
|
|
DI : in slv(DWIDTH-1 downto 0); -- data in (port A)
|
60 |
|
|
DOA : out slv(DWIDTH-1 downto 0); -- data out port A
|
61 |
|
|
DOB : out slv(DWIDTH-1 downto 0) -- data out port B
|
62 |
|
|
);
|
63 |
|
|
end component;
|
64 |
|
|
|
65 |
|
|
component ram_1swsr_wfirst_gen is -- RAM, 1 sync r/w ports, write first
|
66 |
|
|
generic (
|
67 |
|
|
AWIDTH : positive := 10; -- address port width
|
68 |
|
|
DWIDTH : positive := 16); -- data port width
|
69 |
|
|
port(
|
70 |
|
|
CLK : in slbit; -- clock
|
71 |
|
|
EN : in slbit; -- enable
|
72 |
|
|
WE : in slbit; -- write enable
|
73 |
|
|
ADDR : in slv(AWIDTH-1 downto 0); -- address port
|
74 |
|
|
DI : in slv(DWIDTH-1 downto 0); -- data in port
|
75 |
|
|
DO : out slv(DWIDTH-1 downto 0) -- data out port
|
76 |
|
|
);
|
77 |
|
|
end component;
|
78 |
|
|
|
79 |
|
|
component ram_1swsr_rfirst_gen is -- RAM, 1 sync r/w ports, read first
|
80 |
|
|
generic (
|
81 |
|
|
AWIDTH : positive := 11; -- address port width
|
82 |
|
|
DWIDTH : positive := 9); -- data port width
|
83 |
|
|
port(
|
84 |
|
|
CLK : in slbit; -- clock
|
85 |
|
|
EN : in slbit; -- enable
|
86 |
|
|
WE : in slbit; -- write enable
|
87 |
|
|
ADDR : in slv(AWIDTH-1 downto 0); -- address port
|
88 |
|
|
DI : in slv(DWIDTH-1 downto 0); -- data in port
|
89 |
|
|
DO : out slv(DWIDTH-1 downto 0) -- data out port
|
90 |
|
|
);
|
91 |
|
|
end component;
|
92 |
|
|
|
93 |
|
|
component ram_2swsr_wfirst_gen is -- RAM, 2 sync r/w ports, write first
|
94 |
|
|
generic (
|
95 |
|
|
AWIDTH : positive := 11; -- address port width
|
96 |
|
|
DWIDTH : positive := 9); -- data port width
|
97 |
|
|
port(
|
98 |
|
|
CLKA : in slbit; -- clock port A
|
99 |
|
|
CLKB : in slbit; -- clock port B
|
100 |
|
|
ENA : in slbit; -- enable port A
|
101 |
|
|
ENB : in slbit; -- enable port B
|
102 |
|
|
WEA : in slbit; -- write enable port A
|
103 |
|
|
WEB : in slbit; -- write enable port B
|
104 |
|
|
ADDRA : in slv(AWIDTH-1 downto 0); -- address port A
|
105 |
|
|
ADDRB : in slv(AWIDTH-1 downto 0); -- address port B
|
106 |
|
|
DIA : in slv(DWIDTH-1 downto 0); -- data in port A
|
107 |
|
|
DIB : in slv(DWIDTH-1 downto 0); -- data in port B
|
108 |
|
|
DOA : out slv(DWIDTH-1 downto 0); -- data out port A
|
109 |
|
|
DOB : out slv(DWIDTH-1 downto 0) -- data out port B
|
110 |
|
|
);
|
111 |
|
|
end component;
|
112 |
|
|
|
113 |
|
|
component ram_2swsr_rfirst_gen is -- RAM, 2 sync r/w ports, read first
|
114 |
|
|
generic (
|
115 |
|
|
AWIDTH : positive := 11; -- address port width
|
116 |
|
|
DWIDTH : positive := 9); -- data port width
|
117 |
|
|
port(
|
118 |
|
|
CLKA : in slbit; -- clock port A
|
119 |
|
|
CLKB : in slbit; -- clock port B
|
120 |
|
|
ENA : in slbit; -- enable port A
|
121 |
|
|
ENB : in slbit; -- enable port B
|
122 |
|
|
WEA : in slbit; -- write enable port A
|
123 |
|
|
WEB : in slbit; -- write enable port B
|
124 |
|
|
ADDRA : in slv(AWIDTH-1 downto 0); -- address port A
|
125 |
|
|
ADDRB : in slv(AWIDTH-1 downto 0); -- address port B
|
126 |
|
|
DIA : in slv(DWIDTH-1 downto 0); -- data in port A
|
127 |
|
|
DIB : in slv(DWIDTH-1 downto 0); -- data in port B
|
128 |
|
|
DOA : out slv(DWIDTH-1 downto 0); -- data out port A
|
129 |
|
|
DOB : out slv(DWIDTH-1 downto 0) -- data out port B
|
130 |
|
|
);
|
131 |
|
|
end component;
|
132 |
|
|
|
133 |
|
|
component ram_1swsr_xfirst_gen_unisim is -- RAM, 1 sync r/w port
|
134 |
|
|
generic (
|
135 |
|
|
AWIDTH : positive := 11; -- address port width
|
136 |
|
|
DWIDTH : positive := 9; -- data port width
|
137 |
|
|
WRITE_MODE : string := "READ_FIRST"); -- write mode: (READ|WRITE)_FIRST
|
138 |
|
|
port(
|
139 |
|
|
CLK : in slbit; -- clock
|
140 |
|
|
EN : in slbit; -- enable
|
141 |
|
|
WE : in slbit; -- write enable
|
142 |
|
|
ADDR : in slv(AWIDTH-1 downto 0); -- address
|
143 |
|
|
DI : in slv(DWIDTH-1 downto 0); -- data in
|
144 |
|
|
DO : out slv(DWIDTH-1 downto 0) -- data out
|
145 |
|
|
);
|
146 |
|
|
end component;
|
147 |
|
|
|
148 |
|
|
component ram_2swsr_xfirst_gen_unisim is -- RAM, 2 sync r/w ports
|
149 |
|
|
generic (
|
150 |
|
|
AWIDTH : positive := 11; -- address port width
|
151 |
|
|
DWIDTH : positive := 9; -- data port width
|
152 |
|
|
WRITE_MODE : string := "READ_FIRST"); -- write mode: (READ|WRITE)_FIRST
|
153 |
|
|
port(
|
154 |
|
|
CLKA : in slbit; -- clock port A
|
155 |
|
|
CLKB : in slbit; -- clock port B
|
156 |
|
|
ENA : in slbit; -- enable port A
|
157 |
|
|
ENB : in slbit; -- enable port B
|
158 |
|
|
WEA : in slbit; -- write enable port A
|
159 |
|
|
WEB : in slbit; -- write enable port B
|
160 |
|
|
ADDRA : in slv(AWIDTH-1 downto 0); -- address port A
|
161 |
|
|
ADDRB : in slv(AWIDTH-1 downto 0); -- address port B
|
162 |
|
|
DIA : in slv(DWIDTH-1 downto 0); -- data in port A
|
163 |
|
|
DIB : in slv(DWIDTH-1 downto 0); -- data in port B
|
164 |
|
|
DOA : out slv(DWIDTH-1 downto 0); -- data out port A
|
165 |
|
|
DOB : out slv(DWIDTH-1 downto 0) -- data out port B
|
166 |
|
|
);
|
167 |
|
|
end component;
|
168 |
|
|
|
169 |
|
|
component fifo_1c_dram_raw is -- fifo, 1 clock, dram based, raw
|
170 |
|
|
generic (
|
171 |
|
|
AWIDTH : positive := 4; -- address width (sets size)
|
172 |
|
|
DWIDTH : positive := 16); -- data width
|
173 |
|
|
port (
|
174 |
|
|
CLK : in slbit; -- clock
|
175 |
|
|
RESET : in slbit; -- reset
|
176 |
|
|
WE : in slbit; -- write enable
|
177 |
|
|
RE : in slbit; -- read enable
|
178 |
|
|
DI : in slv(DWIDTH-1 downto 0); -- input data
|
179 |
|
|
DO : out slv(DWIDTH-1 downto 0); -- output data
|
180 |
|
|
SIZE : out slv(AWIDTH-1 downto 0); -- number of used slots
|
181 |
|
|
EMPTY : out slbit; -- empty flag
|
182 |
|
|
FULL : out slbit -- full flag
|
183 |
|
|
);
|
184 |
|
|
end component;
|
185 |
|
|
|
186 |
|
|
component fifo_1c_dram is -- fifo, 1 clock, dram based
|
187 |
|
|
generic (
|
188 |
|
|
AWIDTH : positive := 4; -- address width (sets size)
|
189 |
|
|
DWIDTH : positive := 16); -- data width
|
190 |
|
|
port (
|
191 |
|
|
CLK : in slbit; -- clock
|
192 |
|
|
RESET : in slbit; -- reset
|
193 |
|
|
DI : in slv(DWIDTH-1 downto 0); -- input data
|
194 |
|
|
ENA : in slbit; -- write enable
|
195 |
|
|
BUSY : out slbit; -- write port hold
|
196 |
|
|
DO : out slv(DWIDTH-1 downto 0); -- output data
|
197 |
|
|
VAL : out slbit; -- read valid
|
198 |
|
|
HOLD : in slbit; -- read hold
|
199 |
|
|
SIZE : out slv(AWIDTH downto 0) -- number of used slots
|
200 |
|
|
);
|
201 |
|
|
end component;
|
202 |
|
|
|
203 |
|
|
component fifo_1c_bubble is -- fifo, 1 clock, bubble regs
|
204 |
|
|
generic (
|
205 |
|
|
NSTAGE : positive := 4; -- number of stages
|
206 |
|
|
DWIDTH : positive := 16); -- data width
|
207 |
|
|
port (
|
208 |
|
|
CLK : in slbit; -- clock
|
209 |
|
|
RESET : in slbit; -- reset
|
210 |
|
|
DI : in slv(DWIDTH-1 downto 0); -- input data
|
211 |
|
|
ENA : in slbit; -- write enable
|
212 |
|
|
BUSY : out slbit; -- write port hold
|
213 |
|
|
DO : out slv(DWIDTH-1 downto 0); -- output data
|
214 |
|
|
VAL : out slbit; -- read valid
|
215 |
|
|
HOLD : in slbit -- read hold
|
216 |
|
|
);
|
217 |
|
|
end component;
|
218 |
|
|
|
219 |
|
|
component fifo_2c_dram is -- fifo, 2 clock, dram based
|
220 |
|
|
generic (
|
221 |
|
|
AWIDTH : positive := 4; -- address width (sets size)
|
222 |
|
|
DWIDTH : positive := 16); -- data width
|
223 |
|
|
port (
|
224 |
|
|
CLKW : in slbit; -- clock (write side)
|
225 |
|
|
CLKR : in slbit; -- clock (read side)
|
226 |
13 |
wfjm |
RESETW : in slbit; -- W|reset from write side
|
227 |
|
|
RESETR : in slbit; -- R|reset from read side
|
228 |
|
|
DI : in slv(DWIDTH-1 downto 0); -- W|input data
|
229 |
|
|
ENA : in slbit; -- W|write enable
|
230 |
|
|
BUSY : out slbit; -- W|write port hold
|
231 |
|
|
DO : out slv(DWIDTH-1 downto 0); -- R|output data
|
232 |
|
|
VAL : out slbit; -- R|read valid
|
233 |
|
|
HOLD : in slbit; -- R|read hold
|
234 |
|
|
SIZEW : out slv(AWIDTH-1 downto 0); -- W|number slots to write
|
235 |
|
|
SIZER : out slv(AWIDTH-1 downto 0) -- R|number slots to read
|
236 |
2 |
wfjm |
);
|
237 |
|
|
end component;
|
238 |
|
|
|
239 |
36 |
wfjm |
component fifo_2c_dram2 is -- fifo, 2 clock, dram based (v2)
|
240 |
|
|
generic (
|
241 |
|
|
AWIDTH : positive := 4; -- address width (sets size)
|
242 |
|
|
DWIDTH : positive := 16); -- data width
|
243 |
|
|
port (
|
244 |
|
|
CLKW : in slbit; -- clock (write side)
|
245 |
|
|
CLKR : in slbit; -- clock (read side)
|
246 |
|
|
RESETW : in slbit; -- W|reset from write side
|
247 |
|
|
RESETR : in slbit; -- R|reset from read side
|
248 |
|
|
DI : in slv(DWIDTH-1 downto 0); -- W|input data
|
249 |
|
|
ENA : in slbit; -- W|write enable
|
250 |
|
|
BUSY : out slbit; -- W|write port hold
|
251 |
|
|
DO : out slv(DWIDTH-1 downto 0); -- R|output data
|
252 |
|
|
VAL : out slbit; -- R|read valid
|
253 |
|
|
HOLD : in slbit; -- R|read hold
|
254 |
|
|
SIZEW : out slv(AWIDTH-1 downto 0); -- W|number slots to write
|
255 |
|
|
SIZER : out slv(AWIDTH-1 downto 0) -- R|number slots to read
|
256 |
|
|
);
|
257 |
|
|
end component;
|
258 |
|
|
|
259 |
12 |
wfjm |
end package memlib;
|