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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [or1200/] [rtl/] [verilog/] [or1200_spram_64x24.v] - Blame information for rev 27

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

Line No. Rev Author Line
1 10 unneback
//////////////////////////////////////////////////////////////////////
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
////  - Xilinx Virtex RAMB16                                      ////
26
////  - Xilinx Virtex RAMB4                                       ////
27
////  - Altera LPM                                                ////
28
////                                                              ////
29
////  To Do:                                                      ////
30
////   - xilinx rams need external tri-state logic                ////
31
////   - fix avant! two-port ram                                  ////
32
////   - add additional RAMs                                      ////
33
////                                                              ////
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
// Revision 1.8  2004/06/08 18:15:32  lampret
68
// Changed behavior of the simulation generic models
69
//
70
// Revision 1.7  2004/04/05 08:29:57  lampret
71
// Merged branch_qmem into main tree.
72
//
73
// 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
//
76
// Revision 1.3  2003/04/07 01:19:07  lampret
77
// Added Altera LPM RAMs. Changed generic RAM output when OE inactive.
78
//
79
// 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
// 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
// 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
`ifdef OR1200_BIST
115
        // RAM BIST
116
        mbist_si_i, mbist_so_o, mbist_ctrl_i,
117
`endif
118
        // Generic synchronous single-port RAM interface
119
        clk, rst, ce, we, oe, addr, di, doq
120
);
121
 
122
//
123
// Default address and data buses width
124
//
125
parameter aw = 6;
126
parameter dw = 24;
127
 
128
`ifdef OR1200_BIST
129
//
130
// RAM BIST
131
//
132
input mbist_si_i;
133
input [`OR1200_MBIST_CTRL_WIDTH - 1:0] mbist_ctrl_i;
134
output mbist_so_o;
135
`endif
136
 
137
//
138
// 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
output  [dw-1:0] doq;    // output data bus
148
 
149
//
150
// Internal wires and registers
151
//
152
`ifdef OR1200_XILINX_RAMB4
153
wire    [7:0]            unconnected;
154
`else
155
`ifdef OR1200_XILINX_RAMB16
156
wire    [7:0]            unconnected;
157
`endif // !OR1200_XILINX_RAMB16
158
`endif // !OR1200_XILINX_RAMB4
159
 
160
`ifdef OR1200_ARTISAN_SSP
161
`else
162
`ifdef OR1200_VIRTUALSILICON_SSP
163
`else
164
`ifdef OR1200_BIST
165
assign mbist_so_o = mbist_si_i;
166
`endif
167
`endif
168
`endif
169
 
170
`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
`ifdef OR1200_BIST
181
art_hssp_64x24_bist artisan_ssp(
182
`else
183
art_hssp_64x24 artisan_ssp(
184
`endif
185
`endif
186
`ifdef OR1200_BIST
187
        // RAM BIST
188
        .mbist_si_i(mbist_si_i),
189
        .mbist_so_o(mbist_so_o),
190
        .mbist_ctrl_i(mbist_ctrl_i),
191
`endif
192
        .CLK(clk),
193
        .CEN(~ce),
194
        .WEN(~we),
195
        .A(addr),
196
        .D(di),
197
        .OEN(~oe),
198
        .Q(doq)
199
);
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
        .doq(doq)
220
);
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
        .q(doq)
239
);
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
`ifdef OR1200_BIST
254
vs_hdsp_64x24_bist vs_ssp(
255
`else
256
vs_hdsp_64x24 vs_ssp(
257
`endif
258
`endif
259
`ifdef OR1200_BIST
260
        // RAM BIST
261
        .mbist_si_i(mbist_si_i),
262
        .mbist_so_o(mbist_so_o),
263
        .mbist_ctrl_i(mbist_ctrl_i),
264
`endif
265
        .CK(clk),
266
        .ADR(addr),
267
        .DI(di),
268
        .WEN(~we),
269
        .CEN(~ce),
270
        .OEN(~oe),
271
        .DOUT(doq)
272
);
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
        .DO(doq[15:0])
295
);
296
 
297
//
298
// Block 1
299
//
300
RAMB4_S16 ramb4_s16_1(
301
        .CLK(clk),
302
        .RST(rst),
303
        .ADDR({2'b00, addr}),
304
        .DI({8'h00, di[23:16]}),
305
        .EN(ce),
306
        .WE(we),
307
        .DO({unconnected, doq[23:16]})
308
);
309
 
310
`else
311
 
312
`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
`ifdef OR1200_ALTERA_LPM
337
 
338
//
339
// 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
        .q(doq)
359
);
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
// 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
reg     [aw-1:0] addr_reg;               // RAM address register
380
 
381
//
382
// Data output drivers
383
//
384
assign doq = (oe) ? mem[addr_reg] : {dw{1'b0}};
385
 
386
//
387
// RAM address register
388
//
389
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
always @(posedge clk)
399
        if (ce && we)
400
                mem[addr] <= #1 di;
401
 
402
`endif  // !OR1200_ALTERA_LPM
403
`endif  // !OR1200_XILINX_RAMB16
404
`endif  // !OR1200_XILINX_RAMB4
405
`endif  // !OR1200_VIRTUALSILICON_SSP
406
`endif  // !OR1200_VIRAGE_SSP
407
`endif  // !OR1200_AVANT_ATP
408
`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.