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 67

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

powered by: WebSVN 2.1.0

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