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 63

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

powered by: WebSVN 2.1.0

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