Commit 6dbaa4d0 by Alan Mishchenko

Extended command &cone to extract timing critical cones.

parent 3ef00645
......@@ -1260,7 +1260,8 @@ extern Gia_Man_t * Gia_ManSeqStructSweep( Gia_Man_t * p, int fConst, int
extern Gia_Man_t * Gia_ManMapShrink4( Gia_Man_t * p, int fKeepLevel, int fVerbose );
extern Gia_Man_t * Gia_ManMapShrink6( Gia_Man_t * p, int nFanoutMax, int fKeepLevel, int fVerbose );
/*=== giaSopb.c ============================================================*/
extern Gia_Man_t * Gia_ManPerformSopBalanceWin( Gia_Man_t * p, int LevelMax, int nLevelRatio, int nCutNum, int nRelaxRatio, int fVerbose );
extern Gia_Man_t * Gia_ManPerformSopBalanceWin( Gia_Man_t * p, int LevelMax, int nTimeWindow, int nCutNum, int nRelaxRatio, int fVerbose );
extern Gia_Man_t * Gia_ManExtractWindow( Gia_Man_t * p, int LevelMax, int nTimeWindow, int fVerbose );
/*=== giaSort.c ============================================================*/
extern int * Gia_SortFloats( float * pArray, int * pPerm, int nSize );
/*=== giaSim.c ============================================================*/
......
......@@ -54,7 +54,7 @@ void Gia_ManHighlight_rec( Gia_Man_t * p, int iObj )
if ( Gia_ObjIsAnd(pObj) )
Gia_ManHighlight_rec( p, Gia_ObjFaninId1(pObj, iObj) );
}
void Gia_ManPrepareWin( Gia_Man_t * p, Vec_Int_t * vOuts, Vec_Int_t ** pvPis, Vec_Int_t ** pvPos, Vec_Int_t ** pvAnds )
void Gia_ManPrepareWin( Gia_Man_t * p, Vec_Int_t * vOuts, Vec_Int_t ** pvPis, Vec_Int_t ** pvPos, Vec_Int_t ** pvAnds, int fPoOnly )
{
Gia_Obj_t * pObj;
int i;
......@@ -64,15 +64,23 @@ void Gia_ManPrepareWin( Gia_Man_t * p, Vec_Int_t * vOuts, Vec_Int_t ** pvPis, Ve
Gia_ManHighlight_rec( p, Gia_ObjFaninId0p(p, pObj) );
// mark fanins of the outside area
Gia_ManCleanMark0( p );
Gia_ManForEachObj1( p, pObj, i )
if ( fPoOnly )
{
if ( Gia_ObjIsCi(pObj) )
continue;
if ( Gia_ObjIsAnd(pObj) && !Gia_ObjIsTravIdCurrentId(p, i) )
continue;
Gia_ObjFanin0(pObj)->fMark0 = 1;
if ( Gia_ObjIsAnd(pObj) )
Gia_ObjFanin1(pObj)->fMark0 = 1;
Gia_ManForEachCoVec( vOuts, p, pObj, i )
Gia_ObjFanin0(pObj)->fMark0 = 1;
}
else
{
Gia_ManForEachObj1( p, pObj, i )
{
if ( Gia_ObjIsCi(pObj) )
continue;
if ( Gia_ObjIsAnd(pObj) && !Gia_ObjIsTravIdCurrentId(p, i) )
continue;
Gia_ObjFanin0(pObj)->fMark0 = 1;
if ( Gia_ObjIsAnd(pObj) )
Gia_ObjFanin1(pObj)->fMark0 = 1;
}
}
// collect pointed nodes
*pvPis = Vec_IntAlloc( 1000 );
......@@ -103,13 +111,13 @@ void Gia_ManPrepareWin( Gia_Man_t * p, Vec_Int_t * vOuts, Vec_Int_t ** pvPis, Ve
SeeAlso []
***********************************************************************/
Gia_Man_t * Gia_ManExtractWin( Gia_Man_t * p, Vec_Int_t * vOuts )
Gia_Man_t * Gia_ManExtractWin( Gia_Man_t * p, Vec_Int_t * vOuts, int fPoOnly )
{
Vec_Int_t * vPis, * vPos, * vAnds;
Gia_Man_t * pNew;
Gia_Obj_t * pObj;
int i;
Gia_ManPrepareWin( p, vOuts, &vPis, &vPos, &vAnds );
Gia_ManPrepareWin( p, vOuts, &vPis, &vPos, &vAnds, fPoOnly );
// create AIG
pNew = Gia_ManStart( Vec_IntSize(vPis) + Vec_IntSize(vPos) + Vec_IntSize(vAnds) + 1 );
pNew->pName = Abc_UtilStrsav( p->pName );
......@@ -131,7 +139,7 @@ Gia_Man_t * Gia_ManInsertWin( Gia_Man_t * p, Vec_Int_t * vOuts, Gia_Man_t * pWin
Gia_Man_t * pNew, * pTemp;
Gia_Obj_t * pObj;
int i;
Gia_ManPrepareWin( p, vOuts, &vPis, &vPos, &vAnds );
Gia_ManPrepareWin( p, vOuts, &vPis, &vPos, &vAnds, 0 );
// create AIG
pNew = Gia_ManStart( Gia_ManObjNum(p) - Vec_IntSize(vAnds) + Gia_ManAndNum(pWin) );
pNew->pName = Abc_UtilStrsav( p->pName );
......@@ -175,15 +183,42 @@ Gia_Man_t * Gia_ManInsertWin( Gia_Man_t * p, Vec_Int_t * vOuts, Gia_Man_t * pWin
SeeAlso []
***********************************************************************/
Vec_Int_t * Gia_ManFindLatest( Gia_Man_t * p, int LevelMax )
Vec_Int_t * Gia_ManFindLatest( Gia_Man_t * p, int LevelMax, int nTimeWindow )
{
Vec_Int_t * vOuts;
Gia_Obj_t * pObj;
int i;
Vec_Int_t * vOuts;
vOuts = Vec_IntAlloc( 1000 );
Gia_ManForEachCo( p, pObj, i )
if ( Gia_ObjLevel(p, pObj) > LevelMax )
Vec_IntPush( vOuts, i );
if ( Gia_ManHasMapping(p) )
{
int i, k, iFan, nLevels = 0;
int * pLevels = ABC_CALLOC( int, Gia_ManObjNum(p) );
Gia_ManForEachLut( p, i )
{
Gia_LutForEachFanin( p, i, iFan, k )
pLevels[i] = Abc_MaxInt( pLevels[i], pLevels[iFan] );
pLevels[i]++;
nLevels = Abc_MaxInt( nLevels, pLevels[i] );
}
if ( nTimeWindow )
LevelMax = (int)((1.0 - 0.01 * nTimeWindow) * nLevels);
if ( nLevels < LevelMax )
printf( "The maximum mapped level (%d) is less than the target level (%d).\n", nLevels, LevelMax );
Gia_ManForEachCo( p, pObj, i )
if ( pLevels[Gia_ObjFaninId0p(p, pObj)] >= LevelMax )
Vec_IntPush( vOuts, i );
ABC_FREE( pLevels );
}
else
{
int i, nLevels = Gia_ManLevelNum( p );
if ( nTimeWindow )
LevelMax = (int)((1.0 - 0.01 * nTimeWindow) * nLevels);
if ( nLevels < LevelMax )
printf( "The maximum AIG level (%d) is less than the target level (%d).\n", nLevels, LevelMax );
Gia_ManForEachCo( p, pObj, i )
if ( Gia_ObjLevel(p, pObj) >= LevelMax )
Vec_IntPush( vOuts, i );
}
return vOuts;
}
......@@ -198,21 +233,20 @@ Vec_Int_t * Gia_ManFindLatest( Gia_Man_t * p, int LevelMax )
SeeAlso []
***********************************************************************/
Gia_Man_t * Gia_ManPerformSopBalanceWin( Gia_Man_t * p, int LevelMax, int nLevelRatio, int nCutNum, int nRelaxRatio, int fVerbose )
Gia_Man_t * Gia_ManPerformSopBalanceWin( Gia_Man_t * p, int LevelMax, int nTimeWindow, int nCutNum, int nRelaxRatio, int fVerbose )
{
Vec_Int_t * vOuts;
Gia_Man_t * pNew, * pWin, * pWinNew;
int nLevels = Gia_ManLevelNum( p );
if ( nLevelRatio )
LevelMax = (int)((1.0 - 0.01 * nLevelRatio) * nLevels);
//printf( "Using LevelMax = %d.\n", LevelMax );
vOuts = Gia_ManFindLatest( p, LevelMax );
assert( !LevelMax != !nTimeWindow );
vOuts = Gia_ManFindLatest( p, LevelMax, nTimeWindow );
if ( fVerbose )
printf( "Collected %d outputs to extract.\n", Vec_IntSize(vOuts) );
if ( Vec_IntSize(vOuts) == 0 )
{
Vec_IntFree( vOuts );
return Gia_ManDup( p );
}
pWin = Gia_ManExtractWin( p, vOuts );
pWin = Gia_ManExtractWin( p, vOuts, 0 );
pWinNew = Gia_ManPerformSopBalance( pWin, nCutNum, nRelaxRatio, fVerbose );
Gia_ManStop( pWin );
pNew = Gia_ManInsertWin( p, vOuts, pWinNew );
......@@ -221,6 +255,35 @@ Gia_Man_t * Gia_ManPerformSopBalanceWin( Gia_Man_t * p, int LevelMax, int nLevel
return pNew;
}
/**Function*************************************************************
Synopsis []
Description []
SideEffects []
SeeAlso []
***********************************************************************/
Gia_Man_t * Gia_ManExtractWindow( Gia_Man_t * p, int LevelMax, int nTimeWindow, int fVerbose )
{
Vec_Int_t * vOuts;
Gia_Man_t * pWin;
assert( !LevelMax != !nTimeWindow );
vOuts = Gia_ManFindLatest( p, LevelMax, nTimeWindow );
if ( fVerbose )
printf( "Collected %d outputs to extract.\n", Vec_IntSize(vOuts) );
if ( Vec_IntSize(vOuts) == 0 )
{
Vec_IntFree( vOuts );
return Gia_ManDup( p );
}
pWin = Gia_ManExtractWin( p, vOuts, 1 );
Vec_IntFree( vOuts );
return pWin;
}
////////////////////////////////////////////////////////////////////////
/// END OF FILE ///
////////////////////////////////////////////////////////////////////////
......
......@@ -30204,12 +30204,12 @@ int Abc_CommandAbc9Sopb( Abc_Frame_t * pAbc, int argc, char ** argv )
{
Gia_Man_t * pTemp;
int nLevelMax = 0;
int nLevelRatio = 0;
int nTimeWindow = 0;
int nCutNum = 8;
int nRelaxRatio = 0;
int c, fVerbose = 0;
Extra_UtilGetoptReset();
while ( ( c = Extra_UtilGetopt( argc, argv, "LQCRvh" ) ) != EOF )
while ( ( c = Extra_UtilGetopt( argc, argv, "LWCRvh" ) ) != EOF )
{
switch ( c )
{
......@@ -30224,15 +30224,15 @@ int Abc_CommandAbc9Sopb( Abc_Frame_t * pAbc, int argc, char ** argv )
if ( nLevelMax < 0 )
goto usage;
break;
case 'Q':
case 'W':
if ( globalUtilOptind >= argc )
{
Abc_Print( -1, "Command line switch \"-Q\" should be followed by an integer.\n" );
Abc_Print( -1, "Command line switch \"-W\" should be followed by an integer.\n" );
goto usage;
}
nLevelRatio = atoi(argv[globalUtilOptind]);
nTimeWindow = atoi(argv[globalUtilOptind]);
globalUtilOptind++;
if ( nLevelRatio < 0 )
if ( nTimeWindow < 0 )
goto usage;
break;
case 'C':
......@@ -30271,18 +30271,18 @@ int Abc_CommandAbc9Sopb( Abc_Frame_t * pAbc, int argc, char ** argv )
Abc_Print( -1, "Abc_CommandAbc9Sopb(): There is no AIG.\n" );
return 1;
}
if ( nLevelMax || nLevelRatio )
pTemp = Gia_ManPerformSopBalanceWin( pAbc->pGia, nLevelMax, nLevelRatio, nCutNum, nRelaxRatio, fVerbose );
if ( nLevelMax || nTimeWindow )
pTemp = Gia_ManPerformSopBalanceWin( pAbc->pGia, nLevelMax, nTimeWindow, nCutNum, nRelaxRatio, fVerbose );
else
pTemp = Gia_ManPerformSopBalance( pAbc->pGia, nCutNum, nRelaxRatio, fVerbose );
Abc_FrameUpdateGia( pAbc, pTemp );
return 0;
usage:
Abc_Print( -2, "usage: &sopb [-LQCR num] [-vh]\n" );
Abc_Print( -2, "usage: &sopb [-LWCR num] [-vh]\n" );
Abc_Print( -2, "\t performs SOP balancing\n" );
Abc_Print( -2, "\t-L num : optimize paths above this level [default = %d]\n", nLevelMax );
Abc_Print( -2, "\t-Q num : optimize paths falling into this window [default = %d]\n", nLevelRatio );
Abc_Print( -2, "\t-W num : optimize paths falling into this window [default = %d]\n", nTimeWindow );
Abc_Print( -2, "\t-C num : the number of cuts at a node [default = %d]\n", nCutNum );
Abc_Print( -2, "\t-R num : the delay relaxation ratio (num >= 0) [default = %d]\n", nRelaxRatio );
Abc_Print( -2, "\t-v : toggle printing verbose information [default = %s]\n", fVerbose? "yes": "no" );
......@@ -33485,9 +33485,9 @@ int Abc_CommandAbc9Cone( Abc_Frame_t * pAbc, int argc, char ** argv )
{
Gia_Man_t * pTemp;
Vec_Int_t * vPos;
int c, iOutNum = -1, nOutRange = 1, iPartNum = -1, fUseAllCis = 0, fVerbose = 0;
int c, iOutNum = -1, nOutRange = 1, iPartNum = -1, nLevelMax = 0, nTimeWindow = 0, fUseAllCis = 0, fVerbose = 0;
Extra_UtilGetoptReset();
while ( ( c = Extra_UtilGetopt( argc, argv, "ORPavh" ) ) != EOF )
while ( ( c = Extra_UtilGetopt( argc, argv, "ORPLWavh" ) ) != EOF )
{
switch ( c )
{
......@@ -33524,6 +33524,28 @@ int Abc_CommandAbc9Cone( Abc_Frame_t * pAbc, int argc, char ** argv )
if ( iPartNum < 0 )
goto usage;
break;
case 'L':
if ( globalUtilOptind >= argc )
{
Abc_Print( -1, "Command line switch \"-L\" should be followed by an integer.\n" );
goto usage;
}
nLevelMax = atoi(argv[globalUtilOptind]);
globalUtilOptind++;
if ( nLevelMax < 0 )
goto usage;
break;
case 'W':
if ( globalUtilOptind >= argc )
{
Abc_Print( -1, "Command line switch \"-W\" should be followed by an integer.\n" );
goto usage;
}
nTimeWindow = atoi(argv[globalUtilOptind]);
globalUtilOptind++;
if ( nTimeWindow < 0 )
goto usage;
break;
case 'a':
fUseAllCis ^= 1;
break;
......@@ -33541,6 +33563,20 @@ int Abc_CommandAbc9Cone( Abc_Frame_t * pAbc, int argc, char ** argv )
Abc_Print( -1, "Abc_CommandAbc9Cone(): There is no AIG.\n" );
return 1;
}
if ( nLevelMax || nTimeWindow )
{
if ( nLevelMax && nTimeWindow )
{
Abc_Print( -1, "Abc_CommandAbc9Cone(): Parameters -L (max level) and -W (timing window) cannot be specified at the same time.\n" );
return 1;
}
else
{
pTemp = Gia_ManExtractWindow( pAbc->pGia, nLevelMax, nTimeWindow, fVerbose );
Abc_FrameUpdateGia( pAbc, pTemp );
return 0;
}
}
if ( iPartNum >= 0 )
{
Vec_Int_t * vClass;
......@@ -33574,11 +33610,13 @@ int Abc_CommandAbc9Cone( Abc_Frame_t * pAbc, int argc, char ** argv )
return 0;
usage:
Abc_Print( -2, "usage: &cone [-ORP num] [-avh]\n" );
Abc_Print( -2, "usage: &cone [-ORPLW num] [-avh]\n" );
Abc_Print( -2, "\t extracting multi-output sequential logic cones\n" );
Abc_Print( -2, "\t-O num : the index of first PO to extract [default = %d]\n", iOutNum );
Abc_Print( -2, "\t-R num : (optional) the number of outputs to extract [default = %d]\n", nOutRange );
Abc_Print( -2, "\t-P num : (optional) the partition number to extract [default = %d]\n", iPartNum );
Abc_Print( -2, "\t-L num : (optional) extract cones with higher level [default = %d]\n", nLevelMax );
Abc_Print( -2, "\t-W num : (optional) extract cones falling into this window [default = %d]\n", nTimeWindow );
Abc_Print( -2, "\t-a : toggle keeping all CIs or structral support only [default = %s]\n", fUseAllCis? "all": "structural" );
Abc_Print( -2, "\t-v : toggle printing verbose information [default = %s]\n", fVerbose? "yes": "no" );
Abc_Print( -2, "\t-h : print the command usage\n");
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