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

Subversion Repositories minsoc

[/] [minsoc/] [branches/] [rc-1.0/] [rtl/] [verilog/] [minsoc_onchip_ram.v] - Blame information for rev 130

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 rfajardo
//////////////////////////////////////////////////////////////////////
2
////                                                              ////
3
////  Generic Single-Port Synchronous RAM                         ////
4
////                                                              ////
5
////  This file is part of memory library available from          ////
6
////  http://www.opencores.org/cvsweb.shtml/minsoc/               ////
7
////                                                              ////
8
////  Description                                                 ////
9
////  This block is a wrapper with common single-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
////  single-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 Single-Port Sync RAM                              ////
20
////  - Avant! Two-Port Sync RAM (*)                              ////
21
////  - Virage Single-Port Sync RAM                               ////
22
////  - Virtual Silicon Single-Port Sync RAM                      ////
23
////                                                              ////
24
////  Supported FPGA RAMs are:                                    ////
25
////  - Xilinx Virtex RAMB16                                      ////
26
////  - Xilinx Virtex RAMB4                                       ////
27
////  - Altera LPM                                                ////
28
////                                                              ////
29
////  To Do:                                                      ////
30
////   - fix avant! two-port ram                                  ////
31
////   - add additional RAMs                                      ////
32
////                                                              ////
33
////  Author(s):                                                  ////
34
////      - Raul Fajardo, rfajardo@gmail.com                      ////
35
////      - Damjan Lampret, lampret@opencores.org                 ////
36
////                                                              ////
37
//////////////////////////////////////////////////////////////////////
38
////                                                              ////
39
//// Copyright (C) 2000 Authors and OPENCORES.ORG                 ////
40
////                                                              ////
41
//// This source file may be used and distributed without         ////
42
//// restriction provided that this copyright statement is not    ////
43
//// removed from the file and that any derivative work contains  ////
44
//// the original copyright notice and the associated disclaimer. ////
45
////                                                              ////
46
//// This source file is free software; you can redistribute it   ////
47
//// and/or modify it under the terms of the GNU Lesser General   ////
48
//// Public License as published by the Free Software Foundation; ////
49
//// either version 2.1 of the License, or (at your option) any   ////
50
//// later version.                                               ////
51
////                                                              ////
52
//// This source is distributed in the hope that it will be       ////
53
//// useful, but WITHOUT ANY WARRANTY; without even the implied   ////
54
//// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR      ////
55
//// PURPOSE.  See the GNU Lesser General Public License for more ////
56
//// details.                                                     ////
57
////                                                              ////
58
//// You should have received a copy of the GNU Lesser General    ////
59
//// Public License along with this source; if not, download it   ////
60
//// from http://www.gnu.org/licenses/lgpl.html                   ////
61
////                                                              ////
62
//////////////////////////////////////////////////////////////////////
63
//
64
// Revision History
65
//
66
//
67 6 rfajardo
// Revision 2.1 2009/08/23 16:41:00   fajardo
68
// Sensitivity of addr_reg and memory write changed back to posedge clk for GENERIC_MEMORY
69
// This actually models appropriately the behavior of the FPGA internal RAMs
70
//
71 2 rfajardo
// Revision 2.0 2009/09/10 11:30:00   fajardo
72
// Added tri-state buffering for altera output
73
// Sensitivity of addr_reg and memory write changed to negedge clk for GENERIC_MEMORY
74
//
75
// Revision 1.9 2009/08/18 15:15:00   fajardo
76
// Added tri-state buffering for xilinx and generic memory output
77
//
78
// $Log: not supported by cvs2svn $
79
// Revision 1.8  2004/06/08 18:15:32  lampret
80
// Changed behavior of the simulation generic models
81
//
82
// Revision 1.7  2004/04/05 08:29:57  lampret
83
// Merged branch_qmem into main tree.
84
//
85
// Revision 1.3.4.1  2003/12/09 11:46:48  simons
86
// Mbist nameing changed, Artisan ram instance signal names fixed, some synthesis waning fixed.
87
//
88
// Revision 1.3  2003/04/07 01:19:07  lampret
89
// Added Altera LPM RAMs. Changed generic RAM output when OE inactive.
90
//
91
// Revision 1.2  2002/10/17 20:04:40  lampret
92
// Added BIST scan. Special VS RAMs need to be used to implement BIST.
93
//
94
// Revision 1.1  2002/01/03 08:16:15  lampret
95
// New prefixes for RTL files, prefixed module names. Updated cache controllers and MMUs.
96
//
97
// Revision 1.8  2001/11/02 18:57:14  lampret
98
// Modified virtual silicon instantiations.
99
//
100
// Revision 1.7  2001/10/21 17:57:16  lampret
101
// Removed params from generic_XX.v. Added translate_off/on in sprs.v and id.v. Removed spr_addr from dc.v and ic.v. Fixed CR+LF.
102
//
103
// Revision 1.6  2001/10/14 13:12:09  lampret
104
// MP3 version.
105
//
106
// Revision 1.1.1.1  2001/10/06 10:18:36  igorm
107
// no message
108
//
109
// Revision 1.1  2001/08/09 13:39:33  lampret
110
// Major clean-up.
111
//
112
// Revision 1.2  2001/07/30 05:38:02  lampret
113
// Adding empty directories required by HDL coding guidelines
114
//
115
//
116
 
117
// synopsys translate_off
118
`include "timescale.v"
119
// synopsys translate_on
120
`include "minsoc_defines.v"
121
 
122
module minsoc_onchip_ram(
123
`ifdef BIST
124
        // RAM BIST
125
        mbist_si_i, mbist_so_o, mbist_ctrl_i,
126
`endif
127
        // Generic synchronous single-port RAM interface
128
        clk, rst, ce, we, oe, addr, di, doq
129
);
130
 
131
//
132
// Default address and data buses width
133
//
134
parameter aw = 11;
135
parameter dw = 8;
136
 
137
`ifdef BIST
138
//
139
// RAM BIST
140
//
141
input mbist_si_i;
142
input [`MBIST_CTRL_WIDTH - 1:0] mbist_ctrl_i;
143
output mbist_so_o;
144
`endif
145
 
146
//
147
// Generic synchronous single-port RAM interface
148
//
149
input                   clk;    // Clock
150
input                   rst;    // Reset
151
input                   ce;     // Chip enable input
152
input                   we;     // Write enable input
153
input                   oe;     // Output enable input
154
input   [aw-1:0] addr;   // address bus inputs
155
input   [dw-1:0] di;     // input data bus
156
output  [dw-1:0] doq;    // output data bus
157
 
158
//
159
// Decide memory implementation for Xilinx FPGAs
160
//
161
`ifdef SPARTAN2
162
        `define MINSOC_XILINX_RAMB4
163
`elsif VIRTEX
164
        `define MINSOC_XILINX_RAMB4
165
`endif  // !SPARTAN2/VIRTEX
166
 
167
`ifdef SPARTAN3
168
        `define MINSOC_XILINX_RAMB16
169
`elsif SPARTAN3E
170
        `define MINSOC_XILINX_RAMB16
171
`elsif SPARTAN3A
172
        `define MINSOC_XILINX_RAMB16
173
`elsif VIRTEX2
174
        `define MINSOC_XILINX_RAMB16
175
`elsif VIRTEX4
176
        `define MINSOC_XILINX_RAMB16
177
`elsif VIRTEX5
178
        `define MINSOC_XILINX_RAMB16
179
`endif  // !SPARTAN3/SPARTAN3E/SPARTAN3A/VIRTEX2/VIRTEX4/VIRTEX5
180
 
181
 
182
//
183
// Internal wires and registers
184
//
185
 
186
`ifdef ARTISAN_SSP
187
`else
188
`ifdef VIRTUALSILICON_SSP
189
`else
190
`ifdef BIST
191
assign mbist_so_o = mbist_si_i;
192
`endif
193
`endif
194
`endif
195
 
196
 
197
`ifdef GENERIC_MEMORY
198
//
199
// Generic single-port synchronous RAM model
200
//
201
 
202
//
203
// Generic RAM's registers and wires
204
//
205
reg     [dw-1:0] mem [(1<<aw)-1:0];       // RAM content
206
reg     [aw-1:0] addr_reg;               // RAM address register
207
 
208
//
209
// Data output drivers
210
//
211
assign doq = (oe) ? mem[addr_reg] : {dw{1'bZ}};
212
 
213
//
214
// RAM address register
215
//
216 6 rfajardo
always @(posedge clk or posedge rst)
217 2 rfajardo
        if (rst)
218
                addr_reg <= #1 {aw{1'b0}};
219
        else if (ce)
220
                addr_reg <= #1 addr;
221
 
222
//
223
// RAM write
224
//
225 6 rfajardo
always @(posedge clk)
226 2 rfajardo
        if (ce && we)
227
                mem[addr] <= #1 di;
228
 
229
 
230
`elsif ARTISAN_SSP
231
//
232
// Instantiation of ASIC memory:
233
//
234
// Artisan Synchronous Single-Port RAM (ra1sh)
235
//
236
`ifdef UNUSED
237
art_hssp_2048x8 #(dw, 1<<aw, aw) artisan_ssp(
238
`else
239
`ifdef BIST
240
art_hssp_2048x8_bist artisan_ssp(
241
`else
242
art_hssp_2048x8 artisan_ssp(
243
`endif
244
`endif
245
`ifdef BIST
246
        // RAM BIST
247
        .mbist_si_i(mbist_si_i),
248
        .mbist_so_o(mbist_so_o),
249
        .mbist_ctrl_i(mbist_ctrl_i),
250
`endif
251
        .CLK(clk),
252
        .CEN(~ce),
253
        .WEN(~we),
254
        .A(addr),
255
        .D(di),
256
        .OEN(~oe),
257
        .Q(doq)
258
);
259
 
260
 
261
`elsif AVANT_ATP
262
//
263
// Instantiation of ASIC memory:
264
//
265
// Avant! Asynchronous Two-Port RAM
266
//
267
avant_atp avant_atp(
268
        .web(~we),
269
        .reb(),
270
        .oeb(~oe),
271
        .rcsb(),
272
        .wcsb(),
273
        .ra(addr),
274
        .wa(addr),
275
        .di(di),
276
        .doq(doq)
277
);
278
 
279
 
280
`elsif VIRAGE_SSP
281
//
282
// Instantiation of ASIC memory:
283
//
284
// Virage Synchronous 1-port R/W RAM
285
//
286
virage_ssp virage_ssp(
287
        .clk(clk),
288
        .adr(addr),
289
        .d(di),
290
        .we(we),
291
        .oe(oe),
292
        .me(ce),
293
        .q(doq)
294
);
295
 
296
 
297
`elsif VIRTUALSILICON_SSP
298
//
299
// Instantiation of ASIC memory:
300
//
301
// Virtual Silicon Single-Port Synchronous SRAM
302
//
303
`ifdef UNUSED
304
vs_hdsp_2048x8 #(1<<aw, aw-1, dw-1) vs_ssp(
305
`else
306
`ifdef BIST
307
vs_hdsp_2048x8_bist vs_ssp(
308
`else
309
vs_hdsp_2048x8 vs_ssp(
310
`endif
311
`endif
312
`ifdef BIST
313
        // RAM BIST
314
        .mbist_si_i(mbist_si_i),
315
        .mbist_so_o(mbist_so_o),
316
        .mbist_ctrl_i(mbist_ctrl_i),
317
`endif
318
        .CK(clk),
319
        .ADR(addr),
320
        .DI(di),
321
        .WEN(~we),
322
        .CEN(~ce),
323
        .OEN(~oe),
324
        .DOUT(doq)
325
);
326
 
327
 
328
`elsif MINSOC_XILINX_RAMB4
329
//
330
// Instantiation of FPGA memory:
331
//
332
// SPARTAN2/VIRTEX
333
//
334
 
335
wire    [dw-1:0] doq_internal;   // output data bus
336
 
337
//
338
// Block 0
339
//
340
RAMB4_S2 ramb4_s2_0(
341
        .CLK(clk),
342
        .RST(rst),
343
        .ADDR(addr),
344
        .DI(di[1:0]),
345
        .EN(ce),
346
        .WE(we),
347
        .DO(doq_internal[1:0])
348
);
349
 
350
//
351
// Block 1
352
//
353
RAMB4_S2 ramb4_s2_1(
354
        .CLK(clk),
355
        .RST(rst),
356
        .ADDR(addr),
357
        .DI(di[3:2]),
358
        .EN(ce),
359
        .WE(we),
360
        .DO(doq_internal[3:2])
361
);
362
 
363
//
364
// Block 2
365
//
366
RAMB4_S2 ramb4_s2_2(
367
        .CLK(clk),
368
        .RST(rst),
369
        .ADDR(addr),
370
        .DI(di[5:4]),
371
        .EN(ce),
372
        .WE(we),
373
        .DO(doq_internal[5:4])
374
);
375
 
376
//
377
// Block 3
378
//
379
RAMB4_S2 ramb4_s2_3(
380
        .CLK(clk),
381
        .RST(rst),
382
        .ADDR(addr),
383
        .DI(di[7:6]),
384
        .EN(ce),
385
        .WE(we),
386
        .DO(doq_internal[7:6])
387
);
388
 
389
assign doq = (oe) ? (doq_internal) : { dw{1'bZ} };
390
 
391
 
392
`elsif MINSOC_XILINX_RAMB16
393
//
394
// Instantiation of FPGA memory:
395
//
396
// SPARTAN3/SPARTAN3E/VIRTEX2
397
// SPARTAN3A/VIRTEX4/VIRTEX5 are automatically reallocated by ISE
398
//
399
// Added By Nir Mor
400
//
401
 
402
wire    [dw-1:0] doq_internal;   // output data bus
403
 
404
RAMB16_S9 ramb16_s9(
405
        .CLK(clk),
406
        .SSR(rst),
407
        .ADDR(addr),
408
        .DI(di),
409
        .DIP(1'b0),
410
        .EN(ce),
411
        .WE(we),
412
        .DO(doq_internal),
413
        .DOP()
414
);
415
 
416
assign doq = (oe) ? (doq_internal) : { dw{1'bZ} };
417
 
418
 
419
`elsif ALTERA_FPGA
420
//
421
// Instantiation of FPGA memory:
422
//
423
// Altera LPM
424
//
425
// Added By Jamil Khatib
426
//
427
 
428
wire    wr;
429
 
430
assign  wr = ce & we;
431
 
432
wire    [dw-1:0] doq_internal;   // output data bus
433
 
434
initial $display("Using Altera LPM.");
435
 
436
lpm_ram_dq lpm_ram_dq_component (
437
        .address(addr),
438
        .inclock(clk),
439
        .data(di),
440
        .we(wr),
441
        .q(doq_internal)
442
);
443
 
444
assign doq = (oe) ? (doq_internal) : { dw{1'bZ} };
445
 
446
defparam lpm_ram_dq_component.lpm_width = dw,
447
        lpm_ram_dq_component.lpm_widthad = aw,
448
        lpm_ram_dq_component.lpm_indata = "REGISTERED",
449
        lpm_ram_dq_component.lpm_address_control = "REGISTERED",
450
        lpm_ram_dq_component.lpm_outdata = "UNREGISTERED",
451
        lpm_ram_dq_component.lpm_hint = "USE_EAB=ON";
452
        // examplar attribute lpm_ram_dq_component NOOPT TRUE
453
 
454
 
455
`endif  // !ALTERA_FPGA/MINCON_XILINX_RAMB16/MINCON_XILINX_RAMB4/VIRTUALSILICON_SSP/VIRAGE_SSP/AVANT_ATP/ARTISAN_SSP/GENERIC_MEMORY
456
 
457
 
458
endmodule

powered by: WebSVN 2.1.0

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