-
Notifications
You must be signed in to change notification settings - Fork 17
/
mul16u_DAE.c
790 lines (776 loc) · 25.9 KB
/
mul16u_DAE.c
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
/***
* This code is a part of EvoApproxLib library (ehw.fit.vutbr.cz/approxlib) distributed under The MIT License.
* When used, please cite the following article(s): V. Mrazek, Z. Vasicek, L. Sekanina, H. Jiang and J. Han, "Scalable Construction of Approximate Multipliers With Formally Guaranteed Worst Case Error" in IEEE Transactions on Very Large Scale Integration (VLSI) Systems, vol. 26, no. 11, pp. 2572-2576, Nov. 2018. doi: 10.1109/TVLSI.2018.2856362
* This file contains a circuit from a sub-set of pareto optimal circuits with respect to the pwr and mae parameters
***/
// MAE% = 0.0000045 %
// MAE = 195
// WCE% = 0.000021 %
// WCE = 907
// WCRE% = 100.00 %
// EP% = 98.71 %
// MRE% = 0.0005 %
// MSE = 58920
// PDK45_PWR = 1.952 mW
// PDK45_AREA = 2800.8 um2
// PDK45_DELAY = 2.79 ns
#include <stdint.h>
#include <stdlib.h>
uint16_t mul8_364(uint8_t a, uint8_t b)
{
uint16_t c = 0;
uint8_t n0 = (a >> 0) & 0x1;
uint8_t n2 = (a >> 1) & 0x1;
uint8_t n4 = (a >> 2) & 0x1;
uint8_t n6 = (a >> 3) & 0x1;
uint8_t n8 = (a >> 4) & 0x1;
uint8_t n10 = (a >> 5) & 0x1;
uint8_t n12 = (a >> 6) & 0x1;
uint8_t n14 = (a >> 7) & 0x1;
uint8_t n16 = (b >> 0) & 0x1;
uint8_t n18 = (b >> 1) & 0x1;
uint8_t n20 = (b >> 2) & 0x1;
uint8_t n22 = (b >> 3) & 0x1;
uint8_t n24 = (b >> 4) & 0x1;
uint8_t n26 = (b >> 5) & 0x1;
uint8_t n28 = (b >> 6) & 0x1;
uint8_t n30 = (b >> 7) & 0x1;
uint8_t n32;
uint8_t n48;
uint8_t n64;
uint8_t n82;
uint8_t n98;
uint8_t n114;
uint8_t n132;
uint8_t n149;
uint8_t n164;
uint8_t n167;
uint8_t n182;
uint8_t n198;
uint8_t n214;
uint8_t n232;
uint8_t n248;
uint8_t n264;
uint8_t n282;
uint8_t n298;
uint8_t n299;
uint8_t n314;
uint8_t n315;
uint8_t n332;
uint8_t n333;
uint8_t n348;
uint8_t n349;
uint8_t n364;
uint8_t n365;
uint8_t n382;
uint8_t n383;
uint8_t n398;
uint8_t n399;
uint8_t n414;
uint8_t n432;
uint8_t n448;
uint8_t n464;
uint8_t n482;
uint8_t n498;
uint8_t n514;
uint8_t n532;
uint8_t n548;
uint8_t n549;
uint8_t n564;
uint8_t n565;
uint8_t n582;
uint8_t n583;
uint8_t n598;
uint8_t n599;
uint8_t n614;
uint8_t n615;
uint8_t n632;
uint8_t n633;
uint8_t n648;
uint8_t n649;
uint8_t n664;
uint8_t n682;
uint8_t n698;
uint8_t n714;
uint8_t n732;
uint8_t n748;
uint8_t n764;
uint8_t n782;
uint8_t n798;
uint8_t n799;
uint8_t n814;
uint8_t n815;
uint8_t n832;
uint8_t n833;
uint8_t n848;
uint8_t n849;
uint8_t n864;
uint8_t n865;
uint8_t n882;
uint8_t n883;
uint8_t n898;
uint8_t n899;
uint8_t n914;
uint8_t n932;
uint8_t n948;
uint8_t n964;
uint8_t n982;
uint8_t n998;
uint8_t n1014;
uint8_t n1032;
uint8_t n1048;
uint8_t n1049;
uint8_t n1064;
uint8_t n1065;
uint8_t n1082;
uint8_t n1083;
uint8_t n1098;
uint8_t n1099;
uint8_t n1114;
uint8_t n1115;
uint8_t n1132;
uint8_t n1133;
uint8_t n1148;
uint8_t n1149;
uint8_t n1164;
uint8_t n1182;
uint8_t n1198;
uint8_t n1214;
uint8_t n1232;
uint8_t n1248;
uint8_t n1264;
uint8_t n1282;
uint8_t n1298;
uint8_t n1299;
uint8_t n1314;
uint8_t n1315;
uint8_t n1332;
uint8_t n1333;
uint8_t n1348;
uint8_t n1349;
uint8_t n1364;
uint8_t n1365;
uint8_t n1382;
uint8_t n1383;
uint8_t n1398;
uint8_t n1399;
uint8_t n1414;
uint8_t n1432;
uint8_t n1448;
uint8_t n1464;
uint8_t n1482;
uint8_t n1498;
uint8_t n1514;
uint8_t n1532;
uint8_t n1548;
uint8_t n1549;
uint8_t n1564;
uint8_t n1565;
uint8_t n1582;
uint8_t n1583;
uint8_t n1598;
uint8_t n1599;
uint8_t n1614;
uint8_t n1615;
uint8_t n1632;
uint8_t n1633;
uint8_t n1648;
uint8_t n1649;
uint8_t n1664;
uint8_t n1682;
uint8_t n1698;
uint8_t n1714;
uint8_t n1732;
uint8_t n1748;
uint8_t n1764;
uint8_t n1782;
uint8_t n1798;
uint8_t n1799;
uint8_t n1814;
uint8_t n1815;
uint8_t n1832;
uint8_t n1833;
uint8_t n1848;
uint8_t n1849;
uint8_t n1864;
uint8_t n1865;
uint8_t n1882;
uint8_t n1883;
uint8_t n1898;
uint8_t n1899;
uint8_t n1914;
uint8_t n1915;
uint8_t n1932;
uint8_t n1933;
uint8_t n1948;
uint8_t n1949;
uint8_t n1964;
uint8_t n1965;
uint8_t n1982;
uint8_t n1983;
uint8_t n1998;
uint8_t n1999;
uint8_t n2014;
uint8_t n2015;
n32 = n0 & n16;
n48 = n2 & n16;
n64 = n4 & n16;
n82 = n6 & n16;
n98 = n8 & n16;
n114 = n10 & n16;
n132 = n12 & n16;
n149 = n14 & n16;
n164 = n0 & n18;
n167 = n149;
n182 = n2 & n18;
n198 = n4 & n18;
n214 = n6 & n18;
n232 = n8 & n18;
n248 = n10 & n18;
n264 = n12 & n18;
n282 = n14 & n18;
n298 = n48 ^ n164;
n299 = n48 & n164;
n314 = n64 ^ n182;
n315 = n64 & n182;
n332 = n82 ^ n198;
n333 = n82 & n198;
n348 = n98 ^ n214;
n349 = n98 & n214;
n364 = n114 ^ n232;
n365 = n114 & n232;
n382 = n132 ^ n248;
n383 = n132 & n248;
n398 = n167 ^ n264;
n399 = n167 & n264;
n414 = n0 & n20;
n432 = n2 & n20;
n448 = n4 & n20;
n464 = n6 & n20;
n482 = n8 & n20;
n498 = n10 & n20;
n514 = n12 & n20;
n532 = n14 & n20;
n548 = (n314 ^ n414) ^ n299;
n549 = (n314 & n414) | (n414 & n299) | (n314 & n299);
n564 = (n332 ^ n432) ^ n315;
n565 = (n332 & n432) | (n432 & n315) | (n332 & n315);
n582 = (n348 ^ n448) ^ n333;
n583 = (n348 & n448) | (n448 & n333) | (n348 & n333);
n598 = (n364 ^ n464) ^ n349;
n599 = (n364 & n464) | (n464 & n349) | (n364 & n349);
n614 = (n382 ^ n482) ^ n365;
n615 = (n382 & n482) | (n482 & n365) | (n382 & n365);
n632 = (n398 ^ n498) ^ n383;
n633 = (n398 & n498) | (n498 & n383) | (n398 & n383);
n648 = (n282 ^ n514) ^ n399;
n649 = (n282 & n514) | (n514 & n399) | (n282 & n399);
n664 = n0 & n22;
n682 = n2 & n22;
n698 = n4 & n22;
n714 = n6 & n22;
n732 = n8 & n22;
n748 = n10 & n22;
n764 = n12 & n22;
n782 = n14 & n22;
n798 = (n564 ^ n664) ^ n549;
n799 = (n564 & n664) | (n664 & n549) | (n564 & n549);
n814 = (n582 ^ n682) ^ n565;
n815 = (n582 & n682) | (n682 & n565) | (n582 & n565);
n832 = (n598 ^ n698) ^ n583;
n833 = (n598 & n698) | (n698 & n583) | (n598 & n583);
n848 = (n614 ^ n714) ^ n599;
n849 = (n614 & n714) | (n714 & n599) | (n614 & n599);
n864 = (n632 ^ n732) ^ n615;
n865 = (n632 & n732) | (n732 & n615) | (n632 & n615);
n882 = (n648 ^ n748) ^ n633;
n883 = (n648 & n748) | (n748 & n633) | (n648 & n633);
n898 = (n532 ^ n764) ^ n649;
n899 = (n532 & n764) | (n764 & n649) | (n532 & n649);
n914 = n0 & n24;
n932 = n2 & n24;
n948 = n4 & n24;
n964 = n6 & n24;
n982 = n8 & n24;
n998 = n10 & n24;
n1014 = n12 & n24;
n1032 = n14 & n24;
n1048 = (n814 ^ n914) ^ n799;
n1049 = (n814 & n914) | (n914 & n799) | (n814 & n799);
n1064 = (n832 ^ n932) ^ n815;
n1065 = (n832 & n932) | (n932 & n815) | (n832 & n815);
n1082 = (n848 ^ n948) ^ n833;
n1083 = (n848 & n948) | (n948 & n833) | (n848 & n833);
n1098 = (n864 ^ n964) ^ n849;
n1099 = (n864 & n964) | (n964 & n849) | (n864 & n849);
n1114 = (n882 ^ n982) ^ n865;
n1115 = (n882 & n982) | (n982 & n865) | (n882 & n865);
n1132 = (n898 ^ n998) ^ n883;
n1133 = (n898 & n998) | (n998 & n883) | (n898 & n883);
n1148 = (n782 ^ n1014) ^ n899;
n1149 = (n782 & n1014) | (n1014 & n899) | (n782 & n899);
n1164 = n0 & n26;
n1182 = n2 & n26;
n1198 = n4 & n26;
n1214 = n6 & n26;
n1232 = n8 & n26;
n1248 = n10 & n26;
n1264 = n12 & n26;
n1282 = n14 & n26;
n1298 = (n1064 ^ n1164) ^ n1049;
n1299 = (n1064 & n1164) | (n1164 & n1049) | (n1064 & n1049);
n1314 = (n1082 ^ n1182) ^ n1065;
n1315 = (n1082 & n1182) | (n1182 & n1065) | (n1082 & n1065);
n1332 = (n1098 ^ n1198) ^ n1083;
n1333 = (n1098 & n1198) | (n1198 & n1083) | (n1098 & n1083);
n1348 = (n1114 ^ n1214) ^ n1099;
n1349 = (n1114 & n1214) | (n1214 & n1099) | (n1114 & n1099);
n1364 = (n1132 ^ n1232) ^ n1115;
n1365 = (n1132 & n1232) | (n1232 & n1115) | (n1132 & n1115);
n1382 = (n1148 ^ n1248) ^ n1133;
n1383 = (n1148 & n1248) | (n1248 & n1133) | (n1148 & n1133);
n1398 = (n1032 ^ n1264) ^ n1149;
n1399 = (n1032 & n1264) | (n1264 & n1149) | (n1032 & n1149);
n1414 = n0 & n28;
n1432 = n2 & n28;
n1448 = n4 & n28;
n1464 = n6 & n28;
n1482 = n8 & n28;
n1498 = n10 & n28;
n1514 = n12 & n28;
n1532 = n14 & n28;
n1548 = (n1314 ^ n1414) ^ n1299;
n1549 = (n1314 & n1414) | (n1414 & n1299) | (n1314 & n1299);
n1564 = (n1332 ^ n1432) ^ n1315;
n1565 = (n1332 & n1432) | (n1432 & n1315) | (n1332 & n1315);
n1582 = (n1348 ^ n1448) ^ n1333;
n1583 = (n1348 & n1448) | (n1448 & n1333) | (n1348 & n1333);
n1598 = (n1364 ^ n1464) ^ n1349;
n1599 = (n1364 & n1464) | (n1464 & n1349) | (n1364 & n1349);
n1614 = (n1382 ^ n1482) ^ n1365;
n1615 = (n1382 & n1482) | (n1482 & n1365) | (n1382 & n1365);
n1632 = (n1398 ^ n1498) ^ n1383;
n1633 = (n1398 & n1498) | (n1498 & n1383) | (n1398 & n1383);
n1648 = (n1282 ^ n1514) ^ n1399;
n1649 = (n1282 & n1514) | (n1514 & n1399) | (n1282 & n1399);
n1664 = n0 & n30;
n1682 = n2 & n30;
n1698 = n4 & n30;
n1714 = n6 & n30;
n1732 = n8 & n30;
n1748 = n10 & n30;
n1764 = n12 & n30;
n1782 = n14 & n30;
n1798 = (n1564 ^ n1664) ^ n1549;
n1799 = (n1564 & n1664) | (n1664 & n1549) | (n1564 & n1549);
n1814 = (n1582 ^ n1682) ^ n1565;
n1815 = (n1582 & n1682) | (n1682 & n1565) | (n1582 & n1565);
n1832 = (n1598 ^ n1698) ^ n1583;
n1833 = (n1598 & n1698) | (n1698 & n1583) | (n1598 & n1583);
n1848 = (n1614 ^ n1714) ^ n1599;
n1849 = (n1614 & n1714) | (n1714 & n1599) | (n1614 & n1599);
n1864 = (n1632 ^ n1732) ^ n1615;
n1865 = (n1632 & n1732) | (n1732 & n1615) | (n1632 & n1615);
n1882 = (n1648 ^ n1748) ^ n1633;
n1883 = (n1648 & n1748) | (n1748 & n1633) | (n1648 & n1633);
n1898 = (n1532 ^ n1764) ^ n1649;
n1899 = (n1532 & n1764) | (n1764 & n1649) | (n1532 & n1649);
n1914 = n1814 ^ n1799;
n1915 = n1814 & n1799;
n1932 = (n1832 ^ n1815) ^ n1915;
n1933 = (n1832 & n1815) | (n1815 & n1915) | (n1832 & n1915);
n1948 = (n1848 ^ n1833) ^ n1933;
n1949 = (n1848 & n1833) | (n1833 & n1933) | (n1848 & n1933);
n1964 = (n1864 ^ n1849) ^ n1949;
n1965 = (n1864 & n1849) | (n1849 & n1949) | (n1864 & n1949);
n1982 = (n1882 ^ n1865) ^ n1965;
n1983 = (n1882 & n1865) | (n1865 & n1965) | (n1882 & n1965);
n1998 = (n1898 ^ n1883) ^ n1983;
n1999 = (n1898 & n1883) | (n1883 & n1983) | (n1898 & n1983);
n2014 = (n1782 ^ n1899) ^ n1999;
n2015 = (n1782 & n1899) | (n1899 & n1999) | (n1782 & n1999);
c |= (n32 & 0x1) << 0;
c |= (n298 & 0x1) << 1;
c |= (n548 & 0x1) << 2;
c |= (n798 & 0x1) << 3;
c |= (n1048 & 0x1) << 4;
c |= (n1298 & 0x1) << 5;
c |= (n1548 & 0x1) << 6;
c |= (n1798 & 0x1) << 7;
c |= (n1914 & 0x1) << 8;
c |= (n1932 & 0x1) << 9;
c |= (n1948 & 0x1) << 10;
c |= (n1964 & 0x1) << 11;
c |= (n1982 & 0x1) << 12;
c |= (n1998 & 0x1) << 13;
c |= (n2014 & 0x1) << 14;
c |= (n2015 & 0x1) << 15;
return c;
}
uint16_t trun8_tam00b(uint8_t A, uint8_t B)
{
uint16_t P, P_;
uint8_t tmp, C_1_0,C_1_1,C_1_2,C_1_3,C_1_4,C_1_5,C_1_6,C_2_0,C_2_1,C_2_2,C_2_3,C_2_4,C_2_5,C_2_6,C_3_0,C_3_1,C_3_2,C_3_3,C_3_4,C_3_5,C_3_6,C_4_0,C_4_1,C_4_2,C_4_3,C_4_4,C_4_5,C_4_6,C_5_0,C_5_1,C_5_2,C_5_3,C_5_4,C_5_5,C_5_6,C_6_0,C_6_1,C_6_2,C_6_3,C_6_4,C_6_5,C_6_6,C_7_0,C_7_1,C_7_2,C_7_3,C_7_4,C_7_5,C_7_6,S_0_0,S_0_1,S_0_2,S_0_3,S_0_4,S_0_5,S_0_6,S_0_7,S_1_0,S_1_1,S_1_2,S_1_3,S_1_4,S_1_5,S_1_6,S_1_7,S_2_0,S_2_1,S_2_2,S_2_3,S_2_4,S_2_5,S_2_6,S_2_7,S_3_0,S_3_1,S_3_2,S_3_3,S_3_4,S_3_5,S_3_6,S_3_7,S_4_0,S_4_1,S_4_2,S_4_3,S_4_4,S_4_5,S_4_6,S_4_7,S_5_0,S_5_1,S_5_2,S_5_3,S_5_4,S_5_5,S_5_6,S_5_7,S_6_0,S_6_1,S_6_2,S_6_3,S_6_4,S_6_5,S_6_6,S_6_7,S_7_0,S_7_1,S_7_2,S_7_3,S_7_4,S_7_5,S_7_6,S_7_7,S_8_0,S_8_1,S_8_2,S_8_3,S_8_4,S_8_5,S_8_6,S_8_7;
S_0_0 = (((A>>0)&1) & ((B>>0)&1));
S_0_1 = (((A>>0)&1) & ((B>>1)&1));
S_0_2 = (((A>>0)&1) & ((B>>2)&1));
S_0_3 = (((A>>0)&1) & ((B>>3)&1));
S_0_4 = (((A>>0)&1) & ((B>>4)&1));
S_0_5 = (((A>>0)&1) & ((B>>5)&1));
S_0_6 = (((A>>0)&1) & ((B>>6)&1));
S_0_7 = (((A>>0)&1) & ((B>>7)&1));
S_1_0 = S_0_1^(((A>>1)&1) & ((B>>0)&1));
C_1_0 = S_0_1&(((A>>1)&1) & ((B>>0)&1));
S_1_1 = S_0_2^(((A>>1)&1) & ((B>>1)&1));
C_1_1 = S_0_2&(((A>>1)&1) & ((B>>1)&1));
S_1_2 = S_0_3^(((A>>1)&1) & ((B>>2)&1));
C_1_2 = S_0_3&(((A>>1)&1) & ((B>>2)&1));
S_1_3 = S_0_4^(((A>>1)&1) & ((B>>3)&1));
C_1_3 = S_0_4&(((A>>1)&1) & ((B>>3)&1));
S_1_4 = S_0_5^(((A>>1)&1) & ((B>>4)&1));
C_1_4 = S_0_5&(((A>>1)&1) & ((B>>4)&1));
S_1_5 = S_0_6^(((A>>1)&1) & ((B>>5)&1));
C_1_5 = S_0_6&(((A>>1)&1) & ((B>>5)&1));
S_1_6 = S_0_7^(((A>>1)&1) & ((B>>6)&1));
C_1_6 = S_0_7&(((A>>1)&1) & ((B>>6)&1));
S_1_7 = (((A>>1)&1) & ((B>>7)&1));
tmp = S_1_1^C_1_0;
S_2_0 = tmp^(((A>>2)&1) & ((B>>0)&1));
C_2_0 = (tmp&(((A>>2)&1) & ((B>>0)&1)))|(S_1_1&C_1_0);
tmp = S_1_2^C_1_1;
S_2_1 = tmp^(((A>>2)&1) & ((B>>1)&1));
C_2_1 = (tmp&(((A>>2)&1) & ((B>>1)&1)))|(S_1_2&C_1_1);
tmp = S_1_3^C_1_2;
S_2_2 = tmp^(((A>>2)&1) & ((B>>2)&1));
C_2_2 = (tmp&(((A>>2)&1) & ((B>>2)&1)))|(S_1_3&C_1_2);
tmp = S_1_4^C_1_3;
S_2_3 = tmp^(((A>>2)&1) & ((B>>3)&1));
C_2_3 = (tmp&(((A>>2)&1) & ((B>>3)&1)))|(S_1_4&C_1_3);
tmp = S_1_5^C_1_4;
S_2_4 = tmp^(((A>>2)&1) & ((B>>4)&1));
C_2_4 = (tmp&(((A>>2)&1) & ((B>>4)&1)))|(S_1_5&C_1_4);
tmp = S_1_6^C_1_5;
S_2_5 = tmp^(((A>>2)&1) & ((B>>5)&1));
C_2_5 = (tmp&(((A>>2)&1) & ((B>>5)&1)))|(S_1_6&C_1_5);
tmp = S_1_7^C_1_6;
S_2_6 = tmp^(((A>>2)&1) & ((B>>6)&1));
C_2_6 = (tmp&(((A>>2)&1) & ((B>>6)&1)))|(S_1_7&C_1_6);
S_2_7 = (((A>>2)&1) & ((B>>7)&1));
tmp = S_2_1^C_2_0;
S_3_0 = tmp^(((A>>3)&1) & ((B>>0)&1));
C_3_0 = (tmp&(((A>>3)&1) & ((B>>0)&1)))|(S_2_1&C_2_0);
tmp = S_2_2^C_2_1;
S_3_1 = tmp^(((A>>3)&1) & ((B>>1)&1));
C_3_1 = (tmp&(((A>>3)&1) & ((B>>1)&1)))|(S_2_2&C_2_1);
tmp = S_2_3^C_2_2;
S_3_2 = tmp^(((A>>3)&1) & ((B>>2)&1));
C_3_2 = (tmp&(((A>>3)&1) & ((B>>2)&1)))|(S_2_3&C_2_2);
tmp = S_2_4^C_2_3;
S_3_3 = tmp^(((A>>3)&1) & ((B>>3)&1));
C_3_3 = (tmp&(((A>>3)&1) & ((B>>3)&1)))|(S_2_4&C_2_3);
tmp = S_2_5^C_2_4;
S_3_4 = tmp^(((A>>3)&1) & ((B>>4)&1));
C_3_4 = (tmp&(((A>>3)&1) & ((B>>4)&1)))|(S_2_5&C_2_4);
tmp = S_2_6^C_2_5;
S_3_5 = tmp^(((A>>3)&1) & ((B>>5)&1));
C_3_5 = (tmp&(((A>>3)&1) & ((B>>5)&1)))|(S_2_6&C_2_5);
tmp = S_2_7^C_2_6;
S_3_6 = tmp^(((A>>3)&1) & ((B>>6)&1));
C_3_6 = (tmp&(((A>>3)&1) & ((B>>6)&1)))|(S_2_7&C_2_6);
S_3_7 = (((A>>3)&1) & ((B>>7)&1));
tmp = S_3_1^C_3_0;
S_4_0 = tmp^(((A>>4)&1) & ((B>>0)&1));
C_4_0 = (tmp&(((A>>4)&1) & ((B>>0)&1)))|(S_3_1&C_3_0);
tmp = S_3_2^C_3_1;
S_4_1 = tmp^(((A>>4)&1) & ((B>>1)&1));
C_4_1 = (tmp&(((A>>4)&1) & ((B>>1)&1)))|(S_3_2&C_3_1);
tmp = S_3_3^C_3_2;
S_4_2 = tmp^(((A>>4)&1) & ((B>>2)&1));
C_4_2 = (tmp&(((A>>4)&1) & ((B>>2)&1)))|(S_3_3&C_3_2);
tmp = S_3_4^C_3_3;
S_4_3 = tmp^(((A>>4)&1) & ((B>>3)&1));
C_4_3 = (tmp&(((A>>4)&1) & ((B>>3)&1)))|(S_3_4&C_3_3);
tmp = S_3_5^C_3_4;
S_4_4 = tmp^(((A>>4)&1) & ((B>>4)&1));
C_4_4 = (tmp&(((A>>4)&1) & ((B>>4)&1)))|(S_3_5&C_3_4);
tmp = S_3_6^C_3_5;
S_4_5 = tmp^(((A>>4)&1) & ((B>>5)&1));
C_4_5 = (tmp&(((A>>4)&1) & ((B>>5)&1)))|(S_3_6&C_3_5);
tmp = S_3_7^C_3_6;
S_4_6 = tmp^(((A>>4)&1) & ((B>>6)&1));
C_4_6 = (tmp&(((A>>4)&1) & ((B>>6)&1)))|(S_3_7&C_3_6);
S_4_7 = (((A>>4)&1) & ((B>>7)&1));
tmp = S_4_1^C_4_0;
S_5_0 = tmp^(((A>>5)&1) & ((B>>0)&1));
C_5_0 = (tmp&(((A>>5)&1) & ((B>>0)&1)))|(S_4_1&C_4_0);
tmp = S_4_2^C_4_1;
S_5_1 = tmp^(((A>>5)&1) & ((B>>1)&1));
C_5_1 = (tmp&(((A>>5)&1) & ((B>>1)&1)))|(S_4_2&C_4_1);
tmp = S_4_3^C_4_2;
S_5_2 = tmp^(((A>>5)&1) & ((B>>2)&1));
C_5_2 = (tmp&(((A>>5)&1) & ((B>>2)&1)))|(S_4_3&C_4_2);
tmp = S_4_4^C_4_3;
S_5_3 = tmp^(((A>>5)&1) & ((B>>3)&1));
C_5_3 = (tmp&(((A>>5)&1) & ((B>>3)&1)))|(S_4_4&C_4_3);
tmp = S_4_5^C_4_4;
S_5_4 = tmp^(((A>>5)&1) & ((B>>4)&1));
C_5_4 = (tmp&(((A>>5)&1) & ((B>>4)&1)))|(S_4_5&C_4_4);
tmp = S_4_6^C_4_5;
S_5_5 = tmp^(((A>>5)&1) & ((B>>5)&1));
C_5_5 = (tmp&(((A>>5)&1) & ((B>>5)&1)))|(S_4_6&C_4_5);
tmp = S_4_7^C_4_6;
S_5_6 = tmp^(((A>>5)&1) & ((B>>6)&1));
C_5_6 = (tmp&(((A>>5)&1) & ((B>>6)&1)))|(S_4_7&C_4_6);
S_5_7 = (((A>>5)&1) & ((B>>7)&1));
tmp = S_5_1^C_5_0;
S_6_0 = tmp^(((A>>6)&1) & ((B>>0)&1));
C_6_0 = (tmp&(((A>>6)&1) & ((B>>0)&1)))|(S_5_1&C_5_0);
tmp = S_5_2^C_5_1;
S_6_1 = tmp^(((A>>6)&1) & ((B>>1)&1));
C_6_1 = (tmp&(((A>>6)&1) & ((B>>1)&1)))|(S_5_2&C_5_1);
tmp = S_5_3^C_5_2;
S_6_2 = tmp^(((A>>6)&1) & ((B>>2)&1));
C_6_2 = (tmp&(((A>>6)&1) & ((B>>2)&1)))|(S_5_3&C_5_2);
tmp = S_5_4^C_5_3;
S_6_3 = tmp^(((A>>6)&1) & ((B>>3)&1));
C_6_3 = (tmp&(((A>>6)&1) & ((B>>3)&1)))|(S_5_4&C_5_3);
tmp = S_5_5^C_5_4;
S_6_4 = tmp^(((A>>6)&1) & ((B>>4)&1));
C_6_4 = (tmp&(((A>>6)&1) & ((B>>4)&1)))|(S_5_5&C_5_4);
tmp = S_5_6^C_5_5;
S_6_5 = tmp^(((A>>6)&1) & ((B>>5)&1));
C_6_5 = (tmp&(((A>>6)&1) & ((B>>5)&1)))|(S_5_6&C_5_5);
tmp = S_5_7^C_5_6;
S_6_6 = tmp^(((A>>6)&1) & ((B>>6)&1));
C_6_6 = (tmp&(((A>>6)&1) & ((B>>6)&1)))|(S_5_7&C_5_6);
S_6_7 = (((A>>6)&1) & ((B>>7)&1));
tmp = S_6_1^C_6_0;
S_7_0 = tmp^(((A>>7)&1) & ((B>>0)&1));
C_7_0 = (tmp&(((A>>7)&1) & ((B>>0)&1)))|(S_6_1&C_6_0);
tmp = S_6_2^C_6_1;
S_7_1 = tmp^(((A>>7)&1) & ((B>>1)&1));
C_7_1 = (tmp&(((A>>7)&1) & ((B>>1)&1)))|(S_6_2&C_6_1);
tmp = S_6_3^C_6_2;
S_7_2 = tmp^(((A>>7)&1) & ((B>>2)&1));
C_7_2 = (tmp&(((A>>7)&1) & ((B>>2)&1)))|(S_6_3&C_6_2);
tmp = S_6_4^C_6_3;
S_7_3 = tmp^(((A>>7)&1) & ((B>>3)&1));
C_7_3 = (tmp&(((A>>7)&1) & ((B>>3)&1)))|(S_6_4&C_6_3);
tmp = S_6_5^C_6_4;
S_7_4 = tmp^(((A>>7)&1) & ((B>>4)&1));
C_7_4 = (tmp&(((A>>7)&1) & ((B>>4)&1)))|(S_6_5&C_6_4);
tmp = S_6_6^C_6_5;
S_7_5 = tmp^(((A>>7)&1) & ((B>>5)&1));
C_7_5 = (tmp&(((A>>7)&1) & ((B>>5)&1)))|(S_6_6&C_6_5);
tmp = S_6_7^C_6_6;
S_7_6 = tmp^(((A>>7)&1) & ((B>>6)&1));
C_7_6 = (tmp&(((A>>7)&1) & ((B>>6)&1)))|(S_6_7&C_6_6);
S_7_7 = (((A>>7)&1) & ((B>>7)&1));
P_ = (((C_7_0 & 1)<<0)|((C_7_1 & 1)<<1)|((C_7_2 & 1)<<2)|((C_7_3 & 1)<<3)|((C_7_4 & 1)<<4)|((C_7_5 & 1)<<5)|((C_7_6 & 1)<<6)) + (((S_7_1 & 1)<<0)|((S_7_2 & 1)<<1)|((S_7_3 & 1)<<2)|((S_7_4 & 1)<<3)|((S_7_5 & 1)<<4)|((S_7_6 & 1)<<5)|((S_7_7 & 1)<<6));
S_8_0 = (P_ >> 0) & 1;
S_8_1 = (P_ >> 1) & 1;
S_8_2 = (P_ >> 2) & 1;
S_8_3 = (P_ >> 3) & 1;
S_8_4 = (P_ >> 4) & 1;
S_8_5 = (P_ >> 5) & 1;
S_8_6 = (P_ >> 6) & 1;
S_8_7 = (P_ >> 7) & 1;
P = 0;
P |= (S_0_0 & 1) << 0;
P |= (S_1_0 & 1) << 1;
P |= (S_2_0 & 1) << 2;
P |= (S_3_0 & 1) << 3;
P |= (S_4_0 & 1) << 4;
P |= (S_5_0 & 1) << 5;
P |= (S_6_0 & 1) << 6;
P |= (S_7_0 & 1) << 7;
P |= (S_8_0 & 1) << 8;
P |= (S_8_1 & 1) << 9;
P |= (S_8_2 & 1) << 10;
P |= (S_8_3 & 1) << 11;
P |= (S_8_4 & 1) << 12;
P |= (S_8_5 & 1) << 13;
P |= (S_8_6 & 1) << 14;
P |= (S_8_7 & 1) << 15;
return P;
}
uint64_t mult8_cgp14zr_wc907_rcam(const uint64_t B,const uint64_t A)
{
uint64_t O, dout_65, dout_72, dout_73, dout_101, dout_102, dout_106, dout_107, dout_108, dout_109, dout_110, dout_116, dout_117, dout_118, dout_146, dout_148, dout_149, dout_150, dout_151, dout_152, dout_153, dout_154, dout_155, dout_160, dout_161, dout_162, dout_163, dout_186, dout_187, dout_188, dout_189, dout_190, dout_191, dout_192, dout_193, dout_194, dout_195, dout_196, dout_197, dout_198, dout_199, dout_200, dout_203, dout_205, dout_206, dout_207, dout_208, dout_222, dout_226, dout_227, dout_228, dout_229, dout_230, dout_231, dout_232, dout_233, dout_234, dout_235, dout_236, dout_237, dout_238, dout_239, dout_240, dout_241, dout_242, dout_243, dout_244, dout_245, dout_249, dout_250, dout_251, dout_252, dout_253, dout_266, dout_267, dout_268, dout_269, dout_270, dout_271, dout_272, dout_273, dout_274, dout_275, dout_276, dout_277, dout_278, dout_279, dout_280, dout_281, dout_282, dout_283, dout_284, dout_285, dout_286, dout_287, dout_288, dout_289, dout_290, dout_292, dout_293, dout_294, dout_295, dout_296, dout_297, dout_298, dout_306, dout_307, dout_311, dout_312, dout_313, dout_314, dout_315, dout_316, dout_317, dout_318, dout_319, dout_320, dout_321, dout_322, dout_323, dout_324, dout_325, dout_326, dout_327, dout_328, dout_329, dout_330, dout_331, dout_332, dout_333, dout_334, dout_335; int avg=0;
dout_65=((B >> 7)&1)&((A >> 1)&1);
dout_72=((B >> 6)&1)&((A >> 2)&1);
dout_73=((B >> 7)&1)&((A >> 2)&1);
dout_101=((B >> 5)&1)|((B >> 6)&1);
dout_102=((B >> 5)&1)&dout_72;
dout_106=dout_65^dout_73;
dout_107=dout_65&((A >> 2)&1);
dout_108=((B >> 7)&1)&dout_102;
dout_109=dout_106^dout_102;
dout_110=dout_107|dout_108;
dout_116=dout_101&((A >> 3)&1);
dout_117=((B >> 6)&1)&((A >> 3)&1);
dout_118=((B >> 7)&1)&((A >> 3)&1);
dout_146=dout_109^dout_117;
dout_148=dout_106&dout_116;
dout_149=dout_146^dout_116;
dout_150=dout_117|dout_148;
dout_151=dout_110^dout_118;
dout_152=dout_107&((A >> 3)&1);
dout_153=dout_118&dout_150;
dout_154=dout_151^dout_150;
dout_155=dout_152|dout_153;
dout_160=((B >> 4)&1)&((A >> 4)&1);
dout_161=((B >> 5)&1)&((A >> 4)&1);
dout_162=((B >> 6)&1)&((A >> 4)&1);
dout_163=((B >> 7)&1)&((A >> 4)&1);
dout_186=dout_149^dout_161;
dout_187=dout_149&dout_161;
dout_188=dout_186&dout_160;
dout_189=dout_186^dout_160;
dout_190=dout_187|dout_188;
dout_191=dout_154^dout_162;
dout_192=dout_154&dout_162;
dout_193=dout_191&dout_190;
dout_194=dout_191^dout_190;
dout_195=dout_192|dout_193;
dout_196=dout_155^dout_163;
dout_197=dout_155&((A >> 4)&1);
dout_198=((B >> 7)&1)&dout_195;
dout_199=dout_196^dout_195;
dout_200=dout_197|dout_198;
dout_203=((B >> 2)&1)&((A >> 6)&1);
dout_205=((B >> 4)&1)&((A >> 5)&1);
dout_206=((B >> 5)&1)&((A >> 5)&1);
dout_207=((B >> 6)&1)&((A >> 5)&1);
dout_208=((B >> 7)&1)&((A >> 5)&1);
dout_222=((B >> 3)&1)&((A >> 5)&1);
dout_226=dout_189^dout_205;
dout_227=dout_189&dout_205;
dout_228=dout_226&dout_222;
dout_229=dout_226^dout_222;
dout_230=dout_227|dout_228;
dout_231=dout_194^dout_206;
dout_232=dout_194&dout_206;
dout_233=dout_231&dout_230;
dout_234=dout_231^dout_230;
dout_235=dout_232|dout_233;
dout_236=dout_199^dout_207;
dout_237=dout_199&dout_207;
dout_238=dout_236&dout_235;
dout_239=dout_236^dout_235;
dout_240=dout_237|dout_238;
dout_241=dout_200^dout_208;
dout_242=dout_200&((A >> 5)&1);
dout_243=dout_208&dout_240;
dout_244=dout_241^dout_240;
dout_245=dout_242|dout_243;
dout_249=((B >> 3)&1)&((A >> 6)&1);
dout_250=((B >> 4)&1)&((A >> 6)&1);
dout_251=((B >> 5)&1)&((A >> 6)&1);
dout_252=((B >> 6)&1)&((A >> 6)&1);
dout_253=((B >> 7)&1)&((A >> 6)&1);
dout_266=dout_229^dout_249;
dout_267=dout_229&dout_249;
dout_268=dout_266&dout_203;
dout_269=dout_266^dout_203;
dout_270=dout_267|dout_268;
dout_271=dout_234^dout_250;
dout_272=dout_234&dout_250;
dout_273=dout_271&dout_270;
dout_274=dout_271^dout_270;
dout_275=dout_272|dout_273;
dout_276=dout_239^dout_251;
dout_277=dout_239&dout_251;
dout_278=dout_276&dout_275;
dout_279=dout_276^dout_275;
dout_280=dout_277|dout_278;
dout_281=dout_244^dout_252;
dout_282=dout_244&dout_252;
dout_283=dout_281&dout_280;
dout_284=dout_281^dout_280;
dout_285=dout_282|dout_283;
dout_286=dout_245^dout_253;
dout_287=dout_245&((A >> 6)&1);
dout_288=((B >> 7)&1)&dout_285;
dout_289=dout_286^dout_285;
dout_290=dout_287|dout_288;
dout_292=((B >> 1)&1)&((A >> 7)&1);
dout_293=((B >> 2)&1)&((A >> 7)&1);
dout_294=((B >> 3)&1)&((A >> 7)&1);
dout_295=((B >> 4)&1)&((A >> 7)&1);
dout_296=((B >> 5)&1)&((A >> 7)&1);
dout_297=((B >> 6)&1)&((A >> 7)&1);
dout_298=((B >> 7)&1)&((A >> 7)&1);
dout_306=dout_269^dout_293;
dout_307=dout_269&dout_293;
dout_311=dout_274^dout_294;
dout_312=dout_274&dout_294;
dout_313=dout_311&dout_307;
dout_314=dout_311^dout_307;
dout_315=dout_312|dout_313;
dout_316=dout_279^dout_295;
dout_317=dout_279&dout_295;
dout_318=dout_316&dout_315;
dout_319=dout_316^dout_315;
dout_320=dout_317|dout_318;
dout_321=dout_284^dout_296;
dout_322=dout_284&dout_296;
dout_323=dout_321&dout_320;
dout_324=dout_321^dout_320;
dout_325=dout_322|dout_323;
dout_326=dout_289^dout_297;
dout_327=dout_289&dout_297;
dout_328=dout_326&dout_325;
dout_329=dout_326^dout_325;
dout_330=dout_327|dout_328;
dout_331=dout_290^dout_298;
dout_332=dout_290&((A >> 7)&1);
dout_333=((B >> 7)&1)&dout_330;
dout_334=dout_331^dout_330;
dout_335=dout_332|dout_333;
O = 0;
O |= (dout_249&1) << 0;
O |= (dout_293&1) << 1;
O |= (dout_312&1) << 2;
O |= (0&1) << 3;
O |= (dout_317&1) << 4;
O |= (0&1) << 5;
O |= (dout_72&1) << 6;
O |= (dout_292&1) << 7;
O |= (dout_292&1) << 8;
O |= (dout_306&1) << 9;
O |= (dout_314&1) << 10;
O |= (dout_319&1) << 11;
O |= (dout_324&1) << 12;
O |= (dout_329&1) << 13;
O |= (dout_334&1) << 14;
O |= (dout_335&1) << 15;
return O;
}
uint32_t mul16u_DAE (uint16_t a, uint16_t b) {
static uint16_t * cacheLL = NULL;
static uint16_t * cacheLH = NULL;
static uint16_t * cacheHL = NULL;
static uint16_t * cacheHH = NULL;
int fillData = cacheLL == NULL || cacheLH == NULL || cacheHL == NULL || cacheHH == NULL;
if(!cacheLL) cacheLL = (uint16_t *)malloc(256 * 256 * sizeof(uint16_t));
if(!cacheLH) cacheLH = (uint16_t *)malloc(256 * 256 * sizeof(uint16_t));
if(!cacheHL) cacheHL = (uint16_t *)malloc(256 * 256 * sizeof(uint16_t));
if(!cacheHH) cacheHH = (uint16_t *)malloc(256 * 256 * sizeof(uint16_t));
if(fillData) {
for(int i = 0; i < 256; i++) {
for(int j = 0; j < 256; j++) {
cacheLL[i * 256 + j] = mult8_cgp14zr_wc907_rcam(i, j);
cacheLH[i * 256 + j] = trun8_tam00b(i, j);
cacheHL[i * 256 + j] = mul8_364(i, j);
cacheHH[i * 256 + j] = trun8_tam00b(i, j);
}
}
}
uint32_t opt = 0;
opt += (uint32_t)cacheLL[(a & 0xFF ) * 256 + (b & 0xFF )];
opt += (uint32_t)cacheLH[(a & 0xFF ) * 256 + ((b >> 8) & 0xFF )] << 8;
opt += (uint32_t)cacheHL[((a >> 8) & 0xFF) * 256 + (b & 0xFF )] << 8;
opt += (uint32_t)cacheHH[((a >> 8) & 0xFF) * 256 + ((b >> 8) & 0xFF )] << 16;
return opt;
}