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

Subversion Repositories pci

[/] [pci/] [tags/] [rel_3/] [rtl/] [verilog/] [wb_tpram.v] - Blame information for rev 154

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 18 mihad
//////////////////////////////////////////////////////////////////////
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: not supported by cvs2svn $
65 68 tadejm
// Revision 1.6  2002/10/17 22:49:22  tadejm
66
// Changed BIST signals for RAMs.
67
//
68 67 tadejm
// Revision 1.5  2002/10/11 10:09:01  mihad
69
// Added additional testcase and changed rst name in BIST to trst
70
//
71 63 mihad
// Revision 1.4  2002/10/08 17:17:06  mihad
72
// Added BIST signals for RAMs.
73
//
74 62 mihad
// Revision 1.3  2002/09/30 17:22:27  mihad
75
// Added support for Virtual Silicon two port RAM. Didn't run regression on it yet!
76
//
77 60 mihad
// Revision 1.2  2002/08/19 16:51:36  mihad
78
// Extracted distributed RAM module from wb/pci_tpram.v to its own file, got rid of undef directives
79
//
80 49 mihad
// Revision 1.1  2002/02/01 14:43:31  mihad
81
// *** empty log message ***
82 18 mihad
//
83 49 mihad
//
84 18 mihad
 
85
// synopsys translate_off
86
`include "timescale.v"
87
// synopsys translate_on
88
`include "pci_constants.v"
89
 
90
module WB_TPRAM
91
(
92
        // Generic synchronous two-port RAM interface
93
        clk_a,
94
    rst_a,
95
    ce_a,
96
    we_a,
97
    oe_a,
98
    addr_a,
99
    di_a,
100
    do_a,
101
        clk_b,
102
    rst_b,
103
    ce_b,
104
    we_b,
105
    oe_b,
106
    addr_b,
107
    di_b,
108
    do_b
109 62 mihad
`ifdef PCI_BIST
110
    ,
111
    // debug chain signals
112 67 tadejm
    scanb_rst,      // bist scan reset
113
    scanb_clk,      // bist scan clock
114
    scanb_si,       // bist scan serial in
115
    scanb_so,       // bist scan serial out
116 68 tadejm
    scanb_en        // bist scan shift enable
117 62 mihad
`endif
118 18 mihad
);
119
 
120
//
121
// Default address and data buses width
122
//
123
parameter aw = 8;
124
parameter dw = 40;
125
 
126
//
127
// Generic synchronous two-port RAM interface
128
//
129
input                   clk_a;  // Clock
130
input                   rst_a;  // Reset
131
input                   ce_a;   // Chip enable input
132
input                   we_a;   // Write enable input
133
input                   oe_a;   // Output enable input
134
input   [aw-1:0] addr_a; // address bus inputs
135
input   [dw-1:0] di_a;   // input data bus
136
output  [dw-1:0] do_a;   // output data bus
137
input                   clk_b;  // Clock
138
input                   rst_b;  // Reset
139
input                   ce_b;   // Chip enable input
140
input                   we_b;   // Write enable input
141
input                   oe_b;   // Output enable input
142
input   [aw-1:0] addr_b; // address bus inputs
143
input   [dw-1:0] di_b;   // input data bus
144
output  [dw-1:0] do_b;   // output data bus
145
 
146 62 mihad
`ifdef PCI_BIST
147
// debug chain signals
148 67 tadejm
input   scanb_rst;      // bist scan reset
149
input   scanb_clk;      // bist scan clock
150
input   scanb_si;       // bist scan serial in
151
output  scanb_so;       // bist scan serial out
152 68 tadejm
input   scanb_en;       // bist scan shift enable
153 62 mihad
`endif
154
 
155 18 mihad
//
156
// Internal wires and registers
157
//
158
 
159 60 mihad
`ifdef WB_VS_STP
160
    `define PCI_WB_RAM_SELECTED
161 62 mihad
    `ifdef PCI_BIST
162
        vs_hdtp_64x40_bist i_vs_hdtp_64x40_bist
163
    `else
164
        vs_hdtp_64x40 i_vs_hdtp_64x40
165
    `endif
166
        (
167
            .RCK        (clk_b),
168
            .WCK        (clk_a),
169
            .RADR       (addr_b),
170
            .WADR       (addr_a),
171
            .DI         (di_a),
172
            .DOUT       (do_b),
173
            .REN        (1'b0),
174
            .WEN        (!we_a)
175
        `ifdef PCI_BIST
176
            ,
177
            // debug chain signals
178 67 tadejm
            .scanb_rst  (scanb_rst),
179
            .scanb_clk  (scanb_clk),
180
            .scanb_si   (scanb_si),
181
            .scanb_so   (scanb_so),
182 68 tadejm
            .scanb_en   (scanb_en)
183 62 mihad
        `endif
184
        );
185 60 mihad
 
186
    assign do_a = 0 ;
187
`endif
188 18 mihad
 
189
`ifdef WB_ARTISAN_SDP
190 49 mihad
    `define PCI_WB_RAM_SELECTED
191 18 mihad
    //
192
    // Instantiation of ASIC memory:
193
    //
194
    // Artisan Synchronous Double-Port RAM (ra2sh)
195
    //
196
    art_hsdp_256x40 /*#(dw, 1<<aw, aw) */ artisan_sdp
197
    (
198
        .qa(do_a),
199
        .clka(clk_a),
200
        .cena(~ce_a),
201
        .wena(~we_a),
202
        .aa(addr_a),
203
        .da(di_a),
204
        .oena(~oe_a),
205
        .qb(do_b),
206
        .clkb(clk_b),
207
        .cenb(~ce_b),
208
        .wenb(~we_b),
209
        .ab(addr_b),
210
        .db(di_b),
211
        .oenb(~oe_b)
212
    );
213
 
214
`endif
215
 
216
`ifdef AVANT_ATP
217 49 mihad
    `define PCI_WB_RAM_SELECTED
218 18 mihad
    //
219
    // Instantiation of ASIC memory:
220
    //
221
    // Avant! Asynchronous Two-Port RAM
222
    //
223
    avant_atp avant_atp(
224
        .web(~we),
225
        .reb(),
226
        .oeb(~oe),
227
        .rcsb(),
228
        .wcsb(),
229
        .ra(addr),
230
        .wa(addr),
231
        .di(di),
232
        .do(do)
233
    );
234
 
235
`endif
236
 
237
`ifdef VIRAGE_STP
238 49 mihad
    `define PCI_WB_RAM_SELECTED
239 18 mihad
    //
240
    // Instantiation of ASIC memory:
241
    //
242
    // Virage Synchronous 2-port R/W RAM
243
    //
244
    virage_stp virage_stp(
245
        .QA(do_a),
246
        .QB(do_b),
247
 
248
        .ADRA(addr_a),
249
        .DA(di_a),
250
        .WEA(we_a),
251
        .OEA(oe_a),
252
        .MEA(ce_a),
253
        .CLKA(clk_a),
254
 
255
        .ADRB(adr_b),
256
        .DB(di_b),
257
        .WEB(we_b),
258
        .OEB(oe_b),
259
        .MEB(ce_b),
260
        .CLKB(clk_b)
261
    );
262
 
263
`endif
264
 
265 49 mihad
`ifdef WB_XILINX_DIST_RAM
266
    `define PCI_WB_RAM_SELECTED
267
 
268
    reg [(aw-1):0] out_address ;
269
    always@(posedge clk_b or posedge rst_b)
270
    begin
271
        if ( rst_b )
272
            out_address <= #1 0 ;
273
        else if (ce_b)
274
            out_address <= #1 addr_b ;
275
    end
276
 
277
    pci_ram_16x40d #(aw) wb_distributed_ram
278
    (
279
        .data_out       (do_b),
280
        .we             (we_a),
281
        .data_in        (di_a),
282
        .read_address   (out_address),
283
        .write_address  (addr_a),
284
        .wclk           (clk_a)
285
    );
286
    assign do_a = 0 ;
287
`endif
288 18 mihad
`ifdef WB_XILINX_RAMB4
289 49 mihad
    `define PCI_WB_RAM_SELECTED
290 18 mihad
    //
291
    // Instantiation of FPGA memory:
292
    //
293
    // Virtex/Spartan2
294
    //
295
 
296
    //
297
    // Block 0
298
    //
299
 
300
    RAMB4_S16_S16 ramb4_s16_s16_0(
301
        .CLKA(clk_a),
302
        .RSTA(rst_a),
303
        .ADDRA(addr_a),
304
        .DIA(di_a[15:0]),
305
        .ENA(ce_a),
306
        .WEA(we_a),
307
        .DOA(do_a[15:0]),
308
 
309
        .CLKB(clk_b),
310
        .RSTB(rst_b),
311
        .ADDRB(addr_b),
312
        .DIB(di_b[15:0]),
313
        .ENB(ce_b),
314
        .WEB(we_b),
315
        .DOB(do_b[15:0])
316
    );
317
 
318
    //
319
    // Block 1
320
    //
321
 
322
    RAMB4_S16_S16 ramb4_s16_s16_1(
323
        .CLKA(clk_a),
324
        .RSTA(rst_a),
325
        .ADDRA(addr_a),
326
        .DIA(di_a[31:16]),
327
        .ENA(ce_a),
328
        .WEA(we_a),
329
        .DOA(do_a[31:16]),
330
 
331
        .CLKB(clk_b),
332
        .RSTB(rst_b),
333
        .ADDRB(addr_b),
334
        .DIB(di_b[31:16]),
335
        .ENB(ce_b),
336
        .WEB(we_b),
337
        .DOB(do_b[31:16])
338
    );
339
 
340
    //
341
    // Block 2
342
    //
343
    // block ram2 wires - non generic width of block rams
344
    wire [15:0] blk2_di_a = {8'h00, di_a[39:32]} ;
345
    wire [15:0] blk2_di_b = {8'h00, di_b[39:32]} ;
346
 
347
    wire [15:0] blk2_do_a ;
348
    wire [15:0] blk2_do_b ;
349
 
350
    assign do_a[39:32] = blk2_do_a[7:0] ;
351
    assign do_b[39:32] = blk2_do_b[7:0] ;
352
 
353
    RAMB4_S16_S16 ramb4_s16_s16_2(
354
            .CLKA(clk_a),
355
            .RSTA(rst_a),
356
            .ADDRA(addr_a),
357
            .DIA(blk2_di_a),
358
            .ENA(ce_a),
359
            .WEA(we_a),
360
            .DOA(blk2_do_a),
361
 
362
            .CLKB(clk_b),
363
            .RSTB(rst_b),
364
            .ADDRB(addr_b),
365
            .DIB(blk2_di_b),
366
            .ENB(ce_b),
367
            .WEB(we_b),
368
            .DOB(blk2_do_b)
369
    );
370
 
371
`endif
372
 
373 49 mihad
`ifdef PCI_WB_RAM_SELECTED
374 18 mihad
`else
375
    //
376
    // Generic two-port synchronous RAM model
377
    //
378
 
379
    //
380
    // Generic RAM's registers and wires
381
    //
382
    reg [dw-1:0] mem [(1<<aw)-1:0];       // RAM content
383
    reg [dw-1:0] do_reg_a;               // RAM data output register
384
    reg [dw-1:0] do_reg_b;               // RAM data output register
385
 
386
    //
387
    // Data output drivers
388
    //
389
    assign do_a = (oe_a) ? do_reg_a : {dw{1'bz}};
390
    assign do_b = (oe_b) ? do_reg_b : {dw{1'bz}};
391
 
392
    //
393
    // RAM read and write
394
    //
395
    always @(posedge clk_a)
396
        if (ce_a && !we_a)
397
                do_reg_a <= #1 mem[addr_a];
398
        else if (ce_a && we_a)
399
                mem[addr_a] <= #1 di_a;
400
 
401
    //
402
    // RAM read and write
403
    //
404
    always @(posedge clk_b)
405
        if (ce_b && !we_b)
406
                do_reg_b <= #1 mem[addr_b];
407
        else if (ce_b && we_b)
408
                mem[addr_b] <= #1 di_b;
409
`endif
410
 
411
// synopsys translate_off
412
initial
413
begin
414
    if (dw !== 40)
415
    begin
416
        $display("RAM instantiation error! Expected RAM width %d, actual %h!", 40, dw) ;
417
        $finish ;
418
    end
419
    `ifdef XILINX_RAMB4
420
        if (aw !== 8)
421
        begin
422
            $display("RAM instantiation error! Expected RAM address width %d, actual %h!", 40, aw) ;
423
            $finish ;
424
        end
425
    `endif
426
    // currenlty only artisan ram of depth 256 is supported - they don't provide generic ram models
427
    `ifdef ARTISAN_SDP
428
        if (aw !== 8)
429
        begin
430
            $display("RAM instantiation error! Expected RAM address width %d, actual %h!", 40, aw) ;
431
            $finish ;
432
        end
433
    `endif
434
end
435
// synopsys translate_on
436
 
437
endmodule

powered by: WebSVN 2.1.0

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