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_spram_128x32.v] - Blame information for rev 12

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 12 xianfeng
//////////////////////////////////////////////////////////////////////
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
////                                                              ////
20
////  Supported FPGA RAMs are:                                    ////
21
////  - Xilinx Virtex RAMB16                                      ////
22
////  - Xilinx Virtex RAMB4                                       ////
23
////                                                              ////
24
////  To Do:                                                      ////
25
////   - add support for other RAM's                              ////
26
////   - xilinx rams need external tri-state logic                ////
27
////   - fix avant! two-port ram                                  ////
28
////   - add additional RAMs                                      ////
29
////                                                              ////
30
////  Author(s):                                                  ////
31
////      - Damjan Lampret, lampret@opencores.org                 ////
32
////                                                              ////
33
//////////////////////////////////////////////////////////////////////
34
////                                                              ////
35
//// Copyright (C) 2000 Authors and OPENCORES.ORG                 ////
36
////                                                              ////
37
//// This source file may be used and distributed without         ////
38
//// restriction provided that this copyright statement is not    ////
39
//// removed from the file and that any derivative work contains  ////
40
//// the original copyright notice and the associated disclaimer. ////
41
////                                                              ////
42
//// This source file is free software; you can redistribute it   ////
43
//// and/or modify it under the terms of the GNU Lesser General   ////
44
//// Public License as published by the Free Software Foundation; ////
45
//// either version 2.1 of the License, or (at your option) any   ////
46
//// later version.                                               ////
47
////                                                              ////
48
//// This source is distributed in the hope that it will be       ////
49
//// useful, but WITHOUT ANY WARRANTY; without even the implied   ////
50
//// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR      ////
51
//// PURPOSE.  See the GNU Lesser General Public License for more ////
52
//// details.                                                     ////
53
////                                                              ////
54
//// You should have received a copy of the GNU Lesser General    ////
55
//// Public License along with this source; if not, download it   ////
56
//// from http://www.opencores.org/lgpl.shtml                     ////
57
////                                                              ////
58
//////////////////////////////////////////////////////////////////////
59
//
60
// CVS Revision History
61
//
62
// $Log: or1200_spram_128x32.v,v $
63
// Revision 1.3  2005/10/19 11:37:56  jcastillo
64
// Added support for RAMB16 Xilinx4/Spartan3 primitives
65
//
66
// Revision 1.2  2004/06/08 18:15:32  lampret
67
// Changed behavior of the simulation generic models
68
//
69
// Revision 1.1  2004/04/08 11:00:46  simont
70
// Add support for 512B instruction cache.
71
//
72
//
73
//
74
 
75
// synopsys translate_off
76
`include "timescale.v"
77
// synopsys translate_on
78
`include "or1200_defines.v"
79
 
80
module or1200_spram_128x32(
81
`ifdef OR1200_BIST
82
        // RAM BIST
83
        mbist_si_i, mbist_so_o, mbist_ctrl_i,
84
`endif
85
        // Generic synchronous single-port RAM interface
86
        clk, rst, ce, we, oe, addr, di, doq
87
);
88
 
89
//
90
// Default address and data buses width
91
//
92
parameter aw = 7;
93
parameter dw = 32;
94
 
95
`ifdef OR1200_BIST
96
//
97
// RAM BIST
98
//
99
input mbist_si_i;
100
input [`OR1200_MBIST_CTRL_WIDTH - 1:0] mbist_ctrl_i;
101
output mbist_so_o;
102
`endif
103
 
104
//
105
// Generic synchronous single-port RAM interface
106
//
107
input                   clk;    // Clock
108
input                   rst;    // Reset
109
input                   ce;     // Chip enable input
110
input                   we;     // Write enable input
111
input                   oe;     // Output enable input
112
input   [aw-1:0] addr;   // address bus inputs
113
input   [dw-1:0] di;     // input data bus
114
output  [dw-1:0] doq;    // output data bus
115
 
116
//
117
// Internal wires and registers
118
//
119
 
120
`ifdef OR1200_ARTISAN_SSP
121
`else
122
`ifdef OR1200_VIRTUALSILICON_SSP
123
`else
124
`ifdef OR1200_BIST
125
`endif
126
`endif
127
`endif
128
 
129
`ifdef OR1200_ARTISAN_SSP
130
 
131
//
132
// Instantiation of ASIC memory:
133
//
134
// Artisan Synchronous Single-Port RAM (ra1sh)
135
//
136
`ifdef UNUSED
137
`else
138
`ifdef OR1200_BIST
139
`else
140
`endif
141
`endif
142
`ifdef OR1200_BIST
143
`endif
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({1'b0, addr}),
200
        .DI(di[15:0]),
201
        .EN(ce),
202
        .WE(we),
203
        .DO(doq[15:0])
204
);
205
 
206
//
207
// Block 1
208
//
209
RAMB4_S16 ramb4_s16_1(
210
        .CLK(clk),
211
        .RST(rst),
212
        .ADDR({1'b0, addr}),
213
        .DI(di[31:16]),
214
        .EN(ce),
215
        .WE(we),
216
        .DO(doq[31:16])
217
);
218
 
219
`else
220
 
221
`ifdef OR1200_XILINX_RAMB16
222
 
223
//
224
// Instantiation of FPGA memory:
225
//
226
// Virtex4/Spartan3E
227
//
228
// Added By Nir Mor
229
//
230
 
231
RAMB16_S36 ramb16_s36(
232
        .CLK(clk),
233
        .SSR(rst),
234
        .ADDR({2'b00, addr}),
235
        .DI(di),
236
        .DIP(4'h0),
237
        .EN(ce),
238
        .WE(we),
239
        .DO(doq),
240
        .DOP()
241
);
242
 
243
`else
244
 
245
//
246
// Generic single-port synchronous RAM model
247
//
248
 
249
//
250
// Generic RAM's registers and wires
251
//
252
reg     [dw-1:0] mem [(1<<aw)-1:0];       // RAM content
253
reg     [aw-1:0] addr_reg;               // RAM address register
254
 
255
//
256
// Data output drivers
257
//
258
assign doq = (oe) ? mem[addr_reg] : {dw{1'b0}};
259
 
260
//
261
// RAM address register
262
//
263
always @(posedge clk or posedge rst)
264
        if (rst)
265
                addr_reg <= #1 {aw{1'b0}};
266
        else if (ce)
267
                addr_reg <= #1 addr;
268
 
269
//
270
// RAM write
271
//
272
always @(posedge clk)
273
        if (ce && we)
274
                mem[addr] <= #1 di;
275
 
276
`endif  // !OR1200_XILINX_RAMB16
277
`endif  // !OR1200_XILINX_RAMB4
278
`endif  // !OR1200_VIRTUALSILICON_SSP
279
`endif  // !OR1200_VIRAGE_SSP
280
`endif  // !OR1200_AVANT_ATP
281
`endif  // !OR1200_ARTISAN_SSP
282
 
283
endmodule

powered by: WebSVN 2.1.0

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