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

Subversion Repositories or1k

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

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

powered by: WebSVN 2.1.0

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