w11 - vhd 0.794
W11 CPU core and support modules
Loading...
Searching...
No Matches
ram_1swsr_xfirst_gen_unisim.vhd
Go to the documentation of this file.
1-- $Id: ram_1swsr_xfirst_gen_unisim.vhd 1181 2019-07-08 17:00:50Z mueller $
2-- SPDX-License-Identifier: GPL-3.0-or-later
3-- Copyright 2008-2011 by Walter F.J. Mueller <W.F.J.Mueller@gsi.de>
4--
5------------------------------------------------------------------------------
6-- Module Name: ram_1swsr_xfirst_gen_unisim - syn
7-- Description: Single-Port RAM with with one synchronous read/write port
8-- Direct instantiation of Xilinx UNISIM primitives
9--
10-- Dependencies: -
11-- Test bench: -
12-- Target Devices: Spartan-3, Virtex-2,-4
13-- Tool versions: xst 8.1-14.7; ghdl 0.18-0.31
14-- Revision History:
15-- Date Rev Version Comment
16-- 2011-08-14 406 1.0.2 cleaner code for L_DI initialization
17-- 2008-04-13 135 1.0.1 fix range error for AW_14_S1
18-- 2008-03-08 123 1.0 Initial version
19------------------------------------------------------------------------------
20
21library ieee;
22use ieee.std_logic_1164.all;
23
24library unisim;
25use unisim.vcomponents.ALL;
26
27use work.slvtypes.all;
28
29entity ram_1swsr_xfirst_gen_unisim is -- RAM, 1 sync r/w ports
30 generic (
31 AWIDTH : positive := 11; -- address port width
32 DWIDTH : positive := 9; -- data port width
33 WRITE_MODE : string := "READ_FIRST"); -- write mode: (READ|WRITE)_FIRST
34 port(
35 CLK : in slbit; -- clock
36 EN : in slbit; -- enable
37 WE : in slbit; -- write enable
38 ADDR : in slv(AWIDTH-1 downto 0); -- address
39 DI : in slv(DWIDTH-1 downto 0); -- data in
40 DO : out slv(DWIDTH-1 downto 0) -- data out
41 );
43
44
46
47 constant ok_mod32 : boolean := (DWIDTH mod 32)=0 and
48 ((DWIDTH+35)/36)=((DWIDTH+31)/32);
49 constant ok_mod16 : boolean := (DWIDTH mod 16)=0 and
50 ((DWIDTH+17)/18)=((DWIDTH+16)/16);
51 constant ok_mod08 : boolean := (DWIDTH mod 32)=0 and
52 ((DWIDTH+8)/9)=((DWIDTH+7)/8);
53
54begin
55
56 assert AWIDTH>=9 and AWIDTH<=14
57 report "assert(AWIDTH>=9 and AWIDTH<=14): unsupported BRAM from factor"
58 severity failure;
59
60 AW_09_S36: if AWIDTH=9 and not ok_mod32 generate
61 constant dw_mem : positive := ((DWIDTH+35)/36)*36;
62 signal L_DO : slv(dw_mem-1 downto 0) := (others=> '0');
63 signal L_DI : slv(dw_mem-1 downto 0) := (others=> '0');
64 begin
65
66 DI_PAD: if dw_mem>DWIDTH generate
67 L_DI(dw_mem-1 downto DWIDTH) <= (others=>'0');
68 end generate DI_PAD;
69 L_DI(DI'range) <= DI;
70
71 GL: for i in dw_mem/36-1 downto 0 generate
72 MEM : RAMB16_S36
73 generic map (
74 INIT => O"000000000000",
75 SRVAL => O"000000000000",
76 WRITE_MODE => WRITE_MODE)
77 port map (
78 DO => L_DO(36*i+31 downto 36*i),
79 DOP => L_DO(36*i+35 downto 36*i+32),
80 ADDR => ADDR,
81 CLK => CLK,
82 DI => L_DI(36*i+31 downto 36*i),
83 DIP => L_DI(36*i+35 downto 36*i+32),
84 EN => EN,
85 SSR => '0',
86 WE => WE
87 );
88 end generate GL;
89
90 DO <= L_DO(DO'range);
91
92 end generate AW_09_S36;
93
94 AW_09_S32: if AWIDTH=9 and ok_mod32 generate
95 GL: for i in DWIDTH/32-1 downto 0 generate
96 MEM : RAMB16_S36
97 generic map (
98 INIT => X"00000000",
99 SRVAL => X"00000000",
100 WRITE_MODE => WRITE_MODE)
101 port map (
102 DO => DO(32*i+31 downto 32*i),
103 DOP => open,
104 ADDR => ADDR,
105 CLK => CLK,
106 DI => DI(32*i+31 downto 32*i),
107 DIP => "0000",
108 EN => EN,
109 SSR => '0',
110 WE => WE
111 );
112 end generate GL;
113 end generate AW_09_S32;
114
115 AW_10_S18: if AWIDTH=10 and not ok_mod16 generate
116 constant dw_mem : positive := ((DWIDTH+17)/18)*18;
117 signal L_DO : slv(dw_mem-1 downto 0) := (others=> '0');
118 signal L_DI : slv(dw_mem-1 downto 0) := (others=> '0');
119 begin
120
121 DI_PAD: if dw_mem>DWIDTH generate
122 L_DI(dw_mem-1 downto DWIDTH) <= (others=>'0');
123 end generate DI_PAD;
124 L_DI(DI'range) <= DI;
125
126 GL: for i in dw_mem/18-1 downto 0 generate
127 MEM : RAMB16_S18
128 generic map (
129 INIT => O"000000",
130 SRVAL => O"000000",
131 WRITE_MODE => WRITE_MODE)
132 port map (
133 DO => L_DO(18*i+15 downto 18*i),
134 DOP => L_DO(18*i+17 downto 18*i+16),
135 ADDR => ADDR,
136 CLK => CLK,
137 DI => L_DI(18*i+15 downto 18*i),
138 DIP => L_DI(18*i+17 downto 18*i+16),
139 EN => EN,
140 SSR => '0',
141 WE => WE
142 );
143 end generate GL;
144
145 DO <= L_DO(DO'range);
146
147 end generate AW_10_S18;
148
149 AW_10_S16: if AWIDTH=10 and ok_mod16 generate
150 GL: for i in DWIDTH/16-1 downto 0 generate
151 MEM : RAMB16_S18
152 generic map (
153 INIT => X"0000",
154 SRVAL => X"0000",
155 WRITE_MODE => WRITE_MODE)
156 port map (
157 DO => DO(16*i+15 downto 16*i),
158 DOP => open,
159 ADDR => ADDR,
160 CLK => CLK,
161 DI => DI(16*i+15 downto 16*i),
162 DIP => "00",
163 EN => EN,
164 SSR => '0',
165 WE => WE
166 );
167 end generate GL;
168 end generate AW_10_S16;
169
170 AW_11_S9: if AWIDTH=11 and not ok_mod08 generate
171 constant dw_mem : positive := ((DWIDTH+8)/9)*9;
172 signal L_DO : slv(dw_mem-1 downto 0) := (others=> '0');
173 signal L_DI : slv(dw_mem-1 downto 0) := (others=> '0');
174 begin
175
176 DI_PAD: if dw_mem>DWIDTH generate
177 L_DI(dw_mem-1 downto DWIDTH) <= (others=>'0');
178 end generate DI_PAD;
179 L_DI(DI'range) <= DI;
180
181 GL: for i in dw_mem/9-1 downto 0 generate
182 MEM : RAMB16_S9
183 generic map (
184 INIT => O"000",
185 SRVAL => O"000",
186 WRITE_MODE => WRITE_MODE)
187 port map (
188 DO => L_DO(9*i+7 downto 9*i),
189 DOP => L_DO(9*i+8 downto 9*i+8),
190 ADDR => ADDR,
191 CLK => CLK,
192 DI => L_DI(9*i+7 downto 9*i),
193 DIP => L_DI(9*i+8 downto 9*i+8),
194 EN => EN,
195 SSR => '0',
196 WE => WE
197 );
198 end generate GL;
199
200 DO <= L_DO(DO'range);
201
202 end generate AW_11_S9;
203
204 AW_11_S8: if AWIDTH=11 and ok_mod08 generate
205 GL: for i in DWIDTH/8-1 downto 0 generate
206 MEM : RAMB16_S9
207 generic map (
208 INIT => X"00",
209 SRVAL => X"00",
210 WRITE_MODE => WRITE_MODE)
211 port map (
212 DO => DO(8*i+7 downto 8*i),
213 DOP => open,
214 ADDR => ADDR,
215 CLK => CLK,
216 DI => DI(8*i+7 downto 8*i),
217 DIP => "0",
218 EN => EN,
219 SSR => '0',
220 WE => WE
221 );
222 end generate GL;
223 end generate AW_11_S8;
224
225 AW_12_S4: if AWIDTH = 12 generate
226 constant dw_mem : positive := ((DWIDTH+3)/4)*4;
227 signal L_DO : slv(dw_mem-1 downto 0) := (others=> '0');
228 signal L_DI : slv(dw_mem-1 downto 0) := (others=> '0');
229 begin
230
231 DI_PAD: if dw_mem>DWIDTH generate
232 L_DI(dw_mem-1 downto DWIDTH) <= (others=>'0');
233 end generate DI_PAD;
234 L_DI(DI'range) <= DI;
235
236 GL: for i in dw_mem/4-1 downto 0 generate
237 MEM : RAMB16_S4
238 generic map (
239 INIT => X"0",
240 SRVAL => X"0",
241 WRITE_MODE => WRITE_MODE)
242 port map (
243 DO => L_DO(4*i+3 downto 4*i),
244 ADDR => ADDR,
245 CLK => CLK,
246 DI => L_DI(4*i+3 downto 4*i),
247 EN => EN,
248 SSR => '0',
249 WE => WE
250 );
251 end generate GL;
252
253 DO <= L_DO(DO'range);
254
255 end generate AW_12_S4;
256
257 AW_13_S2: if AWIDTH = 13 generate
258 constant dw_mem : positive := ((DWIDTH+1)/2)*2;
259 signal L_DO : slv(dw_mem-1 downto 0) := (others=> '0');
260 signal L_DI : slv(dw_mem-1 downto 0) := (others=> '0');
261 begin
262
263 DI_PAD: if dw_mem>DWIDTH generate
264 L_DI(dw_mem-1 downto DWIDTH) <= (others=>'0');
265 end generate DI_PAD;
266 L_DI(DI'range) <= DI;
267
268 GL: for i in dw_mem/2-1 downto 0 generate
269 MEM : RAMB16_S2
270 generic map (
271 INIT => "00",
272 SRVAL => "00",
273 WRITE_MODE => WRITE_MODE)
274 port map (
275 DO => L_DO(2*i+1 downto 2*i),
276 ADDR => ADDR,
277 CLK => CLK,
278 DI => L_DI(2*i+1 downto 2*i),
279 EN => EN,
280 SSR => '0',
281 WE => WE
282 );
283 end generate GL;
284
285 DO <= L_DO(DO'range);
286
287 end generate AW_13_S2;
288
289 AW_14_S1: if AWIDTH = 14 generate
290 GL: for i in DWIDTH-1 downto 0 generate
291 MEM : RAMB16_S1
292 generic map (
293 INIT => "0",
294 SRVAL => "0",
295 WRITE_MODE => WRITE_MODE)
296 port map (
297 DO => DO(i downto i),
298 ADDR => ADDR,
299 CLK => CLK,
300 DI => DI(i downto i),
301 EN => EN,
302 SSR => '0',
303 WE => WE
304 );
305 end generate GL;
306 end generate AW_14_S1;
307
308
309end syn;
310
311-- Note: in XST 8.2 the defaults for INIT_(A|B) and SRVAL_(A|B) are
312-- nonsense: INIT_A : bit_vector := X"000";
313-- This is a 12 bit value, while a 9 bit one is needed. Thus the
314-- explicit definition above.
positive :=(( DWIDTH+ 35)/ 36)* 36 dw_mem
slv( dw_mem- 1 downto 0) :=( others => '0') L_DO
boolean :=( DWIDTHmod 16)= 0and(( DWIDTH+ 17)/ 18)=(( DWIDTH+ 16)/ 16) ok_mod16
boolean :=( DWIDTHmod 32)= 0and(( DWIDTH+ 8)/ 9)=(( DWIDTH+ 7)/ 8) ok_mod08
slv( dw_mem- 1 downto 0) :=( others => '0') L_DI
boolean :=( DWIDTHmod 32)= 0and(( DWIDTH+ 35)/ 36)=(( DWIDTH+ 31)/ 32) ok_mod32
in ADDR slv( AWIDTH- 1 downto 0)
out DO slv( DWIDTH- 1 downto 0)
in DI slv( DWIDTH- 1 downto 0)
std_logic slbit
Definition: slvtypes.vhd:30
std_logic_vector slv
Definition: slvtypes.vhd:31