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

Subversion Repositories or1k

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

powered by: WebSVN 2.1.0

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