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

Subversion Repositories or1k

[/] [or1k/] [branches/] [mp3_stable/] [or1200/] [rtl/] [verilog/] [generic_spram_2048x32.v] - Blame information for rev 1765

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 218 lampret
//////////////////////////////////////////////////////////////////////
2
////                                                              ////
3
////  Generic Single-Port Synchronous RAM                         ////
4
////                                                              ////
5
////  This file is part of memory library available from          ////
6
////  http://www.opencores.org/cvsweb.shtml/generic_memories/     ////
7
////                                                              ////
8
////  Description                                                 ////
9
////  This block is a wrapper with common single-port             ////
10
////  synchronous memory interface for different                  ////
11
////  types of ASIC and FPGA RAMs. Beside universal memory        ////
12
////  interface it also provides behavioral model of generic      ////
13
////  single-port synchronous RAM.                                ////
14
////  It should be used in all OPENCORES designs that want to be  ////
15
////  portable accross different target technologies and          ////
16
////  independent of target memory.                               ////
17
////                                                              ////
18
////  Supported ASIC RAMs are:                                    ////
19
////  - Artisan Single-Port Sync RAM                              ////
20
////  - Avant! Two-Port Sync RAM (*)                              ////
21
////  - Virage Single-Port Sync RAM                               ////
22
////  - Virtual Silicon Single-Port Sync RAM                      ////
23
////                                                              ////
24
////  Supported FPGA RAMs are:                                    ////
25
////  - Xilinx Virtex RAMB4_S16                                   ////
26
////                                                              ////
27
////  To Do:                                                      ////
28
////   - xilinx rams need external tri-state logic                ////
29
////   - fix avant! two-port ram                                  ////
30
////   - add additional RAMs (Altera etc)                         ////
31
////                                                              ////
32
////  Author(s):                                                  ////
33
////      - Damjan Lampret, lampret@opencores.org                 ////
34
////                                                              ////
35
//////////////////////////////////////////////////////////////////////
36
////                                                              ////
37
//// Copyright (C) 2000 Authors and OPENCORES.ORG                 ////
38
////                                                              ////
39
//// This source file may be used and distributed without         ////
40
//// restriction provided that this copyright statement is not    ////
41
//// removed from the file and that any derivative work contains  ////
42
//// the original copyright notice and the associated disclaimer. ////
43
////                                                              ////
44
//// This source file is free software; you can redistribute it   ////
45
//// and/or modify it under the terms of the GNU Lesser General   ////
46
//// Public License as published by the Free Software Foundation; ////
47
//// either version 2.1 of the License, or (at your option) any   ////
48
//// later version.                                               ////
49
////                                                              ////
50
//// This source is distributed in the hope that it will be       ////
51
//// useful, but WITHOUT ANY WARRANTY; without even the implied   ////
52
//// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR      ////
53
//// PURPOSE.  See the GNU Lesser General Public License for more ////
54
//// details.                                                     ////
55
////                                                              ////
56
//// You should have received a copy of the GNU Lesser General    ////
57
//// Public License along with this source; if not, download it   ////
58
//// from http://www.opencores.org/lgpl.shtml                     ////
59
////                                                              ////
60
//////////////////////////////////////////////////////////////////////
61
//
62
// CVS Revision History
63
//
64
// $Log: not supported by cvs2svn $
65 265 lampret
// Revision 1.7  2001/10/21 17:57:16  lampret
66
// Removed params from generic_XX.v. Added translate_off/on in sprs.v and id.v. Removed spr_addr from dc.v and ic.v. Fixed CR+LF.
67
//
68 218 lampret
// Revision 1.6  2001/10/14 13:12:09  lampret
69
// MP3 version.
70
//
71
// Revision 1.1.1.1  2001/10/06 10:18:36  igorm
72
// no message
73
//
74
// Revision 1.1  2001/08/09 13:39:33  lampret
75
// Major clean-up.
76
//
77
// Revision 1.2  2001/07/30 05:38:02  lampret
78
// Adding empty directories required by HDL coding guidelines
79
//
80
//
81
 
82
// synopsys translate_off
83
`include "timescale.v"
84
// synopsys translate_on
85
`include "defines.v"
86
 
87
module generic_spram_2048x32(
88
        // Generic synchronous single-port RAM interface
89
        clk, rst, ce, we, oe, addr, di, do
90
);
91
 
92
//
93
// Default address and data buses width
94
//
95
parameter aw = 11;
96
parameter dw = 32;
97
 
98
//
99
// Generic synchronous single-port RAM interface
100
//
101
input                   clk;    // Clock
102
input                   rst;    // Reset
103
input                   ce;     // Chip enable input
104
input                   we;     // Write enable input
105
input                   oe;     // Output enable input
106
input   [aw-1:0] addr;   // address bus inputs
107
input   [dw-1:0] di;     // input data bus
108
output  [dw-1:0] do;     // output data bus
109
 
110
//
111
// Internal wires and registers
112
//
113
 
114
 
115
`ifdef ARTISAN_SSP
116
 
117
//
118
// Instantiation of ASIC memory:
119
//
120
// Artisan Synchronous Single-Port RAM (ra1sh)
121
//
122
`ifdef UNUSED
123
art_hdsp_2048x32 #(dw, 1<<aw, aw) artisan_ssp(
124
`else
125
art_hdsp_2048x32 artisan_ssp(
126
`endif
127
        .clk(clk),
128
        .cen(~ce),
129
        .wen(~we),
130
        .a(addr),
131
        .d(di),
132
        .oen(~oe),
133
        .q(do)
134
);
135
 
136
`else
137
 
138
`ifdef AVANT_ATP
139
 
140
//
141
// Instantiation of ASIC memory:
142
//
143
// Avant! Asynchronous Two-Port RAM
144
//
145
avant_atp avant_atp(
146
        .web(~we),
147
        .reb(),
148
        .oeb(~oe),
149
        .rcsb(),
150
        .wcsb(),
151
        .ra(addr),
152
        .wa(addr),
153
        .di(di),
154
        .do(do)
155
);
156
 
157
`else
158
 
159
`ifdef VIRAGE_SSP
160
 
161
//
162
// Instantiation of ASIC memory:
163
//
164
// Virage Synchronous 1-port R/W RAM
165
//
166
virage_ssp virage_ssp(
167
        .clk(clk),
168
        .adr(addr),
169
        .d(di),
170
        .we(we),
171
        .oe(oe),
172
        .me(ce),
173
        .q(do)
174
);
175
 
176
`else
177
 
178
`ifdef VIRTUALSILICON_SSP
179
 
180
//
181
// Instantiation of ASIC memory:
182
//
183
// Virtual Silicon Single-Port Synchronous SRAM
184
//
185 265 lampret
`ifdef UNUSED
186
vs_hdsp_2048x32 #(1<<aw, aw-1, dw-1) vs_ssp(
187
`else
188
vs_hdsp_2048x32 vs_ssp(
189
`endif
190 218 lampret
        .CK(clk),
191
        .ADR(addr),
192
        .DI(di),
193
        .WEN(~we),
194
        .CEN(~ce),
195
        .OEN(~oe),
196
        .DOUT(do)
197
);
198
 
199
`else
200
 
201
`ifdef XILINX_RAMB4
202
 
203
//
204
// Instantiation of FPGA memory:
205
//
206
// Virtex/Spartan2
207
//
208
 
209
//
210
// Block 0
211
//
212
RAMB4_S2 ramb4_s2_0(
213
        .CLK(clk),
214
        .RST(rst),
215
        .ADDR(addr),
216
        .DI(di[1:0]),
217
        .EN(ce),
218
        .WE(we),
219
        .DO(do[1:0])
220
);
221
 
222
//
223
// Block 1
224
//
225
RAMB4_S2 ramb4_s2_1(
226
        .CLK(clk),
227
        .RST(rst),
228
        .ADDR(addr),
229
        .DI(di[3:2]),
230
        .EN(ce),
231
        .WE(we),
232
        .DO(do[3:2])
233
);
234
 
235
//
236
// Block 2
237
//
238
RAMB4_S2 ramb4_s2_2(
239
        .CLK(clk),
240
        .RST(rst),
241
        .ADDR(addr),
242
        .DI(di[5:4]),
243
        .EN(ce),
244
        .WE(we),
245
        .DO(do[5:4])
246
);
247
 
248
//
249
// Block 3
250
//
251
RAMB4_S2 ramb4_s2_3(
252
        .CLK(clk),
253
        .RST(rst),
254
        .ADDR(addr),
255
        .DI(di[7:6]),
256
        .EN(ce),
257
        .WE(we),
258
        .DO(do[7:6])
259
);
260
 
261
//
262
// Block 4
263
//
264
RAMB4_S2 ramb4_s2_4(
265
        .CLK(clk),
266
        .RST(rst),
267
        .ADDR(addr),
268
        .DI(di[9:8]),
269
        .EN(ce),
270
        .WE(we),
271
        .DO(do[9:8])
272
);
273
 
274
//
275
// Block 5
276
//
277
RAMB4_S2 ramb4_s2_5(
278
        .CLK(clk),
279
        .RST(rst),
280
        .ADDR(addr),
281
        .DI(di[11:10]),
282
        .EN(ce),
283
        .WE(we),
284
        .DO(do[11:10])
285
);
286
 
287
//
288
// Block 6
289
//
290
RAMB4_S2 ramb4_s2_6(
291
        .CLK(clk),
292
        .RST(rst),
293
        .ADDR(addr),
294
        .DI(di[13:12]),
295
        .EN(ce),
296
        .WE(we),
297
        .DO(do[13:12])
298
);
299
 
300
//
301
// Block 7
302
//
303
RAMB4_S2 ramb4_s2_7(
304
        .CLK(clk),
305
        .RST(rst),
306
        .ADDR(addr),
307
        .DI(di[15:14]),
308
        .EN(ce),
309
        .WE(we),
310
        .DO(do[15:14])
311
);
312
 
313
//
314
// Block 8
315
//
316
RAMB4_S2 ramb4_s2_8(
317
        .CLK(clk),
318
        .RST(rst),
319
        .ADDR(addr),
320
        .DI(di[17:16]),
321
        .EN(ce),
322
        .WE(we),
323
        .DO(do[17:16])
324
);
325
 
326
//
327
// Block 9
328
//
329
RAMB4_S2 ramb4_s2_9(
330
        .CLK(clk),
331
        .RST(rst),
332
        .ADDR(addr),
333
        .DI(di[19:18]),
334
        .EN(ce),
335
        .WE(we),
336
        .DO(do[19:18])
337
);
338
 
339
//
340
// Block 10
341
//
342
RAMB4_S2 ramb4_s2_10(
343
        .CLK(clk),
344
        .RST(rst),
345
        .ADDR(addr),
346
        .DI(di[21:20]),
347
        .EN(ce),
348
        .WE(we),
349
        .DO(do[21:20])
350
);
351
 
352
//
353
// Block 11
354
//
355
RAMB4_S2 ramb4_s2_11(
356
        .CLK(clk),
357
        .RST(rst),
358
        .ADDR(addr),
359
        .DI(di[23:22]),
360
        .EN(ce),
361
        .WE(we),
362
        .DO(do[23:22])
363
);
364
 
365
//
366
// Block 12
367
//
368
RAMB4_S2 ramb4_s2_12(
369
        .CLK(clk),
370
        .RST(rst),
371
        .ADDR(addr),
372
        .DI(di[25:24]),
373
        .EN(ce),
374
        .WE(we),
375
        .DO(do[25:24])
376
);
377
 
378
//
379
// Block 13
380
//
381
RAMB4_S2 ramb4_s2_13(
382
        .CLK(clk),
383
        .RST(rst),
384
        .ADDR(addr),
385
        .DI(di[27:26]),
386
        .EN(ce),
387
        .WE(we),
388
        .DO(do[27:26])
389
);
390
 
391
//
392
// Block 14
393
//
394
RAMB4_S2 ramb4_s2_14(
395
        .CLK(clk),
396
        .RST(rst),
397
        .ADDR(addr),
398
        .DI(di[29:28]),
399
        .EN(ce),
400
        .WE(we),
401
        .DO(do[29:28])
402
);
403
 
404
//
405
// Block 15
406
//
407
RAMB4_S2 ramb4_s2_15(
408
        .CLK(clk),
409
        .RST(rst),
410
        .ADDR(addr),
411
        .DI(di[31:30]),
412
        .EN(ce),
413
        .WE(we),
414
        .DO(do[31:30])
415
);
416
 
417
`else
418
 
419
//
420
// Generic single-port synchronous RAM model
421
//
422
 
423
//
424
// Generic RAM's registers and wires
425
//
426
reg     [dw-1:0] mem [(1<<aw)-1:0];       // RAM content
427
reg     [dw-1:0] do_reg;                 // RAM data output register
428
 
429
//
430
// Data output drivers
431
//
432
assign do = (oe) ? do_reg : {dw{1'bz}};
433
 
434
//
435
// RAM read and write
436
//
437
always @(posedge clk)
438
        if (ce && !we)
439
                do_reg <= #1 mem[addr];
440
        else if (ce && we)
441
                mem[addr] <= #1 di;
442
 
443
`endif  // !XILINX_RAMB4_S16
444
`endif  // !VIRTUALSILICON_SSP
445
`endif  // !VIRAGE_SSP
446
`endif  // !AVANT_ATP
447
`endif  // !ARTISAN_SSP
448
 
449
endmodule

powered by: WebSVN 2.1.0

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