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

Subversion Repositories mem_ctrl

[/] [mem_ctrl/] [trunk/] [bench/] [verilog/] [test_bench_top.v] - Blame information for rev 23

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

Line No. Rev Author Line
1 4 rudi
/////////////////////////////////////////////////////////////////////
2
////                                                             ////
3
////  Top Level Test Bench                                       ////
4
////                                                             ////
5
////                                                             ////
6
////  Author: Rudolf Usselmann                                   ////
7
////          rudi@asics.ws                                      ////
8
////                                                             ////
9
////                                                             ////
10
////  Downloaded from: http://www.opencores.org/cores/mem_ctrl/  ////
11
////                                                             ////
12
/////////////////////////////////////////////////////////////////////
13
////                                                             ////
14 23 rudi
//// Copyright (C) 2000-2002 Rudolf Usselmann                    ////
15
////                         www.asics.ws                        ////
16
////                         rudi@asics.ws                       ////
17 4 rudi
////                                                             ////
18
//// This source file may be used and distributed without        ////
19
//// restriction provided that this copyright statement is not   ////
20
//// removed from the file and that any derivative work contains ////
21
//// the original copyright notice and the associated disclaimer.////
22
////                                                             ////
23
////     THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY     ////
24
//// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED   ////
25
//// TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS   ////
26
//// FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL THE AUTHOR      ////
27
//// OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,         ////
28
//// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES    ////
29
//// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE   ////
30
//// GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR        ////
31
//// BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF  ////
32
//// LIABILITY, WHETHER IN  CONTRACT, STRICT LIABILITY, OR TORT  ////
33
//// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT  ////
34
//// OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE         ////
35
//// POSSIBILITY OF SUCH DAMAGE.                                 ////
36
////                                                             ////
37
/////////////////////////////////////////////////////////////////////
38
 
39
//  CVS Log
40
//
41 23 rudi
//  $Id: test_bench_top.v,v 1.7 2002-01-21 13:10:37 rudi Exp $
42 4 rudi
//
43 23 rudi
//  $Date: 2002-01-21 13:10:37 $
44
//  $Revision: 1.7 $
45 4 rudi
//  $Author: rudi $
46
//  $Locker:  $
47
//  $State: Exp $
48
//
49
// Change History:
50
//               $Log: not supported by cvs2svn $
51 23 rudi
//               Revision 1.6  2001/11/29 02:17:36  rudi
52
//
53
//
54
//               - More Synthesis cleanup, mostly for speed
55
//               - Several bug fixes
56
//               - Changed code to avoid auto-precharge and
57
//                 burst-terminate combinations (apparently illegal ?)
58
//                 Now we will do a manual precharge ...
59
//
60 16 rudi
//               Revision 1.5  2001/11/13 00:45:15  rudi
61
//
62
//               Just minor test bench update, syncing all the files.
63
//
64 15 rudi
//               Revision 1.4  2001/11/11 01:52:02  rudi
65
//
66
//               Minor fixes to testbench ...
67
//
68 14 rudi
//               Revision 1.3  2001/09/02 02:29:43  rudi
69
//
70
//               Fixed the TMS register setup to be tight and correct.
71
//
72 10 rudi
//               Revision 1.2  2001/08/10 08:16:21  rudi
73
//
74
//               - Changed IO names to be more clear.
75
//               - Uniquifyed define names to be core specific.
76
//               - Removed "Refresh Early" configuration
77
//
78 8 rudi
//               Revision 1.1  2001/07/29 07:34:40  rudi
79
//
80
//
81
//               1) Changed Directory Structure
82
//               2) Fixed several minor bugs
83
//
84 4 rudi
//               Revision 1.2  2001/06/03 11:34:18  rudi
85
//               *** empty log message ***
86
//
87
//               Revision 1.1.1.1  2001/05/13 09:36:32  rudi
88
//               Created Directory Structure
89
//
90
//
91
//
92
//                        
93
 
94
`include "mc_defines.v"
95
 
96
module test;
97
 
98
reg             clk;
99
reg             rst;
100
 
101
// IO Prototypes
102
 
103
wire    [31:0]   wb_data_i;
104
wire    [31:0]   wb_data_o;
105
wire    [31:0]   wb_addr_i;
106
wire    [3:0]    wb_sel_i;
107
wire            wb_we_i;
108
wire            wb_cyc_i;
109
wire            wb_stb_i;
110
wire            wb_ack_o;
111
wire            wb_err_o;
112
wire            wb_rty_o;
113
 
114
reg             susp_req, resume_req;
115
wire            suspended;
116
wire    [31:0]   poc;
117
 
118
reg             mc_clk;
119
reg             mc_br;
120
wire            mc_bg;
121
wire            mc_ack;
122
wire    [23:0]   mc_addr;
123
wire    [31:0]   mc_data_i;
124
wire    [31:0]   mc_data_o;
125
wire    [3:0]    mc_dp_i;
126
wire    [3:0]    mc_dp_o;
127
wire            mc_data_oe;
128
wire    [3:0]    mc_dqm;
129
wire            mc_oe_;
130
wire            mc_we_;
131
wire            mc_cas_;
132
wire            mc_ras_;
133
wire            mc_cke_;
134
wire    [7:0]    mc_cs_;
135
wire            mc_sts;
136
wire            mc_rp_;
137
wire            mc_vpen;
138
wire            mc_adsc_;
139
wire            mc_adv_;
140
wire            mc_zz;
141
wire            mc_c_oe;
142
 
143
 
144
// Test Bench Variables
145
reg     [31:0]   wd_cnt;
146
integer         error_cnt;
147
integer         verbose;
148
integer         poc_mode;
149
reg             wb_err_check_dis;
150 10 rudi
integer         LVL;
151 4 rudi
 
152
integer cyc_cnt;
153
integer ack_cnt;
154
 
155
// Misc Variables
156
 
157
integer         n,m;
158
 
159
reg     [31:0]   data;
160
 
161
reg     [31:0]   buffer32;
162
integer         del, size;
163
reg     [7:0]    mode;
164
reg     [2:0]    bs;
165
integer         sz_inc;
166
integer         read, write;
167
integer         done;
168
integer         adr;
169 23 rudi
integer         do_quick;
170 4 rudi
 
171
/////////////////////////////////////////////////////////////////////
172
//
173
// Defines 
174
//
175
 
176
`define MEM_BASE        32'h0000_0000
177
`define MEM_BASE1       32'h0400_0000
178
`define MEM_BASE2       32'h0800_0000
179
`define MEM_BASE3       32'h0c00_0000
180
`define MEM_BASE4       32'h1000_0000
181
`define MEM_BASE5       32'h1400_0000
182
`define MEM_BASE6       32'h1800_0000
183 14 rudi
`define REG_BASE        32'h6000_0000
184 4 rudi
 
185
`define CSR             8'h00
186
`define POC             8'h04
187
`define BA_MASK         8'h08
188
 
189
`define CSC0            8'h10
190
`define TMS0            8'h14
191
`define CSC1            8'h18
192
`define TMS1            8'h1c
193
`define CSC2            8'h20
194
`define TMS2            8'h24
195
`define CSC3            8'h28
196
`define TMS3            8'h2c
197
`define CSC4            8'h30
198
`define TMS4            8'h34
199
`define CSC5            8'h38
200
`define TMS5            8'h3c
201
`define CSC6            8'h40
202
`define TMS6            8'h44
203
`define CSC7            8'h48
204
`define TMS7            8'h4c
205
 
206
/////////////////////////////////////////////////////////////////////
207
//
208
// Simulation Initialization and Start up Section
209
//
210
 
211
`define SDRAM0          1
212
`define SRAM            1
213
`define MULTI_SDRAM     1
214
`define FLASH           1
215
`define MICRON          1
216
 
217
initial
218
   begin
219
        $display("\n\n");
220
        $display("*****************************************************");
221
        $display("* WISHBONE Memory Controller Simulation started ... *");
222
        $display("*****************************************************");
223
        $display("\n");
224
`ifdef WAVES
225
        $shm_open("waves");
226
        $shm_probe("AS",test,"AS");
227
        $display("INFO: Signal dump enabled ...\n\n");
228
`endif
229 23 rudi
        do_quick = 0;
230 4 rudi
        poc_mode = 1;
231
        #1;
232
        poc_mode = 0;
233
        wb_err_check_dis=0;
234
        cyc_cnt = 0;
235
        ack_cnt = 0;
236
        wd_cnt = 0;
237
        error_cnt = 0;
238
        clk = 1;
239
        mc_clk = 0;
240 14 rudi
        rst = 1;
241 4 rudi
        susp_req = 0;
242
        resume_req = 0;
243
        verbose = 1;
244
        mc_br = 0;
245
 
246 10 rudi
        repeat(11)      @(posedge clk);
247
        #1;
248 14 rudi
        rst = 0;
249 4 rudi
        repeat(10)      @(posedge clk);
250
 
251
        // HERE IS WHERE THE TEST CASES GO ...
252
 
253 16 rudi
        LVL = 2;
254
if(0)    // Full Regression Run
255 4 rudi
   begin
256
$display(" ......................................................");
257
$display(" :                                                    :");
258
$display(" :    Long Regression Run ...                         :");
259
$display(" :....................................................:");
260
        verbose = 0;
261
`ifdef FLASH
262
        boot(0);
263
`endif
264
 
265
        m0.wb_wr1(`REG_BASE + `CSC3,    4'hf, 32'h0000_0000);
266
        sdram_wr1(0);
267
        sdram_rd1(0);
268
        sdram_rd2(0);
269
        sdram_wr2(0);
270
        sdram_rd3(0);
271
        sdram_wr3(0);
272
        sdram_rd4(0);
273
        sdram_wr4(0);
274
        sdram_wp(0);
275 23 rudi
        sdram_bo;
276 4 rudi
        sdram_rmw1(0);
277
        sdram_rmw2(0);
278 16 rudi
        rmw_cross1(0);
279 4 rudi
 
280
`ifdef MULTI_SDRAM
281
        sdram_rd5(0);
282
        sdram_wr5(0);
283
`endif
284
 
285
`ifdef FLASH
286
        asc_rdwr1(0);
287
`endif
288
 
289
`ifdef SRAM
290
        sram_rd1;
291
        sram_wr1;
292
        sram_wp;
293
        sram_rmw1;
294
        sram_rmw2;
295
`endif
296
 
297
        scs_rdwr1(0);
298
   end
299
else
300 15 rudi
if(1)   // Quick Regression Run
301 4 rudi
   begin
302
$display(" ......................................................");
303
$display(" :                                                    :");
304
$display(" :    Short Regression Run ...                        :");
305
$display(" :....................................................:");
306 23 rudi
        do_quick = 1;
307 4 rudi
        verbose = 0;
308 23 rudi
        LVL = 1;
309 16 rudi
 
310 4 rudi
`ifdef FLASH
311 16 rudi
        boot(LVL);
312 4 rudi
`endif
313
        m0.wb_wr1(`REG_BASE + `CSC3,    4'hf, 32'h0000_0000);
314 8 rudi
 
315 16 rudi
        sdram_rd1(LVL);
316
        sdram_wr1(LVL);
317 4 rudi
 
318 16 rudi
        sdram_rd2(LVL);
319
        sdram_wr2(LVL);
320 4 rudi
 
321 16 rudi
        sdram_rd3(LVL);
322
        sdram_wr3(LVL);
323 4 rudi
 
324 16 rudi
        sdram_rd4(LVL);
325
        sdram_wr4(LVL);
326 4 rudi
 
327 16 rudi
        sdram_wp(LVL);
328 23 rudi
        sdram_bo;
329 16 rudi
        sdram_rmw1(LVL);
330
        sdram_rmw2(LVL);
331
        rmw_cross1(LVL);
332 4 rudi
 
333
`ifdef MULTI_SDRAM
334 16 rudi
        sdram_rd5(LVL);
335
        sdram_wr5(LVL);
336 4 rudi
`endif
337
 
338 10 rudi
 
339 4 rudi
`ifdef FLASH
340 16 rudi
        asc_rdwr1(LVL);
341 4 rudi
`endif
342
 
343
`ifdef SRAM
344
        sram_rd1;
345
        sram_wr1;
346
        sram_wp;
347
        sram_rmw1;
348
        sram_rmw2;
349
`endif
350 16 rudi
        scs_rdwr1(LVL);
351 4 rudi
 
352 14 rudi
        mc_reset;
353 4 rudi
   end
354 23 rudi
if(do_quick)    // Suspend resume testing
355 4 rudi
begin
356
$display(" ......................................................");
357
$display(" :                                                    :");
358
$display(" :    Suspend Resume Testing ...                      :");
359
$display(" :....................................................:");
360 23 rudi
        //verbose = 0;
361
        //LVL = 1;
362 4 rudi
        done = 0;
363
        fork
364
           begin
365 10 rudi
 
366 4 rudi
`ifdef FLASH
367 10 rudi
                boot(LVL);
368 4 rudi
`endif
369
                m0.wb_wr1(`REG_BASE + `CSC3,    4'hf, 32'h0000_0000);
370 10 rudi
 
371 4 rudi
                while(susp_req | suspended)     @(posedge clk);
372 10 rudi
                sdram_rd1(LVL);
373 4 rudi
                while(susp_req | suspended)     @(posedge clk);
374 10 rudi
                sdram_wr1(LVL);
375 4 rudi
                while(susp_req | suspended)     @(posedge clk);
376 10 rudi
                sdram_rd2(LVL);
377
 
378 4 rudi
                while(susp_req | suspended)     @(posedge clk);
379 10 rudi
                sdram_wr2(LVL);
380
 
381 4 rudi
                while(susp_req | suspended)     @(posedge clk);
382 10 rudi
                sdram_rd3(LVL);
383 4 rudi
                while(susp_req | suspended)     @(posedge clk);
384 10 rudi
                sdram_wr3(LVL);
385 4 rudi
                while(susp_req | suspended)     @(posedge clk);
386 10 rudi
                sdram_rd4(LVL);
387 4 rudi
                while(susp_req | suspended)     @(posedge clk);
388 10 rudi
                sdram_wr4(LVL);
389 4 rudi
 
390
                while(susp_req | suspended)     @(posedge clk);
391 10 rudi
                sdram_wp(LVL);
392 4 rudi
                while(susp_req | suspended)     @(posedge clk);
393 23 rudi
                sdram_bo;
394
                while(susp_req | suspended)     @(posedge clk);
395 10 rudi
                sdram_rmw1(LVL);
396 4 rudi
                while(susp_req | suspended)     @(posedge clk);
397 10 rudi
                sdram_rmw2(LVL);
398 23 rudi
 
399 16 rudi
                while(susp_req | suspended)     @(posedge clk);
400
                rmw_cross1(LVL);
401 4 rudi
 
402 23 rudi
 
403 4 rudi
`ifdef MULTI_SDRAM
404
                while(susp_req | suspended)     @(posedge clk);
405 10 rudi
                sdram_rd5(LVL);
406 4 rudi
                while(susp_req | suspended)     @(posedge clk);
407 10 rudi
                sdram_wr5(LVL);
408 4 rudi
`endif
409
 
410
`ifdef FLASH
411
                while(susp_req | suspended)     @(posedge clk);
412 10 rudi
                asc_rdwr1(LVL);
413 4 rudi
`endif
414
 
415
`ifdef SRAM
416
                while(susp_req | suspended)     @(posedge clk);
417
                sram_rd1;
418
                while(susp_req | suspended)     @(posedge clk);
419
                sram_wr1;
420
                while(susp_req | suspended)     @(posedge clk);
421
                sram_wp;
422
                while(susp_req | suspended)     @(posedge clk);
423 10 rudi
                sram_wp;
424
                while(susp_req | suspended)     @(posedge clk);
425 4 rudi
                sram_rmw1;
426 10 rudi
 
427 4 rudi
                while(susp_req | suspended)     @(posedge clk);
428 10 rudi
                sram_rmw1;
429
                while(susp_req | suspended)     @(posedge clk);
430 4 rudi
                sram_rmw2;
431
`endif
432 16 rudi
                while(susp_req | suspended)     @(posedge clk);
433
                scs_rdwr1(LVL);
434 4 rudi
 
435
                done = 1;
436
           end
437
 
438
           begin
439
                repeat(50)      @(posedge clk);
440
                while(!done)
441
                   begin
442
                        repeat(40)      @(posedge clk);
443
                        susp_res;
444
                   end
445
           end
446
        join
447 14 rudi
 
448
        mc_reset;
449 4 rudi
end
450 23 rudi
if(do_quick)    // Bus Request testing
451 4 rudi
begin
452
$display(" ......................................................");
453
$display(" :                                                    :");
454
$display(" :    Bus Request/Grant Testing ...                   :");
455
$display(" :....................................................:");
456
        verbose = 0;
457
        done = 0;
458
        fork
459
           begin
460
`ifdef FLASH
461 10 rudi
                boot(LVL);
462 4 rudi
`endif
463 16 rudi
 
464 4 rudi
                m0.wb_wr1(`REG_BASE + `CSC3,    4'hf, 32'h0000_0000);
465 16 rudi
 
466 10 rudi
                sdram_rd1(LVL);
467
                sdram_wr1(LVL);
468
                sdram_rd1(LVL);
469
                sdram_wr1(LVL);
470
                sdram_rd3(LVL);
471
                sdram_wr3(LVL);
472
                sdram_rd4(LVL);
473
                sdram_wr4(LVL);
474
                sdram_wp(LVL);
475 23 rudi
                sdram_bo;
476 10 rudi
                sdram_rmw1(LVL);
477
                sdram_rmw2(LVL);
478 4 rudi
 
479
`ifdef MULTI_SDRAM
480 10 rudi
                sdram_rd5(LVL);
481
                sdram_wr5(LVL);
482 4 rudi
`endif
483
 
484 16 rudi
 
485 4 rudi
`ifdef FLASH
486 10 rudi
                asc_rdwr1(LVL);
487 4 rudi
`endif
488
 
489
`ifdef SRAM
490
                sram_rd1;
491
                sram_wr1;
492
                sram_wp;
493
                sram_rmw1;
494
                sram_rmw2;
495
`endif
496 16 rudi
                scs_rdwr1(LVL);
497 4 rudi
                done = 1;
498
           end
499
 
500
           begin
501
                repeat(50)      @(posedge clk);
502
                while(!done)
503
                   begin
504
                        repeat(40)      @(posedge clk);
505
                        bus_req;
506
                   end
507
           end
508
 
509
        join
510
end
511
else
512 23 rudi
if(0)    // Debug Tests
513 4 rudi
   begin
514
$display(" ......................................................");
515
$display(" :                                                    :");
516
$display(" :    Test Debug Testing ...                          :");
517
$display(" :....................................................:");
518 23 rudi
        verbose = 0;
519 4 rudi
        //boot(2);
520 16 rudi
 
521 4 rudi
        m0.wb_wr1(`REG_BASE + `CSC3,    4'hf, 32'h0000_0000);
522 14 rudi
        //sdram_rd1(2);
523
        //sdram_wr1(2);
524
        //asc_rdwr1(2);
525 16 rudi
//      sram_rd1;
526
//      sram_wr1;
527 8 rudi
        //sram_rmw1;
528 4 rudi
        //sram_rmw2;
529 8 rudi
        //sram_wp;
530 16 rudi
        //scs_rdwr1(2);
531 4 rudi
 
532
        //scs_rdwr1(2);
533
 
534
        //asc_rdwr1(2);
535
        //asc_rdwr1_x(2);
536
 
537 10 rudi
        //sdram_wp(2);
538
        //sdram_rmw1(2);
539 8 rudi
        //sdram_rmw2(2);
540
 
541 10 rudi
        //sdram_rd2(2);
542
        //sdram_wr2(2);
543 14 rudi
 
544
        //sdram_bo;
545
        //sdram_rd1b(2);
546
 
547 16 rudi
 
548
 
549 14 rudi
 
550 16 rudi
        //sdram_rd4(2);
551
        //sdram_wr4(2);
552 14 rudi
        //sdram_rd5(2);
553
        //sdram_wr5(2);
554 16 rudi
 
555
        //sdram_wp(2);
556
        //sdram_rmw1(2);
557
        //sdram_rmw2(2); 
558
 
559
 
560
        //rmw_cross1(2);
561
 
562 4 rudi
/*
563 16 rudi
        sram_rd1;
564
        sram_wr1;
565
        sram_rmw1;
566
        sram_rmw2;
567
        sram_wp;
568
*/
569
 
570
 
571 4 rudi
        sdram_rd1(2);
572 10 rudi
        sdram_wr1(2);
573
        sdram_rd2(2);
574
        sdram_wr2(2);
575
        sdram_rd3(2);
576
        sdram_wr3(2);
577
        sdram_rd4(2);
578
        sdram_wr4(2);
579 23 rudi
 
580
 
581 10 rudi
        sdram_rd5(2);
582
        sdram_wr5(2);
583 16 rudi
 
584 10 rudi
        sdram_wp(2);
585 23 rudi
 
586 10 rudi
        sdram_rmw1(2);
587 14 rudi
        sdram_rmw2(2);
588 16 rudi
        rmw_cross1(2);
589 14 rudi
 
590 4 rudi
 
591 23 rudi
 
592
 
593 4 rudi
        repeat(100)     @(posedge clk);
594
        $finish;
595
   end
596 14 rudi
else
597 4 rudi
   begin
598
 
599
        //
600
        // TEST DEVELOPMENT AREA
601
        //
602 10 rudi
        $display("\n\n");
603
        $display("*****************************************************");
604
        $display("*** Test Development ...                          ***");
605 16 rudi
        $display("*****************************************************\n");
606 4 rudi
 
607
 
608 10 rudi
        show_errors;
609
        $display("*****************************************************");
610
        $display("*** Test DONE ...                                 ***");
611
        $display("*****************************************************\n\n");
612
   end
613 4 rudi
 
614 10 rudi
        repeat(100)     @(posedge clk);
615
        $finish;
616 4 rudi
 
617 10 rudi
end     // End of Initial
618 4 rudi
 
619
 
620 10 rudi
/////////////////////////////////////////////////////////////////////
621
//
622
// Clock Generation
623
//
624 4 rudi
 
625 10 rudi
always #2.5     clk = ~clk;
626 4 rudi
 
627 10 rudi
always @(posedge clk)
628
        mc_clk <= ~mc_clk;
629 4 rudi
 
630 10 rudi
/////////////////////////////////////////////////////////////////////
631
//
632
// IO Monitors
633
//
634 4 rudi
 
635 10 rudi
`define STD     10
636
always @(posedge clk)
637
        if((wb_ack_o === 1'bx) & ($time > `STD) )
638
           begin
639
                $display("ERROR: Wishbone ACK unknown (%t)", $time);
640
                error_cnt = error_cnt + 1;
641
           end
642 4 rudi
 
643 10 rudi
always @(posedge clk)
644
        if( (wb_err_o === 1'bx) & ($time > `STD) )
645 4 rudi
 
646 10 rudi
           begin
647
                $display("ERROR: Wishbone ERR unknown (%t)", $time);
648
                error_cnt = error_cnt + 1;
649
           end
650 4 rudi
 
651 10 rudi
always @(posedge clk)
652
        if( (mc_ras_ === 1'bx) & ($time > `STD) )
653 4 rudi
 
654 10 rudi
           begin
655
                $display("ERROR: MC RAS unknown (%t)", $time);
656
                error_cnt = error_cnt + 1;
657
           end
658 4 rudi
 
659 10 rudi
always @(posedge clk)
660
        if( (mc_cas_ === 1'bx) & ($time > `STD) )
661 4 rudi
 
662
           begin
663 10 rudi
                $display("ERROR: MC CAS unknown (%t)", $time);
664
                error_cnt = error_cnt + 1;
665
           end
666 4 rudi
 
667 10 rudi
always @(posedge clk)
668
        if( (mc_we_ === 1'bx) & ($time > `STD) )
669 4 rudi
 
670 10 rudi
           begin
671
                $display("ERROR: MC WE unknown (%t)", $time);
672
                error_cnt = error_cnt + 1;
673
           end
674 4 rudi
 
675 10 rudi
always @(posedge clk)
676
        if( ((|mc_cs_) === 1'bx) & ($time > `STD) )
677 4 rudi
 
678 10 rudi
           begin
679
                $display("ERROR: MC CS unknown (%t)", $time);
680
                error_cnt = error_cnt + 1;
681 4 rudi
           end
682
 
683 10 rudi
always @(error_cnt)
684
        if(error_cnt > 25)      #500 $finish;
685 4 rudi
 
686 16 rudi
/*
687
time mc_time;
688
 
689
always @(posedge mc_clk)
690
        mc_time = $time;
691
 
692
always @(mc_cke_)
693
        if($time != (mc_time+1) )
694
                $display("WARNING: Unsexpected change of CKE (%t)", $time);
695
*/
696
 
697 4 rudi
/////////////////////////////////////////////////////////////////////
698
//
699
// IO Buffers
700
//
701
 
702 23 rudi
reg     rst_r1, rst_r2, rst_r3, rst_r4;
703
 
704
always @(posedge clk or posedge rst)
705
        if(rst)         rst_r1 <= #1 1'b1;
706
        else            rst_r1 <= #1 1'b0;
707
 
708
always @(posedge clk or posedge rst)
709
        if(rst)         rst_r2 <= #1 1'b1;
710
        else            rst_r2 <= #1 rst_r1;
711
 
712
always @(posedge clk or posedge rst)
713
        if(rst)         rst_r3 <= #1 1'b1;
714
        else            rst_r3 <= #1 rst_r2;
715
 
716
always @(posedge clk or posedge rst)
717
        if(rst)         rst_r4 <= #1 1'b1;
718
        else            rst_r4 <= #1 rst_r3;
719
 
720
 
721 4 rudi
wire    [31:0]   mc_dq;
722
wire    [3:0]    mc_dqp;
723
wire    [23:0]   _mc_addr;
724
wire    [3:0]    _mc_dqm;
725
wire            _mc_oe_;
726
wire            _mc_we_;
727
wire            _mc_cas_;
728
wire            _mc_ras_;
729
wire            _mc_cke_;
730
wire    [7:0]    _mc_cs_;
731
wire            _mc_rp_;
732
wire            _mc_vpen;
733
wire            _mc_adsc_;
734
wire            _mc_adv_;
735
wire            _mc_zz;
736
reg     [31:0]   rst_dq_val;
737
 
738
always @(poc_mode)
739
        case(poc_mode)
740
           0: rst_dq_val = {28'hzzz_zzzz, 2'b10, 2'b00};
741
           1: rst_dq_val = {28'hzzz_zzzz, 2'b10, 2'b01};
742
           2: rst_dq_val = {28'hzzz_zzzz, 2'b10, 2'b10};
743
         //  3: rst_dq_val = {28'hzzzz_zzzz, 2'b10, 2'b11};
744
           default: rst_dq_val = 32'hzzzz_zzzz;
745
        endcase
746
 
747 23 rudi
assign  mc_dq = mc_data_oe ? mc_data_o : (rst_r4 ? rst_dq_val : 32'hzzzz_zzzz);
748 14 rudi
assign  mc_data_i = mc_dq;
749
 
750
assign  mc_dqp = mc_data_oe ? mc_dp_o : 4'hz;
751
assign  mc_dp_i = mc_dqp;
752
 
753
assign  mc_addr = mc_c_oe ? _mc_addr : 24'bz;
754
assign  mc_dqm = mc_c_oe ? _mc_dqm : 4'bz;
755
assign  mc_oe_ = mc_c_oe ? _mc_oe_ : 1'bz;
756
assign  mc_we_ = mc_c_oe ? _mc_we_ : 1'bz;
757
assign  mc_cas_ = mc_c_oe ? _mc_cas_ : 1'bz;
758
assign  mc_ras_ = mc_c_oe ? _mc_ras_ : 1'bz;
759 16 rudi
assign  mc_cke_ = mc_c_oe ? _mc_cke_ : 1'bz;
760 14 rudi
assign  mc_cs_ = mc_c_oe ? _mc_cs_ : 8'bz;
761
assign  mc_rp_ = mc_c_oe ? _mc_rp_ : 1'bz;
762
assign  mc_vpen = mc_c_oe ? _mc_vpen : 1'bz;
763
assign  mc_adsc_ = mc_c_oe ? _mc_adsc_ : 1'bz;
764
assign  mc_adv_ = mc_c_oe ? _mc_adv_ : 1'bz;
765
assign  mc_zz = mc_c_oe ? _mc_zz : 1'bz;
766
 
767 4 rudi
pullup p0(mc_cas_);
768
pullup p1(mc_ras_);
769
pullup p2(mc_oe_);
770
pullup p3(mc_we_);
771
pullup p4(mc_cke_);
772
pullup p5(mc_adsc_);
773
pullup p6(mc_adv_);
774
pullup p70(mc_cs_[0]);
775
pullup p71(mc_cs_[1]);
776
pullup p72(mc_cs_[2]);
777
pullup p73(mc_cs_[3]);
778
pullup p74(mc_cs_[4]);
779
pullup p75(mc_cs_[5]);
780
pullup p76(mc_cs_[6]);
781
pullup p77(mc_cs_[7]);
782
pullup p8(mc_rp_);
783
 
784
 
785
/////////////////////////////////////////////////////////////////////
786
//
787
// WISHBONE Memory Controller IP Core
788
//
789
mc_top  u0(
790 8 rudi
                .clk_i(         clk             ),
791
                .rst_i(         rst             ),
792 4 rudi
                .wb_data_i(     wb_data_i       ),
793
                .wb_data_o(     wb_data_o       ),
794
                .wb_addr_i(     wb_addr_i       ),
795
                .wb_sel_i(      wb_sel_i        ),
796
                .wb_we_i(       wb_we_i         ),
797
                .wb_cyc_i(      wb_cyc_i        ),
798
                .wb_stb_i(      wb_stb_i        ),
799
                .wb_ack_o(      wb_ack_o        ),
800
                .wb_err_o(      wb_err_o        ),
801 8 rudi
                .susp_req_i(    susp_req        ),
802
                .resume_req_i(  resume_req      ),
803
                .suspended_o(   suspended       ),
804
                .poc_o(         poc             ),
805
                .mc_clk_i(      mc_clk          ),
806
                .mc_br_pad_i(   mc_br           ),
807
                .mc_bg_pad_o(   mc_bg           ),
808
                .mc_ack_pad_i(  mc_ack          ),
809
                .mc_addr_pad_o( _mc_addr        ),
810
                .mc_data_pad_i( mc_data_i       ),
811
                .mc_data_pad_o( mc_data_o       ),
812
                .mc_dp_pad_i(   mc_dp_i         ),
813
                .mc_dp_pad_o(   mc_dp_o         ),
814
                .mc_doe_pad_doe_o(mc_data_oe    ),
815
                .mc_dqm_pad_o(  _mc_dqm         ),
816
                .mc_oe_pad_o_(  _mc_oe_         ),
817
                .mc_we_pad_o_(  _mc_we_         ),
818
                .mc_cas_pad_o_( _mc_cas_        ),
819
                .mc_ras_pad_o_( _mc_ras_        ),
820
                .mc_cke_pad_o_( _mc_cke_        ),
821
                .mc_cs_pad_o_(  _mc_cs_         ),
822
                .mc_sts_pad_i(  mc_sts          ),
823
                .mc_rp_pad_o_(  _mc_rp_         ),
824
                .mc_vpen_pad_o( _mc_vpen        ),
825
                .mc_adsc_pad_o_(_mc_adsc_       ),
826
                .mc_adv_pad_o_( _mc_adv_        ),
827
                .mc_zz_pad_o(   _mc_zz          ),
828
                .mc_coe_pad_coe_o(mc_c_oe       )
829 4 rudi
                );
830
 
831
/////////////////////////////////////////////////////////////////////
832
//
833
// WISHBONE Master Model
834
//
835
 
836
wb_mast m0(     .clk(           clk             ),
837 14 rudi
                .rst(           ~rst            ),
838 4 rudi
                .adr(           wb_addr_i       ),
839
                .din(           wb_data_o       ),
840
                .dout(          wb_data_i       ),
841
                .cyc(           wb_cyc_i        ),
842
                .stb(           wb_stb_i        ),
843
                .sel(           wb_sel_i        ),
844
                .we(            wb_we_i         ),
845
                .ack(           wb_ack_o        ),
846
                .err(           wb_err_o        ),
847
                .rty(           wb_rty_o        )
848
                );
849
 
850
/////////////////////////////////////////////////////////////////////
851
//
852
// Sync. CS Device Model
853
//
854
 
855
sync_cs_dev s0(
856
                .clk(           mc_clk          ),
857
                .addr(          mc_addr[15:0]    ),
858
                .dq(            mc_dq           ),
859
                .cs_(           mc_cs_[5]       ),
860
                .we_(           mc_we_          ),
861
                .oe_(           mc_oe_          ),
862
                .ack_(          mc_ack          )
863
                );
864
 
865
 
866
/////////////////////////////////////////////////////////////////////
867
//
868
// Memory Models
869
//
870
 
871 23 rudi
wire    [27:0]   dq_tmp;
872
 
873 4 rudi
`ifdef SDRAM0
874
//      Model:  MT48LC2M32B2 (2Meg x 32 x 4 Banks)
875
mt48lc2m32b2 sdram0(
876
                .Dq(            mc_dq           ),
877
                .Addr(          mc_addr[10:0]    ),
878
                .Ba(            mc_addr[14:13]  ),
879
                .Clk(           mc_clk          ),
880
                .Cke(           mc_cke_         ),
881
                .Cs_n(          mc_cs_[0]        ),
882
                .Ras_n(         mc_ras_         ),
883
                .Cas_n(         mc_cas_         ),
884
                .We_n(          mc_we_          ),
885
                .Dqm(           mc_dqm          )
886
                );
887
 
888
mt48lc2m32b2 sdram0p(
889
                .Dq(            {dq_tmp, mc_dqp}),
890
                .Addr(          mc_addr[10:0]    ),
891
                .Ba(            mc_addr[14:13]  ),
892
                .Clk(           mc_clk          ),
893
                .Cke(           mc_cke_         ),
894
                .Cs_n(          mc_cs_[0]        ),
895
                .Ras_n(         mc_ras_         ),
896
                .Cas_n(         mc_cas_         ),
897
                .We_n(          mc_we_          ),
898
                .Dqm(           mc_dqm          )
899
                );
900
 
901
`endif
902
 
903
`ifdef MULTI_SDRAM
904
//      Model:  MT48LC2M32B2 (2Meg x 32 x 4 Banks)
905
 
906
mt48lc2m32b2 sdram1(
907
                .Dq(            mc_dq           ),
908
                .Addr(          mc_addr[10:0]    ),
909
                .Ba(            mc_addr[14:13]  ),
910
                .Clk(           mc_clk          ),
911
                .Cke(           mc_cke_         ),
912
                .Cs_n(          mc_cs_[1]       ),
913
                .Ras_n(         mc_ras_         ),
914
                .Cas_n(         mc_cas_         ),
915
                .We_n(          mc_we_          ),
916
                .Dqm(           mc_dqm          )
917
                );
918
 
919 23 rudi
mt48lc2m32b2 sdram1p(
920
                .Dq(            {dq_tmp, mc_dqp}        ),
921
                .Addr(          mc_addr[10:0]            ),
922
                .Ba(            mc_addr[14:13]          ),
923
                .Clk(           mc_clk                  ),
924
                .Cke(           mc_cke_                 ),
925
                .Cs_n(          mc_cs_[1]               ),
926
                .Ras_n(         mc_ras_                 ),
927
                .Cas_n(         mc_cas_                 ),
928
                .We_n(          mc_we_                  ),
929
                .Dqm(           mc_dqm                  )
930
                );
931
 
932
 
933 4 rudi
//      Model:  MT48LC2M32B2 (2Meg x 32 x 4 Banks)
934
mt48lc2m32b2 sdram2(
935
                .Dq(            mc_dq           ),
936
                .Addr(          mc_addr[10:0]    ),
937
                .Ba(            mc_addr[14:13]  ),
938
                .Clk(           mc_clk          ),
939
                .Cke(           mc_cke_         ),
940
                .Cs_n(          mc_cs_[2]       ),
941
                .Ras_n(         mc_ras_         ),
942
                .Cas_n(         mc_cas_         ),
943
                .We_n(          mc_we_          ),
944
                .Dqm(           mc_dqm          )
945
                );
946
 
947 23 rudi
mt48lc2m32b2 sdram2p(
948
                .Dq(            {dq_tmp, mc_dqp}),
949
                .Addr(          mc_addr[10:0]    ),
950
                .Ba(            mc_addr[14:13]  ),
951
                .Clk(           mc_clk          ),
952
                .Cke(           mc_cke_         ),
953
                .Cs_n(          mc_cs_[2]       ),
954
                .Ras_n(         mc_ras_         ),
955
                .Cas_n(         mc_cas_         ),
956
                .We_n(          mc_we_          ),
957
                .Dqm(           mc_dqm          )
958
                );
959 4 rudi
 
960 14 rudi
mt48lc16m16a2 sdram1a(
961 4 rudi
                .Dq(            mc_dq[15:0]      ),
962 14 rudi
                .Addr(          mc_addr[12:0]    ),
963 4 rudi
                .Ba(            mc_addr[14:13]  ),
964
                .Clk(           mc_clk          ),
965
                .Cke(           mc_cke_         ),
966 14 rudi
                .Cs_n(          mc_cs_[5]       ),
967 4 rudi
                .Ras_n(         mc_ras_         ),
968
                .Cas_n(         mc_cas_         ),
969
                .We_n(          mc_we_          ),
970
                .Dqm(           mc_dqm[1:0]      )
971
                );
972
 
973 14 rudi
mt48lc16m16a2 sdram1b(
974 4 rudi
                .Dq(            mc_dq[31:16]    ),
975 14 rudi
                .Addr(          mc_addr[12:0]    ),
976 4 rudi
                .Ba(            mc_addr[14:13]  ),
977
                .Clk(           mc_clk          ),
978
                .Cke(           mc_cke_         ),
979 14 rudi
                .Cs_n(          mc_cs_[5]       ),
980 4 rudi
                .Ras_n(         mc_ras_         ),
981
                .Cas_n(         mc_cas_         ),
982
                .We_n(          mc_we_          ),
983
                .Dqm(           mc_dqm[3:2]     )
984
                );
985
 
986
`endif
987
 
988
`ifdef FLASH
989
IntelAdvBoot f1(
990
                .dq(    mc_dq[15:0]      ),
991
                .addr(  mc_addr[19:0]    ),
992
                .ceb(   mc_cs_[3]       ),
993
                .oeb(   mc_oe_          ),
994
                .web(   mc_we_          ),
995
                .rpb(   mc_rp_          ),
996
                .wpb(   1'b0            ),
997
                .vpp(   3300            ),
998
                .vcc(   3300            )
999
                );
1000
`endif
1001
 
1002
 
1003
`ifdef SRAM
1004
 
1005
`ifdef MICRON
1006
mt58l1my18d sram0a(
1007
                .Dq(            {mc_dqp[1],
1008
                                mc_dq[15:8],
1009
                                mc_dqp[0],
1010
                                mc_dq[7:0]}      ),
1011
 
1012
                .Addr(          mc_addr[19:0]    ),
1013
                .Mode(          1'b0            ),
1014
                .Adv_n(         mc_adv_         ),
1015
                .Clk(           mc_clk          ),
1016
                .Adsc_n(        mc_adsc_        ),
1017
                .Adsp_n(        1'b1            ),
1018
 
1019
                .Bwa_n(         mc_dqm[0]        ),
1020
                .Bwb_n(         mc_dqm[1]       ),
1021
                .Bwe_n(         mc_we_          ),
1022
                .Gw_n(          1'b1            ),
1023
 
1024
                .Ce_n(          mc_cs_[4]       ),
1025
                .Ce2(           1'b1            ),
1026
                .Ce2_n(         1'b0            ),
1027
                .Oe_n(          mc_oe_          ),
1028
                .Zz(            mc_zz           )
1029
                );
1030
 
1031
 
1032
mt58l1my18d sram0b(
1033
                .Dq(            {mc_dqp[3],
1034
                                mc_dq[31:24],
1035
                                mc_dqp[2],
1036
                                mc_dq[23:16]}   ),
1037
 
1038
                .Addr(          mc_addr[19:0]    ),
1039
                .Mode(          1'b0            ),
1040
                .Adv_n(         mc_adv_         ),
1041
                .Clk(           mc_clk          ),
1042
                .Adsc_n(        mc_adsc_        ),
1043
                .Adsp_n(        1'b1            ),
1044
 
1045
                .Bwa_n(         mc_dqm[2]       ),
1046
                .Bwb_n(         mc_dqm[3]       ),
1047
                .Bwe_n(         mc_we_          ),
1048
                .Gw_n(          1'b1            ),
1049
 
1050
                .Ce_n(          mc_cs_[4]       ),
1051
                .Ce2(           1'b1            ),
1052
                .Ce2_n(         1'b0            ),
1053
                .Oe_n(          mc_oe_          ),
1054
                .Zz(            mc_zz           )
1055
                );
1056
 
1057
`else
1058
 
1059
idt71t67802s133 sram0a(
1060
                .A(     mc_addr[18:0]    ),
1061
                .D(     mc_dq[15:0]      ),
1062
                .DP(    mc_dqp[1:0]      ),
1063
                .oe_(   mc_oe_          ),
1064
                .ce_(   mc_cs_[4]       ),
1065
                .cs0(   1'b1            ),
1066
                .cs1_(  1'b0            ),
1067
                .lbo_(  1'b0            ),
1068
 
1069
                .gw_(   1'b1            ),
1070
                .bwe_(  mc_we_          ),
1071
                .bw2_(  mc_dqm[1]       ),
1072
                .bw1_(  mc_dqm[0]        ),
1073
 
1074
                .adsp_( 1'b1            ),
1075
                .adsc_( mc_adsc_        ),
1076
                .adv_(  mc_adv_         ),
1077
                .clk(   mc_clk          )
1078
                );
1079
 
1080
idt71t67802s133 sram0b(
1081
                .A(     mc_addr[18:0]    ),
1082
                .D(     mc_dq[31:16]    ),
1083
                .DP(    mc_dqp[3:2]     ),
1084
                .oe_(   mc_oe_          ),
1085
                .ce_(   mc_cs_[4]       ),
1086
                .cs0(   1'b1            ),
1087
                .cs1_(  1'b0            ),
1088
                .lbo_(  1'b0            ),
1089
 
1090
                .gw_(   1'b1            ),
1091
                .bwe_(  mc_we_          ),
1092
                .bw2_(  mc_dqm[3]       ),
1093
                .bw1_(  mc_dqm[2]       ),
1094
 
1095
                .adsp_( 1'b1            ),
1096
                .adsc_( mc_adsc_        ),
1097
                .adv_(  mc_adv_         ),
1098
                .clk(   mc_clk          )
1099
                );
1100
`endif
1101
 
1102
`endif
1103
 
1104
`include "tests.v"
1105
`include "test_lib.v"
1106
 
1107
endmodule
1108
 

powered by: WebSVN 2.1.0

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