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

Subversion Repositories dmt_tx

[/] [dmt_tx/] [trunk/] [const_encoder/] [rtl/] [generic_dpram.v] - Blame information for rev 23

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 10 dannori
//////////////////////////////////////////////////////////////////////
2
////                                                              ////
3
////  Generic Dual-Port Synchronous RAM                           ////
4
////                                                              ////
5
////  This file is part of memory library available from          ////
6
////  http://www.opencores.org/cvsweb.shtml/generic_memories/     ////
7
////                                                              ////
8
////  Description                                                 ////
9
////  This block is a wrapper with common dual-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
////  dual-port synchronous RAM.                                  ////
14
////  It also contains a fully synthesizeable model for FPGAs.    ////
15
////  It should be used in all OPENCORES designs that want to be  ////
16
////  portable accross different target technologies and          ////
17
////  independent of target memory.                               ////
18
////                                                              ////
19
////  Supported ASIC RAMs are:                                    ////
20
////  - Artisan Dual-Port Sync RAM                                ////
21
////  - Avant! Two-Port Sync RAM (*)                              ////
22
////  - Virage 2-port Sync RAM                                    ////
23
////                                                              ////
24
////  Supported FPGA RAMs are:                                    ////
25
////  - Generic FPGA (VENDOR_FPGA)                                ////
26
////    Tested RAMs: Altera, Xilinx                               ////
27
////    Synthesis tools: LeonardoSpectrum, Synplicity             ////
28
////  - Xilinx (VENDOR_XILINX)                                    ////
29
////  - Altera (VENDOR_ALTERA)                                    ////
30
////                                                              ////
31
////  To Do:                                                      ////
32
////   - fix Avant!                                               ////
33
////   - add additional RAMs (VS etc)                             ////
34
////                                                              ////
35
////  Author(s):                                                  ////
36
////      - Richard Herveille, richard@asics.ws                   ////
37
////      - Damjan Lampret, lampret@opencores.org                 ////
38
////                                                              ////
39
//////////////////////////////////////////////////////////////////////
40
////                                                              ////
41
//// Copyright (C) 2000 Authors and OPENCORES.ORG                 ////
42
////                                                              ////
43
//// This source file may be used and distributed without         ////
44
//// restriction provided that this copyright statement is not    ////
45
//// removed from the file and that any derivative work contains  ////
46
//// the original copyright notice and the associated disclaimer. ////
47
////                                                              ////
48
//// This source file is free software; you can redistribute it   ////
49
//// and/or modify it under the terms of the GNU Lesser General   ////
50
//// Public License as published by the Free Software Foundation; ////
51
//// either version 2.1 of the License, or (at your option) any   ////
52
//// later version.                                               ////
53
////                                                              ////
54
//// This source is distributed in the hope that it will be       ////
55
//// useful, but WITHOUT ANY WARRANTY; without even the implied   ////
56
//// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR      ////
57
//// PURPOSE.  See the GNU Lesser General Public License for more ////
58
//// details.                                                     ////
59
////                                                              ////
60
//// You should have received a copy of the GNU Lesser General    ////
61
//// Public License along with this source; if not, download it   ////
62
//// from http://www.opencores.org/lgpl.shtml                     ////
63
////                                                              ////
64
//////////////////////////////////////////////////////////////////////
65
//
66
// CVS Revision History
67
//
68
// $Log: not supported by cvs2svn $
69
// Revision 1.4  2002/09/28 08:18:52  rherveille
70
// Changed synthesizeable FPGA memory implementation.
71
// Fixed some issues with Xilinx BlockRAM
72
//
73
// Revision 1.3  2001/11/09 00:34:18  samg
74
// minor changes: unified with all common rams
75
//
76
// Revision 1.2  2001/11/08 19:11:31  samg
77
// added valid checks to behvioral model
78
//
79
// Revision 1.1.1.1  2001/09/14 09:57:10  rherveille
80
// Major cleanup.
81
// Files are now compliant to Altera & Xilinx memories.
82
// Memories are now compatible, i.e. drop-in replacements.
83
// Added synthesizeable generic FPGA description.
84
// Created "generic_memories" cvs entry.
85
//
86
// Revision 1.1.1.2  2001/08/21 13:09:27  damjan
87
// *** empty log message ***
88
//
89
// Revision 1.1  2001/08/20 18:23:20  damjan
90
// Initial revision
91
//
92
// Revision 1.1  2001/08/09 13:39:33  lampret
93
// Major clean-up.
94
//
95
// Revision 1.2  2001/07/30 05:38:02  lampret
96
// Adding empty directories required by HDL coding guidelines
97
//
98
//
99
 
100
//`include "timescale.v"
101
//
102
`include "defs.vh"
103
 
104
//`define VENDOR_FPGA
105
//`define VENDOR_XILINX
106
//`define VENDOR_ALTERA
107
 
108
module generic_dpram(
109
        // Generic synchronous dual-port RAM interface
110
        rclk, rrst, rce, oe, raddr, do,
111
        wclk, wrst, wce, we, waddr, di
112
);
113
 
114
        //
115
        // Default address and data buses width
116
        //
117
        parameter aw = 5;  // number of bits in address-bus
118
        parameter dw = 16; // number of bits in data-bus
119
 
120
        //
121
        // Generic synchronous double-port RAM interface
122
        //
123
        // read port
124
        input           rclk;  // read clock, rising edge trigger
125
        input           rrst;  // read port reset, active high
126
        input           rce;   // read port chip enable, active high
127
        input           oe;        // output enable, active high
128
        input  [aw-1:0] raddr; // read address
129
        output [dw-1:0] do;    // data output
130
 
131
        // write port
132
        input          wclk;  // write clock, rising edge trigger
133
        input          wrst;  // write port reset, active high
134
        input          wce;   // write port chip enable, active high
135
        input          we;    // write enable, active high
136
        input [aw-1:0] waddr; // write address
137
        input [dw-1:0] di;    // data input
138
 
139
        //
140
        // Module body
141
        //
142
 
143
`ifdef VENDOR_FPGA
144
        //
145
        // Instantiation synthesizeable FPGA memory
146
        //
147
        // This code has been tested using LeonardoSpectrum and Synplicity.
148
        // The code correctly instantiates Altera EABs and Xilinx BlockRAMs.
149
        //
150
        reg [dw-1:0] mem [(1<<aw) -1:0]; // instantiate memory
151
        reg [aw-1:0] ra;                 // register read address
152
 
153
        // read operation
154
        always @(posedge rclk)
155
          if (rce)
156
            ra <= #1 raddr;
157
 
158
        assign do = mem[ra];
159
 
160
        // write operation
161
        always@(posedge wclk)
162
                if (we && wce)
163
                        mem[waddr] <= #1 di;
164
 
165
`else
166
 
167
`ifdef VENDOR_XILINX
168
        //
169
        // Instantiation of FPGA memory:
170
        //
171
        // Virtex/Spartan2 BlockRAMs
172
        //
173
        xilinx_ram_dp xilinx_ram(
174
                // read port
175
                .CLKA(rclk),
176
                .RSTA(rrst),
177
                .ENA(rce),
178
                .ADDRA(raddr),
179
                .DIA( {dw{1'b0}} ),
180
                .WEA(1'b0),
181
                .DOA(do),
182
 
183
                // write port
184
                .CLKB(wclk),
185
                .RSTB(wrst),
186
                .ENB(wce),
187
                .ADDRB(waddr),
188
                .DIB(di),
189
                .WEB(we),
190
                .DOB()
191
        );
192
 
193
        defparam
194
                xilinx_ram.dwidth = dw,
195
                xilinx_ram.awidth = aw;
196
 
197
`else
198
 
199
`ifdef VENDOR_ALTERA
200
        //
201
        // Instantiation of FPGA memory:
202
        //
203
        // Altera FLEX/APEX EABs
204
        //
205
        altera_ram_dp altera_ram(
206
                // read port
207
                .rdclock(rclk),
208
                .rdclocken(rce),
209
                .rdaddress(raddr),
210
                .q(do),
211
 
212
                // write port
213
                .wrclock(wclk),
214
                .wrclocken(wce),
215
                .wren(we),
216
                .wraddress(waddr),
217
                .data(di)
218
        );
219
 
220
        defparam
221
                altera_ram.dwidth = dw,
222
                altera_ram.awidth = aw;
223
 
224
`else
225
 
226
`ifdef VENDOR_ARTISAN
227
 
228
        //
229
        // Instantiation of ASIC memory:
230
        //
231
        // Artisan Synchronous Double-Port RAM (ra2sh)
232
        //
233
        art_hsdp #(dw, 1<<aw, aw) artisan_sdp(
234
                // read port
235
                .qa(do),
236
                .clka(rclk),
237
                .cena(~rce),
238
                .wena(1'b1),
239
                .aa(raddr),
240
                .da( {dw{1'b0}} ),
241
                .oena(~oe),
242
 
243
                // write port
244
                .qb(),
245
                .clkb(wclk),
246
                .cenb(~wce),
247
                .wenb(~we),
248
                .ab(waddr),
249
                .db(di),
250
                .oenb(1'b1)
251
        );
252
 
253
`else
254
 
255
`ifdef VENDOR_AVANT
256
 
257
        //
258
        // Instantiation of ASIC memory:
259
        //
260
        // Avant! Asynchronous Two-Port RAM
261
        //
262
        avant_atp avant_atp(
263
                .web(~we),
264
                .reb(),
265
                .oeb(~oe),
266
                .rcsb(),
267
                .wcsb(),
268
                .ra(raddr),
269
                .wa(waddr),
270
                .di(di),
271
                .do(do)
272
        );
273
 
274
`else
275
 
276
`ifdef VENDOR_VIRAGE
277
 
278
        //
279
        // Instantiation of ASIC memory:
280
        //
281
        // Virage Synchronous 2-port R/W RAM
282
        //
283
        virage_stp virage_stp(
284
                // read port
285
                .CLKA(rclk),
286
                .MEA(rce_a),
287
                .ADRA(raddr),
288
                .DA( {dw{1'b0}} ),
289
                .WEA(1'b0),
290
                .OEA(oe),
291
                .QA(do),
292
 
293
                // write port
294
                .CLKB(wclk),
295
                .MEB(wce),
296
                .ADRB(waddr),
297
                .DB(di),
298
                .WEB(we),
299
                .OEB(1'b1),
300
                .QB()
301
        );
302
 
303
`else
304
 
305
        //
306
        // Generic dual-port synchronous RAM model
307
        //
308
 
309
        //
310
        // Generic RAM's registers and wires
311
        //
312
        reg     [dw-1:0] mem [(1<<aw)-1:0]; // RAM content
313
        reg     [dw-1:0] do_reg;            // RAM data output register
314
 
315
        //
316
        // Data output drivers
317
        //
318
        assign do = (oe & rce) ? do_reg : {dw{1'bz}};
319
 
320
        // read operation
321
        always @(posedge rclk)
322
                if (rce)
323
                        do_reg <= #1 (we && (waddr==raddr)) ? {dw{1'b x}} : mem[raddr];
324
 
325
        // write operation
326
        always @(posedge wclk)
327
                if (wce && we)
328
                        mem[waddr] <= #1 di;
329
 
330
 
331
        // Task prints range of memory
332
        // *** Remember that tasks are non reentrant, don't call this task in parallel for multiple instantiations.
333
        task print_ram;
334
        input [aw-1:0] start;
335
        input [aw-1:0] finish;
336
        integer rnum;
337
        begin
338
                for (rnum=start;rnum<=finish;rnum=rnum+1)
339
                        $display("Addr %h = %h",rnum,mem[rnum]);
340
        end
341
        endtask
342
 
343
`endif // !VENDOR_VIRAGE
344
`endif // !VENDOR_AVANT
345
`endif // !VENDOR_ARTISAN
346
`endif // !VENDOR_ALTERA
347
`endif // !VENDOR_XILINX
348
`endif // !VENDOR_FPGA
349
 
350
endmodule
351
 
352
//
353
// Black-box modules
354
//
355
 
356
`ifdef VENDOR_ALTERA
357
        module altera_ram_dp(
358
                data,
359
                wraddress,
360
                rdaddress,
361
                wren,
362
                wrclock,
363
                wrclocken,
364
                rdclock,
365
                rdclocken,
366
                q) /* synthesis black_box */;
367
 
368
                parameter awidth = 7;
369
                parameter dwidth = 8;
370
 
371
                input [dwidth -1:0] data;
372
                input [awidth -1:0] wraddress;
373
                input [awidth -1:0] rdaddress;
374
                input               wren;
375
                input               wrclock;
376
                input               wrclocken;
377
                input               rdclock;
378
                input               rdclocken;
379
                output [dwidth -1:0] q;
380
 
381
                // synopsis translate_off
382
                // exemplar translate_off
383
 
384
                syn_dpram_rowr #(
385
                        "UNUSED",
386
                        dwidth,
387
                        awidth,
388
                        1 << awidth
389
                )
390
                altera_dpram_model (
391
                        // read port
392
                        .RdClock(rdclock),
393
                        .RdClken(rdclocken),
394
                        .RdAddress(rdaddress),
395
                        .RdEn(1'b1),
396
                        .Q(q),
397
 
398
                        // write port
399
                        .WrClock(wrclock),
400
                        .WrClken(wrclocken),
401
                        .WrAddress(wraddress),
402
                        .WrEn(wren),
403
                        .Data(data)
404
                );
405
 
406
                // exemplar translate_on
407
                // synopsis translate_on
408
 
409
        endmodule
410
`endif // VENDOR_ALTERA
411
 
412
`ifdef VENDOR_XILINX
413
        module xilinx_ram_dp (
414
                ADDRA,
415
                CLKA,
416
                ADDRB,
417
                CLKB,
418
                DIA,
419
                WEA,
420
                DIB,
421
                WEB,
422
                ENA,
423
                ENB,
424
                RSTA,
425
                RSTB,
426
                DOA,
427
                DOB) /* synthesis black_box */ ;
428
 
429
        parameter awidth = 7;
430
        parameter dwidth = 8;
431
 
432
        // port_a
433
        input               CLKA;
434
        input               RSTA;
435
        input               ENA;
436
        input [awidth-1:0]  ADDRA;
437
        input [dwidth-1:0]  DIA;
438
        input               WEA;
439
        output [dwidth-1:0] DOA;
440
 
441
        // port_b
442
        input               CLKB;
443
        input               RSTB;
444
        input               ENB;
445
        input [awidth-1:0]  ADDRB;
446
        input [dwidth-1:0]  DIB;
447
        input               WEB;
448
        output [dwidth-1:0] DOB;
449
 
450
        // insert simulation model
451
 
452
 
453
        // synopsys translate_off
454
        // exemplar translate_off
455
 
456
        C_MEM_DP_BLOCK_V1_0 #(
457
                awidth,
458
                awidth,
459
                1,
460
                1,
461
                "0",
462
                1 << awidth,
463
                1 << awidth,
464
                1,
465
                1,
466
                1,
467
                1,
468
                1,
469
                1,
470
                1,
471
                1,
472
                1,
473
                1,
474
                1,
475
                1,
476
                1,
477
                "",
478
                16,
479
                0,
480
                0,
481
                1,
482
                1,
483
                1,
484
                1,
485
                dwidth,
486
                dwidth)
487
        xilinx_dpram_model (
488
                .ADDRA(ADDRA),
489
                .CLKA(CLKA),
490
                .ADDRB(ADDRB),
491
                .CLKB(CLKB),
492
                .DIA(DIA),
493
                .WEA(WEA),
494
                .DIB(DIB),
495
                .WEB(WEB),
496
                .ENA(ENA),
497
                .ENB(ENB),
498
                .RSTA(RSTA),
499
                .RSTB(RSTB),
500
                .DOA(DOA),
501
                .DOB(DOB));
502
 
503
                // exemplar translate_on
504
                // synopsys translate_on
505
 
506
        endmodule
507
`endif // VENDOR_XILINX

powered by: WebSVN 2.1.0

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