Commit 47dde4e4 by Alan Mishchenko

Correcting incorrect handling of timing in several &-commands.

parent cbbf78e6
......@@ -1188,7 +1188,7 @@ extern void Gia_ManTransferPacking( Gia_Man_t * pGia, Gia_Man_t *
extern void Gia_ManTransferTiming( Gia_Man_t * pGia, Gia_Man_t * p );
extern Gia_Man_t * Gia_ManPerformMapping( Gia_Man_t * p, void * pIfPars, int fNormalized );
extern Gia_Man_t * Gia_ManPerformSopBalance( Gia_Man_t * p, int nCutNum, int nRelaxRatio, int fVerbose );
extern Gia_Man_t * Gia_ManPerformDsdBalance( Gia_Man_t * p, int nCutNum, int nRelaxRatio, int fVerbose );
extern Gia_Man_t * Gia_ManPerformDsdBalance( Gia_Man_t * p, int nLutSize, int nCutNum, int nRelaxRatio, int fVerbose );
/*=== giaJf.c ===========================================================*/
extern void Jf_ManSetDefaultPars( Jf_Par_t * pPars );
extern Gia_Man_t * Jf_ManPerformMapping( Gia_Man_t * pGia, Jf_Par_t * pPars );
......@@ -1262,8 +1262,9 @@ 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 nTimeWindow, int nCutNum, int nRelaxRatio, int fVerbose );
extern Gia_Man_t * Gia_ManExtractWindow( Gia_Man_t * p, int LevelMax, int nTimeWindow, 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_ManPerformDsdBalanceWin( Gia_Man_t * p, int LevelMax, int nTimeWindow, int nLutSize, int nCutNum, int nRelaxRatio, int fVerbose );
/*=== giaSort.c ============================================================*/
extern int * Gia_SortFloats( float * pArray, int * pPerm, int nSize );
/*=== giaSim.c ============================================================*/
......
......@@ -976,6 +976,7 @@ Gia_Man_t * Gia_ManAreaBalance( Gia_Man_t * p, int fSimpleAnd, int nNewNodesMax,
pNew2 = Gia_ManDupNormalize( pNew1 = pNew2 );
Gia_ManStop( pNew1 );
}
Gia_ManTransferTiming( p, pNew2 );
return pNew2;
}
......@@ -998,19 +999,6 @@ void Gia_ManAigPrintPiLevels( Gia_Man_t * p )
printf( "%d ", Gia_ObjLevel(p, pObj) );
printf( "\n" );
}
void Gia_ManAigTransferPiLevels( Gia_Man_t * pNew, Gia_Man_t * p )
{
/*
Gia_Obj_t * pObj;
int i;
if ( p->vLevels == NULL )
return;
Gia_ManCleanLevels( pNew, Gia_ManObjNum(pNew) );
Gia_ManForEachCi( pNew, pObj, i )
Gia_ObjSetLevel( pNew, pObj, Gia_ObjLevel(p, Gia_ManCi(p, i)) );
*/
if ( p->pManTime ) pNew->pManTime = p->pManTime, p->pManTime = NULL;
}
/**Function*************************************************************
......@@ -1023,9 +1011,9 @@ void Gia_ManAigTransferPiLevels( Gia_Man_t * pNew, Gia_Man_t * p )
SeeAlso []
***********************************************************************/
Gia_Man_t * Gia_ManAigSyn2( Gia_Man_t * p, int fOldAlgo, int fCoarsen, int fCutMin, int nRelaxRatio, int fDelayMin, int fVerbose, int fVeryVerbose )
Gia_Man_t * Gia_ManAigSyn2( Gia_Man_t * pInit, int fOldAlgo, int fCoarsen, int fCutMin, int nRelaxRatio, int fDelayMin, int fVerbose, int fVeryVerbose )
{
Gia_Man_t * pNew, * pTemp;
Gia_Man_t * p, * pNew, * pTemp;
Jf_Par_t Pars, * pPars = &Pars;
if ( fOldAlgo )
{
......@@ -1041,13 +1029,13 @@ Gia_Man_t * Gia_ManAigSyn2( Gia_Man_t * p, int fOldAlgo, int fCoarsen, int fCutM
pPars->nAreaTuner = 1;
pPars->nCutNum = 4;
}
if ( fVerbose ) Gia_ManPrintStats( p, NULL );
p = Gia_ManDup( pTemp = p );
Gia_ManAigTransferPiLevels( p, pTemp );
if ( fVerbose ) Gia_ManPrintStats( pInit, NULL );
p = Gia_ManDup( pInit );
Gia_ManTransferTiming( pInit, p );
if ( Gia_ManAndNum(p) == 0 )
return p;
// delay optimization
if ( fDelayMin )
if ( fDelayMin && p->pManTime == NULL )
{
int Area0, Area1, Delay0, Delay1;
int fCutMin = pPars->fCutMin;
......@@ -1064,7 +1052,7 @@ Gia_Man_t * Gia_ManAigSyn2( Gia_Man_t * p, int fOldAlgo, int fCoarsen, int fCutM
Area0 = (int)pPars->Area;
Delay0 = (int)pPars->Delay;
// perform balancing
pNew = Gia_ManPerformDsdBalance( p, 4, 0, 0 );
pNew = Gia_ManPerformDsdBalance( p, 6, 4, 0, 0 );
// perform mapping again
if ( fOldAlgo )
Jf_ManPerformMapping( pNew, pPars );
......@@ -1075,7 +1063,6 @@ Gia_Man_t * Gia_ManAigSyn2( Gia_Man_t * p, int fOldAlgo, int fCoarsen, int fCutM
// choose the best result
if ( Delay1 < Delay0 - 1 || (Delay1 == Delay0 + 1 && 100.0 * (Area1 - Area0) / Area1 < 3.0) )
{
Gia_ManAigTransferPiLevels( pNew, p );
Gia_ManStop( p );
p = pNew;
}
......@@ -1092,7 +1079,6 @@ Gia_Man_t * Gia_ManAigSyn2( Gia_Man_t * p, int fOldAlgo, int fCoarsen, int fCutM
// perform balancing
pNew = Gia_ManAreaBalance( p, 0, ABC_INFINITY, fVeryVerbose, 0 );
if ( fVerbose ) Gia_ManPrintStats( pNew, NULL );
Gia_ManAigTransferPiLevels( pNew, p );
Gia_ManStop( p );
// perform mapping
if ( fOldAlgo )
......@@ -1101,14 +1087,10 @@ Gia_Man_t * Gia_ManAigSyn2( Gia_Man_t * p, int fOldAlgo, int fCoarsen, int fCutM
pNew = Lf_ManPerformMapping( pTemp = pNew, pPars );
if ( fVerbose ) Gia_ManPrintStats( pNew, NULL );
if ( pTemp != pNew )
{
Gia_ManAigTransferPiLevels( pNew, pTemp );
Gia_ManStop( pTemp );
}
// perform balancing
pNew = Gia_ManAreaBalance( pTemp = pNew, 0, ABC_INFINITY, fVeryVerbose, 0 );
if ( fVerbose ) Gia_ManPrintStats( pNew, NULL );
Gia_ManAigTransferPiLevels( pNew, pTemp );
Gia_ManStop( pTemp );
return pNew;
}
......@@ -1124,7 +1106,6 @@ Gia_Man_t * Gia_ManAigSyn3( Gia_Man_t * p, int fVerbose, int fVeryVerbose )
// perform balancing
pNew = Gia_ManAreaBalance( p, 0, ABC_INFINITY, fVeryVerbose, 0 );
if ( fVerbose ) Gia_ManPrintStats( pNew, NULL );
Gia_ManAigTransferPiLevels( pNew, p );
// perform mapping
pPars->nLutSize = 6;
pNew = Jf_ManPerformMapping( pTemp = pNew, pPars );
......@@ -1133,7 +1114,6 @@ Gia_Man_t * Gia_ManAigSyn3( Gia_Man_t * p, int fVerbose, int fVeryVerbose )
// perform balancing
pNew = Gia_ManAreaBalance( pTemp = pNew, 0, ABC_INFINITY, fVeryVerbose, 0 );
if ( fVerbose ) Gia_ManPrintStats( pNew, NULL );
Gia_ManAigTransferPiLevels( pNew, pTemp );
Gia_ManStop( pTemp );
// perform mapping
pPars->nLutSize = 4;
......@@ -1143,7 +1123,6 @@ Gia_Man_t * Gia_ManAigSyn3( Gia_Man_t * p, int fVerbose, int fVeryVerbose )
// perform balancing
pNew = Gia_ManAreaBalance( pTemp = pNew, 0, ABC_INFINITY, fVeryVerbose, 0 );
if ( fVerbose ) Gia_ManPrintStats( pNew, NULL );
Gia_ManAigTransferPiLevels( pNew, pTemp );
Gia_ManStop( pTemp );
return pNew;
}
......@@ -1160,7 +1139,6 @@ Gia_Man_t * Gia_ManAigSyn4( Gia_Man_t * p, int fVerbose, int fVeryVerbose )
// perform balancing
pNew = Gia_ManAreaBalance( p, 0, ABC_INFINITY, fVeryVerbose, 0 );
if ( fVerbose ) Gia_ManPrintStats( pNew, NULL );
Gia_ManAigTransferPiLevels( pNew, p );
// perform mapping
pPars->nLutSize = 7;
pNew = Jf_ManPerformMapping( pTemp = pNew, pPars );
......@@ -1169,12 +1147,10 @@ Gia_Man_t * Gia_ManAigSyn4( Gia_Man_t * p, int fVerbose, int fVeryVerbose )
// perform extraction
pNew = Gia_ManPerformFx( pTemp = pNew, ABC_INFINITY, 0, 0, fVeryVerbose, 0 );
if ( fVerbose ) Gia_ManPrintStats( pNew, NULL );
Gia_ManAigTransferPiLevels( pNew, pTemp );
Gia_ManStop( pTemp );
// perform balancing
pNew = Gia_ManAreaBalance( pTemp = pNew, 0, ABC_INFINITY, fVeryVerbose, 0 );
if ( fVerbose ) Gia_ManPrintStats( pNew, NULL );
Gia_ManAigTransferPiLevels( pNew, pTemp );
Gia_ManStop( pTemp );
// perform mapping
pPars->nLutSize = 5;
......@@ -1184,12 +1160,10 @@ Gia_Man_t * Gia_ManAigSyn4( Gia_Man_t * p, int fVerbose, int fVeryVerbose )
// perform extraction
pNew = Gia_ManPerformFx( pTemp = pNew, ABC_INFINITY, 0, 0, fVeryVerbose, 0 );
if ( fVerbose ) Gia_ManPrintStats( pNew, NULL );
Gia_ManAigTransferPiLevels( pNew, pTemp );
Gia_ManStop( pTemp );
// perform balancing
pNew = Gia_ManAreaBalance( pTemp = pNew, 0, ABC_INFINITY, fVeryVerbose, 0 );
if ( fVerbose ) Gia_ManPrintStats( pNew, NULL );
Gia_ManAigTransferPiLevels( pNew, pTemp );
Gia_ManStop( pTemp );
//Gia_ManAigPrintPiLevels( pNew );
return pNew;
......
......@@ -464,6 +464,7 @@ Gia_Man_t * Gia_ManPerformFx( Gia_Man_t * p, int nNewNodesMax, int LitCountMax,
// Abc_PrintTime( 1, "Fx runtime", Abc_Clock() - clk );
// insert information
pNew = Gia_ManFxInsert( p, vCubes, vCompl );
Gia_ManTransferTiming( p, pNew );
// cleanup
Vec_WecFree( vCubes );
Vec_StrFree( vCompl );
......
......@@ -1619,12 +1619,13 @@ void Gia_ManTransferPacking( Gia_Man_t * pGia, Gia_Man_t * p )
}
void Gia_ManTransferTiming( Gia_Man_t * pGia, Gia_Man_t * p )
{
if ( pGia->pManTime == NULL )
return;
p->pManTime = pGia->pManTime; pGia->pManTime = NULL;
p->pAigExtra = pGia->pAigExtra; pGia->pAigExtra = NULL;
p->nAnd2Delay = pGia->nAnd2Delay; pGia->nAnd2Delay = 0;
}
/**Function*************************************************************
Synopsis [Interface of LUT mapping package.]
......@@ -1741,6 +1742,7 @@ Gia_Man_t * Gia_ManPerformSopBalance( Gia_Man_t * p, int nCutNum, int nRelaxRati
If_ManPerformMapping( pIfMan );
pNew = Gia_ManFromIfAig( pIfMan );
If_ManStop( pIfMan );
Gia_ManTransferTiming( p, pNew );
// transfer name
assert( pNew->pName == NULL );
pNew->pName = Abc_UtilStrsav( p->pName );
......@@ -1748,7 +1750,7 @@ Gia_Man_t * Gia_ManPerformSopBalance( Gia_Man_t * p, int nCutNum, int nRelaxRati
Gia_ManSetRegNum( pNew, Gia_ManRegNum(p) );
return pNew;
}
Gia_Man_t * Gia_ManPerformDsdBalance( Gia_Man_t * p, int nCutNum, int nRelaxRatio, int fVerbose )
Gia_Man_t * Gia_ManPerformDsdBalance( Gia_Man_t * p, int nLutSize, int nCutNum, int nRelaxRatio, int fVerbose )
{
Gia_Man_t * pNew;
If_Man_t * pIfMan;
......@@ -1757,7 +1759,7 @@ Gia_Man_t * Gia_ManPerformDsdBalance( Gia_Man_t * p, int nCutNum, int nRelaxRati
pPars->nCutsMax = nCutNum;
pPars->nRelaxRatio = nRelaxRatio;
pPars->fVerbose = fVerbose;
pPars->nLutSize = 6;
pPars->nLutSize = nLutSize;
pPars->fDsdBalance = 1;
pPars->fUseDsd = 1;
pPars->fCutMin = 1;
......@@ -1773,6 +1775,7 @@ Gia_Man_t * Gia_ManPerformDsdBalance( Gia_Man_t * p, int nCutNum, int nRelaxRati
If_ManPerformMapping( pIfMan );
pNew = Gia_ManFromIfAig( pIfMan );
If_ManStop( pIfMan );
Gia_ManTransferTiming( p, pNew );
// transfer name
assert( pNew->pName == NULL );
pNew->pName = Abc_UtilStrsav( p->pName );
......
......@@ -233,6 +233,35 @@ Vec_Int_t * Gia_ManFindLatest( Gia_Man_t * p, int LevelMax, int nTimeWindow )
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;
}
/**Function*************************************************************
Synopsis []
Description []
SideEffects []
SeeAlso []
***********************************************************************/
Gia_Man_t * Gia_ManPerformSopBalanceWin( Gia_Man_t * p, int LevelMax, int nTimeWindow, int nCutNum, int nRelaxRatio, int fVerbose )
{
Vec_Int_t * vOuts;
......@@ -266,10 +295,10 @@ Gia_Man_t * Gia_ManPerformSopBalanceWin( Gia_Man_t * p, int LevelMax, int nTimeW
SeeAlso []
***********************************************************************/
Gia_Man_t * Gia_ManExtractWindow( Gia_Man_t * p, int LevelMax, int nTimeWindow, int fVerbose )
Gia_Man_t * Gia_ManPerformDsdBalanceWin( Gia_Man_t * p, int LevelMax, int nTimeWindow, int nLutSize, int nCutNum, int nRelaxRatio, int fVerbose )
{
Vec_Int_t * vOuts;
Gia_Man_t * pWin;
Gia_Man_t * pNew, * pWin, * pWinNew;
assert( !LevelMax != !nTimeWindow );
vOuts = Gia_ManFindLatest( p, LevelMax, nTimeWindow );
if ( fVerbose )
......@@ -279,9 +308,13 @@ Gia_Man_t * Gia_ManExtractWindow( Gia_Man_t * p, int LevelMax, int nTimeWindow,
Vec_IntFree( vOuts );
return Gia_ManDup( p );
}
pWin = Gia_ManExtractWin( p, vOuts, 1 );
pWin = Gia_ManExtractWin( p, vOuts, 0 );
pWinNew = Gia_ManPerformDsdBalance( pWin, nLutSize, nCutNum, nRelaxRatio, fVerbose );
Gia_ManStop( pWin );
pNew = Gia_ManInsertWin( p, vOuts, pWinNew );
Gia_ManStop( pWinNew );
Vec_IntFree( vOuts );
return pWin;
return pNew;
}
////////////////////////////////////////////////////////////////////////
......
......@@ -380,6 +380,7 @@ static int Abc_CommandAbc9Sweep ( Abc_Frame_t * pAbc, int argc, cha
static int Abc_CommandAbc9Force ( Abc_Frame_t * pAbc, int argc, char ** argv );
static int Abc_CommandAbc9Embed ( Abc_Frame_t * pAbc, int argc, char ** argv );
static int Abc_CommandAbc9Sopb ( Abc_Frame_t * pAbc, int argc, char ** argv );
static int Abc_CommandAbc9Dsdb ( Abc_Frame_t * pAbc, int argc, char ** argv );
static int Abc_CommandAbc9If ( Abc_Frame_t * pAbc, int argc, char ** argv );
static int Abc_CommandAbc9Iff ( Abc_Frame_t * pAbc, int argc, char ** argv );
static int Abc_CommandAbc9If2 ( Abc_Frame_t * pAbc, int argc, char ** argv );
......@@ -964,6 +965,7 @@ void Abc_Init( Abc_Frame_t * pAbc )
Cmd_CommandAdd( pAbc, "ABC9", "&force", Abc_CommandAbc9Force, 0 );
Cmd_CommandAdd( pAbc, "ABC9", "&embed", Abc_CommandAbc9Embed, 0 );
Cmd_CommandAdd( pAbc, "ABC9", "&sopb", Abc_CommandAbc9Sopb, 0 );
Cmd_CommandAdd( pAbc, "ABC9", "&dsdb", Abc_CommandAbc9Dsdb, 0 );
Cmd_CommandAdd( pAbc, "ABC9", "&if", Abc_CommandAbc9If, 0 );
Cmd_CommandAdd( pAbc, "ABC9", "&iff", Abc_CommandAbc9Iff, 0 );
Cmd_CommandAdd( pAbc, "ABC9", "&if2", Abc_CommandAbc9If2, 0 );
......@@ -30301,6 +30303,120 @@ usage:
SeeAlso []
***********************************************************************/
int Abc_CommandAbc9Dsdb( Abc_Frame_t * pAbc, int argc, char ** argv )
{
Gia_Man_t * pTemp;
int nLevelMax = 0;
int nTimeWindow = 0;
int nLutSize = 6;
int nCutNum = 8;
int nRelaxRatio = 0;
int c, fVerbose = 0;
Extra_UtilGetoptReset();
while ( ( c = Extra_UtilGetopt( argc, argv, "LWKCRvh" ) ) != EOF )
{
switch ( c )
{
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 'K':
if ( globalUtilOptind >= argc )
{
Abc_Print( -1, "Command line switch \"-K\" should be followed by an integer.\n" );
goto usage;
}
nLutSize = atoi(argv[globalUtilOptind]);
globalUtilOptind++;
if ( nLutSize < 0 )
goto usage;
break;
case 'C':
if ( globalUtilOptind >= argc )
{
Abc_Print( -1, "Command line switch \"-C\" should be followed by an integer.\n" );
goto usage;
}
nCutNum = atoi(argv[globalUtilOptind]);
globalUtilOptind++;
if ( nCutNum < 0 )
goto usage;
break;
case 'R':
if ( globalUtilOptind >= argc )
{
Abc_Print( -1, "Command line switch \"-R\" should be followed by an integer.\n" );
goto usage;
}
nRelaxRatio = atoi(argv[globalUtilOptind]);
globalUtilOptind++;
if ( nRelaxRatio < 0 )
goto usage;
break;
case 'v':
fVerbose ^= 1;
break;
case 'h':
goto usage;
default:
goto usage;
}
}
if ( pAbc->pGia == NULL )
{
Abc_Print( -1, "Abc_CommandAbc9Dsdb(): There is no AIG.\n" );
return 1;
}
if ( nLevelMax || nTimeWindow )
pTemp = Gia_ManPerformDsdBalanceWin( pAbc->pGia, nLevelMax, nTimeWindow, nLutSize, nCutNum, nRelaxRatio, fVerbose );
else
pTemp = Gia_ManPerformDsdBalance( pAbc->pGia, nLutSize, nCutNum, nRelaxRatio, fVerbose );
Abc_FrameUpdateGia( pAbc, pTemp );
return 0;
usage:
Abc_Print( -2, "usage: &sopb [-LWKCR 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-W num : optimize paths falling into this window [default = %d]\n", nTimeWindow );
Abc_Print( -2, "\t-K num : the number of LUT inputs (LUT size) [default = %d]\n", nLutSize );
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" );
Abc_Print( -2, "\t-h : print the command usage\n");
return 1;
}
/**Function*************************************************************
Synopsis []
Description []
SideEffects []
SeeAlso []
***********************************************************************/
int Abc_CommandAbc9If( Abc_Frame_t * pAbc, int argc, char ** argv )
{
char Buffer[200];
......@@ -99,7 +99,7 @@ void If_ObjPerformMappingAnd( If_Man_t * p, If_Obj_t * pObj, int Mode, int fPrep
If_Cut_t * pCut0R, * pCut1R;
int fFunc0R, fFunc1R;
int i, k, v, iCutDsd, fChange;
int fSave0 = p->pPars->fDelayOpt || p->pPars->fDelayOptLut || p->pPars->fDsdBalance || p->pPars->fUserRecLib;
int fSave0 = p->pPars->fDelayOpt || p->pPars->fDelayOptLut || p->pPars->fDsdBalance || p->pPars->fUserRecLib || p->pPars->pLutStruct != NULL;
assert( !If_ObjIsAnd(pObj->pFanin0) || pObj->pFanin0->pCutSet->nCuts > 0 );
assert( !If_ObjIsAnd(pObj->pFanin1) || pObj->pFanin1->pCutSet->nCuts > 0 );
......
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