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

Subversion Repositories or1k

[/] [or1k/] [tags/] [rel_28/] [or1200/] [rtl/] [verilog/] [or1200_spram_32x24.v] - Blame information for rev 1777

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

Line No. Rev Author Line
1 1273 simont
//////////////////////////////////////////////////////////////////////
2
////                                                              ////
3
////  Generic Single-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 single-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
////  single-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 Single-Port Sync RAM                              ////
20
////  - Avant! Two-Port Sync RAM (*)                              ////
21
////  - Virage Single-Port Sync RAM                               ////
22
////  - Virtual Silicon Single-Port Sync RAM                      ////
23
////                                                              ////
24
////  Supported FPGA RAMs are:                                    ////
25
////  - Xilinx Virtex RAMB4_S16                                   ////
26
////  - Altera LPM                                                ////
27
////                                                              ////
28
////  To Do:                                                      ////
29
////   - xilinx rams need external tri-state logic                ////
30
////   - fix avant! two-port ram                                  ////
31
////   - add additional RAMs                                      ////
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 1291 lampret
// Revision 1.1  2004/04/08 11:00:46  simont
67
// Add support for 512B instruction cache.
68 1273 simont
//
69
//
70 1291 lampret
//
71 1273 simont
 
72
// synopsys translate_off
73
`include "timescale.v"
74
// synopsys translate_on
75
`include "or1200_defines.v"
76
 
77
module or1200_spram_32x24(
78
`ifdef OR1200_BIST
79
        // RAM BIST
80
        mbist_si_i, mbist_so_o, mbist_ctrl_i,
81
`endif
82
        // Generic synchronous single-port RAM interface
83 1291 lampret
        clk, rst, ce, we, oe, addr, di, doq
84 1273 simont
);
85
 
86
//
87
// Default address and data buses width
88
//
89
parameter aw = 5;
90
parameter dw = 24;
91
 
92
`ifdef OR1200_BIST
93
//
94
// RAM BIST
95
//
96
input mbist_si_i;
97
input [`OR1200_MBIST_CTRL_WIDTH - 1:0] mbist_ctrl_i;
98
output mbist_so_o;
99
`endif
100
 
101
//
102
// Generic synchronous single-port RAM interface
103
//
104
input                   clk;    // Clock
105
input                   rst;    // Reset
106
input                   ce;     // Chip enable input
107
input                   we;     // Write enable input
108
input                   oe;     // Output enable input
109
input   [aw-1:0] addr;   // address bus inputs
110
input   [dw-1:0] di;     // input data bus
111 1291 lampret
output  [dw-1:0] doq;    // output data bus
112 1273 simont
 
113
//
114
// Internal wires and registers
115
//
116
wire [31:24] unconnected;
117
 
118
`ifdef OR1200_ARTISAN_SSP
119
`else
120
`ifdef OR1200_VIRTUALSILICON_SSP
121
`else
122
`ifdef OR1200_BIST
123
`endif
124
`endif
125
`endif
126
 
127
`ifdef OR1200_ARTISAN_SSP
128
 
129
//
130
// Instantiation of ASIC memory:
131
//
132
// Artisan Synchronous Single-Port RAM (ra1sh)
133
//
134
`ifdef UNUSED
135
`else
136
`ifdef OR1200_BIST
137
`else
138
`endif
139
`endif
140
`ifdef OR1200_BIST
141
        // RAM BIST
142
`endif
143
 
144
`else
145
 
146
`ifdef OR1200_AVANT_ATP
147
 
148
//
149
// Instantiation of ASIC memory:
150
//
151
// Avant! Asynchronous Two-Port RAM
152
//
153
 
154
`else
155
 
156
`ifdef OR1200_VIRAGE_SSP
157
 
158
//
159
// Instantiation of ASIC memory:
160
//
161
// Virage Synchronous 1-port R/W RAM
162
//
163
 
164
`else
165
 
166
`ifdef OR1200_VIRTUALSILICON_SSP
167
 
168
//
169
// Instantiation of ASIC memory:
170
//
171
// Virtual Silicon Single-Port Synchronous SRAM
172
//
173
`ifdef UNUSED
174
`else
175
`ifdef OR1200_BIST
176
`else
177
`endif
178
`endif
179
`ifdef OR1200_BIST
180
        // RAM BIST
181
`endif
182
 
183
`else
184
 
185
`ifdef OR1200_XILINX_RAMB4
186
 
187
//
188
// Instantiation of FPGA memory:
189
//
190
// Virtex/Spartan2
191
//
192
 
193
//
194
// Block 0
195
//
196
RAMB4_S16 ramb4_s16_0(
197
        .CLK(clk),
198
        .RST(rst),
199
        .ADDR({3'h0, addr}),
200
        .DI(di[15:0]),
201
        .EN(ce),
202
        .WE(we),
203 1291 lampret
        .DO(doq[15:0])
204 1273 simont
);
205
 
206
//
207
// Block 1
208
//
209
RAMB4_S16 ramb4_s16_1(
210
        .CLK(clk),
211
        .RST(rst),
212
        .ADDR({3'h0, addr}),
213
        .DI({8'h00, di[23:16]}),
214
        .EN(ce),
215
        .WE(we),
216 1291 lampret
        .DO({unconnected, doq[23:16]})
217 1273 simont
);
218
 
219
`else
220
 
221
`ifdef OR1200_ALTERA_LPM
222
 
223
//
224
// Instantiation of FPGA memory:
225
//
226
// Altera LPM
227
//
228
// Added By Jamil Khatib
229
//
230
 
231
 
232
`else
233
 
234
//
235
// Generic single-port synchronous RAM model
236
//
237
 
238
//
239
// Generic RAM's registers and wires
240
//
241
reg     [dw-1:0] mem [(1<<aw)-1:0];       // RAM content
242 1291 lampret
reg     [aw-1:0] addr_reg;               // RAM address register
243 1273 simont
 
244
//
245
// Data output drivers
246
//
247 1291 lampret
assign doq = (oe) ? mem[addr_reg] : {dw{1'b0}};
248 1273 simont
 
249
//
250 1291 lampret
// RAM address register
251 1273 simont
//
252 1291 lampret
always @(posedge clk or posedge rst)
253
        if (rst)
254
                addr_reg <= #1 {aw{1'b0}};
255
        else if (ce)
256
                addr_reg <= #1 addr;
257
 
258
//
259
// RAM write
260
//
261 1273 simont
always @(posedge clk)
262 1291 lampret
        if (ce && we)
263 1273 simont
                mem[addr] <= #1 di;
264
 
265
`endif  // !OR1200_ALTERA_LPM
266
`endif  // !OR1200_XILINX_RAMB4_S16
267
`endif  // !OR1200_VIRTUALSILICON_SSP
268
`endif  // !OR1200_VIRAGE_SSP
269
`endif  // !OR1200_AVANT_ATP
270
`endif  // !OR1200_ARTISAN_SSP
271
 
272
endmodule

powered by: WebSVN 2.1.0

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