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 60

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

powered by: WebSVN 2.1.0

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