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

Subversion Repositories pci

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

powered by: WebSVN 2.1.0

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