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

Subversion Repositories or1k

[/] [or1k/] [tags/] [rel_3/] [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
////                                                              ////
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
// Revision 1.7  2001/10/21 17:57:16  lampret
65
// 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.
66
//
67
// Revision 1.6  2001/10/14 13:12:09  lampret
68
// MP3 version.
69
//
70
// Revision 1.1.1.1  2001/10/06 10:18:36  igorm
71
// no message
72
//
73
// Revision 1.1  2001/08/09 13:39:33  lampret
74
// Major clean-up.
75
//
76
// Revision 1.2  2001/07/30 05:38:02  lampret
77
// Adding empty directories required by HDL coding guidelines
78
//
79
//
80
 
81
// synopsys translate_off
82
`include "timescale.v"
83
// synopsys translate_on
84
`include "or1200_defines.v"
85
 
86
module or1200_tpram_32x32(
87
        // Generic synchronous two-port RAM interface
88
        clk_a, rst_a, ce_a, we_a, oe_a, addr_a, di_a, do_a,
89
        clk_b, rst_b, ce_b, we_b, oe_b, addr_b, di_b, do_b
90
);
91
 
92
//
93
// Default address and data buses width
94
//
95
parameter aw = 5;
96
parameter dw = 32;
97
 
98
//
99
// Generic synchronous two-port RAM interface
100
//
101
input                   clk_a;  // Clock
102
input                   rst_a;  // Reset
103
input                   ce_a;   // Chip enable input
104
input                   we_a;   // Write enable input
105
input                   oe_a;   // Output enable input
106
input   [aw-1:0] addr_a; // address bus inputs
107
input   [dw-1:0] di_a;   // input data bus
108
output  [dw-1:0] do_a;   // output data bus
109
input                   clk_b;  // Clock
110
input                   rst_b;  // Reset
111
input                   ce_b;   // Chip enable input
112
input                   we_b;   // Write enable input
113
input                   oe_b;   // Output enable input
114
input   [aw-1:0] addr_b; // address bus inputs
115
input   [dw-1:0] di_b;   // input data bus
116
output  [dw-1:0] do_b;   // output data bus
117
 
118
//
119
// Internal wires and registers
120
//
121
 
122
 
123
`ifdef OR1200_ARTISAN_SDP
124
 
125
//
126
// Instantiation of ASIC memory:
127
//
128
// Artisan Synchronous Double-Port RAM (ra2sh)
129
//
130
`ifdef UNUSED
131
art_hsdp_32x32 #(dw, 1<<aw, aw) artisan_sdp(
132
`else
133
art_hsdp_32x32 artisan_sdp(
134
`endif
135
        .qa(do_a),
136
        .clka(clk_a),
137
        .cena(~ce_a),
138
        .wena(~we_a),
139
        .aa(addr_a),
140
        .da(di_a),
141
        .oena(~oe_a),
142
        .qb(do_b),
143
        .clkb(clk_b),
144
        .cenb(~ce_b),
145
        .wenb(~we_b),
146
        .ab(addr_b),
147
        .db(di_b),
148
        .oenb(~oe_b)
149
);
150
 
151
`else
152
 
153
`ifdef OR1200_AVANT_ATP
154
 
155
//
156
// Instantiation of ASIC memory:
157
//
158
// Avant! Asynchronous Two-Port RAM
159
//
160
avant_atp avant_atp(
161
        .web(~we),
162
        .reb(),
163
        .oeb(~oe),
164
        .rcsb(),
165
        .wcsb(),
166
        .ra(addr),
167
        .wa(addr),
168
        .di(di),
169
        .do(do)
170
);
171
 
172
`else
173
 
174
`ifdef OR1200_VIRAGE_STP
175
 
176
//
177
// Instantiation of ASIC memory:
178
//
179
// Virage Synchronous 2-port R/W RAM
180
//
181
virage_stp virage_stp(
182
        .QA(do_a),
183
        .QB(do_b),
184
 
185
        .ADRA(addr_a),
186
        .DA(di_a),
187
        .WEA(we_a),
188
        .OEA(oe_a),
189
        .MEA(ce_a),
190
        .CLKA(clk_a),
191
 
192
        .ADRB(adr_b),
193
        .DB(di_b),
194
        .WEB(we_b),
195
        .OEB(oe_b),
196
        .MEB(ce_b),
197
        .CLKB(clk_b)
198
);
199
 
200
`else
201
 
202
`ifdef OR1200_XILINX_RAMB4
203
 
204
//
205
// Instantiation of FPGA memory:
206
//
207
// Virtex/Spartan2
208
//
209
 
210
//
211
// Block 0
212
//
213
RAMB4_S16_S16 ramb4_s16_s16_0(
214
        .CLKA(clk_a),
215
        .RSTA(rst_a),
216
        .ADDRA(addr_a),
217
        .DIA(di_a[15:0]),
218
        .ENA(ce_a),
219
        .WEA(we_a),
220
        .DOA(do_a[15:0]),
221
 
222
        .CLKB(clk_b),
223
        .RSTB(rst_b),
224
        .ADDRB(addr_b),
225
        .DIB(di_b[15:0]),
226
        .ENB(ce_b),
227
        .WEB(we_b),
228
        .DOB(do_b[15:0])
229
);
230
 
231
//
232
// Block 1
233
//
234
RAMB4_S16_S16 ramb4_s16_s16_1(
235
        .CLKA(clk_a),
236
        .RSTA(rst_a),
237
        .ADDRA(addr_a),
238
        .DIA(di_a[31:16]),
239
        .ENA(ce_a),
240
        .WEA(we_a),
241
        .DOA(do_a[31:16]),
242
 
243
        .CLKB(clk_b),
244
        .RSTB(rst_b),
245
        .ADDRB(addr_b),
246
        .DIB(di_b[31:16]),
247
        .ENB(ce_b),
248
        .WEB(we_b),
249
        .DOB(do_b[31:16])
250
);
251
 
252
`else
253
 
254
//
255
// Generic two-port synchronous RAM model
256
//
257
 
258
//
259
// Generic RAM's registers and wires
260
//
261
reg     [dw-1:0] mem [(1<<aw)-1:0];       // RAM content
262
reg     [dw-1:0] do_reg_a;               // RAM data output register
263
reg     [dw-1:0] do_reg_b;               // RAM data output register
264
 
265
//
266
// Data output drivers
267
//
268
assign do_a = (oe_a) ? do_reg_a : {dw{1'bz}};
269
assign do_b = (oe_b) ? do_reg_b : {dw{1'bz}};
270
 
271
//
272
// RAM read and write
273
//
274
always @(posedge clk_a)
275
        if (ce_a && !we_a)
276
                do_reg_a <= #1 mem[addr_a];
277
        else if (ce_a && we_a)
278
                mem[addr_a] <= #1 di_a;
279
 
280
//
281
// RAM read and write
282
//
283
always @(posedge clk_b)
284
        if (ce_b && !we_b)
285
                do_reg_b <= #1 mem[addr_b];
286
        else if (ce_b && we_b)
287
                mem[addr_b] <= #1 di_b;
288
 
289
`endif  // !OR1200_XILINX_RAMB4_S16_S16
290
`endif  // !OR1200_VIRAGE_STP
291
`endif  // !OR1200_AVANT_ATP
292
`endif  // !OR1200_ARTISAN_SDP
293
 
294
endmodule

powered by: WebSVN 2.1.0

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