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

Subversion Repositories pci

[/] [pci/] [tags/] [rel_10/] [rtl/] [verilog/] [pci_wb_tpram.v] - Blame information for rev 154

Details | Compare with Previous | View Log

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

powered by: WebSVN 2.1.0

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