-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathamba3c4unrealy.aag
executable file
·841 lines (781 loc) · 20.2 KB
/
amba3c4unrealy.aag
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
aag 288 19 34 1 235
2
4
6
8
10
12
14
16
18
20
22
24
26
28
30
32
34
36
38
40 1
42 30
44 16
46 452
48 475
50 18
52 493
54 36
56 499
58 2
60 28
62 10
64 4
66 507
68 510
70 38
72 32
74 514
76 525
78 8
80 6
82 531
84 535
86 539
88 392
90 26
92 550
94 560
96 576
98 121
100 22
102 34
104 24
106 20
380
108 22 3
110 26 5
112 111 109
114 32 7
116 115 112
118 98 40
120 119 116
122 100 40
124 54 40
126 125 122
128 126 39
130 128 19
132 21 16
134 29 6
136 28 7
138 137 135
140 139 132
142 21 17
144 29 2
146 28 3
148 147 145
150 149 142
152 20 17
154 29 4
156 28 5
158 157 155
160 159 152
162 102 40
164 42 40
166 165 132
168 164 133
170 169 167
172 50 40
174 172 9
176 173 8
178 177 175
180 178 170
182 70 40
184 182 142
186 183 143
188 187 185
190 104 40
192 191 152
194 190 153
196 195 193
198 196 188
200 198 180
202 201 162
204 48 40
206 52 40
208 207 205
210 56 40
212 211 208
214 66 40
216 215 162
218 216 212
220 218 11
222 78 40
224 223 8
226 222 9
228 227 225
230 228 10
232 44 40
234 233 17
236 232 16
238 237 235
240 106 40
242 241 21
244 240 20
246 245 243
248 247 239
250 248 230
252 251 221
254 253 203
256 254 161
258 256 151
260 258 141
262 260 131
264 125 123
266 264 39
268 266 18
270 269 262
272 90 40
274 272 125
276 274 24
278 276 19
280 279 270
282 273 125
284 282 24
286 284 18
288 287 280
290 72 40
292 290 125
294 292 30
296 294 19
298 297 288
300 291 125
302 300 30
304 302 18
306 305 298
308 183 38
310 182 39
312 311 309
314 313 124
316 315 306
318 190 25
320 191 24
322 321 319
324 323 124
326 325 316
328 164 31
330 165 30
332 331 329
334 333 124
336 335 326
338 172 19
340 173 18
342 341 339
344 343 124
346 345 336
348 68 40
350 24 5
352 350 348
354 353 346
356 74 40
358 30 7
360 358 356
362 361 354
364 65 59
366 364 81
368 367 40
370 369 125
372 370 38
374 373 362
376 96 40
378 377 374
380 379 120
382 46 40
384 76 40
386 385 383
388 382 35
390 389 387
392 88 40
394 86 40
396 82 40
398 84 40
400 399 397
402 400 395
404 402 393
406 404 215
408 398 397
410 408 395
412 410 393
414 143 2
416 415 412
418 399 396
420 418 395
422 420 393
424 422 212
426 425 417
428 426 407
430 398 396
432 430 395
434 432 393
436 153 4
438 437 434
440 400 394
442 440 393
444 133 6
446 445 442
448 447 439
450 448 428
452 450 391
454 11 8
456 454 15
458 456 212
460 458 12
462 460 35
464 211 34
466 465 205
468 464 204
470 469 467
472 470 209
474 473 463
476 460 34
478 206 204
480 478 211
482 480 34
484 483 206
486 207 204
488 486 464
490 489 485
492 490 477
494 208 34
496 495 210
498 497 483
500 214 28
502 215 13
504 502 456
506 505 501
508 349 24
510 509 5
512 357 30
514 513 7
516 385 8
518 15 13
520 518 516
522 384 28
524 523 521
526 450 396
528 417 407
530 528 527
532 450 398
534 533 426
536 450 394
538 537 439
540 92 40
542 382 34
544 542 540
546 543 541
548 547 545
550 548 450
552 94 40
554 553 545
556 552 544
558 557 555
560 558 450
562 543 377
564 563 450
566 557 377
568 387 376
570 568 556
572 571 567
574 573 542
576 575 564
i0 i_hbusreq0
i1 i_hbusreq1
i2 i_hbusreq2
i3 controllable_hmastlock
i4 controllable_nstart
i5 i_hburst1
i6 i_hburst0
i7 controllable_hmaster1
i8 controllable_locked
i9 controllable_hmaster0
i10 i_hlock0
i11 controllable_hgrant1
i12 i_hlock1
i13 controllable_busreq
i14 controllable_hgrant2
i15 i_hlock2
i16 i_hready
i17 controllable_ndecide
i18 controllable_nhgrant0
l0 n41
l1 reg_controllable_hgrant2_out
l2 reg_controllable_hmaster1_out
l3 next_env_fair_out
l4 reg_stateG3_0_out
l5 reg_controllable_locked_out
l6 reg_stateG3_1_out
l7 reg_controllable_ndecide_out
l8 reg_stateG3_2_out
l9 reg_i_hbusreq0_out
l10 reg_controllable_busreq_out
l11 reg_controllable_nstart_out
l12 reg_i_hbusreq1_out
l13 reg_stateG2_out
l14 reg_stateG10_1_out
l15 reg_controllable_nhgrant0_out
l16 reg_i_hlock2_out
l17 reg_stateG10_2_out
l18 reg_stateA1_out
l19 reg_controllable_hmastlock_out
l20 reg_i_hbusreq2_out
l21 next_sys_fair<0>_out
l22 next_sys_fair<1>_out
l23 next_sys_fair<2>_out
l24 next_sys_fair<3>_out
l25 reg_i_hlock1_out
l26 fair_cnt<0>_out
l27 fair_cnt<1>_out
l28 fair_cnt<2>_out
l29 env_safe_err_happened_out
l30 reg_i_hlock0_out
l31 reg_i_hready_out
l32 reg_controllable_hgrant1_out
l33 reg_controllable_hmaster0_out
o0 o_err
c
amba_3_new_4
This file was written by ABC on Sat Aug 31 20:25:07 2013
For information about AIGER format, refer to http://fmv.jku.at/aiger
-------------------------------
This AIGER file has been created by the following sequence of commands:
> vl2mv amba3c4unreal.v ---gives--> amba3c4unreal.mv
> abc -c "read_blif_mv amba3c4unreal.mv; strash; refactor; rewrite; dfraig; rewrite; dfraig; write_aiger -s amba3c4unrealy.aig" ---gives--> amba3c4unrealy.aig
> aigtoaig amba3c4unrealy.aig amba3c4unrealy.aag ---gives--> amba3c4unrealy.aag (this file)
Content of amba3c4unreal.v:
module amba_3_new_4(
o_err,
i_clk,
i_hready,
i_hbusreq0,
i_hlock0,
i_hbusreq1,
i_hlock1,
i_hbusreq2,
i_hlock2,
i_hburst0,
i_hburst1,
controllable_hmaster0,
controllable_hmaster1,
controllable_hmastlock,
controllable_nstart,
controllable_ndecide,
controllable_locked,
controllable_nhgrant0,
controllable_hgrant1,
controllable_hgrant2,
controllable_busreq);
input i_clk;
input i_hready;
input i_hbusreq0;
input i_hlock0;
input i_hbusreq1;
input i_hlock1;
input i_hbusreq2;
input i_hlock2;
input i_hburst0;
input i_hburst1;
input controllable_hmaster0;
input controllable_hmaster1;
input controllable_hmastlock;
input controllable_nstart;
input controllable_ndecide;
input controllable_locked;
input controllable_nhgrant0;
input controllable_hgrant1;
input controllable_hgrant2;
input controllable_busreq;
output o_err;
reg reg_i_hready;
reg reg_i_hbusreq0;
reg reg_i_hlock0;
reg reg_i_hbusreq1;
reg reg_i_hlock1;
reg reg_i_hbusreq2;
reg reg_i_hlock2;
reg reg_controllable_hmaster0;
reg reg_controllable_hmaster1;
reg reg_controllable_hmastlock;
reg reg_controllable_nstart;
reg reg_controllable_ndecide;
reg reg_controllable_locked;
reg reg_controllable_nhgrant0;
reg reg_controllable_hgrant1;
reg reg_controllable_hgrant2;
reg reg_controllable_busreq;
reg reg_stateA1;
reg reg_stateG2;
reg reg_stateG3_0;
reg reg_stateG3_1;
reg reg_stateG3_2;
reg reg_stateG10_1;
reg reg_stateG10_2;
reg env_safe_err_happened;
reg next_env_fair;
reg [2:0] fair_cnt;
reg [3:0] next_sys_fair;
wire env_safe_err0;
wire env_safe_err1;
wire env_safe_err2;
wire env_safe_err;
wire sys_safe_err0;
wire sys_safe_err1;
wire sys_safe_err2;
wire sys_safe_err3;
wire sys_safe_err4;
wire sys_safe_err5;
wire sys_safe_err6;
wire sys_safe_err7;
wire sys_safe_err8;
wire sys_safe_err9;
wire sys_safe_err10;
wire sys_safe_err11;
wire sys_safe_err12;
wire sys_safe_err13;
wire sys_safe_err14;
wire sys_safe_err15;
wire sys_safe_err16;
wire sys_safe_err17;
wire sys_safe_err18;
wire sys_safe_err19;
wire sys_safe_err20;
wire sys_safe_err21;
wire sys_safe_err22;
wire sys_safe_err23;
wire sys_safe_err24;
wire sys_safe_err25;
wire sys_safe_err26;
wire sys_safe_err;
wire env_fair0;
wire env_fair1;
wire sys_fair0;
wire sys_fair1;
wire sys_fair2;
wire sys_fair3;
wire sys_fair4;
wire fair_err;
wire o_err;
// =============================================================
// ENV_TRANSITION:
// =============================================================
// Assumption 3:
// G( hlock0=1 -> hbusreq0=1 );
assign env_safe_err0 = ~(~ i_hlock0 | i_hbusreq0);
// Assumption 3:
// G( hlock1=1 -> hbusreq1=1 );
assign env_safe_err1 = ~(~ i_hlock1 | i_hbusreq1);
// Assumption 3:
// G( hlock2=1 -> hbusreq2=1 );
assign env_safe_err2 = ~(~ i_hlock2 | i_hbusreq2);
// collecting together the safety error bits:
assign env_safe_err = env_safe_err0 |
env_safe_err1 |
env_safe_err2;
// =============================================================
// SYS_TRANSITION:
// =============================================================
// G((hmaster0=0) * (hmaster1=0) -> (hbusreq0=0 <-> busreq=0));
assign sys_safe_err0 = ~( ~( ~(controllable_hmaster0) & ~(controllable_hmaster1) )|(~i_hbusreq0 ^~ (~controllable_busreq)));
// G((hmaster0=1) * (hmaster1=0) -> (hbusreq1=0 <-> busreq=0));
assign sys_safe_err1 = ~( ~( controllable_hmaster0 & ~(controllable_hmaster1) )|(~i_hbusreq1 ^~ (~controllable_busreq)));
// G((hmaster0=0) * (hmaster1=1) -> (hbusreq2=0 <-> busreq=0));
assign sys_safe_err2 = ~( ~( ~(controllable_hmaster0) & controllable_hmaster1 )|(~i_hbusreq2 ^~ (~controllable_busreq)));
// Guarantee 1:
// G((hready=0) -> X(start=0));
assign sys_safe_err3 = ~( reg_i_hready | controllable_nstart );
// G(((stateG2=1) * (start=1)) -> FALSE;
assign sys_safe_err4 = ~( ~(reg_stateG2 & ~controllable_nstart) | 0 );
// G(((stateG3_0=1) * (stateG3_1=0) * (stateG3_2=0) * ((start=1))) -> FALSE);
// G(((stateG3_0=0) * (stateG3_1=1) * (stateG3_2=0) * ((start=1))) -> FALSE);
// G(((stateG3_0=1) * (stateG3_1=1) * (stateG3_2=0) * ((start=1))) -> FALSE);
// G(((stateG3_0=0) * (stateG3_1=0) * (stateG3_2=1) * ((start=1))) -> FALSE);
// all these rules can be summarized as: only in state 000, start=1 is allowed:
assign sys_safe_err5 = (reg_stateG3_0 | reg_stateG3_1 | reg_stateG3_2) & ~controllable_nstart;
// G( (hready=1) -> ( (hgrant0=1) <-> (X(hmaster0=0) * X(hmaster1=0)) ) );
assign sys_safe_err6 = ~( ~(reg_i_hready) | ( ~reg_controllable_nhgrant0 ^~ ( ~(controllable_hmaster0) & ~(controllable_hmaster1) ) ) );
// G( (hready=1) -> ( (hgrant1=1) <-> (X(hmaster0=1) * X(hmaster1=0)) ) );
assign sys_safe_err7 = ~( ~(reg_i_hready) | ( reg_controllable_hgrant1 ^~ ( controllable_hmaster0 & ~(controllable_hmaster1) ) ) );
// G( (hready=1) -> ( (hgrant2=1) <-> (X(hmaster0=0) * X(hmaster1=1)) ) );
assign sys_safe_err8 = ~( ~(reg_i_hready) | ( reg_controllable_hgrant2 ^~ ( ~(controllable_hmaster0) & controllable_hmaster1 ) ) );
// HMASTLOCK:
// G( (hready=1) -> (locked=0 <-> X(hmastlock=0) ) );
assign sys_safe_err9 = ~( ~(reg_i_hready) | (~reg_controllable_locked ^~ ~controllable_hmastlock) );
// Master 0:
// G( X(start=0) -> ( ((hmaster0=0) * (hmaster1=0)) <-> (X(hmaster0=0) * X(hmaster1=0)) ) );
assign sys_safe_err10 = ~( ~(controllable_nstart) | ( ( ~(reg_controllable_hmaster0) & ~(reg_controllable_hmaster1) ) ^~ ( ~(controllable_hmaster0) & ~(controllable_hmaster1) )) );
// Master 1:
// G( X(start=0) -> ( ((hmaster0=1) * (hmaster1=0)) <-> (X(hmaster0=1) * X(hmaster1=0)) ) );
assign sys_safe_err11 = ~( ~(controllable_nstart) | ( ( reg_controllable_hmaster0 & ~(reg_controllable_hmaster1) ) ^~ ( controllable_hmaster0 & ~(controllable_hmaster1) )) );
// Master 2:
// G( X(start=0) -> ( ((hmaster0=0) * (hmaster1=1)) <-> (X(hmaster0=0) * X(hmaster1=1)) ) );
assign sys_safe_err12 = ~( ~(controllable_nstart) | ( ( ~(reg_controllable_hmaster0) & reg_controllable_hmaster1 ) ^~ ( ~(controllable_hmaster0) & controllable_hmaster1 )) );
// Guarantee 6.2:
// G( ((X(start=0))) -> ( (hmastlock=1) <-> X(hmastlock=1)) );
assign sys_safe_err13 = ~( ~(controllable_nstart) | ( reg_controllable_hmastlock ^~ controllable_hmastlock) );
// G( (decide=1 * hlock0=1 * X(hgrant0=1) )->X(locked=1));
assign sys_safe_err14 = ~( ~(~reg_controllable_ndecide & reg_i_hlock0 & ~controllable_nhgrant0) | (controllable_locked) );
// G((decide=1 * hlock0=0 * X(hgrant0=1))->X(locked=0));
assign sys_safe_err15 = ~( ~(~reg_controllable_ndecide & ~reg_i_hlock0 & ~controllable_nhgrant0) | (~controllable_locked) );
// G( (decide=1 * hlock1=1 * X(hgrant1=1) )->X(locked=1));
assign sys_safe_err16 = ~( ~(~reg_controllable_ndecide & reg_i_hlock1 & controllable_hgrant1) | (controllable_locked) );
// G((decide=1 * hlock1=0 * X(hgrant1=1))->X(locked=0));
assign sys_safe_err17 = ~( ~(~reg_controllable_ndecide & ~reg_i_hlock1 & controllable_hgrant1) | (~controllable_locked) );
// G( (decide=1 * hlock2=1 * X(hgrant2=1) )->X(locked=1));
assign sys_safe_err18 = ~( ~(~reg_controllable_ndecide & reg_i_hlock2 & controllable_hgrant2) | (controllable_locked) );
// G((decide=1 * hlock2=0 * X(hgrant2=1))->X(locked=0));
assign sys_safe_err19 = ~( ~(~reg_controllable_ndecide & ~reg_i_hlock2 & controllable_hgrant2) | (~controllable_locked) );
// G( (decide=0) -> ( ((hgrant0=0)<->X(hgrant0=0)) ));
assign sys_safe_err20 = ~( ~(reg_controllable_ndecide) | (reg_controllable_nhgrant0 ^~ controllable_nhgrant0) );
// G( (decide=0) -> ( ((hgrant1=0)<->X(hgrant1=0)) ));
assign sys_safe_err21 = ~( ~(reg_controllable_ndecide) | (~reg_controllable_hgrant1 ^~ ~controllable_hgrant1) );
// G( (decide=0) -> ( ((hgrant2=0)<->X(hgrant2=0)) ));
assign sys_safe_err22 = ~( ~(reg_controllable_ndecide) | (~reg_controllable_hgrant2 ^~ ~controllable_hgrant2) );
// G((decide=0)->(locked=0 <-> X(locked=0)));
assign sys_safe_err23 = ~( ~(reg_controllable_ndecide) | (~reg_controllable_locked ^~ ~controllable_locked) );
// G(((stateG10_1=1) * (((hgrant1=1)) * (hbusreq1=0)))->FALSE);
assign sys_safe_err24 = ~( ~(reg_stateG10_1 & (controllable_hgrant1 & ~i_hbusreq1)) | 0 );
// G(((stateG10_2=1) * (((hgrant2=1)) * (hbusreq2=0)))->FALSE);
assign sys_safe_err25 = ~( ~(reg_stateG10_2 & (controllable_hgrant2 & ~i_hbusreq2)) | 0 );
// default master
// G((decide=1 * hbusreq0=0 * hbusreq1=0 * hbusreq2=0) -> X(hgrant0=1));
assign sys_safe_err26 = ~( ~(~reg_controllable_ndecide & (~reg_i_hbusreq0 & ~reg_i_hbusreq1 & ~reg_i_hbusreq2)) | (~controllable_nhgrant0) );
// collecting together the safety error bits:
assign sys_safe_err = sys_safe_err0 |
sys_safe_err1 |
sys_safe_err2 |
sys_safe_err3 |
sys_safe_err4 |
sys_safe_err5 |
sys_safe_err6 |
sys_safe_err7 |
sys_safe_err8 |
sys_safe_err9 |
sys_safe_err10 |
sys_safe_err11 |
sys_safe_err12 |
sys_safe_err13 |
sys_safe_err14 |
sys_safe_err15 |
sys_safe_err16 |
sys_safe_err17 |
sys_safe_err18 |
sys_safe_err19 |
sys_safe_err20 |
sys_safe_err21 |
sys_safe_err22 |
sys_safe_err23 |
sys_safe_err24 |
sys_safe_err25 |
sys_safe_err26;
// =============================================================
// ENV_FAIRNESS:
// =============================================================
// Assumption 1:
// G(F(stateA1=0));
assign env_fair0 = ~reg_stateA1;
// Assumption 2:
// G(F(hready=1));
assign env_fair1 = i_hready;
// =============================================================
// SYS_FAIRNESS:
// =============================================================
// Guarantee 2:
// G(F(stateG2=0));
assign sys_fair0 = ~reg_stateG2;
// Guarantee 3:
// G(F((stateG3_0=0) * (stateG3_1=0) * (stateG3_2=0)));
assign sys_fair1 = (~reg_stateG3_0 & ~reg_stateG3_1 & ~reg_stateG3_2);
// G(F(((hmaster0=0) * (hmaster1=0)) | hbusreq0=0));
assign sys_fair2 = ( ~(controllable_hmaster0) & ~(controllable_hmaster1) ) | ~i_hbusreq0;
// G(F(((hmaster0=1) * (hmaster1=0)) | hbusreq1=0));
assign sys_fair3 = ( controllable_hmaster0 & ~(controllable_hmaster1) ) | ~i_hbusreq1;
// G(F(((hmaster0=0) * (hmaster1=1)) | hbusreq2=0));
assign sys_fair4 = ( ~(controllable_hmaster0) & controllable_hmaster1 ) | ~i_hbusreq2;
assign fair_err = (fair_cnt >= 3'b100);
// computing the error output bit:
assign o_err = ~env_safe_err & ~env_safe_err_happened & (sys_safe_err | fair_err);
initial
begin
reg_i_hready = 0;
reg_i_hbusreq0 = 0;
reg_i_hlock0 = 0;
reg_i_hbusreq1 = 0;
reg_i_hlock1 = 0;
reg_i_hbusreq2 = 0;
reg_i_hlock2 = 0;
reg_controllable_hmaster0 = 0;
reg_controllable_hmaster1 = 0;
reg_controllable_hmastlock = 0;
reg_controllable_nstart = 0;
reg_controllable_ndecide = 0;
reg_controllable_locked = 0;
reg_controllable_nhgrant0 = 0;
reg_controllable_hgrant1 = 0;
reg_controllable_hgrant2 = 0;
reg_controllable_busreq = 0;
reg_stateA1 = 0;
reg_stateG2 = 0;
reg_stateG3_0 = 0;
reg_stateG3_1 = 0;
reg_stateG3_2 = 0;
reg_stateG10_1 = 0;
reg_stateG10_2 = 0;
env_safe_err_happened = 0;
next_env_fair = 0;
fair_cnt = 0;
next_sys_fair = 0;
end
always @(posedge i_clk)
begin
// We remember if an environment error occurred:
env_safe_err_happened = env_safe_err_happened | env_safe_err;
// Updating the fairness counters:
if((next_sys_fair == 0) & sys_fair0)
begin
next_sys_fair = 1;
next_env_fair = 0;
fair_cnt = 0;
end
else if((next_sys_fair == 1) & sys_fair1)
begin
next_sys_fair = 2;
next_env_fair = 0;
fair_cnt = 0;
end
else if((next_sys_fair == 2) & sys_fair2)
begin
next_sys_fair = 3;
next_env_fair = 0;
fair_cnt = 0;
end
else if((next_sys_fair == 3) & sys_fair3)
begin
next_sys_fair = 4;
next_env_fair = 0;
fair_cnt = 0;
end
else if((next_sys_fair == 4) & sys_fair4)
begin
next_sys_fair = 0;
next_env_fair = 0;
fair_cnt = 0;
end
else if(~next_env_fair & env_fair0)
begin
next_env_fair = 1;
end
else if(next_env_fair & env_fair1)
begin
next_env_fair = 0;
fair_cnt = fair_cnt + 1;
end
// Updating the automata:
// Automaton A1:
if(~reg_stateA1 & controllable_hmastlock & ~i_hburst0 & ~i_hburst1)
begin
reg_stateA1 = 1'b1;
end
else if(reg_stateA1 & ~controllable_busreq)
begin
reg_stateA1 = 1'b0;
end
// Automaton G2:
if(~reg_stateG2)
begin
if(controllable_hmastlock & ~controllable_nstart & ~i_hburst0 & ~i_hburst1)
begin
reg_stateG2 = 1'b1;
end
end
else // if(reg_stateG2)
begin
if(~controllable_busreq)
begin
reg_stateG2 = 1'b0;
end
end
// Automaton G3:
if(~reg_stateG3_0 & ~reg_stateG3_1 & ~reg_stateG3_2 & controllable_hmastlock & ~controllable_nstart & ~i_hburst0 & i_hburst1 & ~i_hready)
begin
reg_stateG3_0 = 1'b1;
reg_stateG3_1 = 1'b0;
reg_stateG3_2 = 1'b0;
end
else if(~reg_stateG3_0 & ~reg_stateG3_1 & ~reg_stateG3_2 & controllable_hmastlock & ~controllable_nstart & ~i_hburst0 & i_hburst1 & i_hready)
begin
reg_stateG3_0 = 1'b0;
reg_stateG3_1 = 1'b1;
reg_stateG3_2 = 1'b0;
end
else if(reg_stateG3_0 & ~reg_stateG3_1 & ~reg_stateG3_2 & i_hready)
begin
reg_stateG3_0 = 1'b0;
reg_stateG3_1 = 1'b1;
reg_stateG3_2 = 1'b0;
end
else if(~reg_stateG3_0 & reg_stateG3_1 & ~reg_stateG3_2 & i_hready)
begin
reg_stateG3_0 = 1'b1;
reg_stateG3_1 = 1'b1;
reg_stateG3_2 = 1'b0;
end
else if(reg_stateG3_0 & reg_stateG3_1 & ~reg_stateG3_2 & i_hready)
begin
reg_stateG3_0 = 1'b0;
reg_stateG3_1 = 1'b0;
reg_stateG3_2 = 1'b1;
end
else if(~reg_stateG3_0 & ~reg_stateG3_1 & reg_stateG3_2 & i_hready)
begin
reg_stateG3_0 = 1'b0;
reg_stateG3_1 = 1'b0;
reg_stateG3_2 = 1'b0;
end
// Automaton G10_1:
if(~reg_stateG10_1 & ~controllable_hgrant1 & ~i_hbusreq1)
begin
reg_stateG10_1 = 1'b1;
end
else if(reg_stateG10_1 & i_hbusreq1)
begin
reg_stateG10_1 = 1'b0;
end
// Automaton G10_2:
if(~reg_stateG10_2 & ~controllable_hgrant2 & ~i_hbusreq2)
begin
reg_stateG10_2 = 1'b1;
end
else if(reg_stateG10_2 & i_hbusreq2)
begin
reg_stateG10_2 = 1'b0;
end
// Latching the previous input:
reg_i_hready = i_hready;
reg_i_hbusreq0 = i_hbusreq0;
reg_i_hlock0 = i_hlock0;
reg_i_hbusreq1 = i_hbusreq1;
reg_i_hlock1 = i_hlock1;
reg_i_hbusreq2 = i_hbusreq2;
reg_i_hlock2 = i_hlock2;
reg_controllable_hmaster0 = controllable_hmaster0;
reg_controllable_hmaster1 = controllable_hmaster1;
reg_controllable_hmastlock = controllable_hmastlock;
reg_controllable_nstart = controllable_nstart;
reg_controllable_ndecide = controllable_ndecide;
reg_controllable_locked = controllable_locked;
reg_controllable_nhgrant0 = controllable_nhgrant0;
reg_controllable_hgrant1 = controllable_hgrant1;
reg_controllable_hgrant2 = controllable_hgrant2;
reg_controllable_busreq = controllable_busreq;
end
endmodule
-------------------------------