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

Subversion Repositories or1k

[/] [or1k/] [trunk/] [rc203soc/] [rtl/] [verilog/] [or1200/] [rtl/] [verilog/] [or1200_dpram_32x32.v] - Blame information for rev 1765

Details | Compare with Previous | View Log

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

powered by: WebSVN 2.1.0

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