26static inline int Fxch_DivNormalize(
Vec_Int_t* vCubeFree )
28 int * L = Vec_IntArray(vCubeFree);
29 int RetValue = 0, LitA0 = -1, LitB0 = -1, LitA1 = -1, LitB1 = -1;
30 assert( Vec_IntSize(vCubeFree) == 4 );
31 if ( Abc_LitIsCompl(L[0]) != Abc_LitIsCompl(L[1]) && (L[0] >> 2) == (L[1] >> 2) )
33 if ( Abc_LitIsCompl(L[2]) == Abc_LitIsCompl(L[3]) )
35 LitA0 = Abc_Lit2Var(L[0]), LitB0 = Abc_Lit2Var(L[1]);
36 if ( Abc_LitIsCompl(L[0]) == Abc_LitIsCompl(L[2]) )
38 assert( Abc_LitIsCompl(L[1]) == Abc_LitIsCompl(L[3]) );
39 LitA1 = Abc_Lit2Var(L[2]), LitB1 = Abc_Lit2Var(L[3]);
43 assert( Abc_LitIsCompl(L[0]) == Abc_LitIsCompl(L[3]) );
44 assert( Abc_LitIsCompl(L[1]) == Abc_LitIsCompl(L[2]) );
45 LitA1 = Abc_Lit2Var(L[3]), LitB1 = Abc_Lit2Var(L[2]);
48 else if ( Abc_LitIsCompl(L[1]) != Abc_LitIsCompl(L[2]) && (L[1] >> 2) == (L[2] >> 2) )
50 if ( Abc_LitIsCompl(L[0]) == Abc_LitIsCompl(L[3]) )
52 LitA0 = Abc_Lit2Var(L[1]), LitB0 = Abc_Lit2Var(L[2]);
53 if ( Abc_LitIsCompl(L[1]) == Abc_LitIsCompl(L[0]) )
54 LitA1 = Abc_Lit2Var(L[0]), LitB1 = Abc_Lit2Var(L[3]);
56 LitA1 = Abc_Lit2Var(L[3]), LitB1 = Abc_Lit2Var(L[0]);
58 else if ( Abc_LitIsCompl(L[2]) != Abc_LitIsCompl(L[3]) && (L[2] >> 2) == (L[3] >> 2) )
60 if ( Abc_LitIsCompl(L[0]) == Abc_LitIsCompl(L[1]) )
62 LitA0 = Abc_Lit2Var(L[2]), LitB0 = Abc_Lit2Var(L[3]);
63 if ( Abc_LitIsCompl(L[2]) == Abc_LitIsCompl(L[0]) )
64 LitA1 = Abc_Lit2Var(L[0]), LitB1 = Abc_Lit2Var(L[1]);
66 LitA1 = Abc_Lit2Var(L[1]), LitB1 = Abc_Lit2Var(L[0]);
70 assert( LitA0 == Abc_LitNot(LitB0) );
71 if ( Abc_LitIsCompl(LitA0) )
76 assert( !Abc_LitIsCompl(LitA0) );
77 if ( Abc_LitIsCompl(LitA1) )
79 LitA1 = Abc_LitNot(LitA1);
80 LitB1 = Abc_LitNot(LitB1);
83 assert( !Abc_LitIsCompl(LitA1) );
88 L[0] = Abc_Var2Lit( LitA0, 0 );
89 L[1] = Abc_Var2Lit( LitB0, 1 );
90 L[2] = Abc_Var2Lit( LitA1, 0 );
91 L[3] = Abc_Var2Lit( LitB1, 1 );
128 SC0_Lit0 = Fxch_ManGetLit( pFxchMan, pSubCube0->
iCube, pSubCube0->
iLit0 );
130 SC1_Lit0 = Fxch_ManGetLit( pFxchMan, pSubCube1->
iCube, pSubCube1->
iLit0 );
133 if ( pSubCube0->
iLit1 == 0 && pSubCube1->
iLit1 == 0 )
135 Vec_IntPush( pFxchMan->
vCubeFree, SC0_Lit0 );
136 Vec_IntPush( pFxchMan->
vCubeFree, SC1_Lit0 );
138 else if ( pSubCube0->
iLit1 > 0 && pSubCube1->
iLit1 > 0 )
142 SC0_Lit1 = Fxch_ManGetLit( pFxchMan, pSubCube0->
iCube, pSubCube0->
iLit1 );
143 SC1_Lit1 = Fxch_ManGetLit( pFxchMan, pSubCube1->
iCube, pSubCube1->
iLit1 );
145 if ( SC0_Lit0 < SC1_Lit0 )
147 Vec_IntPush( pFxchMan->
vCubeFree, Abc_Var2Lit( SC0_Lit0, 0 ) );
148 Vec_IntPush( pFxchMan->
vCubeFree, Abc_Var2Lit( SC1_Lit0, 1 ) );
149 Vec_IntPush( pFxchMan->
vCubeFree, Abc_Var2Lit( SC0_Lit1, 0 ) );
150 Vec_IntPush( pFxchMan->
vCubeFree, Abc_Var2Lit( SC1_Lit1, 1 ) );
154 Vec_IntPush( pFxchMan->
vCubeFree, Abc_Var2Lit( SC1_Lit0, 0 ) );
155 Vec_IntPush( pFxchMan->
vCubeFree, Abc_Var2Lit( SC0_Lit0, 1 ) );
156 Vec_IntPush( pFxchMan->
vCubeFree, Abc_Var2Lit( SC1_Lit1, 0 ) );
157 Vec_IntPush( pFxchMan->
vCubeFree, Abc_Var2Lit( SC0_Lit1, 1 ) );
160 RetValue = Fxch_DivNormalize( pFxchMan->
vCubeFree );
161 if ( RetValue == -1 )
166 if ( pSubCube0->
iLit1 > 0 )
168 SC0_Lit1 = Fxch_ManGetLit( pFxchMan, pSubCube0->
iCube, pSubCube0->
iLit1 );
170 Vec_IntPush( pFxchMan->
vCubeFree, SC1_Lit0 );
171 if ( SC0_Lit0 == Abc_LitNot( SC1_Lit0 ) )
172 Vec_IntPush( pFxchMan->
vCubeFree, SC0_Lit1 );
173 else if ( SC0_Lit1 == Abc_LitNot( SC1_Lit0 ) )
174 Vec_IntPush( pFxchMan->
vCubeFree, SC0_Lit0 );
178 SC1_Lit1 = Fxch_ManGetLit( pFxchMan, pSubCube1->
iCube, pSubCube1->
iLit1 );
180 Vec_IntPush( pFxchMan->
vCubeFree, SC0_Lit0 );
181 if ( SC1_Lit0 == Abc_LitNot( SC0_Lit0 ) )
182 Vec_IntPush( pFxchMan->
vCubeFree, SC1_Lit1 );
183 else if ( SC1_Lit1 == Abc_LitNot( SC0_Lit0 ) )
184 Vec_IntPush( pFxchMan->
vCubeFree, SC1_Lit0 );
188 if ( Vec_IntSize( pFxchMan->
vCubeFree ) == 0 )
191 if ( Vec_IntSize ( pFxchMan->
vCubeFree ) == 2 )
195 Vec_IntWriteEntry( pFxchMan->
vCubeFree, 0, Abc_Var2Lit( Vec_IntEntry( pFxchMan->
vCubeFree, 0 ), 0 ) );
196 Vec_IntWriteEntry( pFxchMan->
vCubeFree, 1, Abc_Var2Lit( Vec_IntEntry( pFxchMan->
vCubeFree, 1 ), 1 ) );
199 Cube0Size = Vec_IntSize( Fxch_ManGetCube( pFxchMan, pSubCube0->
iCube ) );
200 Cube1Size = Vec_IntSize( Fxch_ManGetCube( pFxchMan, pSubCube1->
iCube ) );
201 if ( Vec_IntSize( pFxchMan->
vCubeFree ) % 2 == 0 )
203 Base = Abc_MinInt( Cube0Size, Cube1Size )
204 -( Vec_IntSize( pFxchMan->
vCubeFree ) / 2) - 1;
236 if ( iDiv == Vec_FltSize( pFxchMan->
vDivWeights ) )
244 -Vec_IntSize( pFxchMan->
vCubeFree ) + 0.9
250 -Vec_IntSize( pFxchMan->
vCubeFree ) + 0.9
258 Vec_FltAddToEntry( pFxchMan->
vDivWeights, iDiv, 1 );
260 Vec_FltAddToEntry( pFxchMan->
vDivWeights, iDiv, fBase + Vec_IntSize( pFxchMan->
vCubeFree ) - 1 );
267 if ( Vec_QueIsMember( pFxchMan->
vDivPrio, iDiv ) )
268 Vec_QueUpdate( pFxchMan->
vDivPrio, iDiv );
270 Vec_QuePush( pFxchMan->
vDivPrio, iDiv );
302 Vec_FltAddToEntry( pFxchMan->
vDivWeights, iDiv, -1 );
304 Vec_FltAddToEntry( pFxchMan->
vDivWeights, iDiv, -( fBase + Vec_IntSize( pFxchMan->
vCubeFree ) - 1 ) );
309 if ( Vec_QueIsMember( pFxchMan->
vDivPrio, iDiv ) )
310 Vec_QueUpdate( pFxchMan->
vDivPrio, iDiv );
348 if ( Abc_LitIsCompl(Lit) )
349 Vec_IntPush( vCube1, Abc_Lit2Var( Lit ) );
351 Vec_IntPush( vCube0, Abc_Lit2Var( Lit ) );
353 if ( ( Vec_IntSize( vDiv ) == 4 ) && ( Vec_IntSize( vCube0 ) == 3 ) )
355 assert( Vec_IntSize( vCube1 ) == 3 );
357 pArray = Vec_IntArray( vCube0 );
358 if ( pArray[1] > pArray[2] )
359 ABC_SWAP(
int, pArray[1], pArray[2] );
361 pArray = Vec_IntArray( vCube1 );
362 if ( pArray[1] > pArray[2] )
363 ABC_SWAP(
int, pArray[1], pArray[2] );
393 if ( Abc_LitIsCompl( Abc_Lit2Var( Lit ) ) )
394 CountN += Vec_IntRemove1( vCube0, Abc_Lit2Var( Lit ) );
396 CountP += Vec_IntRemove1( vCube0, Abc_Lit2Var( Lit ) );
399 Count += Vec_IntRemove1( vCube1, Abc_Lit2Var( Lit ) );
401 if ( Vec_IntSize( vDiv ) == 2 )
404 Vec_IntRemove1( vCube0, Abc_LitNot( Abc_Lit2Var( Lit ) ) );
405 Vec_IntRemove1( vCube1, Abc_LitNot( Abc_Lit2Var( Lit ) ) );
408 ret = Count + CountP + CountN;
410 if ( Vec_IntSize( vDiv ) == 4 )
412 int Lit0 = Abc_Lit2Var( Vec_IntEntry( vDiv, 0 ) ),
413 Lit1 = Abc_Lit2Var( Vec_IntEntry( vDiv, 1 ) ),
414 Lit2 = Abc_Lit2Var( Vec_IntEntry( vDiv, 2 ) ),
415 Lit3 = Abc_Lit2Var( Vec_IntEntry( vDiv, 3 ) );
417 if ( Lit0 == Abc_LitNot( Lit1 ) && Lit2 == Abc_LitNot( Lit3 ) && CountN == 1 )
420 if ( Lit0 == Abc_LitNot( Lit1 ) && ret == 2 )
425 ret += Vec_IntRemove1( vCube0, ( Abc_Lit2Var( Lit ) ^ (fCompl && i > 1) ) );
428 ret += Vec_IntRemove1( vCube1, ( Abc_Lit2Var( Lit ) ^ (fCompl && i > 1) ) );
453 printf(
"Div %7d : ", iDiv );
454 printf(
"Weight %12.5f ", Vec_FltEntry( pFxchMan->
vDivWeights, iDiv ) );
457 if ( !Abc_LitIsCompl( Lit ) )
458 printf(
"%d(1)", Abc_Lit2Var( Lit ) );
463 if ( Abc_LitIsCompl( Lit ) )
464 printf(
"%d(2)", Abc_Lit2Var( Lit ) );
466 printf(
" Lits =%7d ", pFxchMan->
nLits );
467 printf(
"Divs =%8d \n", Hsh_VecSize( pFxchMan->
pDivHash ) );
472 int Lit0 = Abc_Lit2Var( Vec_IntEntry( vDiv, 0 ) ),
473 Lit1 = Abc_Lit2Var( Vec_IntEntry( vDiv, 1 ) );
475 if ( ( Vec_IntSize( vDiv ) == 2 ) && ( Lit0 == Abc_LitNot( Lit1 ) ) )
int Fxch_DivAdd(Fxch_Man_t *pFxchMan, int fUpdate, int fSingleCube, int fBase)
int Fxch_DivRemoveLits(Vec_Int_t *vCube0, Vec_Int_t *vCube1, Vec_Int_t *vDiv, int *fCompl)
int Fxch_DivIsNotConstant1(Vec_Int_t *vDiv)
int Fxch_DivCreate(Fxch_Man_t *pFxchMan, Fxch_SubCube_t *pSubCube0, Fxch_SubCube_t *pSubCube1)
void Fxch_DivSepareteCubes(Vec_Int_t *vDiv, Vec_Int_t *vCube0, Vec_Int_t *vCube1)
void Fxch_DivPrint(Fxch_Man_t *pFxchMan, int iDiv)
int Fxch_DivRemove(Fxch_Man_t *pFxchMan, int fUpdate, int fSingleCube, int fBase)
int Fxch_ManComputeLevelDiv(Fxch_Man_t *pFxchMan, Vec_Int_t *vCubeFree)
struct Fxch_SubCube_t_ Fxch_SubCube_t
#define ABC_SWAP(Type, a, b)
#define ABC_NAMESPACE_IMPL_START
#define ABC_NAMESPACE_IMPL_END
typedefABC_NAMESPACE_IMPL_START struct Vec_Int_t_ Vec_Int_t
DECLARATIONS ///.
struct Fxch_Man_t_ Fxch_Man_t
TYPEDEF DECLARATIONS ///.
Vec_Wec_t * vDivCubePairs
#define Vec_IntForEachEntry(vVec, Entry, i)
MACRO DEFINITIONS ///.