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

Subversion Repositories pci

[/] [pci/] [tags/] [rel_3/] [rtl/] [verilog/] [pci_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:51:08  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 PCI_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 PCI_VS_STP
160
    `define PCI_PCI_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
 
186 60 mihad
    assign do_a = 0 ;
187
`endif
188
 
189 18 mihad
`ifdef PCI_ARTISAN_SDP
190 49 mihad
    `define PCI_PCI_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
`endif
214
 
215
`ifdef AVANT_ATP
216 49 mihad
    `define PCI_PCI_RAM_SELECTED
217 18 mihad
    //
218
    // Instantiation of ASIC memory:
219
    //
220
    // Avant! Asynchronous Two-Port RAM
221
    //
222
    avant_atp avant_atp(
223
        .web(~we),
224
        .reb(),
225
        .oeb(~oe),
226
        .rcsb(),
227
        .wcsb(),
228
        .ra(addr),
229
        .wa(addr),
230
        .di(di),
231
        .do(do)
232
    );
233
`endif
234
 
235
`ifdef VIRAGE_STP
236 49 mihad
    `define PCI_PCI_RAM_SELECTED
237 18 mihad
    //
238
    // Instantiation of ASIC memory:
239
    //
240
    // Virage Synchronous 2-port R/W RAM
241
    //
242
    virage_stp virage_stp(
243
        .QA(do_a),
244
        .QB(do_b),
245
 
246
        .ADRA(addr_a),
247
        .DA(di_a),
248
        .WEA(we_a),
249
        .OEA(oe_a),
250
        .MEA(ce_a),
251
        .CLKA(clk_a),
252
 
253
        .ADRB(adr_b),
254
        .DB(di_b),
255
        .WEB(we_b),
256
        .OEB(oe_b),
257
        .MEB(ce_b),
258
        .CLKB(clk_b)
259
    );
260
`endif
261
 
262
`ifdef PCI_XILINX_RAMB4
263 49 mihad
    `define PCI_PCI_RAM_SELECTED
264 18 mihad
    //
265
    // Instantiation of FPGA memory:
266
    //
267
    // Virtex/Spartan2
268
    //
269
 
270
    //
271
    // Block 0
272
    //
273
 
274
    RAMB4_S16_S16 ramb4_s16_s16_0(
275
        .CLKA(clk_a),
276
        .RSTA(rst_a),
277
        .ADDRA(addr_a),
278
        .DIA(di_a[15:0]),
279
        .ENA(ce_a),
280
        .WEA(we_a),
281
        .DOA(do_a[15:0]),
282
 
283
        .CLKB(clk_b),
284
        .RSTB(rst_b),
285
        .ADDRB(addr_b),
286
        .DIB(di_b[15:0]),
287
        .ENB(ce_b),
288
        .WEB(we_b),
289
        .DOB(do_b[15:0])
290
    );
291
 
292
    //
293
    // Block 1
294
    //
295
 
296
    RAMB4_S16_S16 ramb4_s16_s16_1(
297
        .CLKA(clk_a),
298
        .RSTA(rst_a),
299
        .ADDRA(addr_a),
300
        .DIA(di_a[31:16]),
301
        .ENA(ce_a),
302
        .WEA(we_a),
303
        .DOA(do_a[31:16]),
304
 
305
        .CLKB(clk_b),
306
        .RSTB(rst_b),
307
        .ADDRB(addr_b),
308
        .DIB(di_b[31:16]),
309
        .ENB(ce_b),
310
        .WEB(we_b),
311
        .DOB(do_b[31:16])
312
    );
313
 
314
    //
315
    // Block 2
316
    //
317
    // block ram2 wires - non generic width of block rams
318
    wire [15:0] blk2_di_a = {8'h00, di_a[39:32]} ;
319
    wire [15:0] blk2_di_b = {8'h00, di_b[39:32]} ;
320
 
321
    wire [15:0] blk2_do_a ;
322
    wire [15:0] blk2_do_b ;
323
 
324
    assign do_a[39:32] = blk2_do_a[7:0] ;
325
    assign do_b[39:32] = blk2_do_b[7:0] ;
326
 
327
    RAMB4_S16_S16 ramb4_s16_s16_2(
328
            .CLKA(clk_a),
329
            .RSTA(rst_a),
330
            .ADDRA(addr_a),
331
            .DIA(blk2_di_a),
332
            .ENA(ce_a),
333
            .WEA(we_a),
334
            .DOA(blk2_do_a),
335
 
336
            .CLKB(clk_b),
337
            .RSTB(rst_b),
338
            .ADDRB(addr_b),
339
            .DIB(blk2_di_b),
340
            .ENB(ce_b),
341
            .WEB(we_b),
342
            .DOB(blk2_do_b)
343
    );
344
 
345
`endif
346
 
347
`ifdef PCI_XILINX_DIST_RAM
348 49 mihad
    `define PCI_PCI_RAM_SELECTED
349 18 mihad
    reg [(aw-1):0] out_address ;
350
    always@(posedge clk_b or posedge rst_b)
351
    begin
352
        if ( rst_b )
353
            out_address <= #1 0 ;
354
        else if (ce_b)
355
            out_address <= #1 addr_b ;
356
    end
357
 
358 49 mihad
    pci_ram_16x40d #(aw) pci_distributed_ram
359 18 mihad
    (
360
        .data_out       (do_b),
361
        .we             (we_a),
362
        .data_in        (di_a),
363
        .read_address   (out_address),
364
        .write_address  (addr_a),
365
        .wclk           (clk_a)
366
    );
367 49 mihad
 
368
    assign do_a = 0 ;
369 18 mihad
`endif
370
 
371 49 mihad
`ifdef PCI_PCI_RAM_SELECTED
372 18 mihad
`else
373
    //
374
    // Generic two-port synchronous RAM model
375
    //
376
 
377
    //
378
    // Generic RAM's registers and wires
379
    //
380
    reg [dw-1:0] mem [(1<<aw)-1:0];       // RAM content
381
    reg [dw-1:0] do_reg_a;               // RAM data output register
382
    reg [dw-1:0] do_reg_b;               // RAM data output register
383
 
384
    //
385
    // Data output drivers
386
    //
387
    assign do_a = (oe_a) ? do_reg_a : {dw{1'bz}};
388
    assign do_b = (oe_b) ? do_reg_b : {dw{1'bz}};
389
 
390
    //
391
    // RAM read and write
392
    //
393
    always @(posedge clk_a)
394
        if (ce_a && !we_a)
395
                do_reg_a <= #1 mem[addr_a];
396
        else if (ce_a && we_a)
397
                mem[addr_a] <= #1 di_a;
398
 
399
    //
400
    // RAM read and write
401
    //
402
    always @(posedge clk_b)
403
        if (ce_b && !we_b)
404
                do_reg_b <= #1 mem[addr_b];
405
        else if (ce_b && we_b)
406
                mem[addr_b] <= #1 di_b;
407
`endif
408
 
409
// synopsys translate_off
410
initial
411
begin
412
    if (dw !== 40)
413
    begin
414
        $display("RAM instantiation error! Expected RAM width %d, actual %h!", 40, dw) ;
415
        $finish ;
416
    end
417
    `ifdef XILINX_RAMB4
418
        if (aw !== 8)
419
        begin
420
            $display("RAM instantiation error! Expected RAM address width %d, actual %h!", 40, aw) ;
421
            $finish ;
422
        end
423
    `endif
424
    // currenlty only artisan ram of depth 256 is supported - they don't provide generic ram models
425
    `ifdef ARTISAN_SDP
426
        if (aw !== 8)
427
        begin
428
            $display("RAM instantiation error! Expected RAM address width %d, actual %h!", 40, aw) ;
429
            $finish ;
430
        end
431
    `endif
432
end
433
// synopsys translate_on
434
 
435
endmodule

powered by: WebSVN 2.1.0

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