diff options
author | Alan Mishchenko <alanmi@berkeley.edu> | 2012-07-20 13:52:39 -0700 |
---|---|---|
committer | Alan Mishchenko <alanmi@berkeley.edu> | 2012-07-20 13:52:39 -0700 |
commit | f09afdf24c28d5e7f093151380a84ca21b69f8f2 (patch) | |
tree | a1bf0011b9b1ecfdf07338fa7cb393faa7857f39 /src | |
parent | aa78ce56e73427a2a30669a2bbedacc3bb8caa9d (diff) | |
download | abc-f09afdf24c28d5e7f093151380a84ca21b69f8f2.tar.gz abc-f09afdf24c28d5e7f093151380a84ca21b69f8f2.tar.bz2 abc-f09afdf24c28d5e7f093151380a84ca21b69f8f2.zip |
Added switch &trim -c to additionally remove direct connections (POs fed by PIs).
Diffstat (limited to 'src')
-rw-r--r-- | src/aig/gia/giaDup.c | 52 | ||||
-rw-r--r-- | src/base/abci/abc.c | 17 |
2 files changed, 66 insertions, 3 deletions
diff --git a/src/aig/gia/giaDup.c b/src/aig/gia/giaDup.c index 520385b8..3c64575e 100644 --- a/src/aig/gia/giaDup.c +++ b/src/aig/gia/giaDup.c @@ -1005,6 +1005,58 @@ Gia_Man_t * Gia_ManDupTrimmed( Gia_Man_t * p, int fTrimCis, int fTrimCos, int fD /**Function************************************************************* + Synopsis [Removes POs driven by PIs and PIs without fanout.] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +Gia_Man_t * Gia_ManDupTrimmed2( Gia_Man_t * p ) +{ + Gia_Man_t * pNew; + Gia_Obj_t * pObj; + int i; + // start new manager + pNew = Gia_ManStart( Gia_ManObjNum(p) ); + pNew->pName = Abc_UtilStrsav( p->pName ); + // check if there are PIs to be added + Gia_ManCreateRefs( p ); + // discount references of POs + Gia_ManForEachPo( p, pObj, i ) + Gia_ObjRefFanin0Dec( p, pObj ); + // check if PIs are left + Gia_ManForEachPi( p, pObj, i ) + if ( Gia_ObjRefs(p, pObj) ) + break; + if ( i == Gia_ManPiNum(p) ) // there is no PIs - add dummy PI + Gia_ManAppendCi(pNew); + // add the ROs + Gia_ManFillValue( p ); + Gia_ManConst0(p)->Value = 0; + Gia_ManForEachCi( p, pObj, i ) + if ( Gia_ObjRefs(p, pObj) || Gia_ObjIsRo(p, pObj) ) + pObj->Value = Gia_ManAppendCi(pNew); + Gia_ManForEachAnd( p, pObj, i ) + pObj->Value = Gia_ManAppendAnd( pNew, Gia_ObjFanin0Copy(pObj), Gia_ObjFanin1Copy(pObj) ); + // check if there are POs to be added + Gia_ManForEachPo( p, pObj, i ) + if ( !Gia_ObjIsConst0(Gia_ObjFanin0(pObj)) && !Gia_ObjIsPi(p, Gia_ObjFanin0(pObj)) ) + break; + if ( i == Gia_ManPoNum(p) ) // there is no POs - add dummy PO + Gia_ManAppendCo( pNew, 0 ); + Gia_ManForEachCo( p, pObj, i ) + if ( (!Gia_ObjIsConst0(Gia_ObjFanin0(pObj)) && !Gia_ObjIsPi(p, Gia_ObjFanin0(pObj))) || Gia_ObjIsRi(p, pObj) ) + Gia_ManAppendCo( pNew, Gia_ObjFanin0Copy(pObj) ); + Gia_ManSetRegNum( pNew, Gia_ManRegNum(p) ); + assert( !Gia_ManHasDangling( pNew ) ); + return pNew; +} + +/**Function************************************************************* + Synopsis [Duplicates AIG in the DFS order while putting CIs first.] Description [] diff --git a/src/base/abci/abc.c b/src/base/abci/abc.c index 0471d441..e218ad82 100644 --- a/src/base/abci/abc.c +++ b/src/base/abci/abc.c @@ -23555,13 +23555,14 @@ usage: ***********************************************************************/ int Abc_CommandAbc9Trim( Abc_Frame_t * pAbc, int argc, char ** argv ) { - Gia_Man_t * pTemp; + Gia_Man_t * pTemp, * pTemp2; int c; int fTrimCis = 1; int fTrimCos = 1; int fDualOut = 0; + int fPoFedByPi = 0; Extra_UtilGetoptReset(); - while ( ( c = Extra_UtilGetopt( argc, argv, "iodh" ) ) != EOF ) + while ( ( c = Extra_UtilGetopt( argc, argv, "iocdh" ) ) != EOF ) { switch ( c ) { @@ -23571,6 +23572,9 @@ int Abc_CommandAbc9Trim( Abc_Frame_t * pAbc, int argc, char ** argv ) case 'o': fTrimCos ^= 1; break; + case 'c': + fPoFedByPi ^= 1; + break; case 'd': fDualOut ^= 1; break; @@ -23586,14 +23590,21 @@ int Abc_CommandAbc9Trim( Abc_Frame_t * pAbc, int argc, char ** argv ) return 1; } pTemp = Gia_ManDupTrimmed( pAbc->pGia, fTrimCis, fTrimCos, fDualOut ); + if ( fPoFedByPi ) + { + extern Gia_Man_t * Gia_ManDupTrimmed2( Gia_Man_t * p ); + pTemp = Gia_ManDupTrimmed2( pTemp2 = pTemp ); + Gia_ManStop( pTemp2 ); + } Abc_CommandUpdate9( pAbc, pTemp ); return 0; usage: - Abc_Print( -2, "usage: &trim [-iodh]\n" ); + Abc_Print( -2, "usage: &trim [-iocdh]\n" ); Abc_Print( -2, "\t removes PIs without fanout and PO driven by constants\n" ); Abc_Print( -2, "\t-i : toggle removing PIs [default = %s]\n", fTrimCis? "yes": "no" ); Abc_Print( -2, "\t-o : toggle removing POs [default = %s]\n", fTrimCos? "yes": "no" ); + Abc_Print( -2, "\t-c : toggle additionally removing POs fed by PIs [default = %s]\n", fPoFedByPi? "yes": "no" ); Abc_Print( -2, "\t-d : toggle using dual-output miter [default = %s]\n", fDualOut? "yes": "no" ); Abc_Print( -2, "\t-h : print the command usage\n"); return 1; |