]> git.zerfleddert.de Git - raggedstone/blob - ethernet/source/pci/pci_pci_tpram.v
make sure to touch the ngc file when synthesis completes, even if unchanged
[raggedstone] / ethernet / source / pci / pci_pci_tpram.v
1 //////////////////////////////////////////////////////////////////////
2 //// ////
3 //// Generic Two-Port Synchronous RAM ////
4 //// ////
5 //// This file is part of pci bridge project ////
6 //// http://www.opencores.org/cvsweb.shtml/pci/ ////
7 //// ////
8 //// Description ////
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. ////
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 //// ////
26 //// To Do: ////
27 //// - fix Avant! ////
28 //// - xilinx rams need external tri-state logic ////
29 //// - add additional RAMs (Altera, VS etc) ////
30 //// ////
31 //// Author(s): ////
32 //// - Damjan Lampret, lampret@opencores.org ////
33 //// - Miha Dolenc, mihad@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: pci_pci_tpram.v,v $
65 // Revision 1.1 2007-03-20 17:50:56 sithglan
66 // add shit
67 //
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.
71 //
72 // Revision 1.3 2003/10/17 09:11:52 markom
73 // mbist signals updated according to newest convention
74 //
75 // Revision 1.2 2003/08/14 13:06:03 simons
76 // synchronizer_flop replaced with pci_synchronizer_flop, artisan ram instance updated.
77 //
78 // Revision 1.1 2003/01/27 16:49:31 mihad
79 // Changed module and file names. Updated scripts accordingly. FIFO synchronizations changed.
80 //
81 // Revision 1.7 2002/10/18 03:36:37 tadejm
82 // Changed wrong signal name mbist_sen into mbist_ctrl_i.
83 //
84 // Revision 1.6 2002/10/17 22:51:08 tadejm
85 // Changed BIST signals for RAMs.
86 //
87 // Revision 1.5 2002/10/11 10:09:01 mihad
88 // Added additional testcase and changed rst name in BIST to trst
89 //
90 // Revision 1.4 2002/10/08 17:17:06 mihad
91 // Added BIST signals for RAMs.
92 //
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!
95 //
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
98 //
99 // Revision 1.1 2002/02/01 14:43:31 mihad
100 // *** empty log message ***
101 //
102 //
103
104 // synopsys translate_off
105 `include "timescale.v"
106 // synopsys translate_on
107 `include "pci_constants.v"
108
109 module pci_pci_tpram
110 (
111 // Generic synchronous two-port RAM interface
112 clk_a,
113 rst_a,
114 ce_a,
115 we_a,
116 oe_a,
117 addr_a,
118 di_a,
119 do_a,
120 clk_b,
121 rst_b,
122 ce_b,
123 we_b,
124 oe_b,
125 addr_b,
126 di_b,
127 do_b
128 `ifdef PCI_BIST
129 ,
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
134 `endif
135 );
136
137 //
138 // Default address and data buses width
139 //
140 parameter aw = 8;
141 parameter dw = 40;
142
143 //
144 // Generic synchronous two-port RAM interface
145 //
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
162
163 `ifdef PCI_BIST
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
168 `endif
169
170 //
171 // Internal wires and registers
172 //
173
174 `ifdef PCI_VS_STP
175 `define PCI_PCI_RAM_SELECTED
176 `ifdef PCI_BIST
177 vs_hdtp_64x40_bist i_vs_hdtp_64x40_bist
178 `else
179 vs_hdtp_64x40 i_vs_hdtp_64x40
180 `endif
181 (
182 .RCK (clk_b),
183 .WCK (clk_a),
184 .RADR (addr_b),
185 .WADR (addr_a),
186 .DI (di_a),
187 .DOUT (do_b),
188 .REN (1'b0),
189 .WEN (!we_a)
190 `ifdef PCI_BIST
191 ,
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)
196 `endif
197 );
198
199 assign do_a = 0 ;
200 `endif
201
202 `ifdef PCI_ARTISAN_SDP
203 `define PCI_PCI_RAM_SELECTED
204 //
205 // Instantiation of ASIC memory:
206 //
207 // Artisan Synchronous Double-Port RAM (ra2sh)
208 //
209 `ifdef PCI_BIST
210 art_hsdp_64x40_bist /*#(dw, 1<<aw, aw) */ artisan_sdp
211 (
212 .QA(do_a),
213 .CLKA(clk_a),
214 .CENA(~ce_a),
215 .WENA(~we_a),
216 .AA(addr_a),
217 .DA(di_a),
218 .OENA(~oe_a),
219 .QB(do_b),
220 .CLKB(clk_b),
221 .CENB(~ce_b),
222 .WENB(~we_b),
223 .AB(addr_b),
224 .DB(di_b),
225 .OENB(~oe_b),
226 .mbist_si_i (mbist_si_i),
227 .mbist_so_o (mbist_so_o),
228 .mbist_ctrl_i (mbist_ctrl_i)
229 );
230 `else
231 art_hsdp_64x40 /*#(dw, 1<<aw, aw) */ artisan_sdp
232 (
233 .QA(do_a),
234 .CLKA(clk_a),
235 .CENA(~ce_a),
236 .WENA(~we_a),
237 .AA(addr_a),
238 .DA(di_a),
239 .OENA(~oe_a),
240 .QB(do_b),
241 .CLKB(clk_b),
242 .CENB(~ce_b),
243 .WENB(~we_b),
244 .AB(addr_b),
245 .DB(di_b),
246 .OENB(~oe_b)
247 );
248 `endif
249 `endif
250
251 `ifdef AVANT_ATP
252 `define PCI_PCI_RAM_SELECTED
253 //
254 // Instantiation of ASIC memory:
255 //
256 // Avant! Asynchronous Two-Port RAM
257 //
258 avant_atp avant_atp(
259 .web(~we),
260 .reb(),
261 .oeb(~oe),
262 .rcsb(),
263 .wcsb(),
264 .ra(addr),
265 .wa(addr),
266 .di(di),
267 .do(do)
268 );
269 `endif
270
271 `ifdef VIRAGE_STP
272 `define PCI_PCI_RAM_SELECTED
273 //
274 // Instantiation of ASIC memory:
275 //
276 // Virage Synchronous 2-port R/W RAM
277 //
278 virage_stp virage_stp(
279 .QA(do_a),
280 .QB(do_b),
281
282 .ADRA(addr_a),
283 .DA(di_a),
284 .WEA(we_a),
285 .OEA(oe_a),
286 .MEA(ce_a),
287 .CLKA(clk_a),
288
289 .ADRB(adr_b),
290 .DB(di_b),
291 .WEB(we_b),
292 .OEB(oe_b),
293 .MEB(ce_b),
294 .CLKB(clk_b)
295 );
296 `endif
297
298 `ifdef PCI_XILINX_RAMB4
299 `define PCI_PCI_RAM_SELECTED
300 //
301 // Instantiation of FPGA memory:
302 //
303 // Virtex/Spartan2
304 //
305
306 //
307 // Block 0
308 //
309
310 RAMB4_S16_S16 ramb4_s16_s16_0(
311 .CLKA(clk_a),
312 .RSTA(rst_a),
313 .ADDRA(addr_a),
314 .DIA(di_a[15:0]),
315 .ENA(ce_a),
316 .WEA(we_a),
317 .DOA(do_a[15:0]),
318
319 .CLKB(clk_b),
320 .RSTB(rst_b),
321 .ADDRB(addr_b),
322 .DIB(di_b[15:0]),
323 .ENB(ce_b),
324 .WEB(we_b),
325 .DOB(do_b[15:0])
326 );
327
328 //
329 // Block 1
330 //
331
332 RAMB4_S16_S16 ramb4_s16_s16_1(
333 .CLKA(clk_a),
334 .RSTA(rst_a),
335 .ADDRA(addr_a),
336 .DIA(di_a[31:16]),
337 .ENA(ce_a),
338 .WEA(we_a),
339 .DOA(do_a[31:16]),
340
341 .CLKB(clk_b),
342 .RSTB(rst_b),
343 .ADDRB(addr_b),
344 .DIB(di_b[31:16]),
345 .ENB(ce_b),
346 .WEB(we_b),
347 .DOB(do_b[31:16])
348 );
349
350 //
351 // Block 2
352 //
353 // block ram2 wires - non generic width of block rams
354 wire [15:0] blk2_di_a = {8'h00, di_a[39:32]} ;
355 wire [15:0] blk2_di_b = {8'h00, di_b[39:32]} ;
356
357 wire [15:0] blk2_do_a ;
358 wire [15:0] blk2_do_b ;
359
360 assign do_a[39:32] = blk2_do_a[7:0] ;
361 assign do_b[39:32] = blk2_do_b[7:0] ;
362
363 RAMB4_S16_S16 ramb4_s16_s16_2(
364 .CLKA(clk_a),
365 .RSTA(rst_a),
366 .ADDRA(addr_a),
367 .DIA(blk2_di_a),
368 .ENA(ce_a),
369 .WEA(we_a),
370 .DOA(blk2_do_a),
371
372 .CLKB(clk_b),
373 .RSTB(rst_b),
374 .ADDRB(addr_b),
375 .DIB(blk2_di_b),
376 .ENB(ce_b),
377 .WEB(we_b),
378 .DOB(blk2_do_b)
379 );
380
381 `endif
382
383 `ifdef PCI_XILINX_DIST_RAM
384 `define PCI_PCI_RAM_SELECTED
385 reg [(aw-1):0] out_address ;
386 always@(posedge clk_b or posedge rst_b)
387 begin
388 if ( rst_b )
389 out_address <= #1 0 ;
390 else if (ce_b)
391 out_address <= #1 addr_b ;
392 end
393
394 pci_ram_16x40d #(aw) pci_distributed_ram
395 (
396 .data_out (do_b),
397 .we (we_a),
398 .data_in (di_a),
399 .read_address (out_address),
400 .write_address (addr_a),
401 .wclk (clk_a)
402 );
403
404 assign do_a = 0 ;
405 `endif
406
407 `ifdef PCI_PCI_RAM_SELECTED
408 `else
409 //
410 // Generic two-port synchronous RAM model
411 //
412
413 //
414 // Generic RAM's registers and wires
415 //
416 reg [dw-1:0] mem [(1<<aw)-1:0]; // RAM content
417 reg [dw-1:0] do_reg_b; // RAM data output register
418
419 //
420 // Data output drivers
421 //
422 assign do_a = {dw{1'b0}} ;
423 assign do_b = do_reg_b ;
424
425 //
426 // RAM read and write
427 //
428 always @(posedge clk_a)
429 if (ce_a && we_a)
430 mem[addr_a] <= #1 di_a;
431
432 //
433 // RAM read and write
434 //
435 always @(posedge clk_b)
436 if (ce_b)
437 do_reg_b <= #1 mem[addr_b];
438 `endif
439
440 // synopsys translate_off
441 initial
442 begin
443 if (dw !== 40)
444 begin
445 $display("RAM instantiation error! Expected RAM width %d, actual %h!", 40, dw) ;
446 $finish ;
447 end
448 `ifdef XILINX_RAMB4
449 if (aw !== 8)
450 begin
451 $display("RAM instantiation error! Expected RAM address width %d, actual %h!", 40, aw) ;
452 $finish ;
453 end
454 `endif
455 // currenlty only artisan ram of depth 256 is supported - they don't provide generic ram models
456 `ifdef ARTISAN_SDP
457 if (aw !== 8)
458 begin
459 $display("RAM instantiation error! Expected RAM address width %d, actual %h!", 40, aw) ;
460 $finish ;
461 end
462 `endif
463 end
464 // synopsys translate_on
465
466 endmodule
467
Impressum, Datenschutz