1 //////////////////////////////////////////////////////////////////////
3 //// Generic Double-Port Synchronous RAM ////
5 //// This file is part of memory library available from ////
6 //// http://www.opencores.org/cvsweb.shtml/generic_memories/ ////
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. ////
18 //// Supported ASIC RAMs are: ////
19 //// - Artisan Double-Port Sync RAM ////
20 //// - Avant! Two-Port Sync RAM (*) ////
21 //// - Virage 2-port Sync RAM ////
23 //// Supported FPGA RAMs are: ////
24 //// - Xilinx Virtex RAMB4_S16_S16 ////
25 //// - Altera LPM ////
28 //// - fix Avant! ////
29 //// - xilinx rams need external tri-state logic ////
30 //// - add additional RAMs ////
33 //// - Damjan Lampret, lampret@opencores.org ////
35 //////////////////////////////////////////////////////////////////////
37 //// Copyright (C) 2000 Authors and OPENCORES.ORG ////
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. ////
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. ////
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 ////
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 ////
60 //////////////////////////////////////////////////////////////////////
62 // CVS Revision History
65 // Revision 1.8 2004/04/05 08:29:57 lampret
66 // Merged branch_qmem into main tree.
68 // Revision 1.7.4.1 2003/07/08 15:36:37 lampret
69 // Added embedded memory QMEM.
71 // Revision 1.7 2003/04/07 01:19:07 lampret
72 // Added Altera LPM RAMs. Changed generic RAM output when OE inactive.
74 // Revision 1.6 2002/03/28 19:25:42 lampret
75 // Added second type of Virtual Silicon two-port SRAM (for register file). Changed defines for VS STP RAMs.
77 // Revision 1.5 2002/02/01 19:56:54 lampret
78 // Fixed combinational loops.
80 // Revision 1.4 2002/01/23 07:52:36 lampret
81 // 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.
83 // Revision 1.3 2002/01/19 14:10:22 lampret
84 // Fixed OR1200_XILINX_RAM32X1D.
86 // Revision 1.2 2002/01/15 06:12:22 lampret
87 // Fixed module name when compiling with OR1200_XILINX_RAM32X1D
89 // Revision 1.1 2002/01/03 08:16:15 lampret
90 // New prefixes for RTL files, prefixed module names. Updated cache controllers and MMUs.
92 // Revision 1.10 2001/11/05 14:48:00 lampret
93 // Added missing endif
95 // Revision 1.9 2001/11/02 18:57:14 lampret
96 // Modified virtual silicon instantiations.
98 // Revision 1.8 2001/10/22 19:39:56 lampret
99 // Fixed parameters in generic sprams.
101 // Revision 1.7 2001/10/21 17:57:16 lampret
102 // 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.
104 // Revision 1.6 2001/10/14 13:12:09 lampret
107 // Revision 1.1.1.1 2001/10/06 10:18:36 igorm
110 // Revision 1.1 2001/08/09 13:39:33 lampret
113 // Revision 1.2 2001/07/30 05:38:02 lampret
114 // Adding empty directories required by HDL coding guidelines
118 // synopsys translate_off
119 `include "timescale.v"
120 // synopsys translate_on
121 `include "or1200_defines.v"
123 module or1200_dpram_32x32(
124 // Generic synchronous double-port RAM interface
125 clk_a
, rst_a
, ce_a
, oe_a
, addr_a
, do_a
,
126 clk_b
, rst_b
, ce_b
, we_b
, addr_b
, di_b
130 // Default address and data buses width
136 // Generic synchronous double-port RAM interface
138 input clk_a
; // Clock
139 input rst_a
; // Reset
140 input ce_a
; // Chip enable input
141 input oe_a
; // Output enable input
142 input [aw
-1:0] addr_a
; // address bus inputs
143 output [dw
-1:0] do_a
; // output data bus
144 input clk_b
; // Clock
145 input rst_b
; // Reset
146 input ce_b
; // Chip enable input
147 input we_b
; // Write enable input
148 input [aw
-1:0] addr_b
; // address bus inputs
149 input [dw
-1:0] di_b
; // input data bus
152 // Internal wires and registers
155 `ifdef OR1200_ARTISAN_SDP
158 // Instantiation of ASIC memory:
160 // Artisan Synchronous Double-Port RAM (ra2sh)
163 art_hsdp_32x32 #
(dw
, 1<<aw
, aw
) artisan_sdp(
165 art_hsdp_32x32
artisan_sdp(
185 `ifdef OR1200_AVANT_ATP
188 // Instantiation of ASIC memory:
190 // Avant! Asynchronous Two-Port RAM
206 `ifdef OR1200_VIRAGE_STP
209 // Instantiation of ASIC memory:
211 // Virage Synchronous 2-port R/W RAM
213 virage_stp
virage_stp(
234 `ifdef OR1200_VIRTUALSILICON_STP_T1
237 // Instantiation of ASIC memory:
239 // Virtual Silicon Two-port R/W SRAM Type 1
242 vs_hdtp_64x32 #
(1<<aw
, aw
-1, dw
-1) vs_ssp(
244 vs_hdtp_64x32
vs_ssp(
250 .
P1ADR({1'b0, addr_a
}),
251 .
P1DI(32'h0000_0000
),
258 .
P2ADR({1'b0, addr_b
}),
265 `ifdef OR1200_VIRTUALSILICON_STP_T2
268 // Instantiation of ASIC memory:
270 // Virtual Silicon Two-port R/W SRAM Type 2
273 vs_hdtp_32x32 #
(1<<aw
, aw
-1, dw
-1) vs_ssp(
275 vs_hdtp_32x32
vs_ssp(
291 `ifdef OR1200_XILINX_RAM32X1D
294 // Instantiation of FPGA memory:
301 always @(posedge clk_a
or posedge rst_a
)
303 addr_a_r
<= #1 5'b00000;
305 addr_a_r
<= #1 addr_a
;
310 or1200_xcv_ram32x8d
xcv_ram32x8d_0 (
323 or1200_xcv_ram32x8d
xcv_ram32x8d_1 (
337 or1200_xcv_ram32x8d
xcv_ram32x8d_2 (
350 or1200_xcv_ram32x8d
xcv_ram32x8d_3 (
362 `ifdef OR1200_XILINX_RAMB4
365 // Instantiation of FPGA memory:
373 RAMB4_S16_S16
ramb4_s16_0(
376 .
ADDRA({3'b000, addr_a
}),
384 .
ADDRB({3'b000, addr_b
}),
394 RAMB4_S16_S16
ramb4_s16_1(
397 .
ADDRA({3'b000, addr_a
}),
405 .
ADDRB({3'b000, addr_b
}),
414 `ifdef OR1200_ALTERA_LPM_XXX
417 // Instantiation of FPGA memory:
421 // Added By Jamil Khatib
423 altqpram
altqpram_component (
424 .
wraddress_a (addr_a
),
426 .
wraddress_b (addr_b
),
440 defparam altqpram_component.operation_mode
= "BIDIR_DUAL_PORT",
441 altqpram_component.width_write_a
= dw
,
442 altqpram_component.widthad_write_a
= aw
,
443 altqpram_component.numwords_write_a
= dw
,
444 altqpram_component.width_read_a
= dw
,
445 altqpram_component.widthad_read_a
= aw
,
446 altqpram_component.numwords_read_a
= dw
,
447 altqpram_component.width_write_b
= dw
,
448 altqpram_component.widthad_write_b
= aw
,
449 altqpram_component.numwords_write_b
= dw
,
450 altqpram_component.width_read_b
= dw
,
451 altqpram_component.widthad_read_b
= aw
,
452 altqpram_component.numwords_read_b
= dw
,
453 altqpram_component.indata_reg_a
= "INCLOCK_A",
454 altqpram_component.wrcontrol_wraddress_reg_a
= "INCLOCK_A",
455 altqpram_component.outdata_reg_a
= "INCLOCK_A",
456 altqpram_component.indata_reg_b
= "INCLOCK_B",
457 altqpram_component.wrcontrol_wraddress_reg_b
= "INCLOCK_B",
458 altqpram_component.outdata_reg_b
= "INCLOCK_B",
459 altqpram_component.indata_aclr_a
= "INACLR_A",
460 altqpram_component.wraddress_aclr_a
= "INACLR_A",
461 altqpram_component.wrcontrol_aclr_a
= "INACLR_A",
462 altqpram_component.outdata_aclr_a
= "INACLR_A",
463 altqpram_component.indata_aclr_b
= "NONE",
464 altqpram_component.wraddress_aclr_b
= "NONE",
465 altqpram_component.wrcontrol_aclr_b
= "NONE",
466 altqpram_component.outdata_aclr_b
= "INACLR_B",
467 altqpram_component.lpm_hint
= "USE_ESB=ON";
468 //examplar attribute altqpram_component NOOPT TRUE
473 // Generic double-port synchronous RAM model
477 // Generic RAM's registers and wires
479 reg [dw
-1:0] mem
[(1<<aw
)-1:0]; // RAM content
480 reg [dw
-1:0] do_reg
; // RAM data output register
483 // Data output drivers
485 assign do_a
= (oe_a
) ? do_reg
: {dw
{1'b0}};
490 always @(posedge clk_a
)
492 do_reg
<= #1 mem
[addr_a
];
497 always @(posedge clk_b
)
499 mem
[addr_b
] <= #1 di_b
;
501 `endif // !OR1200_ALTERA_LPM
502 `endif // !OR1200_XILINX_RAMB4_S16_S16
503 `endif // !OR1200_XILINX_RAM32X1D
504 `endif // !OR1200_VIRTUALSILICON_SSP_T1
505 `endif // !OR1200_VIRTUALSILICON_SSP_T2
506 `endif // !OR1200_VIRAGE_STP
507 `endif // !OR1200_AVANT_ATP
508 `endif // !OR1200_ARTISAN_SDP