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

Subversion Repositories or1k

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

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 504 lampret
//////////////////////////////////////////////////////////////////////
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 RAMB4_S16_S16                               ////
25 1129 lampret
////  - Altera LPM                                                ////
26 504 lampret
////                                                              ////
27
////  To Do:                                                      ////
28
////   - fix Avant!                                               ////
29
////   - xilinx rams need external tri-state logic                ////
30 1129 lampret
////   - add additional RAMs (VS etc)                             ////
31 504 lampret
////                                                              ////
32
////  Author(s):                                                  ////
33
////      - Damjan Lampret, lampret@opencores.org                 ////
34
////                                                              ////
35
//////////////////////////////////////////////////////////////////////
36
////                                                              ////
37
//// Copyright (C) 2000 Authors and OPENCORES.ORG                 ////
38
////                                                              ////
39
//// This source file may be used and distributed without         ////
40
//// restriction provided that this copyright statement is not    ////
41
//// removed from the file and that any derivative work contains  ////
42
//// the original copyright notice and the associated disclaimer. ////
43
////                                                              ////
44
//// This source file is free software; you can redistribute it   ////
45
//// and/or modify it under the terms of the GNU Lesser General   ////
46
//// Public License as published by the Free Software Foundation; ////
47
//// either version 2.1 of the License, or (at your option) any   ////
48
//// later version.                                               ////
49
////                                                              ////
50
//// This source is distributed in the hope that it will be       ////
51
//// useful, but WITHOUT ANY WARRANTY; without even the implied   ////
52
//// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR      ////
53
//// PURPOSE.  See the GNU Lesser General Public License for more ////
54
//// details.                                                     ////
55
////                                                              ////
56
//// You should have received a copy of the GNU Lesser General    ////
57
//// Public License along with this source; if not, download it   ////
58
//// from http://www.opencores.org/lgpl.shtml                     ////
59
////                                                              ////
60
//////////////////////////////////////////////////////////////////////
61
//
62
// CVS Revision History
63
//
64
// $Log: not supported by cvs2svn $
65 1291 lampret
// Revision 1.3  2004/04/05 08:29:57  lampret
66
// Merged branch_qmem into main tree.
67
//
68 1267 lampret
// Revision 1.2.4.1  2003/07/08 15:36:37  lampret
69
// Added embedded memory QMEM.
70
//
71
// Revision 1.2  2003/04/07 01:19:07  lampret
72
// Added Altera LPM RAMs. Changed generic RAM output when OE inactive.
73
//
74 1129 lampret
// Revision 1.1  2002/01/03 08:16:15  lampret
75
// New prefixes for RTL files, prefixed module names. Updated cache controllers and MMUs.
76
//
77 504 lampret
// Revision 1.7  2001/10/21 17:57:16  lampret
78
// 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.
79
//
80
// Revision 1.6  2001/10/14 13:12:09  lampret
81
// MP3 version.
82
//
83
// Revision 1.1.1.1  2001/10/06 10:18:36  igorm
84
// no message
85
//
86
// Revision 1.1  2001/08/09 13:39:33  lampret
87
// Major clean-up.
88
//
89
// Revision 1.2  2001/07/30 05:38:02  lampret
90
// Adding empty directories required by HDL coding guidelines
91
//
92
//
93
 
94
// synopsys translate_off
95
`include "timescale.v"
96
// synopsys translate_on
97
`include "or1200_defines.v"
98
 
99
module or1200_tpram_32x32(
100
        // Generic synchronous two-port RAM interface
101
        clk_a, rst_a, ce_a, we_a, oe_a, addr_a, di_a, do_a,
102
        clk_b, rst_b, ce_b, we_b, oe_b, addr_b, di_b, do_b
103
);
104
 
105
//
106
// Default address and data buses width
107
//
108
parameter aw = 5;
109
parameter dw = 32;
110
 
111
//
112
// Generic synchronous two-port RAM interface
113
//
114
input                   clk_a;  // Clock
115
input                   rst_a;  // Reset
116
input                   ce_a;   // Chip enable input
117
input                   we_a;   // Write enable input
118
input                   oe_a;   // Output enable input
119
input   [aw-1:0] addr_a; // address bus inputs
120
input   [dw-1:0] di_a;   // input data bus
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                   oe_b;   // Output enable input
127
input   [aw-1:0] addr_b; // address bus inputs
128
input   [dw-1:0] di_b;   // input data bus
129
output  [dw-1:0] do_b;   // output data bus
130
 
131
//
132
// Internal wires and registers
133
//
134
 
135
 
136
`ifdef OR1200_ARTISAN_SDP
137
 
138
//
139
// Instantiation of ASIC memory:
140
//
141
// Artisan Synchronous Double-Port RAM (ra2sh)
142
//
143
`ifdef UNUSED
144
art_hsdp_32x32 #(dw, 1<<aw, aw) artisan_sdp(
145
`else
146
art_hsdp_32x32 artisan_sdp(
147
`endif
148
        .qa(do_a),
149
        .clka(clk_a),
150
        .cena(~ce_a),
151
        .wena(~we_a),
152
        .aa(addr_a),
153
        .da(di_a),
154
        .oena(~oe_a),
155
        .qb(do_b),
156
        .clkb(clk_b),
157
        .cenb(~ce_b),
158
        .wenb(~we_b),
159
        .ab(addr_b),
160
        .db(di_b),
161
        .oenb(~oe_b)
162
);
163
 
164
`else
165
 
166
`ifdef OR1200_AVANT_ATP
167
 
168
//
169
// Instantiation of ASIC memory:
170
//
171
// Avant! Asynchronous Two-Port RAM
172
//
173
avant_atp avant_atp(
174
        .web(~we),
175
        .reb(),
176
        .oeb(~oe),
177
        .rcsb(),
178
        .wcsb(),
179
        .ra(addr),
180
        .wa(addr),
181
        .di(di),
182 1291 lampret
        .doq(doq)
183 504 lampret
);
184
 
185
`else
186
 
187
`ifdef OR1200_VIRAGE_STP
188
 
189
//
190
// Instantiation of ASIC memory:
191
//
192
// Virage Synchronous 2-port R/W RAM
193
//
194
virage_stp virage_stp(
195
        .QA(do_a),
196
        .QB(do_b),
197
 
198
        .ADRA(addr_a),
199
        .DA(di_a),
200
        .WEA(we_a),
201
        .OEA(oe_a),
202
        .MEA(ce_a),
203
        .CLKA(clk_a),
204
 
205
        .ADRB(adr_b),
206
        .DB(di_b),
207
        .WEB(we_b),
208
        .OEB(oe_b),
209
        .MEB(ce_b),
210
        .CLKB(clk_b)
211
);
212
 
213
`else
214
 
215
`ifdef OR1200_XILINX_RAMB4
216
 
217
//
218
// Instantiation of FPGA memory:
219
//
220
// Virtex/Spartan2
221
//
222
 
223
//
224
// Block 0
225
//
226
RAMB4_S16_S16 ramb4_s16_s16_0(
227
        .CLKA(clk_a),
228
        .RSTA(rst_a),
229
        .ADDRA(addr_a),
230
        .DIA(di_a[15:0]),
231
        .ENA(ce_a),
232
        .WEA(we_a),
233
        .DOA(do_a[15:0]),
234
 
235
        .CLKB(clk_b),
236
        .RSTB(rst_b),
237
        .ADDRB(addr_b),
238
        .DIB(di_b[15:0]),
239
        .ENB(ce_b),
240
        .WEB(we_b),
241
        .DOB(do_b[15:0])
242
);
243
 
244
//
245
// Block 1
246
//
247
RAMB4_S16_S16 ramb4_s16_s16_1(
248
        .CLKA(clk_a),
249
        .RSTA(rst_a),
250
        .ADDRA(addr_a),
251
        .DIA(di_a[31:16]),
252
        .ENA(ce_a),
253
        .WEA(we_a),
254
        .DOA(do_a[31:16]),
255
 
256
        .CLKB(clk_b),
257
        .RSTB(rst_b),
258
        .ADDRB(addr_b),
259
        .DIB(di_b[31:16]),
260
        .ENB(ce_b),
261
        .WEB(we_b),
262
        .DOB(do_b[31:16])
263
);
264
 
265
`else
266
 
267 1267 lampret
`ifdef OR1200_ALTERA_LPM_XXX
268 1129 lampret
 
269 504 lampret
//
270 1129 lampret
// Instantiation of FPGA memory:
271
//
272
// Altera LPM
273
//
274
// Added By Jamil Khatib
275
//
276
altqpram altqpram_component (
277
        .wraddress_a (addr_a),
278
        .inclocken_a (ce_a),
279
        .wraddress_b (addr_b),
280
        .wren_a (we_a),
281
        .inclocken_b (ce_b),
282
        .wren_b (we_b),
283
        .inaclr_a (rst_a),
284
        .inaclr_b (rst_b),
285
        .inclock_a (clk_a),
286
        .inclock_b (clk_b),
287
        .data_a (di_a),
288
        .data_b (di_b),
289
        .q_a (do_a),
290
        .q_b (do_b)
291
);
292
 
293
defparam altqpram_component.operation_mode = "BIDIR_DUAL_PORT",
294
        altqpram_component.width_write_a = dw,
295
        altqpram_component.widthad_write_a = aw,
296
        altqpram_component.numwords_write_a = dw,
297
        altqpram_component.width_read_a = dw,
298
        altqpram_component.widthad_read_a = aw,
299
        altqpram_component.numwords_read_a = dw,
300
        altqpram_component.width_write_b = dw,
301
        altqpram_component.widthad_write_b = aw,
302
        altqpram_component.numwords_write_b = dw,
303
        altqpram_component.width_read_b = dw,
304
        altqpram_component.widthad_read_b = aw,
305
        altqpram_component.numwords_read_b = dw,
306
        altqpram_component.indata_reg_a = "INCLOCK_A",
307
        altqpram_component.wrcontrol_wraddress_reg_a = "INCLOCK_A",
308
        altqpram_component.outdata_reg_a = "INCLOCK_A",
309
        altqpram_component.indata_reg_b = "INCLOCK_B",
310
        altqpram_component.wrcontrol_wraddress_reg_b = "INCLOCK_B",
311
        altqpram_component.outdata_reg_b = "INCLOCK_B",
312
        altqpram_component.indata_aclr_a = "INACLR_A",
313
        altqpram_component.wraddress_aclr_a = "INACLR_A",
314
        altqpram_component.wrcontrol_aclr_a = "INACLR_A",
315
        altqpram_component.outdata_aclr_a = "INACLR_A",
316
        altqpram_component.indata_aclr_b = "NONE",
317
        altqpram_component.wraddress_aclr_b = "NONE",
318
        altqpram_component.wrcontrol_aclr_b = "NONE",
319
        altqpram_component.outdata_aclr_b = "INACLR_B",
320
        altqpram_component.lpm_hint = "USE_ESB=ON";
321
        //examplar attribute altqpram_component NOOPT TRUE
322
 
323
`else
324
 
325
//
326 504 lampret
// Generic two-port synchronous RAM model
327
//
328
 
329
//
330
// Generic RAM's registers and wires
331
//
332
reg     [dw-1:0] mem [(1<<aw)-1:0];       // RAM content
333 1291 lampret
reg     [aw-1:0] addr_a_reg;             // RAM read address register
334
reg     [aw-1:0] addr_b_reg;             // RAM read address register
335 504 lampret
 
336
//
337
// Data output drivers
338
//
339 1291 lampret
assign do_a = (oe_a) ? mem[addr_a_reg] : {dw{1'b0}};
340
assign do_b = (oe_b) ? mem[addr_b_reg] : {dw{1'b0}};
341 504 lampret
 
342
//
343 1291 lampret
// RAM write
344 504 lampret
//
345
always @(posedge clk_a)
346 1291 lampret
        if (ce_a && we_a)
347 504 lampret
                mem[addr_a] <= #1 di_a;
348
 
349
//
350 1291 lampret
// RAM write
351 504 lampret
//
352
always @(posedge clk_b)
353 1291 lampret
        if (ce_b && we_b)
354 504 lampret
                mem[addr_b] <= #1 di_b;
355
 
356 1291 lampret
//
357
// RAM read address register
358
//
359
always @(posedge clk_a or posedge rst_a)
360
        if (rst_a)
361
                addr_a_reg <= #1 {aw{1'b0}};
362
        else if (ce_a)
363
                addr_a_reg <= #1 addr_a;
364
 
365
//
366
// RAM read address register
367
//
368
always @(posedge clk_b or posedge rst_b)
369
        if (rst_b)
370
                addr_b_reg <= #1 {aw{1'b0}};
371
        else if (ce_b)
372
                addr_b_reg <= #1 addr_b;
373
 
374 1129 lampret
`endif  // !OR1200_ALTERA_LPM
375 504 lampret
`endif  // !OR1200_XILINX_RAMB4_S16_S16
376
`endif  // !OR1200_VIRAGE_STP
377
`endif  // !OR1200_AVANT_ATP
378
`endif  // !OR1200_ARTISAN_SDP
379
 
380
endmodule

powered by: WebSVN 2.1.0

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