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

Subversion Repositories openrisc_me

[/] [openrisc/] [trunk/] [or1200/] [rtl/] [verilog/] [or1200_tpram_32x32.v] - Blame information for rev 23

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

Line No. Rev Author Line
1 10 unneback
//////////////////////////////////////////////////////////////////////
2
////                                                              ////
3
////  Generic Two-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 two-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
////  two-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 RAMB16                                      ////
25
////  - Xilinx Virtex RAMB4                                       ////
26
////  - Altera LPM                                                ////
27
////                                                              ////
28
////  To Do:                                                      ////
29
////   - fix Avant!                                               ////
30
////   - xilinx rams need external tri-state logic                ////
31
////   - add additional RAMs (VS etc)                             ////
32
////                                                              ////
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
// Revision 1.4  2004/06/08 18:15:48  lampret
67
// Changed behavior of the simulation generic models
68
//
69
// Revision 1.3  2004/04/05 08:29:57  lampret
70
// Merged branch_qmem into main tree.
71
//
72
// Revision 1.2.4.1  2003/07/08 15:36:37  lampret
73
// Added embedded memory QMEM.
74
//
75
// Revision 1.2  2003/04/07 01:19:07  lampret
76
// Added Altera LPM RAMs. Changed generic RAM output when OE inactive.
77
//
78
// Revision 1.1  2002/01/03 08:16:15  lampret
79
// New prefixes for RTL files, prefixed module names. Updated cache controllers and MMUs.
80
//
81
// Revision 1.7  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.6  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_tpram_32x32(
104
        // Generic synchronous two-port RAM interface
105
        clk_a, rst_a, ce_a, we_a, oe_a, addr_a, di_a, do_a,
106
        clk_b, rst_b, ce_b, we_b, oe_b, addr_b, di_b, do_b
107
);
108
 
109
//
110
// Default address and data buses width
111
//
112
parameter aw = 5;
113
parameter dw = 32;
114
 
115
//
116
// Generic synchronous two-port RAM interface
117
//
118
input                   clk_a;  // Clock
119
input                   rst_a;  // Reset
120
input                   ce_a;   // Chip enable input
121
input                   we_a;   // Write enable input
122
input                   oe_a;   // Output enable input
123
input   [aw-1:0] addr_a; // address bus inputs
124
input   [dw-1:0] di_a;   // input data bus
125
output  [dw-1:0] do_a;   // output data bus
126
input                   clk_b;  // Clock
127
input                   rst_b;  // Reset
128
input                   ce_b;   // Chip enable input
129
input                   we_b;   // Write enable input
130
input                   oe_b;   // Output enable input
131
input   [aw-1:0] addr_b; // address bus inputs
132
input   [dw-1:0] di_b;   // input data bus
133
output  [dw-1:0] do_b;   // output data bus
134
 
135
//
136
// Internal wires and registers
137
//
138
 
139
 
140
`ifdef OR1200_ARTISAN_SDP
141
 
142
//
143
// Instantiation of ASIC memory:
144
//
145
// Artisan Synchronous Double-Port RAM (ra2sh)
146
//
147
`ifdef UNUSED
148
art_hsdp_32x32 #(dw, 1<<aw, aw) artisan_sdp(
149
`else
150
art_hsdp_32x32 artisan_sdp(
151
`endif
152
        .qa(do_a),
153
        .clka(clk_a),
154
        .cena(~ce_a),
155
        .wena(~we_a),
156
        .aa(addr_a),
157
        .da(di_a),
158
        .oena(~oe_a),
159
        .qb(do_b),
160
        .clkb(clk_b),
161
        .cenb(~ce_b),
162
        .wenb(~we_b),
163
        .ab(addr_b),
164
        .db(di_b),
165
        .oenb(~oe_b)
166
);
167
 
168
`else
169
 
170
`ifdef OR1200_AVANT_ATP
171
 
172
//
173
// Instantiation of ASIC memory:
174
//
175
// Avant! Asynchronous Two-Port RAM
176
//
177
avant_atp avant_atp(
178
        .web(~we),
179
        .reb(),
180
        .oeb(~oe),
181
        .rcsb(),
182
        .wcsb(),
183
        .ra(addr),
184
        .wa(addr),
185
        .di(di),
186
        .doq(doq)
187
);
188
 
189
`else
190
 
191
`ifdef OR1200_VIRAGE_STP
192
 
193
//
194
// Instantiation of ASIC memory:
195
//
196
// Virage Synchronous 2-port R/W RAM
197
//
198
virage_stp virage_stp(
199
        .QA(do_a),
200
        .QB(do_b),
201
 
202
        .ADRA(addr_a),
203
        .DA(di_a),
204
        .WEA(we_a),
205
        .OEA(oe_a),
206
        .MEA(ce_a),
207
        .CLKA(clk_a),
208
 
209
        .ADRB(adr_b),
210
        .DB(di_b),
211
        .WEB(we_b),
212
        .OEB(oe_b),
213
        .MEB(ce_b),
214
        .CLKB(clk_b)
215
);
216
 
217
`else
218
 
219
`ifdef OR1200_XILINX_RAMB4
220
 
221
//
222
// Instantiation of FPGA memory:
223
//
224
// Virtex/Spartan2
225
//
226
 
227
//
228
// Block 0
229
//
230
RAMB4_S16_S16 ramb4_s16_s16_0(
231
        .CLKA(clk_a),
232
        .RSTA(rst_a),
233
        .ADDRA(addr_a),
234
        .DIA(di_a[15:0]),
235
        .ENA(ce_a),
236
        .WEA(we_a),
237
        .DOA(do_a[15:0]),
238
 
239
        .CLKB(clk_b),
240
        .RSTB(rst_b),
241
        .ADDRB(addr_b),
242
        .DIB(di_b[15:0]),
243
        .ENB(ce_b),
244
        .WEB(we_b),
245
        .DOB(do_b[15:0])
246
);
247
 
248
//
249
// Block 1
250
//
251
RAMB4_S16_S16 ramb4_s16_s16_1(
252
        .CLKA(clk_a),
253
        .RSTA(rst_a),
254
        .ADDRA(addr_a),
255
        .DIA(di_a[31:16]),
256
        .ENA(ce_a),
257
        .WEA(we_a),
258
        .DOA(do_a[31:16]),
259
 
260
        .CLKB(clk_b),
261
        .RSTB(rst_b),
262
        .ADDRB(addr_b),
263
        .DIB(di_b[31:16]),
264
        .ENB(ce_b),
265
        .WEB(we_b),
266
        .DOB(do_b[31:16])
267
);
268
 
269
`else
270
 
271
`ifdef OR1200_XILINX_RAMB16
272
 
273
//
274
// Instantiation of FPGA memory:
275
//
276
// Virtex4/Spartan3E
277
//
278
// Added By Nir Mor
279
//
280
 
281
RAMB16_S36_S36 ramb16_s36_s36(
282
        .CLKA(clk_a),
283
        .SSRA(rst_a),
284
        .ADDRA({4'b0000,addr_a}),
285
        .DIA(di_a),
286
        .DIPA(4'h0),
287
        .ENA(ce_a),
288
        .WEA(we_a),
289
        .DOA(do_a),
290
        .DOPA(),
291
 
292
        .CLKB(clk_b),
293
        .SSRB(rst_b),
294
        .ADDRB({4'b0000,addr_b}),
295
        .DIB(di_b),
296
        .DIPB(4'h0),
297
        .ENB(ce_b),
298
        .WEB(we_b),
299
        .DOB(do_b),
300
        .DOPB()
301
);
302
 
303
`else
304
 
305
`ifdef OR1200_ALTERA_LPM_XXX
306
 
307
//
308
// Instantiation of FPGA memory:
309
//
310
// Altera LPM
311
//
312
// Added By Jamil Khatib
313
//
314
altqpram altqpram_component (
315
        .wraddress_a (addr_a),
316
        .inclocken_a (ce_a),
317
        .wraddress_b (addr_b),
318
        .wren_a (we_a),
319
        .inclocken_b (ce_b),
320
        .wren_b (we_b),
321
        .inaclr_a (rst_a),
322
        .inaclr_b (rst_b),
323
        .inclock_a (clk_a),
324
        .inclock_b (clk_b),
325
        .data_a (di_a),
326
        .data_b (di_b),
327
        .q_a (do_a),
328
        .q_b (do_b)
329
);
330
 
331
defparam altqpram_component.operation_mode = "BIDIR_DUAL_PORT",
332
        altqpram_component.width_write_a = dw,
333
        altqpram_component.widthad_write_a = aw,
334
        altqpram_component.numwords_write_a = dw,
335
        altqpram_component.width_read_a = dw,
336
        altqpram_component.widthad_read_a = aw,
337
        altqpram_component.numwords_read_a = dw,
338
        altqpram_component.width_write_b = dw,
339
        altqpram_component.widthad_write_b = aw,
340
        altqpram_component.numwords_write_b = dw,
341
        altqpram_component.width_read_b = dw,
342
        altqpram_component.widthad_read_b = aw,
343
        altqpram_component.numwords_read_b = dw,
344
        altqpram_component.indata_reg_a = "INCLOCK_A",
345
        altqpram_component.wrcontrol_wraddress_reg_a = "INCLOCK_A",
346
        altqpram_component.outdata_reg_a = "INCLOCK_A",
347
        altqpram_component.indata_reg_b = "INCLOCK_B",
348
        altqpram_component.wrcontrol_wraddress_reg_b = "INCLOCK_B",
349
        altqpram_component.outdata_reg_b = "INCLOCK_B",
350
        altqpram_component.indata_aclr_a = "INACLR_A",
351
        altqpram_component.wraddress_aclr_a = "INACLR_A",
352
        altqpram_component.wrcontrol_aclr_a = "INACLR_A",
353
        altqpram_component.outdata_aclr_a = "INACLR_A",
354
        altqpram_component.indata_aclr_b = "NONE",
355
        altqpram_component.wraddress_aclr_b = "NONE",
356
        altqpram_component.wrcontrol_aclr_b = "NONE",
357
        altqpram_component.outdata_aclr_b = "INACLR_B",
358
        altqpram_component.lpm_hint = "USE_ESB=ON";
359
        //examplar attribute altqpram_component NOOPT TRUE
360
 
361
`else
362
 
363
//
364
// Generic two-port synchronous RAM model
365
//
366
 
367
//
368
// Generic RAM's registers and wires
369
//
370
reg     [dw-1:0] mem [(1<<aw)-1:0];       // RAM content
371
reg     [aw-1:0] addr_a_reg;             // RAM read address register
372
reg     [aw-1:0] addr_b_reg;             // RAM read address register
373
 
374
//
375
// Data output drivers
376
//
377
assign do_a = (oe_a) ? mem[addr_a_reg] : {dw{1'b0}};
378
assign do_b = (oe_b) ? mem[addr_b_reg] : {dw{1'b0}};
379
 
380
//
381
// RAM write
382
//
383
always @(posedge clk_a)
384
        if (ce_a && we_a)
385
                mem[addr_a] <= #1 di_a;
386
 
387
//
388
// RAM write
389
//
390
always @(posedge clk_b)
391
        if (ce_b && we_b)
392
                mem[addr_b] <= #1 di_b;
393
 
394
//
395
// RAM read address register
396
//
397
always @(posedge clk_a or posedge rst_a)
398
        if (rst_a)
399
                addr_a_reg <= #1 {aw{1'b0}};
400
        else if (ce_a)
401
                addr_a_reg <= #1 addr_a;
402
 
403
//
404
// RAM read address register
405
//
406
always @(posedge clk_b or posedge rst_b)
407
        if (rst_b)
408
                addr_b_reg <= #1 {aw{1'b0}};
409
        else if (ce_b)
410
                addr_b_reg <= #1 addr_b;
411
 
412
`endif  // !OR1200_ALTERA_LPM
413
`endif  // !OR1200_XILINX_RAMB16
414
`endif  // !OR1200_XILINX_RAMB4
415
`endif  // !OR1200_VIRAGE_STP
416
`endif  // !OR1200_AVANT_ATP
417
`endif  // !OR1200_ARTISAN_SDP
418
 
419
endmodule

powered by: WebSVN 2.1.0

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