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

Subversion Repositories or1k_soc_on_altera_embedded_dev_kit

[/] [or1k_soc_on_altera_embedded_dev_kit/] [trunk/] [soc/] [rtl/] [or1200/] [rtl/] [verilog/] [or1200_dpram_32x32.v] - Blame information for rev 12

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 12 xianfeng
//////////////////////////////////////////////////////////////////////
2
////                                                              ////
3
////  Generic Double-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 double-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
////  double-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 Double-Port Sync RAM                              ////
20
////  - Avant! Two-Port Sync RAM (*)                              ////
21
////  - Virage 2-port Sync RAM                                    ////
22
////                                                              ////
23
////  Supported FPGA RAMs are:                                    ////
24
////  - Xilinx Virtex RAMB16                                      ////
25
////  - Xilinx Virtex RAMB4                                       ////
26
////  - Altera LPM                                                ////
27
////                                                              ////
28
////  To Do:                                                      ////
29
////   - fix Avant!                                               ////
30
////   - xilinx rams need external tri-state logic                ////
31
////   - add additional RAMs                                      ////
32
////                                                              ////
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: or1200_dpram_32x32.v,v $
66
// Revision 1.10  2005/10/19 11:37:56  jcastillo
67
// Added support for RAMB16 Xilinx4/Spartan3 primitives
68
//
69
// Revision 1.9  2004/06/08 18:15:48  lampret
70
// Changed behavior of the simulation generic models
71
//
72
// Revision 1.8  2004/04/05 08:29:57  lampret
73
// Merged branch_qmem into main tree.
74
//
75
// Revision 1.7.4.1  2003/07/08 15:36:37  lampret
76
// Added embedded memory QMEM.
77
//
78
// Revision 1.7  2003/04/07 01:19:07  lampret
79
// Added Altera LPM RAMs. Changed generic RAM output when OE inactive.
80
//
81
// Revision 1.6  2002/03/28 19:25:42  lampret
82
// Added second type of Virtual Silicon two-port SRAM (for register file). Changed defines for VS STP RAMs.
83
//
84
// Revision 1.5  2002/02/01 19:56:54  lampret
85
// Fixed combinational loops.
86
//
87
// Revision 1.4  2002/01/23 07:52:36  lampret
88
// Changed default reset values for SR and ESR to match or1ksim's. Fixed flop model in or1200_dpram_32x32 when OR1200_XILINX_RAM32X1D is defined.
89
//
90
// Revision 1.3  2002/01/19 14:10:22  lampret
91
// Fixed OR1200_XILINX_RAM32X1D.
92
//
93
// Revision 1.2  2002/01/15 06:12:22  lampret
94
// Fixed module name when compiling with OR1200_XILINX_RAM32X1D
95
//
96
// Revision 1.1  2002/01/03 08:16:15  lampret
97
// New prefixes for RTL files, prefixed module names. Updated cache controllers and MMUs.
98
//
99
// Revision 1.10  2001/11/05 14:48:00  lampret
100
// Added missing endif
101
//
102
// Revision 1.9  2001/11/02 18:57:14  lampret
103
// Modified virtual silicon instantiations.
104
//
105
// Revision 1.8  2001/10/22 19:39:56  lampret
106
// Fixed parameters in generic sprams.
107
//
108
// Revision 1.7  2001/10/21 17:57:16  lampret
109
// 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.
110
//
111
// Revision 1.6  2001/10/14 13:12:09  lampret
112
// MP3 version.
113
//
114
// Revision 1.1.1.1  2001/10/06 10:18:36  igorm
115
// no message
116
//
117
// Revision 1.1  2001/08/09 13:39:33  lampret
118
// Major clean-up.
119
//
120
// Revision 1.2  2001/07/30 05:38:02  lampret
121
// Adding empty directories required by HDL coding guidelines
122
//
123
//
124
 
125
// synopsys translate_off
126
`include "timescale.v"
127
// synopsys translate_on
128
`include "or1200_defines.v"
129
 
130
module or1200_dpram_32x32(
131
        // Generic synchronous double-port RAM interface
132
        clk_a, rst_a, ce_a, oe_a, addr_a, do_a,
133
        clk_b, rst_b, ce_b, we_b, addr_b, di_b
134
);
135
 
136
//
137
// Default address and data buses width
138
//
139
parameter aw = 5;
140
parameter dw = 32;
141
 
142
//
143
// Generic synchronous double-port RAM interface
144
//
145
input                   clk_a;  // Clock
146
input                   rst_a;  // Reset
147
input                   ce_a;   // Chip enable input
148
input                   oe_a;   // Output enable input
149
input   [aw-1:0] addr_a; // address bus inputs
150
output  [dw-1:0] do_a;   // output data bus
151
input                   clk_b;  // Clock
152
input                   rst_b;  // Reset
153
input                   ce_b;   // Chip enable input
154
input                   we_b;   // Write enable input
155
input   [aw-1:0] addr_b; // address bus inputs
156
input   [dw-1:0] di_b;   // input data bus
157
 
158
//
159
// Internal wires and registers
160
//
161
 
162
`ifdef OR1200_ARTISAN_SDP
163
 
164
//
165
// Instantiation of ASIC memory:
166
//
167
// Artisan Synchronous Double-Port RAM (ra2sh)
168
//
169
`ifdef UNUSED
170
art_hsdp_32x32 #(dw, 1<<aw, aw) artisan_sdp(
171
`else
172
art_hsdp_32x32 artisan_sdp(
173
`endif
174
        .qa(do_a),
175
        .clka(clk_a),
176
        .cena(~ce_a),
177
        .wena(1'b1),
178
        .aa(addr_a),
179
        .da(32'h00000000),
180
        .oena(~oe_a),
181
        .qb(),
182
        .clkb(clk_b),
183
        .cenb(~ce_b),
184
        .wenb(~we_b),
185
        .ab(addr_b),
186
        .db(di_b),
187
        .oenb(1'b1)
188
);
189
 
190
`else
191
 
192
`ifdef OR1200_AVANT_ATP
193
 
194
//
195
// Instantiation of ASIC memory:
196
//
197
// Avant! Asynchronous Two-Port RAM
198
//
199
avant_atp avant_atp(
200
        .web(~we),
201
        .reb(),
202
        .oeb(~oe),
203
        .rcsb(),
204
        .wcsb(),
205
        .ra(addr),
206
        .wa(addr),
207
        .di(di),
208
        .doq(doq)
209
);
210
 
211
`else
212
 
213
`ifdef OR1200_VIRAGE_STP
214
 
215
//
216
// Instantiation of ASIC memory:
217
//
218
// Virage Synchronous 2-port R/W RAM
219
//
220
virage_stp virage_stp(
221
        .QA(do_a),
222
        .QB(),
223
 
224
        .ADRA(addr_a),
225
        .DA(32'h00000000),
226
        .WEA(1'b0),
227
        .OEA(oe_a),
228
        .MEA(ce_a),
229
        .CLKA(clk_a),
230
 
231
        .ADRB(addr_b),
232
        .DB(di_b),
233
        .WEB(we_b),
234
        .OEB(1'b1),
235
        .MEB(ce_b),
236
        .CLKB(clk_b)
237
);
238
 
239
`else
240
 
241
`ifdef OR1200_VIRTUALSILICON_STP_T1
242
 
243
//
244
// Instantiation of ASIC memory:
245
//
246
// Virtual Silicon Two-port R/W SRAM Type 1
247
//
248
`ifdef UNUSED
249
vs_hdtp_64x32 #(1<<aw, aw-1, dw-1) vs_ssp(
250
`else
251
vs_hdtp_64x32 vs_ssp(
252
`endif
253
        .P1CK(clk_a),
254
        .P1CEN(~ce_a),
255
        .P1WEN(1'b1),
256
        .P1OEN(~oe_a),
257
        .P1ADR({1'b0, addr_a}),
258
        .P1DI(32'h0000_0000),
259
        .P1DOUT(do_a),
260
 
261
        .P2CK(clk_b),
262
        .P2CEN(~ce_b),
263
        .P2WEN(~ce_b),
264
        .P2OEN(1'b1),
265
        .P2ADR({1'b0, addr_b}),
266
        .P2DI(di_b),
267
        .P2DOUT()
268
);
269
 
270
`else
271
 
272
`ifdef OR1200_VIRTUALSILICON_STP_T2
273
 
274
//
275
// Instantiation of ASIC memory:
276
//
277
// Virtual Silicon Two-port R/W SRAM Type 2
278
//
279
`ifdef UNUSED
280
vs_hdtp_32x32 #(1<<aw, aw-1, dw-1) vs_ssp(
281
`else
282
vs_hdtp_32x32 vs_ssp(
283
`endif
284
        .RCK(clk_a),
285
        .REN(~ce_a),
286
        .OEN(~oe_a),
287
        .RADR(addr_a),
288
        .DOUT(do_a),
289
 
290
        .WCK(clk_b),
291
        .WEN(~ce_b),
292
        .WADR(addr_b),
293
        .DI(di_b)
294
);
295
 
296
`else
297
 
298
`ifdef OR1200_XILINX_RAM32X1D
299
 
300
//
301
// Instantiation of FPGA memory:
302
//
303
// Virtex/Spartan2
304
//
305
 
306
reg     [4:0]    addr_a_r;
307
 
308
always @(posedge clk_a or posedge rst_a)
309
        if (rst_a)
310
                addr_a_r <= #1 5'b00000;
311
        else if (ce_a)
312
                addr_a_r <= #1 addr_a;
313
 
314
//
315
// Block 0
316
//
317
or1200_xcv_ram32x8d xcv_ram32x8d_0 (
318
        .DPO(do_a[7:0]),
319
        .SPO(),
320
        .A(addr_b),
321
        .D(di_b[7:0]),
322
        .DPRA(addr_a_r),
323
        .WCLK(clk_b),
324
        .WE(we_b)
325
);
326
 
327
//
328
// Block 1
329
//
330
or1200_xcv_ram32x8d xcv_ram32x8d_1 (
331
        .DPO(do_a[15:8]),
332
        .SPO(),
333
        .A(addr_b),
334
        .D(di_b[15:8]),
335
        .DPRA(addr_a_r),
336
        .WCLK(clk_b),
337
        .WE(we_b)
338
);
339
 
340
 
341
//
342
// Block 2
343
//
344
or1200_xcv_ram32x8d xcv_ram32x8d_2 (
345
        .DPO(do_a[23:16]),
346
        .SPO(),
347
        .A(addr_b),
348
        .D(di_b[23:16]),
349
        .DPRA(addr_a_r),
350
        .WCLK(clk_b),
351
        .WE(we_b)
352
);
353
 
354
//
355
// Block 3
356
//
357
or1200_xcv_ram32x8d xcv_ram32x8d_3 (
358
        .DPO(do_a[31:24]),
359
        .SPO(),
360
        .A(addr_b),
361
        .D(di_b[31:24]),
362
        .DPRA(addr_a_r),
363
        .WCLK(clk_b),
364
        .WE(we_b)
365
);
366
 
367
`else
368
 
369
`ifdef OR1200_XILINX_RAMB4
370
 
371
//
372
// Instantiation of FPGA memory:
373
//
374
// Virtex/Spartan2
375
//
376
 
377
//
378
// Block 0
379
//
380
RAMB4_S16_S16 ramb4_s16_0(
381
        .CLKA(clk_a),
382
        .RSTA(rst_a),
383
        .ADDRA({3'b000, addr_a}),
384
        .DIA(16'h0000),
385
        .ENA(ce_a),
386
        .WEA(1'b0),
387
        .DOA(do_a[15:0]),
388
 
389
        .CLKB(clk_b),
390
        .RSTB(rst_b),
391
        .ADDRB({3'b000, addr_b}),
392
        .DIB(di_b[15:0]),
393
        .ENB(ce_b),
394
        .WEB(we_b),
395
        .DOB()
396
);
397
 
398
//
399
// Block 1
400
//
401
RAMB4_S16_S16 ramb4_s16_1(
402
        .CLKA(clk_a),
403
        .RSTA(rst_a),
404
        .ADDRA({3'b000, addr_a}),
405
        .DIA(16'h0000),
406
        .ENA(ce_a),
407
        .WEA(1'b0),
408
        .DOA(do_a[31:16]),
409
 
410
        .CLKB(clk_b),
411
        .RSTB(rst_b),
412
        .ADDRB({3'b000, addr_b}),
413
        .DIB(di_b[31:16]),
414
        .ENB(ce_b),
415
        .WEB(we_b),
416
        .DOB()
417
);
418
 
419
`else
420
 
421
`ifdef OR1200_XILINX_RAMB16
422
 
423
//
424
// Instantiation of FPGA memory:
425
//
426
// Virtex4/Spartan3E
427
//
428
// Added By Nir Mor
429
//
430
 
431
RAMB16_S36_S36 ramb16_s36_s36(
432
        .CLKA(clk_a),
433
        .SSRA(rst_a),
434
        .ADDRA({4'b0000, addr_a}),
435
        .DIA(32'h00000000),
436
        .DIPA(4'h0),
437
        .ENA(ce_a),
438
        .WEA(1'b0),
439
        .DOA(do_a),
440
        .DOPA(),
441
 
442
        .CLKB(clk_b),
443
        .SSRB(rst_b),
444
        .ADDRB({4'b0000, addr_b}),
445
        .DIB(di_b),
446
        .DIPB(4'h0),
447
        .ENB(ce_b),
448
        .WEB(we_b),
449
        .DOB(),
450
        .DOPB()
451
);
452
 
453
`else
454
 
455
`ifdef OR1200_ALTERA_LPM_XXX
456
 
457
//
458
// Instantiation of FPGA memory:
459
//
460
// Altera LPM
461
//
462
// Added By Jamil Khatib
463
//
464
altqpram altqpram_component (
465
        .wraddress_a (addr_a),
466
        .inclocken_a (ce_a),
467
        .wraddress_b (addr_b),
468
        .wren_a (we_a),
469
        .inclocken_b (ce_b),
470
        .wren_b (we_b),
471
        .inaclr_a (rst_a),
472
        .inaclr_b (rst_b),
473
        .inclock_a (clk_a),
474
        .inclock_b (clk_b),
475
        .data_a (di_a),
476
        .data_b (di_b),
477
        .q_a (do_a),
478
        .q_b (do_b)
479
);
480
 
481
defparam altqpram_component.operation_mode = "BIDIR_DUAL_PORT",
482
        altqpram_component.width_write_a = dw,
483
        altqpram_component.widthad_write_a = aw,
484
        altqpram_component.numwords_write_a = dw,
485
        altqpram_component.width_read_a = dw,
486
        altqpram_component.widthad_read_a = aw,
487
        altqpram_component.numwords_read_a = dw,
488
        altqpram_component.width_write_b = dw,
489
        altqpram_component.widthad_write_b = aw,
490
        altqpram_component.numwords_write_b = dw,
491
        altqpram_component.width_read_b = dw,
492
        altqpram_component.widthad_read_b = aw,
493
        altqpram_component.numwords_read_b = dw,
494
        altqpram_component.indata_reg_a = "INCLOCK_A",
495
        altqpram_component.wrcontrol_wraddress_reg_a = "INCLOCK_A",
496
        altqpram_component.outdata_reg_a = "INCLOCK_A",
497
        altqpram_component.indata_reg_b = "INCLOCK_B",
498
        altqpram_component.wrcontrol_wraddress_reg_b = "INCLOCK_B",
499
        altqpram_component.outdata_reg_b = "INCLOCK_B",
500
        altqpram_component.indata_aclr_a = "INACLR_A",
501
        altqpram_component.wraddress_aclr_a = "INACLR_A",
502
        altqpram_component.wrcontrol_aclr_a = "INACLR_A",
503
        altqpram_component.outdata_aclr_a = "INACLR_A",
504
        altqpram_component.indata_aclr_b = "NONE",
505
        altqpram_component.wraddress_aclr_b = "NONE",
506
        altqpram_component.wrcontrol_aclr_b = "NONE",
507
        altqpram_component.outdata_aclr_b = "INACLR_B",
508
        altqpram_component.lpm_hint = "USE_ESB=ON";
509
        //examplar attribute altqpram_component NOOPT TRUE
510
 
511
`else
512
 
513
//
514
// Generic double-port synchronous RAM model
515
//
516
 
517
//
518
// Generic RAM's registers and wires
519
//
520
reg     [dw-1:0] mem [(1<<aw)-1:0];       // RAM content
521
reg     [aw-1:0] addr_a_reg;             // RAM address registered
522
 
523
//
524
// Data output drivers
525
//
526
assign do_a = (oe_a) ? mem[addr_a_reg] : {dw{1'b0}};
527
 
528
//
529
// RAM read
530
//
531
always @(posedge clk_a or posedge rst_a)
532
        if (rst_a)
533
                addr_a_reg <= #1 {aw{1'b0}};
534
        else if (ce_a)
535
                addr_a_reg <= #1 addr_a;
536
 
537
//
538
// RAM write
539
//
540
always @(posedge clk_b)
541
        if (ce_b && we_b)
542
                mem[addr_b] <= #1 di_b;
543
 
544
`endif  // !OR1200_ALTERA_LPM
545
`endif  // !OR1200_XILINX_RAMB16
546
`endif  // !OR1200_XILINX_RAMB4
547
`endif  // !OR1200_XILINX_RAM32X1D
548
`endif  // !OR1200_VIRTUALSILICON_SSP_T1
549
`endif  // !OR1200_VIRTUALSILICON_SSP_T2
550
`endif  // !OR1200_VIRAGE_STP
551
`endif  // !OR1200_AVANT_ATP
552
`endif  // !OR1200_ARTISAN_SDP
553
 
554
endmodule

powered by: WebSVN 2.1.0

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