46static inline word * Gia_ManQuantInfoId(
Gia_Man_t *
p,
int iObj ) {
return Vec_WrdEntryP(
p->vSuppWords,
p->nSuppWords * iObj ); }
47static inline word * Gia_ManQuantInfo(
Gia_Man_t *
p,
Gia_Obj_t * pObj ) {
return Gia_ManQuantInfoId(
p, Gia_ObjId(
p, pObj) ); }
49static inline void Gia_ObjCopyGetTwoArray(
Gia_Man_t *
p,
int iObj,
int LitsOut[2] )
51 int * pLits = Vec_IntEntryP( &
p->vCopiesTwo, 2*iObj );
52 LitsOut[0] = pLits[0];
53 LitsOut[1] = pLits[1];
55static inline void Gia_ObjCopySetTwoArray(
Gia_Man_t *
p,
int iObj,
int LitsIn[2] )
57 int * pLits = Vec_IntEntryP( &
p->vCopiesTwo, 2*iObj );
77 if ( Gia_ObjIsTravIdCurrentId(
p, iObj ) )
79 Gia_ObjSetTravIdCurrentId(
p, iObj );
80 pObj = Gia_ManObj(
p, iObj );
81 if ( Gia_ObjIsCi(pObj) )
82 return Gia_ObjCioId(pObj) == CiId;
88 word * pInfo = Gia_ManQuantInfoId(
p, iObj );
int i, CiId;
89 assert( Gia_ObjIsAnd(Gia_ManObj(
p, iObj)) );
94 printf(
"Mismatch at node %d related to CI %d (%d).\n", iObj, CiId, Abc_TtGetBit(pInfo, i) );
102 assert( Gia_ManObjNum(
p) == 1 );
103 assert(
p->vSuppWords == NULL );
104 assert( Vec_IntSize(&
p->vSuppVars) == 0 );
107 p->vSuppWords = Vec_WrdAlloc( 1000 );
108 Vec_WrdPush(
p->vSuppWords, 0 );
113 for ( w = 0; w <
p->nSuppWords; w++ )
114 Vec_WrdPush(
p->vSuppWords, 0 );
115 assert( Vec_WrdSize(
p->vSuppWords) ==
p->nSuppWords * Gia_ManObjNum(
p) );
119 assert( Gia_ObjIsCi(pObj) );
120 assert(
p->vSuppWords != NULL );
121 if (
p->iSuppPi == 64 *
p->nSuppWords )
123 word Data;
int w, Count = 0, Size = Vec_WrdSize(
p->vSuppWords);
124 Vec_Wrd_t * vTemp = Vec_WrdAlloc( Size ? 2 * Size : 1000 );
127 Vec_WrdPush( vTemp, Data );
128 if ( ++Count ==
p->nSuppWords )
130 Vec_WrdPush( vTemp, 0 );
134 Vec_WrdFree(
p->vSuppWords );
135 p->vSuppWords = vTemp;
137 assert( Vec_WrdSize(
p->vSuppWords) ==
p->nSuppWords * Gia_ManObjNum(
p) );
140 assert(
p->iSuppPi == Vec_IntSize(&
p->vSuppVars) );
141 Vec_IntPush( &
p->vSuppVars, Gia_ObjCioId(pObj) );
142 Abc_TtSetBit( Gia_ManQuantInfo(
p, pObj),
p->iSuppPi++ );
146 int iObj = Gia_ObjId(
p, pObj);
147 int iFan0 = Gia_ObjFaninId0(pObj, iObj);
148 int iFan1 = Gia_ObjFaninId1(pObj, iObj);
149 assert( Gia_ObjIsAnd(pObj) );
151 Abc_TtOr( Gia_ManQuantInfo(
p, pObj), Gia_ManQuantInfoId(
p, iFan0), Gia_ManQuantInfoId(
p, iFan1),
p->nSuppWords );
155 return Abc_TtGetBit( Gia_ManQuantInfoId(
p, iObj), iSupp );
159 if ( Abc_TtIsConst0( Gia_ManQuantInfoId(
p, iObj),
p->nSuppWords ) )
161 assert( !Abc_TtIsConst0( Gia_ManQuantInfoId(
p, iObj),
p->nSuppWords ) );
165 return Abc_TtIntersect( Gia_ManQuantInfoId(
p, iObj), Gia_ManQuantInfoId(
p, 0),
p->nSuppWords, 0 );
170 word * pInfo = Gia_ManQuantInfoId(
p, 0 );
171 Abc_TtClear( pInfo,
p->nSuppWords );
172 assert( Abc_TtIsConst0(pInfo,
p->nSuppWords) );
174 if ( !pFuncCiToKeep( pData, CiId ) )
175 Abc_TtSetBit( pInfo, i );
181 if ( Gia_ObjIsTravIdCurrentId(
p, iObj ) )
183 Gia_ObjSetTravIdCurrentId(
p, iObj );
184 pObj = Gia_ManObj(
p, iObj );
185 if ( Gia_ObjIsCi(pObj) )
201 int iLit0, iLit1, iObj = Gia_ObjId(
p, pObj );
202 int iLit = Gia_ObjCopyArray(
p, iObj );
205 if ( Gia_ObjIsCi(pObj) )
207 int iLit = Gia_ManAppendCi( pNew );
208 Gia_Obj_t * pObjNew = Gia_ManObj( pNew, Abc_Lit2Var(iLit) );
210 if ( !pFuncCiToKeep( pData, Gia_ObjCioId(pObj) ) )
215 Gia_ObjSetCopyArray(
p, iObj, iLit );
216 Vec_IntPush( vCis, iObj );
219 assert( Gia_ObjIsAnd(pObj) );
222 iLit0 = Gia_ObjCopyArray(
p, Gia_ObjFaninId0(pObj, iObj) );
223 iLit1 = Gia_ObjCopyArray(
p, Gia_ObjFaninId1(pObj, iObj) );
224 iLit0 = Abc_LitNotCond( iLit0, Gia_ObjFaninC0(pObj) );
225 iLit1 = Abc_LitNotCond( iLit1, Gia_ObjFaninC1(pObj) );
227 Gia_ObjSetCopyArray(
p, iObj, iLit );
228 Vec_IntPush( vObjs, iObj );
233 Gia_Obj_t * pObj, * pRoot = Gia_ManObj(
p, Abc_Lit2Var(iLit) );
235 Vec_Int_t * vObjs = Vec_IntAlloc( 1000 );
236 assert( Gia_ObjIsAnd(pRoot) );
237 if ( Vec_IntSize(&
p->vCopies) < Gia_ManObjNum(
p) )
238 Vec_IntFillExtra( &
p->vCopies, Gia_ManObjNum(
p), -1 );
243 iLit0 = Gia_ObjCopyArray(
p, Abc_Lit2Var(iLit) );
244 iLit0 = Abc_LitNotCond( iLit0, Abc_LitIsCompl(iLit) );
245 if ( pOutLit ) *pOutLit = iLit0;
247 Gia_ObjSetCopyArray(
p, Gia_ObjId(
p, pObj), -1 );
249 Gia_ObjSetCopyArray(
p, Gia_ObjId(
p, pObj), -1 );
251 Vec_IntFree( vObjs );
254 Vec_IntWriteEntry( vCis, i, Gia_ManIdToCioId(
p, iObj) );
255 if ( pvCis ) *pvCis = vCis;
261 int Lits0[2], Lits1[2], pFans[2], fCompl[2];
262 if ( Gia_ObjIsTravIdCurrentId(
p, iObj ) )
264 Gia_ObjCopyGetTwoArray(
p, iObj, pRes );
267 Gia_ObjSetTravIdCurrentId(
p, iObj );
268 pObj = Gia_ManObj(
p, iObj );
269 if ( Gia_ObjIsCi(pObj) )
271 pRes[0] = 0; pRes[1] = 1;
272 Gia_ObjCopySetTwoArray(
p, iObj, pRes );
275 pFans[0] = Gia_ObjFaninId0( pObj, iObj );
276 pFans[1] = Gia_ObjFaninId1( pObj, iObj );
277 fCompl[0] = Gia_ObjFaninC0( pObj );
278 fCompl[1] = Gia_ObjFaninC1( pObj );
282 Lits0[0] = Lits0[1] = Abc_Var2Lit( pFans[0], 0 );
286 Lits1[0] = Lits1[1] = Abc_Var2Lit( pFans[1], 0 );
287 pRes[0] =
Gia_ManHashAnd(
p, Abc_LitNotCond(Lits0[0], fCompl[0]), Abc_LitNotCond(Lits1[0], fCompl[1]) );
288 pRes[1] =
Gia_ManHashAnd(
p, Abc_LitNotCond(Lits0[1], fCompl[0]), Abc_LitNotCond(Lits1[1], fCompl[1]) );
289 Gia_ObjCopySetTwoArray(
p, iObj, pRes );
296 Gia_Obj_t * pObj = Gia_ManObj( p0, Abc_Lit2Var(iLit) );
297 int i, n, Entry, Lit, OutLit = -1, pLits[2], nVarsQua, nAndsOld, nAndsNew;
298 if ( iLit < 2 )
return iLit;
299 if ( Gia_ObjIsCi(pObj) )
return pFuncCiToKeep(pData, Gia_ObjCioId(pObj)) ? iLit : 1;
300 assert( Gia_ObjIsAnd(pObj) );
309 vOuts = Vec_IntAlloc( 100 );
310 vOuts2 = Vec_IntAlloc( 100 );
312 Vec_IntPush( vOuts, OutLit );
314 nAndsOld = Gia_ManAndNum(pNew);
317 Entry = Abc_Lit2Var( Vec_IntEntry(vOuts, 0) );
320 if ( Vec_IntSize(&pNew->
vCopiesTwo) < 2*Gia_ManObjNum(pNew) )
321 Vec_IntFillExtra( &pNew->
vCopiesTwo, 2*Gia_ManObjNum(pNew), -1 );
322 assert( Vec_IntSize(vOuts) > 0 );
323 Vec_IntClear( vOuts2 );
328 for ( n = 0; n < 2; n++ )
330 Lit = Abc_LitNotCond( pLits[n], Abc_LitIsCompl(Entry) );
335 Vec_IntFree( vOuts );
336 Vec_IntFree( vOuts2 );
341 Vec_IntPushUnique( vOuts2, Lit );
344 Vec_IntClear( vOuts );
349 assert( Vec_IntSize(vOuts) > 0 );
351 Vec_IntWriteEntry( vOuts, i, Abc_LitNot(Entry) );
353 OutLit = Abc_LitNot( OutLit );
354 Vec_IntFree( vOuts );
355 Vec_IntFree( vOuts2 );
357 Gia_ManAppendCo( pNew, OutLit );
358 nAndsNew = Gia_ManAndNum(p0);
360 nAndsNew = Gia_ManAndNum(p0) - nAndsNew;
385 if ( Gia_ObjIsTravIdCurrentId(
p, iObj ) )
387 Gia_ObjSetTravIdCurrentId(
p, iObj );
390 Vec_IntPush( vQuantSide, iObj );
393 pObj = Gia_ManObj(
p, iObj );
394 if ( Gia_ObjIsCi(pObj) )
396 Vec_IntPush( vQuantCis, iObj );
401 Vec_IntPush( vQuantAnds, iObj );
414 int i, iObj, iLit0, iLit1, iLitR;
418 if ( Vec_IntSize(&
p->vCopies) < Gia_ManObjNum(
p) )
419 Vec_IntFillExtra( &
p->vCopies, Gia_ManObjNum(
p), -1 );
422 Gia_ObjSetCopyArray(
p, iObj, Gia_ManAppendCi(pNew) );
427 Gia_ObjSetCopyArray(
p, iObj, (iLit0 = Gia_ManAppendCi(pNew)) );
434 iLit0 = Gia_ObjCopyArray(
p, Gia_ObjFaninId0(pObj, iObj) );
435 iLit1 = Gia_ObjCopyArray(
p, Gia_ObjFaninId1(pObj, iObj) );
436 iLit0 = Abc_LitNotCond( iLit0, Gia_ObjFaninC0(pObj) );
437 iLit1 = Abc_LitNotCond( iLit1, Gia_ObjFaninC1(pObj) );
439 Gia_ObjSetCopyArray(
p, iObj, iLitR );
441 iLit0 = Gia_ObjCopyArray(
p, Abc_Lit2Var(iLit) );
442 iLit0 = Abc_LitNotCond( iLit0, Abc_LitIsCompl(iLit) );
443 if ( pOutLit ) *pOutLit = iLit0;
445 Gia_ObjSetCopyArray(
p, iObj, -1 );
447 Gia_ObjSetCopyArray(
p, iObj, -1 );
449 Gia_ObjSetCopyArray(
p, iObj, -1 );
454 int i, Lit, iOutLit, nAndsNew, pLits[2], pRes[2] = {0};
458 if ( Vec_IntSize(vCis) == 0 )
460 if ( Vec_IntSize(vAnds) == 0 )
462 assert( Gia_ObjIsCi( Gia_ManObj(p0, Abc_Lit2Var(iLit)) ) );
463 return Vec_IntFind(vCis, Abc_Lit2Var(iLit)) == -1 ? iLit : 1;
466 if ( Vec_IntSize(&pNew->
vCopiesTwo) < 2*Gia_ManObjNum(pNew) )
467 Vec_IntFillExtra( &pNew->
vCopiesTwo, 2*Gia_ManObjNum(pNew), -1 );
468 Gia_ObjCopySetTwoArray( pNew, 0, pRes );
469 for ( i = 0; i < Gia_ManCiNum(pNew); i++ )
471 pRes[0] = pRes[1] = Abc_Var2Lit( i+1, 0 );
472 Gia_ObjCopySetTwoArray( pNew, i+1, pRes );
474 assert( pNew->
iSuppPi == Gia_ManCiNum(pNew) - Vec_IntSize(vSide) );
475 for ( i = Gia_ManCiNum(pNew) - 1; i >= Vec_IntSize(vSide); i-- )
477 pRes[0] = 0; pRes[1] = 1;
478 Gia_ObjCopySetTwoArray( pNew, i+1, pRes );
481 if ( Vec_IntSize(&pNew->
vCopiesTwo) < 2*Gia_ManObjNum(pNew) )
482 Vec_IntFillExtra( &pNew->
vCopiesTwo, 2*Gia_ManObjNum(pNew), -1 );
485 pLits[0] = Abc_LitNotCond( pLits[0], Abc_LitIsCompl(iOutLit) );
486 pLits[1] = Abc_LitNotCond( pLits[1], Abc_LitIsCompl(iOutLit) );
489 pRes[0] = pRes[1] = Abc_Var2Lit( i+1, 0 );
490 Gia_ObjCopySetTwoArray( pNew, i+1, pRes );
493 Vec_IntAppend( vSide, vCis );
495 Gia_ManAppendCo( pNew, iOutLit );
496 nAndsNew = Gia_ManAndNum(p0);
498 nAndsNew = Gia_ManAndNum(p0) - nAndsNew;
499 Vec_IntShrink( vSide, Vec_IntSize(vSide) - Vec_IntSize(vCis) );
508 Vec_Int_t * vQuantCis = Vec_IntAlloc( 100 );
509 Vec_Int_t * vQuantSide = Vec_IntAlloc( 100 );
510 Vec_Int_t * vQuantAnds = Vec_IntAlloc( 100 );
511 Gia_ManQuantCollect( p0, Abc_Lit2Var(iLit), pFuncCiToKeep, pData, vQuantCis, vQuantSide, vQuantAnds );
513 Vec_IntFree( vQuantCis );
514 Vec_IntFree( vQuantSide );
515 Vec_IntFree( vQuantAnds );
#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 ///.
void Gia_ManQuantSetSuppCi(Gia_Man_t *p, Gia_Obj_t *pObj)
int Gia_ManQuantExist(Gia_Man_t *p0, int iLit, int(*pFuncCiToKeep)(void *, int), void *pData)
void Gia_ManQuantCollect(Gia_Man_t *p, int iObj, int(*pFuncCiToKeep)(void *, int), void *pData, Vec_Int_t *vQuantCis, Vec_Int_t *vQuantSide, Vec_Int_t *vQuantAnds)
Gia_Man_t * Gia_ManQuantDupConeSupp(Gia_Man_t *p, int iLit, int(*pFuncCiToKeep)(void *, int), void *pData, Vec_Int_t **pvCis, int *pOutLit)
void Gia_ManQuantVerify(Gia_Man_t *p, int iObj)
void Gia_ManQuantCollect_rec(Gia_Man_t *p, int iObj, Vec_Int_t *vQuantCis, Vec_Int_t *vQuantSide, Vec_Int_t *vQuantAnds)
int Gia_ManQuantVerify_rec(Gia_Man_t *p, int iObj, int CiId)
Gia_Man_t * Gia_ManQuantExist2Dup(Gia_Man_t *p, int iLit, Vec_Int_t *vCis, Vec_Int_t *vSide, Vec_Int_t *vAnds, int *pOutLit)
void Gia_ManQuantSetSuppAnd(Gia_Man_t *p, Gia_Obj_t *pObj)
void Gia_ManQuantSetSuppZero(Gia_Man_t *p)
int Gia_ManQuantCheckOverlap(Gia_Man_t *p, int iObj)
int Gia_ManQuantCountUsed_rec(Gia_Man_t *p, int iObj)
void Gia_ManQuantSetSuppStart(Gia_Man_t *p)
int Gia_ManQuantCheckSupp(Gia_Man_t *p, int iObj, int iSupp)
int Gia_ManQuantExist2(Gia_Man_t *p0, int iLit, int(*pFuncCiToKeep)(void *, int), void *pData)
void Gia_ManQuantMarkUsedCis(Gia_Man_t *p, int(*pFuncCiToKeep)(void *, int), void *pData)
int Gia_ManQuantExistInt(Gia_Man_t *p0, int iLit, Vec_Int_t *vCis, Vec_Int_t *vSide, Vec_Int_t *vAnds)
void Gia_ManQuantUpdateCiSupp(Gia_Man_t *p, int iObj)
int Gia_ManQuantCountUsed(Gia_Man_t *p, int iObj)
void Gia_ManQuantExist_rec(Gia_Man_t *p, int iObj, int pRes[2])
void Gia_ManQuantDupConeSupp_rec(Gia_Man_t *pNew, Gia_Man_t *p, Gia_Obj_t *pObj, Vec_Int_t *vCis, Vec_Int_t *vObjs, int(*pFuncCiToKeep)(void *, int), void *pData)
void Gia_ManStop(Gia_Man_t *p)
void Gia_ManHashStart(Gia_Man_t *p)
int Gia_ManDupConeBackObjs(Gia_Man_t *p, Gia_Man_t *pNew, Vec_Int_t *vObjs)
int Gia_ManHashAndMulti(Gia_Man_t *p, Vec_Int_t *vLits)
Gia_Man_t * Gia_ManStart(int nObjsMax)
FUNCTION DEFINITIONS ///.
int Gia_ManHashOr(Gia_Man_t *p, int iLit0, int iLit1)
struct Gia_Obj_t_ Gia_Obj_t
struct Gia_Man_t_ Gia_Man_t
#define Gia_ManForEachObjVec(vVec, p, pObj, i)
int Gia_ManHashAnd(Gia_Man_t *p, int iLit0, int iLit1)
void Gia_ManIncrementTravId(Gia_Man_t *p)
int Gia_ManDupConeBack(Gia_Man_t *p, Gia_Man_t *pNew, Vec_Int_t *vCiIds)
unsigned __int64 word
DECLARATIONS ///.
#define Vec_IntForEachEntry(vVec, Entry, i)
MACRO DEFINITIONS ///.
#define Vec_WrdForEachEntry(vVec, Entry, i)
MACRO DEFINITIONS ///.
typedefABC_NAMESPACE_HEADER_START struct Vec_Wrd_t_ Vec_Wrd_t
INCLUDES ///.