aboutsummaryrefslogtreecommitdiff
path: root/testing/DMAppFpgaProg/fpga_data/FlashRom1kbitPattern01_80 - 2018-07-27.stp
blob: 9fa2147434ae668529e503f59241b69aa373e782 (plain)
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
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
NOTE "CREATOR" "Designer Version: 11.8.0.26";
NOTE "CAPTURE" "11.8.0.26";
NOTE "DEVICE" "AGLN250V2";
NOTE "PACKAGE" "AGLN250V2-vq100";
NOTE "DATE" "2018/07/27";
NOTE "TIME" "21:59:31";
NOTE "STAPL_VERSION" "JESD71";
NOTE "VENDOR" "Microsemi Corporation";
NOTE "IDCODE" "03A541CF";
NOTE "IDMASK" "07FFFFFF";
NOTE "DESIGN" "TutorKit1FlashRom2_v100_Top";
NOTE "DESIGN_DIRECTORY" "D:\_ZDROJE\Libero\Tutorial\TUTOR--KIT-1--FLASHROM-2--V1-00\designer\impl1\";
NOTE "CHECKSUM" "0000";
NOTE "SECURITY" "Disable";
NOTE "ALG_VERSION" "20";
NOTE "MAP_VERSION" "1";
NOTE "TOOL_VERSION" "1";
NOTE "MAX_FREQ" "20000000";
NOTE "SILSIG" "00000000";
NOTE "ACT_FROM_SPECIFICATION" "Region_0 (0, 15) (0, 0);Region_1 (1, 15) (1, 0);Region_2 (2
    , 15) (2, 0);Region_3 (3, 15) (3, 0);Region_4 (4, 15) (4, 0);Region_5 (5, 15) (5
    , 0);Region_6 (6, 15) (6, 0);Region_7 (7, 15) (7, 0);";
NOTE "SPEED_GRAD" "STD";
NOTE "TEMP_GRAD" "COM";
NOTE "PLAYER_VERSION_VARIABLE" "PLAYERVERSIONVARIABLE";
NOTE "PLAYER_VERSION_SW_VARIABLE" "PLAYERVERSIONSWVARIABLE";

ACTION ERASE_FROM = 
       VERIFY_IDCODE,
       FW_INITIALIZE,
       DO_ERASE_FROM,
       DO_EXIT;
ACTION PROGRAM_FROM = 
       VERIFY_IDCODE,
       FW_INITIALIZE,
       DO_ERASE_FROM,
       DO_PROGRAM_FROM,
       DO_VERIFY_FROM,
       DO_EXIT;
ACTION VERIFY_FROM = 
       VERIFY_IDCODE,
       FR_INITIALIZE,
       DO_VERIFY_FROM,
       DO_EXIT;
ACTION PROGRAM = 
       VERIFY_IDCODE,
       W_INITIALIZE,
       DO_ERASE,
       DO_PROGRAM_FROM,
       DO_VERIFY_FROM,
       DO_EXIT;
ACTION ERASE = 
       VERIFY_IDCODE,
       W_INITIALIZE,
       DO_ERASE_ONLY,
       DO_EXIT;
ACTION ERASE_ALL = 
       VERIFY_IDCODE,
       INITIALIZE,
       DO_ERASE_ALL,
       DO_EXIT;
ACTION VERIFY = 
       VERIFY_IDCODE,
       R_INITIALIZE,
       DO_VERIFY_FROM,
       DO_EXIT;
ACTION READ_IDCODE = 
       DO_READ_IDCODE;
ACTION VERIFY_DEVICE_INFO = 
       VERIFY_IDCODE,
       READ_INITIALIZE,
       READ_IDCODE_ONLY,
       DO_VERIFY_DEVICE_INFO,
       DO_EXIT;
ACTION DEVICE_INFO = 
       VERIFY_IDCODE,
       READ_INITIALIZE,
       READ_IDCODE_ONLY,
       DO_DEVICE_INFO,
       DO_QUERY_SECURITY,
       DO_EXIT;



DATA CONSTBLOCK;
    INTEGER IEEE1532=0;
    INTEGER STAPL=1;
    INTEGER DIRECTC=2;
    INTEGER PDB=3;
    INTEGER SVF=4;
    INTEGER FP=0;
    INTEGER FPLITE=1;
    INTEGER FP3=2;
    INTEGER SCULPTW=3;
    INTEGER BPW=4;
    INTEGER DIRECTCP=5;
    INTEGER STP=6;
    INTEGER FP4=7;
    INTEGER FP5=8;
    INTEGER FP33=0;
    INTEGER FP34=1;
    INTEGER FP40=2;
    INTEGER FP41=3;
    INTEGER FP42=4;
    INTEGER FP50=5;
    INTEGER FP51=6;
    INTEGER FP60=7;
    INTEGER FP61=8;
    INTEGER FP62=9;
    INTEGER FP84=11;
    INTEGER FP85=12;
    INTEGER FP86=13;
    INTEGER FP90=14;
    INTEGER FP91=15;
    INTEGER FP100=16;
    INTEGER FP_11=19;
    INTEGER FP_11_1=20;
    INTEGER FP_11_2=21;
    INTEGER FP_11_3=22;
    INTEGER FP_11_4=23;
    INTEGER FP_11_5=24;
    INTEGER FP_11_6=25;
    INTEGER FP_11_7=26;
    INTEGER FP_11_8=27;
    INTEGER UNKNOWN=127;
    INTEGER UNSPECIFIED=0;
    INTEGER QN132=1;
    INTEGER VQ100=2;
    INTEGER TQ144=3;
    INTEGER PQ208=4;
    INTEGER FG144=5;
    INTEGER FG256=6;
    INTEGER FG484=7;
    INTEGER FG676=8;
    INTEGER FG896=9;
    INTEGER QN108=10;
    INTEGER QN180=11;
    INTEGER TQ100=12;
    INTEGER CQ208=13;
    INTEGER FG1152=14;
    INTEGER BG456=15;
    INTEGER UNDEFINED=63;
    INTEGER GRADE_UNSPEC=0;
    INTEGER GRADE_1=1;
    INTEGER GRADE_2=2;
    INTEGER GRADE_3=3;
    INTEGER GRADE_F=4;
    INTEGER GRADE_STD=5;
    INTEGER GRADE_4=6;
    INTEGER GRADE_UNDEF=7;
ENDDATA;

DATA PARAMETERS;
    INTEGER FREQ =4;
ENDDATA;

DATA GV;
    INTEGER ULOPT1_BITLOCATION =11;
    INTEGER ULOPT0_BITLOCATION =10;
    INTEGER ULUWE_BITLOCATION =9;
    INTEGER ULARE_BITLOCATION =8;
    INTEGER ULUPC_BITLOCATION =7;
    INTEGER ULUFE_BITLOCATION =6;
    INTEGER ULUFP_BITLOCATION =5;
    INTEGER ULUFJ_BITLOCATION =4;
    INTEGER ULFLR_BITLOCATION =3;
    INTEGER ULULR_BITLOCATION =2;
    INTEGER ULAWE_BITLOCATION =1;
    INTEGER ULARD_BITLOCATION =0;
    BOOLEAN BUFF128[128];
    BOOLEAN BUFF32[32];
    INTEGER I;
    INTEGER J;
    INTEGER TEMP;
    INTEGER SDNUMBER;
    INTEGER ROWNUMBER;
    INTEGER DATAINDEX =0;
    INTEGER FROMROWNUMBER =1;
    INTEGER AESBLOCK;
    BOOLEAN ID[32];
    BOOLEAN PASS = 1;
    BOOLEAN FADDR[3];
    INTEGER STATUS =0;
    BOOLEAN SILSIG[32] = $00000000;
    BOOLEAN ISC_CONFIG_RESULT[18];
    BOOLEAN VERIFYEOL[2];
    BOOLEAN COMBERASESELECT[23];
    BOOLEAN SECKEY_OK = 1;
    BOOLEAN SECREG[44];
    BOOLEAN ULUWE = 0;
    BOOLEAN ULARE = 0;
    BOOLEAN ULUPC = 0;
    BOOLEAN ULUFE = 0;
    BOOLEAN ULUFP = 0;
    BOOLEAN ULUFJ = 0;
    BOOLEAN ULFLR = 0;
    BOOLEAN ULULR = 0;
    BOOLEAN ULAWE = 0;
    BOOLEAN ULARD = 0;
    BOOLEAN ULOPT[2];
    BOOLEAN SUROWCHECKSUM[16];
    INTEGER SUROWCYCLECOUNT =0;
    INTEGER ACT_UROW_CYCLE_COUNT =0;
    BOOLEAN ACT_UROW_DESIGN_NAME[70] = $0ad72fed3e9965e331;
    BOOLEAN SUROWDESIGNNAME[70];
    BOOLEAN SUROWPROGMETHOD[3];
    BOOLEAN ACT_UROW_ALGO_VERSION[7] = $14;
    BOOLEAN SUROWALGOVERSION[7];
    BOOLEAN SUROW_PKG_TYPE[6];
    BOOLEAN ACT_UROW_SW_VERSION[7];
    BOOLEAN SUROW_SW_VERSION[7];
    INTEGER PLAYERVERSIONVARIABLE =0;
    INTEGER PLAYERVERSIONSWVARIABLE =0;
    INTEGER SCULPTORMAJORBASE =5;
    INTEGER SCULPTORMINORBASE =16;
    BOOLEAN ACT_UROW_PROGRAM_SW[4];
    BOOLEAN SUROWPROGRAMSW[4];
    BOOLEAN SUROW_SPEED_GRADE[3];
    BOOLEAN SUROW_SRAM_DISTURB[1];
    BOOLEAN ISERASEONLY = 0;
    BOOLEAN ISRESTOREDESIGN = 0;
    BOOLEAN FLAGDISPLAYCYC = 1;
    BOOLEAN ISPRGARRAY = 0;
    BOOLEAN BSRPATTERN[708] = $9249249249249249249249249249249249249249249249249
        249249249249249249249249249249249249249249249249249249249249249249249249
        24924924924924924924924924924924924924924924924924924924;
    BOOLEAN SAMPLEMASK[708] = $0000000000000000000000000000000000000000000000000
        000000000000000000000000000000000000000000000000000000000000000000000000
        00000000000000000000000000000000000000000000000000000000;
    BOOLEAN BSR[708];
    BOOLEAN SAMPLE_DEVICE[708];
    BOOLEAN ARRAYRONLY = 1;
    BOOLEAN CHKARRAY = 0;
    BOOLEAN FROMRONLY = 1;
    BOOLEAN CHKFROM = 0;
    BOOLEAN CHKNVM = 0;
    BOOLEAN CHKSEC = 1;
    BOOLEAN PERMLOCK = 0;
    INTEGER HEX[16] = 70,69,68,67,66,65,57,56,55,54,53,52,51,50,49,48;
    INTEGER NUMBEROFFROMROWS =8;
    BOOLEAN INITIALIZE_DATA[5] = $00;
    INTEGER SDTILE;
    INTEGER NUMBEROFSDTILES =4;
    INTEGER NUMBEROFMAPROWS =2300;
    INTEGER IDREV;
    INTEGER IDFAB;
    INTEGER BM7DEVICE =0;
    INTEGER BM1DEVICE =0;
    BOOLEAN M1BUFF[128] = $acdd6548ccb488863e291eb18fe95077;
    BOOLEAN M7BUFF[128] = $e137623a2eeee91126015f3f73664945;
    BOOLEAN IDCODEVALUE[32] = $03a541cf;
    BOOLEAN IDMASK[32] = $07ffffff;
    INTEGER SECKEYCHK =0;
    INTEGER DESIGNPKGTYPE =2;
    BOOLEAN ACT_UROW_PROG_METHOD[3] = $1;
    INTEGER LABEL_SEPARATOR =0;
    INTEGER ROWITERATION =100;
    INTEGER PAGEITERATION =100;
    INTEGER PERCENT_UPDATE;
    INTEGER DIFFERENCE;
    INTEGER UNIQUEEXITCODE =0;
ENDDATA;

DATA BITSTREAM;
    BOOLEAN UROW[128];
    BOOLEAN UROW_MASK[128] = $fffffffffffffffffffffffffe01ffc0;
    INTEGER CHECKSUM =0;
ENDDATA;

DATA FROM_V;
    BOOLEAN Region_0[128];
    BOOLEAN Region_1[128];
    BOOLEAN Region_2[128];
    BOOLEAN Region_3[128];
    BOOLEAN Region_4[128];
    BOOLEAN Region_5[128];
    BOOLEAN Region_6[128];
    BOOLEAN Region_7[128];
    BOOLEAN FROMADDRESSMASK[8] = $ff;
    BOOLEAN FROMSTREAM[1024] = @020000_ubtyqNFxl7Vvh@_ulV@zFuXJyn9NvcVEqJNThpUxS
        @Te5jqJZwgjsrOdDjtcRTxzt0EOXDCn5puZHMoAlCcRsPF3RiaTMQLhjt2tSrrkysBV@5KXA
        we8jKJTAgfIrLPLhk_A8ZKIJIPbiyICbfcRYpEzqd06817aG5QuXGCH5j8ZDon710;
ENDDATA;


PROCEDURE DO_EXIT USES GV;
    IRSTOP IRPAUSE;
    DRSTOP DRPAUSE;
    IRSCAN 8, $81;
    WAIT IDLE, 250 USEC;
    IRSCAN 8, $81, CAPTURE BUFF128[7..0];
    IF ( ! (BUFF128[2]==0) ) THEN GOTO Label_0;
    IRSTOP IRPAUSE;
    DRSTOP DRPAUSE;
    IRSCAN 8, $07;
    WAIT IDLE, 1 CYCLES;
    WAIT IDLE, 200 USEC;
    Label_0:
    IRSCAN 8, $ff;
    WAIT IDLE, 200 USEC;
    WAIT RESET, 3 CYCLES;
    EXIT STATUS;
ENDPROC;

PROCEDURE DO_READ_SECURITY USES GV;
    IRSTOP IRPAUSE;
    DRSTOP DRPAUSE;
    IRSCAN 8, $a4;
    WAIT IDLE, 3 CYCLES;
    DRSCAN 44, $00000000000, CAPTURE SECREG[];
    ULUWE = SECREG[ULUWE_BITLOCATION];
    ULARE = SECREG[ULARE_BITLOCATION];
    ULUPC = SECREG[ULUPC_BITLOCATION];
    ULUFE = SECREG[ULUFE_BITLOCATION];
    ULUFP = SECREG[ULUFP_BITLOCATION];
    ULUFJ = SECREG[ULUFJ_BITLOCATION];
    ULFLR = SECREG[ULFLR_BITLOCATION];
    ULULR = SECREG[ULULR_BITLOCATION];
    ULAWE = SECREG[ULAWE_BITLOCATION];
    ULARD = SECREG[ULARD_BITLOCATION];
    ULOPT[1] = SECREG[ULOPT1_BITLOCATION];
    ULOPT[0] = SECREG[ULOPT0_BITLOCATION];
ENDPROC;

PROCEDURE DO_OUTPUT_SECURITY USES GV;
    PRINT "Security Settings :";
    IF ( ! (ULUFP==1) ) THEN GOTO Label_1;
    PRINT "FlashROM Write/Erase protected by pass key.";
    Label_1:
    IF ( ! (ULUFJ==1) ) THEN GOTO Label_2;
    PRINT "FlashROM Read protected by pass key.";
    Label_2:
    IF ( ! (ULAWE==1) ) THEN GOTO Label_3;
    PRINT "Array Write/Erase protected by pass key.";
    Label_3:
    IF ( ! (ULARD==1) ) THEN GOTO Label_4;
    PRINT "Array Verify protected by pass key.";
    Label_4:
    IF ( ! (ULUFE==1) ) THEN GOTO Label_5;
    PRINT "Encrypted FlashROM Programming Enabled.";
    Label_5:
    IF ( ! (ULARE==1) ) THEN GOTO Label_6;
    PRINT "Encrypted FPGA Array Programming Enabled.";
    Label_6:
    PRINT "=========================================";
ENDPROC;

PROCEDURE DO_QUERY_SECURITY USES DO_READ_SECURITY,DO_OUTPUT_SECURITY;
    CALL DO_READ_SECURITY;
    CALL DO_OUTPUT_SECURITY;
ENDPROC;

PROCEDURE READ_UROW USES BITSTREAM,GV;
    IRSTOP IRPAUSE;
    DRSTOP DRPAUSE;
    IRSCAN 8, $c0;
    WAIT IDLE, 1 CYCLES;
    IRSTOP IRPAUSE;
    DRSTOP DRPAUSE;
    IRSCAN 8, $a8;
    WAIT IDLE, 3 CYCLES;
    WAIT IDLE, 165 USEC;
    DRSCAN 128, $00000000000000000000000000000000, CAPTURE UROW[];
    SUROWALGOVERSION[6..0] = $00;
    IF ( ! ( (UROW[5]==0)&&(UROW[0]==1)) ) THEN GOTO Label_7;
    SUROWALGOVERSION[5..4] = UROW[24..23];
    Label_7:
    IF ( ! ( (UROW[5]==1)&&(UROW[0]==0)) ) THEN GOTO Label_8;
    SUROWALGOVERSION[5..4] = UROW[24..23];
    SUROWALGOVERSION[6] = 1;
    Label_8:
    SUROWCHECKSUM[15..0] = UROW[127..112];
    SUROWCYCLECOUNT = INT(UROW[111..102]);
    SUROWDESIGNNAME[69..0] = UROW[101..32];
    SUROWPROGMETHOD[2..0] = UROW[31..29];
    SUROWALGOVERSION[3..0] = UROW[28..25];
    SUROW_PKG_TYPE[5..0] = UROW[22..17];
    SUROW_SW_VERSION[6..0] = UROW[16..10];
    SUROWPROGRAMSW[3..0] = UROW[9..6];
    SUROW_SRAM_DISTURB[0] = UROW[4];
    SUROW_SPEED_GRADE[2..0] = UROW[3..1];
    ACT_UROW_CYCLE_COUNT = SUROWCYCLECOUNT;
ENDPROC;

PROCEDURE FIX_INT_ARRAYS USES GV;
    IF ( ! (HEX[0]!=48) ) THEN GOTO Label_9;
    FOR I = 0 TO 7;
        TEMP = HEX[I];
        HEX[I] = HEX[(15-I)];
        HEX[(15-I)] = TEMP;
    NEXT I;
    Label_9:
    LABEL_SEPARATOR = 0;
ENDPROC;

PROCEDURE DISP_CHKSUM_DESIGN USES GV,FIX_INT_ARRAYS;
    CALL FIX_INT_ARRAYS;
    IF ( ! (INT(SUROWCHECKSUM[15..0])==65535) ) THEN GOTO Label_10;
    PRINT "CHECKSUM: ";
    Label_10:
    IF ( ! (INT(SUROWCHECKSUM[15..0])!=65535) ) THEN GOTO Label_11;
    PRINT "CHECKSUM: ",CHR$(HEX[INT(SUROWCHECKSUM[15..12])]),CHR$(HEX[INT(SUROWCHECKSUM[11..8])])
        ,CHR$(HEX[INT(SUROWCHECKSUM[7..4])]),CHR$(HEX[INT(SUROWCHECKSUM[3..0])]);
    Label_11:
    IF ( ! ( ( (INT(SUROWDESIGNNAME[0..30])==2147483647)&&(INT(SUROWDESIGNNAME[31..61])==2147483647))&&(INT(SUROWDESIGNNAME[62..69])==255)) ) THEN GOTO Label_12;
    PRINT "Design Name: ";
    Label_12:
    IF ( ! ( ( (INT(SUROWDESIGNNAME[0..30])!=2147483647)||(INT(SUROWDESIGNNAME[31..61])!=2147483647))||(INT(SUROWDESIGNNAME[62..69])!=255)) ) THEN GOTO Label_13;
    PRINT "Design Name: ",CHR$(INT(SUROWDESIGNNAME[63..69])),CHR$(INT(SUROWDESIGNNAME[56..62]))
        ,CHR$(INT(SUROWDESIGNNAME[49..55])),CHR$(INT(SUROWDESIGNNAME[42..48])),CHR$(INT(SUROWDESIGNNAME[35..41]))
        ,CHR$(INT(SUROWDESIGNNAME[28..34])),CHR$(INT(SUROWDESIGNNAME[21..27])),CHR$(INT(SUROWDESIGNNAME[14..20]))
        ,CHR$(INT(SUROWDESIGNNAME[7..13])),CHR$(INT(SUROWDESIGNNAME[0..6]));
    Label_13:
    LABEL_SEPARATOR = 0;
ENDPROC;

PROCEDURE DISPLAY_UROW USES BITSTREAM,CONSTBLOCK,GV,DISP_CHKSUM_DESIGN;
    EXPORT "USER_ROW", UROW[127..0];
    PRINT "User information: ";
    CALL DISP_CHKSUM_DESIGN;
    IF ( ! (FLAGDISPLAYCYC==1) ) THEN GOTO Label_14;
    PRINT "CYCLE COUNT: ",SUROWCYCLECOUNT;
    Label_14:
    INTEGER TMPINT =INT(SUROWPROGMETHOD[]);
    INTEGER TMPINT2 =0;
    INTEGER TMPINT3 =0;
    INTEGER TMPINT4 =0;
    INTEGER TMPINT5 =0;
    IF ( ! (TMPINT==IEEE1532) ) THEN GOTO Label_15;
    PRINT "Programming Method: IEEE1532";
    Label_15:
    IF ( ! (TMPINT==STAPL) ) THEN GOTO Label_16;
    PRINT "Programming Method: STAPL";
    Label_16:
    IF ( ! (TMPINT==DIRECTC) ) THEN GOTO Label_17;
    PRINT "Programming Method: DirectC";
    Label_17:
    IF ( ! (TMPINT==PDB) ) THEN GOTO Label_18;
    PRINT "Programming Method: PDB";
    Label_18:
    IF ( ! (TMPINT==SVF) ) THEN GOTO Label_19;
    PRINT "Programming Method: SVF";
    Label_19:
    PRINT "Algorithm Version: ",INT(SUROWALGOVERSION[6..0]);
    TMPINT = INT(SUROW_SPEED_GRADE[]);
    IF ( ! (TMPINT==GRADE_UNSPEC) ) THEN GOTO Label_20;
    PRINT "Device Speed Grade: speed grade information not available from device";
    Label_20:
    IF ( ! (TMPINT==GRADE_1) ) THEN GOTO Label_21;
    PRINT "Device Speed Grade: -1";
    Label_21:
    IF ( ! (TMPINT==GRADE_2) ) THEN GOTO Label_22;
    PRINT "Device Speed Grade: -2";
    Label_22:
    IF ( ! (TMPINT==GRADE_3) ) THEN GOTO Label_23;
    PRINT "Device Speed Grade: -3";
    Label_23:
    IF ( ! (TMPINT==GRADE_F) ) THEN GOTO Label_24;
    PRINT "Device Speed Grade: -F";
    Label_24:
    IF ( ! (TMPINT==GRADE_STD) ) THEN GOTO Label_25;
    PRINT "Device Speed Grade: STD";
    Label_25:
    IF ( ! (TMPINT==GRADE_4) ) THEN GOTO Label_26;
    PRINT "Device Speed Grade: -4";
    Label_26:
    IF ( ! (TMPINT==GRADE_UNDEF) ) THEN GOTO Label_27;
    PRINT "Device Speed Grade: speed grade information not available from device";
    Label_27:
    TMPINT = INT(SUROWPROGRAMSW[]);
    IF ( ! (TMPINT==FP) ) THEN GOTO Label_28;
    PRINT "Programmer: FlashPro";
    Label_28:
    IF ( ! (TMPINT==FPLITE) ) THEN GOTO Label_29;
    PRINT "Programmer: FlashPro Lite";
    Label_29:
    IF ( ! (TMPINT==FP3) ) THEN GOTO Label_30;
    PRINT "Programmer: FlashPro3";
    Label_30:
    IF ( ! (TMPINT==FP4) ) THEN GOTO Label_31;
    PRINT "Programmer: FlashPro4";
    Label_31:
    IF ( ! (TMPINT==FP5) ) THEN GOTO Label_32;
    PRINT "Programmer: FlashPro5";
    Label_32:
    IF ( ! (TMPINT==SCULPTW) ) THEN GOTO Label_33;
    PRINT "Programmer: Sculptor WIN";
    Label_33:
    IF ( ! (TMPINT==BPW) ) THEN GOTO Label_34;
    PRINT "Programmer: BP Programmer";
    Label_34:
    IF ( ! (TMPINT==DIRECTCP) ) THEN GOTO Label_35;
    PRINT "Programmer: DirectC";
    Label_35:
    IF ( ! (TMPINT==STP) ) THEN GOTO Label_36;
    PRINT "Programmer: Actel JAM Player";
    Label_36:
    IF ( ! ( ( ( ( (TMPINT==FP)||(TMPINT==FPLITE))||(TMPINT==FP3))||(TMPINT==FP4))||(TMPINT==FP5)) ) THEN GOTO Label_52;
    TMPINT2 = INT(SUROW_SW_VERSION[]);
    IF ( ! (TMPINT2==FP33) ) THEN GOTO Label_37;
    PRINT "Software: FlashPro v3.3";
    Label_37:
    IF ( ! (TMPINT2==FP34) ) THEN GOTO Label_38;
    PRINT "Software: FlashPro v3.4";
    Label_38:
    IF ( ! (TMPINT2==FP40) ) THEN GOTO Label_39;
    PRINT "Software: FlashPro v4.0";
    Label_39:
    IF ( ! (TMPINT2==FP41) ) THEN GOTO Label_40;
    PRINT "Software: FlashPro v4.1";
    Label_40:
    IF ( ! (TMPINT2==FP42) ) THEN GOTO Label_41;
    PRINT "Software: FlashPro v4.2";
    Label_41:
    IF ( ! (TMPINT2==FP50) ) THEN GOTO Label_42;
    PRINT "Software: FlashPro v5.0";
    Label_42:
    IF ( ! (TMPINT2==FP51) ) THEN GOTO Label_43;
    PRINT "Software: FlashPro v5.1";
    Label_43:
    IF ( ! (TMPINT2==FP60) ) THEN GOTO Label_44;
    PRINT "Software: FlashPro v6.0";
    Label_44:
    IF ( ! (TMPINT2==FP61) ) THEN GOTO Label_45;
    PRINT "Software: FlashPro v6.1";
    Label_45:
    IF ( ! (TMPINT2==FP62) ) THEN GOTO Label_46;
    PRINT "Software: FlashPro v6.2";
    Label_46:
    IF ( ! (TMPINT2==FP84) ) THEN GOTO Label_47;
    PRINT "Software: FlashPro v8.4";
    Label_47:
    IF ( ! (TMPINT2==FP85) ) THEN GOTO Label_48;
    PRINT "Software: FlashPro v8.5";
    Label_48:
    IF ( ! (TMPINT2==FP86) ) THEN GOTO Label_49;
    PRINT "Software: FlashPro v8.6";
    Label_49:
    IF ( ! (TMPINT2==FP90) ) THEN GOTO Label_50;
    PRINT "Software: FlashPro v9.0";
    Label_50:
    IF ( ! (TMPINT2==FP91) ) THEN GOTO NOT_FP91;
    PRINT "Software: FlashPro v9.1";
    NOT_FP91:
    IF ( ! (TMPINT2==FP100) ) THEN GOTO NOT_FP100;
    PRINT "Software: FlashPro v10.0";
    NOT_FP100:
    IF ( ! (TMPINT2==FP_11) ) THEN GOTO NOT_FP_11;
    PRINT "Software: FlashPro v11.0";
    NOT_FP_11:
    IF ( ! (TMPINT2==FP_11_1) ) THEN GOTO NOT_FP_11_1;
    PRINT "Software: FlashPro v11.1";
    NOT_FP_11_1:
    IF ( ! (TMPINT2==FP_11_2) ) THEN GOTO NOT_FP_11_2;
    PRINT "Software: FlashPro v11.2";
    NOT_FP_11_2:
    IF ( ! (TMPINT2==FP_11_3) ) THEN GOTO NOT_FP_11_3;
    PRINT "Software: FlashPro v11.3";
    NOT_FP_11_3:
    IF ( ! (TMPINT2==FP_11_4) ) THEN GOTO NOT_FP_11_4;
    PRINT "Software: FlashPro v11.4";
    NOT_FP_11_4:
    IF ( ! (TMPINT2==FP_11_5) ) THEN GOTO NOT_FP_11_5;
    PRINT "Software: FlashPro v11.5";
    NOT_FP_11_5:
    IF ( ! (TMPINT2==FP_11_6) ) THEN GOTO NOT_FP_11_6;
    PRINT "Software: FlashPro v11.6";
    NOT_FP_11_6:
    IF ( ! (TMPINT2==FP_11_7) ) THEN GOTO NOT_FP_11_7;
    PRINT "Software: FlashPro v11.7";
    NOT_FP_11_7:
    IF ( ! (TMPINT2==FP_11_8) ) THEN GOTO NOT_FP_11_8;
    PRINT "Software: FlashPro v11.8";
    NOT_FP_11_8:
    IF ( ! (TMPINT2==UNKNOWN) ) THEN GOTO Label_51;
    PRINT "Software: FlashPro vX.X";
    Label_51:
    LABEL_SEPARATOR = 0;
    Label_52:
    IF ( ! ( (TMPINT==SCULPTW)||(TMPINT==BPW)) ) THEN GOTO Label_56;
    TMPINT3 = (INT(SUROW_SW_VERSION[6..5])+SCULPTORMAJORBASE);
    TMPINT4 = (INT(SUROW_SW_VERSION[4..1])+SCULPTORMINORBASE);
    TMPINT5 = 0;
    IF ( ! (SUROW_SW_VERSION[0]==1) ) THEN GOTO Label_53;
    TMPINT5 = 1;
    Label_53:
    INTEGER CURRPGM =INT(ACT_UROW_PROGRAM_SW[3..0]);
    IF ( ! (TMPINT==SCULPTW) ) THEN GOTO Label_54;
    IF ( ! ( ( (CURRPGM==FP3)||(CURRPGM==FP4))||(CURRPGM==FP5)) ) THEN GOTO NOT_FP3_FP4;
    PRINT "NOTE: The Sculptor Windows version number below should be converted to HEX.";
    NOT_FP3_FP4:
    PRINT "Software: Sculptor Win v",TMPINT3,".",TMPINT4,".",TMPINT5;
    Label_54:
    IF ( ! (TMPINT==BPW) ) THEN GOTO Label_55;
    IF ( ! ( ( (CURRPGM==FP3)||(CURRPGM==FP4))||(CURRPGM==FP5)) ) THEN GOTO NOT_FP3_FP4_BPW;
    PRINT "NOTE: The BP Windows version number below should be converted to HEX.";
    NOT_FP3_FP4_BPW:
    PRINT "Software: BP Win v",TMPINT3,".",TMPINT4,".",TMPINT5;
    Label_55:
    LABEL_SEPARATOR = 0;
    Label_56:
    PRINT "=========================================";
ENDPROC;

PROCEDURE DISPLAY_FROM USES FROM_V;
    EXPORT "Region_0", Region_0[];
    EXPORT "Region_1", Region_1[];
    EXPORT "Region_2", Region_2[];
    EXPORT "Region_3", Region_3[];
    EXPORT "Region_4", Region_4[];
    EXPORT "Region_5", Region_5[];
    EXPORT "Region_6", Region_6[];
    EXPORT "Region_7", Region_7[];
ENDPROC;

PROCEDURE MAP_FROM_DATA0 USES GV,FROM_V;
    INTEGER DUMMY0 =0;
    Region_0[127..0] = Buff128[127..0];
ENDPROC;

PROCEDURE MAP_FROM_DATA1 USES GV,FROM_V;
    INTEGER DUMMY1 =0;
    Region_1[127..0] = Buff128[127..0];
ENDPROC;

PROCEDURE MAP_FROM_DATA2 USES GV,FROM_V;
    INTEGER DUMMY2 =0;
    Region_2[127..0] = Buff128[127..0];
ENDPROC;

PROCEDURE MAP_FROM_DATA3 USES GV,FROM_V;
    INTEGER DUMMY3 =0;
    Region_3[127..0] = Buff128[127..0];
ENDPROC;

PROCEDURE MAP_FROM_DATA4 USES GV,FROM_V;
    INTEGER DUMMY4 =0;
    Region_4[127..0] = Buff128[127..0];
ENDPROC;

PROCEDURE MAP_FROM_DATA5 USES GV,FROM_V;
    INTEGER DUMMY5 =0;
    Region_5[127..0] = Buff128[127..0];
ENDPROC;

PROCEDURE MAP_FROM_DATA6 USES GV,FROM_V;
    INTEGER DUMMY6 =0;
    Region_6[127..0] = Buff128[127..0];
ENDPROC;

PROCEDURE MAP_FROM_DATA7 USES GV,FROM_V;
    INTEGER DUMMY7 =0;
    Region_7[127..0] = Buff128[127..0];
ENDPROC;

PROCEDURE READ_FROM USES FROM_V,GV,DISPLAY_FROM,MAP_FROM_DATA0,MAP_FROM_DATA1,MAP_FROM_DATA2
    ,MAP_FROM_DATA3,MAP_FROM_DATA4,MAP_FROM_DATA5,MAP_FROM_DATA6,MAP_FROM_DATA7;
    IRSTOP IRPAUSE;
    DRSTOP DRPAUSE;
    IRSCAN 8, $c0;
    WAIT IDLE, 1 CYCLES;
    PRINT "FlashROM Information: ";
    FOR FROMROWNUMBER = NUMBEROFFROMROWS TO 1 STEP -1;
        IF ( ! (FROMADDRESSMASK[(FROMROWNUMBER-1)]==1) ) THEN GOTO Label_65;
        IRSTOP IRPAUSE;
        DRSTOP DRPAUSE;
        IRSCAN 8, $9f;
        DRSCAN 3, BOOL((FROMROWNUMBER-1));
        WAIT IDLE, 1 CYCLES;
        IRSTOP IRPAUSE;
        DRSTOP DRPAUSE;
        IRSCAN 8, $93;
        DRSCAN 128, $00000000000000000000000000000000;
        WAIT IDLE, 3 CYCLES;
        WAIT IDLE, 138 USEC;
        DRSCAN 128, $00000000000000000000000000000000, CAPTURE BUFF128[];
        IF ( ! ((FROMROWNUMBER-1)==0) ) THEN GOTO Label_57;
        CALL MAP_FROM_DATA0;
        Label_57:
        IF ( ! ((FROMROWNUMBER-1)==1) ) THEN GOTO Label_58;
        CALL MAP_FROM_DATA1;
        Label_58:
        IF ( ! ((FROMROWNUMBER-1)==2) ) THEN GOTO Label_59;
        CALL MAP_FROM_DATA2;
        Label_59:
        IF ( ! ((FROMROWNUMBER-1)==3) ) THEN GOTO Label_60;
        CALL MAP_FROM_DATA3;
        Label_60:
        IF ( ! ((FROMROWNUMBER-1)==4) ) THEN GOTO Label_61;
        CALL MAP_FROM_DATA4;
        Label_61:
        IF ( ! ((FROMROWNUMBER-1)==5) ) THEN GOTO Label_62;
        CALL MAP_FROM_DATA5;
        Label_62:
        IF ( ! ((FROMROWNUMBER-1)==6) ) THEN GOTO Label_63;
        CALL MAP_FROM_DATA6;
        Label_63:
        IF ( ! ((FROMROWNUMBER-1)==7) ) THEN GOTO Label_64;
        CALL MAP_FROM_DATA7;
        Label_64:
        LABEL_SEPARATOR = 0;
        Label_65:
        LABEL_SEPARATOR = 0;
    NEXT FROMROWNUMBER;
    CALL DISPLAY_FROM;
ENDPROC;

PROCEDURE READ_F_ROW USES GV;
    IRSTOP IRPAUSE;
    DRSTOP DRPAUSE;
    IRSCAN 8, $c0;
    WAIT IDLE, 1 CYCLES;
    IRSTOP IRPAUSE;
    DRSTOP DRPAUSE;
    IRSCAN 8, $f9;
    DRSCAN 3, FADDR[];
    WAIT IDLE, 1 CYCLES;
    IRSTOP IRPAUSE;
    DRSTOP DRPAUSE;
    IRSCAN 8, $bf;
    WAIT IDLE, 3 CYCLES;
    WAIT IDLE, 165 USEC;
    DRSCAN 128, $00000000000000000000000000000000, CAPTURE BUFF128[];
ENDPROC;

PROCEDURE DO_DEVICE_INFO USES GV,DO_READ_SECURITY,READ_UROW,DISPLAY_UROW,READ_FROM
    ,READ_F_ROW;
    IRSTOP IRPAUSE;
    DRSTOP DRPAUSE;
    IRSCAN 8, $0e;
    WAIT IDLE, 1 CYCLES;
    DRSCAN 32, $00000000, CAPTURE BUFF32[];
    EXPORT "SILSIG", BUFF32[];
    IRSCAN 8, $84, CAPTURE BUFF128[7..0];
    IF ( ! (BUFF128[2]==1) ) THEN GOTO CORE_NOT_ENABLED;
    PRINT "FPGA Array is programmed and enabled.";
    CORE_NOT_ENABLED:
    IF ( ! (BUFF128[2]==0) ) THEN GOTO CORE_ENABLED;
    PRINT "FPGA Array is not enabled.";
    CORE_ENABLED:
    CALL READ_UROW;
    CALL DISPLAY_UROW;
    CALL DO_READ_SECURITY;
    IF ( ! (ULUFJ==0) ) THEN GOTO Label_66;
    CALL READ_FROM;
    Label_66:
    IF ( ! (ULUFJ==1) ) THEN GOTO Label_67;
    PRINT "FlashROM Information: ";
    PRINT "Cannot be displayed due to pass key match failure";
    Label_67:
    FADDR[] = $0;
    CALL READ_F_ROW;
    EXPORT "FSN", BUFF128[55..8];
    PRINT "=========================================";
ENDPROC;

PROCEDURE INIT_AES;
    IRSTOP IRPAUSE;
    DRSTOP DRPAUSE;
    IRSCAN 8, $dd;
    DRSCAN 128, $00000000000000000000000000000000;
    WAIT IDLE, 3 CYCLES;
    WAIT IDLE, 165 USEC;
ENDPROC;

PROCEDURE DO_VERIFY_DEVICE_INFO USES GV,BITSTREAM,DO_EXIT,DO_READ_SECURITY,READ_UROW
    ,DISP_CHKSUM_DESIGN;
    CALL READ_UROW;
    CALL DISP_CHKSUM_DESIGN;
    CALL DO_READ_SECURITY;
    BUFF32[31..0] = BOOL(CHECKSUM);
    UROW[127..112] = BUFF32[15..0];
    UROW[101..32] = ACT_UROW_DESIGN_NAME[69..0];
    IRSTOP IRPAUSE;
    DRSTOP DRPAUSE;
    IRSCAN 8, $c0;
    WAIT IDLE, 1 CYCLES;
    IRSTOP IRPAUSE;
    DRSTOP DRPAUSE;
    IRSCAN 8, $a8;
    WAIT IDLE, 3 CYCLES;
    WAIT IDLE, 165 USEC;
    DRSCAN 128, $00000000000000000000000000000000,COMPARE UROW[],$ffff003fffffffffffffffff00000000
        ,PASS;
    IF ( ! (PASS==0) ) THEN GOTO UROW_CMP_OK;
    STATUS = -43;
    PRINT "Failed to verify design information.";
    UNIQUEEXITCODE = 32772;
    BUFF128[15..0] = BOOL(UNIQUEEXITCODE);
    EXPORT "ERROR_CODE", BUFF128[15..0];
    CALL DO_EXIT;
    UROW_CMP_OK:
    LABEL_SEPARATOR = 0;
ENDPROC;

PROCEDURE READ_IDCODE_ONLY USES GV;
    IRSTOP IRPAUSE;
    DRSTOP DRPAUSE;
    IRSCAN 8, $0f;
    WAIT IDLE, 1 CYCLES;
    DRSCAN 32, $00000000, CAPTURE ID[];
    EXPORT "IDCODE", ID[];
ENDPROC;

PROCEDURE VERIFY_RLOCK USES GV;
    IRSCAN 8, $84,COMPARE $04,$04,PASS;
ENDPROC;

PROCEDURE DO_VERIFY_PGM_RLOCK USES GV,DO_EXIT,VERIFY_RLOCK;
    CALL VERIFY_RLOCK;
    IF ( ! (PASS==0) ) THEN GOTO RLOCK_PGM_PASS;
    STATUS = 10;
    PRINT "Failed to enable FPGA Array.";
    UNIQUEEXITCODE = 32891;
    BUFF128[15..0] = BOOL(UNIQUEEXITCODE);
    EXPORT "ERROR_CODE", BUFF128[15..0];
    CALL DO_EXIT;
    RLOCK_PGM_PASS:
    LABEL_SEPARATOR = 0;
ENDPROC;

PROCEDURE DO_VERIFY_DISABLE_RLOCK USES GV,DO_EXIT,VERIFY_RLOCK;
    CALL VERIFY_RLOCK;
    IF ( ! (PASS==1) ) THEN GOTO RLOCK_PGM_FAIL;
    STATUS = 10;
    PRINT "Failed to disable FPGA Array.";
    UNIQUEEXITCODE = 32918;
    BUFF128[15..0] = BOOL(UNIQUEEXITCODE);
    EXPORT "ERROR_CODE", BUFF128[15..0];
    CALL DO_EXIT;
    RLOCK_PGM_FAIL:
    LABEL_SEPARATOR = 0;
ENDPROC;

PROCEDURE DO_VERIFY_RLOCK USES GV,DO_EXIT,VERIFY_RLOCK;
    CALL VERIFY_RLOCK;
    IF ( ! (PASS==0) ) THEN GOTO RLOCK_VERIFY_PASS;
    STATUS = 11;
    PRINT "FPGA Array is not enabled.";
    UNIQUEEXITCODE = 32892;
    BUFF128[15..0] = BOOL(UNIQUEEXITCODE);
    EXPORT "ERROR_CODE", BUFF128[15..0];
    CALL DO_EXIT;
    RLOCK_VERIFY_PASS:
    LABEL_SEPARATOR = 0;
ENDPROC;

PROCEDURE VERIFY_ID_DMK USES GV,DO_EXIT,INIT_AES;
    CALL INIT_AES;
    IRSTOP IRPAUSE;
    DRSTOP DRPAUSE;
    IRSCAN 8, $0a;
    DRSCAN 128, M7BUFF[];
    WAIT IDLE, 3 CYCLES;
    WAIT IDLE, 90 USEC;
    DRSCAN 128, $00000000000000000000000000000000, CAPTURE BUFF128[],COMPARE $c0000000000000000000000000000000
        ,$c0000000000000000000000000000000,PASS;
    IF ( ! (BUFF128[127]==0) ) THEN GOTO M7VERDONE;
    STATUS = -31;
    PRINT "Failed to verify AES Sec.";
    UNIQUEEXITCODE = 32775;
    BUFF128[15..0] = BOOL(UNIQUEEXITCODE);
    EXPORT "ERROR_CODE", BUFF128[15..0];
    CALL DO_EXIT;
    M7VERDONE:
    IF ( ! ( (BUFF128[126]==0)||(BM7DEVICE==0)) ) THEN GOTO MXIDOK;
    IF ( ! ( (BUFF128[126]==1)&&(BM7DEVICE==0)) ) THEN GOTO LDETECTM1;
    STATUS = 6;
    PRINT "Failed to verify IDCODE.";
    PRINT "Target is an M7 device.";
    UNIQUEEXITCODE = 32776;
    BUFF128[15..0] = BOOL(UNIQUEEXITCODE);
    EXPORT "ERROR_CODE", BUFF128[15..0];
    CALL DO_EXIT;
    LDETECTM1:
    IF ( ! (BUFF128[126]==0) ) THEN GOTO Label_70;
    IRSTOP IRPAUSE;
    DRSTOP DRPAUSE;
    IRSCAN 8, $0a;
    DRSCAN 128, M1BUFF[];
    WAIT IDLE, 3 CYCLES;
    WAIT IDLE, 90 USEC;
    DRSCAN 128, $00000000000000000000000000000000, CAPTURE BUFF128[],COMPARE $c0000000000000000000000000000000
        ,$c0000000000000000000000000000000,PASS;
    IF ( ! (BUFF128[127]==0) ) THEN GOTO M1VERDONE;
    STATUS = -31;
    PRINT "Failed to verify AES Sec.";
    UNIQUEEXITCODE = 32777;
    BUFF128[15..0] = BOOL(UNIQUEEXITCODE);
    EXPORT "ERROR_CODE", BUFF128[15..0];
    CALL DO_EXIT;
    M1VERDONE:
    BOOLEAN BTMPBUFFBIT126 = BUFF128[126];
    IF ( ! ( (BTMPBUFFBIT126==1)&&(BM1DEVICE==0)) ) THEN GOTO REGDEV;
    STATUS = 6;
    PRINT "Failed to verify IDCODE.";
    PRINT "Target is an M1 device.";
    UNIQUEEXITCODE = 32778;
    BUFF128[15..0] = BOOL(UNIQUEEXITCODE);
    EXPORT "ERROR_CODE", BUFF128[15..0];
    CALL DO_EXIT;
    REGDEV:
    IF ( ! ( (BTMPBUFFBIT126==0)&&(BM7DEVICE==1)) ) THEN GOTO Label_68;
    STATUS = 6;
    PRINT "Failed to verify IDCODE.";
    PRINT "The Target is not an M7 Device.";
    UNIQUEEXITCODE = 32781;
    BUFF128[15..0] = BOOL(UNIQUEEXITCODE);
    EXPORT "ERROR_CODE", BUFF128[15..0];
    CALL DO_EXIT;
    Label_68:
    IF ( ! ( (BTMPBUFFBIT126==0)&&(BM1DEVICE==1)) ) THEN GOTO Label_69;
    STATUS = 6;
    PRINT "Failed to verify IDCODE.";
    PRINT "The Target is not an M1 Device.";
    UNIQUEEXITCODE = 32782;
    BUFF128[15..0] = BOOL(UNIQUEEXITCODE);
    EXPORT "ERROR_CODE", BUFF128[15..0];
    CALL DO_EXIT;
    Label_69:
    LABEL_SEPARATOR = 0;
    Label_70:
    LABEL_SEPARATOR = 0;
    MXIDOK:
    LABEL_SEPARATOR = 0;
ENDPROC;

PROCEDURE VERIFY_IDCODE USES GV,PARAMETERS,DO_EXIT;
    FREQUENCY (FREQ*1000000);
    WAIT RESET, 5 CYCLES;
    IRSTOP IRPAUSE;
    DRSTOP DRPAUSE;
    IRSCAN 8, $0f;
    DRSCAN 32, $00000000;
    WAIT IDLE, 1 CYCLES;
    DRSCAN 32, $00000000, CAPTURE ID[],COMPARE IDCODEVALUE[],IDMASK[],PASS;
    IF ( ! (PASS==0) ) THEN GOTO IDOK;
    STATUS = 6;
    PRINT "Failed to verify IDCODE";
    UNIQUEEXITCODE = 32797;
    BUFF128[15..0] = BOOL(UNIQUEEXITCODE);
    EXPORT "ERROR_CODE", BUFF128[15..0];
    CALL DO_EXIT;
    IDOK:
    IDREV = INT(ID[31..28]);
    IDFAB = INT(ID[24..24]);
ENDPROC;

PROCEDURE IS_SECOK USES GV,DO_EXIT;
    IF ( ! (SECKEY_OK==0) ) THEN GOTO SECOK;
    STATUS = -35;
    PRINT "Failed to match pass key.";
    UNIQUEEXITCODE = 32799;
    BUFF128[15..0] = BOOL(UNIQUEEXITCODE);
    EXPORT "ERROR_CODE", BUFF128[15..0];
    CALL DO_EXIT;
    SECOK:
    LABEL_SEPARATOR = 0;
ENDPROC;

PROCEDURE DO_CHECK_FROM_W USES GV,DO_EXIT,DO_READ_SECURITY;
    CALL DO_READ_SECURITY;
    IF ( ! (ULUFP==1) ) THEN GOTO FROMWP;
    STATUS = -27;
    PRINT "FlashROM Write/Erase is protected by pass key.";
    PRINT "A valid pass key needs to be provided.";
    UNIQUEEXITCODE = 32810;
    BUFF128[15..0] = BOOL(UNIQUEEXITCODE);
    EXPORT "ERROR_CODE", BUFF128[15..0];
    CALL DO_EXIT;
    FROMWP:
    IF ( ! (ULUFJ==1) ) THEN GOTO WFROMRP;
    STATUS = -29;
    PRINT "FlashROM Read is protected by pass key.";
    PRINT "A valid pass key needs to be provided.";
    UNIQUEEXITCODE = 32811;
    BUFF128[15..0] = BOOL(UNIQUEEXITCODE);
    EXPORT "ERROR_CODE", BUFF128[15..0];
    CALL DO_EXIT;
    WFROMRP:
    IF ( ! (ULUFE==1) ) THEN GOTO WFROMEP;
    STATUS = -34;
    PRINT "FlashROM Encryption is enforced. Plain text programming is prohibited.";
    UNIQUEEXITCODE = 32812;
    BUFF128[15..0] = BOOL(UNIQUEEXITCODE);
    EXPORT "ERROR_CODE", BUFF128[15..0];
    CALL DO_EXIT;
    WFROMEP:
    LABEL_SEPARATOR = 0;
ENDPROC;

PROCEDURE DO_CHECK_FROM_R USES GV,DO_EXIT,DO_READ_SECURITY;
    CALL DO_READ_SECURITY;
    IF ( ! (ULUFE==1) ) THEN GOTO FROMEP;
    STATUS = -34;
    PRINT "FlashROM Encryption is enforced. Plain text verification is prohibited.";
    UNIQUEEXITCODE = 32815;
    BUFF128[15..0] = BOOL(UNIQUEEXITCODE);
    EXPORT "ERROR_CODE", BUFF128[15..0];
    CALL DO_EXIT;
    FROMEP:
    LABEL_SEPARATOR = 0;
ENDPROC;

PROCEDURE BP_VER USES GV;
    BOOLEAN PLAYER_VERSION_BOOLEAN[32];
    PLAYER_VERSION_BOOLEAN[31..0] = BOOL(PLAYERVERSIONVARIABLE);
    INTEGER PLAYER_MAJOR_VERSION =(INT(PLAYER_VERSION_BOOLEAN[23..16])-SCULPTORMAJORBASE);
    INTEGER PLAYER_MINOR_VERSION =(INT(PLAYER_VERSION_BOOLEAN[15..8])-SCULPTORMINORBASE);
    ACT_UROW_SW_VERSION[6..5] = BOOL(PLAYER_MAJOR_VERSION);
    ACT_UROW_SW_VERSION[4..1] = BOOL(PLAYER_MINOR_VERSION);
    ACT_UROW_SW_VERSION[0] = PLAYER_VERSION_BOOLEAN[0];
    ACT_UROW_PROGRAM_SW[3..0] = BOOL(PLAYERVERSIONSWVARIABLE);
ENDPROC;

PROCEDURE POLL_PROGRAM USES GV;
    INTEGER ILOOP_0;
    FOR ILOOP_0 = 16381 - 1 TO 0 STEP -1;
        IRSTOP IRPAUSE;
        DRSTOP DRPAUSE;
        IRSCAN 8, $84;
        WAIT IDLE, 1 CYCLES;
        WAIT IDLE, 100 USEC;
        DRSCAN 5, $00,COMPARE $00,$0b,PASS;
        IF PASS THEN ILOOP_0 = 0;
    NEXT ILOOP_0;
ENDPROC;

PROCEDURE DO_INITIALIZE USES GV,DO_EXIT,READ_F_ROW,VERIFY_ID_DMK,DO_CHECK_FROM_W
    ,DO_CHECK_FROM_R,BP_VER;
    BSR[707..0] = BSRPATTERN[707..0];
    BOOLEAN SHIFT_DATA[708];
    IRSCAN 8, $01;
    DRSCAN 708, BSR[];
    WAIT IDLE, 1 CYCLES;
    DRSCAN 708, SHIFT_DATA[], CAPTURE SAMPLE_DEVICE[];
    FOR I = 0 TO 707;
        IF ( ! (SAMPLEMASK[I]==1) ) THEN GOTO Label_71;
        BSR[I] = SAMPLE_DEVICE[I];
        Label_71:
        LABEL_SEPARATOR = 0;
    NEXT I;
    IRSTOP IRPAUSE;
    DRSTOP DRPAUSE;
    IRSCAN 8, $01;
    DRSCAN 708, BSR[];
    WAIT IDLE, 1 CYCLES;
    IRSTOP IRPAUSE;
    DRSTOP DRPAUSE;
    IRSCAN 8, $c0;
    WAIT IDLE, 1 CYCLES;
    IRSTOP IRPAUSE;
    DRSTOP DRPAUSE;
    IRSCAN 8, $80;
    DRSCAN 18, $00000;
    WAIT IDLE, 3 CYCLES;
    WAIT IDLE, 1875 USEC;
    DRSCAN 18, $00000, CAPTURE ISC_CONFIG_RESULT[],COMPARE $30000,$30000,PASS;
    IF ( ! (PASS==0) ) THEN GOTO CRCOK;
    STATUS = 5;
    PRINT "Failed to enter programming mode.";
    EXPORT "ISC_Config_Result", ISC_CONFIG_RESULT[];
    UNIQUEEXITCODE = 32850;
    BUFF128[15..0] = BOOL(UNIQUEEXITCODE);
    EXPORT "ERROR_CODE", BUFF128[15..0];
    CALL DO_EXIT;
    CRCOK:
    FADDR[] = $0;
    CALL READ_F_ROW;
    EXPORT "FSN", BUFF128[55..8];
    CALL VERIFY_ID_DMK;
    IF ( ! (CHKFROM==1) ) THEN GOTO SKIPCHKFROM;
    IF ( ! (FROMRONLY==0) ) THEN GOTO Label_72;
    CALL DO_CHECK_FROM_W;
    Label_72:
    IF ( ! (FROMRONLY==1) ) THEN GOTO Label_73;
    CALL DO_CHECK_FROM_R;
    Label_73:
    LABEL_SEPARATOR = 0;
    SKIPCHKFROM:
    IF ( ! (PLAYERVERSIONVARIABLE!=0) ) THEN GOTO Label_74;
    CALL BP_VER;
    Label_74:
    LABEL_SEPARATOR = 0;
ENDPROC;

PROCEDURE READ_INITIALIZE USES GV,DO_INITIALIZE;
    CHKFROM = 0;
    CHKARRAY = 0;
    CHKNVM = 0;
    CHKSEC = 0;
    CALL DO_INITIALIZE;
ENDPROC;

PROCEDURE NW_INITIALIZE_COMMON USES GV;
    CHKFROM = 0;
    CHKARRAY = 0;
ENDPROC;

PROCEDURE NW_INITIALIZE USES DO_INITIALIZE,NW_INITIALIZE_COMMON;
    CALL NW_INITIALIZE_COMMON;
    CALL DO_INITIALIZE;
ENDPROC;

PROCEDURE NR_INITIALIZE_COMMON USES GV;
    CHKFROM = 0;
    CHKARRAY = 0;
ENDPROC;

PROCEDURE NR_INITIALIZE USES DO_INITIALIZE,NR_INITIALIZE_COMMON;
    CALL NR_INITIALIZE_COMMON;
    CALL DO_INITIALIZE;
ENDPROC;

PROCEDURE FW_INITIALIZE USES GV,DO_INITIALIZE;
    FROMRONLY = 0;
    CHKFROM = 1;
    CHKARRAY = 0;
    CHKNVM = 0;
    CALL DO_INITIALIZE;
ENDPROC;

PROCEDURE FR_INITIALIZE USES GV,DO_INITIALIZE;
    FROMRONLY = 1;
    CHKFROM = 1;
    CHKSEC = 0;
    CHKARRAY = 0;
    CHKNVM = 0;
    CALL DO_INITIALIZE;
ENDPROC;

PROCEDURE W_INITIALIZE USES GV,DO_INITIALIZE;
    FROMRONLY = 0;
    CHKFROM = 1;
    CALL DO_INITIALIZE;
ENDPROC;

PROCEDURE R_INITIALIZE USES GV,DO_INITIALIZE;
    FROMRONLY = 1;
    CHKFROM = 1;
    CALL DO_INITIALIZE;
ENDPROC;

PROCEDURE INITIALIZE USES GV,DO_INITIALIZE;
    ARRAYRONLY = 0;
    FROMRONLY = 0;
    CHKFROM = 1;
    CHKARRAY = 1;
    CALL DO_INITIALIZE;
ENDPROC;

PROCEDURE POLL_ERASE USES GV;
    PASS = 0;
    INTEGER ILOOP_1;
    FOR ILOOP_1 = 262141 - 1 TO 0 STEP -1;
        IRSTOP IRPAUSE;
        DRSTOP DRPAUSE;
        IRSCAN 8, $84;
        WAIT IDLE, 1 CYCLES;
        WAIT IDLE, 1000 USEC;
        DRSCAN 5, $00,COMPARE $00,$03,PASS;
        IF PASS THEN ILOOP_1 = 0;
    NEXT ILOOP_1;
ENDPROC;

PROCEDURE UFROM_DISTURB USES GV;
    FOR FROMROWNUMBER = NUMBEROFFROMROWS TO 1 STEP -1;
        IRSTOP IRPAUSE;
        DRSTOP DRPAUSE;
        IRSCAN 8, $9f;
        DRSCAN 3, BOOL((FROMROWNUMBER-1));
        WAIT IDLE, 1 CYCLES;
        IRSTOP IRPAUSE;
        DRSTOP DRPAUSE;
        IRSCAN 8, $9b;
        DRSCAN 128, $ffffffffffffffffffffffffffffffff;
        WAIT IDLE, 5 CYCLES;
        WAIT IDLE, 10000 USEC;
    NEXT FROMROWNUMBER;
ENDPROC;

PROCEDURE PROGRAM_UROW USES GV,BITSTREAM,DO_EXIT,POLL_PROGRAM;
    IF ( ! (ISERASEONLY==1) ) THEN GOTO Label_75;
    UROW[] = $ffffffffffffffffffffffffffffffff;
    Label_75:
    IF ( ! ( (ISERASEONLY==0)||(ISRESTOREDESIGN==1)) ) THEN GOTO SKIP_DESIGN_INFO;
    BUFF32[31..0] = BOOL(CHECKSUM);
    IF ( ! ( !ISRESTOREDESIGN) ) THEN GOTO Label_76;
    UROW[127..112] = BUFF32[15..0];
    Label_76:
    IF ( ! ISRESTOREDESIGN ) THEN GOTO Label_77;
    UROW[127..112] = SUROWCHECKSUM[15..0];
    Label_77:
    IF ( ! ( !ISRESTOREDESIGN) ) THEN GOTO Label_78;
    UROW[101..32] = ACT_UROW_DESIGN_NAME[69..0];
    Label_78:
    IF ( ! ISRESTOREDESIGN ) THEN GOTO Label_79;
    UROW[101..32] = SUROWDESIGNNAME[69..0];
    Label_79:
    LABEL_SEPARATOR = 0;
    SKIP_DESIGN_INFO:
    BUFF32[31..0] = BOOL(ACT_UROW_CYCLE_COUNT);
    UROW[111..102] = BUFF32[9..0];
    UROW[31..29] = ACT_UROW_PROG_METHOD[2..0];
    UROW[28..25] = ACT_UROW_ALGO_VERSION[3..0];
    UROW[16..10] = ACT_UROW_SW_VERSION[6..0];
    UROW[9..6] = ACT_UROW_PROGRAM_SW[3..0];
    UROW[4] = SUROW_SRAM_DISTURB[0];
    IF ( ! (ACT_UROW_ALGO_VERSION[6]==1) ) THEN GOTO Label_80;
    UROW[5] = 1;
    UROW[0] = 0;
    UROW[24..23] = ACT_UROW_ALGO_VERSION[5..4];
    Label_80:
    IF ( ! (ACT_UROW_ALGO_VERSION[6]==0) ) THEN GOTO Label_81;
    UROW[5] = 0;
    UROW[0] = 1;
    UROW[24..23] = ACT_UROW_ALGO_VERSION[5..4];
    Label_81:
    IRSTOP IRPAUSE;
    DRSTOP DRPAUSE;
    IRSCAN 8, $a7;
    DRSCAN 128, UROW[];
    WAIT IDLE, 15 CYCLES;
    CALL POLL_PROGRAM;
    IF ( ! (PASS==0) ) THEN GOTO PROGRAM_OK3;
    STATUS = -24;
    PRINT "Failed to program UROW";
    UNIQUEEXITCODE = 32853;
    BUFF128[15..0] = BOOL(UNIQUEEXITCODE);
    EXPORT "ERROR_CODE", BUFF128[15..0];
    CALL DO_EXIT;
    PROGRAM_OK3:
    IRSTOP IRPAUSE;
    DRSTOP DRPAUSE;
    IRSCAN 8, $c0;
    WAIT IDLE, 1 CYCLES;
    IRSTOP IRPAUSE;
    DRSTOP DRPAUSE;
    IRSCAN 8, $a8;
    WAIT IDLE, 3 CYCLES;
    WAIT IDLE, 165 USEC;
    DRSCAN 128, $00000000000000000000000000000000,COMPARE UROW[],UROW_MASK[],PASS;
    IF ( ! (PASS==0) ) THEN GOTO UROW_OK;
    STATUS = -24;
    PRINT "Failed to program UROW";
    UNIQUEEXITCODE = 32854;
    BUFF128[15..0] = BOOL(UNIQUEEXITCODE);
    EXPORT "ERROR_CODE", BUFF128[15..0];
    CALL DO_EXIT;
    UROW_OK:
    LABEL_SEPARATOR = 0;
ENDPROC;

PROCEDURE FAIL_ERASE USES GV,DO_EXIT;
    STATUS = 8;
    PRINT "Failed Erase Operation";
    UNIQUEEXITCODE = 32855;
    BUFF128[15..0] = BOOL(UNIQUEEXITCODE);
    EXPORT "ERROR_CODE", BUFF128[15..0];
    CALL DO_EXIT;
ENDPROC;

PROCEDURE EXE_ERASE USES BITSTREAM,GV,READ_UROW,POLL_ERASE,UFROM_DISTURB,PROGRAM_UROW
    ,FAIL_ERASE;
    IF ( ! (COMBERASESELECT[14]==1) ) THEN GOTO SKIPRUROW;
    CALL READ_UROW;
    EXPORT "ACTEL_SLOG_UROW", UROW[];
    SKIPRUROW:
    IRSTOP IRPAUSE;
    DRSTOP DRPAUSE;
    IRSCAN 8, $85;
    DRSCAN 23, COMBERASESELECT[];
    WAIT IDLE, 3 CYCLES;
    CALL POLL_ERASE;
    IF ( ! (PASS==0) ) THEN GOTO ERASEOK;
    CALL FAIL_ERASE;
    ERASEOK:
    IF ( ! (COMBERASESELECT[14]==1) ) THEN GOTO Label_82;
    IF ( ! (ISERASEONLY==1) ) THEN GOTO NOT_ERASE_ONLY;
    CALL UFROM_DISTURB;
    NOT_ERASE_ONLY:
    CALL PROGRAM_UROW;
    Label_82:
    LABEL_SEPARATOR = 0;
ENDPROC;

PROCEDURE DO_ERASE USES BITSTREAM,FROM_V,GV,EXE_ERASE;
    PRINT "Erase ...";
    COMBERASESELECT[22..0] = $004000;
    COMBERASESELECT[22..15] = FROMADDRESSMASK[7..0];
    CALL EXE_ERASE;
    PRINT "Completed erase";
    IF ( ! (ISPRGARRAY==1) ) THEN GOTO NOT_PGM_ARRAY_ERASE;
    BUFF32[31..0] = BOOL(CHECKSUM);
    EXPORT "CHECKSUM", BUFF32[15..0];
    NOT_PGM_ARRAY_ERASE:
    LABEL_SEPARATOR = 0;
ENDPROC;

PROCEDURE DO_ERASE_ONLY USES GV,DO_ERASE;
    ISERASEONLY = 1;
    CALL DO_ERASE;
ENDPROC;

PROCEDURE DO_ERASE_FROM USES FROM_V,GV,EXE_ERASE;
    PRINT "Erase FlashROM ...";
    COMBERASESELECT[22..0] = $004000;
    COMBERASESELECT[22..15] = FROMADDRESSMASK[7..0];
    ISERASEONLY = 1;
    ISRESTOREDESIGN = 1;
    CALL EXE_ERASE;
ENDPROC;

PROCEDURE DO_ERASE_ALL USES GV,UFROM_DISTURB,EXE_ERASE;
    IF ( ! ( (BM7DEVICE==1)||(BM1DEVICE==1)) ) THEN GOTO Label_83;
    PRINT "Erase FPGA Array and FlashROM ...";
    Label_83:
    IF ( ! ( (BM7DEVICE!=1)&&(BM1DEVICE!=1)) ) THEN GOTO Label_84;
    PRINT "Erase FPGA Array, FlashROM and Security Settings ...";
    Label_84:
    COMBERASESELECT[22..0] = $7fc00f;
    ISERASEONLY = 1;
    CALL EXE_ERASE;
    CALL UFROM_DISTURB;
ENDPROC;

PROCEDURE DO_VERIFY_FROM USES FROM_V,GV,DO_EXIT;
    IRSTOP IRPAUSE;
    DRSTOP DRPAUSE;
    IRSCAN 8, $c0;
    WAIT IDLE, 1 CYCLES;
    DATAINDEX = 0;
    PRINT "Verify FlashROM ...";
    FOR FROMROWNUMBER = NUMBEROFFROMROWS TO 1 STEP -1;
        IF ( ! (FROMADDRESSMASK[(FROMROWNUMBER-1)]==1) ) THEN GOTO SKIPFROMVRYROW;
        IRSTOP IRPAUSE;
        DRSTOP DRPAUSE;
        IRSCAN 8, $9f;
        DRSCAN 3, BOOL((FROMROWNUMBER-1));
        WAIT IDLE, 1 CYCLES;
        IRSTOP IRPAUSE;
        DRSTOP DRPAUSE;
        IRSCAN 8, $9c;
        DRSCAN 128, FROMSTREAM[(DATAINDEX+127)..DATAINDEX];
        WAIT IDLE, 3 CYCLES;
        WAIT IDLE, 138 USEC;
        DRSCAN 128, $00000000000000000000000000000000,COMPARE $00000000000000000000000000000003
            ,$00000000000000000000000000000003,PASS;
        IF ( ! (PASS==0) ) THEN GOTO FROMVERIFYOK;
        STATUS = 11;
        PRINT "Failed to verify FlashROM at row ",(FROMROWNUMBER-1);
        UNIQUEEXITCODE = 32864;
        BUFF128[15..0] = BOOL(UNIQUEEXITCODE);
        EXPORT "ERROR_CODE", BUFF128[15..0];
        CALL DO_EXIT;
        FROMVERIFYOK:
        DATAINDEX = (DATAINDEX+128);
        SKIPFROMVRYROW:
        LABEL_SEPARATOR = 0;
    NEXT FROMROWNUMBER;
    PRINT "        Verify FlashROM -- pass";
ENDPROC;

PROCEDURE DO_PROGRAM_FROM USES FROM_V,GV,DO_EXIT,POLL_PROGRAM;
    PRINT "Program FlashROM ...";
    DATAINDEX = 0;
    FOR FROMROWNUMBER = NUMBEROFFROMROWS TO 1 STEP -1;
        IF ( ! (FROMADDRESSMASK[(FROMROWNUMBER-1)]==1) ) THEN GOTO SKIPFROMPRGROW;
        IRSTOP IRPAUSE;
        DRSTOP DRPAUSE;
        IRSCAN 8, $9f;
        DRSCAN 3, BOOL((FROMROWNUMBER-1));
        WAIT IDLE, 1 CYCLES;
        IRSTOP IRPAUSE;
        DRSTOP DRPAUSE;
        IRSCAN 8, $9b;
        DRSCAN 128, FROMSTREAM[(DATAINDEX+127)..DATAINDEX];
        WAIT IDLE, 5 CYCLES;
        CALL POLL_PROGRAM;
        IF ( ! (PASS==0) ) THEN GOTO FROMPROGRAM_OK1;
        STATUS = 10;
        PRINT "Failed to program FlashROM";
        UNIQUEEXITCODE = 32866;
        BUFF128[15..0] = BOOL(UNIQUEEXITCODE);
        EXPORT "ERROR_CODE", BUFF128[15..0];
        CALL DO_EXIT;
        FROMPROGRAM_OK1:
        DATAINDEX = (DATAINDEX+128);
        SKIPFROMPRGROW:
        LABEL_SEPARATOR = 0;
    NEXT FROMROWNUMBER;
ENDPROC;

PROCEDURE DO_READ_IDCODE USES READ_IDCODE_ONLY;
    WAIT RESET, 5 CYCLES;
    CALL READ_IDCODE_ONLY;
    EXIT 0;
ENDPROC;


CRC 865C;