5 # let "macc" implement a function like Y = (A*B) + (C*D)
7 # the following permutations of the input pins exist:
9 # g01 | A B C D | match
10 # g02 | A B D C | match
15 # g07 | B A C D | match
16 # g08 | B A D C | match
25 # g17 | C D A B | match
26 # g18 | C D B A | match
31 # g23 | D C A B | match
32 # g24 | D C B A | match
34 my @matches = qw
/g01 g02 g07 g08 g17 g18 g23 g24/;
35 my @non_matches = qw
/g03 g04 g05 g06 g09 g10 g11 g12 g13 g14 g15 g16 g19 g20 g21 g22/;
44 print splice(@t,$i,1),splice(@t,$j,1),splice(@t,$k,1),$t[0];
55 printf "graph g%02d\n", $iter++;
56 printf " node input input A 32 1 B 32 1 C 32 1 D 32 1\n";
57 printf " node macc macc A 32 1 B 32 1 C 32 1 D 32 1\n";
58 printf " connect input A macc %s\n", splice(@t,$i,1);
59 printf " connect input B macc %s\n", splice(@t,$j,1);
60 printf " connect input C macc %s\n", splice(@t,$k,1);
61 printf " connect input D macc %s\n", splice(@t,0,1);
71 my $id = sprintf "_%02d", $iter++;
73 printf " node input$id input A 16 B 16 C 16 D 16\n";
74 printf " node macc$id macc A 16 B 16 C 16 D 16\n";
75 printf " connect input$id A macc$id %s\n", splice(@t,$i,1);
76 printf " connect input$id B macc$id %s\n", splice(@t,$j,1);
77 printf " connect input$id C macc$id %s\n", splice(@t,$k,1);
78 printf " connect input$id D macc$id %s\n", splice(@t,0,1);
84 printf "swapgroup macc A B\n";
85 printf "swapgroup macc C D\n";
86 printf "swapperm macc A B C D : C D A B\n";
88 for my $i (@matches) {
89 for my $j (@non_matches) {
90 printf "solve %s %s\n", $i, $j;
92 printf "expect 0\n\n";
94 for my $i (@matches) {
95 for my $j (@matches) {
96 printf "solve %s %s\n", $i, $j;
98 printf "expect %d\n\n", @matches*@matches;
100 printf "solve g01 gXL false\n";
103 printf "solve g03 gXL false\n";
106 printf "solve g04 gXL false\n";