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

Subversion Repositories or1k

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

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

Line No. Rev Author Line
1 1186 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.3  2003/10/17 07:59:44  markom
67
// mbist signals updated according to newest convention
68
//
69 1200 markom
// Revision 1.2  2003/09/12 09:03:54  dries
70
// correct all the syntax errors
71
//
72 1194 dries
// Revision 1.1  2003/08/26 09:37:02  simons
73
// Added support for rams with byte write access.
74 1186 simons
//
75 1194 dries
//
76 1186 simons
 
77
// synopsys translate_off
78
`include "timescale.v"
79
// synopsys translate_on
80
`include "or1200_defines.v"
81
 
82
module or1200_spram_2048x32_bw(
83
`ifdef OR1200_BIST
84
        // RAM BIST
85 1200 markom
        mbist_si_i, mbist_so_o, mbist_ctrl_i,
86 1186 simons
`endif
87
        // Generic synchronous single-port RAM interface
88 1291 lampret
        clk, rst, ce, we, oe, addr, di, doq
89 1186 simons
);
90
 
91
`ifdef OR1200_BIST
92
//
93
// RAM BIST
94
//
95 1200 markom
input                   mbist_si_i;
96
input [`OR1200_MBIST_CTRL_WIDTH - 1:0] mbist_ctrl_i;       // bist chain shift control
97
output                  mbist_so_o;
98 1186 simons
`endif
99
 
100
//
101
// Generic synchronous single-port RAM interface
102
//
103
input                   clk;    // Clock
104
input                   rst;    // Reset
105
input                   ce;     // Chip enable input
106
input   [3:0]           we;     // Write enable input
107
input                   oe;     // Output enable input
108
input   [10:0]          addr;   // address bus inputs
109
input   [31:0]          di;     // input data bus
110 1291 lampret
output  [31:0]          doq;     // output data bus
111 1186 simons
 
112
//
113
// Internal wires and registers
114
//
115
 
116
`ifdef OR1200_ARTISAN_SSP
117
`else
118
`ifdef OR1200_VIRTUALSILICON_SSP
119
`else
120
`ifdef OR1200_BIST
121 1200 markom
assign mbist_so_o = mbist_si_i;
122 1186 simons
`endif
123
`endif
124
`endif
125
 
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
art_hssp_2048x32_bw artisan_ssp(
136
`else
137
`ifdef OR1200_BIST
138
art_hssp_2048x32_bw_bist artisan_ssp(
139
`else
140
art_hssp_2048x32_bw artisan_ssp(
141
`endif
142
`endif
143
`ifdef OR1200_BIST
144
        // RAM BIST
145 1200 markom
        .mbist_si_i(mbist_si_i),
146
        .mbist_so_o(mbist_so_o),
147
        .mbist_ctrl_i(mbist_ctrl_i),
148 1186 simons
`endif
149
        .CLK(clk),
150
        .CEN(~ce),
151
        .WEN(~we),
152
        .A(addr),
153
        .D(di),
154
        .OEN(~oe),
155 1291 lampret
        .Q(doq)
156 1186 simons
);
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 1291 lampret
        .doq(doq)
177 1186 simons
);
178
 
179
`else
180
 
181
`ifdef OR1200_VIRAGE_SSP
182
 
183
//
184
// Instantiation of ASIC memory:
185
//
186
// Virage Synchronous 1-port R/W RAM
187
//
188
virage_ssp virage_ssp(
189
        .clk(clk),
190
        .adr(addr),
191
        .d(di),
192
        .we(we),
193
        .oe(oe),
194
        .me(ce),
195 1291 lampret
        .q(doq)
196 1186 simons
);
197
 
198
`else
199
 
200
`ifdef OR1200_VIRTUALSILICON_SSP
201
 
202
//
203
// Instantiation of ASIC memory:
204
//
205
// Virtual Silicon Single-Port Synchronous SRAM
206
//
207
`ifdef OR1200_BIST
208 1200 markom
wire mbist_si_i_ram_0;
209
wire mbist_si_i_ram_1;
210
wire mbist_si_i_ram_2;
211
wire mbist_si_i_ram_3;
212
wire mbist_so_o_ram_0;
213
wire mbist_so_o_ram_1;
214
wire mbist_so_o_ram_2;
215
wire mbist_so_o_ram_3;
216
assign mbist_si_i_ram_0 = mbist_si_i;
217
assign mbist_si_i_ram_1 = mbist_so_o_ram_0;
218
assign mbist_si_i_ram_2 = mbist_so_o_ram_1;
219
assign mbist_si_i_ram_3 = mbist_so_o_ram_2;
220
assign mbist_so_o = mbist_so_o_ram_3;
221 1186 simons
`endif
222
 
223
`ifdef UNUSED
224
vs_hdsp_2048x8 vs_ssp_0(
225
`else
226
`ifdef OR1200_BIST
227
vs_hdsp_2048x8_bist vs_ssp_0(
228
`else
229
vs_hdsp_2048x8 vs_ssp_0(
230
`endif
231
`endif
232
`ifdef OR1200_BIST
233
        // RAM BIST
234 1200 markom
        .mbist_si_i(mbist_si_i_ram_0),
235
        .mbist_so_o(mbist_so_o_ram_0),
236
        .mbist_ctrl_i(mbist_ctrl_i),
237 1186 simons
`endif
238
        .CK(clk),
239
        .ADR(addr),
240
        .DI(di[7:0]),
241
        .WEN(~we[0]),
242
        .CEN(~ce),
243
        .OEN(~oe),
244 1291 lampret
        .DOUT(doq[7:0])
245 1186 simons
);
246
 
247
`ifdef UNUSED
248
vs_hdsp_2048x8 vs_ssp_1(
249
`else
250
`ifdef OR1200_BIST
251
vs_hdsp_2048x8_bist vs_ssp_1(
252
`else
253
vs_hdsp_2048x8 vs_ssp_1(
254
`endif
255
`endif
256
`ifdef OR1200_BIST
257
        // RAM BIST
258 1200 markom
        .mbist_si_i(mbist_si_i_ram_1),
259
        .mbist_so_o(mbist_so_o_ram_1),
260
        .mbist_ctrl_i(mbist_ctrl_i),
261 1186 simons
`endif
262
        .CK(clk),
263
        .ADR(addr),
264
        .DI(di[15:8]),
265
        .WEN(~we[1]),
266
        .CEN(~ce),
267
        .OEN(~oe),
268 1291 lampret
        .DOUT(doq[15:8])
269 1186 simons
);
270
 
271
`ifdef UNUSED
272
vs_hdsp_2048x8 vs_ssp_2(
273
`else
274
`ifdef OR1200_BIST
275
vs_hdsp_2048x8_bist vs_ssp_2(
276
`else
277
vs_hdsp_2048x8 vs_ssp_2(
278
`endif
279
`endif
280
`ifdef OR1200_BIST
281
        // RAM BIST
282 1200 markom
        .mbist_si_i(mbist_si_i_ram_2),
283
        .mbist_so_o(mbist_so_o_ram_2),
284
        .mbist_ctrl_i(mbist_ctrl_i),
285 1186 simons
`endif
286
        .CK(clk),
287
        .ADR(addr),
288
        .DI(di[23:16]),
289
        .WEN(~we[2]),
290
        .CEN(~ce),
291
        .OEN(~oe),
292 1291 lampret
        .DOUT(doq[23:16])
293 1186 simons
);
294
 
295
`ifdef UNUSED
296
vs_hdsp_2048x8 vs_ssp_3(
297
`else
298
`ifdef OR1200_BIST
299
vs_hdsp_2048x8_bist vs_ssp_3(
300
`else
301
vs_hdsp_2048x8 vs_ssp_3(
302
`endif
303
`endif
304
`ifdef OR1200_BIST
305
        // RAM BIST
306 1200 markom
        .mbist_si_i(mbist_si_i_ram_3),
307
        .mbist_so_o(mbist_so_o_ram_3),
308
        .mbist_ctrl_i(mbist_ctrl_i),
309 1186 simons
`endif
310
        .CK(clk),
311
        .ADR(addr),
312
        .DI(di[31:24]),
313
        .WEN(~we[3]),
314
        .CEN(~ce),
315
        .OEN(~oe),
316 1291 lampret
        .DOUT(doq[31:24])
317 1186 simons
);
318
 
319
`else
320
 
321
`ifdef OR1200_XILINX_RAMB4
322
 
323
//
324
// Instantiation of FPGA memory:
325
//
326
// Virtex/Spartan2
327
//
328
 
329
//
330
// Block 0
331
//
332
RAMB4_S2 ramb4_s2_0(
333
        .CLK(clk),
334
        .RST(rst),
335
        .ADDR(addr),
336
        .DI(di[1:0]),
337
        .EN(ce),
338
        .WE(we[0]),
339 1291 lampret
        .DO(doq[1:0])
340 1186 simons
);
341
 
342
//
343
// Block 1
344
//
345
RAMB4_S2 ramb4_s2_1(
346
        .CLK(clk),
347
        .RST(rst),
348
        .ADDR(addr),
349
        .DI(di[3:2]),
350
        .EN(ce),
351
        .WE(we[0]),
352 1291 lampret
        .DO(doq[3:2])
353 1186 simons
);
354
 
355
//
356
// Block 2
357
//
358
RAMB4_S2 ramb4_s2_2(
359
        .CLK(clk),
360
        .RST(rst),
361
        .ADDR(addr),
362
        .DI(di[5:4]),
363
        .EN(ce),
364
        .WE(we[0]),
365 1291 lampret
        .DO(doq[5:4])
366 1186 simons
);
367
 
368
//
369
// Block 3
370
//
371
RAMB4_S2 ramb4_s2_3(
372
        .CLK(clk),
373
        .RST(rst),
374
        .ADDR(addr),
375
        .DI(di[7:6]),
376
        .EN(ce),
377
        .WE(we[0]),
378 1291 lampret
        .DO(doq[7:6])
379 1194 dries
);
380 1186 simons
//
381
// Block 4
382
//
383
RAMB4_S2 ramb4_s2_4(
384
        .CLK(clk),
385
        .RST(rst),
386
        .ADDR(addr),
387
        .DI(di[9:8]),
388
        .EN(ce),
389
        .WE(we[1]),
390 1291 lampret
        .DO(doq[9:8])
391 1186 simons
);
392
 
393
//
394
// Block 5
395
//
396
RAMB4_S2 ramb4_s2_5(
397
        .CLK(clk),
398
        .RST(rst),
399
        .ADDR(addr),
400
        .DI(di[11:10]),
401
        .EN(ce),
402
        .WE(we[1]),
403 1291 lampret
        .DO(doq[11:10])
404 1186 simons
);
405
 
406
//
407
// Block 6
408
//
409
RAMB4_S2 ramb4_s2_6(
410
        .CLK(clk),
411
        .RST(rst),
412
        .ADDR(addr),
413
        .DI(di[13:12]),
414
        .EN(ce),
415
        .WE(we[1]),
416 1291 lampret
        .DO(doq[13:12])
417 1186 simons
);
418
 
419
//
420
// Block 7
421
//
422
RAMB4_S2 ramb4_s2_7(
423
        .CLK(clk),
424
        .RST(rst),
425
        .ADDR(addr),
426
        .DI(di[15:14]),
427
        .EN(ce),
428
        .WE(we[1]),
429 1291 lampret
        .DO(doq[15:14])
430 1194 dries
);
431 1186 simons
//
432
// Block 8
433
//
434
RAMB4_S2 ramb4_s2_8(
435
        .CLK(clk),
436
        .RST(rst),
437
        .ADDR(addr),
438
        .DI(di[17:16]),
439
        .EN(ce),
440
        .WE(we[2]),
441 1291 lampret
        .DO(doq[17:16])
442 1186 simons
);
443
 
444
//
445
// Block 9
446
//
447
RAMB4_S2 ramb4_s2_9(
448
        .CLK(clk),
449
        .RST(rst),
450
        .ADDR(addr),
451
        .DI(di[19:18]),
452
        .EN(ce),
453
        .WE(we[2]),
454 1291 lampret
        .DO(doq[19:18])
455 1186 simons
);
456
 
457
//
458
// Block 10
459
//
460
RAMB4_S2 ramb4_s2_10(
461
        .CLK(clk),
462
        .RST(rst),
463
        .ADDR(addr),
464
        .DI(di[21:20]),
465
        .EN(ce),
466
        .WE(we[2]),
467 1291 lampret
        .DO(doq[21:20])
468 1186 simons
);
469
 
470
//
471
// Block 11
472
//
473
RAMB4_S2 ramb4_s2_11(
474
        .CLK(clk),
475
        .RST(rst),
476
        .ADDR(addr),
477
        .DI(di[23:22]),
478
        .EN(ce),
479
        .WE(we[2]),
480 1291 lampret
        .DO(doq[23:22])
481 1194 dries
);
482 1186 simons
//
483
// Block 12
484
//
485
RAMB4_S2 ramb4_s2_12(
486
        .CLK(clk),
487
        .RST(rst),
488
        .ADDR(addr),
489
        .DI(di[25:24]),
490
        .EN(ce),
491
        .WE(we[3]),
492 1291 lampret
        .DO(doq[25:24])
493 1186 simons
);
494
 
495
//
496
// Block 13
497
//
498
RAMB4_S2 ramb4_s2_13(
499
        .CLK(clk),
500
        .RST(rst),
501
        .ADDR(addr),
502
        .DI(di[27:26]),
503
        .EN(ce),
504
        .WE(we[3]),
505 1291 lampret
        .DO(doq[27:26])
506 1186 simons
);
507
 
508
//
509
// Block 14
510
//
511
RAMB4_S2 ramb4_s2_14(
512
        .CLK(clk),
513
        .RST(rst),
514
        .ADDR(addr),
515
        .DI(di[29:28]),
516
        .EN(ce),
517
        .WE(we[3]),
518 1291 lampret
        .DO(doq[29:28])
519 1186 simons
);
520
 
521
//
522
// Block 15
523
//
524
RAMB4_S2 ramb4_s2_15(
525
        .CLK(clk),
526
        .RST(rst),
527
        .ADDR(addr),
528
        .DI(di[31:30]),
529
        .EN(ce),
530
        .WE(we[3]),
531 1291 lampret
        .DO(doq[31:30])
532 1194 dries
);
533 1186 simons
 
534
`else
535
 
536
//
537
// Generic single-port synchronous RAM model
538
//
539
 
540
//
541
// Generic RAM's registers and wires
542
//
543 1291 lampret
reg     [7:0]        mem_0 [2047:0];              // RAM content
544
reg     [7:0]        mem_1 [2047:0];              // RAM content
545
reg     [7:0]        mem_2 [2047:0];              // RAM content
546
reg     [7:0]        mem_3 [2047:0];              // RAM content
547
reg     [10:0]       addr_reg;                    // RAM address register
548
 
549 1186 simons
//
550
// Data output drivers
551
//
552 1291 lampret
assign doq = (oe) ? {mem_3[addr_reg], mem_2[addr_reg], mem_1[addr_reg], mem_0[addr_reg]} : {32{1'b0}};
553
 
554 1186 simons
//
555 1291 lampret
// RAM address register
556 1186 simons
//
557 1291 lampret
always @(posedge clk or posedge rst)
558
        if (rst)
559
                addr_reg <= #1 11'h000;
560
        else if (ce)
561
                addr_reg <= #1 addr;
562
 
563
//
564
// RAM write byte 0
565
//
566 1186 simons
always @(posedge clk)
567 1291 lampret
        if (ce && we[0])
568 1186 simons
                mem_0[addr] <= #1 di[7:0];
569 1291 lampret
 
570
//
571
// RAM write byte 1
572
//
573
always @(posedge clk)
574
        if (ce && we[1])
575 1186 simons
                mem_1[addr] <= #1 di[15:8];
576 1291 lampret
 
577
//
578
// RAM write byte 2
579
//
580
always @(posedge clk)
581
        if (ce && we[2])
582 1186 simons
                mem_2[addr] <= #1 di[23:16];
583 1291 lampret
 
584
//
585
// RAM write byte 3
586
//
587
always @(posedge clk)
588
        if (ce && we[3])
589 1186 simons
                mem_3[addr] <= #1 di[31:24];
590
 
591
`endif  // !OR1200_XILINX_RAMB4_S16
592
`endif  // !OR1200_VIRTUALSILICON_SSP
593
`endif  // !OR1200_VIRAGE_SSP
594
`endif  // !OR1200_AVANT_ATP
595
`endif  // !OR1200_ARTISAN_SSP
596
 
597
endmodule

powered by: WebSVN 2.1.0

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