diff options
-rw-r--r-- | src/aig/gia/giaMfs.c | 2 | ||||
-rw-r--r-- | src/base/abci/abcMfs.c | 2 | ||||
-rw-r--r-- | src/base/main/mainInit.c | 2 | ||||
-rw-r--r-- | src/opt/sfm/sfm.h | 2 | ||||
-rw-r--r-- | src/opt/sfm/sfmInt.h | 3 | ||||
-rw-r--r-- | src/opt/sfm/sfmNtk.c | 28 |
6 files changed, 22 insertions, 17 deletions
diff --git a/src/aig/gia/giaMfs.c b/src/aig/gia/giaMfs.c index 8a8e3686..4f6e74a1 100644 --- a/src/aig/gia/giaMfs.c +++ b/src/aig/gia/giaMfs.c @@ -247,7 +247,7 @@ Sfm_Ntk_t * Gia_ManExtractMfs( Gia_Man_t * p, Gia_Man_t * pBoxes, Vec_Int_t ** p Vec_IntFree( vPoNodes ); Vec_WrdFree( vTruthsTemp ); *pvId2Mfs = vId2Mfs; - return Sfm_NtkConstruct( vFanins, nPiNum, nPoNum, vFixed, vTruths ); + return Sfm_NtkConstruct( vFanins, nPiNum, nPoNum, vFixed, NULL, vTruths ); } /**Function************************************************************* diff --git a/src/base/abci/abcMfs.c b/src/base/abci/abcMfs.c index aa2a702e..28715057 100644 --- a/src/base/abci/abcMfs.c +++ b/src/base/abci/abcMfs.c @@ -134,7 +134,7 @@ Sfm_Ntk_t * Abc_NtkExtractMfs( Abc_Ntk_t * pNtk, int nFirstFixed ) // for ( i = Abc_NtkCiNum(pNtk); i + Abc_NtkCoNum(pNtk) < Abc_NtkObjNum(pNtk); i++ ) // if ( rand() % 10 == 0 ) // Vec_StrWriteEntry( vFixed, i, (char)1 ); - return Sfm_NtkConstruct( vFanins, Abc_NtkCiNum(pNtk), Abc_NtkCoNum(pNtk), vFixed, vTruths ); + return Sfm_NtkConstruct( vFanins, Abc_NtkCiNum(pNtk), Abc_NtkCoNum(pNtk), vFixed, NULL, vTruths ); } /**Function************************************************************* diff --git a/src/base/main/mainInit.c b/src/base/main/mainInit.c index bbe0bbd1..bdf0613e 100644 --- a/src/base/main/mainInit.c +++ b/src/base/main/mainInit.c @@ -23,7 +23,7 @@ ABC_NAMESPACE_IMPL_START -//#define USE_ABC2 +#define USE_ABC2 //#define USE_ABC85 //////////////////////////////////////////////////////////////////////// diff --git a/src/opt/sfm/sfm.h b/src/opt/sfm/sfm.h index cc797afc..d9156513 100644 --- a/src/opt/sfm/sfm.h +++ b/src/opt/sfm/sfm.h @@ -69,7 +69,7 @@ struct Sfm_Par_t_ extern void Sfm_ParSetDefault( Sfm_Par_t * pPars ); extern int Sfm_NtkPerform( Sfm_Ntk_t * p, Sfm_Par_t * pPars ); /*=== sfmNtk.c ==========================================================*/ -extern Sfm_Ntk_t * Sfm_NtkConstruct( Vec_Wec_t * vFanins, int nPis, int nPos, Vec_Str_t * vFixed, Vec_Wrd_t * vTruths ); +extern Sfm_Ntk_t * Sfm_NtkConstruct( Vec_Wec_t * vFanins, int nPis, int nPos, Vec_Str_t * vFixed, Vec_Str_t * vEmpty, Vec_Wrd_t * vTruths ); extern void Sfm_NtkFree( Sfm_Ntk_t * p ); extern Vec_Int_t * Sfm_NodeReadFanins( Sfm_Ntk_t * p, int i ); extern word * Sfm_NodeReadTruth( Sfm_Ntk_t * p, int i ); diff --git a/src/opt/sfm/sfmInt.h b/src/opt/sfm/sfmInt.h index b3e1909d..84a4491a 100644 --- a/src/opt/sfm/sfmInt.h +++ b/src/opt/sfm/sfmInt.h @@ -61,6 +61,7 @@ struct Sfm_Ntk_t_ int nLevelMax; // maximum level // user data Vec_Str_t * vFixed; // persistent objects + Vec_Str_t * vEmpty; // transparent objects Vec_Wrd_t * vTruths; // truth tables Vec_Wec_t vFanins; // fanins // attributes @@ -129,6 +130,8 @@ static inline int Sfm_ObjIsPi( Sfm_Ntk_t * p, int i ) { return static inline int Sfm_ObjIsPo( Sfm_Ntk_t * p, int i ) { return i + p->nPos >= p->nObjs; } static inline int Sfm_ObjIsNode( Sfm_Ntk_t * p, int i ) { return i >= p->nPis && i + p->nPos < p->nObjs; } static inline int Sfm_ObjIsFixed( Sfm_Ntk_t * p, int i ) { return Vec_StrEntry(p->vFixed, i); } +static inline int Sfm_ObjAddsLevelArray( Vec_Str_t * p, int i ) { return p == NULL || Vec_StrEntry(p, i) == 0; } +static inline int Sfm_ObjAddsLevel( Sfm_Ntk_t * p, int i ) { return Sfm_ObjAddsLevelArray(p->vEmpty, i); } static inline Vec_Int_t * Sfm_ObjFiArray( Sfm_Ntk_t * p, int i ) { return Vec_WecEntry(&p->vFanins, i); } static inline Vec_Int_t * Sfm_ObjFoArray( Sfm_Ntk_t * p, int i ) { return Vec_WecEntry(&p->vFanouts, i); } diff --git a/src/opt/sfm/sfmNtk.c b/src/opt/sfm/sfmNtk.c index 1e650454..edd14f95 100644 --- a/src/opt/sfm/sfmNtk.c +++ b/src/opt/sfm/sfmNtk.c @@ -107,21 +107,21 @@ void Sfm_CreateFanout( Vec_Wec_t * vFanins, Vec_Wec_t * vFanouts ) SeeAlso [] ***********************************************************************/ -static inline int Sfm_ObjLevelNew( Vec_Int_t * vArray, Vec_Int_t * vLevels ) +static inline int Sfm_ObjLevelNew( Vec_Int_t * vArray, Vec_Int_t * vLevels, int fAddLevel ) { int k, Fanin, Level = 0; Vec_IntForEachEntry( vArray, Fanin, k ) Level = Abc_MaxInt( Level, Vec_IntEntry(vLevels, Fanin) ); - return Level + 1; + return Level + fAddLevel; } -void Sfm_CreateLevel( Vec_Wec_t * vFanins, Vec_Int_t * vLevels ) +void Sfm_CreateLevel( Vec_Wec_t * vFanins, Vec_Int_t * vLevels, Vec_Str_t * vEmpty ) { Vec_Int_t * vArray; int i; assert( Vec_IntSize(vLevels) == 0 ); Vec_IntFill( vLevels, Vec_WecSize(vFanins), 0 ); Vec_WecForEachLevel( vFanins, vArray, i ) - Vec_IntWriteEntry( vLevels, i, Sfm_ObjLevelNew(vArray, vLevels) ); + Vec_IntWriteEntry( vLevels, i, Sfm_ObjLevelNew(vArray, vLevels, Sfm_ObjAddsLevelArray(vEmpty, i)) ); } /**Function************************************************************* @@ -135,21 +135,21 @@ void Sfm_CreateLevel( Vec_Wec_t * vFanins, Vec_Int_t * vLevels ) SeeAlso [] ***********************************************************************/ -static inline int Sfm_ObjLevelNewR( Vec_Int_t * vArray, Vec_Int_t * vLevelsR ) +static inline int Sfm_ObjLevelNewR( Vec_Int_t * vArray, Vec_Int_t * vLevelsR, int fAddLevel ) { int k, Fanout, LevelR = 0; Vec_IntForEachEntry( vArray, Fanout, k ) LevelR = Abc_MaxInt( LevelR, Vec_IntEntry(vLevelsR, Fanout) ); - return LevelR + 1; + return LevelR + fAddLevel; } -void Sfm_CreateLevelR( Vec_Wec_t * vFanouts, Vec_Int_t * vLevelsR ) +void Sfm_CreateLevelR( Vec_Wec_t * vFanouts, Vec_Int_t * vLevelsR, Vec_Str_t * vEmpty ) { Vec_Int_t * vArray; int i; assert( Vec_IntSize(vLevelsR) == 0 ); Vec_IntFill( vLevelsR, Vec_WecSize(vFanouts), 0 ); Vec_WecForEachLevelReverse( vFanouts, vArray, i ) - Vec_IntWriteEntry( vLevelsR, i, Sfm_ObjLevelNewR(vArray, vLevelsR) ); + Vec_IntWriteEntry( vLevelsR, i, Sfm_ObjLevelNewR(vArray, vLevelsR, Sfm_ObjAddsLevelArray(vEmpty, i)) ); } /**Function************************************************************* @@ -163,7 +163,7 @@ void Sfm_CreateLevelR( Vec_Wec_t * vFanouts, Vec_Int_t * vLevelsR ) SeeAlso [] ***********************************************************************/ -Sfm_Ntk_t * Sfm_NtkConstruct( Vec_Wec_t * vFanins, int nPis, int nPos, Vec_Str_t * vFixed, Vec_Wrd_t * vTruths ) +Sfm_Ntk_t * Sfm_NtkConstruct( Vec_Wec_t * vFanins, int nPis, int nPos, Vec_Str_t * vFixed, Vec_Str_t * vEmpty, Vec_Wrd_t * vTruths ) { Sfm_Ntk_t * p; Sfm_CheckConsistency( vFanins, nPis, nPos, vFixed ); @@ -174,13 +174,14 @@ Sfm_Ntk_t * Sfm_NtkConstruct( Vec_Wec_t * vFanins, int nPis, int nPos, Vec_Str_t p->nNodes = p->nObjs - p->nPis - p->nPos; // user data p->vFixed = vFixed; + p->vEmpty = vEmpty; p->vTruths = vTruths; p->vFanins = *vFanins; ABC_FREE( vFanins ); // attributes Sfm_CreateFanout( &p->vFanins, &p->vFanouts ); - Sfm_CreateLevel( &p->vFanins, &p->vLevels ); - Sfm_CreateLevelR( &p->vFanouts, &p->vLevelsR ); + Sfm_CreateLevel( &p->vFanins, &p->vLevels, vEmpty ); + Sfm_CreateLevelR( &p->vFanouts, &p->vLevelsR, vEmpty ); Vec_IntFill( &p->vCounts, p->nObjs, 0 ); Vec_IntFill( &p->vTravIds, p->nObjs, 0 ); Vec_IntFill( &p->vTravIds2, p->nObjs, 0 ); @@ -212,6 +213,7 @@ void Sfm_NtkFree( Sfm_Ntk_t * p ) { // user data Vec_StrFree( p->vFixed ); + Vec_StrFree( p->vEmpty ); Vec_WrdFree( p->vTruths ); Vec_WecErase( &p->vFanins ); // attributes @@ -291,7 +293,7 @@ void Sfm_NtkDeleteObj_rec( Sfm_Ntk_t * p, int iNode ) void Sfm_NtkUpdateLevel_rec( Sfm_Ntk_t * p, int iNode ) { int i, iFanout; - int LevelNew = Sfm_ObjLevelNew( Sfm_ObjFiArray(p, iNode), &p->vLevels ); + int LevelNew = Sfm_ObjLevelNew( Sfm_ObjFiArray(p, iNode), &p->vLevels, Sfm_ObjAddsLevel(p, iNode) ); if ( LevelNew == Sfm_ObjLevel(p, iNode) ) return; Sfm_ObjSetLevel( p, iNode, LevelNew ); @@ -301,7 +303,7 @@ void Sfm_NtkUpdateLevel_rec( Sfm_Ntk_t * p, int iNode ) void Sfm_NtkUpdateLevelR_rec( Sfm_Ntk_t * p, int iNode ) { int i, iFanin; - int LevelNew = Sfm_ObjLevelNewR( Sfm_ObjFoArray(p, iNode), &p->vLevelsR ); + int LevelNew = Sfm_ObjLevelNewR( Sfm_ObjFoArray(p, iNode), &p->vLevelsR, Sfm_ObjAddsLevel(p, iNode) ); if ( LevelNew == Sfm_ObjLevelR(p, iNode) ) return; Sfm_ObjSetLevelR( p, iNode, LevelNew ); |