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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [or1200/] [rtl/] [verilog/] [or1200_spram_2048x32_bw.v] - Blame information for rev 39

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

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

powered by: WebSVN 2.1.0

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