Commit 9e0c90d4 by Alan Mishchenko

Adding integrity check for boxes and flops.

parent dd3e5a90
...@@ -1319,6 +1319,7 @@ extern Gia_Man_t * Gia_ManStgRead( char * pFileName, int kHot, int fVerb ...@@ -1319,6 +1319,7 @@ extern Gia_Man_t * Gia_ManStgRead( char * pFileName, int kHot, int fVerb
/*=== giaSweep.c ============================================================*/ /*=== giaSweep.c ============================================================*/
extern Gia_Man_t * Gia_ManFraigSweepSimple( Gia_Man_t * p, void * pPars ); extern Gia_Man_t * Gia_ManFraigSweepSimple( Gia_Man_t * p, void * pPars );
extern Gia_Man_t * Gia_ManSweepWithBoxes( Gia_Man_t * p, void * pParsC, void * pParsS, int fConst, int fEquiv, int fVerbose ); extern Gia_Man_t * Gia_ManSweepWithBoxes( Gia_Man_t * p, void * pParsC, void * pParsS, int fConst, int fEquiv, int fVerbose );
extern void Gia_ManCheckIntegrityWithBoxes( Gia_Man_t * p );
/*=== giaSweeper.c ============================================================*/ /*=== giaSweeper.c ============================================================*/
extern Gia_Man_t * Gia_SweeperStart( Gia_Man_t * p ); extern Gia_Man_t * Gia_SweeperStart( Gia_Man_t * p );
extern void Gia_SweeperStop( Gia_Man_t * p ); extern void Gia_SweeperStop( Gia_Man_t * p );
...@@ -1351,6 +1352,9 @@ extern Vec_Flt_t * Gia_ManPrintOutputProb( Gia_Man_t * p ); ...@@ -1351,6 +1352,9 @@ extern Vec_Flt_t * Gia_ManPrintOutputProb( Gia_Man_t * p );
/*=== giaTim.c ===========================================================*/ /*=== giaTim.c ===========================================================*/
extern int Gia_ManBoxNum( Gia_Man_t * p ); extern int Gia_ManBoxNum( Gia_Man_t * p );
extern int Gia_ManRegBoxNum( Gia_Man_t * p ); extern int Gia_ManRegBoxNum( Gia_Man_t * p );
extern int Gia_ManNonRegBoxNum( Gia_Man_t * p );
extern int Gia_ManBoxCiNum( Gia_Man_t * p );
extern int Gia_ManBoxCoNum( Gia_Man_t * p );
extern int Gia_ManIsSeqWithBoxes( Gia_Man_t * p ); extern int Gia_ManIsSeqWithBoxes( Gia_Man_t * p );
extern int Gia_ManIsNormalized( Gia_Man_t * p ); extern int Gia_ManIsNormalized( Gia_Man_t * p );
extern Gia_Man_t * Gia_ManDupNormalize( Gia_Man_t * p ); extern Gia_Man_t * Gia_ManDupNormalize( Gia_Man_t * p );
......
...@@ -403,13 +403,15 @@ void Gia_ManPrintStats( Gia_Man_t * p, Gps_Par_t * pPars ) ...@@ -403,13 +403,15 @@ void Gia_ManPrintStats( Gia_Man_t * p, Gps_Par_t * pPars )
if ( p->pName ) if ( p->pName )
Abc_Print( 1, "%s%-8s%s : ", "\033[1;37m", p->pName, "\033[0m" ); // bright Abc_Print( 1, "%s%-8s%s : ", "\033[1;37m", p->pName, "\033[0m" ); // bright
#endif #endif
Abc_Print( 1, "i/o =%7d/%7d", Gia_ManPiNum(p), Gia_ManPoNum(p) ); Abc_Print( 1, "i/o =%7d/%7d",
Gia_ManPiNum(p) - Gia_ManBoxCiNum(p) - Gia_ManRegBoxNum(p),
Gia_ManPoNum(p) - Gia_ManBoxCoNum(p) - Gia_ManRegBoxNum(p) );
if ( Gia_ManConstrNum(p) ) if ( Gia_ManConstrNum(p) )
Abc_Print( 1, "(c=%d)", Gia_ManConstrNum(p) ); Abc_Print( 1, "(c=%d)", Gia_ManConstrNum(p) );
if ( Gia_ManRegNum(p) ) if ( Gia_ManRegNum(p) )
Abc_Print( 1, " ff =%7d", Gia_ManRegNum(p) ); Abc_Print( 1, " ff =%7d", Gia_ManRegNum(p) );
if ( p->vRegClasses ) if ( Gia_ManRegBoxNum(p) )
Abc_Print( 1, " boxff =%d(%d)", Vec_IntSize(p->vRegClasses), Vec_IntFindMax(p->vRegClasses) ); Abc_Print( 1, " boxff =%d(%d)", Gia_ManRegBoxNum(p), Vec_IntFindMax(p->vRegClasses) );
#ifdef WIN32 #ifdef WIN32
{ {
...@@ -433,7 +435,7 @@ void Gia_ManPrintStats( Gia_Man_t * p, Gps_Par_t * pPars ) ...@@ -433,7 +435,7 @@ void Gia_ManPrintStats( Gia_Man_t * p, Gps_Par_t * pPars )
if ( Gia_ManHasChoices(p) ) if ( Gia_ManHasChoices(p) )
Abc_Print( 1, " ch =%5d", Gia_ManChoiceNum(p) ); Abc_Print( 1, " ch =%5d", Gia_ManChoiceNum(p) );
if ( p->pManTime ) if ( p->pManTime )
Abc_Print( 1, " box = %d", Gia_ManBoxNum(p) - Gia_ManRegBoxNum(p) ); Abc_Print( 1, " box = %d", Gia_ManNonRegBoxNum(p) );
if ( pPars && pPars->fMuxXor ) if ( pPars && pPars->fMuxXor )
printf( "\nXOR/MUX " ), Gia_ManPrintMuxStats( p ); printf( "\nXOR/MUX " ), Gia_ManPrintMuxStats( p );
if ( pPars && pPars->fSwitch ) if ( pPars && pPars->fSwitch )
...@@ -475,6 +477,17 @@ void Gia_ManPrintStats( Gia_Man_t * p, Gps_Par_t * pPars ) ...@@ -475,6 +477,17 @@ void Gia_ManPrintStats( Gia_Man_t * p, Gps_Par_t * pPars )
// } // }
if ( p->vInitClasses ) if ( p->vInitClasses )
Gia_ManPrintInitClasses( p->vInitClasses ); Gia_ManPrintInitClasses( p->vInitClasses );
// check integrity of boxes
Gia_ManCheckIntegrityWithBoxes( p );
/*
if ( Gia_ManRegBoxNum(p) )
{
int i, Limit = Vec_IntFindMax(p->vRegClasses);
for ( i = 1; i <= Limit; i++ )
printf( "%d ", Vec_IntCountEntry(p->vRegClasses, i) );
printf( "\n" );
}
*/
if ( pPars && pPars->fTents ) if ( pPars && pPars->fTents )
{ {
/* /*
......
...@@ -404,6 +404,8 @@ Gia_Man_t * Gia_ManPerformMfs( Gia_Man_t * p, Sfm_Par_t * pPars ) ...@@ -404,6 +404,8 @@ Gia_Man_t * Gia_ManPerformMfs( Gia_Man_t * p, Sfm_Par_t * pPars )
pNew = Gia_ManInsertMfs( p, pNtk ); pNew = Gia_ManInsertMfs( p, pNtk );
if( pPars->fVerbose ) if( pPars->fVerbose )
Abc_Print( 1, "The network has %d nodes changed by \"&mfs\".\n", nNodes ); Abc_Print( 1, "The network has %d nodes changed by \"&mfs\".\n", nNodes );
// check integrity
//Gia_ManCheckIntegrityWithBoxes( pNew );
} }
Sfm_NtkFree( pNtk ); Sfm_NtkFree( pNtk );
return pNew; return pNew;
......
...@@ -361,6 +361,75 @@ Gia_Man_t * Gia_ManFraigReduceGia( Gia_Man_t * p, int * pReprs ) ...@@ -361,6 +361,75 @@ Gia_Man_t * Gia_ManFraigReduceGia( Gia_Man_t * p, int * pReprs )
/**Function************************************************************* /**Function*************************************************************
Synopsis [Compute the set of CIs representing carry-outs of boxes.]
Description []
SideEffects []
SeeAlso []
***********************************************************************/
Vec_Int_t * Gia_ManComputeCarryOuts( Gia_Man_t * p )
{
Gia_Obj_t * pObj;
Tim_Man_t * pManTime = (Tim_Man_t *)p->pManTime;
int i, iLast, iBox, nBoxes = Tim_ManBoxNum( pManTime );
Vec_Int_t * vCarryOuts = Vec_IntAlloc( nBoxes );
for ( i = 0; i < nBoxes; i++ )
{
iLast = Tim_ManBoxInputLast( pManTime, i );
pObj = Gia_ObjFanin0( Gia_ManCo(p, iLast) );
if ( !Gia_ObjIsCi(pObj) )
continue;
iBox = Tim_ManBoxForCi( pManTime, Gia_ObjCioId(pObj) );
if ( iBox == -1 )
continue;
assert( Gia_ObjIsCi(pObj) );
if ( Gia_ObjCioId(pObj) == Tim_ManBoxOutputLast(pManTime, iBox) )
Vec_IntPush( vCarryOuts, Gia_ObjId(p, pObj) );
}
return vCarryOuts;
}
/**Function*************************************************************
Synopsis [Checks integriting of complex flops and carry-chains.]
Description []
SideEffects []
SeeAlso []
***********************************************************************/
void Gia_ManCheckIntegrityWithBoxes( Gia_Man_t * p )
{
Gia_Obj_t * pObj;
Vec_Int_t * vCarryOuts;
int i, nCountReg = 0, nCountCarry = 0;
if ( p->pManTime == NULL )
return;
Gia_ManCreateRefs( p );
for ( i = Gia_ManPoNum(p) - Gia_ManRegBoxNum(p); i < Gia_ManPoNum(p); i++ )
{
pObj = Gia_ObjFanin0( Gia_ManPo(p, i) );
assert( Gia_ObjIsCi(pObj) );
if ( Gia_ObjRefNum(p, pObj) > 1 )
nCountReg++;
}
vCarryOuts = Gia_ManComputeCarryOuts( p );
Gia_ManForEachObjVec( vCarryOuts, p, pObj, i )
if ( Gia_ObjRefNum(p, pObj) > 1 )
nCountCarry++;
Vec_IntFree( vCarryOuts );
if ( nCountReg || nCountCarry )
printf( "Warning: AIG with boxes has internal fanout in %d complex flops and %d carries.\n", nCountReg, nCountCarry );
ABC_FREE( p->pRefs );
}
/**Function*************************************************************
Synopsis [Computes representatives in terms of the original objects.] Synopsis [Computes representatives in terms of the original objects.]
Description [] Description []
...@@ -373,11 +442,12 @@ Gia_Man_t * Gia_ManFraigReduceGia( Gia_Man_t * p, int * pReprs ) ...@@ -373,11 +442,12 @@ Gia_Man_t * Gia_ManFraigReduceGia( Gia_Man_t * p, int * pReprs )
int * Gia_ManFraigSelectReprs( Gia_Man_t * p, Gia_Man_t * pClp, int fVerbose ) int * Gia_ManFraigSelectReprs( Gia_Man_t * p, Gia_Man_t * pClp, int fVerbose )
{ {
Gia_Obj_t * pObj; Gia_Obj_t * pObj;
Vec_Int_t * vCarryOuts;
Tim_Man_t * pManTime = (Tim_Man_t *)p->pManTime; Tim_Man_t * pManTime = (Tim_Man_t *)p->pManTime;
int * pReprs = ABC_FALLOC( int, Gia_ManObjNum(p) ); int * pReprs = ABC_FALLOC( int, Gia_ManObjNum(p) );
int * pClp2Gia = ABC_FALLOC( int, Gia_ManObjNum(pClp) ); int * pClp2Gia = ABC_FALLOC( int, Gia_ManObjNum(pClp) );
int i, nBoxes, iLast, iBox, iLitClp, iLitClp2, iReprClp, fCompl; int i, iLitClp, iLitClp2, iReprClp, fCompl;
int nConsts = 0, nReprs = 0, Count1 = 0, Count2 = 0; int nConsts = 0, nReprs = 0;
assert( pManTime != NULL ); assert( pManTime != NULL );
// count the number of equivalent objects // count the number of equivalent objects
Gia_ManForEachObj1( pClp, pObj, i ) Gia_ManForEachObj1( pClp, pObj, i )
...@@ -402,26 +472,15 @@ int * Gia_ManFraigSelectReprs( Gia_Man_t * p, Gia_Man_t * pClp, int fVerbose ) ...@@ -402,26 +472,15 @@ int * Gia_ManFraigSelectReprs( Gia_Man_t * p, Gia_Man_t * pClp, int fVerbose )
pObj = Gia_ObjFanin0( Gia_ManPo(p, i) ); pObj = Gia_ObjFanin0( Gia_ManPo(p, i) );
assert( Gia_ObjIsCi(pObj) ); assert( Gia_ObjIsCi(pObj) );
pObj->fMark0 = 1; pObj->fMark0 = 1;
Count1++;
} }
// mark connects between last box inputs and first box outputs // mark connects between last box inputs and first box outputs
nBoxes = Tim_ManBoxNum( pManTime ); vCarryOuts = Gia_ManComputeCarryOuts( p );
for ( i = 0; i < nBoxes; i++ ) Gia_ManForEachObjVec( vCarryOuts, p, pObj, i )
{ pObj->fMark0 = 1;
iLast = Tim_ManBoxInputLast( pManTime, i );
pObj = Gia_ObjFanin0( Gia_ManCo(p, iLast) );
if ( !Gia_ObjIsCi(pObj) )
continue;
iBox = Tim_ManBoxForCi( pManTime, Gia_ObjCioId(pObj) );
if ( iBox == -1 )
continue;
assert( Gia_ObjIsCi(pObj) );
if ( Gia_ObjCioId(pObj) == Tim_ManBoxOutputLast(pManTime, iBox) )
pObj->fMark0 = 1, Count2++;
}
if ( fVerbose ) if ( fVerbose )
printf( "Fixed %d flop inputs and %d box/box connections (out of %d boxes).\n", printf( "Fixed %d flop inputs and %d box/box connections (out of %d non-flop boxes).\n",
Count1, Count2, nBoxes - Gia_ManRegBoxNum(p) ); Gia_ManRegBoxNum(p), Vec_IntSize(vCarryOuts), Gia_ManNonRegBoxNum(p) );
Vec_IntFree( vCarryOuts );
// compute representatives // compute representatives
pClp2Gia[0] = 0; pClp2Gia[0] = 0;
...@@ -553,6 +612,8 @@ Gia_Man_t * Gia_ManSweepWithBoxes( Gia_Man_t * p, void * pParsC, void * pParsS, ...@@ -553,6 +612,8 @@ Gia_Man_t * Gia_ManSweepWithBoxes( Gia_Man_t * p, void * pParsC, void * pParsS,
pNew = Gia_ManDupNormalize( pTemp = pNew ); pNew = Gia_ManDupNormalize( pTemp = pNew );
Gia_ManTransferTiming( pNew, pTemp ); Gia_ManTransferTiming( pNew, pTemp );
Gia_ManStop( pTemp ); Gia_ManStop( pTemp );
// check integrity
//Gia_ManCheckIntegrityWithBoxes( pNew );
return pNew; return pNew;
} }
......
...@@ -54,6 +54,18 @@ int Gia_ManRegBoxNum( Gia_Man_t * p ) ...@@ -54,6 +54,18 @@ int Gia_ManRegBoxNum( Gia_Man_t * p )
{ {
return p->vRegClasses ? Vec_IntSize(p->vRegClasses) : 0; return p->vRegClasses ? Vec_IntSize(p->vRegClasses) : 0;
} }
int Gia_ManNonRegBoxNum( Gia_Man_t * p )
{
return Gia_ManBoxNum(p) - Gia_ManRegBoxNum(p);
}
int Gia_ManBoxCiNum( Gia_Man_t * p )
{
return p->pManTime ? Gia_ManCiNum(p) - Tim_ManPiNum((Tim_Man_t *)p->pManTime) : 0;
}
int Gia_ManBoxCoNum( Gia_Man_t * p )
{
return p->pManTime ? Gia_ManCoNum(p) - Tim_ManPoNum((Tim_Man_t *)p->pManTime) : 0;
}
/**Function************************************************************* /**Function*************************************************************
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment