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

Subversion Repositories or1k

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

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 597 lampret
// Revision 1.2  2002/01/15 06:12:22  lampret
65
// Fixed module name when compiling with OR1200_XILINX_RAM32X1D
66
//
67 573 lampret
// Revision 1.1  2002/01/03 08:16:15  lampret
68
// New prefixes for RTL files, prefixed module names. Updated cache controllers and MMUs.
69
//
70 504 lampret
// Revision 1.10  2001/11/05 14:48:00  lampret
71
// Added missing endif
72
//
73
// Revision 1.9  2001/11/02 18:57:14  lampret
74
// Modified virtual silicon instantiations.
75
//
76
// Revision 1.8  2001/10/22 19:39:56  lampret
77
// Fixed parameters in generic sprams.
78
//
79
// Revision 1.7  2001/10/21 17:57:16  lampret
80
// 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.
81
//
82
// Revision 1.6  2001/10/14 13:12:09  lampret
83
// MP3 version.
84
//
85
// Revision 1.1.1.1  2001/10/06 10:18:36  igorm
86
// no message
87
//
88
// Revision 1.1  2001/08/09 13:39:33  lampret
89
// Major clean-up.
90
//
91
// Revision 1.2  2001/07/30 05:38:02  lampret
92
// Adding empty directories required by HDL coding guidelines
93
//
94
//
95
 
96
// synopsys translate_off
97
`include "timescale.v"
98
// synopsys translate_on
99
`include "or1200_defines.v"
100
 
101
module or1200_dpram_32x32(
102
        // Generic synchronous double-port RAM interface
103
        clk_a, rst_a, ce_a, oe_a, addr_a, do_a,
104
        clk_b, rst_b, ce_b, we_b, addr_b, di_b
105
);
106
 
107
//
108
// Default address and data buses width
109
//
110
parameter aw = 5;
111
parameter dw = 32;
112
 
113
//
114
// Generic synchronous double-port RAM interface
115
//
116
input                   clk_a;  // Clock
117
input                   rst_a;  // Reset
118
input                   ce_a;   // Chip enable input
119
input                   oe_a;   // Output enable input
120
input   [aw-1:0] addr_a; // address bus inputs
121
output  [dw-1:0] do_a;   // output data bus
122
input                   clk_b;  // Clock
123
input                   rst_b;  // Reset
124
input                   ce_b;   // Chip enable input
125
input                   we_b;   // Write enable input
126
input   [aw-1:0] addr_b; // address bus inputs
127
input   [dw-1:0] di_b;   // input data bus
128
 
129
//
130
// Internal wires and registers
131
//
132
 
133
`ifdef OR1200_ARTISAN_SDP
134
 
135
//
136
// Instantiation of ASIC memory:
137
//
138
// Artisan Synchronous Double-Port RAM (ra2sh)
139
//
140
`ifdef UNUSED
141
art_hsdp_32x32 #(dw, 1<<aw, aw) artisan_sdp(
142
`else
143
art_hsdp_32x32 artisan_sdp(
144
`endif
145
        .qa(do_a),
146
        .clka(clk_a),
147
        .cena(~ce_a),
148
        .wena(1'b1),
149
        .aa(addr_a),
150
        .da(32'h00000000),
151
        .oena(~oe_a),
152
        .qb(),
153
        .clkb(clk_b),
154
        .cenb(~ce_b),
155
        .wenb(~we_b),
156
        .ab(addr_b),
157
        .db(di_b),
158
        .oenb(1'b1)
159
);
160
 
161
`else
162
 
163
`ifdef OR1200_AVANT_ATP
164
 
165
//
166
// Instantiation of ASIC memory:
167
//
168
// Avant! Asynchronous Two-Port RAM
169
//
170
avant_atp avant_atp(
171
        .web(~we),
172
        .reb(),
173
        .oeb(~oe),
174
        .rcsb(),
175
        .wcsb(),
176
        .ra(addr),
177
        .wa(addr),
178
        .di(di),
179
        .do(do)
180
);
181
 
182
`else
183
 
184
`ifdef OR1200_VIRAGE_STP
185
 
186
//
187
// Instantiation of ASIC memory:
188
//
189
// Virage Synchronous 2-port R/W RAM
190
//
191
virage_stp virage_stp(
192
        .QA(do_a),
193
        .QB(),
194
 
195
        .ADRA(addr_a),
196
        .DA(32'h00000000),
197
        .WEA(1'b0),
198
        .OEA(oe_a),
199
        .MEA(ce_a),
200
        .CLKA(clk_a),
201
 
202
        .ADRB(addr_b),
203
        .DB(di_b),
204
        .WEB(we_b),
205
        .OEB(1'b1),
206
        .MEB(ce_b),
207
        .CLKB(clk_b)
208
);
209
 
210
`else
211
 
212
`ifdef OR1200_VIRTUALSILICON_STP
213
 
214
//
215
// Instantiation of ASIC memory:
216
//
217
// Virtual Silicon Two-port R/W SRAM
218
//
219
`ifdef UNUSED
220
vs_hdtp_32x32 #(1<<aw, aw-1, dw-1) vs_ssp(
221
`else
222
vs_hdtp_32x32 vs_ssp(
223
`endif
224
        .RCK(clk_a),
225
        .REN(~ce_a),
226
        .OEN(~oe_a),
227
        .RADR(addr_a),
228
        .DI(di_b),
229
        .WCK(clk_b),
230
        .WEN(~ce_b),
231
        .WADR(addr_b),
232
        .DOUT(do_a)
233
);
234
 
235
`else
236
 
237
`ifdef OR1200_XILINX_RAM32X1D
238
 
239
//
240
// Instantiation of FPGA memory:
241
//
242
// Virtex/Spartan2
243
//
244
 
245 597 lampret
reg     [4:0]    addr_a_r;
246
 
247
always @(posedge clk_a or posedge rst_a)
248
        if (ce_a)
249
                addr_a_r <= #1 addr_a;
250
 
251 504 lampret
//
252
// Block 0
253
//
254 573 lampret
or1200_xcv_ram32x8d xcv_ram32x8d_0 (
255 504 lampret
        .DPO(do_a[7:0]),
256
        .SPO(),
257
        .A(addr_b),
258
        .D(di_b[7:0]),
259 597 lampret
        .DPRA(addr_a_r),
260 504 lampret
        .WCLK(clk_b),
261
        .WE(we_b)
262
);
263
 
264
//
265
// Block 1
266
//
267 573 lampret
or1200_xcv_ram32x8d xcv_ram32x8d_1 (
268 504 lampret
        .DPO(do_a[15:8]),
269
        .SPO(),
270
        .A(addr_b),
271
        .D(di_b[15:8]),
272 597 lampret
        .DPRA(addr_a_r),
273 504 lampret
        .WCLK(clk_b),
274
        .WE(we_b)
275
);
276
 
277
 
278
//
279
// Block 2
280
//
281 573 lampret
or1200_xcv_ram32x8d xcv_ram32x8d_2 (
282 504 lampret
        .DPO(do_a[23:16]),
283
        .SPO(),
284
        .A(addr_b),
285
        .D(di_b[23:16]),
286 597 lampret
        .DPRA(addr_a_r),
287 504 lampret
        .WCLK(clk_b),
288
        .WE(we_b)
289
);
290
 
291
//
292
// Block 3
293
//
294 573 lampret
or1200_xcv_ram32x8d xcv_ram32x8d_3 (
295 504 lampret
        .DPO(do_a[31:24]),
296
        .SPO(),
297
        .A(addr_b),
298
        .D(di_b[31:24]),
299 597 lampret
        .DPRA(addr_a_r),
300 504 lampret
        .WCLK(clk_b),
301
        .WE(we_b)
302
);
303
 
304
`else
305
 
306
`ifdef OR1200_XILINX_RAMB4
307
 
308
//
309
// Instantiation of FPGA memory:
310
//
311
// Virtex/Spartan2
312
//
313
 
314
//
315
// Block 0
316
//
317
RAMB4_S16_S16 ramb4_s16_0(
318
        .CLKA(clk_a),
319
        .RSTA(rst_a),
320
        .ADDRA({3'b000, addr_a}),
321
        .DIA(16'h0000),
322
        .ENA(ce_a),
323
        .WEA(1'b0),
324
        .DOA(do_a[15:0]),
325
 
326
        .CLKB(clk_b),
327
        .RSTB(rst_b),
328
        .ADDRB({3'b000, addr_b}),
329
        .DIB(di_b[15:0]),
330
        .ENB(ce_b),
331
        .WEB(we_b),
332
        .DOB()
333
);
334
 
335
//
336
// Block 1
337
//
338
RAMB4_S16_S16 ramb4_s16_1(
339
        .CLKA(clk_a),
340
        .RSTA(rst_a),
341
        .ADDRA({3'b000, addr_a}),
342
        .DIA(16'h0000),
343
        .ENA(ce_a),
344
        .WEA(1'b0),
345
        .DOA(do_a[31:16]),
346
 
347
        .CLKB(clk_b),
348
        .RSTB(rst_b),
349
        .ADDRB({3'b000, addr_b}),
350
        .DIB(di_b[31:16]),
351
        .ENB(ce_b),
352
        .WEB(we_b),
353
        .DOB()
354
);
355
 
356
`else
357
 
358
//
359
// Generic double-port synchronous RAM model
360
//
361
 
362
//
363
// Generic RAM's registers and wires
364
//
365
reg     [dw-1:0] mem [(1<<aw)-1:0];       // RAM content
366
reg     [dw-1:0] do_reg;                 // RAM data output register
367
 
368
//
369
// Data output drivers
370
//
371
assign do_a = (oe_a) ? do_reg : {dw{1'bz}};
372
 
373
//
374
// RAM read
375
//
376
always @(posedge clk_a)
377
        if (ce_a)
378
                do_reg <= #1 mem[addr_a];
379
 
380
//
381
// RAM write
382
//
383
always @(posedge clk_b)
384
        if (ce_b && we_b)
385
                mem[addr_b] <= #1 di_b;
386
 
387
`endif  // !OR1200_XILINX_RAMB4_S16_S16
388
`endif  // !OR1200_XILINX_RAM32X1D
389
`endif  // !OR1200_VIRTUALSILICON_SSP
390
`endif  // !OR1200_VIRAGE_STP
391
`endif  // !OR1200_AVANT_ATP
392
`endif  // !OR1200_ARTISAN_SDP
393
 
394
endmodule

powered by: WebSVN 2.1.0

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