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

Subversion Repositories or1k

[/] [or1k/] [branches/] [branch_qmem/] [or1200/] [rtl/] [verilog/] [or1200_spram_512x20.v] - Blame information for rev 1163

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 1129 lampret
// Revision 1.2  2002/10/17 20:04:40  lampret
67
// Added BIST scan. Special VS RAMs need to be used to implement BIST.
68
//
69 1063 lampret
// Revision 1.1  2002/01/03 08:16:15  lampret
70
// New prefixes for RTL files, prefixed module names. Updated cache controllers and MMUs.
71
//
72 504 lampret
// Revision 1.10  2001/11/27 21:24:04  lampret
73
// Changed instantiation name of VS RAMs.
74
//
75
// Revision 1.9  2001/11/27 19:45:04  lampret
76
// Fixed VS RAM instantiation - again.
77
//
78
// Revision 1.8  2001/11/23 21:42:31  simons
79
// Program counter divided to PPC and NPC.
80
//
81
// Revision 1.6  2001/10/21 17:57:16  lampret
82
// 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.
83
//
84
// Revision 1.5  2001/10/14 13:12:09  lampret
85
// MP3 version.
86
//
87
// Revision 1.1.1.1  2001/10/06 10:18:36  igorm
88
// no message
89
//
90
// Revision 1.1  2001/08/09 13:39:33  lampret
91
// Major clean-up.
92
//
93
// Revision 1.2  2001/07/30 05:38:02  lampret
94
// Adding empty directories required by HDL coding guidelines
95
//
96
//
97
 
98
// synopsys translate_off
99
`include "timescale.v"
100
// synopsys translate_on
101
`include "or1200_defines.v"
102
 
103
module or1200_spram_512x20(
104 1063 lampret
`ifdef OR1200_BIST
105
        // RAM BIST
106
        scanb_rst, scanb_si, scanb_so, scanb_en, scanb_clk,
107
`endif
108 504 lampret
        // Generic synchronous single-port RAM interface
109
        clk, rst, ce, we, oe, addr, di, do
110
);
111
 
112
//
113
// Default address and data buses width
114
//
115
parameter aw = 9;
116
parameter dw = 20;
117
 
118 1063 lampret
`ifdef OR1200_BIST
119 504 lampret
//
120 1063 lampret
// RAM BIST
121
//
122
input                   scanb_rst,
123
                        scanb_si,
124
                        scanb_en,
125
                        scanb_clk;
126
output                  scanb_so;
127
`endif
128
 
129
//
130 504 lampret
// Generic synchronous single-port RAM interface
131
//
132
input                   clk;    // Clock
133
input                   rst;    // Reset
134
input                   ce;     // Chip enable input
135
input                   we;     // Write enable input
136
input                   oe;     // Output enable input
137
input   [aw-1:0] addr;   // address bus inputs
138
input   [dw-1:0] di;     // input data bus
139
output  [dw-1:0] do;     // output data bus
140
 
141
//
142
// Internal wires and registers
143
//
144
wire    [3:0]            unconnected;
145
 
146 1063 lampret
`ifdef OR1200_VIRTUALSILICON_SSP
147
`else
148
`ifdef OR1200_BIST
149
assign scanb_so = scanb_si;
150
`endif
151
`endif
152
 
153 504 lampret
`ifdef OR1200_ARTISAN_SSP
154
 
155
//
156
// Instantiation of ASIC memory:
157
//
158
// Artisan Synchronous Single-Port RAM (ra1sh)
159
//
160
`ifdef UNUSED
161
art_hssp_512x20 #(dw, 1<<aw, aw) artisan_ssp(
162
`else
163
art_hssp_512x20 artisan_ssp(
164
`endif
165
        .clk(clk),
166
        .cen(~ce),
167
        .wen(~we),
168
        .a(addr),
169
        .d(di),
170
        .oen(~oe),
171
        .q(do)
172
);
173
 
174
`else
175
 
176
`ifdef OR1200_AVANT_ATP
177
 
178
//
179
// Instantiation of ASIC memory:
180
//
181
// Avant! Asynchronous Two-Port RAM
182
//
183
avant_atp avant_atp(
184
        .web(~we),
185
        .reb(),
186
        .oeb(~oe),
187
        .rcsb(),
188
        .wcsb(),
189
        .ra(addr),
190
        .wa(addr),
191
        .di(di),
192
        .do(do)
193
);
194
 
195
`else
196
 
197
`ifdef OR1200_VIRAGE_SSP
198
 
199
//
200
// Instantiation of ASIC memory:
201
//
202
// Virage Synchronous 1-port R/W RAM
203
//
204
virage_ssp virage_ssp(
205
        .clk(clk),
206
        .adr(addr),
207
        .d(di),
208
        .we(we),
209
        .oe(oe),
210
        .me(ce),
211
        .q(do)
212
);
213
 
214
`else
215
 
216
`ifdef OR1200_VIRTUALSILICON_SSP
217
 
218
//
219
// Instantiation of ASIC memory:
220
//
221
// Virtual Silicon Single-Port Synchronous SRAM
222
//
223
`ifdef UNUSED
224
vs_hdsp_512x20 #(1<<aw, aw-1, dw-1) vs_ssp(
225
`else
226 1063 lampret
`ifdef OR1200_BIST
227
vs_hdsp_512x20_bist vs_ssp(
228
`else
229 504 lampret
vs_hdsp_512x20 vs_ssp(
230
`endif
231 1063 lampret
`endif
232
`ifdef OR1200_BIST
233
        // RAM BIST
234
        .scanb_rst(scanb_rst),
235
        .scanb_si(scanb_si),
236
        .scanb_so(scanb_so),
237
        .scanb_en(scanb_en),
238
        .scanb_clk(scanb_clk),
239
`endif
240 504 lampret
        .CK(clk),
241
        .ADR(addr),
242
        .DI(di),
243
        .WEN(~we),
244
        .CEN(~ce),
245
        .OEN(~oe),
246
        .DOUT(do)
247
);
248
 
249
`else
250
 
251
`ifdef OR1200_XILINX_RAMB4
252
 
253
//
254
// Instantiation of FPGA memory:
255
//
256
// Virtex/Spartan2
257
//
258
 
259
//
260
// Block 0
261
//
262
RAMB4_S8 ramb4_s8_0(
263
        .CLK(clk),
264
        .RST(rst),
265
        .ADDR(addr),
266
        .DI(di[7:0]),
267
        .EN(ce),
268
        .WE(we),
269
        .DO(do[7:0])
270
);
271
 
272
//
273
// Block 1
274
//
275
RAMB4_S8 ramb4_s8_1(
276
        .CLK(clk),
277
        .RST(rst),
278
        .ADDR(addr),
279
        .DI(di[15:8]),
280
        .EN(ce),
281
        .WE(we),
282
        .DO(do[15:8])
283
);
284
 
285
//
286
// Block 2
287
//
288
RAMB4_S8 ramb4_s8_2(
289
        .CLK(clk),
290
        .RST(rst),
291
        .ADDR(addr),
292
        .DI({4'b0000, di[19:16]}),
293
        .EN(ce),
294
        .WE(we),
295
        .DO({unconnected, do[19:16]})
296
);
297
 
298
`else
299
 
300 1129 lampret
`ifdef OR1200_ALTERA_LPM
301
 
302 504 lampret
//
303 1129 lampret
// Instantiation of FPGA memory:
304
//
305
// Altera LPM
306
//
307
// Added By Jamil Khatib
308
//
309
 
310
wire    wr;
311
 
312
assign  wr = ce & we;
313
 
314
initial $display("Using Altera LPM.");
315
 
316
lpm_ram_dq lpm_ram_dq_component (
317
        .address(addr),
318
        .inclock(clk),
319
        .outclock(clk),
320
        .data(di),
321
        .we(wr),
322
        .q(do)
323
);
324
 
325
defparam lpm_ram_dq_component.lpm_width = dw,
326
        lpm_ram_dq_component.lpm_widthad = aw,
327
        lpm_ram_dq_component.lpm_indata = "REGISTERED",
328
        lpm_ram_dq_component.lpm_address_control = "REGISTERED",
329
        lpm_ram_dq_component.lpm_outdata = "UNREGISTERED",
330
        lpm_ram_dq_component.lpm_hint = "USE_EAB=ON";
331
        // examplar attribute lpm_ram_dq_component NOOPT TRUE
332
 
333
`else
334
 
335
//
336 504 lampret
// Generic single-port synchronous RAM model
337
//
338
 
339
//
340
// Generic RAM's registers and wires
341
//
342
reg     [dw-1:0] mem [(1<<aw)-1:0];       // RAM content
343
reg     [dw-1:0] do_reg;                 // RAM data output register
344
 
345
//
346
// Data output drivers
347
//
348 1129 lampret
assign do = (oe) ? do_reg : {dw{1'b0}};
349 504 lampret
 
350
//
351
// RAM read and write
352
//
353
always @(posedge clk)
354
        if (ce && !we)
355
                do_reg <= #1 mem[addr];
356
        else if (ce && we)
357
                mem[addr] <= #1 di;
358
 
359 1129 lampret
`endif  // !OR1200_ALTERA_LPM
360 504 lampret
`endif  // !OR1200_XILINX_RAMB4_S16
361
`endif  // !OR1200_VIRTUALSILICON_SSP
362
`endif  // !OR1200_VIRAGE_SSP
363
`endif  // !OR1200_AVANT_ATP
364
`endif  // !OR1200_ARTISAN_SSP
365
 
366
endmodule

powered by: WebSVN 2.1.0

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