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

Subversion Repositories pci

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

powered by: WebSVN 2.1.0

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