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

Subversion Repositories or1k

[/] [or1k/] [tags/] [rel_13/] [or1200/] [rtl/] [verilog/] [or1200_spram_2048x32.v] - Blame information for rev 1189

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

powered by: WebSVN 2.1.0

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