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

Subversion Repositories t6507lp

[/] [t6507lp/] [trunk/] [fv/] [fsm_chk.e] - Blame information for rev 206

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

Line No. Rev Author Line
1 206 creep
<'
2
import fsm_components;
3
type state_t : [RESET, CYCLE_1, CYCLE_2, CYCLE_3, CYCLE_4, CYCLE_5, CYCLE_6, CYCLE_7];
4
unit fsm_chk_u {
5
        !A  : byte;
6
          keep soft A == 0;
7
        !X  : byte;
8
          keep soft X == 0;
9
        !Y  : byte;
10
          keep soft Y == 0;
11
        !PC : uint(bits : 13);
12
          keep soft PC == 0;
13
//      !SP : uint(bits : 9);
14
//        keep soft SP == 9'b100000000;
15
        !SP : byte;
16
          keep soft SP == 0;
17
 
18
        --!R  : byte;
19
        -- keep soft R == 0;
20
        --!PS : byte;
21
        --  keep soft PS[0:0] == 0;
22
        --  keep soft PS[1:1] == 0;
23
        --  keep soft PS[2:2] == 0;
24
        --  keep soft PS[3:3] == 0;
25
        --  keep soft PS[4:4] == 0;
26
        --  keep soft PS[5:5] == 1;
27
        --  keep soft PS[6:6] == 0;
28
        --  keep soft PS[7:7] == 0;
29
        -- N : bit;
30
        -- V : bit;
31
        -- B : bit;
32
        -- D : bit;
33
        -- I : bit;
34
        -- Z : bit;
35
        -- C : bit;
36
        -- keep soft N == 0;
37
        -- keep soft V == 0;
38
        -- keep soft B == 0;
39
        -- keep soft D == 0;
40
        -- keep soft I == 0;
41
        -- keep soft Z == 0;
42
        -- keep soft C == 0;
43
 
44
        !new_inst   : bool;
45
        keep new_inst == FALSE;
46
        !new_input : fsm_input_s;
47
        !old_input : fsm_input_s;
48
        --!new_inst  : bool;
49
        --keep soft new_inst == FALSE;
50
 
51
        --!i : ps_index;
52
 
53
        !new_state : state_t;
54
        !old_state : state_t;
55
 
56
        --count_cycles : int;
57
        --first_cycle  : bool;
58
        --last_a       : byte;
59
        --last_status  : byte;
60
        --last_result  : byte;
61
        !PCL:byte;
62
        !PCH:byte;
63
        !SP_aux:byte;
64
        !rst : bit;
65
        !rst_counter  : byte;
66
 
67
        --keep first_cycle  == TRUE;
68
        --keep count_cycles == 0;
69
        keep rst_counter  == 0;
70
 
71
        !instruction      : valid_opcodes;
72
        !last_instruction : valid_opcodes;
73
        !instructions     : valid_opcodes;
74
 
75
        print_state () is {
76
                outf("-------------------------------------------------------\n");
77
                print instructions;
78
                -- print instruction;
79
                print 't6507lp_fsm.ir';
80
                print 't6507lp_fsm.sp';
81
                print SP + 256;
82
                print 't6507lp_fsm.pc';
83
                print PC;
84
                --print addr;
85
                case ('t6507lp_fsm.state') {
86
 
87
                        2  : { outf("  t6507lp_fsm.state = FETCH_LOW\n");};
88
                        3  : { outf("  t6507lp_fsm.state = FETCH_HIGH\n"); };
89
                        4  : { outf("  t6507lp_fsm.state = READ_MEM\n"); };
90
                        5  : { outf("  t6507lp_fsm.state = DUMMY_WRT_CALC\n"); };
91
                        6  : { outf("  t6507lp_fsm.state = WRITE_MEM\n"); };
92
                        7  : { outf("  t6507lp_fsm.state = FETCH_OP_CALC_PARAM\n"); };
93
                        8  : { outf("  t6507lp_fsm.state = READ_MEM_CALC_INDEX\n"); };
94
                        9  : { outf("  t6507lp_fsm.state = FETCH_HIGH_CALC_INDEX\n"); };
95
                        10 : { outf("  t6507lp_fsm.state = READ_MEM_FIX_ADDR\n"); };
96
                        11 : { outf("  t6507lp_fsm.state = FETCH_OP_EVAL_BRANCH\n"); };
97
                        12 : { outf("  t6507lp_fsm.state = FETCH_OP_FIX_PC\n"); };
98
                        13 : { outf("  t6507lp_fsm.state = READ_FROM_POINTER\n"); };
99
                        14 : { outf("  t6507lp_fsm.state = READ_FROM_POINTER_X\n"); };
100
                        15 : { outf("  t6507lp_fsm.state = READ_FROM_POINTER_X1\n"); };
101
                        16 : { outf("  t6507lp_fsm.state = PUSH_PCH\n"); };
102
                        17 : { outf("  t6507lp_fsm.state = PUSH_PCL\n"); };
103
                        18 : { outf("  t6507lp_fsm.state = PUSH_STATUS\n"); };
104
                        19 : { outf("  t6507lp_fsm.state = FETCH_PCL\n"); };
105
                        20 : { outf("  t6507lp_fsm.state = FETCH_PCH\n"); };
106
                        21 : { outf("  t6507lp_fsm.state = INCREMENT_SP\n"); };
107
                        22 : { outf("  t6507lp_fsm.state = PULL_STATUS\n"); };
108
                        23 : { outf("  t6507lp_fsm.state = PULL_PCL\n"); };
109
                        24 : { outf("  t6507lp_fsm.state = PULL_PCH\n"); };
110
                        25 : { outf("  t6507lp_fsm.state = INCREMENT_PC\n"); };
111
                        26 : { outf("  t6507lp_fsm.state = PUSH_REGISTER\n"); };
112
                        27 : { outf("  t6507lp_fsm.state = PULL_REGISTER\n"); };
113
                        28 : { outf("  t6507lp_fsm.state = DUMMY\n"); };
114
                        31 : { outf("  t6507lp_fsm.state = RESET\n"); };
115
                };
116
        };
117
 
118
        store(input : fsm_input_s) is {
119
        --reset_n    : bit;
120
        --alu_result : byte;
121
        --alu_status : byte;
122
        --data_in    : byte;
123
        --alu_x      : byte;
124
        --alu_y      : byte;
125
        //print me;
126
        //print input;
127
                if (input.reset_n == 0) {
128
                  rst_counter = 0;
129
                  new_state = RESET;
130
                  old_state = RESET;
131
                  A = 0;
132
                  X = 0;
133
                  Y = 0;
134
                  PC = 0;
135
                  SP = 255;
136
                }
137
                else {
138
                        case (old_state) {
139
                                RESET    : {
140
                                        if (rst_counter == 7) {
141
                                                new_state = CYCLE_1;
142
                                        };
143
                                };
144
                                CYCLE_1 : {
145
                                        instruction = input.data_in.as_a(valid_opcodes);
146
                                        new_state = CYCLE_2;
147
                                };
148
                                CYCLE_2 : {
149
                                        case {
150
                                                (
151
                                                  instruction == BRK_IMP ||
152
                                                  instruction == PHA_IMP ||
153
                                                  instruction == PHP_IMP ||
154
                                                  instruction == PLA_IMP ||
155
                                                  instruction == PLP_IMP ||
156
                                                  instruction == RTI_IMP ||
157
                                                  instruction == RTS_IMP
158
                                                ) : {
159
                                                        new_state = CYCLE_3;
160
                                                };
161
                                                //JSR_ABS : {
162
                                                //      new_state = CYCLE_3;
163
                                                //      PCL = input.data_in;
164
                                                //};
165
                                                (
166
                                                  instruction == ADC_ABS ||
167
                                                  instruction == ASL_ABS ||
168
                                                  instruction == BIT_ABS ||
169
                                                  instruction == AND_ABS ||
170
                                                  instruction == CMP_ABS ||
171
                                                  instruction == DEC_ABS ||
172
                                                  instruction == EOR_ABS ||
173
                                                  instruction == INC_ABS ||
174
                                                  instruction == JMP_ABS ||
175
                                                  instruction == LDA_ABS ||
176
                                                  instruction == LDX_ABS ||
177
                                                  instruction == LDY_ABS ||
178
                                                  instruction == LSR_ABS ||
179
                                                  instruction == ORA_ABS ||
180
                                                  instruction == ROL_ABS ||
181
                                                  instruction == ROR_ABS ||
182
                                                  instruction == SBC_ABS ||
183
                                                  instruction == STA_ABS ||
184
                                                  instruction == STX_ABS ||
185
                                                  instruction == STY_ABS ||
186
                                                  instruction == LDA_ZPG ||
187
                                                  instruction == LDX_ZPG ||
188
                                                  instruction == LDY_ZPG ||
189
                                                  instruction == EOR_ZPG ||
190
                                                  instruction == AND_ZPG ||
191
                                                  instruction == ORA_ZPG ||
192
                                                  instruction == ADC_ZPG ||
193
                                                  instruction == SBC_ZPG ||
194
                                                  instruction == CMP_ZPG ||
195
                                                  instruction == BIT_ZPG ||
196
                                                  instruction == STA_ZPG ||
197
                                                  instruction == STX_ZPG ||
198
                                                  instruction == STY_ZPG ||
199
                                                  instruction == ASL_ZPG ||
200
                                                  instruction == LSR_ZPG ||
201
                                                  instruction == ROL_ZPG ||
202
                                                  instruction == ROR_ZPG ||
203
                                                  instruction == INC_ZPG ||
204
                                                  instruction == DEC_ZPG
205
                                                ) : {
206
                                                        new_state = CYCLE_3;
207
                                                        PCL = input.data_in;
208
                                                };
209
                                                (
210
                                                  instruction == LDA_ZPX ||
211
                                                  instruction == LDX_ZPY ||
212
                                                  instruction == LDY_ZPX ||
213
                                                  instruction == EOR_ZPX ||
214
                                                  instruction == AND_ZPX ||
215
                                                  instruction == ORA_ZPX ||
216
                                                  instruction == ADC_ZPX ||
217
                                                  instruction == SBC_ZPX ||
218
                                                  instruction == CMP_ZPX
219
                                                ) : {
220
                                                        new_state = CYCLE_3;
221
                                                        PCL = input.data_in;
222
                                                        X = alu_x;
223
                                                        Y = alu_y;
224
                                                };
225
                                                (
226
                                                  instruction == TXS_IMP
227
                                                ) : {
228
                                                        new_state = CYCLE_1;
229
                                                        SP_aux    = input.alu_x;
230
                                                };
231
                                                default : {
232
                                                        new_state = CYCLE_1;
233
                                                };
234
                                        };
235
                                };
236
                                CYCLE_3 : {
237
                                        case {
238
                                                (
239
                                                  instruction == BRK_IMP ||
240
                                                  instruction == PLA_IMP ||
241
                                                  instruction == PLP_IMP ||
242
                                                  instruction == RTI_IMP ||
243
                                                  instruction == RTS_IMP ||
244
                                                  instruction == ASL_ZPG ||
245
                                                  instruction == LSR_ZPG ||
246
                                                  instruction == ROL_ZPG ||
247
                                                  instruction == ROR_ZPG ||
248
                                                  instruction == INC_ZPG ||
249
                                                  instruction == DEC_ZPG ||
250
                                                  instruction == LDA_ZPX ||
251
                                                  instruction == LDX_ZPY ||
252
                                                  instruction == LDY_ZPX ||
253
                                                  instruction == EOR_ZPX ||
254
                                                  instruction == AND_ZPX ||
255
                                                  instruction == ORA_ZPX ||
256
                                                  instruction == ADC_ZPX ||
257
                                                  instruction == SBC_ZPX ||
258
                                                  instruction == CMP_ZPX
259
                                                ) : {
260
                                                        new_state = CYCLE_4;
261
                                                };
262
                                                //JSR_ABS : {
263
                                                //      new_state = CYCLE_4;
264
                                                //      PCH = input.data_in;
265
                                                //};
266
                                                (
267
                                                  instruction == ADC_ABS ||
268
                                                  instruction == ASL_ABS ||
269
                                                  instruction == BIT_ABS ||
270
                                                  instruction == AND_ABS ||
271
                                                  instruction == CMP_ABS ||
272
                                                  instruction == DEC_ABS ||
273
                                                  instruction == EOR_ABS ||
274
                                                  instruction == INC_ABS ||
275
                                                  instruction == LDA_ABS ||
276
                                                  instruction == LDX_ABS ||
277
                                                  instruction == LDY_ABS ||
278
                                                  instruction == LSR_ABS ||
279
                                                  instruction == ORA_ABS ||
280
                                                  instruction == ROL_ABS ||
281
                                                  instruction == ROR_ABS ||
282
                                                  instruction == SBC_ABS ||
283
                                                  instruction == STA_ABS ||
284
                                                  instruction == STX_ABS ||
285
                                                  instruction == STY_ABS
286
                                                ) : {
287
                                                        new_state = CYCLE_4;
288
                                                        PCH = input.data_in;
289
                                                };
290
                                                (
291
                                                  instruction == JMP_ABS
292
                                                ) : {
293
                                                        new_state = CYCLE_1;
294
                                                        PCH = input.data_in;
295
                                                };
296
                                                default : {
297
                                                        new_state = CYCLE_1;
298
                                                };
299
                                        };
300
                                };
301
                                CYCLE_4 : {
302
                                        case {
303
                                                //JSR_ABS : {
304
                                                //      new_state = CYCLE_5;
305
                                                //};
306
                                                (
307
                                                  instruction == RTS_IMP
308
                                                ) : {
309
                                                        new_state = CYCLE_5;
310
                                                        PCL = input.data_in;
311
                                                };
312
                                                (
313
                                                  instruction == ASL_ABS ||
314
                                                  instruction == BRK_IMP ||
315
                                                  instruction == DEC_ABS ||
316
                                                  instruction == INC_ABS ||
317
                                                  instruction == LSR_ABS ||
318
                                                  instruction == ROL_ABS ||
319
                                                  instruction == ROR_ABS ||
320
                                                  instruction == RTI_IMP ||
321
                                                  instruction == ASL_ZPG ||
322
                                                  instruction == LSR_ZPG ||
323
                                                  instruction == ROL_ZPG ||
324
                                                  instruction == ROR_ZPG ||
325
                                                  instruction == INC_ZPG ||
326
                                                  instruction == DEC_ZPG
327
                                                ) : {
328
                                                        new_state = CYCLE_5;
329
                                                };
330
                                                default : {
331
                                                        new_state = CYCLE_1;
332
                                                };
333
                                        };
334
                                };
335
                                CYCLE_5 : {
336
                                        case {
337
                                                //JSR_ABS : {
338
                                                //      new_state = CYCLE_6;
339
                                                //};
340
                                                (
341
                                                  instruction == RTI_IMP
342
                                                ) : {
343
                                                        new_state = CYCLE_6;
344
                                                        PCL = input.data_in;
345
                                                };
346
                                                (
347
                                                  instruction == RTS_IMP
348
                                                ) : {
349
                                                        new_state = CYCLE_6;
350
                                                        PCH = input.data_in;
351
                                                };
352
                                                (
353
                                                  instruction == ASL_ABS ||
354
                                                  instruction == BRK_IMP ||
355
                                                  instruction == DEC_ABS ||
356
                                                  instruction == INC_ABS ||
357
                                                  instruction == LSR_ABS ||
358
                                                  instruction == ROL_ABS ||
359
                                                  instruction == ROR_ABS
360
                                                ) : {
361
                                                        new_state = CYCLE_6;
362
                                                };
363
                                                default : {
364
                                                        new_state = CYCLE_1;
365
                                                };
366
                                        };
367
                                };
368
                                CYCLE_6 : {
369
                                        case {
370
                                                (
371
                                                  instruction == BRK_IMP
372
                                                ) : {
373
                                                        new_state = CYCLE_7;
374
                                                        PCL = input.data_in;
375
                                                };
376
                                                (
377
                                                  instructions == RTI_IMP
378
                                                ) : {
379
                                                        new_state = CYCLE_1;
380
                                                        PCH = input.data_in;
381
                                                };
382
                                                default : {
383
                                                        new_state = CYCLE_1;
384
                                                };
385
                                        };
386
                                };
387
                                CYCLE_7 : {
388
                                        //case (instruction) {
389
                                        //      BRK_IMP : {
390
                                        //              new_state = CYCLE_6;
391
                                        //      };
392
                                        //      default :
393
                                                new_state = CYCLE_1;
394
                                                PCH = input.data_in
395
                                        };
396
                        };
397
                        old_input = new_input;
398
                        new_input = input;
399
                };
400
        };
401
 
402
        compare(addr: uint(bits:13), mem_rw:bit, data_out:byte, alu_opcode:valid_opcodes, alu_a:byte, alu_enable:bit) is {
403
                case (old_state) {
404
                        RESET    : {
405
                                print_state();
406
                                rst = 1;
407
                                rst_counter = rst_counter + 1;
408
                        };
409
                        CYCLE_1 : {
410
                                print_state();
411
                                print addr;
412
                                last_instruction = instructions;
413
                                instructions = instruction;
414
                                //print instructions;
415
                                //print last_instruction;
416
                                if (mem_rw != 0) {
417
                                        dut_error("Mem_rw is Wrong!");
418
                                };
419
                                if (rst == 0) {
420
                                        case {
421
                                                (
422
                                                  last_instruction == ADC_ABS ||
423
                                                  last_instruction == ADC_IMM ||
424
                                                  last_instruction == AND_ABS ||
425
                                                  last_instruction == AND_IMM ||
426
                                                  last_instruction == BIT_ABS ||
427
                                                  last_instruction == CMP_ABS ||
428
                                                  last_instruction == CMP_IMM ||
429
                                                  last_instruction == CPX_IMM ||
430
                                                  last_instruction == CPY_IMM ||
431
                                                  last_instruction == EOR_ABS ||
432
                                                  last_instruction == EOR_IMM ||
433
                                                  last_instruction == LDA_ABS ||
434
                                                  last_instruction == LDA_IMM ||
435
                                                  last_instruction == LDX_ABS ||
436
                                                  last_instruction == LDX_IMM ||
437
                                                  last_instruction == LDY_ABS ||
438
                                                  last_instruction == LDY_IMM ||
439
                                                  last_instruction == ORA_ABS ||
440
                                                  last_instruction == ORA_IMM ||
441
                                                  last_instruction == PLA_IMP ||
442
                                                  last_instruction == PLP_IMP ||
443
                                                  last_instruction == SBC_ABS ||
444
                                                  last_instruction == SBC_IMM ||
445
                                                  last_instruction == LDA_ZPG ||
446
                                                  last_instruction == LDX_ZPG ||
447
                                                  last_instruction == LDY_ZPG ||
448
                                                  last_instruction == EOR_ZPG ||
449
                                                  last_instruction == AND_ZPG ||
450
                                                  last_instruction == ORA_ZPG ||
451
                                                  last_instruction == ADC_ZPG ||
452
                                                  last_instruction == SBC_ZPG ||
453
                                                  last_instruction == CMP_ZPG ||
454
                                                  last_instruction == BIT_ZPG
455
                                                ) : {
456
                                                        if (alu_opcode != last_instruction) {
457
                                                                dut_error("alu_opcode is Wrong!");
458
                                                        };
459
                                                        if (alu_enable != 1) {
460
                                                                dut_error("alu_enable is Wrong!");
461
                                                        };
462
                                                        if (addr != PC) {
463
                                                                dut_error("Address is Wrong!");
464
                                                        };
465
                                                };
466
                                                default : {
467
                                                        if (alu_opcode.as_a(byte) != 0) {
468
                                                                print alu_enable;
469
                                                                print alu_opcode;
470
                                                                print last_instruction;
471
                                                                dut_error("alu_opcode is Wrong!");
472
                                                        };
473
                                                        if (alu_enable != 0) {
474
                                                                dut_error("alu_enable is Wrong!");
475
                                                        };
476
                                                        if (alu_a != 0) {
477
                                                                dut_error("alu_a is Wrong!");
478
                                                        };
479
                                                        if (addr != PC) {
480
                                                                dut_error("Address is Wrong!");
481
                                                        };
482
                                                };
483
                                        };
484
                                }
485
                                else {
486
                                        rst = 0;
487
                                        if (alu_enable != 0) {
488
                                                dut_error("alu_enable is Wrong!");
489
                                        };
490
                                        if (alu_opcode.as_a(byte) != 0) {
491
                                                dut_error("alu_opcode is Wrong!");
492
                                        };
493
                                        if (alu_a != 0) {
494
                                                dut_error("alu_a is Wrong!");
495
                                        };
496
                                        if (addr != PC) {
497
                                                dut_error("Address is Wrong!");
498
                                        };
499
                                };
500
                                PC = PC + 1;
501
                        };
502
                        CYCLE_2 : {
503
                                print_state();
504
                                print addr;
505
                                if (addr != PC) {
506
                                        dut_error("ADDR should be equal PC!");
507
                                };
508
                                if (mem_rw != 0) {
509
                                        dut_error("MEM_RW should be 0 (READ)");
510
                                };
511
                                case {
512
                                        (
513
                                          instructions == ADC_ABS ||
514
                                          instructions == ADC_IMM ||
515
                                          instructions == AND_ABS ||
516
                                          instructions == AND_IMM ||
517
                                          instructions == ASL_ABS ||
518
                                          instructions == BIT_ABS ||
519
                                          instructions == BRK_IMP ||
520
                                          instructions == CMP_ABS ||
521
                                          instructions == CMP_IMM ||
522
                                          instructions == CPX_IMM ||
523
                                          instructions == CPY_IMM ||
524
                                          instructions == DEC_ABS ||
525
                                          instructions == EOR_ABS ||
526
                                          instructions == EOR_IMM ||
527
                                          instructions == INC_ABS ||
528
                                          instructions == JMP_ABS ||
529
                                          instructions == LDA_ABS ||
530
                                          instructions == LDA_IMM ||
531
                                          instructions == LDX_ABS ||
532
                                          instructions == LDX_IMM ||
533
                                          instructions == LDY_ABS ||
534
                                          instructions == LDY_IMM ||
535
                                          instructions == LSR_ABS ||
536
                                          instructions == ORA_ABS ||
537
                                          instructions == ORA_IMM ||
538
                                          instructions == ROL_ABS ||
539
                                          instructions == ROR_ABS ||
540
                                          instructions == SBC_ABS ||
541
                                          instructions == SBC_IMM ||
542
                                          instructions == LDA_ZPG ||
543
                                          instructions == LDX_ZPG ||
544
                                          instructions == LDY_ZPG ||
545
                                          instructions == EOR_ZPG ||
546
                                          instructions == AND_ZPG ||
547
                                          instructions == ORA_ZPG ||
548
                                          instructions == ADC_ZPG ||
549
                                          instructions == SBC_ZPG ||
550
                                          instructions == CMP_ZPG ||
551
                                          instructions == BIT_ZPG ||
552
                                          instructions == ASL_ZPG ||
553
                                          instructions == LSR_ZPG ||
554
                                          instructions == ROL_ZPG ||
555
                                          instructions == ROR_ZPG ||
556
                                          instructions == INC_ZPG ||
557
                                          instructions == DEC_ZPG
558
                                        ) : {
559
                                                if (alu_opcode.as_a(byte) != 0) {
560
                                                        dut_error("Opcode is Wrong!");
561
                                                };
562
                                                if (alu_enable != 0) {
563
                                                        dut_error("BRK_IMP is Wrong!");
564
                                                };
565
                                                PC = PC + 1;
566
                                        };
567
                                        (
568
                                          instructions == STA_ABS ||
569
                                          instructions == STX_ABS ||
570
                                          instructions == STY_ABS ||
571
                                          instructions == STA_ZPG ||
572
                                          instructions == STX_ZPG ||
573
                                          instructions == STY_ZPG ||
574
                                          instructions == LDA_ZPX ||
575
                                          instructions == LDX_ZPY ||
576
                                          instructions == LDY_ZPX ||
577
                                          instructions == EOR_ZPX ||
578
                                          instructions == AND_ZPX ||
579
                                          instructions == ORA_ZPX ||
580
                                          instructions == ADC_ZPX ||
581
                                          instructions == SBC_ZPX ||
582
                                          instructions == CMP_ZPX
583
                                        ) : {
584
                                                if (alu_opcode != instructions) {
585
                                                        dut_error("Opcode is Wrong!");
586
                                                };
587
                                                if (alu_enable != 1) {
588
                                                        dut_error("ASL_ACC is Wrong!");
589
                                                };
590
                                                PC = PC + 1;
591
                                        };
592
                                        (
593
                                          instructions == NOP_IMP ||
594
                                          instructions == PHP_IMP ||
595
                                          instructions == PLA_IMP ||
596
                                          instructions == PLP_IMP ||
597
                                          instructions == RTI_IMP ||
598
                                          instructions == RTS_IMP
599
 
600
                                        ) : {
601
                                                if (alu_opcode.as_a(byte) != 0) {
602
                                                        dut_error("Opcode is Wrong!");
603
                                                };
604
                                                if (alu_enable != 0) {
605
                                                        dut_error("ASL_ACC is Wrong!");
606
                                                };
607
                                        };
608
                                        (
609
                                          instructions == ASL_ACC ||
610
                                          instructions == CLC_IMP ||
611
                                          instructions == CLD_IMP ||
612
                                          instructions == CLI_IMP ||
613
                                          instructions == CLV_IMP ||
614
                                          instructions == DEX_IMP ||
615
                                          instructions == DEY_IMP ||
616
                                          instructions == INX_IMP ||
617
                                          instructions == INY_IMP ||
618
                                          instructions == LSR_ACC ||
619
                                          instructions == PHA_IMP ||
620
                                          instructions == ROL_ACC ||
621
                                          instructions == SEC_IMP ||
622
                                          instructions == SED_IMP ||
623
                                          instructions == SEI_IMP ||
624
                                          instructions == TAX_IMP ||
625
                                          instructions == TAY_IMP ||
626
                                          instructions == TXA_IMP ||
627
                                          instructions == TYA_IMP
628
                                        ) : {
629
                                                if (alu_opcode != instructions) {
630
                                                        dut_error("Opcode is Wrong!");
631
                                                };
632
                                                if (alu_enable != 1) {
633
                                                        dut_error("ASL_ACC is Wrong!");
634
                                                };
635
                                        };
636
                                        //JSR_ABS : {
637
                                        //      if (alu_opcode.as_a(byte) != 0) {
638
                                        //              dut_error("Opcode is Wrong!");
639
                                        //      };
640
                                        //      if (mem_rw != 0) {
641
                                        //              dut_error("MEM_RW should be 1 (WRITE)");
642
                                        //      };
643
                                        //      if (alu_enable != 0) {
644
                                        //              dut_error("JSR_IMP is Wrong!");
645
                                        //      };
646
                                        //      if (addr != PC) {
647
                                        //              dut_error("ADDR should be equal SP!");
648
                                        //      };
649
                                        //      PC = PC + 1;
650
                                        //};
651
                                        (
652
                                          instructions == TSX_IMP
653
                                        ) : {
654
                                                if (alu_opcode != instructions) {
655
                                                        dut_error("Opcode is Wrong!");
656
                                                };
657
                                                if (alu_enable != 1) {
658
                                                        dut_error("TSX_IMP is Wrong!");
659
                                                };
660
                                                if (alu_a != SP) {
661
                                                        dut_error("TSX_IMP is Wrong!");
662
                                                };
663
                                        };
664
                                        (
665
                                          instructions == TXS_IMP
666
                                        ) : {
667
                                                if (alu_opcode != instructions) {
668
                                                        dut_error("Opcode is Wrong!");
669
                                                };
670
                                                if (alu_enable != 1) {
671
                                                        dut_error("TXS_IMP is Wrong!");
672
                                                };
673
                                                SP = SP_aux;
674
                                        };
675
                                };
676
                        };
677
                        CYCLE_3 : {
678
                                print_state();
679
                                print addr;
680
                                case {
681
                                        (
682
                                          instructions == BRK_IMP
683
                                        ) : {
684
                                                if (alu_opcode.as_a(byte) != 0) {
685
                                                        dut_error("Opcode is Wrong!");
686
                                                };
687
                                                if (mem_rw != 1) {
688
                                                        dut_error("MEM_RW should be 1 (WRITE)");
689
                                                };
690
                                                if (alu_enable != 0) {
691
                                                        dut_error("BRK_IMP is Wrong!");
692
                                                };
693
                                                if (data_out[4:0] != PC[12:8] && data_out[7:5] != 0) {
694
                                                        dut_error("BRK_IMP is Wrong!");
695
                                                };
696
                                                if (addr != SP + 256) {
697
                                                        dut_error("ADDR should be equal SP!");
698
                                                };
699
                                                SP = SP - 1;
700
                                        };
701
                                        //JSR_ABS : {
702
                                        //      if (alu_opcode.as_a(byte) != 0) {
703
                                        //              dut_error("Opcode is Wrong!");
704
                                        //      };
705
                                        //      if (mem_rw != 0) {
706
                                        //              dut_error("MEM_RW should be 1 (WRITE)");
707
                                        //      };
708
                                        //      if (alu_enable != 0) {
709
                                        //              dut_error("JSR_IMP is Wrong!");
710
                                        //      };
711
                                        //      if (addr != PC) {
712
                                        //              dut_error("ADDR should be equal PC!");
713
                                        //      };
714
                                        //};
715
                                        (
716
                                          instructions == STA_ZPG ||
717
                                          instructions == STX_ZPG ||
718
                                          instructions == STY_ZPG
719
                                        ) : {
720
                                                if (alu_opcode.as_a(byte) != 0) {
721
                                                        dut_error("Opcode is Wrong!");
722
                                                };
723
                                                if (alu_enable != 0) {
724
                                                        dut_error("ASL_ACC is Wrong!");
725
                                                };
726
                                                if (mem_rw != 1) {
727
                                                        dut_error("MEM_RW should be 1 (WRITE)");
728
                                                };
729
                                                if (addr != PCL) {
730
                                                        dut_error("ADDR should be equal SP!");
731
                                                };
732
                                        };
733
                                        (
734
                                          instructions == JMP_ABS
735
                                        ) : {
736
                                                if (alu_opcode.as_a(byte) != 0) {
737
                                                        dut_error("Opcode is Wrong!");
738
                                                };
739
                                                if (alu_enable != 0) {
740
                                                        dut_error("ASL_ACC is Wrong!");
741
                                                };
742
                                                if (mem_rw != 0) {
743
                                                        dut_error("MEM_RW should be 1 (WRITE)");
744
                                                };
745
                                                PC[7:0] = PCL;
746
                                                PC[12:8] = PCH[4:0];
747
                                        };
748
                                        (
749
                                          instructions == LDA_ZPX ||
750
                                          instructions == LDX_ZPY ||
751
                                          instructions == LDY_ZPX ||
752
                                          instructions == EOR_ZPX ||
753
                                          instructions == AND_ZPX ||
754
                                          instructions == ORA_ZPX ||
755
                                          instructions == ADC_ZPX ||
756
                                          instructions == SBC_ZPX ||
757
                                          instructions == CMP_ZPX
758
                                        ) : {
759
                                                if (alu_opcode.as_a(byte) != 0) {
760
                                                        dut_error("Opcode is Wrong!");
761
                                                };
762
                                                if (alu_enable != 0) {
763
                                                        dut_error("ASL_ACC is Wrong!");
764
                                                };
765
                                                if (mem_rw != 0) {
766
                                                        dut_error("MEM_RW should be 0 (WRITE)");
767
                                                };
768
                                                if (addr != PCL) {
769
                                                        dut_error("ADDR should be equal SP!");
770
                                                };
771
                                        };
772
                                        (
773
                                          instructions == ADC_ABS ||
774
                                          instructions == AND_ABS ||
775
                                          instructions == ASL_ABS ||
776
                                          instructions == BIT_ABS ||
777
                                          instructions == CMP_ABS ||
778
                                          instructions == DEC_ABS ||
779
                                          instructions == EOR_ABS ||
780
                                          instructions == INC_ABS ||
781
                                          instructions == LDA_ABS ||
782
                                          instructions == LDX_ABS ||
783
                                          instructions == LDY_ABS ||
784
                                          instructions == LSR_ABS ||
785
                                          instructions == ORA_ABS ||
786
                                          instructions == ROL_ABS ||
787
                                          instructions == ROR_ABS ||
788
                                          instructions == SBC_ABS ||
789
                                          instructions == STA_ABS ||
790
                                          instructions == STX_ABS ||
791
                                          instructions == STY_ABS
792
                                        ) : {
793
                                                if (alu_opcode.as_a(byte) != 0) {
794
                                                        dut_error("Opcode is Wrong!");
795
                                                };
796
                                                if (alu_enable != 0) {
797
                                                        dut_error("ASL_ACC is Wrong!");
798
                                                };
799
                                                if (addr != PC) {
800
                                                        dut_error("ADDR should be equal SP!");
801
                                                };
802
                                                if (mem_rw != 0) {
803
                                                        dut_error("MEM_RW should be 1 (WRITE)");
804
                                                };
805
                                                PC = PC + 1;
806
                                        };
807
                                        (
808
                                          instructions == LDA_ZPG ||
809
                                          instructions == LDX_ZPG ||
810
                                          instructions == LDY_ZPG ||
811
                                          instructions == EOR_ZPG ||
812
                                          instructions == AND_ZPG ||
813
                                          instructions == ORA_ZPG ||
814
                                          instructions == ADC_ZPG ||
815
                                          instructions == SBC_ZPG ||
816
                                          instructions == CMP_ZPG ||
817
                                          instructions == BIT_ZPG ||
818
                                          instructions == ASL_ZPG ||
819
                                          instructions == LSR_ZPG ||
820
                                          instructions == ROL_ZPG ||
821
                                          instructions == ROR_ZPG ||
822
                                          instructions == INC_ZPG ||
823
                                          instructions == DEC_ZPG
824
                                        ) : {
825
                                                if (alu_opcode.as_a(byte) != 0) {
826
                                                        dut_error("Opcode is Wrong!");
827
                                                };
828
                                                if (alu_enable != 0) {
829
                                                        dut_error("ASL_ACC is Wrong!");
830
                                                };
831
                                                if (mem_rw != 0) {
832
                                                        dut_error("MEM_RW should be 1 (WRITE)");
833
                                                };
834
                                                if (addr != PCL) {
835
                                                        dut_error("ADDR should be equal SP!");
836
                                                };
837
                                        };
838
                                        (
839
                                          instructions == PHA_IMP ||
840
                                          instructions == PHP_IMP
841
                                        ) : {
842
                                                if (alu_opcode.as_a(byte) != 0) {
843
                                                        dut_error("Opcode is Wrong!");
844
                                                };
845
                                                if (mem_rw != 1) {
846
                                                        dut_error("MEM_RW should be 1 (WRITE)");
847
                                                };
848
                                                if (alu_a != 0) {
849
                                                        dut_error("PHP_IMP is Wrong!");
850
                                                };
851
                                                if (addr != SP + 256) {
852
                                                        dut_error("ADDR should be equal SP!");
853
                                                };
854
                                                SP = SP - 1;
855
                                                if (alu_enable != 0) {
856
                                                        dut_error("PHP_IMP is Wrong!");
857
                                                };
858
                                        };
859
                                        (
860
                                          instructions == PLA_IMP ||
861
                                          instructions == PLP_IMP ||
862
                                          instructions == RTI_IMP ||
863
                                          instructions == RTS_IMP
864
                                        ) : {
865
                                                if (alu_opcode.as_a(byte) != 0) {
866
                                                        dut_error("Opcode is Wrong!");
867
                                                };
868
                                                if (alu_enable != 0) {
869
                                                        dut_error("PLA_IMP is Wrong!");
870
                                                };
871
                                                if (mem_rw != 0) {
872
                                                        dut_error("MEM_RW should be 0 (READ)");
873
                                                };
874
                                                if (addr != SP + 256) {
875
                                                        dut_error("ADDR should be equal SP!");
876
                                                };
877
                                                SP = SP + 1;
878
                                        };
879
                                };
880
                        };
881
                        CYCLE_4 : {
882
                                print_state();
883
                                print addr;
884
                                case {
885
                                        (
886
                                          instructions == BRK_IMP
887
                                        ) : {
888
                                                if (alu_opcode.as_a(byte) != 0) {
889
                                                        dut_error("Opcode is Wrong!");
890
                                                };
891
                                                if (mem_rw != 1) {
892
                                                        dut_error("MEM_RW should be 1 (WRITE)");
893
                                                };
894
                                                if (alu_enable != 0) {
895
                                                        dut_error("BRK_IMP is Wrong!");
896
                                                };
897
                                                if (data_out != PC[7:0]) {
898
                                                        dut_error("BRK_IMP is Wrong!");
899
                                                };
900
                                                if (addr != SP + 256) {
901
                                                        dut_error("ADDR should be equal SP!");
902
                                                };
903
                                                SP = SP - 1;
904
                                        };
905
                                        //JSR_ABS : {
906
                                        //      if (alu_opcode.as_a(byte) != 0) {
907
                                        //              dut_error("Opcode is Wrong!");
908
                                        //      };
909
                                        //      if (mem_rw != 1) {
910
                                        //              dut_error("MEM_RW should be 1 (WRITE)");
911
                                        //      };
912
                                        //      if (alu_enable != 0) {
913
                                        //              dut_error("JSR_ABS is Wrong!");
914
                                        //      };
915
                                        //      if (data_out != PC[7:0]) {
916
                                        //              dut_error("JSR_ABS is Wrong!");
917
                                        //      };
918
                                        //      if (addr != SP + 256) {
919
                                        //              dut_error("ADDR should be equal SP!");
920
                                        //      };
921
                                        //      SP = SP - 1;
922
                                        //};
923
                                        (
924
                                          instructions == LDA_ZPX ||
925
                                          instructions == LDY_ZPX ||
926
                                          instructions == EOR_ZPX ||
927
                                          instructions == AND_ZPX ||
928
                                          instructions == ORA_ZPX ||
929
                                          instructions == ADC_ZPX ||
930
                                          instructions == SBC_ZPX ||
931
                                          instructions == CMP_ZPX
932
                                        ) : {
933
                                                if (alu_opcode.as_a(byte) != 0) {
934
                                                        dut_error("Opcode is Wrong!");
935
                                                };
936
                                                if (alu_enable != 0) {
937
                                                        dut_error("ASL_ACC is Wrong!");
938
                                                };
939
                                                if (mem_rw != 0) {
940
                                                        dut_error("MEM_RW should be 0 (WRITE)");
941
                                                };
942
                                                if (addr != PCL + X) {
943
                                                        dut_error("ADDR should be equal SP!");
944
                                                };
945
                                        };
946
                                        (
947
                                          instructions == LDX_ZPY
948
                                        ) : {
949
                                                if (alu_opcode.as_a(byte) != 0) {
950
                                                        dut_error("Opcode is Wrong!");
951
                                                };
952
                                                if (alu_enable != 0) {
953
                                                        dut_error("ASL_ACC is Wrong!");
954
                                                };
955
                                                if (mem_rw != 0) {
956
                                                        dut_error("MEM_RW should be 0 (WRITE)");
957
                                                };
958
                                                if (addr != PCL + Y) {
959
                                                        dut_error("ADDR should be equal SP!");
960
                                                };
961
                                        };
962
                                        (
963
                                          instructions == ADC_ABS ||
964
                                          instructions == AND_ABS ||
965
                                          instructions == ASL_ABS ||
966
                                          instructions == BIT_ABS ||
967
                                          instructions == CMP_ABS ||
968
                                          instructions == DEC_ABS ||
969
                                          instructions == EOR_ABS ||
970
                                          instructions == INC_ABS ||
971
                                          instructions == LDA_ABS ||
972
                                          instructions == LDX_ABS ||
973
                                          instructions == LDY_ABS ||
974
                                          instructions == LSR_ABS ||
975
                                          instructions == ORA_ABS ||
976
                                          instructions == ROL_ABS ||
977
                                          instructions == ROR_ABS ||
978
                                          instructions == SBC_ABS
979
                                          ) : {
980
                                                if (alu_opcode.as_a(byte) != 0) {
981
                                                        dut_error("Opcode is Wrong!");
982
                                                };
983
                                                if (alu_enable != 0) {
984
                                                        dut_error("ASL_ACC is Wrong!");
985
                                                };
986
                                                if (addr[7:0] != PCL) {
987
                                                        dut_error("ADDR should be equal SP!");
988
                                                };
989
                                                if (addr[12:8] != PCH[4:0]) {
990
                                                        dut_error("ADDR should be equal SP!");
991
                                                };
992
                                                if (mem_rw != 0) {
993
                                                        dut_error("MEM_RW should be 1 (WRITE)");
994
                                                };
995
                                        };
996
                                        (
997
                                          instructions == STA_ABS ||
998
                                          instructions == STX_ABS ||
999
                                          instructions == STY_ABS
1000
                                        ) : {
1001
                                                if (alu_opcode.as_a(byte) != 0) {
1002
                                                        dut_error("Opcode is Wrong!");
1003
                                                };
1004
                                                if (alu_enable != 0) {
1005
                                                        dut_error("ASL_ACC is Wrong!");
1006
                                                };
1007
                                                if (addr[7:0] != PCL) {
1008
                                                        dut_error("ADDR should be equal SP!");
1009
                                                };
1010
                                                if (addr[12:8] != PCH[4:0]) {
1011
                                                        dut_error("ADDR should be equal SP!");
1012
                                                };
1013
                                                if (mem_rw != 1) {
1014
                                                        dut_error("MEM_RW should be 1 (WRITE)");
1015
                                                };
1016
                                        };
1017
                                        (
1018
                                          instructions == ASL_ZPG ||
1019
                                          instructions == LSR_ZPG ||
1020
                                          instructions == ROL_ZPG ||
1021
                                          instructions == ROR_ZPG ||
1022
                                          instructions == INC_ZPG ||
1023
                                          instructions == DEC_ZPG
1024
                                        ) : {
1025
                                                if (alu_opcode != instructions) {
1026
                                                        dut_error("Opcode is Wrong!");
1027
                                                };
1028
                                                if (mem_rw != 1) {
1029
                                                        dut_error("MEM_RW should be 1 (WRITE)");
1030
                                                };
1031
                                                if (alu_enable != 1) {
1032
                                                        dut_error("BRK_IMP is Wrong!");
1033
                                                };
1034
                                                if (addr[7:0] != PCL) {
1035
                                                        dut_error("ADDR should be equal SP!");
1036
                                                };
1037
                                        };
1038
                                        (
1039
                                          instructions == PLA_IMP ||
1040
                                          instructions == PLP_IMP
1041
                                        ) : {
1042
                                                if (alu_opcode.as_a(byte) != 0) {
1043
                                                        dut_error("Opcode is Wrong!");
1044
                                                };
1045
                                                if (mem_rw != 0) {
1046
                                                        dut_error("MEM_RW should be 0 (READ)");
1047
                                                };
1048
                                                if (alu_enable != 0) {
1049
                                                        dut_error("PLP_IMP is Wrong!");
1050
                                                };
1051
                                                if (addr != SP + 256) {
1052
                                                        dut_error("ADDR should be equal SP!");
1053
                                                };
1054
                                        };
1055
                                        (
1056
                                          instructions == RTI_IMP
1057
                                        ) : {
1058
                                                if (alu_opcode.as_a(byte) != 0) {
1059
                                                        dut_error("Opcode is Wrong!");
1060
                                                };
1061
                                                if (mem_rw != 0) {
1062
                                                        dut_error("MEM_RW should be 1 (WRITE)");
1063
                                                };
1064
                                                if (alu_enable != 0) {
1065
                                                        dut_error("RTI_IMP is Wrong!");
1066
                                                };
1067
                                                if (addr != SP + 256) {
1068
                                                        print addr, SP;
1069
                                                        dut_error("ADDR should be equal SP!");
1070
                                                };
1071
                                                SP = SP + 1;
1072
                                        };
1073
                                        (
1074
                                          instructions == RTS_IMP
1075
                                        ) : {
1076
                                                if (alu_opcode.as_a(byte) != 0) {
1077
                                                        dut_error("Opcode is Wrong!");
1078
                                                };
1079
                                                if (alu_enable != 0) {
1080
                                                        dut_error("RTS_IMP is Wrong!");
1081
                                                };
1082
                                                if (addr != SP + 256) {
1083
                                                        dut_error("ADDR should be equal SP!");
1084
                                                };
1085
                                                SP = SP + 1;
1086
                                                PC[7:0] = PCL;
1087
                                        };
1088
                                };
1089
                        };
1090
                        CYCLE_5 : {
1091
                                print_state();
1092
                                print addr;
1093
                                case {
1094
                                        (
1095
                                          instructions == BRK_IMP
1096
                                        ) : {
1097
                                                if (alu_opcode.as_a(byte) != 0) {
1098
                                                        dut_error("Opcode is Wrong!");
1099
                                                };
1100
                                                if (mem_rw != 1) {
1101
                                                        dut_error("MEM_RW should be 1 (WRITE)");
1102
                                                };
1103
                                                if (alu_enable != 0) {
1104
                                                        dut_error("BRK_IMP is Wrong!");
1105
                                                };
1106
                                                if (addr != SP + 256) {
1107
                                                        dut_error("ADDR should be equal SP!");
1108
                                                };
1109
                                                SP = SP - 1;
1110
                                        };
1111
                                        //JSR_ABS : {
1112
                                        //      if (alu_opcode.as_a(byte) != 0) {
1113
                                        //              dut_error("Opcode is Wrong!");
1114
                                        //      };
1115
                                        //      if (mem_rw != 1) {
1116
                                        //              dut_error("MEM_RW should be 1 (WRITE)");
1117
                                        //      };
1118
                                        //      if (alu_enable != 0) {
1119
                                        //              dut_error("JSR_ABS is Wrong!");
1120
                                        //      };
1121
                                        //      if (data_out != PC[12:8]) {
1122
                                        //              dut_error("JSR_ABS is Wrong!");
1123
                                        //      };
1124
                                        //      if (addr != SP + 256) {
1125
                                        //              dut_error("ADDR should be equal SP!");
1126
                                        //      };
1127
                                        //      SP = SP - 1;
1128
                                        //};
1129
                                        (
1130
                                          instructions == RTI_IMP
1131
                                        ) : {
1132
                                                if (alu_opcode != instructions) {
1133
                                                        dut_error("Opcode is Wrong!");
1134
                                                };
1135
                                                if (mem_rw != 0) {
1136
                                                        dut_error("MEM_RW should be 1 (WRITE)");
1137
                                                };
1138
                                                if (alu_enable != 1) {
1139
                                                        dut_error("RTI_IMP is Wrong!");
1140
                                                };
1141
                                                if (addr != SP + 256) {
1142
                                                        dut_error("ADDR should be equal SP!");
1143
                                                };
1144
                                                SP = SP + 1;
1145
                                                PC[7:0] = PCL;
1146
                                        };
1147
                                        (
1148
                                          instructions == RTS_IMP
1149
                                        ) : {
1150
                                                if (alu_opcode.as_a(byte) != 0) {
1151
                                                        dut_error("Opcode is Wrong!");
1152
                                                };
1153
                                                if (alu_enable != 0) {
1154
                                                        dut_error("SEI_IMP is Wrong!");
1155
                                                };
1156
                                                if (addr != SP + 256) {
1157
                                                        dut_error("ADDR should be equal SP!");
1158
                                                };
1159
                                                PC[12:8] = PCH[4:0];
1160
                                        };
1161
                                        (
1162
                                          instructions == ASL_ZPG ||
1163
                                          instructions == LSR_ZPG ||
1164
                                          instructions == ROL_ZPG ||
1165
                                          instructions == ROR_ZPG ||
1166
                                          instructions == INC_ZPG ||
1167
                                          instructions == DEC_ZPG
1168
                                        ) : {
1169
                                                if (alu_opcode.as_a(byte) != 0) {
1170
                                                        dut_error("Opcode is Wrong!");
1171
                                                };
1172
                                                if (mem_rw != 1) {
1173
                                                        dut_error("MEM_RW should be 1 (WRITE)");
1174
                                                };
1175
                                                if (alu_enable != 0) {
1176
                                                        dut_error("BRK_IMP is Wrong!");
1177
                                                };
1178
                                                if (addr[7:0] != PCL) {
1179
                                                        dut_error("ADDR should be equal SP!");
1180
                                                };
1181
                                        };
1182
                                        (
1183
                                          instructions == ASL_ABS ||
1184
                                          instructions == DEC_ABS ||
1185
                                          instructions == INC_ABS ||
1186
                                          instructions == LSR_ABS ||
1187
                                          instructions == ROL_ABS ||
1188
                                          instructions == ROR_ABS
1189
                                        ) : {
1190
                                                if (alu_opcode != instructions) {
1191
                                                        dut_error("Opcode is Wrong!");
1192
                                                };
1193
                                                if (mem_rw != 1) {
1194
                                                        dut_error("MEM_RW should be 1 (WRITE)");
1195
                                                };
1196
                                                if (alu_enable != 1) {
1197
                                                        dut_error("BRK_IMP is Wrong!");
1198
                                                };
1199
                                                if (addr[7:0] != PCL) {
1200
                                                        dut_error("ADDR should be equal SP!");
1201
                                                };
1202
                                                if (addr[12:8] != PCH[4:0]) {
1203
                                                        dut_error("ADDR should be equal SP!");
1204
                                                };
1205
                                        };
1206
                                };
1207
                        };
1208
                        CYCLE_6 : {
1209
                                print_state();
1210
                                print addr;
1211
                                case {
1212
                                        (
1213
                                          instructions == BRK_IMP
1214
                                        ) : {
1215
                                                if (alu_opcode.as_a(byte) != 0) {
1216
                                                        dut_error("Opcode is Wrong!");
1217
                                                };
1218
                                                if (mem_rw != 0) {
1219
                                                        dut_error("MEM_RW should be 1 (WRITE)");
1220
                                                };
1221
                                                if (alu_enable != 0) {
1222
                                                        dut_error("BRK_IMP is Wrong!");
1223
                                                };
1224
                                                if (addr != 13'b1111111111110) {
1225
                                                        dut_error("BRK_IMP is Wrong!");
1226
                                                };
1227
                                                PC[7:0] = PCL;
1228
                                        };
1229
                                        //JSR_ABS : {
1230
                                        //      if (alu_opcode.as_a(byte) != 0) {
1231
                                        //              dut_error("Opcode is Wrong!");
1232
                                        //      };
1233
                                        //      if (mem_rw != 0) {
1234
                                        //              dut_error("MEM_RW should be 1 (WRITE)");
1235
                                        //      };
1236
                                        //      if (alu_enable != 0) {
1237
                                        //              dut_error("JSR_ABS is Wrong!");
1238
                                        //      };
1239
                                        //      if (addr != PC) {
1240
                                        //              dut_error("ADDR should be equal SP!");
1241
                                        //      };
1242
                                        //      PC [7:0] = PCL;
1243
                                        //      PC[12:8] = PCH[4:0];
1244
                                        //};
1245
                                        (
1246
                                          instructions == RTI_IMP
1247
                                        ) : {
1248
                                                if (alu_opcode.as_a(byte) != 0) {
1249
                                                        dut_error("Opcode is Wrong!");
1250
                                                };
1251
                                                if (mem_rw != 0) {
1252
                                                        dut_error("MEM_RW should be 1 (WRITE)");
1253
                                                };
1254
                                                if (alu_enable != 0) {
1255
                                                        dut_error("RTI_IMP is Wrong!");
1256
                                                };
1257
                                                if (addr != SP + 256) {
1258
                                                        dut_error("ADDR should be equal SP!");
1259
                                                };
1260
                                                PC[12:8] = PCH[4:0];
1261
                                        };
1262
                                        (
1263
                                          instructions == RTS_IMP
1264
                                        ) : {
1265
                                                if (alu_opcode.as_a(byte) != 0) {
1266
                                                        dut_error("Opcode is Wrong!");
1267
                                                };
1268
                                                if (mem_rw != 0) {
1269
                                                        dut_error("MEM_RW should be 1 (WRITE)");
1270
                                                };
1271
                                                if (alu_enable != 0) {
1272
                                                        dut_error("RTI_IMP is Wrong!");
1273
                                                };
1274
                                                if (addr != PC) {
1275
                                                        dut_error("ADDR should be equal SP!");
1276
                                                };
1277
                                                PC = PC + 1;
1278
                                        };
1279
                                        (
1280
                                          instructions == ASL_ABS ||
1281
                                          instructions == DEC_ABS ||
1282
                                          instructions == INC_ABS ||
1283
                                          instructions == LSR_ABS ||
1284
                                          instructions == ROL_ABS ||
1285
                                          instructions == ROR_ABS
1286
                                        ) : {
1287
                                                if (alu_opcode.as_a(byte) != 0) {
1288
                                                        dut_error("Opcode is Wrong!");
1289
                                                };
1290
                                                if (mem_rw != 1) {
1291
                                                        dut_error("MEM_RW should be 1 (WRITE)");
1292
                                                };
1293
                                                if (alu_enable != 0) {
1294
                                                        dut_error("BRK_IMP is Wrong!");
1295
                                                };
1296
                                                if (addr[7:0] != PCL) {
1297
                                                        dut_error("ADDR should be equal SP!");
1298
                                                };
1299
                                                if (addr[12:8] != PCH[4:0]) {
1300
                                                        dut_error("ADDR should be equal SP!");
1301
                                                };
1302
                                        };
1303
                                };
1304
                        };
1305
                        CYCLE_7 : {
1306
                                print_state();
1307
                                print addr;
1308
                                case {
1309
                                        (
1310
                                          instructions == BRK_IMP
1311
                                        ) : {
1312
                                                if (alu_opcode.as_a(byte) != 0) {
1313
                                                        dut_error("Opcode is Wrong!");
1314
                                                };
1315
                                                if (mem_rw != 0) {
1316
                                                        dut_error("MEM_RW should be 1 (WRITE)");
1317
                                                };
1318
                                                if (alu_enable != 0) {
1319
                                                        dut_error("BRK_IMP is Wrong!");
1320
                                                };
1321
                                                if (addr != 13'b1111111111111) {
1322
                                                        dut_error("BRK_IMP is Wrong!");
1323
                                                };
1324
                                                PC[12:8] = PCH[4:0];
1325
                                        };
1326
                                };
1327
                        };
1328
                };
1329
        old_state = new_state;
1330
        };
1331
};
1332
'>

powered by: WebSVN 2.1.0

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