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

Subversion Repositories or1k

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

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

Line No. Rev Author Line
1 1188 simons
//////////////////////////////////////////////////////////////////////
2
////                                                              ////
3
////  Generic Single-Port Synchronous RAM with byte write signals ////
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.2  2003/10/17 07:59:44  markom
67
// mbist signals updated according to newest convention
68
//
69 1200 markom
// Revision 1.1  2003/08/27 08:38:36  simons
70
// Added support for rams with byte write access.
71 1188 simons
//
72 1200 markom
//
73 1188 simons
 
74
// synopsys translate_off
75
`include "timescale.v"
76
// synopsys translate_on
77
`include "or1200_defines.v"
78
 
79
module or1200_spram_1024x32_bw(
80
`ifdef OR1200_BIST
81
        // RAM BIST
82 1200 markom
        mbist_si_i, mbist_so_o, mbist_ctrl_i,
83 1188 simons
`endif
84
        // Generic synchronous single-port RAM interface
85 1291 lampret
        clk, rst, ce, we, oe, addr, di, doq
86 1188 simons
);
87
 
88
`ifdef OR1200_BIST
89
//
90
// RAM BIST
91
//
92 1200 markom
input                   mbist_si_i;
93
input [`OR1200_MBIST_CTRL_WIDTH - 1:0] mbist_ctrl_i;       // bist chain shift control
94
output                  mbist_so_o;
95 1188 simons
`endif
96
 
97
//
98
// Generic synchronous single-port RAM interface
99
//
100
input                   clk;    // Clock
101
input                   rst;    // Reset
102
input                   ce;     // Chip enable input
103
input   [3:0]           we;     // Write enable input
104
input                   oe;     // Output enable input
105
input   [9:0]           addr;   // address bus inputs
106
input   [31:0]          di;     // input data bus
107 1291 lampret
output  [31:0]          doq;     // output data bus
108 1188 simons
 
109
//
110
// Internal wires and registers
111
//
112
 
113
`ifdef OR1200_ARTISAN_SSP
114
`else
115
`ifdef OR1200_VIRTUALSILICON_SSP
116
`else
117
`ifdef OR1200_BIST
118 1200 markom
assign mbist_so_o = mbist_si_i;
119 1188 simons
`endif
120
`endif
121
`endif
122
 
123
 
124
`ifdef OR1200_ARTISAN_SSP
125
 
126
//
127
// Instantiation of ASIC memory:
128
//
129
// Artisan Synchronous Single-Port RAM (ra1sh)
130
//
131
`ifdef UNUSED
132
art_hssp_1024x32_bw artisan_ssp(
133
`else
134
`ifdef OR1200_BIST
135
art_hssp_1024x32_bw_bist artisan_ssp(
136
`else
137
art_hssp_1024x32_bw artisan_ssp(
138
`endif
139
`endif
140
`ifdef OR1200_BIST
141
        // RAM BIST
142 1200 markom
        .mbist_si_i(mbist_si_i),
143
        .mbist_so_o(mbist_so_o),
144
        .mbist_ctrl_i(mbist_ctrl_i),
145 1188 simons
`endif
146
        .CLK(clk),
147
        .CEN(~ce),
148
        .WEN(~we),
149
        .A(addr),
150
        .D(di),
151
        .OEN(~oe),
152 1291 lampret
        .Q(doq)
153 1188 simons
);
154
 
155
`else
156
 
157
`ifdef OR1200_AVANT_ATP
158
 
159
//
160
// Instantiation of ASIC memory:
161
//
162
// Avant! Asynchronous Two-Port RAM
163
//
164
avant_atp avant_atp(
165
        .web(~we),
166
        .reb(),
167
        .oeb(~oe),
168
        .rcsb(),
169
        .wcsb(),
170
        .ra(addr),
171
        .wa(addr),
172
        .di(di),
173 1291 lampret
        .doq(doq)
174 1188 simons
);
175
 
176
`else
177
 
178
`ifdef OR1200_VIRAGE_SSP
179
 
180
//
181
// Instantiation of ASIC memory:
182
//
183
// Virage Synchronous 1-port R/W RAM
184
//
185
virage_ssp virage_ssp(
186
        .clk(clk),
187
        .adr(addr),
188
        .d(di),
189
        .we(we),
190
        .oe(oe),
191
        .me(ce),
192 1291 lampret
        .q(doq)
193 1188 simons
);
194
 
195
`else
196
 
197
`ifdef OR1200_VIRTUALSILICON_SSP
198
 
199
//
200
// Instantiation of ASIC memory:
201
//
202
// Virtual Silicon Single-Port Synchronous SRAM
203
//
204
`ifdef OR1200_BIST
205 1200 markom
wire mbist_si_i_ram_0;
206
wire mbist_si_i_ram_1;
207
wire mbist_si_i_ram_2;
208
wire mbist_si_i_ram_3;
209
wire mbist_so_o_ram_0;
210
wire mbist_so_o_ram_1;
211
wire mbist_so_o_ram_2;
212
wire mbist_so_o_ram_3;
213
assign mbist_si_i_ram_0 = mbist_si_i;
214
assign mbist_si_i_ram_1 = mbist_so_o_ram_0;
215
assign mbist_si_i_ram_2 = mbist_so_o_ram_1;
216
assign mbist_si_i_ram_3 = mbist_so_o_ram_2;
217
assign mbist_so_o = mbist_so_o_ram_3;
218 1188 simons
`endif
219
 
220
`ifdef UNUSED
221
vs_hdsp_1024x8 vs_ssp_0(
222
`else
223
`ifdef OR1200_BIST
224
vs_hdsp_1024x8_bist vs_ssp_0(
225
`else
226
vs_hdsp_1024x8 vs_ssp_0(
227
`endif
228
`endif
229
`ifdef OR1200_BIST
230
        // RAM BIST
231 1200 markom
        .mbist_si_i(mbist_si_i_ram_0),
232
        .mbist_so_o(mbist_so_o_ram_0),
233
        .mbist_ctrl_i(mbist_ctrl_i),
234 1188 simons
`endif
235
        .CK(clk),
236
        .ADR(addr),
237
        .DI(di[7:0]),
238
        .WEN(~we[0]),
239
        .CEN(~ce),
240
        .OEN(~oe),
241 1291 lampret
        .DOUT(doq[7:0])
242 1188 simons
);
243
 
244
`ifdef UNUSED
245
vs_hdsp_1024x8 vs_ssp_1(
246
`else
247
`ifdef OR1200_BIST
248
vs_hdsp_1024x8_bist vs_ssp_1(
249
`else
250
vs_hdsp_1024x8 vs_ssp_1(
251
`endif
252
`endif
253
`ifdef OR1200_BIST
254
        // RAM BIST
255 1200 markom
        .mbist_si_i(mbist_si_i_ram_1),
256
        .mbist_so_o(mbist_so_o_ram_1),
257
        .mbist_ctrl_i(mbist_ctrl_i),
258 1188 simons
`endif
259
        .CK(clk),
260
        .ADR(addr),
261
        .DI(di[15:8]),
262
        .WEN(~we[1]),
263
        .CEN(~ce),
264
        .OEN(~oe),
265 1291 lampret
        .DOUT(doq[15:8])
266 1188 simons
);
267
 
268
`ifdef UNUSED
269
vs_hdsp_1024x8 vs_ssp_2(
270
`else
271
`ifdef OR1200_BIST
272
vs_hdsp_1024x8_bist vs_ssp_2(
273
`else
274
vs_hdsp_1024x8 vs_ssp_2(
275
`endif
276
`endif
277
`ifdef OR1200_BIST
278
        // RAM BIST
279 1200 markom
        .mbist_si_i(mbist_si_i_ram_2),
280
        .mbist_so_o(mbist_so_o_ram_2),
281
        .mbist_ctrl_i(mbist_ctrl_i),
282 1188 simons
`endif
283
        .CK(clk),
284
        .ADR(addr),
285
        .DI(di[23:16]),
286
        .WEN(~we[2]),
287
        .CEN(~ce),
288
        .OEN(~oe),
289 1291 lampret
        .DOUT(doq[23:16])
290 1188 simons
);
291
 
292
`ifdef UNUSED
293
vs_hdsp_1024x8 vs_ssp_3(
294
`else
295
`ifdef OR1200_BIST
296
vs_hdsp_1024x8_bist vs_ssp_3(
297
`else
298
vs_hdsp_1024x8 vs_ssp_3(
299
`endif
300
`endif
301
`ifdef OR1200_BIST
302
        // RAM BIST
303 1200 markom
        .mbist_si_i(mbist_si_i_ram_3),
304
        .mbist_so_o(mbist_so_o_ram_3),
305
        .mbist_ctrl_i(mbist_ctrl_i),
306 1188 simons
`endif
307
        .CK(clk),
308
        .ADR(addr),
309
        .DI(di[31:24]),
310
        .WEN(~we[3]),
311
        .CEN(~ce),
312
        .OEN(~oe),
313 1291 lampret
        .DOUT(doq[31:24])
314 1188 simons
);
315
 
316
`else
317
 
318
`ifdef OR1200_XILINX_RAMB4
319
 
320
//
321
// Instantiation of FPGA memory:
322
//
323
// Virtex/Spartan2
324
//
325
 
326
//
327
// Block 0
328
//
329
RAMB4_S4 ramb4_s4_0(
330
        .CLK(clk),
331
        .RST(rst),
332
        .ADDR(addr),
333
        .DI(di[3:0]),
334
        .EN(ce),
335
        .WE(we[0]),
336 1291 lampret
        .DO(doq[3:0])
337 1188 simons
);
338
 
339
//
340
// Block 1
341
//
342
RAMB4_S4 ramb4_s4_1(
343
        .CLK(clk),
344
        .RST(rst),
345
        .ADDR(addr),
346
        .DI(di[7:4]),
347
        .EN(ce),
348
        .WE(we[0]),
349 1291 lampret
        .DO(doq[7:4])
350 1188 simons
);
351
 
352
//
353
// Block 2
354
//
355
RAMB4_S4 ramb4_s4_2(
356
        .CLK(clk),
357
        .RST(rst),
358
        .ADDR(addr),
359
        .DI(di[11:8]),
360
        .EN(ce),
361
        .WE(we[1]),
362 1291 lampret
        .DO(doq[11:8])
363 1188 simons
);
364
 
365
//
366
// Block 3
367
//
368
RAMB4_S4 ramb4_s4_3(
369
        .CLK(clk),
370
        .RST(rst),
371
        .ADDR(addr),
372
        .DI(di[15:12]),
373
        .EN(ce),
374
        .WE(we[1]),
375 1291 lampret
        .DO(doq[15:12])
376 1188 simons
);
377
 
378
//
379
// Block 4
380
//
381
RAMB4_S4 ramb4_s4_4(
382
        .CLK(clk),
383
        .RST(rst),
384
        .ADDR(addr),
385
        .DI(di[19:16]),
386
        .EN(ce),
387
        .WE(we[2]),
388 1291 lampret
        .DO(doq[19:16])
389 1188 simons
);
390
 
391
//
392
// Block 5
393
//
394
RAMB4_S4 ramb4_s4_5(
395
        .CLK(clk),
396
        .RST(rst),
397
        .ADDR(addr),
398
        .DI(di[23:20]),
399
        .EN(ce),
400
        .WE(we[2]),
401 1291 lampret
        .DO(doq[23:20])
402 1188 simons
);
403
 
404
//
405
// Block 6
406
//
407
RAMB4_S4 ramb4_s4_6(
408
        .CLK(clk),
409
        .RST(rst),
410
        .ADDR(addr),
411
        .DI(di[27:24]),
412
        .EN(ce),
413
        .WE(we[3]),
414 1291 lampret
        .DO(doq[27:24])
415 1188 simons
);
416
 
417
//
418
// Block 7
419
//
420
RAMB4_S4 ramb4_s4_7(
421
        .CLK(clk),
422
        .RST(rst),
423
        .ADDR(addr),
424
        .DI(di[31:28]),
425
        .EN(ce),
426
        .WE(we[3]),
427 1291 lampret
        .DO(doq[31:28])
428 1188 simons
);
429
 
430
`else
431
 
432
//
433
// Generic single-port synchronous RAM model
434
//
435
 
436
//
437
// Generic RAM's registers and wires
438
//
439 1291 lampret
reg     [7:0]        mem_0 [1023:0];              // RAM content
440
reg     [7:0]        mem_1 [1023:0];              // RAM content
441
reg     [7:0]        mem_2 [1023:0];              // RAM content
442
reg     [7:0]        mem_3 [1023:0];              // RAM content
443
reg     [9:0]        addr_reg;                 // RAM address register
444 1188 simons
 
445
//
446
// Data output drivers
447
//
448 1291 lampret
assign doq = (oe) ? {mem_3[addr_reg], mem_2[addr_reg], mem_1[addr_reg], mem_0[addr_reg]} : {32{1'b0}};
449 1188 simons
 
450
//
451 1291 lampret
// RAM address register
452 1188 simons
//
453 1291 lampret
always @(posedge clk or posedge rst)
454
        if (rst)
455
                addr_reg <= #1 10'h000;
456
        else if (ce)
457
                addr_reg <= #1 addr;
458
 
459
//
460
// RAM write byte 0
461
//
462 1188 simons
always @(posedge clk)
463 1291 lampret
        if (ce && we[0])
464 1188 simons
                mem_0[addr] <= #1 di[7:0];
465 1291 lampret
 
466
//
467
// RAM write byte 1
468
//
469
always @(posedge clk)
470
        if (ce && we[1])
471 1188 simons
                mem_1[addr] <= #1 di[15:8];
472 1291 lampret
 
473
//
474
// RAM write byte 2
475
//
476
always @(posedge clk)
477
        if (ce && we[2])
478 1188 simons
                mem_2[addr] <= #1 di[23:16];
479 1291 lampret
 
480
//
481
// RAM write byte 3
482
//
483
always @(posedge clk)
484
        if (ce && we[3])
485 1188 simons
                mem_3[addr] <= #1 di[31:24];
486
 
487 1291 lampret
 
488 1188 simons
`endif  // !OR1200_XILINX_RAMB4_S16
489
`endif  // !OR1200_VIRTUALSILICON_SSP
490
`endif  // !OR1200_VIRAGE_SSP
491
`endif  // !OR1200_AVANT_ATP
492
`endif  // !OR1200_ARTISAN_SSP
493
 
494
endmodule

powered by: WebSVN 2.1.0

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