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

Subversion Repositories or1k

[/] [or1k/] [branches/] [mp3_stable/] [mp3/] [lib/] [xilinx/] [unisims/] [RAMB4_S4_S16.v] - Blame information for rev 1765

Details | Compare with Previous | View Log

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

powered by: WebSVN 2.1.0

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