1 //////////////////////////////////////////////////////////////////////
3 //// Generic Two-Port Synchronous RAM ////
5 //// This file is part of pci bridge project ////
6 //// http://www.opencores.org/cvsweb.shtml/pci/ ////
9 //// This block is a wrapper with common two-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 //// two-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 ////
27 //// - fix Avant! ////
28 //// - xilinx rams need external tri-state logic ////
29 //// - add additional RAMs (Altera, VS etc) ////
32 //// - Damjan Lampret, lampret@opencores.org ////
33 //// - Miha Dolenc, mihad@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
64 // $Log: pci_wb_tpram.v,v $
65 // Revision 1.1 2007-03-20 17:50:56 sithglan
68 // Revision 1.4 2004/08/19 15:27:34 mihad
69 // Changed minimum pci image size to 256 bytes because
70 // of some PC system problems with size of IO images.
72 // Revision 1.3 2003/10/17 09:11:52 markom
73 // mbist signals updated according to newest convention
75 // Revision 1.2 2003/08/14 13:06:03 simons
76 // synchronizer_flop replaced with pci_synchronizer_flop, artisan ram instance updated.
78 // Revision 1.1 2003/01/27 16:49:31 mihad
79 // Changed module and file names. Updated scripts accordingly. FIFO synchronizations changed.
81 // Revision 1.7 2002/10/18 03:36:37 tadejm
82 // Changed wrong signal name mbist_sen into mbist_ctrl_i.
84 // Revision 1.6 2002/10/17 22:49:22 tadejm
85 // Changed BIST signals for RAMs.
87 // Revision 1.5 2002/10/11 10:09:01 mihad
88 // Added additional testcase and changed rst name in BIST to trst
90 // Revision 1.4 2002/10/08 17:17:06 mihad
91 // Added BIST signals for RAMs.
93 // Revision 1.3 2002/09/30 17:22:27 mihad
94 // Added support for Virtual Silicon two port RAM. Didn't run regression on it yet!
96 // Revision 1.2 2002/08/19 16:51:36 mihad
97 // Extracted distributed RAM module from wb/pci_tpram.v to its own file, got rid of undef directives
99 // Revision 1.1 2002/02/01 14:43:31 mihad
100 // *** empty log message ***
104 // synopsys translate_off
105 `include "timescale.v"
106 // synopsys translate_on
107 `include "pci_constants.v"
111 // Generic synchronous two-port RAM interface
130 // debug chain signals
131 mbist_si_i, // bist scan serial in
132 mbist_so_o, // bist scan serial out
133 mbist_ctrl_i // bist chain shift control
138 // Default address and data buses width
144 // Generic synchronous two-port RAM interface
146 input clk_a; // Clock
147 input rst_a; // Reset
148 input ce_a; // Chip enable input
149 input we_a; // Write enable input
150 input oe_a; // Output enable input
151 input [aw-1:0] addr_a; // address bus inputs
152 input [dw-1:0] di_a; // input data bus
153 output [dw-1:0] do_a; // output data bus
154 input clk_b; // Clock
155 input rst_b; // Reset
156 input ce_b; // Chip enable input
157 input we_b; // Write enable input
158 input oe_b; // Output enable input
159 input [aw-1:0] addr_b; // address bus inputs
160 input [dw-1:0] di_b; // input data bus
161 output [dw-1:0] do_b; // output data bus
164 // debug chain signals
165 input mbist_si_i; // bist scan serial in
166 output mbist_so_o; // bist scan serial out
167 input [`PCI_MBIST_CTRL_WIDTH - 1:0] mbist_ctrl_i; // bist chain shift control
171 // Internal wires and registers
175 `define PCI_WB_RAM_SELECTED
177 vs_hdtp_64x40_bist i_vs_hdtp_64x40_bist
179 vs_hdtp_64x40 i_vs_hdtp_64x40
192 // debug chain signals
193 .mbist_si_i (mbist_si_i),
194 .mbist_so_o (mbist_so_o),
195 .mbist_ctrl_i (mbist_ctrl_i)
202 `ifdef WB_ARTISAN_SDP
203 `define PCI_WB_RAM_SELECTED
205 // Instantiation of ASIC memory:
207 // Artisan Synchronous Double-Port RAM (ra2sh)
210 art_hsdp_64x40_bist /*#(dw, 1<<aw, aw) */ artisan_sdp
226 .mbist_si_i (mbist_si_i),
227 .mbist_so_o (mbist_so_o),
228 .mbist_ctrl_i (mbist_ctrl_i)
231 art_hsdp_64x40 /*#(dw, 1<<aw, aw) */ artisan_sdp
252 `define PCI_WB_RAM_SELECTED
254 // Instantiation of ASIC memory:
256 // Avant! Asynchronous Two-Port RAM
273 `define PCI_WB_RAM_SELECTED
275 // Instantiation of ASIC memory:
277 // Virage Synchronous 2-port R/W RAM
279 virage_stp virage_stp(
300 `ifdef WB_XILINX_DIST_RAM
301 `define PCI_WB_RAM_SELECTED
303 reg [(aw-1):0] out_address ;
304 always@(posedge clk_b or posedge rst_b)
307 out_address <= #1 0 ;
309 out_address <= #1 addr_b ;
312 pci_ram_16x40d #(aw) wb_distributed_ram
317 .read_address (out_address),
318 .write_address (addr_a),
323 `ifdef WB_XILINX_RAMB4
324 `define PCI_WB_RAM_SELECTED
326 // Instantiation of FPGA memory:
335 RAMB4_S16_S16 ramb4_s16_s16_0(
357 RAMB4_S16_S16 ramb4_s16_s16_1(
378 // block ram2 wires - non generic width of block rams
379 wire [15:0] blk2_di_a = {8'h00, di_a[39:32]} ;
380 wire [15:0] blk2_di_b = {8'h00, di_b[39:32]} ;
382 wire [15:0] blk2_do_a ;
383 wire [15:0] blk2_do_b ;
385 assign do_a[39:32] = blk2_do_a[7:0] ;
386 assign do_b[39:32] = blk2_do_b[7:0] ;
388 RAMB4_S16_S16 ramb4_s16_s16_2(
408 `ifdef PCI_WB_RAM_SELECTED
411 // Generic two-port synchronous RAM model
415 // Generic RAM's registers and wires
417 reg [dw-1:0] mem [(1<<aw)-1:0]; // RAM content
418 reg [dw-1:0] do_reg_b; // RAM data output register
421 // Data output drivers
423 assign do_a = {dw{1'b0}} ;
424 assign do_b = do_reg_b ;
427 // RAM read and write
429 always @(posedge clk_a)
431 mem[addr_a] <= #1 di_a;
434 // RAM read and write
436 always @(posedge clk_b)
438 do_reg_b <= #1 mem[addr_b];
441 // synopsys translate_off
446 $display("RAM instantiation error! Expected RAM width %d, actual %h!", 40, dw) ;
452 $display("RAM instantiation error! Expected RAM address width %d, actual %h!", 40, aw) ;
456 // currenlty only artisan ram of depth 256 is supported - they don't provide generic ram models
460 $display("RAM instantiation error! Expected RAM address width %d, actual %h!", 40, aw) ;
465 // synopsys translate_on