Commit 78855cc9 by Alan Mishchenko

Added supporting dual-output seq miters in &trim.

parent 8a89f1c3
......@@ -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 );
......
......@@ -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;
}
......
......@@ -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" );
......
......@@ -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;
}
......
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