1 |
266 |
lampret |
// $Header: /home/marcus/revision_ctrl_test/oc_cvs/cvs/or1k/mp3/lib/xilinx/unisims/RAMB4_S2_S16.v,v 1.1.1.1 2001-11-04 18:59:59 lampret Exp $
|
2 |
|
|
|
3 |
|
|
/*
|
4 |
|
|
|
5 |
|
|
FUNCTION : 4x2x16 Block RAM with synchronous write capability
|
6 |
|
|
|
7 |
|
|
*/
|
8 |
|
|
|
9 |
|
|
`timescale 100 ps / 10 ps
|
10 |
|
|
|
11 |
|
|
`celldefine
|
12 |
|
|
|
13 |
|
|
module RAMB4_S2_S16 (DOA, DOB, ADDRA, CLKA, DIA, ENA, RSTA, WEA, ADDRB, CLKB, DIB, ENB, RSTB, WEB);
|
14 |
|
|
|
15 |
|
|
parameter cds_action = "ignore";
|
16 |
|
|
|
17 |
|
|
parameter INIT_00 = 256'h0000000000000000000000000000000000000000000000000000000000000000;
|
18 |
|
|
parameter INIT_01 = 256'h0000000000000000000000000000000000000000000000000000000000000000;
|
19 |
|
|
parameter INIT_02 = 256'h0000000000000000000000000000000000000000000000000000000000000000;
|
20 |
|
|
parameter INIT_03 = 256'h0000000000000000000000000000000000000000000000000000000000000000;
|
21 |
|
|
parameter INIT_04 = 256'h0000000000000000000000000000000000000000000000000000000000000000;
|
22 |
|
|
parameter INIT_05 = 256'h0000000000000000000000000000000000000000000000000000000000000000;
|
23 |
|
|
parameter INIT_06 = 256'h0000000000000000000000000000000000000000000000000000000000000000;
|
24 |
|
|
parameter INIT_07 = 256'h0000000000000000000000000000000000000000000000000000000000000000;
|
25 |
|
|
parameter INIT_08 = 256'h0000000000000000000000000000000000000000000000000000000000000000;
|
26 |
|
|
parameter INIT_09 = 256'h0000000000000000000000000000000000000000000000000000000000000000;
|
27 |
|
|
parameter INIT_0A = 256'h0000000000000000000000000000000000000000000000000000000000000000;
|
28 |
|
|
parameter INIT_0B = 256'h0000000000000000000000000000000000000000000000000000000000000000;
|
29 |
|
|
parameter INIT_0C = 256'h0000000000000000000000000000000000000000000000000000000000000000;
|
30 |
|
|
parameter INIT_0D = 256'h0000000000000000000000000000000000000000000000000000000000000000;
|
31 |
|
|
parameter INIT_0E = 256'h0000000000000000000000000000000000000000000000000000000000000000;
|
32 |
|
|
parameter INIT_0F = 256'h0000000000000000000000000000000000000000000000000000000000000000;
|
33 |
|
|
|
34 |
|
|
output [1:0] DOA;
|
35 |
|
|
reg [1:0] doa_out;
|
36 |
|
|
wire doa_out0, doa_out1;
|
37 |
|
|
|
38 |
|
|
input [10:0] ADDRA;
|
39 |
|
|
input [1:0] DIA;
|
40 |
|
|
input ENA, CLKA, WEA, RSTA;
|
41 |
|
|
|
42 |
|
|
output [15:0] DOB;
|
43 |
|
|
reg [15:0] dob_out;
|
44 |
|
|
wire dob_out0, dob_out1, dob_out2, dob_out3, dob_out4, dob_out5, dob_out6, dob_out7, dob_out8, dob_out9, dob_out10, dob_out11, dob_out12, dob_out13, dob_out14, dob_out15;
|
45 |
|
|
|
46 |
|
|
input [7:0] ADDRB;
|
47 |
|
|
input [15:0] DIB;
|
48 |
|
|
input ENB, CLKB, WEB, RSTB;
|
49 |
|
|
|
50 |
|
|
reg [4095:0] mem;
|
51 |
|
|
reg [8:0] count;
|
52 |
|
|
|
53 |
|
|
reg [5:0] mi, mj, ai, aj, bi, bj, ci, cj;
|
54 |
|
|
|
55 |
|
|
wire [10:0] addra_int;
|
56 |
|
|
wire [1:0] dia_int;
|
57 |
|
|
wire ena_int, clka_int, wea_int, rsta_int;
|
58 |
|
|
wire [7:0] addrb_int;
|
59 |
|
|
wire [15:0] dib_int;
|
60 |
|
|
wire enb_int, clkb_int, web_int, rstb_int;
|
61 |
|
|
|
62 |
|
|
reg recovery_a, recovery_b;
|
63 |
|
|
reg address_collision;
|
64 |
|
|
|
65 |
|
|
wire clka_enable = ena_int && wea_int && enb_int && address_collision;
|
66 |
|
|
wire clkb_enable = enb_int && web_int && ena_int && address_collision;
|
67 |
|
|
wire collision = clka_enable || clkb_enable;
|
68 |
|
|
|
69 |
|
|
tri0 GSR = glbl.GSR;
|
70 |
|
|
|
71 |
|
|
always @(GSR)
|
72 |
|
|
if (GSR) begin
|
73 |
|
|
assign doa_out = 0;
|
74 |
|
|
end
|
75 |
|
|
else begin
|
76 |
|
|
deassign doa_out;
|
77 |
|
|
end
|
78 |
|
|
|
79 |
|
|
always @(GSR)
|
80 |
|
|
if (GSR) begin
|
81 |
|
|
assign dob_out = 0;
|
82 |
|
|
end
|
83 |
|
|
else begin
|
84 |
|
|
deassign dob_out;
|
85 |
|
|
end
|
86 |
|
|
|
87 |
|
|
buf b_doa_out0 (doa_out0, doa_out[0]);
|
88 |
|
|
buf b_doa_out1 (doa_out1, doa_out[1]);
|
89 |
|
|
buf b_dob_out0 (dob_out0, dob_out[0]);
|
90 |
|
|
buf b_dob_out1 (dob_out1, dob_out[1]);
|
91 |
|
|
buf b_dob_out2 (dob_out2, dob_out[2]);
|
92 |
|
|
buf b_dob_out3 (dob_out3, dob_out[3]);
|
93 |
|
|
buf b_dob_out4 (dob_out4, dob_out[4]);
|
94 |
|
|
buf b_dob_out5 (dob_out5, dob_out[5]);
|
95 |
|
|
buf b_dob_out6 (dob_out6, dob_out[6]);
|
96 |
|
|
buf b_dob_out7 (dob_out7, dob_out[7]);
|
97 |
|
|
buf b_dob_out8 (dob_out8, dob_out[8]);
|
98 |
|
|
buf b_dob_out9 (dob_out9, dob_out[9]);
|
99 |
|
|
buf b_dob_out10 (dob_out10, dob_out[10]);
|
100 |
|
|
buf b_dob_out11 (dob_out11, dob_out[11]);
|
101 |
|
|
buf b_dob_out12 (dob_out12, dob_out[12]);
|
102 |
|
|
buf b_dob_out13 (dob_out13, dob_out[13]);
|
103 |
|
|
buf b_dob_out14 (dob_out14, dob_out[14]);
|
104 |
|
|
buf b_dob_out15 (dob_out15, dob_out[15]);
|
105 |
|
|
buf b_doa0 (DOA[0], doa_out0);
|
106 |
|
|
buf b_doa1 (DOA[1], doa_out1);
|
107 |
|
|
buf b_dob0 (DOB[0], dob_out0);
|
108 |
|
|
buf b_dob1 (DOB[1], dob_out1);
|
109 |
|
|
buf b_dob2 (DOB[2], dob_out2);
|
110 |
|
|
buf b_dob3 (DOB[3], dob_out3);
|
111 |
|
|
buf b_dob4 (DOB[4], dob_out4);
|
112 |
|
|
buf b_dob5 (DOB[5], dob_out5);
|
113 |
|
|
buf b_dob6 (DOB[6], dob_out6);
|
114 |
|
|
buf b_dob7 (DOB[7], dob_out7);
|
115 |
|
|
buf b_dob8 (DOB[8], dob_out8);
|
116 |
|
|
buf b_dob9 (DOB[9], dob_out9);
|
117 |
|
|
buf b_dob10 (DOB[10], dob_out10);
|
118 |
|
|
buf b_dob11 (DOB[11], dob_out11);
|
119 |
|
|
buf b_dob12 (DOB[12], dob_out12);
|
120 |
|
|
buf b_dob13 (DOB[13], dob_out13);
|
121 |
|
|
buf b_dob14 (DOB[14], dob_out14);
|
122 |
|
|
buf b_dob15 (DOB[15], dob_out15);
|
123 |
|
|
buf b_addra_0 (addra_int[0], ADDRA[0]);
|
124 |
|
|
buf b_addra_1 (addra_int[1], ADDRA[1]);
|
125 |
|
|
buf b_addra_2 (addra_int[2], ADDRA[2]);
|
126 |
|
|
buf b_addra_3 (addra_int[3], ADDRA[3]);
|
127 |
|
|
buf b_addra_4 (addra_int[4], ADDRA[4]);
|
128 |
|
|
buf b_addra_5 (addra_int[5], ADDRA[5]);
|
129 |
|
|
buf b_addra_6 (addra_int[6], ADDRA[6]);
|
130 |
|
|
buf b_addra_7 (addra_int[7], ADDRA[7]);
|
131 |
|
|
buf b_addra_8 (addra_int[8], ADDRA[8]);
|
132 |
|
|
buf b_addra_9 (addra_int[9], ADDRA[9]);
|
133 |
|
|
buf b_addra_10 (addra_int[10], ADDRA[10]);
|
134 |
|
|
buf b_dia_0 (dia_int[0], DIA[0]);
|
135 |
|
|
buf b_dia_1 (dia_int[1], DIA[1]);
|
136 |
|
|
buf b_clka (clka_int, CLKA);
|
137 |
|
|
buf b_ena (ena_int, ENA);
|
138 |
|
|
buf b_rsta (rsta_int, RSTA);
|
139 |
|
|
buf b_wea (wea_int, WEA);
|
140 |
|
|
buf b_addrb_0 (addrb_int[0], ADDRB[0]);
|
141 |
|
|
buf b_addrb_1 (addrb_int[1], ADDRB[1]);
|
142 |
|
|
buf b_addrb_2 (addrb_int[2], ADDRB[2]);
|
143 |
|
|
buf b_addrb_3 (addrb_int[3], ADDRB[3]);
|
144 |
|
|
buf b_addrb_4 (addrb_int[4], ADDRB[4]);
|
145 |
|
|
buf b_addrb_5 (addrb_int[5], ADDRB[5]);
|
146 |
|
|
buf b_addrb_6 (addrb_int[6], ADDRB[6]);
|
147 |
|
|
buf b_addrb_7 (addrb_int[7], ADDRB[7]);
|
148 |
|
|
buf b_dib_0 (dib_int[0], DIB[0]);
|
149 |
|
|
buf b_dib_1 (dib_int[1], DIB[1]);
|
150 |
|
|
buf b_dib_2 (dib_int[2], DIB[2]);
|
151 |
|
|
buf b_dib_3 (dib_int[3], DIB[3]);
|
152 |
|
|
buf b_dib_4 (dib_int[4], DIB[4]);
|
153 |
|
|
buf b_dib_5 (dib_int[5], DIB[5]);
|
154 |
|
|
buf b_dib_6 (dib_int[6], DIB[6]);
|
155 |
|
|
buf b_dib_7 (dib_int[7], DIB[7]);
|
156 |
|
|
buf b_dib_8 (dib_int[8], DIB[8]);
|
157 |
|
|
buf b_dib_9 (dib_int[9], DIB[9]);
|
158 |
|
|
buf b_dib_10 (dib_int[10], DIB[10]);
|
159 |
|
|
buf b_dib_11 (dib_int[11], DIB[11]);
|
160 |
|
|
buf b_dib_12 (dib_int[12], DIB[12]);
|
161 |
|
|
buf b_dib_13 (dib_int[13], DIB[13]);
|
162 |
|
|
buf b_dib_14 (dib_int[14], DIB[14]);
|
163 |
|
|
buf b_dib_15 (dib_int[15], DIB[15]);
|
164 |
|
|
buf b_clkb (clkb_int, CLKB);
|
165 |
|
|
buf b_enb (enb_int, ENB);
|
166 |
|
|
buf b_rstb (rstb_int, RSTB);
|
167 |
|
|
buf b_web (web_int, WEB);
|
168 |
|
|
|
169 |
|
|
initial begin
|
170 |
|
|
for (count = 0; count < 256; count = count + 1) begin
|
171 |
|
|
mem[count] <= INIT_00[count];
|
172 |
|
|
mem[256 * 1 + count] <= INIT_01[count];
|
173 |
|
|
mem[256 * 2 + count] <= INIT_02[count];
|
174 |
|
|
mem[256 * 3 + count] <= INIT_03[count];
|
175 |
|
|
mem[256 * 4 + count] <= INIT_04[count];
|
176 |
|
|
mem[256 * 5 + count] <= INIT_05[count];
|
177 |
|
|
mem[256 * 6 + count] <= INIT_06[count];
|
178 |
|
|
mem[256 * 7 + count] <= INIT_07[count];
|
179 |
|
|
mem[256 * 8 + count] <= INIT_08[count];
|
180 |
|
|
mem[256 * 9 + count] <= INIT_09[count];
|
181 |
|
|
mem[256 * 10 + count] <= INIT_0A[count];
|
182 |
|
|
mem[256 * 11 + count] <= INIT_0B[count];
|
183 |
|
|
mem[256 * 12 + count] <= INIT_0C[count];
|
184 |
|
|
mem[256 * 13 + count] <= INIT_0D[count];
|
185 |
|
|
mem[256 * 14 + count] <= INIT_0E[count];
|
186 |
|
|
mem[256 * 15 + count] <= INIT_0F[count];
|
187 |
|
|
end
|
188 |
|
|
recovery_a <= 0;
|
189 |
|
|
recovery_b <= 0;
|
190 |
|
|
end
|
191 |
|
|
|
192 |
|
|
always @(addra_int or addrb_int) begin
|
193 |
|
|
address_collision <= 1'b0;
|
194 |
|
|
for (ci = 0; ci < 2; ci = ci + 1) begin
|
195 |
|
|
for (cj = 0; cj < 16; cj = cj + 1) begin
|
196 |
|
|
if ((addra_int * 2 + ci) == (addrb_int * 16 + cj)) begin
|
197 |
|
|
address_collision <= 1'b1;
|
198 |
|
|
end
|
199 |
|
|
end
|
200 |
|
|
end
|
201 |
|
|
end
|
202 |
|
|
|
203 |
|
|
always @(posedge recovery_a or posedge recovery_b) begin
|
204 |
|
|
if (wea_int == 1 && web_int == 1) begin
|
205 |
|
|
for (mi = 0; mi < 2; mi = mi + 1) begin
|
206 |
|
|
for (mj = 0; mj < 16; mj = mj + 1) begin
|
207 |
|
|
if ((addra_int * 2 + mi) == (addrb_int * 16 + mj)) begin
|
208 |
|
|
mem[addra_int * 2 + mi] <= 1'bX;
|
209 |
|
|
end
|
210 |
|
|
end
|
211 |
|
|
end
|
212 |
|
|
end
|
213 |
|
|
recovery_a <= 0;
|
214 |
|
|
recovery_b <= 0;
|
215 |
|
|
end
|
216 |
|
|
|
217 |
|
|
always @(posedge recovery_a or posedge recovery_b) begin
|
218 |
|
|
if (web_int == 1 && rsta_int == 0) begin
|
219 |
|
|
for (ai = 0; ai < 2; ai = ai + 1) begin
|
220 |
|
|
for (aj = 0; aj < 16; aj = aj + 1) begin
|
221 |
|
|
if ((addra_int * 2 + ai) == (addrb_int * 16 + aj)) begin
|
222 |
|
|
doa_out[ai] <= 1'bX;
|
223 |
|
|
end
|
224 |
|
|
end
|
225 |
|
|
end
|
226 |
|
|
end
|
227 |
|
|
end
|
228 |
|
|
|
229 |
|
|
always @(posedge recovery_a or posedge recovery_b) begin
|
230 |
|
|
if (wea_int == 1 && rstb_int == 0) begin
|
231 |
|
|
for (bi = 0; bi < 2; bi = bi + 1) begin
|
232 |
|
|
for (bj = 0; bj < 16; bj = bj + 1) begin
|
233 |
|
|
if ((addra_int * 2 + bi) == (addrb_int * 16 + bj)) begin
|
234 |
|
|
dob_out[bj] <= 1'bX;
|
235 |
|
|
end
|
236 |
|
|
end
|
237 |
|
|
end
|
238 |
|
|
end
|
239 |
|
|
end
|
240 |
|
|
|
241 |
|
|
always @(posedge clka_int) begin
|
242 |
|
|
if (ena_int == 1'b1) begin
|
243 |
|
|
if (rsta_int == 1'b1) begin
|
244 |
|
|
doa_out[0] <= 0;
|
245 |
|
|
doa_out[1] <= 0;
|
246 |
|
|
end
|
247 |
|
|
else if (wea_int == 0) begin
|
248 |
|
|
doa_out[0] <= mem[addra_int * 2 + 0];
|
249 |
|
|
doa_out[1] <= mem[addra_int * 2 + 1];
|
250 |
|
|
end
|
251 |
|
|
else begin
|
252 |
|
|
doa_out[0] <= dia_int[0];
|
253 |
|
|
doa_out[1] <= dia_int[1];
|
254 |
|
|
end
|
255 |
|
|
end
|
256 |
|
|
end
|
257 |
|
|
|
258 |
|
|
always @(posedge clka_int) begin
|
259 |
|
|
if (ena_int == 1'b1 && wea_int == 1'b1) begin
|
260 |
|
|
mem[addra_int * 2 + 0] <= dia_int[0];
|
261 |
|
|
mem[addra_int * 2 + 1] <= dia_int[1];
|
262 |
|
|
end
|
263 |
|
|
end
|
264 |
|
|
|
265 |
|
|
always @(posedge clkb_int) begin
|
266 |
|
|
if (enb_int == 1'b1) begin
|
267 |
|
|
if (rstb_int == 1'b1) begin
|
268 |
|
|
dob_out[0] <= 0;
|
269 |
|
|
dob_out[1] <= 0;
|
270 |
|
|
dob_out[2] <= 0;
|
271 |
|
|
dob_out[3] <= 0;
|
272 |
|
|
dob_out[4] <= 0;
|
273 |
|
|
dob_out[5] <= 0;
|
274 |
|
|
dob_out[6] <= 0;
|
275 |
|
|
dob_out[7] <= 0;
|
276 |
|
|
dob_out[8] <= 0;
|
277 |
|
|
dob_out[9] <= 0;
|
278 |
|
|
dob_out[10] <= 0;
|
279 |
|
|
dob_out[11] <= 0;
|
280 |
|
|
dob_out[12] <= 0;
|
281 |
|
|
dob_out[13] <= 0;
|
282 |
|
|
dob_out[14] <= 0;
|
283 |
|
|
dob_out[15] <= 0;
|
284 |
|
|
end
|
285 |
|
|
else if (web_int == 0) begin
|
286 |
|
|
dob_out[0] <= mem[addrb_int * 16 + 0];
|
287 |
|
|
dob_out[1] <= mem[addrb_int * 16 + 1];
|
288 |
|
|
dob_out[2] <= mem[addrb_int * 16 + 2];
|
289 |
|
|
dob_out[3] <= mem[addrb_int * 16 + 3];
|
290 |
|
|
dob_out[4] <= mem[addrb_int * 16 + 4];
|
291 |
|
|
dob_out[5] <= mem[addrb_int * 16 + 5];
|
292 |
|
|
dob_out[6] <= mem[addrb_int * 16 + 6];
|
293 |
|
|
dob_out[7] <= mem[addrb_int * 16 + 7];
|
294 |
|
|
dob_out[8] <= mem[addrb_int * 16 + 8];
|
295 |
|
|
dob_out[9] <= mem[addrb_int * 16 + 9];
|
296 |
|
|
dob_out[10] <= mem[addrb_int * 16 + 10];
|
297 |
|
|
dob_out[11] <= mem[addrb_int * 16 + 11];
|
298 |
|
|
dob_out[12] <= mem[addrb_int * 16 + 12];
|
299 |
|
|
dob_out[13] <= mem[addrb_int * 16 + 13];
|
300 |
|
|
dob_out[14] <= mem[addrb_int * 16 + 14];
|
301 |
|
|
dob_out[15] <= mem[addrb_int * 16 + 15];
|
302 |
|
|
end
|
303 |
|
|
else begin
|
304 |
|
|
dob_out[0] <= dib_int[0];
|
305 |
|
|
dob_out[1] <= dib_int[1];
|
306 |
|
|
dob_out[2] <= dib_int[2];
|
307 |
|
|
dob_out[3] <= dib_int[3];
|
308 |
|
|
dob_out[4] <= dib_int[4];
|
309 |
|
|
dob_out[5] <= dib_int[5];
|
310 |
|
|
dob_out[6] <= dib_int[6];
|
311 |
|
|
dob_out[7] <= dib_int[7];
|
312 |
|
|
dob_out[8] <= dib_int[8];
|
313 |
|
|
dob_out[9] <= dib_int[9];
|
314 |
|
|
dob_out[10] <= dib_int[10];
|
315 |
|
|
dob_out[11] <= dib_int[11];
|
316 |
|
|
dob_out[12] <= dib_int[12];
|
317 |
|
|
dob_out[13] <= dib_int[13];
|
318 |
|
|
dob_out[14] <= dib_int[14];
|
319 |
|
|
dob_out[15] <= dib_int[15];
|
320 |
|
|
end
|
321 |
|
|
end
|
322 |
|
|
end
|
323 |
|
|
|
324 |
|
|
always @(posedge clkb_int) begin
|
325 |
|
|
if (enb_int == 1'b1 && web_int == 1'b1) begin
|
326 |
|
|
mem[addrb_int * 16 + 0] <= dib_int[0];
|
327 |
|
|
mem[addrb_int * 16 + 1] <= dib_int[1];
|
328 |
|
|
mem[addrb_int * 16 + 2] <= dib_int[2];
|
329 |
|
|
mem[addrb_int * 16 + 3] <= dib_int[3];
|
330 |
|
|
mem[addrb_int * 16 + 4] <= dib_int[4];
|
331 |
|
|
mem[addrb_int * 16 + 5] <= dib_int[5];
|
332 |
|
|
mem[addrb_int * 16 + 6] <= dib_int[6];
|
333 |
|
|
mem[addrb_int * 16 + 7] <= dib_int[7];
|
334 |
|
|
mem[addrb_int * 16 + 8] <= dib_int[8];
|
335 |
|
|
mem[addrb_int * 16 + 9] <= dib_int[9];
|
336 |
|
|
mem[addrb_int * 16 + 10] <= dib_int[10];
|
337 |
|
|
mem[addrb_int * 16 + 11] <= dib_int[11];
|
338 |
|
|
mem[addrb_int * 16 + 12] <= dib_int[12];
|
339 |
|
|
mem[addrb_int * 16 + 13] <= dib_int[13];
|
340 |
|
|
mem[addrb_int * 16 + 14] <= dib_int[14];
|
341 |
|
|
mem[addrb_int * 16 + 15] <= dib_int[15];
|
342 |
|
|
end
|
343 |
|
|
end
|
344 |
|
|
|
345 |
|
|
specify
|
346 |
|
|
(CLKA *> DOA) = (1, 1);
|
347 |
|
|
(CLKB *> DOB) = (1, 1);
|
348 |
|
|
$recovery (posedge CLKB, posedge CLKA &&& collision, 1, recovery_b);
|
349 |
|
|
$recovery (posedge CLKA, posedge CLKB &&& collision, 1, recovery_a);
|
350 |
|
|
endspecify
|
351 |
|
|
|
352 |
|
|
endmodule
|
353 |
|
|
|
354 |
|
|
`endcelldefine
|