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

Subversion Repositories or1k

[/] [or1k/] [tags/] [rel_21/] [or1200/] [rtl/] [verilog/] [or1200_dpram_32x32.v] - Blame information for rev 778

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

Line No. Rev Author Line
1 504 lampret
//////////////////////////////////////////////////////////////////////
2
////                                                              ////
3
////  Generic Double-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 double-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
////  double-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 Double-Port Sync RAM                              ////
20
////  - Avant! Two-Port Sync RAM (*)                              ////
21
////  - Virage 2-port Sync RAM                                    ////
22
////                                                              ////
23
////  Supported FPGA RAMs are:                                    ////
24
////  - Xilinx Virtex RAMB4_S16_S16                               ////
25
////                                                              ////
26
////  To Do:                                                      ////
27
////   - fix Avant!                                               ////
28
////   - xilinx rams need external tri-state logic                ////
29
////   - add additional RAMs (Altera, VS etc)                     ////
30
////                                                              ////
31
////  Author(s):                                                  ////
32
////      - Damjan Lampret, lampret@opencores.org                 ////
33
////                                                              ////
34
//////////////////////////////////////////////////////////////////////
35
////                                                              ////
36
//// Copyright (C) 2000 Authors and OPENCORES.ORG                 ////
37
////                                                              ////
38
//// This source file may be used and distributed without         ////
39
//// restriction provided that this copyright statement is not    ////
40
//// removed from the file and that any derivative work contains  ////
41
//// the original copyright notice and the associated disclaimer. ////
42
////                                                              ////
43
//// This source file is free software; you can redistribute it   ////
44
//// and/or modify it under the terms of the GNU Lesser General   ////
45
//// Public License as published by the Free Software Foundation; ////
46
//// either version 2.1 of the License, or (at your option) any   ////
47
//// later version.                                               ////
48
////                                                              ////
49
//// This source is distributed in the hope that it will be       ////
50
//// useful, but WITHOUT ANY WARRANTY; without even the implied   ////
51
//// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR      ////
52
//// PURPOSE.  See the GNU Lesser General Public License for more ////
53
//// details.                                                     ////
54
////                                                              ////
55
//// You should have received a copy of the GNU Lesser General    ////
56
//// Public License along with this source; if not, download it   ////
57
//// from http://www.opencores.org/lgpl.shtml                     ////
58
////                                                              ////
59
//////////////////////////////////////////////////////////////////////
60
//
61
// CVS Revision History
62
//
63
// $Log: not supported by cvs2svn $
64 778 lampret
// Revision 1.5  2002/02/01 19:56:54  lampret
65
// Fixed combinational loops.
66
//
67 636 lampret
// Revision 1.4  2002/01/23 07:52:36  lampret
68
// Changed default reset values for SR and ESR to match or1ksim's. Fixed flop model in or1200_dpram_32x32 when OR1200_XILINX_RAM32X1D is defined.
69
//
70 610 lampret
// Revision 1.3  2002/01/19 14:10:22  lampret
71
// Fixed OR1200_XILINX_RAM32X1D.
72
//
73 597 lampret
// Revision 1.2  2002/01/15 06:12:22  lampret
74
// Fixed module name when compiling with OR1200_XILINX_RAM32X1D
75
//
76 573 lampret
// Revision 1.1  2002/01/03 08:16:15  lampret
77
// New prefixes for RTL files, prefixed module names. Updated cache controllers and MMUs.
78
//
79 504 lampret
// Revision 1.10  2001/11/05 14:48:00  lampret
80
// Added missing endif
81
//
82
// Revision 1.9  2001/11/02 18:57:14  lampret
83
// Modified virtual silicon instantiations.
84
//
85
// Revision 1.8  2001/10/22 19:39:56  lampret
86
// Fixed parameters in generic sprams.
87
//
88
// Revision 1.7  2001/10/21 17:57:16  lampret
89
// 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.
90
//
91
// Revision 1.6  2001/10/14 13:12:09  lampret
92
// MP3 version.
93
//
94
// Revision 1.1.1.1  2001/10/06 10:18:36  igorm
95
// no message
96
//
97
// Revision 1.1  2001/08/09 13:39:33  lampret
98
// Major clean-up.
99
//
100
// Revision 1.2  2001/07/30 05:38:02  lampret
101
// Adding empty directories required by HDL coding guidelines
102
//
103
//
104
 
105
// synopsys translate_off
106
`include "timescale.v"
107
// synopsys translate_on
108
`include "or1200_defines.v"
109
 
110
module or1200_dpram_32x32(
111
        // Generic synchronous double-port RAM interface
112
        clk_a, rst_a, ce_a, oe_a, addr_a, do_a,
113
        clk_b, rst_b, ce_b, we_b, addr_b, di_b
114
);
115
 
116
//
117
// Default address and data buses width
118
//
119
parameter aw = 5;
120
parameter dw = 32;
121
 
122
//
123
// Generic synchronous double-port RAM interface
124
//
125
input                   clk_a;  // Clock
126
input                   rst_a;  // Reset
127
input                   ce_a;   // Chip enable input
128
input                   oe_a;   // Output enable input
129
input   [aw-1:0] addr_a; // address bus inputs
130
output  [dw-1:0] do_a;   // output data bus
131
input                   clk_b;  // Clock
132
input                   rst_b;  // Reset
133
input                   ce_b;   // Chip enable input
134
input                   we_b;   // Write enable input
135
input   [aw-1:0] addr_b; // address bus inputs
136
input   [dw-1:0] di_b;   // input data bus
137
 
138
//
139
// Internal wires and registers
140
//
141
 
142
`ifdef OR1200_ARTISAN_SDP
143
 
144
//
145
// Instantiation of ASIC memory:
146
//
147
// Artisan Synchronous Double-Port RAM (ra2sh)
148
//
149
`ifdef UNUSED
150
art_hsdp_32x32 #(dw, 1<<aw, aw) artisan_sdp(
151
`else
152
art_hsdp_32x32 artisan_sdp(
153
`endif
154
        .qa(do_a),
155
        .clka(clk_a),
156
        .cena(~ce_a),
157
        .wena(1'b1),
158
        .aa(addr_a),
159
        .da(32'h00000000),
160
        .oena(~oe_a),
161
        .qb(),
162
        .clkb(clk_b),
163
        .cenb(~ce_b),
164
        .wenb(~we_b),
165
        .ab(addr_b),
166
        .db(di_b),
167
        .oenb(1'b1)
168
);
169
 
170
`else
171
 
172
`ifdef OR1200_AVANT_ATP
173
 
174
//
175
// Instantiation of ASIC memory:
176
//
177
// Avant! Asynchronous Two-Port RAM
178
//
179
avant_atp avant_atp(
180
        .web(~we),
181
        .reb(),
182
        .oeb(~oe),
183
        .rcsb(),
184
        .wcsb(),
185
        .ra(addr),
186
        .wa(addr),
187
        .di(di),
188
        .do(do)
189
);
190
 
191
`else
192
 
193
`ifdef OR1200_VIRAGE_STP
194
 
195
//
196
// Instantiation of ASIC memory:
197
//
198
// Virage Synchronous 2-port R/W RAM
199
//
200
virage_stp virage_stp(
201
        .QA(do_a),
202
        .QB(),
203
 
204
        .ADRA(addr_a),
205
        .DA(32'h00000000),
206
        .WEA(1'b0),
207
        .OEA(oe_a),
208
        .MEA(ce_a),
209
        .CLKA(clk_a),
210
 
211
        .ADRB(addr_b),
212
        .DB(di_b),
213
        .WEB(we_b),
214
        .OEB(1'b1),
215
        .MEB(ce_b),
216
        .CLKB(clk_b)
217
);
218
 
219
`else
220
 
221 778 lampret
`ifdef OR1200_VIRTUALSILICON_STP_T1
222 504 lampret
 
223
//
224
// Instantiation of ASIC memory:
225
//
226 778 lampret
// Virtual Silicon Two-port R/W SRAM Type 1
227 504 lampret
//
228
`ifdef UNUSED
229 636 lampret
vs_hdtp_64x32 #(1<<aw, aw-1, dw-1) vs_ssp(
230 504 lampret
`else
231 636 lampret
vs_hdtp_64x32 vs_ssp(
232 504 lampret
`endif
233 636 lampret
        .P1CK(clk_a),
234
        .P1CEN(~ce_a),
235
        .P1WEN(1'b1),
236
        .P1OEN(~oe_a),
237
        .P1ADR({1'b0, addr_a}),
238
        .P1DI(32'h0000_0000),
239
        .P1DOUT(do_a),
240
 
241
        .P2CK(clk_b),
242
        .P2CEN(~ce_b),
243
        .P2WEN(~ce_b),
244
        .P2OEN(1'b1),
245
        .P2ADR({1'b0, addr_b}),
246
        .P2DI(di_b),
247
        .P2DOUT()
248 504 lampret
);
249
 
250
`else
251
 
252 778 lampret
`ifdef OR1200_VIRTUALSILICON_STP_T2
253
 
254
//
255
// Instantiation of ASIC memory:
256
//
257
// Virtual Silicon Two-port R/W SRAM Type 2
258
//
259
`ifdef UNUSED
260
vs_hdtp_32x32 #(1<<aw, aw-1, dw-1) vs_ssp(
261
`else
262
vs_hdtp_32x32 vs_ssp(
263
`endif
264
        .RCK(clk_a),
265
        .REN(~ce_a),
266
        .OEN(~oe_a),
267
        .RADR(addr_a),
268
        .DOUT(do_a),
269
 
270
        .WCK(clk_b),
271
        .WEN(~ce_b),
272
        .WADR(addr_b),
273
        .DI(di_b)
274
);
275
 
276
`else
277
 
278 504 lampret
`ifdef OR1200_XILINX_RAM32X1D
279
 
280
//
281
// Instantiation of FPGA memory:
282
//
283
// Virtex/Spartan2
284
//
285
 
286 597 lampret
reg     [4:0]    addr_a_r;
287
 
288
always @(posedge clk_a or posedge rst_a)
289 610 lampret
        if (rst_a)
290
                addr_a_r <= #1 5'b00000;
291
        else if (ce_a)
292 597 lampret
                addr_a_r <= #1 addr_a;
293
 
294 504 lampret
//
295
// Block 0
296
//
297 573 lampret
or1200_xcv_ram32x8d xcv_ram32x8d_0 (
298 504 lampret
        .DPO(do_a[7:0]),
299
        .SPO(),
300
        .A(addr_b),
301
        .D(di_b[7:0]),
302 597 lampret
        .DPRA(addr_a_r),
303 504 lampret
        .WCLK(clk_b),
304
        .WE(we_b)
305
);
306
 
307
//
308
// Block 1
309
//
310 573 lampret
or1200_xcv_ram32x8d xcv_ram32x8d_1 (
311 504 lampret
        .DPO(do_a[15:8]),
312
        .SPO(),
313
        .A(addr_b),
314
        .D(di_b[15:8]),
315 597 lampret
        .DPRA(addr_a_r),
316 504 lampret
        .WCLK(clk_b),
317
        .WE(we_b)
318
);
319
 
320
 
321
//
322
// Block 2
323
//
324 573 lampret
or1200_xcv_ram32x8d xcv_ram32x8d_2 (
325 504 lampret
        .DPO(do_a[23:16]),
326
        .SPO(),
327
        .A(addr_b),
328
        .D(di_b[23:16]),
329 597 lampret
        .DPRA(addr_a_r),
330 504 lampret
        .WCLK(clk_b),
331
        .WE(we_b)
332
);
333
 
334
//
335
// Block 3
336
//
337 573 lampret
or1200_xcv_ram32x8d xcv_ram32x8d_3 (
338 504 lampret
        .DPO(do_a[31:24]),
339
        .SPO(),
340
        .A(addr_b),
341
        .D(di_b[31:24]),
342 597 lampret
        .DPRA(addr_a_r),
343 504 lampret
        .WCLK(clk_b),
344
        .WE(we_b)
345
);
346
 
347
`else
348
 
349
`ifdef OR1200_XILINX_RAMB4
350
 
351
//
352
// Instantiation of FPGA memory:
353
//
354
// Virtex/Spartan2
355
//
356
 
357
//
358
// Block 0
359
//
360
RAMB4_S16_S16 ramb4_s16_0(
361
        .CLKA(clk_a),
362
        .RSTA(rst_a),
363
        .ADDRA({3'b000, addr_a}),
364
        .DIA(16'h0000),
365
        .ENA(ce_a),
366
        .WEA(1'b0),
367
        .DOA(do_a[15:0]),
368
 
369
        .CLKB(clk_b),
370
        .RSTB(rst_b),
371
        .ADDRB({3'b000, addr_b}),
372
        .DIB(di_b[15:0]),
373
        .ENB(ce_b),
374
        .WEB(we_b),
375
        .DOB()
376
);
377
 
378
//
379
// Block 1
380
//
381
RAMB4_S16_S16 ramb4_s16_1(
382
        .CLKA(clk_a),
383
        .RSTA(rst_a),
384
        .ADDRA({3'b000, addr_a}),
385
        .DIA(16'h0000),
386
        .ENA(ce_a),
387
        .WEA(1'b0),
388
        .DOA(do_a[31:16]),
389
 
390
        .CLKB(clk_b),
391
        .RSTB(rst_b),
392
        .ADDRB({3'b000, addr_b}),
393
        .DIB(di_b[31:16]),
394
        .ENB(ce_b),
395
        .WEB(we_b),
396
        .DOB()
397
);
398
 
399
`else
400
 
401
//
402
// Generic double-port synchronous RAM model
403
//
404
 
405
//
406
// Generic RAM's registers and wires
407
//
408
reg     [dw-1:0] mem [(1<<aw)-1:0];       // RAM content
409
reg     [dw-1:0] do_reg;                 // RAM data output register
410
 
411
//
412
// Data output drivers
413
//
414
assign do_a = (oe_a) ? do_reg : {dw{1'bz}};
415
 
416
//
417
// RAM read
418
//
419
always @(posedge clk_a)
420
        if (ce_a)
421
                do_reg <= #1 mem[addr_a];
422
 
423
//
424
// RAM write
425
//
426
always @(posedge clk_b)
427
        if (ce_b && we_b)
428
                mem[addr_b] <= #1 di_b;
429
 
430
`endif  // !OR1200_XILINX_RAMB4_S16_S16
431
`endif  // !OR1200_XILINX_RAM32X1D
432 778 lampret
`endif  // !OR1200_VIRTUALSILICON_SSP_T1
433
`endif  // !OR1200_VIRTUALSILICON_SSP_T2
434 504 lampret
`endif  // !OR1200_VIRAGE_STP
435
`endif  // !OR1200_AVANT_ATP
436
`endif  // !OR1200_ARTISAN_SDP
437
 
438
endmodule

powered by: WebSVN 2.1.0

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