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

Subversion Repositories or1k

[/] [or1k/] [tags/] [rel_13/] [or1200/] [rtl/] [verilog/] [or1200_spram_512x20.v] - Blame information for rev 1772

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
////  - Xilinx Virtex RAMB4_S16                                   ////
26 1129 lampret
////  - Altera LPM                                                ////
27 504 lampret
////                                                              ////
28
////  To Do:                                                      ////
29
////   - xilinx rams need external tri-state logic                ////
30
////   - fix avant! two-port ram                                  ////
31 1129 lampret
////   - add additional RAMs                                      ////
32 504 lampret
////                                                              ////
33
////  Author(s):                                                  ////
34
////      - Damjan Lampret, lampret@opencores.org                 ////
35
////                                                              ////
36
//////////////////////////////////////////////////////////////////////
37
////                                                              ////
38
//// Copyright (C) 2000 Authors and OPENCORES.ORG                 ////
39
////                                                              ////
40
//// This source file may be used and distributed without         ////
41
//// restriction provided that this copyright statement is not    ////
42
//// removed from the file and that any derivative work contains  ////
43
//// the original copyright notice and the associated disclaimer. ////
44
////                                                              ////
45
//// This source file is free software; you can redistribute it   ////
46
//// and/or modify it under the terms of the GNU Lesser General   ////
47
//// Public License as published by the Free Software Foundation; ////
48
//// either version 2.1 of the License, or (at your option) any   ////
49
//// later version.                                               ////
50
////                                                              ////
51
//// This source is distributed in the hope that it will be       ////
52
//// useful, but WITHOUT ANY WARRANTY; without even the implied   ////
53
//// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR      ////
54
//// PURPOSE.  See the GNU Lesser General Public License for more ////
55
//// details.                                                     ////
56
////                                                              ////
57
//// You should have received a copy of the GNU Lesser General    ////
58
//// Public License along with this source; if not, download it   ////
59
//// from http://www.opencores.org/lgpl.shtml                     ////
60
////                                                              ////
61
//////////////////////////////////////////////////////////////////////
62
//
63
// CVS Revision History
64
//
65
// $Log: not supported by cvs2svn $
66 1184 simons
// Revision 1.4  2003/08/11 13:32:19  simons
67
// BIST interface added for Artisan memory instances.
68
//
69 1179 simons
// Revision 1.3  2003/04/07 01:19:07  lampret
70
// Added Altera LPM RAMs. Changed generic RAM output when OE inactive.
71
//
72 1129 lampret
// Revision 1.2  2002/10/17 20:04:40  lampret
73
// Added BIST scan. Special VS RAMs need to be used to implement BIST.
74
//
75 1063 lampret
// Revision 1.1  2002/01/03 08:16:15  lampret
76
// New prefixes for RTL files, prefixed module names. Updated cache controllers and MMUs.
77
//
78 504 lampret
// Revision 1.10  2001/11/27 21:24:04  lampret
79
// Changed instantiation name of VS RAMs.
80
//
81
// Revision 1.9  2001/11/27 19:45:04  lampret
82
// Fixed VS RAM instantiation - again.
83
//
84
// Revision 1.8  2001/11/23 21:42:31  simons
85
// Program counter divided to PPC and NPC.
86
//
87
// Revision 1.6  2001/10/21 17:57:16  lampret
88
// 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.
89
//
90
// Revision 1.5  2001/10/14 13:12:09  lampret
91
// MP3 version.
92
//
93
// Revision 1.1.1.1  2001/10/06 10:18:36  igorm
94
// no message
95
//
96
// Revision 1.1  2001/08/09 13:39:33  lampret
97
// Major clean-up.
98
//
99
// Revision 1.2  2001/07/30 05:38:02  lampret
100
// Adding empty directories required by HDL coding guidelines
101
//
102
//
103
 
104
// synopsys translate_off
105
`include "timescale.v"
106
// synopsys translate_on
107
`include "or1200_defines.v"
108
 
109
module or1200_spram_512x20(
110 1063 lampret
`ifdef OR1200_BIST
111
        // RAM BIST
112
        scanb_rst, scanb_si, scanb_so, scanb_en, scanb_clk,
113
`endif
114 504 lampret
        // Generic synchronous single-port RAM interface
115
        clk, rst, ce, we, oe, addr, di, do
116
);
117
 
118
//
119
// Default address and data buses width
120
//
121
parameter aw = 9;
122
parameter dw = 20;
123
 
124 1063 lampret
`ifdef OR1200_BIST
125 504 lampret
//
126 1063 lampret
// RAM BIST
127
//
128
input                   scanb_rst,
129
                        scanb_si,
130
                        scanb_en,
131
                        scanb_clk;
132
output                  scanb_so;
133
`endif
134
 
135
//
136 504 lampret
// Generic synchronous single-port RAM interface
137
//
138
input                   clk;    // Clock
139
input                   rst;    // Reset
140
input                   ce;     // Chip enable input
141
input                   we;     // Write enable input
142
input                   oe;     // Output enable input
143
input   [aw-1:0] addr;   // address bus inputs
144
input   [dw-1:0] di;     // input data bus
145
output  [dw-1:0] do;     // output data bus
146
 
147
//
148
// Internal wires and registers
149
//
150
wire    [3:0]            unconnected;
151
 
152 1184 simons
`ifdef OR1200_ARTISAN_SSP
153
`else
154
`ifdef OR1200_VIRTUALSILICON_SSP
155
`else
156 1063 lampret
`ifdef OR1200_BIST
157
assign scanb_so = scanb_si;
158
`endif
159 1184 simons
`endif
160
`endif
161 1063 lampret
 
162 1184 simons
 
163 504 lampret
`ifdef OR1200_ARTISAN_SSP
164
 
165
//
166
// Instantiation of ASIC memory:
167
//
168
// Artisan Synchronous Single-Port RAM (ra1sh)
169
//
170
`ifdef UNUSED
171
art_hssp_512x20 #(dw, 1<<aw, aw) artisan_ssp(
172
`else
173 1179 simons
`ifdef OR1200_BIST
174
art_hssp_512x20_bist artisan_ssp(
175
`else
176 504 lampret
art_hssp_512x20 artisan_ssp(
177
`endif
178 1179 simons
`endif
179
`ifdef OR1200_BIST
180
        // RAM BIST
181
        .scanb_rst(scanb_rst),
182
        .scanb_si(scanb_si),
183
        .scanb_so(scanb_so),
184
        .scanb_en(scanb_en),
185
        .scanb_clk(scanb_clk),
186
`endif
187
        .CLK(clk),
188
        .CEN(~ce),
189
        .WEN(~we),
190
        .A(addr),
191
        .D(di),
192
        .OEN(~oe),
193
        .Q(do)
194 504 lampret
);
195
 
196
`else
197
 
198
`ifdef OR1200_AVANT_ATP
199
 
200
//
201
// Instantiation of ASIC memory:
202
//
203
// Avant! Asynchronous Two-Port RAM
204
//
205
avant_atp avant_atp(
206
        .web(~we),
207
        .reb(),
208
        .oeb(~oe),
209
        .rcsb(),
210
        .wcsb(),
211
        .ra(addr),
212
        .wa(addr),
213
        .di(di),
214
        .do(do)
215
);
216
 
217
`else
218
 
219
`ifdef OR1200_VIRAGE_SSP
220
 
221
//
222
// Instantiation of ASIC memory:
223
//
224
// Virage Synchronous 1-port R/W RAM
225
//
226
virage_ssp virage_ssp(
227
        .clk(clk),
228
        .adr(addr),
229
        .d(di),
230
        .we(we),
231
        .oe(oe),
232
        .me(ce),
233
        .q(do)
234
);
235
 
236
`else
237
 
238
`ifdef OR1200_VIRTUALSILICON_SSP
239
 
240
//
241
// Instantiation of ASIC memory:
242
//
243
// Virtual Silicon Single-Port Synchronous SRAM
244
//
245
`ifdef UNUSED
246
vs_hdsp_512x20 #(1<<aw, aw-1, dw-1) vs_ssp(
247
`else
248 1063 lampret
`ifdef OR1200_BIST
249
vs_hdsp_512x20_bist vs_ssp(
250
`else
251 504 lampret
vs_hdsp_512x20 vs_ssp(
252
`endif
253 1063 lampret
`endif
254
`ifdef OR1200_BIST
255
        // RAM BIST
256
        .scanb_rst(scanb_rst),
257
        .scanb_si(scanb_si),
258
        .scanb_so(scanb_so),
259
        .scanb_en(scanb_en),
260
        .scanb_clk(scanb_clk),
261
`endif
262 504 lampret
        .CK(clk),
263
        .ADR(addr),
264
        .DI(di),
265
        .WEN(~we),
266
        .CEN(~ce),
267
        .OEN(~oe),
268
        .DOUT(do)
269
);
270
 
271
`else
272
 
273
`ifdef OR1200_XILINX_RAMB4
274
 
275
//
276
// Instantiation of FPGA memory:
277
//
278
// Virtex/Spartan2
279
//
280
 
281
//
282
// Block 0
283
//
284
RAMB4_S8 ramb4_s8_0(
285
        .CLK(clk),
286
        .RST(rst),
287
        .ADDR(addr),
288
        .DI(di[7:0]),
289
        .EN(ce),
290
        .WE(we),
291
        .DO(do[7:0])
292
);
293
 
294
//
295
// Block 1
296
//
297
RAMB4_S8 ramb4_s8_1(
298
        .CLK(clk),
299
        .RST(rst),
300
        .ADDR(addr),
301
        .DI(di[15:8]),
302
        .EN(ce),
303
        .WE(we),
304
        .DO(do[15:8])
305
);
306
 
307
//
308
// Block 2
309
//
310
RAMB4_S8 ramb4_s8_2(
311
        .CLK(clk),
312
        .RST(rst),
313
        .ADDR(addr),
314
        .DI({4'b0000, di[19:16]}),
315
        .EN(ce),
316
        .WE(we),
317
        .DO({unconnected, do[19:16]})
318
);
319
 
320
`else
321
 
322 1129 lampret
`ifdef OR1200_ALTERA_LPM
323
 
324 504 lampret
//
325 1129 lampret
// Instantiation of FPGA memory:
326
//
327
// Altera LPM
328
//
329
// Added By Jamil Khatib
330
//
331
 
332
wire    wr;
333
 
334
assign  wr = ce & we;
335
 
336
initial $display("Using Altera LPM.");
337
 
338
lpm_ram_dq lpm_ram_dq_component (
339
        .address(addr),
340
        .inclock(clk),
341
        .outclock(clk),
342
        .data(di),
343
        .we(wr),
344
        .q(do)
345
);
346
 
347
defparam lpm_ram_dq_component.lpm_width = dw,
348
        lpm_ram_dq_component.lpm_widthad = aw,
349
        lpm_ram_dq_component.lpm_indata = "REGISTERED",
350
        lpm_ram_dq_component.lpm_address_control = "REGISTERED",
351
        lpm_ram_dq_component.lpm_outdata = "UNREGISTERED",
352
        lpm_ram_dq_component.lpm_hint = "USE_EAB=ON";
353
        // examplar attribute lpm_ram_dq_component NOOPT TRUE
354
 
355
`else
356
 
357
//
358 504 lampret
// Generic single-port synchronous RAM model
359
//
360
 
361
//
362
// Generic RAM's registers and wires
363
//
364
reg     [dw-1:0] mem [(1<<aw)-1:0];       // RAM content
365
reg     [dw-1:0] do_reg;                 // RAM data output register
366
 
367
//
368
// Data output drivers
369
//
370 1129 lampret
assign do = (oe) ? do_reg : {dw{1'b0}};
371 504 lampret
 
372
//
373
// RAM read and write
374
//
375
always @(posedge clk)
376
        if (ce && !we)
377
                do_reg <= #1 mem[addr];
378
        else if (ce && we)
379
                mem[addr] <= #1 di;
380
 
381 1129 lampret
`endif  // !OR1200_ALTERA_LPM
382 504 lampret
`endif  // !OR1200_XILINX_RAMB4_S16
383
`endif  // !OR1200_VIRTUALSILICON_SSP
384
`endif  // !OR1200_VIRAGE_SSP
385
`endif  // !OR1200_AVANT_ATP
386
`endif  // !OR1200_ARTISAN_SSP
387
 
388
endmodule

powered by: WebSVN 2.1.0

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