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

Subversion Repositories t6507lp

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

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 214 creep
        !pointer : byte;
18
          keep soft pointer == 0;
19 206 creep
 
20 212 creep
        !more_cycles : bool;
21
          keep soft more_cycles == FALSE;
22 206 creep
        --!R  : byte;
23
        -- keep soft R == 0;
24
        --!PS : byte;
25
        --  keep soft PS[0:0] == 0;
26
        --  keep soft PS[1:1] == 0;
27
        --  keep soft PS[2:2] == 0;
28
        --  keep soft PS[3:3] == 0;
29
        --  keep soft PS[4:4] == 0;
30
        --  keep soft PS[5:5] == 1;
31
        --  keep soft PS[6:6] == 0;
32
        --  keep soft PS[7:7] == 0;
33
        -- N : bit;
34
        -- V : bit;
35
        -- B : bit;
36
        -- D : bit;
37
        -- I : bit;
38
        -- Z : bit;
39
        -- C : bit;
40
        -- keep soft N == 0;
41
        -- keep soft V == 0;
42
        -- keep soft B == 0;
43
        -- keep soft D == 0;
44
        -- keep soft I == 0;
45
        -- keep soft Z == 0;
46
        -- keep soft C == 0;
47
 
48
        !new_inst   : bool;
49
        keep new_inst == FALSE;
50
        !new_input : fsm_input_s;
51
        !old_input : fsm_input_s;
52
        --!new_inst  : bool;
53
        --keep soft new_inst == FALSE;
54
 
55
        --!i : ps_index;
56
 
57
        !new_state : state_t;
58
        !old_state : state_t;
59
 
60
        --count_cycles : int;
61
        --first_cycle  : bool;
62
        --last_a       : byte;
63
        --last_status  : byte;
64
        --last_result  : byte;
65
        !PCL:byte;
66
        !PCH:byte;
67
        !SP_aux:byte;
68
        !rst : bit;
69
        !rst_counter  : byte;
70
 
71
        --keep first_cycle  == TRUE;
72
        --keep count_cycles == 0;
73
        keep rst_counter  == 0;
74
 
75
        !instruction      : valid_opcodes;
76
        !last_instruction : valid_opcodes;
77
        !instructions     : valid_opcodes;
78
 
79
        print_state () is {
80
                outf("-------------------------------------------------------\n");
81
                print instructions;
82
                -- print instruction;
83
                print 't6507lp_fsm.ir';
84
                print 't6507lp_fsm.sp';
85
                print SP + 256;
86
                print 't6507lp_fsm.pc';
87
                print PC;
88
                --print addr;
89
                case ('t6507lp_fsm.state') {
90
 
91
                        2  : { outf("  t6507lp_fsm.state = FETCH_LOW\n");};
92
                        3  : { outf("  t6507lp_fsm.state = FETCH_HIGH\n"); };
93
                        4  : { outf("  t6507lp_fsm.state = READ_MEM\n"); };
94
                        5  : { outf("  t6507lp_fsm.state = DUMMY_WRT_CALC\n"); };
95
                        6  : { outf("  t6507lp_fsm.state = WRITE_MEM\n"); };
96
                        7  : { outf("  t6507lp_fsm.state = FETCH_OP_CALC_PARAM\n"); };
97
                        8  : { outf("  t6507lp_fsm.state = READ_MEM_CALC_INDEX\n"); };
98
                        9  : { outf("  t6507lp_fsm.state = FETCH_HIGH_CALC_INDEX\n"); };
99
                        10 : { outf("  t6507lp_fsm.state = READ_MEM_FIX_ADDR\n"); };
100
                        11 : { outf("  t6507lp_fsm.state = FETCH_OP_EVAL_BRANCH\n"); };
101
                        12 : { outf("  t6507lp_fsm.state = FETCH_OP_FIX_PC\n"); };
102
                        13 : { outf("  t6507lp_fsm.state = READ_FROM_POINTER\n"); };
103
                        14 : { outf("  t6507lp_fsm.state = READ_FROM_POINTER_X\n"); };
104
                        15 : { outf("  t6507lp_fsm.state = READ_FROM_POINTER_X1\n"); };
105
                        16 : { outf("  t6507lp_fsm.state = PUSH_PCH\n"); };
106
                        17 : { outf("  t6507lp_fsm.state = PUSH_PCL\n"); };
107
                        18 : { outf("  t6507lp_fsm.state = PUSH_STATUS\n"); };
108
                        19 : { outf("  t6507lp_fsm.state = FETCH_PCL\n"); };
109
                        20 : { outf("  t6507lp_fsm.state = FETCH_PCH\n"); };
110
                        21 : { outf("  t6507lp_fsm.state = INCREMENT_SP\n"); };
111
                        22 : { outf("  t6507lp_fsm.state = PULL_STATUS\n"); };
112
                        23 : { outf("  t6507lp_fsm.state = PULL_PCL\n"); };
113
                        24 : { outf("  t6507lp_fsm.state = PULL_PCH\n"); };
114
                        25 : { outf("  t6507lp_fsm.state = INCREMENT_PC\n"); };
115
                        26 : { outf("  t6507lp_fsm.state = PUSH_REGISTER\n"); };
116
                        27 : { outf("  t6507lp_fsm.state = PULL_REGISTER\n"); };
117
                        28 : { outf("  t6507lp_fsm.state = DUMMY\n"); };
118
                        31 : { outf("  t6507lp_fsm.state = RESET\n"); };
119
                };
120
        };
121
 
122
        store(input : fsm_input_s) is {
123
        --reset_n    : bit;
124
        --alu_result : byte;
125
        --alu_status : byte;
126
        --data_in    : byte;
127
        --alu_x      : byte;
128
        --alu_y      : byte;
129
        //print me;
130
        //print input;
131
                if (input.reset_n == 0) {
132
                  rst_counter = 0;
133
                  new_state = RESET;
134
                  old_state = RESET;
135
                  A = 0;
136
                  X = 0;
137
                  Y = 0;
138
                  PC = 0;
139
                  SP = 255;
140
                }
141
                else {
142
                        case (old_state) {
143
                                RESET    : {
144
                                        if (rst_counter == 7) {
145
                                                new_state = CYCLE_1;
146
                                        };
147
                                };
148
                                CYCLE_1 : {
149
                                        instruction = input.data_in.as_a(valid_opcodes);
150
                                        new_state = CYCLE_2;
151
                                };
152
                                CYCLE_2 : {
153 212 creep
                                        X = input.alu_x;
154
                                        Y = input.alu_y;
155 206 creep
                                        case {
156
                                                (
157
                                                  instruction == BRK_IMP ||
158
                                                  instruction == PHA_IMP ||
159
                                                  instruction == PHP_IMP ||
160
                                                  instruction == PLA_IMP ||
161
                                                  instruction == PLP_IMP ||
162
                                                  instruction == RTI_IMP ||
163
                                                  instruction == RTS_IMP
164
                                                ) : {
165
                                                        new_state = CYCLE_3;
166
                                                };
167
                                                //JSR_ABS : {
168
                                                //      new_state = CYCLE_3;
169
                                                //      PCL = input.data_in;
170
                                                //};
171
                                                (
172
                                                  instruction == ADC_ABS ||
173
                                                  instruction == ASL_ABS ||
174
                                                  instruction == BIT_ABS ||
175
                                                  instruction == AND_ABS ||
176
                                                  instruction == CMP_ABS ||
177
                                                  instruction == DEC_ABS ||
178
                                                  instruction == EOR_ABS ||
179
                                                  instruction == INC_ABS ||
180
                                                  instruction == JMP_ABS ||
181
                                                  instruction == LDA_ABS ||
182
                                                  instruction == LDX_ABS ||
183
                                                  instruction == LDY_ABS ||
184
                                                  instruction == LSR_ABS ||
185
                                                  instruction == ORA_ABS ||
186
                                                  instruction == ROL_ABS ||
187
                                                  instruction == ROR_ABS ||
188
                                                  instruction == SBC_ABS ||
189
                                                  instruction == STA_ABS ||
190
                                                  instruction == STX_ABS ||
191
                                                  instruction == STY_ABS ||
192
                                                  instruction == LDA_ZPG ||
193
                                                  instruction == LDX_ZPG ||
194
                                                  instruction == LDY_ZPG ||
195
                                                  instruction == EOR_ZPG ||
196
                                                  instruction == AND_ZPG ||
197
                                                  instruction == ORA_ZPG ||
198
                                                  instruction == ADC_ZPG ||
199
                                                  instruction == SBC_ZPG ||
200
                                                  instruction == CMP_ZPG ||
201
                                                  instruction == BIT_ZPG ||
202
                                                  instruction == STA_ZPG ||
203
                                                  instruction == STX_ZPG ||
204
                                                  instruction == STY_ZPG ||
205
                                                  instruction == ASL_ZPG ||
206
                                                  instruction == LSR_ZPG ||
207
                                                  instruction == ROL_ZPG ||
208
                                                  instruction == ROR_ZPG ||
209
                                                  instruction == INC_ZPG ||
210 212 creep
                                                  instruction == DEC_ZPG ||
211 206 creep
                                                  instruction == LDA_ZPX ||
212
                                                  instruction == LDX_ZPY ||
213
                                                  instruction == LDY_ZPX ||
214
                                                  instruction == EOR_ZPX ||
215
                                                  instruction == AND_ZPX ||
216
                                                  instruction == ORA_ZPX ||
217
                                                  instruction == ADC_ZPX ||
218
                                                  instruction == SBC_ZPX ||
219 212 creep
                                                  instruction == CMP_ZPX ||
220
                                                  instruction == ASL_ZPX ||
221
                                                  instruction == LSR_ZPX ||
222
                                                  instruction == ROL_ZPX ||
223
                                                  instruction == ROR_ZPX ||
224
                                                  instruction == INC_ZPX ||
225
                                                  instruction == DEC_ZPX ||
226
                                                  instruction == STA_ZPX ||
227
                                                  instruction == STX_ZPY ||
228 214 creep
                                                  instruction == STY_ZPX ||
229 212 creep
                                                  instruction == LDA_ABX ||
230
                                                  instruction == LDA_ABY ||
231
                                                  instruction == LDX_ABY ||
232
                                                  instruction == LDY_ABX ||
233
                                                  instruction == EOR_ABX ||
234
                                                  instruction == EOR_ABY ||
235
                                                  instruction == AND_ABX ||
236
                                                  instruction == AND_ABY ||
237
                                                  instruction == ORA_ABX ||
238
                                                  instruction == ORA_ABY ||
239
                                                  instruction == ADC_ABX ||
240
                                                  instruction == ADC_ABY ||
241
                                                  instruction == SBC_ABX ||
242
                                                  instruction == SBC_ABY ||
243
                                                  instruction == CMP_ABX ||
244 214 creep
                                                  instruction == CMP_ABY ||
245
                                                  instruction == ASL_ABX ||
246
                                                  instruction == LSR_ABX ||
247
                                                  instruction == ROL_ABX ||
248
                                                  instruction == ROR_ABX ||
249
                                                  instruction == INC_ABX ||
250
                                                  instruction == DEC_ABX
251 212 creep
                                                ) : {
252
                                                        new_state = CYCLE_3;
253
                                                        PCL = input.data_in;
254
                                                };
255
                                                (
256 214 creep
                                                  instruction == LDA_IDX ||
257
                                                  instruction == STA_IDX ||
258
                                                  instruction == ORA_IDX ||
259
                                                  instruction == EOR_IDX ||
260
                                                  instruction == AND_IDX ||
261
                                                  instruction == ADC_IDX ||
262
                                                  instruction == CMP_IDX ||
263 215 creep
                                                  instruction == SBC_IDX ||
264
                                                  instruction == LDA_IDY ||
265
                                                  --instruction == STA_IDY ||
266
                                                  instruction == ORA_IDY ||
267
                                                  instruction == EOR_IDY ||
268
                                                  instruction == AND_IDY ||
269
                                                  instruction == ADC_IDY ||
270
                                                  instruction == CMP_IDY ||
271
                                                  instruction == SBC_IDY
272 214 creep
                                                ) : {
273
                                                        new_state = CYCLE_3;
274
                                                        pointer = input.data_in;
275
                                                };
276
                                                (
277 206 creep
                                                  instruction == TXS_IMP
278
                                                ) : {
279
                                                        new_state = CYCLE_1;
280
                                                        SP_aux    = input.alu_x;
281
                                                };
282
                                                default : {
283
                                                        new_state = CYCLE_1;
284
                                                };
285
                                        };
286
                                };
287
                                CYCLE_3 : {
288
                                        case {
289 214 creep
                                                //JSR_ABS : {
290
                                                //      new_state = CYCLE_4;
291
                                                //      PCH = input.data_in;
292
                                                //};
293 206 creep
                                                (
294
                                                  instruction == BRK_IMP ||
295
                                                  instruction == PLA_IMP ||
296
                                                  instruction == PLP_IMP ||
297
                                                  instruction == RTI_IMP ||
298
                                                  instruction == RTS_IMP ||
299
                                                  instruction == ASL_ZPG ||
300
                                                  instruction == LSR_ZPG ||
301
                                                  instruction == ROL_ZPG ||
302
                                                  instruction == ROR_ZPG ||
303
                                                  instruction == INC_ZPG ||
304 214 creep
                                                  instruction == DEC_ZPG ||
305 206 creep
                                                  instruction == LDA_ZPX ||
306
                                                  instruction == LDX_ZPY ||
307
                                                  instruction == LDY_ZPX ||
308
                                                  instruction == EOR_ZPX ||
309
                                                  instruction == AND_ZPX ||
310
                                                  instruction == ORA_ZPX ||
311
                                                  instruction == ADC_ZPX ||
312
                                                  instruction == SBC_ZPX ||
313 212 creep
                                                  instruction == CMP_ZPX ||
314
                                                  instruction == ASL_ZPX ||
315
                                                  instruction == LSR_ZPX ||
316
                                                  instruction == ROL_ZPX ||
317
                                                  instruction == ROR_ZPX ||
318
                                                  instruction == INC_ZPX ||
319
                                                  instruction == DEC_ZPX ||
320
                                                  instruction == STA_ZPX ||
321
                                                  instruction == STX_ZPY ||
322 214 creep
                                                  instruction == STY_ZPX ||
323
                                                  instruction == LDA_IDX ||
324
                                                  instruction == STA_IDX ||
325
                                                  instruction == ORA_IDX ||
326
                                                  instruction == EOR_IDX ||
327
                                                  instruction == AND_IDX ||
328
                                                  instruction == ADC_IDX ||
329
                                                  instruction == CMP_IDX ||
330
                                                  instruction == SBC_IDX
331 206 creep
                                                ) : {
332
                                                        new_state = CYCLE_4;
333
                                                };
334
                                                (
335 215 creep
                                                  instruction == LDA_IDY ||
336
                                                  --instruction == STA_IDY ||
337
                                                  instruction == ORA_IDY ||
338
                                                  instruction == EOR_IDY ||
339
                                                  instruction == AND_IDY ||
340
                                                  instruction == ADC_IDY ||
341
                                                  instruction == CMP_IDY ||
342
                                                  instruction == SBC_IDY
343
                                                ) : {
344
                                                        new_state = CYCLE_4;
345
                                                        PCL = input.data_in;
346
                                                };
347
                                                (
348 206 creep
                                                  instruction == ADC_ABS ||
349
                                                  instruction == ASL_ABS ||
350
                                                  instruction == BIT_ABS ||
351
                                                  instruction == AND_ABS ||
352
                                                  instruction == CMP_ABS ||
353
                                                  instruction == DEC_ABS ||
354
                                                  instruction == EOR_ABS ||
355
                                                  instruction == INC_ABS ||
356
                                                  instruction == LDA_ABS ||
357
                                                  instruction == LDX_ABS ||
358
                                                  instruction == LDY_ABS ||
359
                                                  instruction == LSR_ABS ||
360
                                                  instruction == ORA_ABS ||
361
                                                  instruction == ROL_ABS ||
362
                                                  instruction == ROR_ABS ||
363
                                                  instruction == SBC_ABS ||
364
                                                  instruction == STA_ABS ||
365
                                                  instruction == STX_ABS ||
366 212 creep
                                                  instruction == STY_ABS ||
367
                                                  instruction == LDA_ABX ||
368
                                                  instruction == LDA_ABY ||
369
                                                  instruction == LDX_ABY ||
370
                                                  instruction == LDY_ABX ||
371
                                                  instruction == EOR_ABX ||
372
                                                  instruction == EOR_ABY ||
373
                                                  instruction == AND_ABX ||
374
                                                  instruction == AND_ABY ||
375
                                                  instruction == ORA_ABX ||
376
                                                  instruction == ORA_ABY ||
377
                                                  instruction == ADC_ABX ||
378
                                                  instruction == ADC_ABY ||
379
                                                  instruction == SBC_ABX ||
380
                                                  instruction == SBC_ABY ||
381
                                                  instruction == CMP_ABX ||
382 214 creep
                                                  instruction == CMP_ABY ||
383
                                                  instruction == ASL_ABX ||
384
                                                  instruction == LSR_ABX ||
385
                                                  instruction == ROL_ABX ||
386
                                                  instruction == ROR_ABX ||
387
                                                  instruction == INC_ABX ||
388
                                                  instruction == DEC_ABX
389 206 creep
                                                ) : {
390
                                                        new_state = CYCLE_4;
391
                                                        PCH = input.data_in;
392
                                                };
393
                                                (
394
                                                  instruction == JMP_ABS
395
                                                ) : {
396
                                                        new_state = CYCLE_1;
397
                                                        PCH = input.data_in;
398
                                                };
399
                                                default : {
400
                                                        new_state = CYCLE_1;
401
                                                };
402
                                        };
403
                                };
404
                                CYCLE_4 : {
405
                                        case {
406
                                                //JSR_ABS : {
407
                                                //      new_state = CYCLE_5;
408
                                                //};
409
                                                (
410
                                                  instruction == RTS_IMP
411
                                                ) : {
412
                                                        new_state = CYCLE_5;
413
                                                        PCL = input.data_in;
414
                                                };
415
                                                (
416
                                                  instruction == ASL_ABS ||
417
                                                  instruction == BRK_IMP ||
418
                                                  instruction == DEC_ABS ||
419
                                                  instruction == INC_ABS ||
420
                                                  instruction == LSR_ABS ||
421
                                                  instruction == ROL_ABS ||
422
                                                  instruction == ROR_ABS ||
423
                                                  instruction == RTI_IMP ||
424
                                                  instruction == ASL_ZPG ||
425
                                                  instruction == LSR_ZPG ||
426
                                                  instruction == ROL_ZPG ||
427
                                                  instruction == ROR_ZPG ||
428
                                                  instruction == INC_ZPG ||
429 212 creep
                                                  instruction == DEC_ZPG ||
430
                                                  instruction == ASL_ZPX ||
431
                                                  instruction == LSR_ZPX ||
432
                                                  instruction == ROL_ZPX ||
433
                                                  instruction == ROR_ZPX ||
434
                                                  instruction == INC_ZPX ||
435
                                                  instruction == DEC_ZPX ||
436 214 creep
                                                  instruction == ASL_ABX ||
437
                                                  instruction == LSR_ABX ||
438
                                                  instruction == ROL_ABX ||
439
                                                  instruction == ROR_ABX ||
440
                                                  instruction == INC_ABX ||
441
                                                  instruction == DEC_ABX ||
442 212 creep
                                                  (
443
                                                        more_cycles == TRUE &&
444
                                                        (
445
                                                          instruction == LDA_ABX ||
446
                                                          instruction == LDA_ABY ||
447
                                                          instruction == LDX_ABY ||
448
                                                          instruction == LDY_ABX ||
449
                                                          instruction == EOR_ABX ||
450
                                                          instruction == EOR_ABY ||
451
                                                          instruction == AND_ABX ||
452
                                                          instruction == AND_ABY ||
453
                                                          instruction == ORA_ABX ||
454
                                                          instruction == ORA_ABY ||
455
                                                          instruction == ADC_ABX ||
456
                                                          instruction == ADC_ABY ||
457
                                                          instruction == SBC_ABX ||
458
                                                          instruction == SBC_ABY ||
459
                                                          instruction == CMP_ABX ||
460
                                                          instruction == CMP_ABY
461
                                                        )
462
                                                  )
463 206 creep
                                                ) : {
464
                                                        new_state = CYCLE_5;
465
                                                };
466 214 creep
                                                (
467
                                                  instruction == LDA_IDX ||
468
                                                  instruction == STA_IDX ||
469
                                                  instruction == ORA_IDX ||
470
                                                  instruction == EOR_IDX ||
471
                                                  instruction == AND_IDX ||
472
                                                  instruction == ADC_IDX ||
473
                                                  instruction == CMP_IDX ||
474
                                                  instruction == SBC_IDX
475
                                                ) : {
476
                                                        new_state = CYCLE_5;
477
                                                        PCL = input.data_in;
478
                                                };
479 215 creep
                                                (
480
                                                  instruction == LDA_IDY ||
481
                                                  --instruction == STA_IDY ||
482
                                                  instruction == ORA_IDY ||
483
                                                  instruction == EOR_IDY ||
484
                                                  instruction == AND_IDY ||
485
                                                  instruction == ADC_IDY ||
486
                                                  instruction == CMP_IDY ||
487
                                                  instruction == SBC_IDY
488
                                                ) : {
489
                                                        new_state = CYCLE_5;
490
                                                        PCH = input.data_in;
491
                                                };
492 206 creep
                                                default : {
493
                                                        new_state = CYCLE_1;
494
                                                };
495
                                        };
496
                                };
497
                                CYCLE_5 : {
498
                                        case {
499
                                                //JSR_ABS : {
500
                                                //      new_state = CYCLE_6;
501
                                                //};
502
                                                (
503
                                                  instruction == RTI_IMP
504
                                                ) : {
505
                                                        new_state = CYCLE_6;
506
                                                        PCL = input.data_in;
507
                                                };
508
                                                (
509
                                                  instruction == RTS_IMP
510
                                                ) : {
511
                                                        new_state = CYCLE_6;
512
                                                        PCH = input.data_in;
513
                                                };
514
                                                (
515
                                                  instruction == ASL_ABS ||
516
                                                  instruction == BRK_IMP ||
517
                                                  instruction == DEC_ABS ||
518
                                                  instruction == INC_ABS ||
519
                                                  instruction == LSR_ABS ||
520
                                                  instruction == ROL_ABS ||
521 212 creep
                                                  instruction == ROR_ABS ||
522
                                                  instruction == ASL_ZPX ||
523
                                                  instruction == LSR_ZPX ||
524
                                                  instruction == ROL_ZPX ||
525
                                                  instruction == ROR_ZPX ||
526
                                                  instruction == INC_ZPX ||
527 214 creep
                                                  instruction == DEC_ZPX ||
528
                                                  instruction == ASL_ABX ||
529
                                                  instruction == LSR_ABX ||
530
                                                  instruction == ROL_ABX ||
531
                                                  instruction == ROR_ABX ||
532
                                                  instruction == INC_ABX ||
533 215 creep
                                                  instruction == DEC_ABX ||
534
                                                  (
535
                                                    more_cycles == TRUE &&
536
                                                    (
537
                                                      instruction == LDA_IDY ||
538
                                                      --instruction == STA_IDY ||
539
                                                      instruction == ORA_IDY ||
540
                                                      instruction == EOR_IDY ||
541
                                                      instruction == AND_IDY ||
542
                                                      instruction == ADC_IDY ||
543
                                                      instruction == CMP_IDY ||
544
                                                      instruction == SBC_IDY
545
                                                    )
546
                                                  )
547 206 creep
                                                ) : {
548
                                                        new_state = CYCLE_6;
549
                                                };
550 212 creep
                                                (
551 214 creep
                                                  instruction == LDA_IDX ||
552
                                                  instruction == STA_IDX ||
553
                                                  instruction == ORA_IDX ||
554
                                                  instruction == EOR_IDX ||
555
                                                  instruction == AND_IDX ||
556
                                                  instruction == ADC_IDX ||
557
                                                  instruction == CMP_IDX ||
558
                                                  instruction == SBC_IDX
559 212 creep
                                                ) : {
560 214 creep
                                                        new_state = CYCLE_6;
561
                                                        PCH = input.data_in;
562 212 creep
                                                };
563 206 creep
                                                default : {
564
                                                        new_state = CYCLE_1;
565
                                                };
566
                                        };
567
                                };
568
                                CYCLE_6 : {
569
                                        case {
570
                                                (
571
                                                  instruction == BRK_IMP
572
                                                ) : {
573
                                                        new_state = CYCLE_7;
574
                                                        PCL = input.data_in;
575
                                                };
576
                                                (
577
                                                  instructions == RTI_IMP
578
                                                ) : {
579
                                                        new_state = CYCLE_1;
580
                                                        PCH = input.data_in;
581
                                                };
582 214 creep
                                                (
583
                                                  instruction == ASL_ABX ||
584
                                                  instruction == LSR_ABX ||
585
                                                  instruction == ROL_ABX ||
586
                                                  instruction == ROR_ABX ||
587
                                                  instruction == INC_ABX ||
588
                                                  instruction == DEC_ABX
589
                                                ) : {
590
                                                        new_state = CYCLE_7;
591
                                                };
592 206 creep
                                                default : {
593
                                                        new_state = CYCLE_1;
594
                                                };
595
                                        };
596
                                };
597
                                CYCLE_7 : {
598 214 creep
                                        case (instruction) {
599
                                                BRK_IMP : {
600
                                                        new_state = CYCLE_1;
601
                                                        PCH = input.data_in;
602
                                                };
603
                                                default : {
604
                                                        new_state = CYCLE_1;
605
                                                };
606 206 creep
                                        };
607 214 creep
                                };
608 206 creep
                        };
609
                        old_input = new_input;
610
                        new_input = input;
611
                };
612
        };
613
 
614
        compare(addr: uint(bits:13), mem_rw:bit, data_out:byte, alu_opcode:valid_opcodes, alu_a:byte, alu_enable:bit) is {
615
                case (old_state) {
616
                        RESET    : {
617
                                print_state();
618
                                rst = 1;
619
                                rst_counter = rst_counter + 1;
620
                        };
621
                        CYCLE_1 : {
622 212 creep
                                more_cycles = FALSE;
623 206 creep
                                print_state();
624
                                print addr;
625
                                last_instruction = instructions;
626
                                instructions = instruction;
627
                                if (mem_rw != 0) {
628
                                        dut_error("Mem_rw is Wrong!");
629
                                };
630
                                if (rst == 0) {
631
                                        case {
632
                                                (
633
                                                  last_instruction == ADC_ABS ||
634
                                                  last_instruction == ADC_IMM ||
635
                                                  last_instruction == AND_ABS ||
636
                                                  last_instruction == AND_IMM ||
637
                                                  last_instruction == BIT_ABS ||
638
                                                  last_instruction == CMP_ABS ||
639
                                                  last_instruction == CMP_IMM ||
640
                                                  last_instruction == CPX_IMM ||
641
                                                  last_instruction == CPY_IMM ||
642
                                                  last_instruction == EOR_ABS ||
643
                                                  last_instruction == EOR_IMM ||
644
                                                  last_instruction == LDA_ABS ||
645
                                                  last_instruction == LDA_IMM ||
646
                                                  last_instruction == LDX_ABS ||
647
                                                  last_instruction == LDX_IMM ||
648
                                                  last_instruction == LDY_ABS ||
649
                                                  last_instruction == LDY_IMM ||
650
                                                  last_instruction == ORA_ABS ||
651
                                                  last_instruction == ORA_IMM ||
652
                                                  last_instruction == PLA_IMP ||
653
                                                  last_instruction == PLP_IMP ||
654
                                                  last_instruction == SBC_ABS ||
655
                                                  last_instruction == SBC_IMM ||
656
                                                  last_instruction == LDA_ZPG ||
657
                                                  last_instruction == LDX_ZPG ||
658
                                                  last_instruction == LDY_ZPG ||
659
                                                  last_instruction == EOR_ZPG ||
660
                                                  last_instruction == AND_ZPG ||
661
                                                  last_instruction == ORA_ZPG ||
662
                                                  last_instruction == ADC_ZPG ||
663
                                                  last_instruction == SBC_ZPG ||
664
                                                  last_instruction == CMP_ZPG ||
665 212 creep
                                                  last_instruction == BIT_ZPG ||
666
                                                  last_instruction == LDA_ZPX ||
667
                                                  last_instruction == LDX_ZPY ||
668
                                                  last_instruction == LDY_ZPX ||
669
                                                  last_instruction == EOR_ZPX ||
670
                                                  last_instruction == AND_ZPX ||
671
                                                  last_instruction == ORA_ZPX ||
672
                                                  last_instruction == ADC_ZPX ||
673
                                                  last_instruction == SBC_ZPX ||
674
                                                  last_instruction == CMP_ZPX ||
675
                                                  last_instruction == LDA_ABX ||
676
                                                  last_instruction == LDA_ABY ||
677
                                                  last_instruction == LDX_ABY ||
678
                                                  last_instruction == LDY_ABX ||
679
                                                  last_instruction == EOR_ABX ||
680
                                                  last_instruction == EOR_ABY ||
681
                                                  last_instruction == AND_ABX ||
682
                                                  last_instruction == AND_ABY ||
683
                                                  last_instruction == ORA_ABX ||
684
                                                  last_instruction == ORA_ABY ||
685
                                                  last_instruction == ADC_ABX ||
686
                                                  last_instruction == ADC_ABY ||
687
                                                  last_instruction == SBC_ABX ||
688
                                                  last_instruction == SBC_ABY ||
689
                                                  last_instruction == CMP_ABX ||
690 214 creep
                                                  last_instruction == CMP_ABY ||
691
                                                  last_instruction == LDA_IDX ||
692
                                                  last_instruction == ORA_IDX ||
693
                                                  last_instruction == EOR_IDX ||
694
                                                  last_instruction == AND_IDX ||
695
                                                  last_instruction == ADC_IDX ||
696
                                                  last_instruction == CMP_IDX ||
697 215 creep
                                                  last_instruction == SBC_IDX ||
698
                                                  last_instruction == LDA_IDY ||
699
                                                  last_instruction == ORA_IDY ||
700
                                                  last_instruction == EOR_IDY ||
701
                                                  last_instruction == AND_IDY ||
702
                                                  last_instruction == ADC_IDY ||
703
                                                  last_instruction == CMP_IDY ||
704
                                                  last_instruction == SBC_IDY
705 206 creep
                                                ) : {
706
                                                        if (alu_opcode != last_instruction) {
707
                                                                dut_error("alu_opcode is Wrong!");
708
                                                        };
709
                                                        if (alu_enable != 1) {
710
                                                                dut_error("alu_enable is Wrong!");
711
                                                        };
712
                                                        if (addr != PC) {
713
                                                                dut_error("Address is Wrong!");
714
                                                        };
715
                                                };
716 214 creep
                                                --(
717
                                                --) : {
718
                                                --      if (alu_opcode != last_instruction) {
719
                                                --              dut_error("alu_opcode is Wrong!");
720
                                                --      };
721
                                                --      if (alu_enable != 1) {
722
                                                --              dut_error("alu_enable is Wrong!");
723
                                                --      };
724
                                                --      if (addr[7:0] != PCL) {
725
                                                --              dut_error("Address is Wrong!");
726
                                                --      };
727
                                                --      if (addr[12:8] != PCH[4:0]) {
728
                                                --              dut_error("Address is Wrong!");
729
                                                --      };
730
                                                --};
731 206 creep
                                                default : {
732
                                                        if (alu_opcode.as_a(byte) != 0) {
733
                                                                dut_error("alu_opcode is Wrong!");
734
                                                        };
735
                                                        if (alu_enable != 0) {
736
                                                                dut_error("alu_enable is Wrong!");
737
                                                        };
738
                                                        if (alu_a != 0) {
739
                                                                dut_error("alu_a is Wrong!");
740
                                                        };
741
                                                        if (addr != PC) {
742
                                                                dut_error("Address is Wrong!");
743
                                                        };
744
                                                };
745
                                        };
746
                                }
747
                                else {
748
                                        rst = 0;
749
                                        if (alu_enable != 0) {
750
                                                dut_error("alu_enable is Wrong!");
751
                                        };
752
                                        if (alu_opcode.as_a(byte) != 0) {
753
                                                dut_error("alu_opcode is Wrong!");
754
                                        };
755
                                        if (alu_a != 0) {
756
                                                dut_error("alu_a is Wrong!");
757
                                        };
758
                                        if (addr != PC) {
759
                                                dut_error("Address is Wrong!");
760
                                        };
761
                                };
762
                                PC = PC + 1;
763
                        };
764
                        CYCLE_2 : {
765
                                print_state();
766
                                print addr;
767
                                if (addr != PC) {
768
                                        dut_error("ADDR should be equal PC!");
769
                                };
770
                                if (mem_rw != 0) {
771
                                        dut_error("MEM_RW should be 0 (READ)");
772
                                };
773
                                case {
774
                                        (
775
                                          instructions == ADC_ABS ||
776
                                          instructions == ADC_IMM ||
777
                                          instructions == AND_ABS ||
778
                                          instructions == AND_IMM ||
779
                                          instructions == ASL_ABS ||
780
                                          instructions == BIT_ABS ||
781
                                          instructions == BRK_IMP ||
782
                                          instructions == CMP_ABS ||
783
                                          instructions == CMP_IMM ||
784
                                          instructions == CPX_IMM ||
785
                                          instructions == CPY_IMM ||
786
                                          instructions == DEC_ABS ||
787
                                          instructions == EOR_ABS ||
788
                                          instructions == EOR_IMM ||
789
                                          instructions == INC_ABS ||
790
                                          instructions == JMP_ABS ||
791
                                          instructions == LDA_ABS ||
792
                                          instructions == LDA_IMM ||
793
                                          instructions == LDX_ABS ||
794
                                          instructions == LDX_IMM ||
795
                                          instructions == LDY_ABS ||
796
                                          instructions == LDY_IMM ||
797
                                          instructions == LSR_ABS ||
798
                                          instructions == ORA_ABS ||
799
                                          instructions == ORA_IMM ||
800
                                          instructions == ROL_ABS ||
801
                                          instructions == ROR_ABS ||
802
                                          instructions == SBC_ABS ||
803
                                          instructions == SBC_IMM ||
804
                                          instructions == LDA_ZPG ||
805
                                          instructions == LDX_ZPG ||
806
                                          instructions == LDY_ZPG ||
807
                                          instructions == EOR_ZPG ||
808
                                          instructions == AND_ZPG ||
809
                                          instructions == ORA_ZPG ||
810
                                          instructions == ADC_ZPG ||
811
                                          instructions == SBC_ZPG ||
812
                                          instructions == CMP_ZPG ||
813
                                          instructions == BIT_ZPG ||
814
                                          instructions == ASL_ZPG ||
815
                                          instructions == LSR_ZPG ||
816
                                          instructions == ROL_ZPG ||
817
                                          instructions == ROR_ZPG ||
818
                                          instructions == INC_ZPG ||
819 212 creep
                                          instructions == DEC_ZPG ||
820
                                          instructions == LDA_ZPX ||
821
                                          instructions == LDX_ZPY ||
822
                                          instructions == LDY_ZPX ||
823
                                          instructions == EOR_ZPX ||
824
                                          instructions == AND_ZPX ||
825
                                          instructions == ORA_ZPX ||
826
                                          instructions == ADC_ZPX ||
827
                                          instructions == SBC_ZPX ||
828
                                          instructions == CMP_ZPX ||
829
                                          instructions == ASL_ZPX ||
830
                                          instructions == LSR_ZPX ||
831
                                          instructions == ROL_ZPX ||
832
                                          instructions == ROR_ZPX ||
833
                                          instructions == INC_ZPX ||
834
                                          instructions == DEC_ZPX ||
835
                                          instructions == STX_ZPY ||
836
                                          instructions == STY_ZPX ||
837
                                          instructions == STA_ZPX ||
838
                                          instructions == LDA_ABX ||
839
                                          instructions == LDA_ABY ||
840
                                          instructions == LDX_ABY ||
841
                                          instructions == LDY_ABX ||
842
                                          instructions == EOR_ABX ||
843
                                          instructions == EOR_ABY ||
844
                                          instructions == AND_ABX ||
845
                                          instructions == AND_ABY ||
846
                                          instructions == ORA_ABX ||
847
                                          instructions == ORA_ABY ||
848
                                          instructions == ADC_ABX ||
849
                                          instructions == ADC_ABY ||
850
                                          instructions == SBC_ABX ||
851
                                          instructions == SBC_ABY ||
852
                                          instructions == CMP_ABX ||
853 214 creep
                                          instructions == CMP_ABY ||
854
                                          instructions == ASL_ABX ||
855
                                          instructions == LSR_ABX ||
856
                                          instructions == ROL_ABX ||
857
                                          instructions == ROR_ABX ||
858
                                          instructions == INC_ABX ||
859
                                          instructions == DEC_ABX ||
860
                                          instructions == LDA_IDX ||
861
                                          instructions == STA_IDX ||
862
                                          instructions == ORA_IDX ||
863
                                          instructions == EOR_IDX ||
864
                                          instructions == AND_IDX ||
865
                                          instructions == ADC_IDX ||
866
                                          instructions == CMP_IDX ||
867 215 creep
                                          instructions == SBC_IDX ||
868
                                          instructions == LDA_IDY ||
869
                                          --instructions == STA_IDY ||
870
                                          instructions == ORA_IDY ||
871
                                          instructions == EOR_IDY ||
872
                                          instructions == AND_IDY ||
873
                                          instructions == ADC_IDY ||
874
                                          instructions == CMP_IDY ||
875
                                          instructions == SBC_IDY
876 206 creep
                                        ) : {
877
                                                if (alu_opcode.as_a(byte) != 0) {
878
                                                        dut_error("Opcode is Wrong!");
879
                                                };
880
                                                if (alu_enable != 0) {
881
                                                        dut_error("BRK_IMP is Wrong!");
882
                                                };
883
                                                PC = PC + 1;
884
                                        };
885 212 creep
                                        -- TODO: STX and STY should not
886
                                        -- TODO: they dont need access to alu at any cycle
887
                                        -- TODO: because X and Y are available at alu_x and alu_y
888 206 creep
                                        (
889
                                          instructions == STA_ABS ||
890 212 creep
                                          instructions == STA_ZPG ||
891
                                          instructions == STX_ABS ||
892 206 creep
                                          instructions == STY_ABS ||
893
                                          instructions == STX_ZPG ||
894 212 creep
                                          instructions == STY_ZPG
895 206 creep
                                        ) : {
896
                                                if (alu_opcode != instructions) {
897
                                                        dut_error("Opcode is Wrong!");
898
                                                };
899
                                                if (alu_enable != 1) {
900
                                                        dut_error("ASL_ACC is Wrong!");
901
                                                };
902
                                                PC = PC + 1;
903
                                        };
904
                                        (
905
                                          instructions == NOP_IMP ||
906
                                          instructions == PHP_IMP ||
907
                                          instructions == PLA_IMP ||
908
                                          instructions == PLP_IMP ||
909
                                          instructions == RTI_IMP ||
910
                                          instructions == RTS_IMP
911
 
912
                                        ) : {
913
                                                if (alu_opcode.as_a(byte) != 0) {
914
                                                        dut_error("Opcode is Wrong!");
915
                                                };
916
                                                if (alu_enable != 0) {
917
                                                        dut_error("ASL_ACC is Wrong!");
918
                                                };
919
                                        };
920
                                        (
921
                                          instructions == ASL_ACC ||
922
                                          instructions == CLC_IMP ||
923
                                          instructions == CLD_IMP ||
924
                                          instructions == CLI_IMP ||
925
                                          instructions == CLV_IMP ||
926
                                          instructions == DEX_IMP ||
927
                                          instructions == DEY_IMP ||
928
                                          instructions == INX_IMP ||
929
                                          instructions == INY_IMP ||
930
                                          instructions == LSR_ACC ||
931
                                          instructions == PHA_IMP ||
932
                                          instructions == ROL_ACC ||
933 214 creep
                                          instructions == ROR_ACC ||
934 206 creep
                                          instructions == SEC_IMP ||
935
                                          instructions == SED_IMP ||
936
                                          instructions == SEI_IMP ||
937
                                          instructions == TAX_IMP ||
938
                                          instructions == TAY_IMP ||
939
                                          instructions == TXA_IMP ||
940
                                          instructions == TYA_IMP
941
                                        ) : {
942
                                                if (alu_opcode != instructions) {
943
                                                        dut_error("Opcode is Wrong!");
944
                                                };
945
                                                if (alu_enable != 1) {
946
                                                        dut_error("ASL_ACC is Wrong!");
947
                                                };
948
                                        };
949
                                        //JSR_ABS : {
950
                                        //      if (alu_opcode.as_a(byte) != 0) {
951
                                        //              dut_error("Opcode is Wrong!");
952
                                        //      };
953
                                        //      if (mem_rw != 0) {
954
                                        //              dut_error("MEM_RW should be 1 (WRITE)");
955
                                        //      };
956
                                        //      if (alu_enable != 0) {
957
                                        //              dut_error("JSR_IMP is Wrong!");
958
                                        //      };
959
                                        //      if (addr != PC) {
960
                                        //              dut_error("ADDR should be equal SP!");
961
                                        //      };
962
                                        //      PC = PC + 1;
963
                                        //};
964
                                        (
965
                                          instructions == TSX_IMP
966
                                        ) : {
967
                                                if (alu_opcode != instructions) {
968
                                                        dut_error("Opcode is Wrong!");
969
                                                };
970
                                                if (alu_enable != 1) {
971
                                                        dut_error("TSX_IMP is Wrong!");
972
                                                };
973
                                                if (alu_a != SP) {
974
                                                        dut_error("TSX_IMP is Wrong!");
975
                                                };
976
                                        };
977
                                        (
978
                                          instructions == TXS_IMP
979
                                        ) : {
980
                                                if (alu_opcode != instructions) {
981
                                                        dut_error("Opcode is Wrong!");
982
                                                };
983
                                                if (alu_enable != 1) {
984
                                                        dut_error("TXS_IMP is Wrong!");
985
                                                };
986
                                                SP = SP_aux;
987
                                        };
988
                                };
989
                        };
990
                        CYCLE_3 : {
991
                                print_state();
992
                                print addr;
993
                                case {
994
                                        (
995
                                          instructions == BRK_IMP
996
                                        ) : {
997
                                                if (alu_opcode.as_a(byte) != 0) {
998
                                                        dut_error("Opcode is Wrong!");
999
                                                };
1000
                                                if (mem_rw != 1) {
1001
                                                        dut_error("MEM_RW should be 1 (WRITE)");
1002
                                                };
1003
                                                if (alu_enable != 0) {
1004
                                                        dut_error("BRK_IMP is Wrong!");
1005
                                                };
1006
                                                if (data_out[4:0] != PC[12:8] && data_out[7:5] != 0) {
1007
                                                        dut_error("BRK_IMP is Wrong!");
1008
                                                };
1009
                                                if (addr != SP + 256) {
1010
                                                        dut_error("ADDR should be equal SP!");
1011
                                                };
1012
                                                SP = SP - 1;
1013
                                        };
1014
                                        //JSR_ABS : {
1015
                                        //      if (alu_opcode.as_a(byte) != 0) {
1016
                                        //              dut_error("Opcode is Wrong!");
1017
                                        //      };
1018
                                        //      if (mem_rw != 0) {
1019
                                        //              dut_error("MEM_RW should be 1 (WRITE)");
1020
                                        //      };
1021
                                        //      if (alu_enable != 0) {
1022
                                        //              dut_error("JSR_IMP is Wrong!");
1023
                                        //      };
1024
                                        //      if (addr != PC) {
1025
                                        //              dut_error("ADDR should be equal PC!");
1026
                                        //      };
1027
                                        //};
1028 212 creep
                                        -- TODO: This is probably an error STA should not use ALU on the third cycle
1029 206 creep
                                        (
1030 212 creep
                                          instructions == STA_ZPX ||
1031
                                          instructions == STX_ZPY ||
1032
                                          instructions == STY_ZPX
1033
                                        ) : {
1034
                                                if (alu_opcode != instructions) {
1035
                                                        dut_error("Opcode is Wrong!");
1036
                                                };
1037
                                                if (alu_enable != 1) {
1038
                                                        dut_error("ASL_ACC is Wrong!");
1039
                                                };
1040
                                                if (mem_rw != 0) {
1041
                                                        dut_error("MEM_RW should be 1 (WRITE)");
1042
                                                };
1043
                                                if (addr != PCL) {
1044
                                                        dut_error("ADDR should be equal SP!");
1045
                                                };
1046
                                        };
1047
                                        (
1048 206 creep
                                          instructions == STA_ZPG ||
1049
                                          instructions == STX_ZPG ||
1050
                                          instructions == STY_ZPG
1051
                                        ) : {
1052
                                                if (alu_opcode.as_a(byte) != 0) {
1053
                                                        dut_error("Opcode is Wrong!");
1054
                                                };
1055
                                                if (alu_enable != 0) {
1056
                                                        dut_error("ASL_ACC is Wrong!");
1057
                                                };
1058
                                                if (mem_rw != 1) {
1059
                                                        dut_error("MEM_RW should be 1 (WRITE)");
1060
                                                };
1061
                                                if (addr != PCL) {
1062
                                                        dut_error("ADDR should be equal SP!");
1063
                                                };
1064
                                        };
1065
                                        (
1066
                                          instructions == JMP_ABS
1067
                                        ) : {
1068
                                                if (alu_opcode.as_a(byte) != 0) {
1069
                                                        dut_error("Opcode is Wrong!");
1070
                                                };
1071
                                                if (alu_enable != 0) {
1072
                                                        dut_error("ASL_ACC is Wrong!");
1073
                                                };
1074
                                                if (mem_rw != 0) {
1075
                                                        dut_error("MEM_RW should be 1 (WRITE)");
1076
                                                };
1077
                                                PC[7:0] = PCL;
1078
                                                PC[12:8] = PCH[4:0];
1079
                                        };
1080
                                        (
1081
                                          instructions == LDA_ZPX ||
1082
                                          instructions == LDX_ZPY ||
1083
                                          instructions == LDY_ZPX ||
1084
                                          instructions == EOR_ZPX ||
1085
                                          instructions == AND_ZPX ||
1086
                                          instructions == ORA_ZPX ||
1087
                                          instructions == ADC_ZPX ||
1088
                                          instructions == SBC_ZPX ||
1089 212 creep
                                          instructions == CMP_ZPX ||
1090
                                          instructions == ASL_ZPX ||
1091
                                          instructions == LSR_ZPX ||
1092
                                          instructions == ROL_ZPX ||
1093
                                          instructions == ROR_ZPX ||
1094
                                          instructions == INC_ZPX ||
1095
                                          instructions == DEC_ZPX
1096 206 creep
                                        ) : {
1097
                                                if (alu_opcode.as_a(byte) != 0) {
1098
                                                        dut_error("Opcode is Wrong!");
1099
                                                };
1100
                                                if (alu_enable != 0) {
1101
                                                        dut_error("ASL_ACC is Wrong!");
1102
                                                };
1103
                                                if (mem_rw != 0) {
1104
                                                        dut_error("MEM_RW should be 0 (WRITE)");
1105
                                                };
1106
                                                if (addr != PCL) {
1107
                                                        dut_error("ADDR should be equal SP!");
1108
                                                };
1109
                                        };
1110
                                        (
1111 214 creep
                                          instructions == LDA_IDX ||
1112
                                          instructions == STA_IDX ||
1113
                                          instructions == ORA_IDX ||
1114
                                          instructions == EOR_IDX ||
1115
                                          instructions == AND_IDX ||
1116
                                          instructions == ADC_IDX ||
1117
                                          instructions == CMP_IDX ||
1118 215 creep
                                          instructions == SBC_IDX ||
1119
                                          instructions == LDA_IDY ||
1120
                                          --instructions == STA_IDY ||
1121
                                          instructions == ORA_IDY ||
1122
                                          instructions == EOR_IDY ||
1123
                                          instructions == AND_IDY ||
1124
                                          instructions == ADC_IDY ||
1125
                                          instructions == CMP_IDY ||
1126
                                          instructions == SBC_IDY
1127 214 creep
                                        ) : {
1128
                                                if (alu_opcode.as_a(byte) != 0) {
1129
                                                        dut_error("Opcode is Wrong!");
1130
                                                };
1131
                                                if (alu_enable != 0) {
1132
                                                        dut_error("ASL_ACC is Wrong!");
1133
                                                };
1134
                                                if (mem_rw != 0) {
1135
                                                        dut_error("MEM_RW should be 0 (WRITE)");
1136
                                                };
1137
                                                if (addr != pointer) {
1138
                                                        dut_error("ADDR should be equal SP!");
1139
                                                };
1140
                                        };
1141
                                        (
1142 206 creep
                                          instructions == ADC_ABS ||
1143
                                          instructions == AND_ABS ||
1144
                                          instructions == ASL_ABS ||
1145
                                          instructions == BIT_ABS ||
1146
                                          instructions == CMP_ABS ||
1147
                                          instructions == DEC_ABS ||
1148
                                          instructions == EOR_ABS ||
1149
                                          instructions == INC_ABS ||
1150
                                          instructions == LDA_ABS ||
1151
                                          instructions == LDX_ABS ||
1152
                                          instructions == LDY_ABS ||
1153
                                          instructions == LSR_ABS ||
1154
                                          instructions == ORA_ABS ||
1155
                                          instructions == ROL_ABS ||
1156
                                          instructions == ROR_ABS ||
1157
                                          instructions == SBC_ABS ||
1158
                                          instructions == STA_ABS ||
1159
                                          instructions == STX_ABS ||
1160 212 creep
                                          instructions == STY_ABS ||
1161
                                          instructions == LDA_ABX ||
1162
                                          instructions == LDY_ABX ||
1163
                                          instructions == EOR_ABX ||
1164
                                          instructions == AND_ABX ||
1165
                                          instructions == ORA_ABX ||
1166
                                          instructions == ADC_ABX ||
1167
                                          instructions == SBC_ABX ||
1168 214 creep
                                          instructions == CMP_ABX ||
1169
                                          instructions == ASL_ABX ||
1170
                                          instructions == LSR_ABX ||
1171
                                          instructions == ROL_ABX ||
1172
                                          instructions == ROR_ABX ||
1173
                                          instructions == INC_ABX ||
1174
                                          instructions == DEC_ABX
1175 206 creep
                                        ) : {
1176
                                                if (alu_opcode.as_a(byte) != 0) {
1177
                                                        dut_error("Opcode is Wrong!");
1178
                                                };
1179
                                                if (alu_enable != 0) {
1180
                                                        dut_error("ASL_ACC is Wrong!");
1181
                                                };
1182
                                                if (addr != PC) {
1183
                                                        dut_error("ADDR should be equal SP!");
1184
                                                };
1185
                                                if (mem_rw != 0) {
1186
                                                        dut_error("MEM_RW should be 1 (WRITE)");
1187
                                                };
1188
                                                PC = PC + 1;
1189 212 creep
                                                if (PCL + X > 255) {
1190
                                                        more_cycles = TRUE;
1191
                                                };
1192 206 creep
                                        };
1193
                                        (
1194 212 creep
                                          instructions == LDA_ABY ||
1195
                                          instructions == LDX_ABY ||
1196
                                          instructions == AND_ABY ||
1197
                                          instructions == EOR_ABY ||
1198
                                          instructions == ORA_ABY ||
1199
                                          instructions == ADC_ABY ||
1200
                                          instructions == SBC_ABY ||
1201
                                          instructions == CMP_ABY
1202
                                        ) : {
1203
                                                if (alu_opcode.as_a(byte) != 0) {
1204
                                                        dut_error("Opcode is Wrong!");
1205
                                                };
1206
                                                if (alu_enable != 0) {
1207
                                                        dut_error("ASL_ACC is Wrong!");
1208
                                                };
1209
                                                if (addr != PC) {
1210
                                                        dut_error("ADDR should be equal SP!");
1211
                                                };
1212
                                                if (mem_rw != 0) {
1213
                                                        dut_error("MEM_RW should be 1 (WRITE)");
1214
                                                };
1215
                                                PC = PC + 1;
1216
                                                if (PCL + Y > 255) {
1217
                                                        more_cycles = TRUE;
1218
                                                };
1219
                                        };
1220
                                        (
1221 206 creep
                                          instructions == LDA_ZPG ||
1222
                                          instructions == LDX_ZPG ||
1223
                                          instructions == LDY_ZPG ||
1224
                                          instructions == EOR_ZPG ||
1225
                                          instructions == AND_ZPG ||
1226
                                          instructions == ORA_ZPG ||
1227
                                          instructions == ADC_ZPG ||
1228
                                          instructions == SBC_ZPG ||
1229
                                          instructions == CMP_ZPG ||
1230
                                          instructions == BIT_ZPG ||
1231
                                          instructions == ASL_ZPG ||
1232
                                          instructions == LSR_ZPG ||
1233
                                          instructions == ROL_ZPG ||
1234
                                          instructions == ROR_ZPG ||
1235
                                          instructions == INC_ZPG ||
1236
                                          instructions == DEC_ZPG
1237
                                        ) : {
1238
                                                if (alu_opcode.as_a(byte) != 0) {
1239
                                                        dut_error("Opcode is Wrong!");
1240
                                                };
1241
                                                if (alu_enable != 0) {
1242
                                                        dut_error("ASL_ACC is Wrong!");
1243
                                                };
1244
                                                if (mem_rw != 0) {
1245
                                                        dut_error("MEM_RW should be 1 (WRITE)");
1246
                                                };
1247
                                                if (addr != PCL) {
1248
                                                        dut_error("ADDR should be equal SP!");
1249
                                                };
1250
                                        };
1251
                                        (
1252
                                          instructions == PHA_IMP ||
1253
                                          instructions == PHP_IMP
1254
                                        ) : {
1255
                                                if (alu_opcode.as_a(byte) != 0) {
1256
                                                        dut_error("Opcode is Wrong!");
1257
                                                };
1258
                                                if (mem_rw != 1) {
1259
                                                        dut_error("MEM_RW should be 1 (WRITE)");
1260
                                                };
1261
                                                if (alu_a != 0) {
1262
                                                        dut_error("PHP_IMP is Wrong!");
1263
                                                };
1264
                                                if (addr != SP + 256) {
1265
                                                        dut_error("ADDR should be equal SP!");
1266
                                                };
1267
                                                SP = SP - 1;
1268
                                                if (alu_enable != 0) {
1269
                                                        dut_error("PHP_IMP is Wrong!");
1270
                                                };
1271
                                        };
1272
                                        (
1273
                                          instructions == PLA_IMP ||
1274
                                          instructions == PLP_IMP ||
1275
                                          instructions == RTI_IMP ||
1276
                                          instructions == RTS_IMP
1277
                                        ) : {
1278
                                                if (alu_opcode.as_a(byte) != 0) {
1279
                                                        dut_error("Opcode is Wrong!");
1280
                                                };
1281
                                                if (alu_enable != 0) {
1282
                                                        dut_error("PLA_IMP is Wrong!");
1283
                                                };
1284
                                                if (mem_rw != 0) {
1285
                                                        dut_error("MEM_RW should be 0 (READ)");
1286
                                                };
1287
                                                if (addr != SP + 256) {
1288
                                                        dut_error("ADDR should be equal SP!");
1289
                                                };
1290
                                                SP = SP + 1;
1291
                                        };
1292
                                };
1293
                        };
1294
                        CYCLE_4 : {
1295
                                print_state();
1296
                                print addr;
1297
                                case {
1298
                                        (
1299
                                          instructions == BRK_IMP
1300
                                        ) : {
1301
                                                if (alu_opcode.as_a(byte) != 0) {
1302
                                                        dut_error("Opcode is Wrong!");
1303
                                                };
1304
                                                if (mem_rw != 1) {
1305
                                                        dut_error("MEM_RW should be 1 (WRITE)");
1306
                                                };
1307
                                                if (alu_enable != 0) {
1308
                                                        dut_error("BRK_IMP is Wrong!");
1309
                                                };
1310
                                                if (data_out != PC[7:0]) {
1311
                                                        dut_error("BRK_IMP is Wrong!");
1312
                                                };
1313
                                                if (addr != SP + 256) {
1314
                                                        dut_error("ADDR should be equal SP!");
1315
                                                };
1316
                                                SP = SP - 1;
1317
                                        };
1318
                                        //JSR_ABS : {
1319
                                        //      if (alu_opcode.as_a(byte) != 0) {
1320
                                        //              dut_error("Opcode is Wrong!");
1321
                                        //      };
1322
                                        //      if (mem_rw != 1) {
1323
                                        //              dut_error("MEM_RW should be 1 (WRITE)");
1324
                                        //      };
1325
                                        //      if (alu_enable != 0) {
1326
                                        //              dut_error("JSR_ABS is Wrong!");
1327
                                        //      };
1328
                                        //      if (data_out != PC[7:0]) {
1329
                                        //              dut_error("JSR_ABS is Wrong!");
1330
                                        //      };
1331
                                        //      if (addr != SP + 256) {
1332
                                        //              dut_error("ADDR should be equal SP!");
1333
                                        //      };
1334
                                        //      SP = SP - 1;
1335
                                        //};
1336
                                        (
1337
                                          instructions == LDA_ZPX ||
1338
                                          instructions == LDY_ZPX ||
1339
                                          instructions == EOR_ZPX ||
1340
                                          instructions == AND_ZPX ||
1341
                                          instructions == ORA_ZPX ||
1342
                                          instructions == ADC_ZPX ||
1343
                                          instructions == SBC_ZPX ||
1344 212 creep
                                          instructions == CMP_ZPX ||
1345
                                          instructions == ASL_ZPX ||
1346
                                          instructions == LSR_ZPX ||
1347
                                          instructions == ROL_ZPX ||
1348
                                          instructions == ROR_ZPX ||
1349
                                          instructions == INC_ZPX ||
1350
                                          instructions == DEC_ZPX
1351 206 creep
                                        ) : {
1352
                                                if (alu_opcode.as_a(byte) != 0) {
1353
                                                        dut_error("Opcode is Wrong!");
1354
                                                };
1355
                                                if (alu_enable != 0) {
1356
                                                        dut_error("ASL_ACC is Wrong!");
1357
                                                };
1358
                                                if (mem_rw != 0) {
1359
                                                        dut_error("MEM_RW should be 0 (WRITE)");
1360
                                                };
1361 212 creep
                                                --TODO: Isn`t it suppose to have ADDRH == 0????
1362 214 creep
                                                if (PCL + X > 255) {
1363
                                                        if (addr[7:0] != PCL + X - 256) {
1364
                                                                dut_error("ADDR should be equal SP!");
1365
                                                        };
1366
                                                }
1367
                                                else {
1368
                                                        if (addr[7:0] != PCL + X) {
1369
                                                                dut_error("ADDR should be equal SP!");
1370
                                                        };
1371 206 creep
                                                };
1372
                                        };
1373
                                        (
1374 212 creep
                                          instructions == LDA_ABX ||
1375
                                          instructions == LDY_ABX ||
1376
                                          instructions == EOR_ABX ||
1377
                                          instructions == AND_ABX ||
1378
                                          instructions == ORA_ABX ||
1379
                                          instructions == ADC_ABX ||
1380
                                          instructions == SBC_ABX ||
1381 214 creep
                                          instructions == CMP_ABX ||
1382
                                          instructions == ASL_ABX ||
1383
                                          instructions == LSR_ABX ||
1384
                                          instructions == ROL_ABX ||
1385
                                          instructions == ROR_ABX ||
1386
                                          instructions == INC_ABX ||
1387
                                          instructions == DEC_ABX
1388 206 creep
                                        ) : {
1389
                                                if (alu_opcode.as_a(byte) != 0) {
1390
                                                        dut_error("Opcode is Wrong!");
1391
                                                };
1392
                                                if (alu_enable != 0) {
1393
                                                        dut_error("ASL_ACC is Wrong!");
1394
                                                };
1395
                                                if (mem_rw != 0) {
1396
                                                        dut_error("MEM_RW should be 0 (WRITE)");
1397
                                                };
1398 212 creep
                                                if (PCL + X > 255) {
1399
                                                        more_cycles = TRUE;
1400
                                                        if (addr[7:0] != PCL + X - 256) {
1401
                                                                dut_error("ADDR should be equal SP!");
1402
                                                        };
1403
                                                }
1404
                                                else {
1405
                                                        if (addr[7:0] != PCL + X) {
1406
                                                                dut_error("ADDR should be equal SP!");
1407
                                                        };
1408 206 creep
                                                };
1409
                                        };
1410
                                        (
1411 214 creep
                                          instructions == LDA_IDX ||
1412
                                          instructions == STA_IDX ||
1413
                                          instructions == ORA_IDX ||
1414
                                          instructions == EOR_IDX ||
1415
                                          instructions == AND_IDX ||
1416
                                          instructions == ADC_IDX ||
1417
                                          instructions == CMP_IDX ||
1418
                                          instructions == SBC_IDX
1419
                                        ) : {
1420
                                                if (alu_opcode.as_a(byte) != 0) {
1421
                                                        dut_error("Opcode is Wrong!");
1422
                                                };
1423
                                                if (alu_enable != 0) {
1424
                                                        dut_error("ASL_ACC is Wrong!");
1425
                                                };
1426
                                                if (mem_rw != 0) {
1427
                                                        dut_error("MEM_RW should be 0 (WRITE)");
1428
                                                };
1429
                                                if (pointer + X > 255) {
1430
                                                        if (addr[7:0] != pointer + X - 256) {
1431
                                                                dut_error("ADDR is wrong");
1432
                                                        };
1433
                                                }
1434
                                                else {
1435
                                                        if (addr[7:0] != pointer + X) {
1436
                                                                dut_error("ADDR is wrong");
1437
                                                        };
1438
                                                };
1439
                                        };
1440
                                        (
1441 215 creep
                                          instructions == LDA_IDY ||
1442
                                          --instructions == STA_IDY ||
1443
                                          instructions == ORA_IDY ||
1444
                                          instructions == EOR_IDY ||
1445
                                          instructions == AND_IDY ||
1446
                                          instructions == ADC_IDY ||
1447
                                          instructions == CMP_IDY ||
1448
                                          instructions == SBC_IDY
1449
                                        ) : {
1450
                                                if (alu_opcode.as_a(byte) != 0) {
1451
                                                        dut_error("Opcode is Wrong!");
1452
                                                };
1453
                                                if (alu_enable != 0) {
1454
                                                        dut_error("ASL_ACC is Wrong!");
1455
                                                };
1456
                                                if (mem_rw != 0) {
1457
                                                        dut_error("MEM_RW should be 0 (WRITE)");
1458
                                                };
1459
                                                if (addr != pointer + 1) {
1460
                                                        dut_error("ADDR should be equal SP!");
1461
                                                };
1462
                                                if (PCL + Y > 255) {
1463
                                                        more_cycles = TRUE;
1464
                                                };
1465
                                        };
1466
                                        (
1467 212 creep
                                          instructions == LDX_ZPY ||
1468
                                          instructions == LDA_ABY ||
1469
                                          instructions == LDX_ABY ||
1470
                                          instructions == EOR_ABY ||
1471
                                          instructions == AND_ABY ||
1472
                                          instructions == ORA_ABY ||
1473
                                          instructions == ADC_ABY ||
1474
                                          instructions == SBC_ABY ||
1475
                                          instructions == CMP_ABY
1476
                                        ) : {
1477
                                                if (alu_opcode.as_a(byte) != 0) {
1478
                                                        dut_error("Opcode is Wrong!");
1479
                                                };
1480
                                                if (alu_enable != 0) {
1481
                                                        dut_error("ASL_ACC is Wrong!");
1482
                                                };
1483
                                                if (mem_rw != 0) {
1484
                                                        dut_error("MEM_RW should be 0 (WRITE)");
1485
                                                };
1486
                                                if (PCL + Y > 255) {
1487
                                                        more_cycles = TRUE;
1488
                                                        if (addr[7:0] != PCL + Y - 256) {
1489
                                                                dut_error("ADDR should be equal SP!");
1490
                                                        };
1491
                                                }
1492
                                                else {
1493
                                                        if (addr[7:0] != PCL + Y) {
1494
                                                                dut_error("ADDR should be equal SP!");
1495
                                                        };
1496
                                                };
1497
                                        };
1498
                                        (
1499 206 creep
                                          instructions == ADC_ABS ||
1500
                                          instructions == AND_ABS ||
1501
                                          instructions == ASL_ABS ||
1502
                                          instructions == BIT_ABS ||
1503
                                          instructions == CMP_ABS ||
1504
                                          instructions == DEC_ABS ||
1505
                                          instructions == EOR_ABS ||
1506
                                          instructions == INC_ABS ||
1507
                                          instructions == LDA_ABS ||
1508
                                          instructions == LDX_ABS ||
1509
                                          instructions == LDY_ABS ||
1510
                                          instructions == LSR_ABS ||
1511
                                          instructions == ORA_ABS ||
1512
                                          instructions == ROL_ABS ||
1513
                                          instructions == ROR_ABS ||
1514
                                          instructions == SBC_ABS
1515
                                          ) : {
1516
                                                if (alu_opcode.as_a(byte) != 0) {
1517
                                                        dut_error("Opcode is Wrong!");
1518
                                                };
1519
                                                if (alu_enable != 0) {
1520
                                                        dut_error("ASL_ACC is Wrong!");
1521
                                                };
1522
                                                if (addr[7:0] != PCL) {
1523
                                                        dut_error("ADDR should be equal SP!");
1524
                                                };
1525
                                                if (addr[12:8] != PCH[4:0]) {
1526
                                                        dut_error("ADDR should be equal SP!");
1527
                                                };
1528
                                                if (mem_rw != 0) {
1529
                                                        dut_error("MEM_RW should be 1 (WRITE)");
1530
                                                };
1531
                                        };
1532
                                        (
1533
                                          instructions == STA_ABS ||
1534
                                          instructions == STX_ABS ||
1535
                                          instructions == STY_ABS
1536
                                        ) : {
1537
                                                if (alu_opcode.as_a(byte) != 0) {
1538
                                                        dut_error("Opcode is Wrong!");
1539
                                                };
1540
                                                if (alu_enable != 0) {
1541
                                                        dut_error("ASL_ACC is Wrong!");
1542
                                                };
1543
                                                if (addr[7:0] != PCL) {
1544
                                                        dut_error("ADDR should be equal SP!");
1545
                                                };
1546
                                                if (addr[12:8] != PCH[4:0]) {
1547
                                                        dut_error("ADDR should be equal SP!");
1548
                                                };
1549
                                                if (mem_rw != 1) {
1550
                                                        dut_error("MEM_RW should be 1 (WRITE)");
1551
                                                };
1552
                                        };
1553
                                        (
1554
                                          instructions == ASL_ZPG ||
1555
                                          instructions == LSR_ZPG ||
1556
                                          instructions == ROL_ZPG ||
1557
                                          instructions == ROR_ZPG ||
1558
                                          instructions == INC_ZPG ||
1559
                                          instructions == DEC_ZPG
1560
                                        ) : {
1561
                                                if (alu_opcode != instructions) {
1562
                                                        dut_error("Opcode is Wrong!");
1563
                                                };
1564
                                                if (mem_rw != 1) {
1565
                                                        dut_error("MEM_RW should be 1 (WRITE)");
1566
                                                };
1567
                                                if (alu_enable != 1) {
1568
                                                        dut_error("BRK_IMP is Wrong!");
1569
                                                };
1570
                                                if (addr[7:0] != PCL) {
1571
                                                        dut_error("ADDR should be equal SP!");
1572
                                                };
1573
                                        };
1574
                                        (
1575 212 creep
                                          instructions == STA_ZPX ||
1576
                                          instructions == STY_ZPX
1577
                                        ) : {
1578
                                                if (alu_opcode.as_a(byte) != 0) {
1579
                                                        dut_error("Opcode is Wrong!");
1580
                                                };
1581
                                                if (alu_enable != 0) {
1582
                                                        dut_error("ASL_ACC is Wrong!");
1583
                                                };
1584
                                                if (mem_rw != 1) {
1585
                                                        dut_error("MEM_RW should be 1 (WRITE)");
1586
                                                };
1587 214 creep
                                                if (PCL + X > 255) {
1588
                                                        if (addr[7:0] != PCL + X - 256) {
1589
                                                                dut_error("ADDR should be equal SP!");
1590
                                                        };
1591
                                                }
1592
                                                else {
1593
                                                        if (addr[7:0] != PCL + X) {
1594
                                                                dut_error("ADDR should be equal SP!");
1595
                                                        };
1596 212 creep
                                                };
1597
                                        };
1598
                                        (
1599
                                          instructions == STX_ZPY
1600
                                        ) : {
1601
                                                if (alu_opcode.as_a(byte) != 0) {
1602
                                                        dut_error("Opcode is Wrong!");
1603
                                                };
1604
                                                if (alu_enable != 0) {
1605
                                                        dut_error("ASL_ACC is Wrong!");
1606
                                                };
1607
                                                if (mem_rw != 1) {
1608
                                                        dut_error("MEM_RW should be 1 (WRITE)");
1609
                                                };
1610 214 creep
                                                if (PCL + Y > 255) {
1611
                                                        if (addr[7:0] != PCL + Y - 256) {
1612
                                                                dut_error("ADDR should be equal SP!");
1613
                                                        };
1614
                                                }
1615
                                                else {
1616
                                                        if (addr[7:0] != PCL + Y) {
1617
                                                                dut_error("ADDR should be equal SP!");
1618
                                                        };
1619 212 creep
                                                };
1620
                                        };
1621
                                        (
1622 206 creep
                                          instructions == PLA_IMP ||
1623
                                          instructions == PLP_IMP
1624
                                        ) : {
1625
                                                if (alu_opcode.as_a(byte) != 0) {
1626
                                                        dut_error("Opcode is Wrong!");
1627
                                                };
1628
                                                if (mem_rw != 0) {
1629
                                                        dut_error("MEM_RW should be 0 (READ)");
1630
                                                };
1631
                                                if (alu_enable != 0) {
1632
                                                        dut_error("PLP_IMP is Wrong!");
1633
                                                };
1634
                                                if (addr != SP + 256) {
1635
                                                        dut_error("ADDR should be equal SP!");
1636
                                                };
1637
                                        };
1638
                                        (
1639
                                          instructions == RTI_IMP
1640
                                        ) : {
1641
                                                if (alu_opcode.as_a(byte) != 0) {
1642
                                                        dut_error("Opcode is Wrong!");
1643
                                                };
1644
                                                if (mem_rw != 0) {
1645
                                                        dut_error("MEM_RW should be 1 (WRITE)");
1646
                                                };
1647
                                                if (alu_enable != 0) {
1648
                                                        dut_error("RTI_IMP is Wrong!");
1649
                                                };
1650
                                                if (addr != SP + 256) {
1651
                                                        dut_error("ADDR should be equal SP!");
1652
                                                };
1653
                                                SP = SP + 1;
1654
                                        };
1655
                                        (
1656
                                          instructions == RTS_IMP
1657
                                        ) : {
1658
                                                if (alu_opcode.as_a(byte) != 0) {
1659
                                                        dut_error("Opcode is Wrong!");
1660
                                                };
1661
                                                if (alu_enable != 0) {
1662
                                                        dut_error("RTS_IMP is Wrong!");
1663
                                                };
1664
                                                if (addr != SP + 256) {
1665
                                                        dut_error("ADDR should be equal SP!");
1666
                                                };
1667
                                                SP = SP + 1;
1668
                                                PC[7:0] = PCL;
1669
                                        };
1670
                                };
1671
                        };
1672
                        CYCLE_5 : {
1673
                                print_state();
1674
                                print addr;
1675
                                case {
1676
                                        (
1677
                                          instructions == BRK_IMP
1678
                                        ) : {
1679
                                                if (alu_opcode.as_a(byte) != 0) {
1680
                                                        dut_error("Opcode is Wrong!");
1681
                                                };
1682
                                                if (mem_rw != 1) {
1683
                                                        dut_error("MEM_RW should be 1 (WRITE)");
1684
                                                };
1685
                                                if (alu_enable != 0) {
1686
                                                        dut_error("BRK_IMP is Wrong!");
1687
                                                };
1688
                                                if (addr != SP + 256) {
1689
                                                        dut_error("ADDR should be equal SP!");
1690
                                                };
1691
                                                SP = SP - 1;
1692
                                        };
1693
                                        //JSR_ABS : {
1694
                                        //      if (alu_opcode.as_a(byte) != 0) {
1695
                                        //              dut_error("Opcode is Wrong!");
1696
                                        //      };
1697
                                        //      if (mem_rw != 1) {
1698
                                        //              dut_error("MEM_RW should be 1 (WRITE)");
1699
                                        //      };
1700
                                        //      if (alu_enable != 0) {
1701
                                        //              dut_error("JSR_ABS is Wrong!");
1702
                                        //      };
1703
                                        //      if (data_out != PC[12:8]) {
1704
                                        //              dut_error("JSR_ABS is Wrong!");
1705
                                        //      };
1706
                                        //      if (addr != SP + 256) {
1707
                                        //              dut_error("ADDR should be equal SP!");
1708
                                        //      };
1709
                                        //      SP = SP - 1;
1710
                                        //};
1711
                                        (
1712 214 creep
                                          instructions == LDA_IDX ||
1713
                                          instructions == ORA_IDX ||
1714
                                          instructions == EOR_IDX ||
1715
                                          instructions == AND_IDX ||
1716
                                          instructions == ADC_IDX ||
1717
                                          instructions == CMP_IDX ||
1718
                                          instructions == SBC_IDX
1719
                                        ) : {
1720
                                                if (alu_opcode.as_a(byte) != 0) {
1721
                                                        dut_error("Opcode is Wrong!");
1722
                                                };
1723
                                                if (alu_enable != 0) {
1724
                                                        dut_error("ASL_ACC is Wrong!");
1725
                                                };
1726
                                                if (mem_rw != 0) {
1727
                                                        dut_error("MEM_RW should be 0 (WRITE)");
1728
                                                };
1729
                                                if (pointer + X + 1 > 255) {
1730
                                                        if (addr[7:0] != pointer + X + 1 - 256) {
1731
                                                                dut_error("ADDR is wrong");
1732
                                                        };
1733
                                                }
1734
                                                else {
1735
                                                        if (addr[7:0] != pointer + X + 1) {
1736
                                                                dut_error("ADDR is wrong");
1737
                                                        };
1738
                                                };
1739
                                        };
1740
                                        (
1741 215 creep
                                          instructions == LDA_IDY ||
1742
                                          --instructions == STA_IDY ||
1743
                                          instructions == ORA_IDY ||
1744
                                          instructions == EOR_IDY ||
1745
                                          instructions == AND_IDY ||
1746
                                          instructions == ADC_IDY ||
1747
                                          instructions == CMP_IDY ||
1748
                                          instructions == SBC_IDY
1749
                                        ) : {
1750
                                                if (alu_opcode.as_a(byte) != 0) {
1751
                                                        dut_error("Opcode is Wrong!");
1752
                                                };
1753
                                                if (alu_enable != 0) {
1754
                                                        dut_error("ASL_ACC is Wrong!");
1755
                                                };
1756
                                                if (mem_rw != 0) {
1757
                                                        dut_error("MEM_RW should be 0 (WRITE)");
1758
                                                };
1759
                                                if (PCL + Y > 255) {
1760
                                                        if (addr[7:0] != PCL + Y - 256) {
1761
                                                                dut_error("ADDR is wrong");
1762
                                                        };
1763
                                                }
1764
                                                else {
1765
                                                        if (addr[7:0] != PCL + Y) {
1766
                                                                dut_error("ADDR is wrong");
1767
                                                        };
1768
                                                };
1769
                                        };
1770
                                        (
1771
                                          instructions == STA_IDX
1772
                                        ) : {
1773
                                                if (alu_opcode != instructions) {
1774
                                                        dut_error("Opcode is Wrong!");
1775
                                                };
1776
                                                if (alu_enable != 1) {
1777
                                                        dut_error("ASL_ACC is Wrong!");
1778
                                                };
1779
                                                if (mem_rw != 0) {
1780
                                                        dut_error("MEM_RW should be 0 (WRITE)");
1781
                                                };
1782
                                                if (pointer + X + 1 > 255) {
1783
                                                        if (addr[7:0] != pointer + X + 1 - 256) {
1784
                                                                dut_error("ADDR is wrong");
1785
                                                        };
1786
                                                }
1787
                                                else {
1788
                                                        if (addr[7:0] != pointer + X + 1) {
1789
                                                                dut_error("ADDR is wrong");
1790
                                                        };
1791
                                                };
1792
                                        };
1793
                                        (
1794 206 creep
                                          instructions == RTI_IMP
1795
                                        ) : {
1796
                                                if (alu_opcode != instructions) {
1797
                                                        dut_error("Opcode is Wrong!");
1798
                                                };
1799
                                                if (mem_rw != 0) {
1800
                                                        dut_error("MEM_RW should be 1 (WRITE)");
1801
                                                };
1802
                                                if (alu_enable != 1) {
1803
                                                        dut_error("RTI_IMP is Wrong!");
1804
                                                };
1805
                                                if (addr != SP + 256) {
1806
                                                        dut_error("ADDR should be equal SP!");
1807
                                                };
1808
                                                SP = SP + 1;
1809
                                                PC[7:0] = PCL;
1810
                                        };
1811
                                        (
1812
                                          instructions == RTS_IMP
1813
                                        ) : {
1814
                                                if (alu_opcode.as_a(byte) != 0) {
1815
                                                        dut_error("Opcode is Wrong!");
1816
                                                };
1817
                                                if (alu_enable != 0) {
1818
                                                        dut_error("SEI_IMP is Wrong!");
1819
                                                };
1820
                                                if (addr != SP + 256) {
1821
                                                        dut_error("ADDR should be equal SP!");
1822
                                                };
1823
                                                PC[12:8] = PCH[4:0];
1824
                                        };
1825
                                        (
1826
                                          instructions == ASL_ZPG ||
1827
                                          instructions == LSR_ZPG ||
1828
                                          instructions == ROL_ZPG ||
1829
                                          instructions == ROR_ZPG ||
1830
                                          instructions == INC_ZPG ||
1831
                                          instructions == DEC_ZPG
1832
                                        ) : {
1833
                                                if (alu_opcode.as_a(byte) != 0) {
1834
                                                        dut_error("Opcode is Wrong!");
1835
                                                };
1836
                                                if (mem_rw != 1) {
1837
                                                        dut_error("MEM_RW should be 1 (WRITE)");
1838
                                                };
1839
                                                if (alu_enable != 0) {
1840
                                                        dut_error("BRK_IMP is Wrong!");
1841
                                                };
1842
                                                if (addr[7:0] != PCL) {
1843
                                                        dut_error("ADDR should be equal SP!");
1844
                                                };
1845
                                        };
1846
                                        (
1847 212 creep
                                          instructions == LDA_ABX ||
1848
                                          instructions == LDY_ABX ||
1849
                                          instructions == EOR_ABX ||
1850
                                          instructions == AND_ABX ||
1851
                                          instructions == ORA_ABX ||
1852
                                          instructions == ADC_ABX ||
1853
                                          instructions == SBC_ABX ||
1854 214 creep
                                          instructions == CMP_ABX ||
1855
                                          (
1856
                                                more_cycles == TRUE &&
1857
                                                (
1858
                                                  instructions == ASL_ABX ||
1859
                                                  instructions == LSR_ABX ||
1860
                                                  instructions == ROL_ABX ||
1861
                                                  instructions == ROR_ABX ||
1862
                                                  instructions == INC_ABX ||
1863
                                                  instructions == DEC_ABX
1864
                                                )
1865
                                          )
1866 212 creep
                                        ) : {
1867
                                                if (alu_opcode.as_a(byte) != 0) {
1868
                                                        dut_error("Opcode is Wrong!");
1869
                                                };
1870
                                                if (alu_enable != 0) {
1871
                                                        dut_error("ASL_ACC is Wrong!");
1872
                                                };
1873
                                                if (mem_rw != 0) {
1874
                                                        dut_error("MEM_RW should be 0 (WRITE)");
1875
                                                };
1876
                                                if (addr[7:0] != PCL + X - 256) {
1877
                                                        dut_error("ADDR is wrong!");
1878
                                                };
1879
                                                if (addr[12:8] != PCH[4:0] + 1) {
1880
                                                        dut_error("ADDR is wrong!");
1881
                                                };
1882
                                        };
1883
                                        (
1884 214 creep
                                          more_cycles == FALSE &&
1885
                                          (
1886
                                                  instructions == ASL_ABX ||
1887
                                                  instructions == LSR_ABX ||
1888
                                                  instructions == ROL_ABX ||
1889
                                                  instructions == ROR_ABX ||
1890
                                                  instructions == INC_ABX ||
1891
                                                  instructions == DEC_ABX
1892
                                          )
1893
                                        ) : {
1894
                                                if (alu_opcode.as_a(byte) != 0) {
1895
                                                        dut_error("Opcode is Wrong!");
1896
                                                };
1897
                                                if (alu_enable != 0) {
1898
                                                        dut_error("ASL_ACC is Wrong!");
1899
                                                };
1900
                                                if (mem_rw != 0) {
1901
                                                        dut_error("MEM_RW should be 0 (WRITE)");
1902
                                                };
1903
                                                if (addr[7:0] != PCL + X) {
1904
                                                        dut_error("ADDR should be equal SP!");
1905
                                                };
1906
                                        };
1907
                                        (
1908 212 creep
                                          instructions == LDX_ZPY ||
1909
                                          instructions == LDA_ABY ||
1910
                                          instructions == LDX_ABY ||
1911
                                          instructions == EOR_ABY ||
1912
                                          instructions == AND_ABY ||
1913
                                          instructions == ORA_ABY ||
1914
                                          instructions == ADC_ABY ||
1915
                                          instructions == SBC_ABY ||
1916
                                          instructions == CMP_ABY
1917
                                        ) : {
1918
                                                if (alu_opcode.as_a(byte) != 0) {
1919
                                                        dut_error("Opcode is Wrong!");
1920
                                                };
1921
                                                if (alu_enable != 0) {
1922
                                                        dut_error("ASL_ACC is Wrong!");
1923
                                                };
1924
                                                if (mem_rw != 0) {
1925
                                                        dut_error("MEM_RW should be 0 (WRITE)");
1926
                                                };
1927
                                                if (addr[7:0] != PCL + Y - 256) {
1928
                                                        dut_error("ADDR is wrong!");
1929
                                                };
1930
                                                if (addr[12:8] != PCH[4:0] + 1) {
1931
                                                        dut_error("ADDR is wrong!");
1932
                                                };
1933
                                        };
1934
                                        (
1935
                                          instructions == ASL_ZPX ||
1936
                                          instructions == LSR_ZPX ||
1937
                                          instructions == ROL_ZPX ||
1938
                                          instructions == ROR_ZPX ||
1939
                                          instructions == INC_ZPX ||
1940
                                          instructions == DEC_ZPX
1941
                                        ) : {
1942
                                                if (alu_opcode != instructions) {
1943
                                                        dut_error("Opcode is Wrong!");
1944
                                                };
1945
                                                if (alu_enable != 1) {
1946
                                                        dut_error("ASL_ACC is Wrong!");
1947
                                                };
1948
                                                if (mem_rw != 1) {
1949
                                                        dut_error("MEM_RW should be 0 (WRITE)");
1950
                                                };
1951 214 creep
                                                if (PCL + X > 255) {
1952
                                                        if (addr[7:0] != PCL + X - 256) {
1953
                                                                dut_error("ADDR should be equal SP!");
1954
                                                        };
1955
                                                }
1956
                                                else {
1957
                                                        if (addr[7:0] != PCL + X) {
1958
                                                                dut_error("ADDR should be equal SP!");
1959
                                                        };
1960 212 creep
                                                };
1961
                                        };
1962
                                        (
1963 206 creep
                                          instructions == ASL_ABS ||
1964
                                          instructions == DEC_ABS ||
1965
                                          instructions == INC_ABS ||
1966
                                          instructions == LSR_ABS ||
1967
                                          instructions == ROL_ABS ||
1968
                                          instructions == ROR_ABS
1969
                                        ) : {
1970
                                                if (alu_opcode != instructions) {
1971
                                                        dut_error("Opcode is Wrong!");
1972
                                                };
1973
                                                if (mem_rw != 1) {
1974
                                                        dut_error("MEM_RW should be 1 (WRITE)");
1975
                                                };
1976
                                                if (alu_enable != 1) {
1977
                                                        dut_error("BRK_IMP is Wrong!");
1978
                                                };
1979
                                                if (addr[7:0] != PCL) {
1980
                                                        dut_error("ADDR should be equal SP!");
1981
                                                };
1982
                                                if (addr[12:8] != PCH[4:0]) {
1983
                                                        dut_error("ADDR should be equal SP!");
1984
                                                };
1985
                                        };
1986
                                };
1987
                        };
1988
                        CYCLE_6 : {
1989
                                print_state();
1990
                                print addr;
1991
                                case {
1992
                                        (
1993
                                          instructions == BRK_IMP
1994
                                        ) : {
1995
                                                if (alu_opcode.as_a(byte) != 0) {
1996
                                                        dut_error("Opcode is Wrong!");
1997
                                                };
1998
                                                if (mem_rw != 0) {
1999
                                                        dut_error("MEM_RW should be 1 (WRITE)");
2000
                                                };
2001
                                                if (alu_enable != 0) {
2002
                                                        dut_error("BRK_IMP is Wrong!");
2003
                                                };
2004
                                                if (addr != 13'b1111111111110) {
2005
                                                        dut_error("BRK_IMP is Wrong!");
2006
                                                };
2007
                                                PC[7:0] = PCL;
2008
                                        };
2009
                                        //JSR_ABS : {
2010
                                        //      if (alu_opcode.as_a(byte) != 0) {
2011
                                        //              dut_error("Opcode is Wrong!");
2012
                                        //      };
2013
                                        //      if (mem_rw != 0) {
2014
                                        //              dut_error("MEM_RW should be 1 (WRITE)");
2015
                                        //      };
2016
                                        //      if (alu_enable != 0) {
2017
                                        //              dut_error("JSR_ABS is Wrong!");
2018
                                        //      };
2019
                                        //      if (addr != PC) {
2020
                                        //              dut_error("ADDR should be equal SP!");
2021
                                        //      };
2022
                                        //      PC [7:0] = PCL;
2023
                                        //      PC[12:8] = PCH[4:0];
2024
                                        //};
2025
                                        (
2026 214 creep
                                          instructions == LDA_IDX ||
2027
                                          instructions == ORA_IDX ||
2028
                                          instructions == EOR_IDX ||
2029
                                          instructions == AND_IDX ||
2030
                                          instructions == ADC_IDX ||
2031
                                          instructions == CMP_IDX ||
2032
                                          instructions == SBC_IDX
2033
                                        ) : {
2034
                                                if (alu_opcode.as_a(byte) != 0) {
2035
                                                        dut_error("Opcode is Wrong!");
2036
                                                };
2037
                                                if (alu_enable != 0) {
2038
                                                        dut_error("ASL_ACC is Wrong!");
2039
                                                };
2040
                                                if (mem_rw != 0) {
2041
                                                        dut_error("MEM_RW should be 0 (WRITE)");
2042
                                                };
2043
                                                if (addr[7:0] != PCL) {
2044
                                                        dut_error("ADDR is wrong");
2045
                                                };
2046
                                                if (addr[12:8] != PCH[4:0]) {
2047
                                                        dut_error("ADDR is wrong");
2048
                                                };
2049
                                        };
2050
                                        (
2051 215 creep
                                          instructions == LDA_IDY ||
2052
                                          --instructions == STA_IDY ||
2053
                                          instructions == ORA_IDY ||
2054
                                          instructions == EOR_IDY ||
2055
                                          instructions == AND_IDY ||
2056
                                          instructions == ADC_IDY ||
2057
                                          instructions == CMP_IDY ||
2058
                                          instructions == SBC_IDY
2059 214 creep
                                        ) : {
2060
                                                if (alu_opcode.as_a(byte) != 0) {
2061
                                                        dut_error("Opcode is Wrong!");
2062
                                                };
2063
                                                if (alu_enable != 0) {
2064
                                                        dut_error("ASL_ACC is Wrong!");
2065
                                                };
2066 215 creep
                                                if (mem_rw != 0) {
2067
                                                        dut_error("MEM_RW should be 0 (WRITE)");
2068
                                                };
2069
                                                if (addr[7:0] != PCL + Y - 256) {
2070
                                                        dut_error("ADDR is wrong");
2071
                                                };
2072
                                                if (addr[12:8] != PCH[4:0] + 1) {
2073
                                                        print PCH, addr[12:8];
2074
                                                        print PCL + Y, addr[7:0];
2075
                                                        dut_error("ADDR is wrong");
2076
                                                };
2077
                                        };
2078
                                        (
2079
                                          instructions == STA_IDX
2080
                                        ) : {
2081
                                                if (alu_opcode.as_a(byte) != 0) {
2082
                                                        dut_error("Opcode is Wrong!");
2083
                                                };
2084
                                                if (alu_enable != 0) {
2085
                                                        dut_error("ASL_ACC is Wrong!");
2086
                                                };
2087 214 creep
                                                if (mem_rw != 1) {
2088
                                                        dut_error("MEM_RW should be 0 (WRITE)");
2089
                                                };
2090
                                                if (addr[7:0] != PCL) {
2091
                                                        dut_error("ADDR is wrong");
2092
                                                };
2093
                                                if (addr[12:8] != PCH[4:0]) {
2094
                                                        dut_error("ADDR is wrong");
2095
                                                };
2096
                                        };
2097
                                        (
2098 206 creep
                                          instructions == RTI_IMP
2099
                                        ) : {
2100
                                                if (alu_opcode.as_a(byte) != 0) {
2101
                                                        dut_error("Opcode is Wrong!");
2102
                                                };
2103
                                                if (mem_rw != 0) {
2104
                                                        dut_error("MEM_RW should be 1 (WRITE)");
2105
                                                };
2106
                                                if (alu_enable != 0) {
2107
                                                        dut_error("RTI_IMP is Wrong!");
2108
                                                };
2109
                                                if (addr != SP + 256) {
2110
                                                        dut_error("ADDR should be equal SP!");
2111
                                                };
2112
                                                PC[12:8] = PCH[4:0];
2113
                                        };
2114
                                        (
2115
                                          instructions == RTS_IMP
2116
                                        ) : {
2117
                                                if (alu_opcode.as_a(byte) != 0) {
2118
                                                        dut_error("Opcode is Wrong!");
2119
                                                };
2120
                                                if (mem_rw != 0) {
2121
                                                        dut_error("MEM_RW should be 1 (WRITE)");
2122
                                                };
2123
                                                if (alu_enable != 0) {
2124
                                                        dut_error("RTI_IMP is Wrong!");
2125
                                                };
2126
                                                if (addr != PC) {
2127
                                                        dut_error("ADDR should be equal SP!");
2128
                                                };
2129
                                                PC = PC + 1;
2130
                                        };
2131
                                        (
2132 212 creep
                                          instructions == ASL_ZPX ||
2133
                                          instructions == LSR_ZPX ||
2134
                                          instructions == ROL_ZPX ||
2135
                                          instructions == ROR_ZPX ||
2136
                                          instructions == INC_ZPX ||
2137
                                          instructions == DEC_ZPX
2138
                                        ) : {
2139
                                                if (alu_opcode.as_a(byte) != 0) {
2140
                                                        dut_error("Opcode is Wrong!");
2141
                                                };
2142
                                                if (alu_enable != 0) {
2143
                                                        dut_error("ASL_ACC is Wrong!");
2144
                                                };
2145
                                                if (mem_rw != 1) {
2146
                                                        dut_error("MEM_RW should be 0 (WRITE)");
2147
                                                };
2148 214 creep
                                                if (PCL + X > 255) {
2149
                                                        if (addr[7:0] != PCL + X - 256) {
2150
                                                                dut_error("ADDR should be equal SP!");
2151
                                                        };
2152
                                                }
2153
                                                else {
2154
                                                        if (addr[7:0] != PCL + X) {
2155
                                                                dut_error("ADDR should be equal SP!");
2156
                                                        };
2157 212 creep
                                                };
2158
                                        };
2159
                                        (
2160 214 creep
                                          more_cycles == TRUE &&
2161
                                          (
2162
                                                instructions == ASL_ABX ||
2163
                                                instructions == LSR_ABX ||
2164
                                                instructions == ROL_ABX ||
2165
                                                instructions == ROR_ABX ||
2166
                                                instructions == INC_ABX ||
2167
                                                instructions == DEC_ABX
2168
                                          )
2169
                                        ) : {
2170
                                                if (alu_opcode != instructions) {
2171
                                                        dut_error("Opcode is Wrong!");
2172
                                                };
2173
                                                if (alu_enable != 1) {
2174
                                                        dut_error("ASL_ACC is Wrong!");
2175
                                                };
2176
                                                if (mem_rw != 1) {
2177
                                                        dut_error("MEM_RW should be 0 (WRITE)");
2178
                                                };
2179
                                                if (addr[7:0] != PCL + X - 256) {
2180
                                                        dut_error("ADDR is wrong!");
2181
                                                };
2182
                                                if (addr[12:8] != PCH[4:0] + 1) {
2183
                                                        dut_error("ADDR is wrong!");
2184
                                                };
2185
                                        };
2186
                                        (
2187
                                          more_cycles == FALSE &&
2188
                                          (
2189
                                                instructions == ASL_ABX ||
2190
                                                instructions == LSR_ABX ||
2191
                                                instructions == ROL_ABX ||
2192
                                                instructions == ROR_ABX ||
2193
                                                instructions == INC_ABX ||
2194
                                                instructions == DEC_ABX
2195
                                          )
2196
                                        ) : {
2197
                                                if (alu_opcode != instructions) {
2198
                                                        dut_error("Opcode is Wrong!");
2199
                                                };
2200
                                                if (alu_enable != 1) {
2201
                                                        dut_error("ASL_ACC is Wrong!");
2202
                                                };
2203
                                                if (mem_rw != 1) {
2204
                                                        dut_error("MEM_RW should be 0 (WRITE)");
2205
                                                };
2206
                                                if (addr[7:0] != PCL + X) {
2207
                                                        dut_error("ADDR is wrong!");
2208
                                                };
2209
                                                if (addr[12:8] != PCH[4:0]) {
2210
                                                        dut_error("ADDR is wrong!");
2211
                                                };
2212
                                        };
2213
                                        (
2214 206 creep
                                          instructions == ASL_ABS ||
2215
                                          instructions == DEC_ABS ||
2216
                                          instructions == INC_ABS ||
2217
                                          instructions == LSR_ABS ||
2218
                                          instructions == ROL_ABS ||
2219
                                          instructions == ROR_ABS
2220
                                        ) : {
2221
                                                if (alu_opcode.as_a(byte) != 0) {
2222
                                                        dut_error("Opcode is Wrong!");
2223
                                                };
2224
                                                if (mem_rw != 1) {
2225
                                                        dut_error("MEM_RW should be 1 (WRITE)");
2226
                                                };
2227
                                                if (alu_enable != 0) {
2228
                                                        dut_error("BRK_IMP is Wrong!");
2229
                                                };
2230
                                                if (addr[7:0] != PCL) {
2231
                                                        dut_error("ADDR should be equal SP!");
2232
                                                };
2233
                                                if (addr[12:8] != PCH[4:0]) {
2234
                                                        dut_error("ADDR should be equal SP!");
2235
                                                };
2236
                                        };
2237
                                };
2238
                        };
2239
                        CYCLE_7 : {
2240
                                print_state();
2241
                                print addr;
2242
                                case {
2243
                                        (
2244 214 creep
                                          more_cycles == TRUE &&
2245
                                          (
2246
                                                instructions == ASL_ABX ||
2247
                                                instructions == LSR_ABX ||
2248
                                                instructions == ROL_ABX ||
2249
                                                instructions == ROR_ABX ||
2250
                                                instructions == INC_ABX ||
2251
                                                instructions == DEC_ABX
2252
                                          )
2253
                                        ) : {
2254
                                                if (alu_opcode.as_a(byte) != 0) {
2255
                                                        dut_error("Opcode is Wrong!");
2256
                                                };
2257
                                                if (alu_enable != 0) {
2258
                                                        dut_error("ASL_ACC is Wrong!");
2259
                                                };
2260
                                                if (mem_rw != 1) {
2261
                                                        dut_error("MEM_RW should be 0 (WRITE)");
2262
                                                };
2263
                                                if (addr[7:0] != PCL + X - 256) {
2264
                                                        dut_error("ADDR is wrong!");
2265
                                                };
2266
                                                if (addr[12:8] != PCH[4:0] + 1) {
2267
                                                        dut_error("ADDR is wrong!");
2268
                                                };
2269
                                        };
2270
                                        (
2271
                                          more_cycles == FALSE &&
2272
                                          (
2273
                                                instructions == ASL_ABX ||
2274
                                                instructions == LSR_ABX ||
2275
                                                instructions == ROL_ABX ||
2276
                                                instructions == ROR_ABX ||
2277
                                                instructions == INC_ABX ||
2278
                                                instructions == DEC_ABX
2279
                                          )
2280
                                        ) : {
2281
                                                if (alu_opcode.as_a(byte) != 0) {
2282
                                                        dut_error("Opcode is Wrong!");
2283
                                                };
2284
                                                if (alu_enable != 0) {
2285
                                                        dut_error("ASL_ACC is Wrong!");
2286
                                                };
2287
                                                if (mem_rw != 1) {
2288
                                                        dut_error("MEM_RW should be 0 (WRITE)");
2289
                                                };
2290
                                                if (addr[7:0] != PCL + X) {
2291
                                                        dut_error("ADDR is wrong!");
2292
                                                };
2293
                                                if (addr[12:8] != PCH[4:0]) {
2294
                                                        dut_error("ADDR is wrong!");
2295
                                                };
2296
                                        };
2297
                                        (
2298 206 creep
                                          instructions == BRK_IMP
2299
                                        ) : {
2300
                                                if (alu_opcode.as_a(byte) != 0) {
2301
                                                        dut_error("Opcode is Wrong!");
2302
                                                };
2303
                                                if (mem_rw != 0) {
2304
                                                        dut_error("MEM_RW should be 1 (WRITE)");
2305
                                                };
2306
                                                if (alu_enable != 0) {
2307
                                                        dut_error("BRK_IMP is Wrong!");
2308
                                                };
2309
                                                if (addr != 13'b1111111111111) {
2310
                                                        dut_error("BRK_IMP is Wrong!");
2311
                                                };
2312
                                                PC[12:8] = PCH[4:0];
2313
                                        };
2314
                                };
2315
                        };
2316
                };
2317
        old_state = new_state;
2318
        };
2319
};
2320
'>

powered by: WebSVN 2.1.0

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