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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [orpsocv2/] [rtl/] [verilog/] [or1200/] [or1200_spram_256x21.v] - Blame information for rev 803

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

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

powered by: WebSVN 2.1.0

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