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

Subversion Repositories or1k

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

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 504 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 1129 lampret
////  - Altera LPM                                                ////
27 504 lampret
////                                                              ////
28
////  To Do:                                                      ////
29
////   - xilinx rams need external tri-state logic                ////
30
////   - fix avant! two-port ram                                  ////
31 1129 lampret
////   - add additional RAMs                                      ////
32 504 lampret
////                                                              ////
33
////  Author(s):                                                  ////
34
////      - Damjan Lampret, lampret@opencores.org                 ////
35
////                                                              ////
36
//////////////////////////////////////////////////////////////////////
37
////                                                              ////
38
//// Copyright (C) 2000 Authors and OPENCORES.ORG                 ////
39
////                                                              ////
40
//// This source file may be used and distributed without         ////
41
//// restriction provided that this copyright statement is not    ////
42
//// removed from the file and that any derivative work contains  ////
43
//// the original copyright notice and the associated disclaimer. ////
44
////                                                              ////
45
//// This source file is free software; you can redistribute it   ////
46
//// and/or modify it under the terms of the GNU Lesser General   ////
47
//// Public License as published by the Free Software Foundation; ////
48
//// either version 2.1 of the License, or (at your option) any   ////
49
//// later version.                                               ////
50
////                                                              ////
51
//// This source is distributed in the hope that it will be       ////
52
//// useful, but WITHOUT ANY WARRANTY; without even the implied   ////
53
//// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR      ////
54
//// PURPOSE.  See the GNU Lesser General Public License for more ////
55
//// details.                                                     ////
56
////                                                              ////
57
//// You should have received a copy of the GNU Lesser General    ////
58
//// Public License along with this source; if not, download it   ////
59
//// from http://www.opencores.org/lgpl.shtml                     ////
60
////                                                              ////
61
//////////////////////////////////////////////////////////////////////
62
//
63
// CVS Revision History
64
//
65
// $Log: not supported by cvs2svn $
66 1129 lampret
// Revision 1.3  2002/10/28 15:03:50  mohor
67
// Signal scanb_sen renamed to scanb_en.
68
//
69 1077 mohor
// Revision 1.2  2002/10/17 20:04:40  lampret
70
// Added BIST scan. Special VS RAMs need to be used to implement BIST.
71
//
72 1063 lampret
// Revision 1.1  2002/01/03 08:16:15  lampret
73
// New prefixes for RTL files, prefixed module names. Updated cache controllers and MMUs.
74
//
75 504 lampret
// Revision 1.8  2001/11/02 18:57:14  lampret
76
// Modified virtual silicon instantiations.
77
//
78
// Revision 1.7  2001/10/21 17:57:16  lampret
79
// 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.
80
//
81
// Revision 1.6  2001/10/14 13:12:09  lampret
82
// MP3 version.
83
//
84
// Revision 1.1.1.1  2001/10/06 10:18:36  igorm
85
// no message
86
//
87
// Revision 1.1  2001/08/09 13:39:33  lampret
88
// Major clean-up.
89
//
90
// Revision 1.2  2001/07/30 05:38:02  lampret
91
// Adding empty directories required by HDL coding guidelines
92
//
93
//
94
 
95
// synopsys translate_off
96
`include "timescale.v"
97
// synopsys translate_on
98
`include "or1200_defines.v"
99
 
100
module or1200_spram_2048x32(
101 1063 lampret
`ifdef OR1200_BIST
102
        // RAM BIST
103
        scanb_rst, scanb_si, scanb_so, scanb_en, scanb_clk,
104
`endif
105 504 lampret
        // Generic synchronous single-port RAM interface
106
        clk, rst, ce, we, oe, addr, di, do
107
);
108
 
109
//
110
// Default address and data buses width
111
//
112
parameter aw = 11;
113
parameter dw = 32;
114
 
115 1063 lampret
`ifdef OR1200_BIST
116 504 lampret
//
117 1063 lampret
// RAM BIST
118
//
119
input                   scanb_rst,
120
                        scanb_si,
121
                        scanb_en,
122
                        scanb_clk;
123
output                  scanb_so;
124
`endif
125
 
126
//
127 504 lampret
// Generic synchronous single-port RAM interface
128
//
129
input                   clk;    // Clock
130
input                   rst;    // Reset
131
input                   ce;     // Chip enable input
132
input                   we;     // Write enable input
133
input                   oe;     // Output enable input
134
input   [aw-1:0] addr;   // address bus inputs
135
input   [dw-1:0] di;     // input data bus
136
output  [dw-1:0] do;     // output data bus
137
 
138
//
139
// Internal wires and registers
140
//
141
 
142 1063 lampret
`ifdef OR1200_VIRTUALSILICON_SSP
143
`else
144
`ifdef OR1200_BIST
145
assign scanb_so = scanb_si;
146
`endif
147
`endif
148 504 lampret
 
149
`ifdef OR1200_ARTISAN_SSP
150
 
151
//
152
// Instantiation of ASIC memory:
153
//
154
// Artisan Synchronous Single-Port RAM (ra1sh)
155
//
156
`ifdef UNUSED
157
art_hdsp_2048x32 #(dw, 1<<aw, aw) artisan_ssp(
158
`else
159
art_hdsp_2048x32 artisan_ssp(
160
`endif
161
        .clk(clk),
162
        .cen(~ce),
163
        .wen(~we),
164
        .a(addr),
165
        .d(di),
166
        .oen(~oe),
167
        .q(do)
168
);
169
 
170
`else
171
 
172
`ifdef OR1200_AVANT_ATP
173
 
174
//
175
// Instantiation of ASIC memory:
176
//
177
// Avant! Asynchronous Two-Port RAM
178
//
179
avant_atp avant_atp(
180
        .web(~we),
181
        .reb(),
182
        .oeb(~oe),
183
        .rcsb(),
184
        .wcsb(),
185
        .ra(addr),
186
        .wa(addr),
187
        .di(di),
188
        .do(do)
189
);
190
 
191
`else
192
 
193
`ifdef OR1200_VIRAGE_SSP
194
 
195
//
196
// Instantiation of ASIC memory:
197
//
198
// Virage Synchronous 1-port R/W RAM
199
//
200
virage_ssp virage_ssp(
201
        .clk(clk),
202
        .adr(addr),
203
        .d(di),
204
        .we(we),
205
        .oe(oe),
206
        .me(ce),
207
        .q(do)
208
);
209
 
210
`else
211
 
212
`ifdef OR1200_VIRTUALSILICON_SSP
213
 
214
//
215
// Instantiation of ASIC memory:
216
//
217
// Virtual Silicon Single-Port Synchronous SRAM
218
//
219
`ifdef UNUSED
220
vs_hdsp_2048x32 #(1<<aw, aw-1, dw-1) vs_ssp(
221
`else
222 1063 lampret
`ifdef OR1200_BIST
223
vs_hdsp_2048x32_bist vs_ssp(
224
`else
225 504 lampret
vs_hdsp_2048x32 vs_ssp(
226
`endif
227 1063 lampret
`endif
228
`ifdef OR1200_BIST
229
        // RAM BIST
230
        .scanb_rst(scanb_rst),
231
        .scanb_si(scanb_si),
232
        .scanb_so(scanb_so),
233
        .scanb_en(scanb_en),
234 1077 mohor
        .scanb_clk(scanb_clk),
235 1063 lampret
`endif
236 504 lampret
        .CK(clk),
237
        .ADR(addr),
238
        .DI(di),
239
        .WEN(~we),
240
        .CEN(~ce),
241
        .OEN(~oe),
242
        .DOUT(do)
243
);
244
 
245
`else
246
 
247
`ifdef OR1200_XILINX_RAMB4
248
 
249
//
250
// Instantiation of FPGA memory:
251
//
252
// Virtex/Spartan2
253
//
254
 
255
//
256
// Block 0
257
//
258
RAMB4_S2 ramb4_s2_0(
259
        .CLK(clk),
260
        .RST(rst),
261
        .ADDR(addr),
262
        .DI(di[1:0]),
263
        .EN(ce),
264
        .WE(we),
265
        .DO(do[1:0])
266
);
267
 
268
//
269
// Block 1
270
//
271
RAMB4_S2 ramb4_s2_1(
272
        .CLK(clk),
273
        .RST(rst),
274
        .ADDR(addr),
275
        .DI(di[3:2]),
276
        .EN(ce),
277
        .WE(we),
278
        .DO(do[3:2])
279
);
280
 
281
//
282
// Block 2
283
//
284
RAMB4_S2 ramb4_s2_2(
285
        .CLK(clk),
286
        .RST(rst),
287
        .ADDR(addr),
288
        .DI(di[5:4]),
289
        .EN(ce),
290
        .WE(we),
291
        .DO(do[5:4])
292
);
293
 
294
//
295
// Block 3
296
//
297
RAMB4_S2 ramb4_s2_3(
298
        .CLK(clk),
299
        .RST(rst),
300
        .ADDR(addr),
301
        .DI(di[7:6]),
302
        .EN(ce),
303
        .WE(we),
304
        .DO(do[7:6])
305
);
306
 
307
//
308
// Block 4
309
//
310
RAMB4_S2 ramb4_s2_4(
311
        .CLK(clk),
312
        .RST(rst),
313
        .ADDR(addr),
314
        .DI(di[9:8]),
315
        .EN(ce),
316
        .WE(we),
317
        .DO(do[9:8])
318
);
319
 
320
//
321
// Block 5
322
//
323
RAMB4_S2 ramb4_s2_5(
324
        .CLK(clk),
325
        .RST(rst),
326
        .ADDR(addr),
327
        .DI(di[11:10]),
328
        .EN(ce),
329
        .WE(we),
330
        .DO(do[11:10])
331
);
332
 
333
//
334
// Block 6
335
//
336
RAMB4_S2 ramb4_s2_6(
337
        .CLK(clk),
338
        .RST(rst),
339
        .ADDR(addr),
340
        .DI(di[13:12]),
341
        .EN(ce),
342
        .WE(we),
343
        .DO(do[13:12])
344
);
345
 
346
//
347
// Block 7
348
//
349
RAMB4_S2 ramb4_s2_7(
350
        .CLK(clk),
351
        .RST(rst),
352
        .ADDR(addr),
353
        .DI(di[15:14]),
354
        .EN(ce),
355
        .WE(we),
356
        .DO(do[15:14])
357
);
358
 
359
//
360
// Block 8
361
//
362
RAMB4_S2 ramb4_s2_8(
363
        .CLK(clk),
364
        .RST(rst),
365
        .ADDR(addr),
366
        .DI(di[17:16]),
367
        .EN(ce),
368
        .WE(we),
369
        .DO(do[17:16])
370
);
371
 
372
//
373
// Block 9
374
//
375
RAMB4_S2 ramb4_s2_9(
376
        .CLK(clk),
377
        .RST(rst),
378
        .ADDR(addr),
379
        .DI(di[19:18]),
380
        .EN(ce),
381
        .WE(we),
382
        .DO(do[19:18])
383
);
384
 
385
//
386
// Block 10
387
//
388
RAMB4_S2 ramb4_s2_10(
389
        .CLK(clk),
390
        .RST(rst),
391
        .ADDR(addr),
392
        .DI(di[21:20]),
393
        .EN(ce),
394
        .WE(we),
395
        .DO(do[21:20])
396
);
397
 
398
//
399
// Block 11
400
//
401
RAMB4_S2 ramb4_s2_11(
402
        .CLK(clk),
403
        .RST(rst),
404
        .ADDR(addr),
405
        .DI(di[23:22]),
406
        .EN(ce),
407
        .WE(we),
408
        .DO(do[23:22])
409
);
410
 
411
//
412
// Block 12
413
//
414
RAMB4_S2 ramb4_s2_12(
415
        .CLK(clk),
416
        .RST(rst),
417
        .ADDR(addr),
418
        .DI(di[25:24]),
419
        .EN(ce),
420
        .WE(we),
421
        .DO(do[25:24])
422
);
423
 
424
//
425
// Block 13
426
//
427
RAMB4_S2 ramb4_s2_13(
428
        .CLK(clk),
429
        .RST(rst),
430
        .ADDR(addr),
431
        .DI(di[27:26]),
432
        .EN(ce),
433
        .WE(we),
434
        .DO(do[27:26])
435
);
436
 
437
//
438
// Block 14
439
//
440
RAMB4_S2 ramb4_s2_14(
441
        .CLK(clk),
442
        .RST(rst),
443
        .ADDR(addr),
444
        .DI(di[29:28]),
445
        .EN(ce),
446
        .WE(we),
447
        .DO(do[29:28])
448
);
449
 
450
//
451
// Block 15
452
//
453
RAMB4_S2 ramb4_s2_15(
454
        .CLK(clk),
455
        .RST(rst),
456
        .ADDR(addr),
457
        .DI(di[31:30]),
458
        .EN(ce),
459
        .WE(we),
460
        .DO(do[31:30])
461
);
462
 
463
`else
464
 
465 1129 lampret
`ifdef OR1200_ALTERA_LPM
466
 
467 504 lampret
//
468 1129 lampret
// Instantiation of FPGA memory:
469
//
470
// Altera LPM
471
//
472
// Added By Jamil Khatib
473
//
474
 
475
wire    wr;
476
 
477
assign  wr = ce & we;
478
 
479
initial $display("Using Altera LPM.");
480
 
481
lpm_ram_dq lpm_ram_dq_component (
482
        .address(addr),
483
        .inclock(clk),
484
        .outclock(clk),
485
        .data(di),
486
        .we(wr),
487
        .q(do)
488
);
489
 
490
defparam lpm_ram_dq_component.lpm_width = dw,
491
        lpm_ram_dq_component.lpm_widthad = aw,
492
        lpm_ram_dq_component.lpm_indata = "REGISTERED",
493
        lpm_ram_dq_component.lpm_address_control = "REGISTERED",
494
        lpm_ram_dq_component.lpm_outdata = "UNREGISTERED",
495
        lpm_ram_dq_component.lpm_hint = "USE_EAB=ON";
496
        // examplar attribute lpm_ram_dq_component NOOPT TRUE
497
 
498
`else
499
 
500
//
501 504 lampret
// Generic single-port synchronous RAM model
502
//
503
 
504
//
505
// Generic RAM's registers and wires
506
//
507
reg     [dw-1:0] mem [(1<<aw)-1:0];       // RAM content
508
reg     [dw-1:0] do_reg;                 // RAM data output register
509
 
510
//
511
// Data output drivers
512
//
513 1129 lampret
assign do = (oe) ? do_reg : {dw{1'b0}};
514 504 lampret
 
515
//
516
// RAM read and write
517
//
518
always @(posedge clk)
519
        if (ce && !we)
520
                do_reg <= #1 mem[addr];
521
        else if (ce && we)
522
                mem[addr] <= #1 di;
523
 
524 1129 lampret
`endif  // !OR1200_ALTERA_LPM
525 504 lampret
`endif  // !OR1200_XILINX_RAMB4_S16
526
`endif  // !OR1200_VIRTUALSILICON_SSP
527
`endif  // !OR1200_VIRAGE_SSP
528
`endif  // !OR1200_AVANT_ATP
529
`endif  // !OR1200_ARTISAN_SSP
530
 
531
endmodule

powered by: WebSVN 2.1.0

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