diff --git a/src/base/abci/abc.c b/src/base/abci/abc.c index 00eb766b7..dcb67140a 100644 --- a/src/base/abci/abc.c +++ b/src/base/abci/abc.c @@ -146,6 +146,7 @@ static int Abc_CommandTestRand ( Abc_Frame_t * pAbc, int argc, cha static int Abc_CommandRunSat ( Abc_Frame_t * pAbc, int argc, char ** argv ); static int Abc_CommandRunEco ( Abc_Frame_t * pAbc, int argc, char ** argv ); static int Abc_CommandRunGen ( Abc_Frame_t * pAbc, int argc, char ** argv ); +static int Abc_CommandRunScript ( Abc_Frame_t * pAbc, int argc, char ** argv ); static int Abc_CommandRunTest ( Abc_Frame_t * pAbc, int argc, char ** argv ); static int Abc_CommandRewrite ( Abc_Frame_t * pAbc, int argc, char ** argv ); @@ -962,6 +963,7 @@ void Abc_Init( Abc_Frame_t * pAbc ) Cmd_CommandAdd( pAbc, "Synthesis", "runsat", Abc_CommandRunSat, 0 ); Cmd_CommandAdd( pAbc, "Synthesis", "runeco", Abc_CommandRunEco, 0 ); Cmd_CommandAdd( pAbc, "Synthesis", "rungen", Abc_CommandRunGen, 0 ); + Cmd_CommandAdd( pAbc, "Synthesis", "runscript", Abc_CommandRunScript, 0 ); Cmd_CommandAdd( pAbc, "Synthesis", "xec", Abc_CommandRunTest, 0 ); Cmd_CommandAdd( pAbc, "Synthesis", "rewrite", Abc_CommandRewrite, 1 ); @@ -7681,6 +7683,113 @@ usage: return 1; } +/**Function************************************************************* + + Synopsis [] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +int Abc_CommandRunScript( Abc_Frame_t * pAbc, int argc, char ** argv ) +{ + int c, nIters = 10, nBeg = 0, nAdd = 1, fVerbose = 0; char * pScript = NULL, * pSpot = NULL; + Extra_UtilGetoptReset(); + while ( ( c = Extra_UtilGetopt( argc, argv, "IBASvh" ) ) != EOF ) + { + switch ( c ) + { + case 'I': + if ( globalUtilOptind >= argc ) + { + Abc_Print( -1, "Command line switch \"-I\" should be followed by an integer.\n" ); + goto usage; + } + nIters = atoi(argv[globalUtilOptind]); + globalUtilOptind++; + break; + case 'B': + if ( globalUtilOptind >= argc ) + { + Abc_Print( -1, "Command line switch \"-B\" should be followed by an integer.\n" ); + goto usage; + } + nBeg = atoi(argv[globalUtilOptind]); + globalUtilOptind++; + break; + case 'A': + if ( globalUtilOptind >= argc ) + { + Abc_Print( -1, "Command line switch \"-A\" should be followed by an integer.\n" ); + goto usage; + } + nAdd = atoi(argv[globalUtilOptind]); + globalUtilOptind++; + break; + case 'S': + if ( globalUtilOptind >= argc ) + { + Abc_Print( -1, "Command line switch \"-S\" should be followed by a script.\n" ); + goto usage; + } + pScript = argv[globalUtilOptind]; + globalUtilOptind++; + break; + case 'v': + fVerbose ^= 1; + break; + case 'h': + goto usage; + default: + goto usage; + } + } + if ( pScript == NULL ) + { + Abc_Print( -1, "Command line switch \"-S\" should be specified and followed by a string.\n" ); + goto usage; + } + pSpot = strstr( pScript, "*" ); + if ( pSpot == NULL ) + { + Abc_Print( -1, "Script should contain symbol \'*\'.\n" ); + goto usage; + } + assert( *pSpot == '*' ); + for ( c = 0; c < nIters; c++ ) + { + char pCommLine[1000] = {0}; + char pNumber[10] = {0}; + sprintf( pNumber, "%d", nBeg + c*nAdd ); + strcpy( pCommLine, pScript ); + pCommLine[(int)(pSpot - pScript)] = 0; + strcat( pCommLine, pNumber ); + strcat( pCommLine, pSpot+1 ); + if ( fVerbose ) + printf( "Iteration %3d : %s\n", c, pCommLine ); + if ( Cmd_CommandExecute(Abc_FrameGetGlobalFrame(), pCommLine) ) { + Abc_Print( 1, "Something did not work out with the command \"%s\".\n", pCommLine ); + goto usage; + } + } + printf( "Finished iterating script %d times.\n", nIters ); + return 0; + +usage: + Abc_Print( -2, "usage: runscript [-IBA num] [-S str] [-vh]\n" ); + Abc_Print( -2, "\t running the script with different values\n" ); + Abc_Print( -2, "\t-I : the number of iterations [default = %d]\n", nIters ); + Abc_Print( -2, "\t-B : the starting number [default = %d]\n", nBeg ); + Abc_Print( -2, "\t-A : the increment added in each iteration [default = %d]\n", nAdd ); + Abc_Print( -2, "\t-S : the script to iterate [default = none]\n" ); + 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 [] diff --git a/src/base/abci/abcCas.c b/src/base/abci/abcCas.c index 4d34cce68..8ee79bffc 100644 --- a/src/base/abci/abcCas.c +++ b/src/base/abci/abcCas.c @@ -1238,7 +1238,7 @@ void Abc_NtkLutCascadeFile( char * pFileName, int nVarsOrig, int nLutSize, int n printf( "Statistics for %d-rail LUT cascade:\n", nRails ); for ( i = 0; i < 100; i++ ) if ( LutStats[i] ) - printf( " %d LUT6 : Function count = %8d (%6.2f %%)\n", i, LutStats[i], 100.0*LutStats[i]/nFuncs ); + printf( " %2d LUT%d : Function count = %8d (%6.2f %%)\n", i, nLutSize, LutStats[i], 100.0*LutStats[i]/nFuncs ); printf( "Non-decomp : Function count = %8d (%6.2f %%)\n", nFuncs-Sum, 100.0*(nFuncs-Sum)/Abc_MaxInt(1, nFuncs) ); printf( "Finished %d functions (%.2f LUTs / function; %.2f functions / sec). ", nFuncs, 1.0*nTotalLuts/Sum, 1.0*nFuncs/(((double)(Abc_Clock() - clkStart))/((double)CLOCKS_PER_SEC)) ); diff --git a/src/base/abci/abcPart.c b/src/base/abci/abcPart.c index 81a051c2b..88f3d8c94 100644 --- a/src/base/abci/abcPart.c +++ b/src/base/abci/abcPart.c @@ -1467,7 +1467,7 @@ void Abc_NtkInsertPartitions_rec( Abc_Ntk_t * pNew, Abc_Obj_t * pObj, Vec_Int_t pNode->pCopy = Abc_ObjFanin0(Abc_NtkPo(pWin, i))->pCopy; assert( pObj->pCopy ); } -Abc_Ntk_t * Abc_NtkInsertPartitions( Abc_Ntk_t * p, Vec_Ptr_t * vvIns, Vec_Ptr_t * vvOuts, Vec_Ptr_t * vWins, int fOverlap, Vec_Int_t * vGains ) +Abc_Ntk_t * Abc_NtkInsertPartitions( Abc_Ntk_t * p, Vec_Ptr_t * vvIns, Vec_Ptr_t * vvNodes, Vec_Ptr_t * vvOuts, Vec_Ptr_t * vWins, int fOverlap, Vec_Int_t * vGains ) { if ( vvIns == NULL ) { assert( vvOuts == NULL ); @@ -1493,16 +1493,12 @@ Abc_Ntk_t * Abc_NtkInsertPartitions( Abc_Ntk_t * p, Vec_Ptr_t * vvIns, Vec_Ptr_t Vec_IntForEachEntry( vGains, Gain, i ) { if ( Gain <= 0 ) continue; - Vec_Int_t * vIns = (Vec_Int_t *)Vec_PtrEntry(vvIns, i); - Vec_Int_t * vOuts = (Vec_Int_t *)Vec_PtrEntry(vvOuts, i); - Abc_Obj_t * pNode; int j, k; - Abc_NtkForEachObjVec( vIns, p, pNode, j ) + Vec_Int_t * vNodes = (Vec_Int_t *)Vec_PtrEntry(vvNodes, i); + Abc_Obj_t * pNode; int j; + Abc_NtkForEachObjVec( vNodes, p, pNode, j ) if ( Abc_NodeIsTravIdCurrent(pNode) ) break; - Abc_NtkForEachObjVec( vOuts, p, pNode, k ) - if ( Abc_NodeIsTravIdCurrent(pNode) ) - break; - if ( j < Vec_IntSize(vIns) || k < Vec_IntSize(vOuts) ) + if ( j < Vec_IntSize(vNodes) ) Vec_IntWriteEntry( vGains, i, -1 ); } } @@ -1764,8 +1760,8 @@ void Abc_NtKMarkTfiTfo( Vec_Int_t * vOne, Abc_Ntk_t * pNtk ) { int i; Abc_Obj_t * pObj; Abc_NtkForEachObjVec( vOne, pNtk, pObj, i ) { - Abc_NodeSetTravIdPrevious(pObj); - Abc_ObjDfsMark_rec( pObj ); + //Abc_NodeSetTravIdPrevious(pObj); + //Abc_ObjDfsMark_rec( pObj ); Abc_NodeSetTravIdPrevious(pObj); Abc_ObjDfsMark2_rec( pObj ); } @@ -1939,7 +1935,7 @@ void Abc_NtkStochMap( int nSuppMax, int nIters, int TimeOut, int Seed, int fOver Abc_Ntk_t * pNtk = Abc_NtkDupDfs(Abc_FrameReadNtk(Abc_FrameGetGlobalFrame())); Vec_Ptr_t * vWins = Abc_NtkExtractPartitions( pNtk, i, nSuppMax, &vIns, &vOuts, &vNodes, fOverlap ); Vec_Int_t * vGains = Abc_NtkStochProcess( vWins, pScript, nProcs, 0, 0 ); int nPartsInit = Vec_PtrSize(vWins); - Abc_Ntk_t * pNew = Abc_NtkInsertPartitions( pNtk, vIns, vOuts, vWins, fOverlap, vGains ); + Abc_Ntk_t * pNew = Abc_NtkInsertPartitions( pNtk, vIns, vNodes, vOuts, vWins, fOverlap, vGains ); Abc_FrameReplaceCurrentNetwork( Abc_FrameGetGlobalFrame(), pNew ); if ( fVerbose ) printf( "Iteration %3d : Using %3d -> %3d partitions. Reducing area from %.2f to %.2f. ", diff --git a/src/base/main/mainUtils.c b/src/base/main/mainUtils.c index 22d0e8774..654d246f0 100644 --- a/src/base/main/mainUtils.c +++ b/src/base/main/mainUtils.c @@ -337,15 +337,15 @@ void Abc_FrameStorePrint( Abc_Frame_t * pAbc ) { if ( pAbc->pHash == NULL ) Abc_FrameStoreStart( pAbc ); - int i, Entry, Max = Vec_IntFindMax( pAbc->pHash->vValue ); + int i, Entry, nAll = 0, Max = Vec_IntFindMax( pAbc->pHash->vValue ); Vec_Int_t * vCounts = Vec_IntStart( Max+1 ); Vec_IntForEachEntry( pAbc->pHash->vValue, Entry, i ) Vec_IntAddToEntry( vCounts, Entry, 1 ); printf( "Distribution of %d stored items by reference count (=): ", Hsh_VecSize(pAbc->pHash) ); Vec_IntForEachEntry( vCounts, Entry, i ) if ( Entry ) - printf( "%d=%d ", i, Entry ); - printf( "\n" ); + printf( "%d=%d ", i, Entry ), nAll += i * Entry; + printf( "ALL=%d\n", nAll ); Vec_IntFree( vCounts ); }