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 218

Go to most recent revision | 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
// Revision 1.6  2001/10/14 13:12:09  lampret
66
// MP3 version.
67
//
68
// Revision 1.1.1.1  2001/10/06 10:18:36  igorm
69
// no message
70
//
71
// Revision 1.1  2001/08/09 13:39:33  lampret
72
// Major clean-up.
73
//
74
// Revision 1.2  2001/07/30 05:38:02  lampret
75
// Adding empty directories required by HDL coding guidelines
76
//
77
//
78
 
79
// synopsys translate_off
80
`include "timescale.v"
81
// synopsys translate_on
82
`include "defines.v"
83
 
84
module generic_spram_2048x32(
85
        // Generic synchronous single-port RAM interface
86
        clk, rst, ce, we, oe, addr, di, do
87
);
88
 
89
//
90
// Default address and data buses width
91
//
92
parameter aw = 11;
93
parameter dw = 32;
94
 
95
//
96
// Generic synchronous single-port RAM interface
97
//
98
input                   clk;    // Clock
99
input                   rst;    // Reset
100
input                   ce;     // Chip enable input
101
input                   we;     // Write enable input
102
input                   oe;     // Output enable input
103
input   [aw-1:0] addr;   // address bus inputs
104
input   [dw-1:0] di;     // input data bus
105
output  [dw-1:0] do;     // output data bus
106
 
107
//
108
// Internal wires and registers
109
//
110
 
111
 
112
`ifdef ARTISAN_SSP
113
 
114
//
115
// Instantiation of ASIC memory:
116
//
117
// Artisan Synchronous Single-Port RAM (ra1sh)
118
//
119
`ifdef UNUSED
120
art_hdsp_2048x32 #(dw, 1<<aw, aw) artisan_ssp(
121
`else
122
art_hdsp_2048x32 artisan_ssp(
123
`endif
124
        .clk(clk),
125
        .cen(~ce),
126
        .wen(~we),
127
        .a(addr),
128
        .d(di),
129
        .oen(~oe),
130
        .q(do)
131
);
132
 
133
`else
134
 
135
`ifdef AVANT_ATP
136
 
137
//
138
// Instantiation of ASIC memory:
139
//
140
// Avant! Asynchronous Two-Port RAM
141
//
142
avant_atp avant_atp(
143
        .web(~we),
144
        .reb(),
145
        .oeb(~oe),
146
        .rcsb(),
147
        .wcsb(),
148
        .ra(addr),
149
        .wa(addr),
150
        .di(di),
151
        .do(do)
152
);
153
 
154
`else
155
 
156
`ifdef VIRAGE_SSP
157
 
158
//
159
// Instantiation of ASIC memory:
160
//
161
// Virage Synchronous 1-port R/W RAM
162
//
163
virage_ssp virage_ssp(
164
        .clk(clk),
165
        .adr(addr),
166
        .d(di),
167
        .we(we),
168
        .oe(oe),
169
        .me(ce),
170
        .q(do)
171
);
172
 
173
`else
174
 
175
`ifdef VIRTUALSILICON_SSP
176
 
177
//
178
// Instantiation of ASIC memory:
179
//
180
// Virtual Silicon Single-Port Synchronous SRAM
181
//
182
virtualsilicon_ssp #(1<<aw, aw-1, dw-1) virtualsilicon_ssp(
183
        .CK(clk),
184
        .ADR(addr),
185
        .DI(di),
186
        .WEN(~we),
187
        .CEN(~ce),
188
        .OEN(~oe),
189
        .DOUT(do)
190
);
191
 
192
`else
193
 
194
`ifdef XILINX_RAMB4
195
 
196
//
197
// Instantiation of FPGA memory:
198
//
199
// Virtex/Spartan2
200
//
201
 
202
//
203
// Block 0
204
//
205
RAMB4_S2 ramb4_s2_0(
206
        .CLK(clk),
207
        .RST(rst),
208
        .ADDR(addr),
209
        .DI(di[1:0]),
210
        .EN(ce),
211
        .WE(we),
212
        .DO(do[1:0])
213
);
214
 
215
//
216
// Block 1
217
//
218
RAMB4_S2 ramb4_s2_1(
219
        .CLK(clk),
220
        .RST(rst),
221
        .ADDR(addr),
222
        .DI(di[3:2]),
223
        .EN(ce),
224
        .WE(we),
225
        .DO(do[3:2])
226
);
227
 
228
//
229
// Block 2
230
//
231
RAMB4_S2 ramb4_s2_2(
232
        .CLK(clk),
233
        .RST(rst),
234
        .ADDR(addr),
235
        .DI(di[5:4]),
236
        .EN(ce),
237
        .WE(we),
238
        .DO(do[5:4])
239
);
240
 
241
//
242
// Block 3
243
//
244
RAMB4_S2 ramb4_s2_3(
245
        .CLK(clk),
246
        .RST(rst),
247
        .ADDR(addr),
248
        .DI(di[7:6]),
249
        .EN(ce),
250
        .WE(we),
251
        .DO(do[7:6])
252
);
253
 
254
//
255
// Block 4
256
//
257
RAMB4_S2 ramb4_s2_4(
258
        .CLK(clk),
259
        .RST(rst),
260
        .ADDR(addr),
261
        .DI(di[9:8]),
262
        .EN(ce),
263
        .WE(we),
264
        .DO(do[9:8])
265
);
266
 
267
//
268
// Block 5
269
//
270
RAMB4_S2 ramb4_s2_5(
271
        .CLK(clk),
272
        .RST(rst),
273
        .ADDR(addr),
274
        .DI(di[11:10]),
275
        .EN(ce),
276
        .WE(we),
277
        .DO(do[11:10])
278
);
279
 
280
//
281
// Block 6
282
//
283
RAMB4_S2 ramb4_s2_6(
284
        .CLK(clk),
285
        .RST(rst),
286
        .ADDR(addr),
287
        .DI(di[13:12]),
288
        .EN(ce),
289
        .WE(we),
290
        .DO(do[13:12])
291
);
292
 
293
//
294
// Block 7
295
//
296
RAMB4_S2 ramb4_s2_7(
297
        .CLK(clk),
298
        .RST(rst),
299
        .ADDR(addr),
300
        .DI(di[15:14]),
301
        .EN(ce),
302
        .WE(we),
303
        .DO(do[15:14])
304
);
305
 
306
//
307
// Block 8
308
//
309
RAMB4_S2 ramb4_s2_8(
310
        .CLK(clk),
311
        .RST(rst),
312
        .ADDR(addr),
313
        .DI(di[17:16]),
314
        .EN(ce),
315
        .WE(we),
316
        .DO(do[17:16])
317
);
318
 
319
//
320
// Block 9
321
//
322
RAMB4_S2 ramb4_s2_9(
323
        .CLK(clk),
324
        .RST(rst),
325
        .ADDR(addr),
326
        .DI(di[19:18]),
327
        .EN(ce),
328
        .WE(we),
329
        .DO(do[19:18])
330
);
331
 
332
//
333
// Block 10
334
//
335
RAMB4_S2 ramb4_s2_10(
336
        .CLK(clk),
337
        .RST(rst),
338
        .ADDR(addr),
339
        .DI(di[21:20]),
340
        .EN(ce),
341
        .WE(we),
342
        .DO(do[21:20])
343
);
344
 
345
//
346
// Block 11
347
//
348
RAMB4_S2 ramb4_s2_11(
349
        .CLK(clk),
350
        .RST(rst),
351
        .ADDR(addr),
352
        .DI(di[23:22]),
353
        .EN(ce),
354
        .WE(we),
355
        .DO(do[23:22])
356
);
357
 
358
//
359
// Block 12
360
//
361
RAMB4_S2 ramb4_s2_12(
362
        .CLK(clk),
363
        .RST(rst),
364
        .ADDR(addr),
365
        .DI(di[25:24]),
366
        .EN(ce),
367
        .WE(we),
368
        .DO(do[25:24])
369
);
370
 
371
//
372
// Block 13
373
//
374
RAMB4_S2 ramb4_s2_13(
375
        .CLK(clk),
376
        .RST(rst),
377
        .ADDR(addr),
378
        .DI(di[27:26]),
379
        .EN(ce),
380
        .WE(we),
381
        .DO(do[27:26])
382
);
383
 
384
//
385
// Block 14
386
//
387
RAMB4_S2 ramb4_s2_14(
388
        .CLK(clk),
389
        .RST(rst),
390
        .ADDR(addr),
391
        .DI(di[29:28]),
392
        .EN(ce),
393
        .WE(we),
394
        .DO(do[29:28])
395
);
396
 
397
//
398
// Block 15
399
//
400
RAMB4_S2 ramb4_s2_15(
401
        .CLK(clk),
402
        .RST(rst),
403
        .ADDR(addr),
404
        .DI(di[31:30]),
405
        .EN(ce),
406
        .WE(we),
407
        .DO(do[31:30])
408
);
409
 
410
`else
411
 
412
//
413
// Generic single-port synchronous RAM model
414
//
415
 
416
//
417
// Generic RAM's registers and wires
418
//
419
reg     [dw-1:0] mem [(1<<aw)-1:0];       // RAM content
420
reg     [dw-1:0] do_reg;                 // RAM data output register
421
 
422
//
423
// Data output drivers
424
//
425
assign do = (oe) ? do_reg : {dw{1'bz}};
426
 
427
//
428
// RAM read and write
429
//
430
always @(posedge clk)
431
        if (ce && !we)
432
                do_reg <= #1 mem[addr];
433
        else if (ce && we)
434
                mem[addr] <= #1 di;
435
 
436
`endif  // !XILINX_RAMB4_S16
437
`endif  // !VIRTUALSILICON_SSP
438
`endif  // !VIRAGE_SSP
439
`endif  // !AVANT_ATP
440
`endif  // !ARTISAN_SSP
441
 
442
endmodule

powered by: WebSVN 2.1.0

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