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

Subversion Repositories or1k

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

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

powered by: WebSVN 2.1.0

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