diff options
author | Alan Mishchenko <alanmi@berkeley.edu> | 2013-10-09 22:30:03 -0700 |
---|---|---|
committer | Alan Mishchenko <alanmi@berkeley.edu> | 2013-10-09 22:30:03 -0700 |
commit | 7d56aabab667d8b550f72c426feac11f78029630 (patch) | |
tree | 5c641db42195b24e7765c5d4f71bc9cfa380e726 /src/opt | |
parent | 608fe4e3bd2051aeba4cb557af6f348d0fb1075c (diff) | |
download | abc-7d56aabab667d8b550f72c426feac11f78029630.tar.gz abc-7d56aabab667d8b550f72c426feac11f78029630.tar.bz2 abc-7d56aabab667d8b550f72c426feac11f78029630.zip |
Upgrading 'mfs2' to consider some nodes as having no level.
Diffstat (limited to 'src/opt')
-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 |
3 files changed, 19 insertions, 14 deletions
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 ); |