ABC: A System for Sequential Synthesis and Verification
 
Loading...
Searching...
No Matches
ac_wrapper.cpp
Go to the documentation of this file.
1
18
19#include "ac_wrapper.h"
20#include "ac_decomposition.hpp"
21#include "acd66.hpp"
22#include "acdXX.hpp"
23
25
26int acd_evaluate( word * pTruth, unsigned nVars, int lutSize, unsigned *pdelay, unsigned *cost, int try_no_late_arrival )
27{
28 using namespace acd;
29
31 ps.lut_size = lutSize;
32 ps.use_first = false;
33 ps.try_no_late_arrival = static_cast<bool>( try_no_late_arrival );
35
36 ac_decomposition_impl acd( nVars, ps, &st );
37 int val = acd.run( pTruth, *pdelay );
38
39 if ( val < 0 )
40 {
41 *pdelay = 0;
42 return -1;
43 }
44
45 *pdelay = acd.get_profile();
46 *cost = st.num_luts;
47
48 return val;
49}
50
51int acd_decompose( word * pTruth, unsigned nVars, int lutSize, unsigned *pdelay, unsigned char *decomposition )
52{
53 using namespace acd;
54
56 ps.lut_size = lutSize;
57 ps.use_first = true;
59
60 ac_decomposition_impl acd( nVars, ps, &st );
61 acd.run( pTruth, *pdelay );
62 int val = acd.compute_decomposition();
63
64 if ( val < 0 )
65 {
66 *pdelay = 0;
67 return -1;
68 }
69
70 *pdelay = acd.get_profile();
71 acd.get_decomposition( decomposition );
72 return 0;
73}
74
75int acd2_evaluate( word * pTruth, unsigned nVars, int lutSize, unsigned *pdelay, unsigned *cost, int try_no_late_arrival )
76{
77 using namespace acd;
78
79 acdXX_params ps;
80 ps.lut_size = lutSize;
81 ps.max_shared_vars = lutSize - 2;
82 acdXX_impl acd( nVars, ps );
83 int val = acd.run( pTruth, *pdelay );
84
85 if ( val == 0 )
86 {
87 *pdelay = 0;
88 return -1;
89 }
90
91 acd.compute_decomposition();
92 *pdelay = acd.get_profile();
93 *cost = 2;
94
95 return val;
96}
97
98int acd2_decompose( word * pTruth, unsigned nVars, int lutSize, unsigned *pdelay, unsigned char *decomposition )
99{
100 using namespace acd;
101
102 acdXX_params ps;
103 ps.lut_size = lutSize;
104 ps.max_shared_vars = lutSize - 2;
105 acdXX_impl acd( nVars, ps );
106 acd.run( pTruth, *pdelay );
107 int val = acd.compute_decomposition();
108
109 if ( val != 0 )
110 {
111 *pdelay = 0;
112 return -1;
113 }
114
115 *pdelay = acd.get_profile();
116
117 acd.get_decomposition( decomposition );
118 return 0;
119}
120
121inline int acd66_evaluate( word * pTruth, unsigned nVars )
122{
123 using namespace acd;
124
125 acd66_impl acd( nVars, true, false );
126
127 if ( acd.run( pTruth ) == 0 )
128 return 0;
129
130 return 1;
131}
132
133int acdXX_evaluate( word * pTruth, unsigned lutSize, unsigned nVars )
134{
135 using namespace acd;
136
137 if ( lutSize == 6 )
138 {
139 return acd66_evaluate( pTruth, nVars );
140 }
141
142 acdXX_params ps;
143 ps.lut_size = lutSize;
144 ps.max_shared_vars = lutSize - 2;
145 acdXX_impl acd( nVars, ps );
146
147 if ( acd.run( pTruth ) == 0 )
148 return 0;
149
150 return 1;
151}
152
153int acdXX_decompose( word * pTruth, unsigned lutSize, unsigned nVars, unsigned char *decomposition )
154{
155 using namespace acd;
156
157 acdXX_params ps;
158 ps.lut_size = lutSize;
159
160 for ( int i = 0; i <= lutSize - 2; ++i )
161 {
162 ps.max_shared_vars = i;
163 ps.min_shared_vars = i;
164 acdXX_impl acd( nVars, ps );
165
166 if ( acd.run( pTruth ) == 0 )
167 continue;
168 acd.compute_decomposition();
169 acd.get_decomposition( decomposition );
170 return 0;
171 }
172
173 return 1;
174}
175
#define ABC_NAMESPACE_IMPL_START
#define ABC_NAMESPACE_IMPL_END
Ashenhurst-Curtis decomposition.
int acd_decompose(word *pTruth, unsigned nVars, int lutSize, unsigned *pdelay, unsigned char *decomposition)
int acdXX_decompose(word *pTruth, unsigned lutSize, unsigned nVars, unsigned char *decomposition)
int acd66_evaluate(word *pTruth, unsigned nVars)
int acdXX_evaluate(word *pTruth, unsigned lutSize, unsigned nVars)
ABC_NAMESPACE_IMPL_START int acd_evaluate(word *pTruth, unsigned nVars, int lutSize, unsigned *pdelay, unsigned *cost, int try_no_late_arrival)
int acd2_evaluate(word *pTruth, unsigned nVars, int lutSize, unsigned *pdelay, unsigned *cost, int try_no_late_arrival)
int acd2_decompose(word *pTruth, unsigned nVars, int lutSize, unsigned *pdelay, unsigned char *decomposition)
Ashenhurst-Curtis decomposition for "66" cascade.
Ashenhurst-Curtis decomposition for "XX" cascade.
unsigned __int64 word
DECLARATIONS ///.
Definition kitPerm.c:36
Parameters for ac_decomposition.
bool use_first
Use the first feasible decomposition found.
bool try_no_late_arrival
If decomposition with delay profile fails, try without.
uint32_t lut_size
LUT size for decomposition (3 < num < 7).
Statistics for ac_decomposition.
uint32_t lut_size
Definition acdXX.hpp:55
uint32_t max_shared_vars
Definition acdXX.hpp:58
uint32_t min_shared_vars
Definition acdXX.hpp:61