21#ifndef ABC__map__mio__exp_h
22#define ABC__map__mio__exp_h
49 vExp = Vec_IntAlloc( 1 );
56 vExp = Vec_IntAlloc( 1 );
72static inline Vec_Int_t * Exp_Var(
int iVar )
75 vExp = Vec_IntAlloc( 1 );
76 Vec_IntPush( vExp, 2 * iVar );
79static inline int Exp_LitShift(
int nVars,
int Lit,
int Shift )
81 if ( Lit < 2 * nVars )
83 return Lit + 2 * Shift;
87 return Vec_IntSize(
p) == 1 && !Exp_IsConst(
p);
91 return Vec_IntSize(
p)/2;
95 Vec_IntWriteEntry(
p, 0, Vec_IntEntry(
p,0) ^ 1 );
98static inline void Exp_PrintLit(
int nVars,
int Lit )
101 Abc_Print( 1,
"Const0" );
103 Abc_Print( 1,
"Const1" );
104 else if ( Lit < 2 * nVars )
105 Abc_Print( 1,
"%s%c", (Lit&1) ?
"!" :
" ",
'a' + Lit/2 );
107 Abc_Print( 1,
"%s%d", (Lit&1) ?
"!" :
" ", Lit/2 );
109static inline void Exp_Print(
int nVars,
Vec_Int_t *
p )
112 for ( i = 0; i < Exp_NodeNum(
p); i++ )
114 Abc_Print( 1,
"%2d = ", nVars + i );
115 Exp_PrintLit( nVars, Vec_IntEntry(
p, 2*i+0) );
116 Abc_Print( 1,
" & " );
117 Exp_PrintLit( nVars, Vec_IntEntry(
p, 2*i+1) );
118 Abc_Print( 1,
"\n" );
120 Abc_Print( 1,
" F = " );
121 Exp_PrintLit( nVars, Vec_IntEntryLast(
p) );
122 Abc_Print( 1,
"\n" );
126 Vec_IntReverseOrder(
p );
129static inline void Exp_PrintReverse(
int nVars,
Vec_Int_t *
p )
132 Exp_Print( nVars,
p );
137 int i, Len0 = Vec_IntSize(p0), Len1 = Vec_IntSize(p1);
138 Vec_Int_t * r = Vec_IntAlloc( Len0 + Len1 + 1 );
139 assert( (Len0 & 1) && (Len1 & 1) );
140 Vec_IntPush( r, 2 * (nVars + Len0/2 + Len1/2) );
141 Vec_IntPush( r, Exp_LitShift( nVars, Vec_IntEntry(p0, 0) ^ fCompl0, Len1/2 ) );
142 Vec_IntPush( r, Vec_IntEntry(p1, 0) ^ fCompl1 );
143 for ( i = 1; i < Len0; i++ )
144 Vec_IntPush( r, Exp_LitShift( nVars, Vec_IntEntry(p0, i), Len1/2 ) );
145 for ( i = 1; i < Len1; i++ )
146 Vec_IntPush( r, Vec_IntEntry(p1, i) );
147 assert( Vec_IntSize(r) == Len0 + Len1 + 1 );
152 return Exp_Not( Exp_And(pMan, nVars, p0, p1, 1, 1) );
156 int i, Len0 = Vec_IntSize(p0), Len1 = Vec_IntSize(p1);
157 Vec_Int_t * r = Vec_IntAlloc( Len0 + Len1 + 5 );
158 assert( (Len0 & 1) && (Len1 & 1) );
159 Vec_IntPush( r, 2 * (nVars + Len0/2 + Len1/2 + 2) );
160 Vec_IntPush( r, 2 * (nVars + Len0/2 + Len1/2 + 1) + 1 );
161 Vec_IntPush( r, 2 * (nVars + Len0/2 + Len1/2 + 0) + 1 );
162 Vec_IntPush( r, Exp_LitShift( nVars, Vec_IntEntry(p0, 0) ^ 1, Len1/2 ) );
163 Vec_IntPush( r, Vec_IntEntry(p1, 0) );
164 Vec_IntPush( r, Exp_LitShift( nVars, Vec_IntEntry(p0, 0), Len1/2 ) );
165 Vec_IntPush( r, Vec_IntEntry(p1, 0) ^ 1 );
166 for ( i = 1; i < Len0; i++ )
167 Vec_IntPush( r, Exp_LitShift( nVars, Vec_IntEntry(p0, i), Len1/2 ) );
168 for ( i = 1; i < Len1; i++ )
169 Vec_IntPush( r, Vec_IntEntry(p1, i) );
170 assert( Vec_IntSize(r) == Len0 + Len1 + 5 );
173static inline word Exp_Truth6Lit(
int nVars,
int Lit,
word * puFanins,
word * puNodes )
179 if ( Lit < 2 * nVars )
180 return (Lit&1) ? ~puFanins[Lit/2] : puFanins[Lit/2];
181 return (Lit&1) ? ~puNodes[Lit/2-nVars] : puNodes[Lit/2-nVars];
185 static word Truth6[6] = {
195 if ( puFanins == NULL )
196 puFanins = (
word *)Truth6;
198 for ( i = 0; i < Exp_NodeNum(
p); i++ )
199 puNodes[i] = Exp_Truth6Lit( nVars, Vec_IntEntry(
p, 2*i+0), puFanins, puNodes ) &
200 Exp_Truth6Lit( nVars, Vec_IntEntry(
p, 2*i+1), puFanins, puNodes );
201 Res = Exp_Truth6Lit( nVars, Vec_IntEntryLast(
p), puFanins, puNodes );
205static inline void Exp_Truth8(
int nVars,
Vec_Int_t *
p,
word ** puFanins,
word * puRes )
207 word Truth8[8][4] = {
217 word * puFaninsInt[8], * pStore, * pThis = NULL;
218 int i, k, iRoot = Vec_IntEntryLast(
p);
219 if ( puFanins == NULL )
221 puFanins = puFaninsInt;
222 for ( k = 0; k < 8; k++ )
223 puFanins[k] = Truth8[k];
225 if ( Exp_NodeNum(
p) == 0 )
227 assert( iRoot < 2 * nVars );
229 for ( k = 0; k < 4; k++ )
232 for ( k = 0; k < 4; k++ )
233 puRes[k] = Abc_LitIsCompl(iRoot) ? ~puFanins[Abc_Lit2Var(iRoot)][k] : puFanins[Abc_Lit2Var(iRoot)][k];
237 for ( i = 0; i < Exp_NodeNum(
p); i++ )
239 int iVar0 = Abc_Lit2Var( Vec_IntEntry(
p, 2*i+0) );
240 int iVar1 = Abc_Lit2Var( Vec_IntEntry(
p, 2*i+1) );
241 int fCompl0 = Abc_LitIsCompl( Vec_IntEntry(
p, 2*i+0) );
242 int fCompl1 = Abc_LitIsCompl( Vec_IntEntry(
p, 2*i+1) );
243 word * pIn0 = iVar0 < nVars ? puFanins[iVar0] : pStore + 4 * (iVar0 - nVars);
244 word * pIn1 = iVar1 < nVars ? puFanins[iVar1] : pStore + 4 * (iVar1 - nVars);
245 pThis = pStore + 4 * i;
246 if ( fCompl0 && fCompl1 )
247 for ( k = 0; k < 4; k++ )
248 pThis[k] = ~pIn0[k] & ~pIn1[k];
249 else if ( fCompl0 && !fCompl1 )
250 for ( k = 0; k < 4; k++ )
251 pThis[k] = ~pIn0[k] & pIn1[k];
252 else if ( !fCompl0 && fCompl1 )
253 for ( k = 0; k < 4; k++ )
254 pThis[k] = pIn0[k] & ~pIn1[k];
256 for ( k = 0; k < 4; k++ )
257 pThis[k] = pIn0[k] & pIn1[k];
259 assert( Abc_Lit2Var(iRoot) - nVars == i - 1 );
260 for ( k = 0; k < 4; k++ )
261 puRes[k] = Abc_LitIsCompl(iRoot) ? ~pThis[k] : pThis[k];
264static inline void Exp_TruthLit(
int nVars,
int Lit,
word ** puFanins,
word ** puNodes,
word * pRes,
int nWords )
268 for ( w = 0; w <
nWords; w++ )
271 for ( w = 0; w <
nWords; w++ )
273 else if ( Lit < 2 * nVars )
274 for ( w = 0; w <
nWords; w++ )
275 pRes[w] = (Lit&1) ? ~puFanins[Lit/2][w] : puFanins[Lit/2][w];
277 for ( w = 0; w <
nWords; w++ )
278 pRes[w] = (Lit&1) ? ~puNodes[Lit/2-nVars][w] : puNodes[Lit/2-nVars][w];
280static inline void Exp_Truth(
int nVars,
Vec_Int_t *
p,
word * pRes )
282 static word Truth6[6] = {
290 word ** puFanins, ** puNodes, * pTemp0, * pTemp1;
291 int i, w,
nWords = (nVars <= 6 ? 1 : 1 << (nVars-6));
294 for ( i = 0; i < nVars; i++ )
297 for ( i = 0; i < nVars; i++ )
299 for ( w = 0; w <
nWords; w++ )
300 puFanins[i][w] = Truth6[i];
302 for ( w = 0; w <
nWords; w++ )
303 puFanins[i][w] = (w & (1 << (i-6))) ? ~(
word)0 : 0;
306 for ( i = 0; i < Exp_NodeNum(
p); i++ )
311 for ( i = 0; i < Exp_NodeNum(
p); i++ )
313 Exp_TruthLit( nVars, Vec_IntEntry(
p, 2*i+0), puFanins, puNodes, pTemp0,
nWords );
314 Exp_TruthLit( nVars, Vec_IntEntry(
p, 2*i+1), puFanins, puNodes, pTemp1,
nWords );
315 for ( w = 0; w <
nWords; w++ )
316 puNodes[i][w] = pTemp0[w] & pTemp1[w];
321 Exp_TruthLit( nVars, Vec_IntEntryLast(
p), puFanins, puNodes, pRes,
nWords );
323 for ( i = 0; i < nVars; i++ )
326 for ( i = 0; i < Exp_NodeNum(
p); i++ )
#define ABC_ALLOC(type, num)
#define ABC_CALLOC(type, num)
#define ABC_CONST(number)
PARAMETERS ///.
#define ABC_NAMESPACE_HEADER_END
#define ABC_NAMESPACE_HEADER_START
NAMESPACES ///.
typedefABC_NAMESPACE_IMPL_START struct Vec_Int_t_ Vec_Int_t
DECLARATIONS ///.
#define EXP_CONST0
INCLUDES ///.
unsigned __int64 word
DECLARATIONS ///.