mirror of https://github.com/YosysHQ/abc.git
Added switch &trim -c to additionally remove direct connections (POs fed by PIs).
This commit is contained in:
parent
aa78ce56e7
commit
f09afdf24c
|
|
@ -1003,6 +1003,58 @@ Gia_Man_t * Gia_ManDupTrimmed( Gia_Man_t * p, int fTrimCis, int fTrimCos, int fD
|
|||
return pNew;
|
||||
}
|
||||
|
||||
/**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.]
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
Loading…
Reference in New Issue