diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/aig/gia/gia.h | 2 | ||||
-rw-r--r-- | src/aig/gia/giaDup.c | 51 | ||||
-rw-r--r-- | src/aig/gia/giaReparam.c | 2 | ||||
-rw-r--r-- | src/base/abci/abc.c | 11 |
4 files changed, 56 insertions, 10 deletions
diff --git a/src/aig/gia/gia.h b/src/aig/gia/gia.h index 2d465e86..8b8013bb 100644 --- a/src/aig/gia/gia.h +++ b/src/aig/gia/gia.h @@ -676,7 +676,7 @@ extern Gia_Man_t * Gia_ManDupDfsSkip( Gia_Man_t * p ); extern Gia_Man_t * Gia_ManDupDfsCone( Gia_Man_t * p, Gia_Obj_t * pObj ); extern Gia_Man_t * Gia_ManDupDfsLitArray( Gia_Man_t * p, Vec_Int_t * vLits ); extern Gia_Man_t * Gia_ManDupNormalized( Gia_Man_t * p ); -extern Gia_Man_t * Gia_ManDupTrimmed( Gia_Man_t * p, int fTrimCis, int fTrimCos ); +extern Gia_Man_t * Gia_ManDupTrimmed( Gia_Man_t * p, int fTrimCis, int fTrimCos, int fDualOut ); extern Gia_Man_t * Gia_ManDupOntop( Gia_Man_t * p, Gia_Man_t * p2 ); extern Gia_Man_t * Gia_ManDupDfsCiMap( Gia_Man_t * p, int * pCi2Lit, Vec_Int_t * vLits ); extern Gia_Man_t * Gia_ManDupDfsClasses( Gia_Man_t * p ); diff --git a/src/aig/gia/giaDup.c b/src/aig/gia/giaDup.c index 7084a38e..28af14da 100644 --- a/src/aig/gia/giaDup.c +++ b/src/aig/gia/giaDup.c @@ -901,25 +901,66 @@ Gia_Man_t * Gia_ManDupNormalized( Gia_Man_t * p ) SeeAlso [] ***********************************************************************/ -Gia_Man_t * Gia_ManDupTrimmed( Gia_Man_t * p, int fTrimCis, int fTrimCos ) +Gia_Man_t * Gia_ManDupTrimmed( Gia_Man_t * p, int fTrimCis, int fTrimCos, int fDualOut ) { Gia_Man_t * pNew; Gia_Obj_t * pObj; int i; - Gia_ManFillValue( p ); pNew = Gia_ManStart( Gia_ManObjNum(p) ); pNew->pName = Abc_UtilStrsav( p->pName ); + // check if there are PIs to be added Gia_ManSetRefs( p ); + Gia_ManForEachPi( p, pObj, i ) + if ( !fTrimCis || pObj->Value > 0 ) + 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 ( !fTrimCis || pObj->Value > 0 || 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) ); - Gia_ManForEachCo( p, pObj, i ) - if ( !fTrimCos || !Gia_ObjIsConst0(Gia_ObjFanin0(pObj)) || Gia_ObjIsRi(p, pObj) ) + if ( fDualOut && fTrimCos ) + { + Gia_Man_t * pNonDual, * pTemp; + Gia_Obj_t * pPo0, * pPo1; + // create non-dual miter + assert( (Gia_ManPoNum(p) & 1) == 0 ); + pNonDual = Gia_ManTransformMiter( p ); + pNonDual = Gia_ManSeqStructSweep( pTemp = pNonDual, 1, 1, 0 ); + Gia_ManStop( pTemp ); + assert( Gia_ManPiNum(pNonDual) > 0 ); + assert( 2 * Gia_ManPoNum(pNonDual) == Gia_ManPoNum(p) ); + // skip PO pairs corresponding to const0 POs of the non-dual miter + Gia_ManForEachPo( pNonDual, pObj, i ) + if ( !Gia_ObjIsConst0(Gia_ObjFanin0(pObj)) ) + { + pPo0 = Gia_ManPo( p, 2*i+0 ); + pPo1 = Gia_ManPo( p, 2*i+1 ); + pPo0->Value = Gia_ManAppendCo( pNew, Gia_ObjFanin0Copy(pPo0) ); + pPo1->Value = Gia_ManAppendCo( pNew, Gia_ObjFanin0Copy(pPo1) ); + } + Gia_ManStop( pNonDual ); + Gia_ManForEachRi( p, pObj, i ) pObj->Value = Gia_ManAppendCo( pNew, Gia_ObjFanin0Copy(pObj) ); - Gia_ManSetRegNum( pNew, Gia_ManRegNum(p) ); + Gia_ManSetRegNum( pNew, Gia_ManRegNum(p) ); + // cleanup + pNew = Gia_ManSeqStructSweep( pTemp = pNew, 1, 1, 0 ); + Gia_ManStop( pTemp ); + // trim the PIs +// pNew = Gia_ManDupTrimmed( pTemp = pNew, 1, 0, 0 ); +// Gia_ManStop( pTemp ); + } + else + { + Gia_ManForEachCo( p, pObj, i ) + if ( !fTrimCos || !Gia_ObjIsConst0(Gia_ObjFanin0(pObj)) || Gia_ObjIsRi(p, pObj) ) + pObj->Value = Gia_ManAppendCo( pNew, Gia_ObjFanin0Copy(pObj) ); + Gia_ManSetRegNum( pNew, Gia_ManRegNum(p) ); + } return pNew; } diff --git a/src/aig/gia/giaReparam.c b/src/aig/gia/giaReparam.c index 59a45477..edaacdac 100644 --- a/src/aig/gia/giaReparam.c +++ b/src/aig/gia/giaReparam.c @@ -151,7 +151,7 @@ Gia_Man_t * Gia_ManReparam( Gia_Man_t * p, int fVerbose ) } // perform input trimming - pNew = Gia_ManDupTrimmed( p, 1, 0 ); + pNew = Gia_ManDupTrimmed( p, 1, 0, 0 ); if ( fVerbose ) { printf( "After PI trimming:\n" ); diff --git a/src/base/abci/abc.c b/src/base/abci/abc.c index 5fde1ca0..cb22493c 100644 --- a/src/base/abci/abc.c +++ b/src/base/abci/abc.c @@ -22949,8 +22949,9 @@ int Abc_CommandAbc9Trim( Abc_Frame_t * pAbc, int argc, char ** argv ) int c; int fTrimCis = 1; int fTrimCos = 1; + int fDualOut = 0; Extra_UtilGetoptReset(); - while ( ( c = Extra_UtilGetopt( argc, argv, "ioh" ) ) != EOF ) + while ( ( c = Extra_UtilGetopt( argc, argv, "iodh" ) ) != EOF ) { switch ( c ) { @@ -22960,6 +22961,9 @@ int Abc_CommandAbc9Trim( Abc_Frame_t * pAbc, int argc, char ** argv ) case 'o': fTrimCos ^= 1; break; + case 'd': + fDualOut ^= 1; + break; case 'h': goto usage; default: @@ -22971,15 +22975,16 @@ int Abc_CommandAbc9Trim( Abc_Frame_t * pAbc, int argc, char ** argv ) Abc_Print( -1, "Abc_CommandAbc9Trim(): There is no AIG.\n" ); return 1; } - pTemp = Gia_ManDupTrimmed( pAbc->pGia, fTrimCis, fTrimCos ); + pTemp = Gia_ManDupTrimmed( pAbc->pGia, fTrimCis, fTrimCos, fDualOut ); Abc_CommandUpdate9( pAbc, pTemp ); return 0; usage: - Abc_Print( -2, "usage: &trim [-ioh]\n" ); + Abc_Print( -2, "usage: &trim [-iodh]\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-d : toggle using dual-output miter [default = %s]\n", fDualOut? "yes": "no" ); Abc_Print( -2, "\t-h : print the command usage\n"); return 1; } |