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

Subversion Repositories or1k_soc_on_altera_embedded_dev_kit

[/] [or1k_soc_on_altera_embedded_dev_kit/] [trunk/] [soc/] [bench/] [models/] [28f016s3/] [test1s3.v] - Blame information for rev 12

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 12 xianfeng
/*
2
 INTEL DEVELOPER'S SOFTWARE LICENSE AGREEMENT
3
 
4
BY USING THIS SOFTWARE, YOU ARE AGREEING TO BE BOUND BY THE TERMS OF
5
THIS AGREEMENT.  DO NOT USE THE SOFTWARE UNTIL YOU HAVE CAREFULLY READ
6
AND AGREED TO THE FOLLOWING TERMS AND CONDITIONS.  IF YOU DO NOT AGREE
7
TO THE TERMS OF THIS AGREEMENT, PROMPTLY RETURN THE SOFTWARE PACKAGE AND
8
ANY ACCOMPANYING ITEMS.
9
 
10
IF YOU USE THIS SOFTWARE, YOU WILL BE BOUND BY THE TERMS OF THIS
11
AGREEMENT
12
 
13
LICENSE: Intel Corporation ("Intel") grants you the non-exclusive right
14
to use the enclosed software program ("Software").  You will not use,
15
copy, modify, rent, sell or transfer the Software or any portion
16
thereof, except as provided in this Agreement.
17
 
18
System OEM Developers may:
19
1.      Copy the Software for support, backup or archival purposes;
20
2.      Install, use, or distribute Intel owned Software in object code
21
        only;
22
3.      Modify and/or use Software source code that Intel directly makes
23
        available to you as an OEM Developer;
24
4.      Install, use, modify, distribute, and/or make or have made
25
        derivatives ("Derivatives") of Intel owned Software under the
26
        terms and conditions in this Agreement, ONLY if you are a System
27
        OEM Developer and NOT an end-user.
28
 
29
RESTRICTIONS:
30
 
31
YOU WILL NOT:
32
1.      Copy the Software, in whole or in part, except as provided for
33
        in this Agreement;
34
2.      Decompile or reverse engineer any Software provided in object
35
        code format;
36
3.      Distribute any Software or Derivative code to any end-users,
37
        unless approved by Intel in a prior writing.
38
 
39
TRANSFER: You may transfer the Software to another OEM Developer if the
40
receiving party agrees to the terms of this Agreement at the sole risk
41
of any receiving party.
42
 
43
OWNERSHIP AND COPYRIGHT OF SOFTWARE: Title to the Software and all
44
copies thereof remain with Intel or its vendors.  The Software is
45
copyrighted and is protected by United States and international
46
copyright laws.  You will not remove the copyright notice from the
47
Software.  You agree to prevent any unauthorized copying of the
48
Software.
49
 
50
DERIVATIVE WORK: OEM Developers that make or have made Derivatives will
51
not be required to provide Intel with a copy of the source or object
52
code.  OEM Developers shall be authorized to use, market, sell, and/or
53
distribute Derivatives to other OEM Developers at their own risk and
54
expense. Title to Derivatives and all copies thereof shall be in the
55
particular OEM Developer creating the Derivative.  Such OEMs shall
56
remove the Intel copyright notice from all Derivatives if such notice is
57
contained in the Software source code.
58
 
59
DUAL MEDIA SOFTWARE: If the Software package contains multiple media,
60
you may only use the medium appropriate for your system.
61
 
62
WARRANTY: Intel warrants that it has the right to license you to use,
63
modify, or distribute the Software as provided in this Agreement. The
64
Software is provided "AS IS".  Intel makes no representations to
65
upgrade, maintain, or support the Software at any time. Intel warrants
66
that the media on which the Software is furnished will be free from
67
defects in material and workmanship for a period of one (1) year from
68
the date of purchase.  Upon return of such defective media, Intel's
69
entire liability and your exclusive remedy shall be the replacement of
70
the Software.
71
 
72
THE ABOVE WARRANTIES ARE THE ONLY WARRANTIES OF ANY KIND, EITHER EXPRESS
73
OR IMPLIED, INCLUDING WARRANTIES OF MERCHANTABILITY OR FITNESS FOR ANY
74
PARTICULAR PURPOSE.
75
 
76
LIMITATION OF LIABILITY: NEITHER INTEL NOR ITS VENDORS OR AGENTS SHALL
77
BE LIABLE FOR ANY LOSS OF PROFITS, LOSS OF USE, LOSS OF DATA,
78
INTERRUPTION OF BUSINESS, NOR FOR INDIRECT, SPECIAL, INCIDENTAL OR
79
CONSEQUENTIAL DAMAGES OF ANY KIND WHETHER UNDER THIS AGREEMENT OR
80
OTHERWISE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
81
 
82
TERMINATION OF THIS LICENSE: Intel reserves the right to conduct or have
83
conducted audits to verify your compliance with this Agreement.  Intel
84
may terminate this Agreement at any time if you are in breach of any of
85
its terms and conditions.  Upon termination, you will immediately
86
destroy, and certify in writing the destruction of, the Software or
87
return all copies of the Software and documentation to Intel.
88
 
89
U.S. GOVERNMENT RESTRICTED RIGHTS: The Software and documentation were
90
developed at private expense and are provided with "RESTRICTED RIGHTS".
91
Use, duplication or disclosure by the Government is subject to
92
restrictions as set forth in FAR52.227-14 and DFAR252.227-7013 et seq.
93
or its successor.
94
 
95
EXPORT LAWS: You agree that the distribution and export/re-export of the
96
Software is in compliance with the laws, regulations, orders or other
97
restrictions of the U.S. Export Administration Regulations.
98
 
99
APPLICABLE LAW: This Agreement is governed by the laws of the State of
100
California and the United States, including patent and copyright laws.
101
Any claim arising out of this Agreement will be brought in Santa Clara
102
County, California.
103
 
104
*/
105
 
106
 
107
`timescale   1ns/1ns
108
 
109
 
110
module test28F016SC();
111
 
112
reg [`AddrSize-1:0]  address;
113
 
114
reg [31:0]  vcc,
115
            vpp;
116
 
117
reg         ceb,
118
            oeb,
119
            web,
120
            rpb;
121
 
122
wire        ryby;
123
 
124
reg [1:0]   rpblevel;    // 00 = VIL
125
                         // 01 = VIH
126
                         // 10 = VHH
127
 
128
reg    [`MaxOutputs-1:0]  dq_reg;
129
wire   [`MaxOutputs-1:0]  dq = dq_reg;
130
 
131
i28f016s3 IFlash (dq, address, ceb, oeb, web, rpb, ryby, vpp, vcc, rpblevel);
132
 
133
initial
134
    begin
135
//        $dumpfile("f008sc.dmp");
136
//        $dumpoff;
137
//        $dumpvars(???,dq,address,ceb,oeb,web,rpb);
138
 
139
       dq_reg = `MaxOutputs'hz;
140
       rpblevel = `rpb_vil;
141
       powerup;
142
       ReadID;
143
       //Verify READS with loose timing (OE Toggling)
144
       #100
145
       SetReadMode;
146
 
147
       $display("READ DATA, Loose Timing, toggle OE");
148
       #100
149
       ReadData(`AddrSize'h0);
150
       #100
151
       ReadData(`AddrSize'h10000);
152
       #100
153
       ReadData(`AddrSize'h1F0000);
154
       #100
155
       ReadData(`AddrSize'h1FFFFF);
156
 
157
       $display("READ DATA, Loose Timing, toggle Addr");
158
       //Verify Reads (OE LOW)
159
       #100
160
       address = `AddrSize'h3FFFF;
161
       #100
162
       address = `AddrSize'h4FFFF;
163
       #100
164
       address = `AddrSize'h5FFFF;
165
       #100
166
       oeb = `VIH;
167
 
168
       $display("SET BLOCK LOCK-BITS");
169
       #100
170
       SetBlockLockBit(`AddrSize'h000000);
171
       #100
172
       SetBlockLockBit(`AddrSize'h010000);
173
       #100
174
       SetBlockLockBit(`AddrSize'h1F0000);
175
       #100
176
       ReadID;
177
       #100
178
       oeb = `VIH;
179
 
180
       #100
181
       $display("PROGRAM DATA, Loose Timing, Block Locked");
182
       #100
183
       ProgramData(`AddrSize'h000000, `MaxOutputs'h00);
184
       #100
185
       ProgramData(`AddrSize'h010000, `MaxOutputs'h01);
186
       #100
187
       ProgramData(`AddrSize'h1F0000, `MaxOutputs'h0F);
188
       #100
189
       ProgramData(`AddrSize'h1FFFFF, `MaxOutputs'h10);
190
       #100
191
       SetReadMode;
192
       $display("READ DATA, Loose Timing, toggle OE");
193
       #100
194
       ReadData(`AddrSize'h000000);
195
       #100
196
       ReadData(`AddrSize'h010000);
197
       $display("READ DATA, Loose Timing, toggle Addr");
198
       //Verify Reads (OE LOW)
199
       #100
200
       address = `AddrSize'h1F0000;
201
       #100
202
       address = `AddrSize'h1FFFFF;
203
       #100
204
       oeb = `VIH;
205
       $display("BLOCK LOCK-BIT OVERRIDE");
206
       #100
207
       rpblevel = `rpb_vhh;
208
       #100
209
       ProgramData(`AddrSize'h000000, `MaxOutputs'h00);
210
       #100
211
       rpblevel = `rpb_vih;
212
       #100
213
       SetReadMode;
214
       #100
215
       ReadData(`AddrSize'h000000);
216
       #100
217
       oeb = `VIH;
218
 
219
       $display("CLEAR BLOCK LOCK-BITS");
220
       #100
221
       ClearBlockLockBit;
222
       $display("PROGRAM DATA, Boot Unlocked");
223
       #100
224
       ProgramData(`AddrSize'h015000, `MaxOutputs'h51);
225
       #100
226
       ProgramData(`AddrSize'h015FFF, `MaxOutputs'h22);
227
       #100
228
       ProgramData(`AddrSize'h020000, `MaxOutputs'h02);
229
       #100
230
       ProgramData(`AddrSize'h04FFFF, `MaxOutputs'h11);
231
       #100
232
       ProgramData(`AddrSize'h050001, `MaxOutputs'h12);
233
       #100
234
       ProgramData(`AddrSize'h060000, `MaxOutputs'h06);
235
       #100
236
       ProgramData(`AddrSize'h06FFFF, `MaxOutputs'hF6);
237
       #100
238
       ProgramData(`AddrSize'h1F0000, `MaxOutputs'hAA);
239
       #100
240
       ProgramData2(`AddrSize'h1FFFFF, `MaxOutputs'h55);
241
 
242
       $display("READ DATA, Loose Timing,  Toggle OE");
243
       #100
244
       SetReadMode;
245
       #100
246
       ReadData(`AddrSize'h015000);
247
       #100
248
       address = `AddrSize'h1F0000;
249
       #100
250
       address = `AddrSize'h1FFFFF;
251
       #100
252
       address = `AddrSize'h020000;
253
       #100
254
       address = `AddrSize'h0F0000;
255
       #100
256
       address = `AddrSize'h0FFFFF;
257
       #100
258
       oeb = `VIH;
259
       $display("ERASE BLOCK");
260
       #100
261
       EraseBlock(`AddrSize'h1F000F);
262
       $display("READ DATA, Loose Timing, Toggle Addr");
263
       #100
264
       SetReadMode;
265
       #100
266
       oeb = `VIL;
267
       #100
268
       address = `AddrSize'h1F0000;
269
       #100
270
       address = `AddrSize'h1FFFFF;
271
       #100
272
       address = `AddrSize'h015000;
273
       #100
274
       oeb = `VIH;
275
       begin:  WriteSuspend
276
         $display("WRITE SUSPEND TEST");
277
         #100
278
         StartProgram(`AddrSize'h050000, `MaxOutputs'h05);
279
         #150
280
         oeb = `VIH;
281
         #100
282
         oeb = `VIL;
283
         #100
284
         oeb = `VIH;
285
         #(((`AC_ProgramTime_Byte_50_12/2)*`TimerPeriod_)-1000)
286
         Suspend;
287
         #100
288
         SetReadMode;
289
         #100
290
         ReadData(`AddrSize'h04FFFF);
291
         #100
292
         ReadData(`AddrSize'h050000);
293
         #100
294
         ReadData(`AddrSize'h050001);
295
         #100
296
         oeb = `VIH;
297
         #100
298
         StartProgram(`AddrSize'h0AA000, `MaxOutputs'h66);
299
         #300
300
         Resume;
301
         #100
302
         oeb = `VIL;
303
         #((`AC_ProgramTime_Byte_50_12/2)*`TimerPeriod_)
304
         begin: Poll
305
           forever
306
             begin
307
               oeb = `VIH;
308
               #500
309
               oeb = `VIL;
310
               #500
311
               if (dq[7] == `VIH)
312
                 disable Poll;
313
             end
314
         end
315
         #300
316
         SetReadMode;
317
         #100
318
         ReadData(`AddrSize'h050001);
319
         #100
320
         ReadData(`AddrSize'h050000);
321
         #100
322
         ReadData(`AddrSize'h0AA000);
323
         #100
324
         oeb = `VIH;
325
       end  //WriteSuspend
326
       begin: BadErase
327
         $display("BAD ERASE TEST");
328
         #100
329
         address = `AddrSize'h060000;
330
         #100
331
         dq_reg = `EraseBlockCmd;
332
         #100
333
         web = `VIL;
334
         #100
335
         web = `VIH;
336
         #100
337
         dq_reg = `ReadArrayCmd;
338
         #100
339
         web = `VIL;
340
         #100
341
         web = `VIH;
342
         #100
343
         dq_reg = `MaxOutputs'hz;
344
         #100
345
         oeb = `VIL;
346
         #1000
347
         begin: Poll
348
           forever
349
             begin
350
               oeb = `VIH;
351
               #1000
352
               oeb = `VIL;
353
               #1000
354
               if (dq[7] == `VIH)
355
                 disable Poll;
356
             end
357
         end
358
       end //BadErase
359
       #200
360
       ReadCSRMode;
361
       #200
362
       ClearCSRMode;
363
       #200
364
       ReadCSRMode;
365
       #200
366
       SetReadMode;
367
       #100
368
       ReadData(`AddrSize'h060000);
369
       #100
370
       ReadData(`AddrSize'h06FFFF);
371
       #100
372
       oeb = `VIH;
373
       begin:  EraseSuspend
374
         $display("ERASE SUSPEND TEST");
375
         #100
376
         StartErase(`AddrSize'h015000);
377
         #1000
378
         oeb = `VIH;
379
         #100
380
         oeb = `VIL;
381
         #100
382
         oeb = `VIH;
383
         #(((`AC_EraseTime_Block_50_12/2)*`TimerPeriod_)-1000)
384
         Suspend;
385
         #100
386
         SetReadMode;
387
         #100
388
         ReadData(`AddrSize'h020000);
389
         #100
390
         ReadData(`AddrSize'h015FFF);
391
         #100
392
         oeb = `VIH;
393
         #300
394
         Resume;
395
         #100
396
         oeb = `VIL;
397
         #(((`AC_EraseTime_Block_50_12/2)*`TimerPeriod_)-1000)
398
         begin: Poll
399
           forever
400
             begin
401
               oeb = `VIH;
402
               #1000
403
               oeb = `VIL;
404
               #1000
405
               if (dq[7] == `VIH)
406
                 disable Poll;
407
             end
408
         end
409
         #300
410
         SetReadMode;
411
         #100
412
         ReadData(`AddrSize'h010000);
413
         #100
414
         ReadData(`AddrSize'h015FFF);
415
         #100
416
         ReadData(`AddrSize'h020000);
417
         #100
418
         oeb = `VIH;
419
       end  //EraseSuspend
420
       #300
421
       $display("Embedded Suspend Mode");
422
       begin:  EraseSuspend_
423
         #100
424
         StartErase(`AddrSize'h065000);
425
         #1000
426
         oeb = `VIH;
427
         #100
428
         oeb = `VIL;
429
         #100
430
         oeb = `VIH;
431
         #(((`AC_EraseTime_Block_50_12/2)*`TimerPeriod_)-1000)
432
         Suspend;
433
         #100
434
         SetReadMode;
435
         #100
436
         ReadData(`AddrSize'h050000);
437
         #100
438
         oeb = `VIH;
439
         begin:  WriteSuspend_
440
           $display("EMBEDDED WRITE SUSPEND TEST");
441
           #100
442
           StartProgram(`AddrSize'h0FFFFF, `MaxOutputs'h77);
443
           #150
444
           oeb = `VIH;
445
           #100
446
           oeb = `VIL;
447
           #100
448
           oeb = `VIH;
449
           #((`AC_ProgramTime_Byte_50_12/2)*`TimerPeriod_)
450
           Suspend;
451
           #100
452
           SetReadMode;
453
           #100
454
           ReadData(`AddrSize'h050001);
455
           #100
456
           ReadData(`AddrSize'h060000);
457
           #100
458
           oeb = `VIH;
459
           #300
460
           Resume;  //Write Operation
461
           #100
462
           oeb = `VIL;
463
           #500
464
//           #((`AC_ProgramTime_Byte_50_12/2)*`TimerPeriod_)
465
           begin: Poll
466
             forever
467
               begin
468
                 oeb = `VIH;
469
                 #500
470
                 oeb = `VIL;
471
                 #500
472
                 if (dq[7] == `VIH)
473
                   disable Poll;
474
               end
475
           end
476
           #300
477
           SetReadMode;
478
           #100
479
           ReadData(`AddrSize'h0FFFFF);
480
           #100
481
           oeb = `VIH;
482
         end  //WriteSuspend_
483
         #300
484
         Resume;  //Erase Operation
485
         #100
486
         oeb = `VIL;
487
         #(((`AC_EraseTime_Block_50_12/2)*`TimerPeriod_)-1000)
488
         begin: Poll
489
           forever
490
             begin
491
               oeb = `VIH;
492
               #1000
493
               oeb = `VIL;
494
               #1000
495
               if (dq[7] == `VIH)
496
                 disable Poll;
497
             end
498
         end
499
         #300
500
         SetReadMode;
501
         #100
502
         ReadData(`AddrSize'h06FFFF);
503
         #100
504
         ReadData(`AddrSize'h060000);
505
         #100
506
         ReadData(`AddrSize'h050000);
507
         #100
508
         oeb = `VIH;
509
       end  //EraseSuspend_
510
       begin: MasterLockBitTest
511
         $display("MASTER LOCK-BIT TEST");
512
         SetMasterLockBit(`AddrSize'h0);
513
         #100
514
         rpblevel = `rpb_vhh;
515
         #100
516
         SetMasterLockBit(`AddrSize'h0);
517
         #100
518
         rpblevel = `rpb_vih;
519
         #100
520
         SetBlockLockBit(`AddrSize'h090000);
521
         #100
522
         rpblevel = `rpb_vhh;
523
         #100
524
         SetBlockLockBit(`AddrSize'h080000);
525
         #100
526
         SetBlockLockBit(`AddrSize'h070000);
527
         #100
528
         rpblevel = `rpb_vih;
529
         #100
530
         ProgramData(`AddrSize'h090000, `MaxOutputs'h09);
531
         #100
532
         ProgramData(`AddrSize'h080000, `MaxOutputs'h08);
533
         #100
534
         ProgramData(`AddrSize'h070000, `MaxOutputs'h07);
535
         #200
536
         SetReadMode;
537
         #100
538
         ReadData(`AddrSize'h070000);
539
         #100
540
         ReadData(`AddrSize'h080000);
541
         #100
542
         ReadData(`AddrSize'h090000);
543
         #100
544
         oeb = `VIH;
545
         #100
546
         ClearBlockLockBit;
547
         #100
548
         rpblevel = `rpb_vhh;
549
         #100
550
         ClearBlockLockBit;
551
         #100
552
         rpblevel = `rpb_vih;
553
         #100
554
         ProgramData(`AddrSize'h080000, `MaxOutputs'h08);
555
         #100
556
         ProgramData(`AddrSize'h070000, `MaxOutputs'h07);
557
         #100
558
         SetReadMode;
559
         #100
560
         ReadData(`AddrSize'h070000);
561
         #100
562
         ReadData(`AddrSize'h080000);
563
         #100
564
         oeb = `VIH;
565
       end
566
       #100
567
       vcc = 3450;
568
       #100
569
       ReadData(`AddrSize'h000000);
570
       #100
571
       ReadData(`AddrSize'h0FFFFF);
572
       #1000
573
       powerdown;
574
       #1000 $finish;
575
    end
576
 
577
always @(dq or address or ceb or rpb or oeb or web or vcc or vpp or rpblevel)
578
  begin
579
    $display(
580
      "%d Addr = %h, Data = %h, CEb=%b, RPb=%b, OEb=%b, WEb=%d, vcc=%d, vpp = %d",
581
      $time, address, dq, ceb, rpb, oeb, web, vcc, vpp);
582
  end
583
 
584
task powerup;
585
  begin
586
    $display("  POWERUP TASK");
587
    rpb = `VIL;         //reset
588
    #100
589
    address = 0;
590
    #100
591
    web = `VIH;         //write enable high
592
    #100
593
    oeb = `VIH;         //output ts
594
    #100
595
    ceb = `VIH;         //disabled
596
    #100
597
    vcc = 5000;         //power up vcc
598
    #5000
599
    vpp = 12000;        //ramp up vpp
600
    #5000
601
    rpb = `VIH;         //out of reset
602
    rpblevel = `rpb_vih;
603
    #100
604
    oeb = `VIL;         //enable outputs
605
    #100
606
    ceb = `VIL;         //enable chip
607
  end
608
endtask
609
 
610
 
611
task powerdown;
612
  begin
613
    $display("  POWERDOWN TASK");
614
    address = 0;
615
    #100
616
    rpb = `VIL;     //reset
617
    #100
618
    oeb = `VIH;     //output ts
619
    #100
620
    web = `VIH;     //we high
621
    #100
622
    ceb = `VIH;     //disabled
623
    #100
624
    vpp = 0;        //power down vpp
625
    #5000
626
    vcc = 0;        //ramp down vcc
627
  end
628
endtask
629
 
630
 
631
task ReadData;
632
  input [`AddrSize-1:0] addr;
633
 
634
  begin
635
    $display("  READDATA TASK");
636
    oeb = `VIH;
637
    #100
638
    address = addr;
639
    #100
640
    oeb = `VIL;
641
  end
642
endtask
643
 
644
 
645
task SetReadMode;
646
  begin
647
    $display("  SETREADMODE TASK");
648
    oeb = `VIH;
649
    #100
650
    dq_reg[`Byte] = `ReadArrayCmd;
651
    #100
652
    web = `VIL;
653
    #100
654
    web = `VIH;
655
    #100
656
    dq_reg = `MaxOutputs'hz;
657
  end
658
endtask
659
 
660
 
661
task ReadID;
662
  begin
663
    $display("  READID TASK");
664
    oeb = `VIH;
665
    #100
666
    address = `AddrSize'h0;
667
    #100
668
    dq_reg[`Byte] = `ReadIDCmd;
669
    #100
670
    web = `VIL;
671
    #100
672
    web = `VIH;
673
    #100
674
    dq_reg = `MaxOutputs'hz;
675
    #100
676
    oeb = `VIL;
677
    #100
678
    address = `AddrSize'h1;
679
    #100
680
    address = `AddrSize'h3;
681
    #100
682
    address = `AddrSize'h2;
683
    #100
684
    address = `AddrSize'h10002;
685
  end
686
endtask
687
 
688
 
689
task ReadCSRMode;
690
  begin
691
    $display("  READCSR MODE TASK");
692
    oeb = `VIH;
693
    #100
694
    dq_reg[`Byte] = `ReadCSRCmd;
695
    #100
696
    web = `VIL;
697
    #100
698
    web = `VIH;
699
    #100
700
    dq_reg = `MaxOutputs'hz;
701
    #100
702
    oeb = `VIL;
703
  end
704
endtask
705
 
706
 
707
task ClearCSRMode;
708
  begin
709
    $display("  CLEARCSRMODE TASK");
710
    oeb = `VIH;
711
    #100
712
    dq_reg[`Byte] = `ClearCSRCmd;
713
    #100
714
    web = `VIL;
715
    #100
716
    web = `VIH;
717
    #100
718
    dq_reg = `MaxOutputs'hz;
719
  end
720
endtask
721
 
722
 
723
task StartProgram;
724
  input [`AddrSize-1:0] addr;
725
  input [`MaxOutputs-1:0] data;
726
  begin
727
    $display("  STARTPROGRAM TASK");
728
    #100
729
    address = addr;
730
    #100
731
    dq_reg[`Byte] = `Program2Cmd;
732
    #100
733
    web = `VIL;
734
    #100
735
    web = `VIH;
736
    #100
737
    dq_reg[`Byte] = data;
738
    #100
739
    web = `VIL;
740
    #100
741
    web = `VIH;
742
    #100
743
    dq_reg = `MaxOutputs'hz;
744
  end
745
endtask
746
 
747
 
748
task ProgramData;
749
  input [`AddrSize-1:0] addr;
750
  input [`MaxOutputs-1:0] data;
751
  begin
752
    $display("  PROGRAMDATA TASK");
753
    StartProgram(addr, data);
754
    #100
755
    oeb = `VIL;
756
    #((`AC_ProgramTime_Byte_50_12*`TimerPeriod_)-500)
757
    begin:  Poll
758
      forever
759
        begin
760
          oeb = `VIH;
761
          #100
762
          oeb = `VIL;
763
          #100
764
          if (dq[7] == `VIH)
765
            disable Poll;
766
        end //forever
767
    end //Poll
768
    #300
769
    ClearCSRMode;
770
  end
771
endtask
772
 
773
 
774
task StartProgram2;
775
  input [`AddrSize-1:0] addr;
776
  input [`MaxOutputs-1:0] data;
777
  begin
778
    $display("  STARTPROGRAM2 TASK");
779
    #100
780
    address = addr;
781
    #100
782
    dq_reg[`Byte] = `Program2Cmd;
783
    #100
784
    web = `VIL;
785
    #5
786
    ceb = `VIL;
787
    #100
788
    ceb = `VIH;
789
    #5
790
    web = `VIH;
791
    #100
792
    dq_reg[`Byte] = data;
793
    #100
794
    web = `VIL;
795
    #5
796
    ceb = `VIL;
797
    #100
798
    ceb = `VIH;
799
    #5
800
    web = `VIH;
801
    #100
802
    ceb = `VIL;
803
    dq_reg = `MaxOutputs'hz;
804
  end
805
endtask
806
 
807
 
808
task ProgramData2;
809
  input [`AddrSize-1:0] addr;
810
  input [`MaxOutputs-1:0] data;
811
  begin
812
    $display("  PROGRAMDATA2 TASK");
813
    ceb = `VIH;
814
    StartProgram2(addr, data);
815
    #100
816
    oeb = `VIL;
817
    #((`AC_ProgramTime_Byte_50_12*`TimerPeriod_)-500)
818
    begin:  Poll
819
      forever
820
        begin
821
          oeb = `VIH;
822
          #100
823
          oeb = `VIL;
824
          #100
825
          if (dq[7] == `VIH)
826
            disable Poll;
827
        end //forever
828
    end //Poll
829
    #300
830
    ClearCSRMode;
831
  end
832
endtask
833
 
834
task StartErase;
835
  input [`AddrSize-1:0] BlockAddr;
836
  begin
837
    $display("  STARTERASE TASK");
838
    #100
839
    address = BlockAddr;
840
    #100
841
    dq_reg = `EraseBlockCmd;
842
    #100
843
    web = `VIL;
844
    #100
845
    web = `VIH;
846
    #100
847
    dq_reg = `ConfirmCmd;
848
    #100
849
    web = `VIL;
850
    #100
851
    web = `VIH;
852
    #100
853
    dq_reg = `MaxOutputs'hz;
854
  end
855
endtask
856
 
857
 
858
task EraseBlock;
859
  input [`AddrSize-1:0] BlockAddr;
860
  time EraseTime;
861
  begin
862
    $display("  ERASEBLOCK TASK");
863
    StartErase(BlockAddr);
864
    #100
865
    oeb = `VIL;
866
    EraseTime = ((`AC_EraseTime_Block_50_12*`TimerPeriod_)-5000);
867
    #EraseTime
868
    begin: Poll
869
      forever
870
        begin
871
          oeb = `VIH;
872
          #1000
873
          oeb = `VIL;
874
          #1000
875
          if (dq[7] == `VIH)
876
            disable Poll;
877
        end
878
    end
879
    #300
880
    ClearCSRMode;
881
  end
882
endtask
883
 
884
 
885
task StartLockBit;
886
  input [`AddrSize-1:0] BlockAddr;
887
  begin
888
    $display("  STARTLOCKBIT TASK");
889
    #100
890
    address = BlockAddr;
891
    #100
892
    dq_reg = `LBSetupCmd;
893
    #100
894
    web = `VIL;
895
    #100
896
    web = `VIH;
897
    #100
898
    dq_reg = `SetBlockLBCmd;
899
    #100
900
    web = `VIL;
901
    #100
902
    web = `VIH;
903
    #100
904
    dq_reg = `MaxOutputs'hz;
905
  end
906
endtask
907
 
908
 
909
task SetBlockLockBit;
910
  input [`AddrSize-1:0] BlockAddr;
911
  time LockBitTime;
912
  begin
913
    $display("  SETBLOCKLOCKBIT TASK");
914
    StartLockBit(BlockAddr);
915
    #100
916
    oeb = `VIL;
917
    LockBitTime = ((`AC_Set_LockBit_50_12*`TimerPeriod_)-5000);
918
    #LockBitTime
919
    begin : Poll
920
      forever
921
        begin
922
          oeb = `VIH;
923
          #1000
924
          oeb = `VIL;
925
          #1000
926
          if (dq[7] == `VIH)
927
            disable Poll;
928
        end //forever
929
    end //Poll
930
    #300
931
    ClearCSRMode;
932
  end
933
endtask
934
 
935
 
936
task StartClearBit;
937
  begin
938
    $display("  STARTCLEARBIT TASK");
939
    #100
940
    dq_reg = `LBSetupCmd;
941
    #100
942
    web = `VIL;
943
    #100
944
    web = `VIH;
945
    #100
946
    dq_reg = `ClearLBCmd;
947
    #100
948
    web = `VIL;
949
    #100
950
    web = `VIH;
951
    #100
952
    dq_reg = `MaxOutputs'hz;
953
  end
954
endtask
955
 
956
 
957
task ClearBlockLockBit;
958
  time ClearBitTime;
959
  begin
960
    $display("  CLEARBLOCKLOCKBIT TASK");
961
    StartClearBit;
962
 
963
    #100
964
    oeb = `VIL;
965
    ClearBitTime = ((`AC_Clear_LockBit_50_12*`TimerPeriod_)-5000);
966
    #ClearBitTime
967
    begin : Poll
968
         forever
969
           begin
970
                oeb = `VIH;
971
                #1000
972
                oeb = `VIL;
973
                #1000
974
                if (dq[7] == `VIH)
975
                  disable Poll;
976
           end //forever
977
    end //Poll
978
    #300
979
    ClearCSRMode;
980
  end
981
endtask
982
 
983
 
984
task SetMasterLockBit;
985
  input [`AddrSize-1:0] DeviceAddr;
986
  time LockBitTime;
987
  begin
988
    $display("  SETMASTERLOCKBIT TASK");
989
    #100
990
    address = DeviceAddr;
991
    #100
992
    dq_reg = `LBSetupCmd;
993
    #100
994
    web = `VIL;
995
    #100
996
    web = `VIH;
997
    #100
998
    dq_reg = `SetMasterLBCmd;
999
    #100
1000
    web = `VIL;
1001
    #100
1002
    web = `VIH;
1003
    #100
1004
    dq_reg = `MaxOutputs'hz;
1005
    #100
1006
    oeb = `VIL;
1007
    LockBitTime = ((`AC_Set_LockBit_50_12*`TimerPeriod_)-5000);
1008
    #LockBitTime
1009
    begin : Poll
1010
      forever
1011
        begin
1012
          oeb = `VIH;
1013
          #1000
1014
          oeb = `VIL;
1015
          #1000
1016
          if (dq[7] == `VIH)
1017
            disable Poll;
1018
        end //forever
1019
    end //Poll
1020
    #300
1021
    ClearCSRMode;
1022
  end
1023
endtask
1024
 
1025
task Suspend;
1026
  begin
1027
    $display("  SUSPEND TASK");
1028
    #100
1029
    dq_reg = `SuspendCmd;
1030
    #100
1031
    web = `VIL;
1032
    #100
1033
    web = `VIH;
1034
    #100
1035
    dq_reg = `MaxOutputs'hz;
1036
    #100
1037
    oeb = `VIL;
1038
    #500
1039
    begin: Poll
1040
      forever
1041
        begin
1042
          oeb = `VIH;
1043
          #100
1044
          oeb = `VIL;
1045
          #100
1046
          if (dq[7] == `VIH)
1047
            disable Poll;
1048
        end
1049
    end
1050
  end
1051
endtask
1052
 
1053
 
1054
task Resume;
1055
  begin
1056
    $display("  RESUME TASK");
1057
    #100
1058
    dq_reg = `ResumeCmd;
1059
    #100
1060
    web = `VIL;
1061
    #100
1062
    web = `VIH;
1063
    #100
1064
    dq_reg = `MaxOutputs'hz;
1065
  end
1066
endtask
1067
 
1068
endmodule

powered by: WebSVN 2.1.0

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