Commit 73b264e5 by chengshuyao

BSD: updated 20241211

parents
#include<stdlib.h>
#include<stdio.h>
#include<stdbool.h>
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<math.h>
#include<sys/time.h>
#include<functional>
#include<string>
#include<fstream>
#include<sstream>
#include<vector>
#include<dirent.h>
#include<stdint.h>
#include<omp.h>
#include<unistd.h>
#include<random>
using namespace std;
//电路的parameter Circuit_parameter
int circuit_index = 9999; //电路编号
extern const int parameter_input_bit_width = 64; //输入bit有几位
extern const int parameter_output_bit_width = 32; //输出bit有几位
int parameter_test_ios = 10000; //测试要求多少样本
//算法的parameter Algorithm_parameter
extern const int parameter_num_threads = 100; //线程数
extern const int parameter_multi_output_index = 0; //BSD从第几层开始化简,前面若干层展开序确定
extern const int parameter_early_stop_depth = 100; //BSD到第几层终止,输出此时的不准确BSD
extern const int parameter_max_samples = 40000; //BSD每一个节点最多进行多少次采样
extern const int parameter_max_BDD_width = 10000; //BSD每一层最多多少个节点
//全局变量
int GLOBAL_BDD_id_number;
int GLOBAL_BDD_nodes;
int GLOBAL_BDD_split_nodes;
int GLOBAL_train_time;
int GLOBAL_program_time;
#include"cvt.h"
#include"io_generator_function.h"
#include"BSD.h"
#include"next_layer_bit.h"
#include"tool_function.h"
#include"print_circuit.h"
int main(int argc,char* argv[]){
omp_set_num_threads(parameter_num_threads);
GLOBAL_BDD_id_number = 0;
GLOBAL_BDD_nodes = 0;
GLOBAL_BDD_split_nodes = 0;
int i,j;
int which_demo_function;
if(argc >= 2){
circuit_index = atoi(argv[1]);
}
if(argc>=3){
which_demo_function = atoi(argv[2]);
}else{
which_demo_function = 20;
}
DIR* output_dir;
output_dir = opendir("rtl/");
dirent *ptr;
vector<string> files;
while((ptr=readdir(output_dir))!=NULL){
files.push_back(ptr->d_name);
}
bool this_bit_finished = 0;
for (i=0;i<files.size();i++){
if(files[i].substr(0,8) == "function"){
int this_output_bit = 0;
for(j=0;j<10;j++){
//cout<<files[i].substr(18+j,1);
if(files[i].substr(18+j+1,1) == "."){
break;
}
}
//cout<<atoi(files[i].substr(9,9+j).c_str());
if(atoi(files[i].substr(9,9+j).c_str()) == circuit_index){
this_bit_finished = 1;
cout<<"this bit finished: "<<circuit_index<<endl;
return 0;
break;
}
}
}
closedir(output_dir);
BDD_class BDD_class_main;
BDD_class_main.start_depth = 0;
BDD_class_main.BDD_id = 0;
GLOBAL_BDD_id_number += 1;
BDD_class_main.which_demo_function = which_demo_function;
BDD_class_main.which_demo_function = 2;
BDD_class_main.how_many_start_nodes = parameter_output_bit_width;
BDD_class_main.start_nodes = new BDD_node [BDD_class_main.how_many_start_nodes];
for(int zi=0;zi<BDD_class_main.how_many_start_nodes;zi++){
BDD_class_main.start_nodes[zi].which_bit_output = zi;
BDD_class_main.start_nodes[zi].which_root_node = zi;
BDD_class_main.start_nodes[zi].which_root_node_all[BDD_class_main.start_nodes[zi].which_root_node] = 1;
}
for(int zi=0;zi<parameter_input_bit_width+1;zi++){
BDD_class_main.has_been_unfold[zi] = 0;
BDD_class_main.most_influence[zi] = 0;
BDD_class_main.BDD_width_each_layer[zi] = 0;
}
BDD_class_main.BDD_FULL_PROCESS();
};
This diff is collapsed. Click to expand it.
aag 727 10 0 11 717
2
4
6
8
10
12
14
16
18
20
269
499
703
844
860
870
1048
1228
1360
1438
1454
22 20 3
24 22 4
26 21 5
28 27 25
30 13 9
32 30 29
34 21 2
36 35 5
38 21 4
40 39 17
42 40 37
44 43 33
46 45 7
48 13 7
50 49 3
52 6 4
54 53 51
56 55 21
58 9 4
60 9 7
62 61 20
64 8 2
66 65 63
68 67 5
70 69 59
72 70 57
74 73 17
76 75 47
78 77 19
80 7 2
82 18 16
84 82 13
86 20 17
88 87 85
90 89 4
92 21 13
94 17 4
96 95 92
98 97 91
100 99 80
102 5 3
104 21 6
106 104 102
108 106 84
110 109 101
112 111 9
114 113 79
116 115 15
118 20 5
120 7 3
122 120 118
124 123 13
126 125 14
128 20 2
130 21 3
132 131 129
134 133 4
136 134 6
138 136 12
140 139 127
142 141 18
144 23 5
146 145 19
148 6 5
150 148 34
152 151 147
154 153 13
156 155 143
158 157 8
160 35 7
162 161 14
164 134 60
166 165 163
168 167 12
170 9 3
172 20 6
174 38 7
176 175 173
178 177 170
180 178 14
182 181 169
184 183 18
186 185 159
188 19 4
190 9 6
192 190 118
194 193 189
196 195 3
198 20 6
200 21 5
202 14 7
204 203 8
206 205 200
208 207 199
210 209 19
212 211 197
214 213 13
216 215 186
218 60 3
220 200 19
222 220 218
224 223 216
226 225 17
228 227 117
230 229 11
232 9 5
234 232 7
236 18 10
238 237 14
240 21 19
242 241 15
244 243 239
246 244 12
248 20 10
250 21 14
252 251 249
254 14 12
256 255 253
258 256 19
260 259 247
262 261 3
264 262 17
266 264 234
268 267 231
270 18 2
272 270 198
274 19 7
276 274 130
278 277 273
280 279 12
282 20 14
284 18 13
286 285 283
288 287 3
290 282 18
292 92 19
294 293 291
296 294 289
298 297 6
300 299 281
302 301 11
304 20 15
306 20 10
308 18 10
310 19 12
312 311 309
314 313 15
316 315 307
318 317 305
320 318 120
322 321 303
324 323 5
326 18 14
328 327 287
330 328 2
332 12 3
334 20 19
336 334 332
338 337 331
340 339 7
342 19 15
344 14 3
346 345 7
348 347 284
350 349 343
352 351 21
354 353 341
356 355 4
358 18 15
360 358 104
362 361 357
364 363 11
366 365 325
368 367 9
370 12 4
372 19 8
374 7 5
376 374 372
378 377 371
380 379 2
382 61 12
384 52 8
386 385 383
388 386 381
390 389 14
392 19 12
394 392 384
396 395 391
398 396 20
400 18 12
402 19 8
404 403 401
406 405 2
408 274 12
410 409 407
412 411 5
414 18 8
416 415 7
418 417 3
420 18 7
422 420 2
424 13 2
426 425 333
428 426 423
430 429 4
432 431 419
434 432 413
436 435 15
438 14 5
440 439 6
442 19 5
444 443 441
446 444 8
448 15 5
450 449 7
452 18 3
454 453 450
456 4 2
458 457 454
460 459 447
462 461 13
464 463 437
466 464 21
468 467 399
470 468 11
472 471 369
474 473 17
476 103 6
478 457 160
480 479 477
482 480 19
484 420 38
486 485 483
488 487 16
490 489 107
492 491 30
494 492 15
496 494 11
498 497 475
500 417 5
502 359 6
504 503 501
506 505 12
508 18 4
510 509 14
512 511 21
514 513 7
516 334 5
518 517 515
520 519 8
522 521 507
524 19 14
526 20 9
528 526 4
530 528 524
532 531 522
534 9 4
536 535 335
538 537 527
540 538 15
542 421 8
544 543 12
546 13 6
548 547 8
550 549 18
552 551 545
554 553 4
556 14 13
558 556 19
560 558 232
562 561 555
564 563 21
566 565 541
568 566 532
570 569 11
572 20 18
574 19 14
576 575 573
578 577 13
580 579 7
582 580 5
584 10 9
586 584 582
588 587 571
590 589 3
592 129 18
594 20 19
596 595 593
598 597 12
600 199 13
602 601 599
604 602 4
606 21 18
608 607 335
610 608 201
612 611 6
614 613 605
616 615 9
618 8 5
620 619 12
622 240 7
624 622 621
626 18 5
628 626 62
630 629 625
632 631 2
634 633 617
636 635 15
638 20 4
640 638 6
642 641 627
644 643 14
646 240 6
648 105 18
650 649 647
652 650 645
654 653 8
656 119 14
658 657 39
660 659 18
662 19 9
664 639 201
666 665 662
668 667 661
670 669 7
672 671 655
674 673 424
676 675 637
678 677 11
680 679 591
682 681 17
684 15 13
686 128 82
688 687 131
690 689 4
692 442 34
694 693 691
696 695 684
698 696 60
700 698 11
702 701 683
704 305 8
706 14 6
708 707 705
710 709 11
712 20 18
714 712 684
716 715 255
718 584 7
720 718 717
722 721 711
724 723 5
726 92 19
728 18 12
730 728 304
732 731 727
734 733 6
736 359 12
738 737 8
740 739 559
742 740 735
744 743 4
746 556 6
748 747 745
750 749 11
752 751 725
754 753 3
756 405 6
758 729 7
760 759 757
762 760 21
764 20 12
766 764 19
768 767 9
770 769 7
772 373 15
774 13 8
776 775 773
778 777 771
780 778 763
782 781 4
784 556 9
786 448 408
788 787 785
790 789 21
792 791 783
794 793 2
796 556 61
798 15 8
800 798 6
802 801 797
804 803 20
806 556 21
808 807 799
810 809 19
812 811 805
814 813 5
816 815 795
818 343 93
820 819 7
822 765 15
824 729 639
826 825 822
828 827 821
830 829 8
832 831 816
834 606 4
836 834 556
838 837 832
840 839 11
842 841 755
844 843 17
846 476 11
848 374 3
850 11 8
852 851 585
854 853 848
856 855 847
858 857 17
860 858 254
862 718 102
864 850 849
866 865 863
868 867 17
870 868 254
872 13 5
874 873 6
876 875 21
878 876 15
880 638 12
882 881 879
884 883 2
886 93 3
888 886 6
890 889 885
892 891 18
894 22 6
896 895 221
898 897 12
900 899 893
902 21 7
904 20 6
906 905 903
908 713 241
910 909 14
912 910 907
914 913 900
916 915 17
918 38 7
920 21 16
922 921 18
924 923 148
926 925 919
928 927 3
930 638 270
932 931 241
934 933 16
936 934 7
938 937 929
940 939 684
942 941 917
944 943 9
946 639 221
948 947 2
950 38 6
952 951 949
954 15 3
956 664 443
958 956 954
960 959 952
962 961 13
964 456 19
966 326 2
968 967 189
970 969 7
972 971 965
974 973 20
976 12 2
978 18 3
980 979 977
982 981 38
984 983 975
986 984 963
988 987 8
990 12 7
992 990 133
994 547 15
996 995 22
998 997 993
1000 999 19
1002 128 18
1004 241 6
1006 1005 1003
1008 1007 14
1010 1009 1001
1012 1011 4
1014 955 19
1016 1015 425
1018 1017 21
1020 1018 7
1022 18 6
1024 1022 22
1026 1025 1021
1028 1027 5
1030 1029 1013
1032 1030 989
1034 1033 17
1036 1035 945
1038 1037 11
1040 10 5
1042 1040 218
1044 1043 255
1046 1045 17
1048 1047 1039
1050 18 9
1052 1051 283
1054 1053 2
1056 798 452
1058 1057 525
1060 1059 20
1062 326 21
1064 1063 1061
1066 1064 1055
1068 1067 7
1070 712 9
1072 713 8
1074 1073 271
1076 1075 15
1078 1077 1071
1080 1079 6
1082 240 15
1084 1082 9
1086 1085 1081
1088 1086 1069
1090 1089 4
1092 20 18
1094 21 2
1096 1095 1093
1098 1096 15
1100 1098 7
1102 910 3
1104 1103 1101
1106 1105 8
1108 274 3
1110 1109 967
1112 1111 21
1114 663 15
1116 1115 1004
1118 1117 1113
1120 1118 1107
1122 1121 5
1124 8 7
1126 524 21
1128 1126 1124
1130 1129 1123
1132 1130 1091
1134 1133 13
1136 907 2
1138 21 12
1140 1139 3
1142 1141 1137
1144 1142 18
1146 392 198
1148 1147 1145
1150 1149 9
1152 12 8
1154 1153 105
1156 1155 3
1158 990 8
1160 1159 1157
1162 1161 19
1164 1138 1124
1166 1165 1163
1168 1166 1151
1170 1169 4
1172 8 6
1174 65 7
1176 1175 909
1178 1177 1173
1180 1179 12
1182 646 64
1184 1183 1181
1186 1185 5
1188 764 18
1190 1188 1172
1192 1191 1187
1194 1192 1171
1196 1195 15
1198 1197 1135
1200 1199 17
1202 609 6
1204 1202 3
1206 82 21
1208 1206 80
1210 1209 1205
1212 1211 448
1214 1212 30
1216 1215 1201
1218 1217 11
1220 170 48
1222 1220 448
1224 17 10
1226 1224 1222
1228 1227 1219
1230 1138 374
1232 1231 529
1234 1233 3
1236 12 4
1238 13 8
1240 1239 1237
1242 1240 7
1244 1242 201
1246 1244 527
1248 873 664
1250 1249 190
1252 1251 1247
1254 1252 1235
1256 1255 19
1258 1153 547
1260 1259 543
1262 1260 4
1264 618 333
1266 1264 420
1268 1267 1263
1270 1269 20
1272 1240 171
1274 1272 7
1276 424 232
1278 1277 1275
1280 1279 18
1282 12 9
1284 452 13
1286 1285 1283
1288 1287 52
1290 1289 1281
1292 1291 21
1294 1293 1271
1296 1294 1257
1298 1297 15
1300 241 5
1302 1301 6
1304 1303 657
1306 1305 2
1308 189 15
1310 1309 6
1312 39 18
1314 1313 656
1316 1315 1311
1318 1316 1307
1320 1319 774
1322 1321 1299
1324 1323 17
1326 420 2
1328 1023 275
1330 1329 3
1332 1331 1327
1334 1333 21
1336 19 3
1338 1336 198
1340 1339 1335
1342 1341 5
1344 1108 638
1346 1345 1343
1348 1347 30
1350 1348 15
1352 1351 1325
1354 1353 11
1356 1224 30
1358 1356 848
1360 1359 1355
1362 191 13
1364 1363 14
1366 235 10
1368 800 424
1370 1369 17
1372 1371 1301
1374 1373 1367
1376 1374 1365
1378 235 17
1380 1379 2
1382 191 16
1384 1383 1381
1386 1384 1376
1388 283 8
1390 1389 452
1392 93 9
1394 1393 1391
1396 1395 7
1398 800 713
1400 1398 13
1402 1189 15
1404 1403 9
1406 1405 1401
1408 1406 1397
1410 1409 4
1412 765 19
1414 1413 1392
1416 1414 6
1418 823 452
1420 1419 283
1422 1421 8
1424 685 10
1426 1425 9
1428 1427 1423
1430 1429 7
1432 1431 1417
1434 1433 5
1436 1435 1411
1438 1436 1386
1440 23 4
1442 37 19
1444 1443 1441
1446 1445 850
1448 1446 6
1450 1449 863
1452 1451 17
1454 1452 684
c
Generated by Yosys 0.22+57 (git sha1 518194fac, gcc 9.3.0 -fPIC -Os)
aag 171 7 0 26 164
2
4
6
8
10
12
14
47
67
82
105
141
155
179
193
207
219
234
240
259
262
264
270
276
280
284
286
308
322
331
1
338
342
16 8 5
18 16 10
20 10 8
22 11 9
24 23 21
26 25 4
28 27 19
30 29 6
32 8 4
34 32 10
36 10 8
38 5 2
40 38 36
42 41 35
44 43 7
46 45 31
48 11 9
50 48 4
52 50 6
54 10 9
56 54 4
58 20 3
60 58 5
62 61 57
64 63 7
66 65 53
68 11 8
70 69 2
72 25 3
74 73 71
76 75 4
78 59 5
80 79 77
82 80 7
84 54 6
86 54 4
88 10 9
90 9 3
92 90 89
94 25 2
96 95 93
98 96 5
100 99 87
102 101 7
104 103 85
106 54 2
108 106 6
110 8 3
112 12 10
114 112 110
116 15 8
118 116 21
120 13 8
122 120 21
124 12 8
126 125 123
128 127 14
130 129 119
132 131 2
134 133 115
136 135 4
138 136 7
140 139 109
142 54 4
144 142 6
146 14 8
148 147 119
150 149 4
152 150 7
154 153 145
156 37 3
158 156 23
160 49 2
162 161 159
164 163 4
166 37 5
168 166 23
170 169 165
172 171 7
174 8 6
176 174 10
178 177 173
180 59 5
182 7 5
184 182 181
186 97 4
188 187 41
190 189 6
192 191 185
194 54 3
196 195 4
198 7 4
200 198 197
202 6 4
204 202 25
206 205 201
208 50 6
210 194 4
212 36 5
214 213 211
216 215 7
218 217 209
220 55 6
222 49 2
224 8 3
226 225 223
228 227 4
230 169 7
232 230 229
234 233 221
236 48 3
238 236 5
240 238 7
242 69 4
244 10 5
246 245 243
248 247 6
250 49 4
252 227 5
254 253 251
256 255 7
258 257 249
260 48 2
262 260 6
264 236 6
266 68 3
268 266 5
270 268 6
272 68 2
274 272 5
276 274 6
278 272 4
280 278 6
282 266 4
284 282 6
286 48 6
288 4 2
290 288 127
292 69 2
294 293 38
296 295 7
298 296 291
300 58 4
302 36 5
304 303 301
306 304 6
308 307 299
310 36 12
312 310 15
314 312 2
316 315 4
318 273 5
320 319 317
322 320 7
324 305 6
326 288 131
328 326 7
330 329 325
332 106 4
334 194 5
336 335 333
338 337 7
340 106 5
342 340 7
c
Generated by Yosys 0.22+57 (git sha1 518194fac, gcc 9.3.0 -fPIC -Os)
aag 312 8 0 256 304
2
4
6
8
10
12
14
16
30
36
42
46
52
58
62
66
72
76
82
86
90
94
98
102
108
110
112
114
116
118
120
122
124
126
128
130
132
134
136
138
144
146
148
150
152
154
156
158
160
162
164
166
168
170
172
174
180
182
184
186
188
190
192
194
196
198
200
202
204
206
208
210
216
218
220
222
224
226
228
230
232
234
236
238
240
242
244
246
250
252
254
256
258
260
262
264
266
268
270
272
274
276
278
280
284
286
288
290
292
294
296
298
300
302
304
306
308
310
312
314
318
320
322
324
326
328
330
332
334
336
338
340
342
344
346
348
354
356
358
360
362
364
366
368
370
372
374
376
378
380
382
384
388
390
392
394
396
398
400
402
404
406
408
410
412
414
416
418
422
424
426
428
430
432
434
436
438
440
442
444
446
448
450
452
456
458
460
462
464
466
468
470
472
474
476
478
480
482
484
486
492
494
496
498
500
502
504
506
508
510
512
514
516
518
520
522
526
528
530
532
534
536
538
540
542
544
546
548
550
552
554
556
560
562
564
566
568
570
572
574
576
578
580
582
584
586
588
590
594
596
598
600
602
604
606
608
610
612
614
616
618
620
622
624
18 7 3
20 9 5
22 20 18
24 13 11
26 16 15
28 26 24
30 28 22
32 7 2
34 32 20
36 34 28
38 9 4
40 38 18
42 40 28
44 38 32
46 44 28
48 6 3
50 48 20
52 50 28
54 6 2
56 54 20
58 56 28
60 48 38
62 60 28
64 54 38
66 64 28
68 8 5
70 68 18
72 70 28
74 68 32
76 74 28
78 8 4
80 78 18
82 80 28
84 78 32
86 84 28
88 68 48
90 88 28
92 68 54
94 92 28
96 78 48
98 96 28
100 78 54
102 100 28
104 13 10
106 104 26
108 106 22
110 106 34
112 106 40
114 106 44
116 106 50
118 106 56
120 106 60
122 106 64
124 106 70
126 106 74
128 106 80
130 106 84
132 106 88
134 106 92
136 106 96
138 106 100
140 12 11
142 140 26
144 142 22
146 142 34
148 142 40
150 142 44
152 142 50
154 142 56
156 142 60
158 142 64
160 142 70
162 142 74
164 142 80
166 142 84
168 142 88
170 142 92
172 142 96
174 142 100
176 12 10
178 176 26
180 178 22
182 178 34
184 178 40
186 178 44
188 178 50
190 178 56
192 178 60
194 178 64
196 178 70
198 178 74
200 178 80
202 178 84
204 178 88
206 178 92
208 178 96
210 178 100
212 16 14
214 212 24
216 214 22
218 214 34
220 214 40
222 214 44
224 214 50
226 214 56
228 214 60
230 214 64
232 214 70
234 214 74
236 214 80
238 214 84
240 214 88
242 214 92
244 214 96
246 214 100
248 212 104
250 248 22
252 248 34
254 248 40
256 248 44
258 248 50
260 248 56
262 248 60
264 248 64
266 248 70
268 248 74
270 248 80
272 248 84
274 248 88
276 248 92
278 248 96
280 248 100
282 212 140
284 282 22
286 282 34
288 282 40
290 282 44
292 282 50
294 282 56
296 282 60
298 282 64
300 282 70
302 282 74
304 282 80
306 282 84
308 282 88
310 282 92
312 282 96
314 282 100
316 212 176
318 316 22
320 316 34
322 316 40
324 316 44
326 316 50
328 316 56
330 316 60
332 316 64
334 316 70
336 316 74
338 316 80
340 316 84
342 316 88
344 316 92
346 316 96
348 316 100
350 17 15
352 350 24
354 352 22
356 352 34
358 352 40
360 352 44
362 352 50
364 352 56
366 352 60
368 352 64
370 352 70
372 352 74
374 352 80
376 352 84
378 352 88
380 352 92
382 352 96
384 352 100
386 350 104
388 386 22
390 386 34
392 386 40
394 386 44
396 386 50
398 386 56
400 386 60
402 386 64
404 386 70
406 386 74
408 386 80
410 386 84
412 386 88
414 386 92
416 386 96
418 386 100
420 350 140
422 420 22
424 420 34
426 420 40
428 420 44
430 420 50
432 420 56
434 420 60
436 420 64
438 420 70
440 420 74
442 420 80
444 420 84
446 420 88
448 420 92
450 420 96
452 420 100
454 350 176
456 454 22
458 454 34
460 454 40
462 454 44
464 454 50
466 454 56
468 454 60
470 454 64
472 454 70
474 454 74
476 454 80
478 454 84
480 454 88
482 454 92
484 454 96
486 454 100
488 17 14
490 488 24
492 490 22
494 490 34
496 490 40
498 490 44
500 490 50
502 490 56
504 490 60
506 490 64
508 490 70
510 490 74
512 490 80
514 490 84
516 490 88
518 490 92
520 490 96
522 490 100
524 488 104
526 524 22
528 524 34
530 524 40
532 524 44
534 524 50
536 524 56
538 524 60
540 524 64
542 524 70
544 524 74
546 524 80
548 524 84
550 524 88
552 524 92
554 524 96
556 524 100
558 488 140
560 558 22
562 558 34
564 558 40
566 558 44
568 558 50
570 558 56
572 558 60
574 558 64
576 558 70
578 558 74
580 558 80
582 558 84
584 558 88
586 558 92
588 558 96
590 558 100
592 488 176
594 592 22
596 592 34
598 592 40
600 592 44
602 592 50
604 592 56
606 592 60
608 592 64
610 592 70
612 592 74
614 592 80
616 592 84
618 592 88
620 592 92
622 592 96
624 592 100
c
Generated by Yosys 0.22+57 (git sha1 518194fac, gcc 9.3.0 -fPIC -Os)
This source diff could not be displayed because it is too large. You can view the blob instead.
This diff is collapsed. Click to expand it.
aag 268 11 0 7 257
2
4
6
8
10
12
14
16
18
20
22
143
276
403
423
485
527
537
24 10 4
26 18 11
28 27 25
30 29 2
32 10 4
34 33 3
36 35 31
38 36 15
40 38 17
42 18 10
44 43 41
46 45 13
48 16 11
50 17 12
52 7 4
54 52 50
56 55 49
58 56 8
60 16 10
62 61 9
64 63 59
66 64 19
68 18 12
70 68 11
72 71 67
74 72 47
76 75 21
78 19 10
80 78 9
82 17 11
84 83 81
86 85 7
88 86 4
90 6 5
92 19 17
94 92 90
96 95 21
98 96 89
100 99 15
102 100 12
104 20 14
106 104 13
108 107 103
110 108 77
112 111 23
114 9 7
116 8 6
118 117 115
120 118 21
122 120 19
124 123 23
126 125 17
128 22 20
130 128 18
132 131 127
134 133 14
136 22 15
138 136 16
140 139 135
142 140 113
144 21 11
146 17 7
148 147 145
150 149 5
152 6 4
154 153 2
156 6 3
158 157 155
160 158 17
162 160 10
164 21 18
166 165 163
168 166 151
170 169 15
172 21 19
174 172 16
176 10 8
178 177 174
180 20 17
182 181 179
184 182 171
186 185 13
188 173 10
190 17 15
192 191 11
194 193 189
196 194 6
198 196 4
200 21 16
202 200 78
204 203 199
206 205 8
208 164 10
210 20 16
212 211 209
214 213 14
216 215 207
218 217 12
220 164 11
222 221 181
224 223 15
226 225 219
228 226 187
230 229 23
232 21 14
234 232 11
236 15 12
238 236 9
240 239 235
242 241 7
244 236 5
246 245 235
248 247 9
250 249 243
252 8 6
254 232 10
256 254 252
258 257 250
260 258 23
262 261 17
264 263 137
266 265 19
268 164 16
270 268 14
272 270 22
274 273 267
276 274 231
278 12 11
280 279 8
282 15 10
284 282 2
286 285 9
288 287 281
290 288 4
292 15 11
294 4 2
296 295 10
298 296 8
300 299 293
302 301 13
304 303 291
306 305 6
308 15 8
310 308 7
312 12 9
314 313 311
316 315 10
318 317 307
320 319 17
322 14 13
324 322 6
326 325 245
328 327 10
330 328 8
332 177 12
334 332 14
336 335 331
338 336 321
340 339 19
342 16 15
344 342 8
346 17 14
348 346 7
350 349 345
352 351 12
354 352 10
356 12 10
358 357 16
360 358 14
362 361 355
364 362 341
366 365 21
368 14 10
370 368 50
372 371 343
374 373 18
376 375 367
378 377 23
380 22 18
382 20 19
384 382 12
386 385 381
388 387 16
390 388 14
392 16 12
394 393 18
396 395 23
398 397 20
400 399 391
402 400 379
404 23 21
406 404 9
408 392 42
410 14 7
412 410 408
414 19 11
416 414 13
418 416 190
420 419 413
422 421 406
424 153 15
426 424 12
428 427 21
430 17 10
432 14 12
434 432 430
436 15 13
438 436 294
440 439 435
442 441 8
444 442 6
446 347 11
448 447 445
450 448 428
452 237 17
454 453 9
456 433 16
458 457 455
460 458 450
462 461 19
464 18 8
466 9 6
468 467 465
470 469 10
472 470 432
474 472 200
476 432 16
478 477 20
480 479 475
482 480 463
484 483 23
486 18 14
488 486 392
490 17 13
492 490 294
494 19 8
496 494 492
498 497 489
500 499 6
502 392 18
504 502 8
506 504 14
508 507 501
510 509 10
512 511 404
514 368 252
516 514 12
518 15 13
520 519 517
522 520 17
524 522 19
526 525 512
528 92 23
530 528 21
532 176 6
534 532 432
536 535 530
c
Generated by Yosys 0.22+57 (git sha1 518194fac, gcc 9.3.0 -fPIC -Os)
This source diff could not be displayed because it is too large. You can view the blob instead.
This diff is collapsed. Click to expand it.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
aag 345 60 0 30 285
2
4
6
8
10
12
14
16
18
20
22
24
26
28
30
32
34
36
38
40
42
44
46
48
50
52
54
56
58
60
62
64
66
68
70
72
74
76
78
80
82
84
86
88
90
92
94
96
98
100
102
104
106
108
110
112
114
116
118
120
399
682
690
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
122 23 21
124 123 24
126 125 27
128 126 29
130 129 30
132 130 32
134 133 35
136 135 36
138 137 39
140 139 40
142 140 42
144 143 45
146 144 47
148 147 48
150 148 50
152 150 52
154 153 55
156 155 56
158 156 58
160 158 60
162 23 21
164 22 20
166 165 163
168 130 33
170 131 32
172 171 169
174 126 29
176 127 28
178 177 175
180 178 172
182 125 27
184 124 26
186 185 183
188 186 180
190 188 166
192 155 56
194 154 57
196 195 193
198 147 48
200 146 49
202 201 199
204 203 197
206 135 37
208 134 36
210 209 207
212 139 40
214 138 41
216 215 213
218 217 210
220 218 204
222 123 25
224 122 24
226 225 223
228 129 30
230 128 31
232 231 229
234 233 226
236 234 220
238 19 17
240 238 236
242 240 190
244 15 13
246 11 9
248 246 244
250 7 5
252 250 248
254 156 59
256 157 58
258 257 255
260 258 20
262 260 252
264 262 242
266 153 55
268 152 54
270 269 267
272 150 53
274 151 52
276 275 273
278 276 270
280 148 51
282 149 50
284 283 281
286 144 47
288 145 46
290 289 287
292 290 284
294 292 278
296 143 45
298 142 44
300 299 297
302 140 43
304 141 42
306 305 303
308 306 300
310 308 294
312 137 39
314 136 38
316 315 313
318 133 35
320 132 34
322 321 319
324 322 316
326 324 310
328 326 264
330 329 160
332 196 21
334 187 167
336 334 332
338 179 173
340 338 336
342 323 317
344 307 301
346 344 342
348 291 285
350 348 346
352 277 271
354 352 350
356 354 340
358 159 61
360 158 60
362 361 359
364 362 259
366 4 2
368 366 364
370 8 6
372 370 368
374 12 10
376 374 372
378 376 356
380 16 14
382 227 18
384 382 380
386 232 211
388 386 384
390 216 202
392 390 388
394 392 378
396 395 161
398 397 331
400 83 81
402 401 84
404 403 87
406 404 89
408 407 90
410 408 92
412 411 95
414 413 96
416 415 99
418 417 100
420 418 102
422 421 105
424 422 107
426 425 108
428 426 110
430 428 112
432 431 115
434 433 116
436 434 118
438 436 120
440 439 2
442 63 3
444 443 438
446 83 81
448 82 80
450 449 447
452 408 93
454 409 92
456 455 453
458 404 89
460 405 88
462 461 459
464 462 456
466 403 87
468 402 86
470 469 467
472 470 464
474 472 450
476 425 108
478 424 109
480 479 477
482 433 117
484 432 116
486 485 483
488 486 481
490 413 97
492 412 96
494 493 491
496 417 100
498 416 101
500 499 497
502 501 494
504 502 488
506 401 85
508 400 84
510 509 507
512 407 90
514 406 91
516 515 513
518 517 510
520 518 504
522 79 77
524 522 520
526 524 474
528 75 73
530 71 69
532 530 528
534 67 65
536 534 532
538 435 119
540 434 118
542 541 539
544 543 80
546 544 536
548 546 526
550 429 113
552 428 112
554 553 551
556 431 114
558 430 115
560 559 557
562 561 555
564 426 111
566 427 110
568 567 565
570 422 107
572 423 106
574 573 571
576 574 568
578 576 562
580 421 105
582 420 104
584 583 581
586 418 103
588 419 102
590 589 587
592 590 584
594 592 578
596 415 99
598 414 98
600 599 597
602 411 95
604 410 94
606 605 603
608 606 600
610 608 594
612 610 548
614 613 438
616 81 62
618 471 451
620 618 616
622 463 457
624 622 620
626 607 601
628 591 585
630 628 626
632 575 569
634 632 630
636 560 554
638 636 634
640 638 624
642 542 64
644 68 66
646 644 642
648 72 70
650 648 646
652 76 74
654 652 650
656 654 640
658 511 78
660 516 495
662 660 658
664 500 480
666 664 662
668 487 120
670 668 666
672 670 656
674 673 615
676 674 445
678 677 397
680 678 441
682 681 331
684 438 2
686 684 62
688 687 615
690 689 398
c
Generated by Yosys 0.22+57 (git sha1 518194fac, gcc 9.3.0 -fPIC -Os)
This diff is collapsed. Click to expand it.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This diff is collapsed. Click to expand it.
// @start ==================================================
// @file aig.h
// @author Chongxiao Li (chongxiao_li@outlook.com)
// @brief
// @version 0.1
// @date 2022-10-27
//
// @copyright Copyright (c) 2022
//
// @end ==================================================
#ifndef AUTOPIPELINE_AIG_H
#define AUTOPIPELINE_AIG_H
#include <assert.h>
#include <algorithm>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <vector>
class AigNode {
public:
AigNode();
int node_id_ = -1;
int left_id_ = -1;
int right_id_ = -1;
AigNode* left_node_ptr_ = nullptr;
AigNode* right_node_ptr_ = nullptr;
bool is_left_neg_ = 0;
bool is_right_neg_ = 0;
bool is_output_ = 0;
int output_bits_id_ = -1;
bool is_left_leaf_ = 0;
bool is_right_leaf_ = 0;
bool* left_leaf_ptr_ = nullptr;
bool* right_leaf_ptr_ = nullptr;
bool left_leaf_value_ = 0;
bool right_leaf_value_ = 0;
int key_path_length_ = -1;
int highest_level_ = -1;
int stage_id_ = -1;
int infer_value_ = -1;
bool accessed_ = false;
std::vector<int> ancestor_ids_;
AigNode(const AigNode& node);
AigNode& operator=(const AigNode& node);
private:
};
class Aig {
public:
Aig();
~Aig();
int input_width_ = 0;
int output_width_ = 0;
int node_num_ = 0;
int longest_key_path_length_ = -1;
int* output_id_list_;
AigNode** output_ptr_list_;
AigNode* node_vector_;
int AigInfer(bool* output_array, bool* input_reg);
bool NodeInfer(AigNode& node, bool* input_reg);
int CalHighestLevel(AigNode& node);
int CalKeyPathLength(AigNode& node);
int RecordAncestor();
private:
};
int LoadAig(Aig& aig, const char* aag_dir);
#endif // AUTOPIPELINE_AIG_H
\ No newline at end of file
#pragma once
#include<iostream>
#include<cstring>
using namespace std;
int cvt_bit_to_number(bool input_data[], int k){
int output_number = 0;
int i;
for (i=0;i<k-1;i++){
output_number += uint32_t(input_data[k-1-i]) << i;
//cout<<input_data[i];
}
if(input_data[0]){
output_number -= uint32_t(1)<<(k-1);
}
//cout<<' '<<dec<< output_number<<endl;
return output_number;
};
//bool* cvt_number_to_bit(int input_data, int k){
// int i;
// //bool* output_bits;
// bool* output_bits = new bool [k];
// for (i=0;i<k;i++){
// output_bits[i] = (input_data >> (k-1-i)) & int(1);
// }
// return output_bits;
//};
long cvt_bit_to_number_unsigned(bool input_data[], int k){
uint32_t output_number = 0;
int i;
for (i=0;i<k;i++){
output_number += uint32_t(input_data[i]) << (k-1-i);
//cout<<input_data[i];
}
//cout<<' '<<dec<<output_number<<endl;
return output_number;
};
//bool* cvt_number_to_bit_unsigned(uint32_t input_data, int k){
//
// bool* output_bits = new bool [k];
// int i;
// for (i=0;i<k;i++){
// output_bits[i] = (input_data >> (k-1-i)) & uint32_t(1);
// //cout<<output_number[i];
// }
// //cout<<' '<<hex<<input_data<<endl;
// return output_bits;
//};
void sign_extend(bool* bit_output, int output_length, bool* bit_input, int input_length) {
for(int i = 0; i < output_length-input_length; i++)
bit_output[i] = bit_input[0];
for(int i = 0; i < input_length; i++)
bit_output[output_length - input_length + i] = bit_input[i];
}
void zero_extend(bool* bit_output, int output_length, bool* bit_input, int input_length) {
for(int i = 0; i < output_length-input_length; i++)
bit_output[i] = 0;
for(int i = 0; i < input_length; i++)
bit_output[output_length - input_length + i] = bit_input[i];
}
void add_bit_list(bool* bit_output, bool* bit_input_a, bool* bit_input_b, int length) {
bool c = 0;
for(int i = length-1; i >= 0; i--) {
int temp = int(bit_input_a[i]) + int(bit_input_b[i]) + int(c);
bit_output[i] = temp%2==1 ? 1:0 ;
c = temp > 1? 1:0;
}
}
void copy_indice(bool* dst, uint32_t dst_idx, bool* src, uint32_t src_idx, uint32_t num) {
memcpy(dst + dst_idx, src + src_idx, num*sizeof(bool));
}
template <typename T>
void cout_indice(T arr, uint32_t idx, uint32_t num) {
for (int i = 0; i < num; i++)
cout << arr[i + idx];
cout << endl;
}
void init_indice(bool* arr, uint32_t idx, uint32_t num) {
memset(arr+idx, 0, num*sizeof(bool));
}
void init_indice(uint32_t* arr, uint32_t idx, uint32_t num) {
memset(arr+idx, 0, num*sizeof(uint32_t));
}
void cvt_number_to_bit_unsigned(bool* output_number, uint32_t input_data, int k) {
int i;
for (i = 0; i < k; i++) {
output_number[i] = (input_data >> (k - 1 - i)) & uint32_t(1);
// cout<<output_number[i];
}
// cout<<' '<< dec<<input_data<<endl;
};
void cvt_number_to_bit(bool* output_number, int input_data, int k) {
int i;
for (i = 0; i < k; i++) {
output_number[i] = (input_data >> (k - 1 - i)) & uint32_t(1);
// cout<<output_number[i];
}
// cout<<' '<< input_data<<endl;
};
src/
The latest version of the BSD Learner. Still working for the first released version on Github.
BSD.cpp main code of our algorithm
cvt.h head and some tool functions
print_circuit.h turn the graph into verilog
1. When we want more accurate/complex circuit:
BSD.cpp line 20: This parameter "bit_width" means total input bit amounts.
line 21: If accuracy is not enough, get this parameter larger. In CPU tapeout task, it is set from 200k to 1M.
line 24: This paramter means how many root nodes of one BSD.
line 29: If BSD is not efficient enough in merging nodes together, get this parameter larger may help.
Note that this parameter should not be larger than line 21
line 32: How many samples are there in the test set. Should be larger if we want more accurate circuits.
line 41: The biggest BDD width. Could be smaller in the demo case, but should be large if we are facing more complex circuit.
2. When we are doing ablation study/tradeoff:
BSD.cpp line 22: Set to a larger number than "bit_width", this program produces a decision tree.
line 31: A tradeoff between time/area, set to 1 (default) is the slowest but most area effient. Set to other N+ is quicker.
line 34: Until XX depth to stop expansion. It is a time/accuracy tradeoff. Default is the most accurate.
int BDD_class::set_random_input_data(bool** mask_input_data){
int i,j;
random_device rd;
mt19937 gen(rd());
//#pragma omp parallel for
for (int zj=0;zj<BSD_samples*parameter_input_bit_width;zj++){
int i = int(zj/parameter_input_bit_width);
int j = int(zj%parameter_input_bit_width);
//srand((int)time(0));
int zi = 0;
long randint;
zi = zj%30;
if(zi == 0){
//randint = rand();
randint = gen();
}
mask_input_data[i][j] = bool((randint >> (zi))%2);
}
return 0;
};
int BDD_class::mask_random_input_data(int depth,bool mask[parameter_input_bit_width],int amount,int* most_influence,bool** mask_input_data){
int i,j;
//#pragma omp parallel for
for (i=0;i<amount;i++){
for (j=0;j<depth+1;j++){
mask_input_data[i][most_influence[j]] = mask[most_influence[j]];
}
}
return 0;
};
int BDD_class::compare_simplify_list(int list_line_amount,bool* this_line,bool** simplify_list){
int which_list_number = -1;
bool it_can_simplify = 0;
int i,j;
bool it_can_simplify_here;
which_list_number = -1;
if(1){
for (int i=list_line_amount-1;i>=0;i--){
it_can_simplify_here = 1;
for(int j=0;j<BSD_samples;j++){
if(simplify_list[i][j] != this_line[j]){
it_can_simplify_here = 0;
break;
}
}
if(it_can_simplify_here){
it_can_simplify = 1;
which_list_number = i;
break;
}
}
}
return which_list_number;
};
int BDD_class::compare_simplify_list_neg(int list_line_amount,bool* this_line,bool** simplify_list){
int which_list_number = -1;
//return which_list_number;
bool it_can_simplify = 0;
int i,j;
bool it_can_simplify_here;
which_list_number = -1;
if(1){
for (i=list_line_amount-1;i>=0;i--){
it_can_simplify_here = 1;
for(int j=0;j<BSD_samples;j++){
if(simplify_list[i][j] == this_line[j]){
it_can_simplify_here = 0;
break;
}
}
if(it_can_simplify_here){
it_can_simplify = 1;
which_list_number = i;
break;
}
}
}
return which_list_number;
};
export PATH=/lustre/S/chengshuyao/haoshiming/anaconda3/envs/BSD/bin:/bin:/lustre/S/chengshuyao/haoshiming/anaconda3/envs/BSD/bin:/lustre/S/chengshuyao/haoshiming/anaconda3/envs/BSD/bin/gcc
export LIBRARY_PATH=/lustre/S/chengshuyao/haoshiming/anaconda3/envs/BSD/bin:/lustre/S/chengshuyao/haoshiming/anaconda3/envs/BSD/lib
export LD_LIBRARY_PATH=/lustre/S/chengshuyao/haoshiming/anaconda3/envs/BSD/bin:/lustre/S/chengshuyao/haoshiming/anaconda3/envs/BSD/lib
rm rtl/*
g++ BSD.cpp -O3 -std=c++11 -fopenmp -pg
./a.out
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment