51 int i, iBox, nBoxIns, nBoxOuts, iShift, nRealCis;
52 if ( Gia_ObjIsTravIdCurrent(
p, pObj) )
54 Gia_ObjSetTravIdCurrent(
p, pObj);
55 if ( Gia_ObjIsAnd(pObj) )
61 assert( Gia_ObjIsCi(pObj) );
63 if ( Gia_ObjCioId(pObj) < nRealCis )
66 int iFlop = Gia_ObjCioId(pObj) - (nRealCis - nRegs);
67 assert( iFlop >= 0 && iFlop < nRegs );
68 pObj = Gia_ManCo(
p, Gia_ManPoNum(
p) - nRegs + iFlop );
69 Vec_IntPush( vRoots, Gia_ObjId(
p, pObj) );
78 for ( i = 0; i < nBoxOuts; i++ )
79 Gia_ObjSetTravIdCurrent(
p, Gia_ManCi(
p, iShift + i));
82 for ( i = 0; i < nBoxIns; i++ )
83 Gia_ObjSetTravIdCurrent(
p, Gia_ManCo(
p, iShift + i));
84 for ( i = 0; i < nBoxIns; i++ )
97 assert( Gia_ManRegNum(
p) == 0 );
101 Gia_ObjSetTravIdCurrent(
p, Gia_ManConst0(
p) );
102 for ( i = 0; i < nRealCis - nRegs; i++ )
103 Gia_ObjSetTravIdCurrent(
p, Gia_ManPi(
p, i) );
106 for ( i = Gia_ManPoNum(
p) - nRealCos; i < Gia_ManPoNum(
p) - nRegs; i++ )
108 Gia_ObjSetTravIdCurrent(
p, Gia_ManPo(
p, i) );
116 assert( Gia_ObjIsCo(pObj) );
117 Gia_ObjSetTravIdCurrent(
p, pObj );
122 Vec_IntFree( vRoots );
130 int curCi, curCo, nBoxIns, nBoxOuts;
131 int i, k, iShift, nMarked;
137 pNew->
pName = Abc_UtilStrsav(
p->pName );
138 pNew->
pSpec = Abc_UtilStrsav(
p->pSpec );
139 Gia_ManConst0(
p)->Value = 0;
142 if ( !Gia_ObjIsTravIdCurrent(
p, pObj) )
144 if ( Gia_ObjIsCi(pObj) )
145 pObj->
Value = Gia_ManAppendCi(pNew);
146 else if ( Gia_ObjIsAnd(pObj) )
147 pObj->
Value = Gia_ManAppendAnd( pNew, Gia_ObjFanin0Copy(pObj), Gia_ObjFanin1Copy(pObj) );
148 else if ( Gia_ObjIsCo(pObj) )
149 pObj->
Value = Gia_ManAppendCo( pNew, Gia_ObjFanin0Copy(pObj) );
161 if ( Gia_ObjIsTravIdCurrent(
p, Gia_ManCo(
p, iShift + i)) )
163 Vec_IntPush( pNew->
vRegClasses, Vec_IntEntry(
p->vRegClasses, i) );
165 Vec_IntPush( pNew->
vRegInits, Vec_IntEntry(
p->vRegInits, i) );
170 if (
p->vRegClasses )
184 for ( k = 0; k < nBoxIns; k++ )
185 nMarked += Gia_ObjIsTravIdCurrent(
p, Gia_ManCo(
p, curCo + k) );
186 for ( k = 0; k < nBoxOuts; k++ )
187 nMarked += Gia_ObjIsTravIdCurrent(
p, Gia_ManCi(
p, curCi + k) );
191 assert( nMarked == 0 || nMarked == nBoxIns + nBoxOuts );
193 Vec_IntPush( vBoxesLeft, i );
196 assert( curCi == Gia_ManCiNum(
p) );
197 assert( curCo == Gia_ManCoNum(
p) );
201 assert(
p->pAigExtra != NULL );
205 Vec_IntFree( vBoxesLeft );
223 for (
assert( Gia_ObjIsCi(pObj) ); Gia_ObjIsCi(pObj); pObj-- )
224 if ( Gia_ObjIsTravIdCurrent(
p, pObj) )
230 for (
assert( Gia_ObjIsCi(pObj) ); Gia_ObjIsCi(pObj); pObj-- )
232 Gia_ObjSetTravIdCurrent(
p, pObj );
237 for (
assert( Gia_ObjIsCo(pObj) ); Gia_ObjIsCo(pObj); pObj-- )
240 Gia_ObjSetTravIdCurrent(
p, pObj );
241 Gia_ObjSetTravIdCurrent(
p, Gia_ObjFanin0(pObj) );
247 for (
assert( Gia_ObjIsAnd(pObj) ); Gia_ObjIsAnd(pObj); pObj-- )
248 if ( Gia_ObjIsTravIdCurrent(
p, pObj) )
250 Gia_ObjSetTravIdCurrent(
p, Gia_ObjFanin0(pObj) );
251 Gia_ObjSetTravIdCurrent(
p, Gia_ObjFanin1(pObj) );
264 Gia_ObjSetTravIdCurrent(
p, Gia_ManConst0(
p) );
265 vBoxPres = Vec_IntAlloc( 1000 );
268 pObj = Gia_ManObj(
p, Gia_ManObjNum(
p) - 1 );
269 assert( Gia_ObjIsCo(pObj) );
270 while ( Gia_ObjIsCo(pObj) )
273 if ( Gia_ObjIsAnd(pObj) )
275 assert( Gia_ObjIsCi(pObj) );
278 Vec_IntPush( vBoxPres, fLabelPos );
280 Vec_IntPop( vBoxPres );
281 Vec_IntReverseOrder( vBoxPres );
282 assert( Gia_ObjIsConst0(pObj) );
285 if ( Gia_ObjIsCi(pObj) )
286 Gia_ObjSetTravIdCurrent(
p, pObj );
291 pNew->
pName = Abc_UtilStrsav(
p->pName );
292 pNew->
pSpec = Abc_UtilStrsav(
p->pSpec );
293 Gia_ManConst0(
p)->Value = 0;
296 if ( !Gia_ObjIsTravIdCurrent(
p, pObj) )
298 if ( Gia_ObjIsCi(pObj) )
299 pObj->
Value = Gia_ManAppendCi(pNew);
300 else if ( Gia_ObjIsAnd(pObj) )
301 pObj->
Value = Gia_ManAppendAnd( pNew, Gia_ObjFanin0Copy(pObj), Gia_ObjFanin1Copy(pObj) );
302 else if ( Gia_ObjIsCo(pObj) )
303 pObj->
Value = Gia_ManAppendCo( pNew, Gia_ObjFanin0Copy(pObj) );
309 assert(
p->pAigExtra != NULL );
312 Vec_IntFree( vBoxPres );
332 int fanId = Gia_ObjFaninId0p(
p, pObj );
333 if ( pReprs[fanId] == -1 )
334 return Gia_ObjFanin0Copy( pObj );
335 assert( Abc_Lit2Var(pReprs[fanId]) < Gia_ObjId(
p, pObj) );
336 return Abc_LitNotCond( Gia_ObjValue(Gia_ManObj(
p, Abc_Lit2Var(pReprs[fanId]))), Gia_ObjFaninC0(pObj) ^ Abc_LitIsCompl(pReprs[fanId]) );
340 int fanId = Gia_ObjFaninId1p(
p, pObj );
341 if ( pReprs[fanId] == -1 )
342 return Gia_ObjFanin1Copy( pObj );
343 assert( Abc_Lit2Var(pReprs[fanId]) < Gia_ObjId(
p, pObj) );
344 return Abc_LitNotCond( Gia_ObjValue(Gia_ManObj(
p, Abc_Lit2Var(pReprs[fanId]))), Gia_ObjFaninC1(pObj) ^ Abc_LitIsCompl(pReprs[fanId]) );
352 assert( Gia_ManRegNum(
p) == 0 );
354 pNew->
pName = Abc_UtilStrsav(
p->pName );
355 pNew->
pSpec = Abc_UtilStrsav(
p->pSpec );
360 if ( Gia_ObjIsAnd(pObj) )
362 else if ( Gia_ObjIsCi(pObj) )
363 pObj->
Value = Gia_ManAppendCi( pNew );
364 else if ( Gia_ObjIsCo(pObj) )
366 else if ( Gia_ObjIsConst0(pObj) )
390 Vec_Int_t * vCarryOuts = Vec_IntAlloc( nBoxes );
394 int createRefs = (
p->pRefs == NULL);
399 for ( i = 0; i < nBoxes; i++ )
402 pObj = Gia_ObjFanin0( Gia_ManCo(
p, iLast) );
403 if ( !Gia_ObjIsCi(pObj) )
408 assert( Gia_ObjIsCi(pObj) );
410 Vec_IntPush( vCarryOuts, Gia_ObjId(
p, pObj) );
416 pObj = Gia_ManCi(
p, iLast);
417 if ( Gia_ObjRefNum(
p, pObj) == 0 ) {
418 Vec_IntPush( vCarryOuts, Gia_ObjId(
p, pObj) );
445 int i, nCountReg = 0, nCountCarry = 0;
446 if (
p->pManTime == NULL )
452 pObj = Gia_ObjFanin0( Gia_ManPo(
p, i) );
453 assert( Gia_ObjIsCi(pObj) );
454 if ( Gia_ObjRefNum(
p, pObj) > 1 )
459 if ( Gia_ObjRefNum(
p, pObj) > 1 )
461 Vec_IntFree( vCarryOuts );
462 if ( nCountReg || nCountCarry )
463 printf(
"Warning: AIG with boxes has internal fanout in %d complex flops and %d carries.\n", nCountReg, nCountCarry );
483 int * pReprs =
ABC_FALLOC(
int, Gia_ManObjNum(
p) );
484 int * pClp2Gia =
ABC_FALLOC(
int, Gia_ManObjNum(pClp) );
485 int i, iLitClp, iLitClp2, iReprClp, fCompl;
486 int nConsts = 0, nReprs = 0;
487 assert( pManTime != NULL );
491 if ( Gia_ObjIsCo(pObj) )
493 if ( i == Gia_ObjReprSelf(pClp, i) )
495 if ( Gia_ObjReprSelf(pClp, i) == 0 )
501 printf(
"Computed %d const objects and %d other objects.\n", nConsts, nReprs );
502 nConsts = nReprs = 0;
508 pObj = Gia_ObjFanin0( Gia_ManPo(
p, i) );
509 assert( Gia_ObjIsCi(pObj) );
517 printf(
"Fixed %d flop inputs and %d box/box connections (out of %d non-flop boxes).\n",
519 Vec_IntFree( vCarryOuts );
522 pFlopTypes[0] = pFlopTypes[1] = pFlopTypes[2] = 0;
525 Gia_Obj_t * pRepr = Gia_ObjReprObj(pClp, i);
526 if ( pRepr && pRepr != pObj )
528 if ( pRepr == Gia_ManConst0(pClp) )
530 else if ( Gia_ObjIsRo(pClp, pRepr) )
540 if ( Gia_ObjIsCo(pObj) )
542 if ( Gia_ObjIsCi(pObj) && pObj->
fMark0 )
544 assert( Gia_ObjIsCi(pObj) || Gia_ObjIsAnd(pObj) );
545 iLitClp = Gia_ObjValue(pObj);
548 iReprClp = Gia_ObjReprSelf( pClp, Abc_Lit2Var(iLitClp) );
549 if ( pClp2Gia[iReprClp] == -1 )
550 pClp2Gia[iReprClp] = i;
553 iLitClp2 = Gia_ObjValue( Gia_ManObj(
p, pClp2Gia[iReprClp]) );
554 assert( Gia_ObjReprSelf(pClp, Abc_Lit2Var(iLitClp)) == Gia_ObjReprSelf(pClp, Abc_Lit2Var(iLitClp2)) );
555 fCompl = Abc_LitIsCompl(iLitClp) ^ Abc_LitIsCompl(iLitClp2);
556 fCompl ^= Gia_ManObj(pClp, Abc_Lit2Var(iLitClp))->fPhase;
557 fCompl ^= Gia_ManObj(pClp, Abc_Lit2Var(iLitClp2))->fPhase;
558 pReprs[i] = Abc_Var2Lit( pClp2Gia[iReprClp], fCompl );
559 assert( Abc_Lit2Var(pReprs[i]) < i );
560 if ( pClp2Gia[iReprClp] == 0 )
570 printf(
"Found %d const objects and %d other objects.\n", nConsts, nReprs );
589 assert( Gia_ManObjNum(
p) == Aig_ManObjNum(pNew) );
634 int i, Class, nFlops;
635 int nDoms = Vec_IntFindMax(vRegClasses);
636 assert( iDom >= 1 && iDom <= nDoms );
638 assert( Gia_ManRegNum(
p) > 0 );
640 vPerm = Vec_IntAlloc( Gia_ManRegNum(
p) );
643 Vec_IntPush( vPerm, i );
644 nFlops = Vec_IntSize( vPerm );
647 Vec_IntPush( vPerm, i );
648 nFlops = Vec_IntSize(vPerm) - nFlops;
649 assert( Vec_IntSize(vPerm) == Gia_ManRegNum(
p) );
652 assert( Gia_ManObjNum(pNew) == Gia_ManObjNum(
p) );
653 Vec_IntFree( vPerm );
655 pNew->
nRegs = nFlops;
660 pNew->
nRegs = Gia_ManRegNum(
p);
665 Gia_ManObj(pNew, Abc_Lit2Var(pObj->
Value))->Value = Abc_Var2Lit(i, 0);
674 int nDoms = Vec_IntFindMax(
p->vRegClasses);
675 int * pReprs, iDom, pFlopTypes[3] = {0};
676 assert( Gia_ManRegNum(
p) == 0 );
677 assert(
p->pAigExtra != NULL );
685 for ( iDom = 1; iDom <= nDoms; iDom++ )
687 int nFlopsNew, nFlops = Vec_IntCountEntry(pNew->
vRegClasses, iDom);
709 nFlopsNew = Vec_IntCountEntry(pNew->
vRegClasses, iDom);
710 pFlopTypes[2] = nFlops - nFlopsNew - (pFlopTypes[0] + pFlopTypes[1]);
713 printf(
"Domain %2d : %5d -> %5d : ", iDom, nFlops, nFlopsNew );
714 printf(
"EqConst =%4d. EqFlop =%4d. Dangling =%4d. Unused =%4d.\n",
715 pFlopTypes[0], pFlopTypes[1], Abc_MaxInt(0, pFlopTypes[2]), Abc_MaxInt(0, -pFlopTypes[2]) );
742 int * pReprs, pFlopTypes[3] = {0};
743 int nFlopsNew, nFlops;
744 assert( Gia_ManRegNum(
p) == 0 );
745 assert(
p->pAigExtra != NULL );
778 nFlopsNew = Vec_IntCountEntry(pNew->
vRegClasses, 1);
779 pFlopTypes[2] = nFlops - nFlopsNew - (pFlopTypes[0] + pFlopTypes[1]);
782 printf(
"Domain %2d : %5d -> %5d : ", 1, nFlops, nFlopsNew );
783 printf(
"EqConst =%4d. EqFlop =%4d. Dangling =%4d. Unused =%4d.\n",
784 pFlopTypes[0], pFlopTypes[1], Abc_MaxInt(0, pFlopTypes[2]), Abc_MaxInt(0, -pFlopTypes[2]) );
void Dch_ComputeEquivalences(Aig_Man_t *pAig, Dch_Pars_t *pPars)
#define ABC_FALLOC(type, num)
#define ABC_NAMESPACE_IMPL_START
#define ABC_NAMESPACE_IMPL_END
void Aig_ManStop(Aig_Man_t *p)
typedefABC_NAMESPACE_HEADER_START struct Aig_Man_t_ Aig_Man_t
INCLUDES ///.
typedefABC_NAMESPACE_IMPL_START struct Vec_Int_t_ Vec_Int_t
DECLARATIONS ///.
int Cec_ManLSCorrespondenceClasses(Gia_Man_t *pAig, Cec_ParCor_t *pPars)
struct Cec_ParCor_t_ Cec_ParCor_t
typedefABC_NAMESPACE_HEADER_START struct Dch_Pars_t_ Dch_Pars_t
INCLUDES ///.
void Gia_ManSeqCleanupClasses(Gia_Man_t *p, int fConst, int fEquiv, int fVerbose)
Aig_Man_t * Gia_ManToAigSimple(Gia_Man_t *p)
void Gia_ManReprFromAigRepr(Aig_Man_t *pAig, Gia_Man_t *pGia)
int Gia_ManFraigCheckCis(Gia_Man_t *p, Gia_Obj_t *pObj)
void Gia_ManMarkSeqGiaWithBoxes(Gia_Man_t *p, int fSeq)
Gia_Man_t * Gia_ManSweepWithBoxesAndDomains(Gia_Man_t *p, void *pParsS, int fConst, int fEquiv, int fVerbose, int fVerbEquivs)
Gia_Obj_t * Gia_ManFraigMarkCos(Gia_Man_t *p, Gia_Obj_t *pObj, int fMark)
Gia_Man_t * Gia_ManFraigSweepSimple(Gia_Man_t *p, void *pPars)
int * Gia_ManFraigSelectReprs(Gia_Man_t *p, Gia_Man_t *pClp, int fVerbose, int pFlopTypes[3])
int Gia_ObjFanin0CopyRepr(Gia_Man_t *p, Gia_Obj_t *pObj, int *pReprs)
ABC_NAMESPACE_IMPL_START void Gia_ManMarkSeqGiaWithBoxes_rec(Gia_Man_t *p, Gia_Obj_t *pObj, Vec_Int_t *vRoots)
DECLARATIONS ///.
Gia_Obj_t * Gia_ManFraigMarkCis(Gia_Man_t *p, Gia_Obj_t *pObj, int fMark)
Gia_Obj_t * Gia_ManFraigMarkAnd(Gia_Man_t *p, Gia_Obj_t *pObj)
int Gia_ObjFanin1CopyRepr(Gia_Man_t *p, Gia_Obj_t *pObj, int *pReprs)
Gia_Man_t * Gia_ManFraigReduceGia(Gia_Man_t *p, int *pReprs)
void Gia_ManSweepComputeOneDomainEquivs(Gia_Man_t *p, Vec_Int_t *vRegClasses, int iDom, void *pParsS, int fConst, int fEquiv, int fVerbose)
Gia_Man_t * Gia_ManFraigCreateGia(Gia_Man_t *p)
void Gia_ManCheckIntegrityWithBoxes(Gia_Man_t *p)
Vec_Int_t * Gia_ManComputeCarryOuts(Gia_Man_t *p)
Gia_Man_t * Gia_ManSweepWithBoxes(Gia_Man_t *p, void *pParsC, void *pParsS, int fConst, int fEquiv, int fVerbose, int fVerbEquivs)
Gia_Man_t * Gia_ManDupWithBoxes(Gia_Man_t *p, int fSeq)
void Gia_ManFraigSweepPerform(Gia_Man_t *p, void *pPars)
void Gia_ManStop(Gia_Man_t *p)
Gia_Man_t * Gia_ManDup(Gia_Man_t *p)
#define Gia_ManForEachRo(p, pObj, i)
int Gia_ManNonRegBoxNum(Gia_Man_t *p)
int Gia_ManHasDangling(Gia_Man_t *p)
int Gia_ManRegBoxNum(Gia_Man_t *p)
void * Gia_ManUpdateTimMan(Gia_Man_t *p, Vec_Int_t *vBoxPres)
Gia_Man_t * Gia_ManUpdateExtraAig(void *pTime, Gia_Man_t *pAig, Vec_Int_t *vBoxPres)
Gia_Man_t * Gia_ManEquivReduce(Gia_Man_t *p, int fUseAll, int fDualOut, int fSkipPhase, int fVerbose)
void Gia_ManHashAlloc(Gia_Man_t *p)
void Gia_ManDupRemapEquiv(Gia_Man_t *pNew, Gia_Man_t *p)
Gia_Man_t * Gia_ManDupPermFlop(Gia_Man_t *p, Vec_Int_t *vFfPerm)
Gia_Man_t * Gia_ManStart(int nObjsMax)
FUNCTION DEFINITIONS ///.
int Gia_ManBoxNum(Gia_Man_t *p)
DECLARATIONS ///.
struct Gia_Obj_t_ Gia_Obj_t
void * Gia_ManUpdateTimMan2(Gia_Man_t *p, Vec_Int_t *vBoxesLeft, int nTermsDiff)
Gia_Man_t * Gia_ManDupCollapse(Gia_Man_t *p, Gia_Man_t *pBoxes, Vec_Int_t *vBoxPres, int fSeq)
void Gia_ManFillValue(Gia_Man_t *p)
struct Gia_Man_t_ Gia_Man_t
#define Gia_ManForEachObj1(p, pObj, i)
#define Gia_ManForEachObjVec(vVec, p, pObj, i)
void Gia_ManCleanMark0(Gia_Man_t *p)
void Gia_ManTransferTiming(Gia_Man_t *p, Gia_Man_t *pGia)
void Gia_ManCreateRefs(Gia_Man_t *p)
Gia_Man_t * Gia_ManDupNormalize(Gia_Man_t *p, int fHashMapping)
int Gia_ManHashAnd(Gia_Man_t *p, int iLit0, int iLit1)
void Gia_ManIncrementTravId(Gia_Man_t *p)
int Gia_ManClockDomainNum(Gia_Man_t *p)
#define Gia_ManForEachObj(p, pObj, i)
MACRO DEFINITIONS ///.
#define Gia_ManForEachCi(p, pObj, i)
void Gia_ManSetPhase(Gia_Man_t *p)
void Gia_ManHashStop(Gia_Man_t *p)
Gia_Man_t * Gia_ManDupUnnormalize(Gia_Man_t *p)
Gia_Man_t * Gia_ManUpdateExtraAig2(void *pTime, Gia_Man_t *pAig, Vec_Int_t *vBoxesLeft)
int Tim_ManBoxOutputNum(Tim_Man_t *p, int iBox)
int Tim_ManBoxNum(Tim_Man_t *p)
int Tim_ManBoxOutputLast(Tim_Man_t *p, int iBox)
typedefABC_NAMESPACE_HEADER_START struct Tim_Man_t_ Tim_Man_t
INCLUDES ///.
int Tim_ManBoxForCi(Tim_Man_t *p, int iCo)
int Tim_ManPoNum(Tim_Man_t *p)
int Tim_ManBoxInputLast(Tim_Man_t *p, int iBox)
int Tim_ManBoxInputFirst(Tim_Man_t *p, int iBox)
int Tim_ManBoxInputNum(Tim_Man_t *p, int iBox)
int Tim_ManPiNum(Tim_Man_t *p)
int Tim_ManBoxOutputFirst(Tim_Man_t *p, int iBox)
#define Vec_IntForEachEntry(vVec, Entry, i)
MACRO DEFINITIONS ///.