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

Subversion Repositories pci

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

powered by: WebSVN 2.1.0

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