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 62

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 62 mihad
// Revision 1.3  2002/09/30 17:22:27  mihad
66
// Added support for Virtual Silicon two port RAM. Didn't run regression on it yet!
67
//
68 60 mihad
// Revision 1.2  2002/08/19 16:51:36  mihad
69
// Extracted distributed RAM module from wb/pci_tpram.v to its own file, got rid of undef directives
70
//
71 49 mihad
// Revision 1.1  2002/02/01 14:43:31  mihad
72
// *** empty log message ***
73 18 mihad
//
74 49 mihad
//
75 18 mihad
 
76
// synopsys translate_off
77
`include "timescale.v"
78
// synopsys translate_on
79
`include "pci_constants.v"
80
 
81
module PCI_TPRAM
82
(
83
        // Generic synchronous two-port RAM interface
84
        clk_a,
85
    rst_a,
86
    ce_a,
87
    we_a,
88
    oe_a,
89
    addr_a,
90
    di_a,
91
    do_a,
92
        clk_b,
93
    rst_b,
94
    ce_b,
95
    we_b,
96
    oe_b,
97
    addr_b,
98
    di_b,
99
    do_b
100 62 mihad
`ifdef PCI_BIST
101
    ,
102
    // debug chain signals
103
    SO,
104
    SI,
105
    shift_DR,
106
    capture_DR,
107
    extest,
108
    tck
109
`endif
110 18 mihad
);
111
 
112
//
113
// Default address and data buses width
114
//
115
parameter aw = 8;
116
parameter dw = 40;
117
 
118
//
119
// Generic synchronous two-port RAM interface
120
//
121
input                   clk_a;  // Clock
122
input                   rst_a;  // Reset
123
input                   ce_a;   // Chip enable input
124
input                   we_a;   // Write enable input
125
input                   oe_a;   // Output enable input
126
input   [aw-1:0] addr_a; // address bus inputs
127
input   [dw-1:0] di_a;   // input data bus
128
output  [dw-1:0] do_a;   // output data bus
129
input                   clk_b;  // Clock
130
input                   rst_b;  // Reset
131
input                   ce_b;   // Chip enable input
132
input                   we_b;   // Write enable input
133
input                   oe_b;   // Output enable input
134
input   [aw-1:0] addr_b; // address bus inputs
135
input   [dw-1:0] di_b;   // input data bus
136
output  [dw-1:0] do_b;   // output data bus
137
 
138 62 mihad
`ifdef PCI_BIST
139
// debug chain signals
140
output  SO ;
141
input   SI ;
142
input   shift_DR ;
143
input   capture_DR ;
144
input   extest ;
145
input   tck ;
146
`endif
147
 
148 18 mihad
//
149
// Internal wires and registers
150
//
151
 
152 60 mihad
`ifdef PCI_VS_STP
153
    `define PCI_PCI_RAM_SELECTED
154 62 mihad
    `ifdef PCI_BIST
155
        vs_hdtp_64x40_bist i_vs_hdtp_64x40_bist
156
    `else
157
        vs_hdtp_64x40 i_vs_hdtp_64x40
158
    `endif
159
        (
160
            .RCK        (clk_b),
161
            .WCK        (clk_a),
162
            .RADR       (addr_b),
163
            .WADR       (addr_a),
164
            .DI         (di_a),
165
            .DOUT       (do_b),
166
            .REN        (1'b0),
167
            .WEN        (!we_a)
168
        `ifdef PCI_BIST
169
            ,
170
            // reset
171
            .rst        (rst_a),
172 18 mihad
 
173 62 mihad
            // debug chain signals
174
            .SO         (SO),
175
            .SI         (SI),
176
            .shift_DR   (shift_DR),
177
            .capture_DR (capture_DR),
178
            .extest     (extest),
179
            .tck        (tck)
180
        `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.