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

Subversion Repositories or1k_soc_on_altera_embedded_dev_kit

[/] [or1k_soc_on_altera_embedded_dev_kit/] [trunk/] [soc/] [rtl/] [or1200/] [rtl/] [verilog/] [or1200_tpram_32x32.v] - Blame information for rev 12

Details | Compare with Previous | View Log

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

powered by: WebSVN 2.1.0

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