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

Subversion Repositories or1k

[/] [or1k/] [trunk/] [or1200/] [rtl/] [verilog/] [or1200_spram_64x24.v] - Blame information for rev 1778

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

Line No. Rev Author Line
1 504 lampret
//////////////////////////////////////////////////////////////////////
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/generic_memories/     ////
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 1582 jcastillo
////  - Xilinx Virtex RAMB16                                      ////
26
////  - Xilinx Virtex RAMB4                                       ////
27 1129 lampret
////  - Altera LPM                                                ////
28 504 lampret
////                                                              ////
29
////  To Do:                                                      ////
30
////   - xilinx rams need external tri-state logic                ////
31
////   - fix avant! two-port ram                                  ////
32 1129 lampret
////   - add additional RAMs                                      ////
33 504 lampret
////                                                              ////
34
////  Author(s):                                                  ////
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.opencores.org/lgpl.shtml                     ////
61
////                                                              ////
62
//////////////////////////////////////////////////////////////////////
63
//
64
// CVS Revision History
65
//
66
// $Log: not supported by cvs2svn $
67 1582 jcastillo
// Revision 1.8  2004/06/08 18:15:32  lampret
68
// Changed behavior of the simulation generic models
69
//
70 1291 lampret
// Revision 1.7  2004/04/05 08:29:57  lampret
71
// Merged branch_qmem into main tree.
72
//
73 1267 lampret
// Revision 1.3.4.1  2003/12/09 11:46:48  simons
74
// Mbist nameing changed, Artisan ram instance signal names fixed, some synthesis waning fixed.
75 1200 markom
//
76 1179 simons
// Revision 1.3  2003/04/07 01:19:07  lampret
77
// Added Altera LPM RAMs. Changed generic RAM output when OE inactive.
78
//
79 1129 lampret
// Revision 1.2  2002/10/17 20:04:41  lampret
80
// Added BIST scan. Special VS RAMs need to be used to implement BIST.
81
//
82 1063 lampret
// Revision 1.1  2002/01/03 08:16:15  lampret
83
// New prefixes for RTL files, prefixed module names. Updated cache controllers and MMUs.
84
//
85 504 lampret
// Revision 1.8  2001/11/02 18:57:14  lampret
86
// Modified virtual silicon instantiations.
87
//
88
// Revision 1.7  2001/10/22 19:39:56  lampret
89
// Fixed parameters in generic sprams.
90
//
91
// Revision 1.6  2001/10/21 17:57:16  lampret
92
// 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.
93
//
94
// Revision 1.5  2001/10/14 13:12:09  lampret
95
// MP3 version.
96
//
97
// Revision 1.1.1.1  2001/10/06 10:18:36  igorm
98
// no message
99
//
100
// Revision 1.1  2001/08/09 13:39:33  lampret
101
// Major clean-up.
102
//
103
// Revision 1.2  2001/07/30 05:38:02  lampret
104
// Adding empty directories required by HDL coding guidelines
105
//
106
//
107
 
108
// synopsys translate_off
109
`include "timescale.v"
110
// synopsys translate_on
111
`include "or1200_defines.v"
112
 
113
module or1200_spram_64x24(
114 1063 lampret
`ifdef OR1200_BIST
115
        // RAM BIST
116 1200 markom
        mbist_si_i, mbist_so_o, mbist_ctrl_i,
117 1063 lampret
`endif
118 504 lampret
        // Generic synchronous single-port RAM interface
119 1291 lampret
        clk, rst, ce, we, oe, addr, di, doq
120 504 lampret
);
121
 
122
//
123
// Default address and data buses width
124
//
125
parameter aw = 6;
126
parameter dw = 24;
127
 
128 1063 lampret
`ifdef OR1200_BIST
129 504 lampret
//
130 1063 lampret
// RAM BIST
131
//
132 1267 lampret
input mbist_si_i;
133
input [`OR1200_MBIST_CTRL_WIDTH - 1:0] mbist_ctrl_i;
134
output mbist_so_o;
135 1063 lampret
`endif
136
 
137
//
138 504 lampret
// Generic synchronous single-port RAM interface
139
//
140
input                   clk;    // Clock
141
input                   rst;    // Reset
142
input                   ce;     // Chip enable input
143
input                   we;     // Write enable input
144
input                   oe;     // Output enable input
145
input   [aw-1:0] addr;   // address bus inputs
146
input   [dw-1:0] di;     // input data bus
147 1291 lampret
output  [dw-1:0] doq;    // output data bus
148 504 lampret
 
149
//
150
// Internal wires and registers
151
//
152 1582 jcastillo
`ifdef OR1200_XILINX_RAMB4
153 504 lampret
wire    [7:0]            unconnected;
154 1582 jcastillo
`else
155
`ifdef OR1200_XILINX_RAMB16
156
wire    [7:0]            unconnected;
157
`endif // !OR1200_XILINX_RAMB16
158
`endif // !OR1200_XILINX_RAMB4
159 504 lampret
 
160 1184 simons
`ifdef OR1200_ARTISAN_SSP
161
`else
162
`ifdef OR1200_VIRTUALSILICON_SSP
163
`else
164 1063 lampret
`ifdef OR1200_BIST
165 1200 markom
assign mbist_so_o = mbist_si_i;
166 1063 lampret
`endif
167 1184 simons
`endif
168
`endif
169 1063 lampret
 
170 504 lampret
`ifdef OR1200_ARTISAN_SSP
171
 
172
//
173
// Instantiation of ASIC memory:
174
//
175
// Artisan Synchronous Single-Port RAM (ra1sh)
176
//
177
`ifdef UNUSED
178
art_hssp_64x24 #(dw, 1<<aw, aw) artisan_ssp(
179
`else
180 1179 simons
`ifdef OR1200_BIST
181
art_hssp_64x24_bist artisan_ssp(
182
`else
183 504 lampret
art_hssp_64x24 artisan_ssp(
184
`endif
185 1179 simons
`endif
186
`ifdef OR1200_BIST
187
        // RAM BIST
188 1200 markom
        .mbist_si_i(mbist_si_i),
189
        .mbist_so_o(mbist_so_o),
190
        .mbist_ctrl_i(mbist_ctrl_i),
191 1179 simons
`endif
192
        .CLK(clk),
193
        .CEN(~ce),
194
        .WEN(~we),
195
        .A(addr),
196
        .D(di),
197
        .OEN(~oe),
198 1291 lampret
        .Q(doq)
199 504 lampret
);
200
 
201
`else
202
 
203
`ifdef OR1200_AVANT_ATP
204
 
205
//
206
// Instantiation of ASIC memory:
207
//
208
// Avant! Asynchronous Two-Port RAM
209
//
210
avant_atp avant_atp(
211
        .web(~we),
212
        .reb(),
213
        .oeb(~oe),
214
        .rcsb(),
215
        .wcsb(),
216
        .ra(addr),
217
        .wa(addr),
218
        .di(di),
219 1291 lampret
        .doq(doq)
220 504 lampret
);
221
 
222
`else
223
 
224
`ifdef OR1200_VIRAGE_SSP
225
 
226
//
227
// Instantiation of ASIC memory:
228
//
229
// Virage Synchronous 1-port R/W RAM
230
//
231
virage_ssp virage_ssp(
232
        .clk(clk),
233
        .adr(addr),
234
        .d(di),
235
        .we(we),
236
        .oe(oe),
237
        .me(ce),
238 1291 lampret
        .q(doq)
239 504 lampret
);
240
 
241
`else
242
 
243
`ifdef OR1200_VIRTUALSILICON_SSP
244
 
245
//
246
// Instantiation of ASIC memory:
247
//
248
// Virtual Silicon Single-Port Synchronous SRAM
249
//
250
`ifdef UNUSED
251
vs_hdsp_64x24 #(1<<aw, aw-1, dw-1) vs_ssp(
252
`else
253 1063 lampret
`ifdef OR1200_BIST
254
vs_hdsp_64x24_bist vs_ssp(
255
`else
256 504 lampret
vs_hdsp_64x24 vs_ssp(
257
`endif
258 1063 lampret
`endif
259
`ifdef OR1200_BIST
260
        // RAM BIST
261 1200 markom
        .mbist_si_i(mbist_si_i),
262
        .mbist_so_o(mbist_so_o),
263
        .mbist_ctrl_i(mbist_ctrl_i),
264 1063 lampret
`endif
265 504 lampret
        .CK(clk),
266
        .ADR(addr),
267
        .DI(di),
268
        .WEN(~we),
269
        .CEN(~ce),
270
        .OEN(~oe),
271 1291 lampret
        .DOUT(doq)
272 504 lampret
);
273
 
274
`else
275
 
276
`ifdef OR1200_XILINX_RAMB4
277
 
278
//
279
// Instantiation of FPGA memory:
280
//
281
// Virtex/Spartan2
282
//
283
 
284
//
285
// Block 0
286
//
287
RAMB4_S16 ramb4_s16_0(
288
        .CLK(clk),
289
        .RST(rst),
290
        .ADDR({2'b00, addr}),
291
        .DI(di[15:0]),
292
        .EN(ce),
293
        .WE(we),
294 1291 lampret
        .DO(doq[15:0])
295 504 lampret
);
296
 
297
//
298
// Block 1
299
//
300
RAMB4_S16 ramb4_s16_1(
301
        .CLK(clk),
302
        .RST(rst),
303
        .ADDR({2'b00, addr}),
304 1582 jcastillo
        .DI({8'h00, di[23:16]}),
305 504 lampret
        .EN(ce),
306
        .WE(we),
307 1291 lampret
        .DO({unconnected, doq[23:16]})
308 504 lampret
);
309
 
310
`else
311
 
312 1582 jcastillo
`ifdef OR1200_XILINX_RAMB16
313
 
314
//
315
// Instantiation of FPGA memory:
316
//
317
// Virtex4/Spartan3E
318
//
319
// Added By Nir Mor
320
//
321
 
322
RAMB16_S36 ramb16_s36(
323
        .CLK(clk),
324
        .SSR(rst),
325
        .ADDR({3'b000, addr}),
326
        .DI({8'h00,di}),
327
        .DIP(4'h0),
328
        .EN(ce),
329
        .WE(we),
330
        .DO({unconnected, doq}),
331
        .DOP()
332
);
333
 
334
`else
335
 
336 1129 lampret
`ifdef OR1200_ALTERA_LPM
337
 
338 504 lampret
//
339 1129 lampret
// Instantiation of FPGA memory:
340
//
341
// Altera LPM
342
//
343
// Added By Jamil Khatib
344
//
345
 
346
wire    wr;
347
 
348
assign  wr = ce & we;
349
 
350
initial $display("Using Altera LPM.");
351
 
352
lpm_ram_dq lpm_ram_dq_component (
353
        .address(addr),
354
        .inclock(clk),
355
        .outclock(clk),
356
        .data(di),
357
        .we(wr),
358 1291 lampret
        .q(doq)
359 1129 lampret
);
360
 
361
defparam lpm_ram_dq_component.lpm_width = dw,
362
        lpm_ram_dq_component.lpm_widthad = aw,
363
        lpm_ram_dq_component.lpm_indata = "REGISTERED",
364
        lpm_ram_dq_component.lpm_address_control = "REGISTERED",
365
        lpm_ram_dq_component.lpm_outdata = "UNREGISTERED",
366
        lpm_ram_dq_component.lpm_hint = "USE_EAB=ON";
367
        // examplar attribute lpm_ram_dq_component NOOPT TRUE
368
 
369
`else
370
 
371
//
372 504 lampret
// Generic single-port synchronous RAM model
373
//
374
 
375
//
376
// Generic RAM's registers and wires
377
//
378
reg     [dw-1:0] mem [(1<<aw)-1:0];       // RAM content
379 1291 lampret
reg     [aw-1:0] addr_reg;               // RAM address register
380 504 lampret
 
381
//
382
// Data output drivers
383
//
384 1291 lampret
assign doq = (oe) ? mem[addr_reg] : {dw{1'b0}};
385 504 lampret
 
386
//
387 1291 lampret
// RAM address register
388 504 lampret
//
389 1291 lampret
always @(posedge clk or posedge rst)
390
        if (rst)
391
                addr_reg <= #1 {aw{1'b0}};
392
        else if (ce)
393
                addr_reg <= #1 addr;
394
 
395
//
396
// RAM write
397
//
398 504 lampret
always @(posedge clk)
399 1291 lampret
        if (ce && we)
400
                mem[addr] <= #1 di;
401 504 lampret
 
402 1129 lampret
`endif  // !OR1200_ALTERA_LPM
403 1582 jcastillo
`endif  // !OR1200_XILINX_RAMB16
404
`endif  // !OR1200_XILINX_RAMB4
405 504 lampret
`endif  // !OR1200_VIRTUALSILICON_SSP
406
`endif  // !OR1200_VIRAGE_SSP
407 1582 jcastillo
`endif  // !OR1200_AVANT_ATP
408 504 lampret
`endif  // !OR1200_ARTISAN_SSP
409
 
410
endmodule

powered by: WebSVN 2.1.0

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