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

Subversion Repositories or1k

[/] [or1k/] [tags/] [rel_29/] [or1200/] [rtl/] [verilog/] [or1200_dpram_32x32.v] - Blame information for rev 1267

Go to most recent revision | Details | Compare with Previous | View Log

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

powered by: WebSVN 2.1.0

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