Commit 7d56aaba by Alan Mishchenko

Upgrading 'mfs2' to consider some nodes as having no level.

parent 608fe4e3
...@@ -247,7 +247,7 @@ Sfm_Ntk_t * Gia_ManExtractMfs( Gia_Man_t * p, Gia_Man_t * pBoxes, Vec_Int_t ** p ...@@ -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_IntFree( vPoNodes );
Vec_WrdFree( vTruthsTemp ); Vec_WrdFree( vTruthsTemp );
*pvId2Mfs = vId2Mfs; *pvId2Mfs = vId2Mfs;
return Sfm_NtkConstruct( vFanins, nPiNum, nPoNum, vFixed, vTruths ); return Sfm_NtkConstruct( vFanins, nPiNum, nPoNum, vFixed, NULL, vTruths );
} }
/**Function************************************************************* /**Function*************************************************************
......
...@@ -134,7 +134,7 @@ Sfm_Ntk_t * Abc_NtkExtractMfs( Abc_Ntk_t * pNtk, int nFirstFixed ) ...@@ -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++ ) // for ( i = Abc_NtkCiNum(pNtk); i + Abc_NtkCoNum(pNtk) < Abc_NtkObjNum(pNtk); i++ )
// if ( rand() % 10 == 0 ) // if ( rand() % 10 == 0 )
// Vec_StrWriteEntry( vFixed, i, (char)1 ); // 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************************************************************* /**Function*************************************************************
......
...@@ -23,7 +23,7 @@ ...@@ -23,7 +23,7 @@
ABC_NAMESPACE_IMPL_START ABC_NAMESPACE_IMPL_START
//#define USE_ABC2 #define USE_ABC2
//#define USE_ABC85 //#define USE_ABC85
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
......
...@@ -69,7 +69,7 @@ struct Sfm_Par_t_ ...@@ -69,7 +69,7 @@ struct Sfm_Par_t_
extern void Sfm_ParSetDefault( Sfm_Par_t * pPars ); extern void Sfm_ParSetDefault( Sfm_Par_t * pPars );
extern int Sfm_NtkPerform( Sfm_Ntk_t * p, Sfm_Par_t * pPars ); extern int Sfm_NtkPerform( Sfm_Ntk_t * p, Sfm_Par_t * pPars );
/*=== sfmNtk.c ==========================================================*/ /*=== 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 void Sfm_NtkFree( Sfm_Ntk_t * p );
extern Vec_Int_t * Sfm_NodeReadFanins( Sfm_Ntk_t * p, int i ); extern Vec_Int_t * Sfm_NodeReadFanins( Sfm_Ntk_t * p, int i );
extern word * Sfm_NodeReadTruth( Sfm_Ntk_t * p, int i ); extern word * Sfm_NodeReadTruth( Sfm_Ntk_t * p, int i );
......
...@@ -61,6 +61,7 @@ struct Sfm_Ntk_t_ ...@@ -61,6 +61,7 @@ struct Sfm_Ntk_t_
int nLevelMax; // maximum level int nLevelMax; // maximum level
// user data // user data
Vec_Str_t * vFixed; // persistent objects Vec_Str_t * vFixed; // persistent objects
Vec_Str_t * vEmpty; // transparent objects
Vec_Wrd_t * vTruths; // truth tables Vec_Wrd_t * vTruths; // truth tables
Vec_Wec_t vFanins; // fanins Vec_Wec_t vFanins; // fanins
// attributes // attributes
...@@ -129,6 +130,8 @@ static inline int Sfm_ObjIsPi( Sfm_Ntk_t * p, int i ) { return ...@@ -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_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_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_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_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); } static inline Vec_Int_t * Sfm_ObjFoArray( Sfm_Ntk_t * p, int i ) { return Vec_WecEntry(&p->vFanouts, i); }
......
...@@ -107,21 +107,21 @@ void Sfm_CreateFanout( Vec_Wec_t * vFanins, Vec_Wec_t * vFanouts ) ...@@ -107,21 +107,21 @@ void Sfm_CreateFanout( Vec_Wec_t * vFanins, Vec_Wec_t * vFanouts )
SeeAlso [] 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; int k, Fanin, Level = 0;
Vec_IntForEachEntry( vArray, Fanin, k ) Vec_IntForEachEntry( vArray, Fanin, k )
Level = Abc_MaxInt( Level, Vec_IntEntry(vLevels, Fanin) ); 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; Vec_Int_t * vArray;
int i; int i;
assert( Vec_IntSize(vLevels) == 0 ); assert( Vec_IntSize(vLevels) == 0 );
Vec_IntFill( vLevels, Vec_WecSize(vFanins), 0 ); Vec_IntFill( vLevels, Vec_WecSize(vFanins), 0 );
Vec_WecForEachLevel( vFanins, vArray, i ) 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************************************************************* /**Function*************************************************************
...@@ -135,21 +135,21 @@ void Sfm_CreateLevel( Vec_Wec_t * vFanins, Vec_Int_t * vLevels ) ...@@ -135,21 +135,21 @@ void Sfm_CreateLevel( Vec_Wec_t * vFanins, Vec_Int_t * vLevels )
SeeAlso [] 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; int k, Fanout, LevelR = 0;
Vec_IntForEachEntry( vArray, Fanout, k ) Vec_IntForEachEntry( vArray, Fanout, k )
LevelR = Abc_MaxInt( LevelR, Vec_IntEntry(vLevelsR, Fanout) ); 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; Vec_Int_t * vArray;
int i; int i;
assert( Vec_IntSize(vLevelsR) == 0 ); assert( Vec_IntSize(vLevelsR) == 0 );
Vec_IntFill( vLevelsR, Vec_WecSize(vFanouts), 0 ); Vec_IntFill( vLevelsR, Vec_WecSize(vFanouts), 0 );
Vec_WecForEachLevelReverse( vFanouts, vArray, i ) 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************************************************************* /**Function*************************************************************
...@@ -163,7 +163,7 @@ void Sfm_CreateLevelR( Vec_Wec_t * vFanouts, Vec_Int_t * vLevelsR ) ...@@ -163,7 +163,7 @@ void Sfm_CreateLevelR( Vec_Wec_t * vFanouts, Vec_Int_t * vLevelsR )
SeeAlso [] 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_Ntk_t * p;
Sfm_CheckConsistency( vFanins, nPis, nPos, vFixed ); 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 ...@@ -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; p->nNodes = p->nObjs - p->nPis - p->nPos;
// user data // user data
p->vFixed = vFixed; p->vFixed = vFixed;
p->vEmpty = vEmpty;
p->vTruths = vTruths; p->vTruths = vTruths;
p->vFanins = *vFanins; p->vFanins = *vFanins;
ABC_FREE( vFanins ); ABC_FREE( vFanins );
// attributes // attributes
Sfm_CreateFanout( &p->vFanins, &p->vFanouts ); Sfm_CreateFanout( &p->vFanins, &p->vFanouts );
Sfm_CreateLevel( &p->vFanins, &p->vLevels ); Sfm_CreateLevel( &p->vFanins, &p->vLevels, vEmpty );
Sfm_CreateLevelR( &p->vFanouts, &p->vLevelsR ); Sfm_CreateLevelR( &p->vFanouts, &p->vLevelsR, vEmpty );
Vec_IntFill( &p->vCounts, p->nObjs, 0 ); Vec_IntFill( &p->vCounts, p->nObjs, 0 );
Vec_IntFill( &p->vTravIds, p->nObjs, 0 ); Vec_IntFill( &p->vTravIds, p->nObjs, 0 );
Vec_IntFill( &p->vTravIds2, p->nObjs, 0 ); Vec_IntFill( &p->vTravIds2, p->nObjs, 0 );
...@@ -212,6 +213,7 @@ void Sfm_NtkFree( Sfm_Ntk_t * p ) ...@@ -212,6 +213,7 @@ void Sfm_NtkFree( Sfm_Ntk_t * p )
{ {
// user data // user data
Vec_StrFree( p->vFixed ); Vec_StrFree( p->vFixed );
Vec_StrFree( p->vEmpty );
Vec_WrdFree( p->vTruths ); Vec_WrdFree( p->vTruths );
Vec_WecErase( &p->vFanins ); Vec_WecErase( &p->vFanins );
// attributes // attributes
...@@ -291,7 +293,7 @@ void Sfm_NtkDeleteObj_rec( Sfm_Ntk_t * p, int iNode ) ...@@ -291,7 +293,7 @@ void Sfm_NtkDeleteObj_rec( Sfm_Ntk_t * p, int iNode )
void Sfm_NtkUpdateLevel_rec( Sfm_Ntk_t * p, int iNode ) void Sfm_NtkUpdateLevel_rec( Sfm_Ntk_t * p, int iNode )
{ {
int i, iFanout; 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) ) if ( LevelNew == Sfm_ObjLevel(p, iNode) )
return; return;
Sfm_ObjSetLevel( p, iNode, LevelNew ); Sfm_ObjSetLevel( p, iNode, LevelNew );
...@@ -301,7 +303,7 @@ void Sfm_NtkUpdateLevel_rec( Sfm_Ntk_t * p, int iNode ) ...@@ -301,7 +303,7 @@ void Sfm_NtkUpdateLevel_rec( Sfm_Ntk_t * p, int iNode )
void Sfm_NtkUpdateLevelR_rec( Sfm_Ntk_t * p, int iNode ) void Sfm_NtkUpdateLevelR_rec( Sfm_Ntk_t * p, int iNode )
{ {
int i, iFanin; 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) ) if ( LevelNew == Sfm_ObjLevelR(p, iNode) )
return; return;
Sfm_ObjSetLevelR( p, iNode, LevelNew ); Sfm_ObjSetLevelR( p, iNode, LevelNew );
......
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