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

Subversion Repositories or1k

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

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

powered by: WebSVN 2.1.0

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