From d51f798956a9f9fbdd1fc4eeecc483e511b1c3d3 Mon Sep 17 00:00:00 2001 From: Alan Mishchenko Date: Sun, 3 May 2020 10:32:30 -0700 Subject: Experimental resubstitution. --- src/base/abci/abc.c | 100 +++++++++++++++++++++++++++++++++++++++++++++++++ src/base/acb/acbFunc.c | 4 +- src/base/acb/acbUtil.c | 4 ++ 3 files changed, 106 insertions(+), 2 deletions(-) (limited to 'src/base') diff --git a/src/base/abci/abc.c b/src/base/abci/abc.c index 85053e18..70ef45ca 100644 --- a/src/base/abci/abc.c +++ b/src/base/abci/abc.c @@ -437,6 +437,7 @@ static int Abc_CommandAbc9Shrink ( Abc_Frame_t * pAbc, int argc, cha static int Abc_CommandAbc9Fx ( Abc_Frame_t * pAbc, int argc, char ** argv ); static int Abc_CommandAbc9Balance ( Abc_Frame_t * pAbc, int argc, char ** argv ); static int Abc_CommandAbc9BalanceLut ( Abc_Frame_t * pAbc, int argc, char ** argv ); +static int Abc_CommandAbc9Resub ( Abc_Frame_t * pAbc, int argc, char ** argv ); static int Abc_CommandAbc9Syn2 ( Abc_Frame_t * pAbc, int argc, char ** argv ); static int Abc_CommandAbc9Syn3 ( Abc_Frame_t * pAbc, int argc, char ** argv ); static int Abc_CommandAbc9Syn4 ( Abc_Frame_t * pAbc, int argc, char ** argv ); @@ -1156,6 +1157,7 @@ void Abc_Init( Abc_Frame_t * pAbc ) Cmd_CommandAdd( pAbc, "ABC9", "&fx", Abc_CommandAbc9Fx, 0 ); Cmd_CommandAdd( pAbc, "ABC9", "&b", Abc_CommandAbc9Balance, 0 ); Cmd_CommandAdd( pAbc, "ABC9", "&blut", Abc_CommandAbc9BalanceLut, 0 ); + Cmd_CommandAdd( pAbc, "ABC9", "&resub", Abc_CommandAbc9Resub, 0 ); Cmd_CommandAdd( pAbc, "ABC9", "&syn2", Abc_CommandAbc9Syn2, 0 ); Cmd_CommandAdd( pAbc, "ABC9", "&syn3", Abc_CommandAbc9Syn3, 0 ); Cmd_CommandAdd( pAbc, "ABC9", "&syn4", Abc_CommandAbc9Syn4, 0 ); @@ -34769,6 +34771,104 @@ usage: return 1; } +/**Function************************************************************* + + Synopsis [] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +int Abc_CommandAbc9Resub( Abc_Frame_t * pAbc, int argc, char ** argv ) +{ + extern Gia_Man_t * Gia_ManResub1( char * pFileName, int nNodes, int nSupp, int nDivs, int fVerbose, int fVeryVerbose ); + extern Gia_Man_t * Gia_ManResub2( Gia_Man_t * pGia, int nNodes, int nSupp, int nDivs, int fVerbose, int fVeryVerbose ); + Gia_Man_t * pTemp; + int nNodes = 0; + int nSupp = 0; + int nDivs = 0; + int c, fVerbose = 0; + int fVeryVerbose = 0; + Extra_UtilGetoptReset(); + while ( ( c = Extra_UtilGetopt( argc, argv, "NSDvwh" ) ) != EOF ) + { + switch ( c ) + { + case 'N': + if ( globalUtilOptind >= argc ) + { + Abc_Print( 1, "Command line switch \"-N\" should be followed by a floating point number.\n" ); + return 0; + } + nNodes = atoi(argv[globalUtilOptind]); + globalUtilOptind++; + if ( nNodes < 0 ) + goto usage; + break; + case 'S': + if ( globalUtilOptind >= argc ) + { + Abc_Print( 1, "Command line switch \"-S\" should be followed by a floating point number.\n" ); + return 0; + } + nSupp = atoi(argv[globalUtilOptind]); + globalUtilOptind++; + if ( nSupp < 0 ) + goto usage; + break; + case 'D': + if ( globalUtilOptind >= argc ) + { + Abc_Print( 1, "Command line switch \"-D\" should be followed by a floating point number.\n" ); + return 0; + } + nDivs = atoi(argv[globalUtilOptind]); + globalUtilOptind++; + if ( nDivs < 0 ) + goto usage; + break; + case 'v': + fVerbose ^= 1; + break; + case 'w': + fVeryVerbose ^= 1; + break; + case 'h': + goto usage; + default: + goto usage; + } + } + if ( argc == globalUtilOptind + 1 ) + { + pTemp = Gia_ManResub1( argv[globalUtilOptind], nNodes, nSupp, nDivs, fVerbose, fVeryVerbose ); + Abc_FrameUpdateGia( pAbc, pTemp ); + return 0; + } + if ( pAbc->pGia == NULL ) + { + Abc_Print( -1, "Abc_CommandAbc9Resub(): There is no AIG.\n" ); + return 1; + } + pTemp = Gia_ManResub2( pAbc->pGia, nNodes, nSupp, nDivs, fVerbose, fVeryVerbose ); + Abc_FrameUpdateGia( pAbc, pTemp ); + return 0; + +usage: + Abc_Print( -2, "usage: &resub [-NSD num] [-vwh]\n" ); + Abc_Print( -2, "\t performs AIG resubstitution\n" ); + Abc_Print( -2, "\t-N num : the limit on added nodes (num >= 0) [default = %d]\n", nNodes ); + Abc_Print( -2, "\t-S num : the limit on support size (num > 0) [default = %d]\n", nSupp ); + Abc_Print( -2, "\t-D num : the limit on divisor count (num > 0) [default = %d]\n", nDivs ); + Abc_Print( -2, "\t-v : toggles printing verbose information [default = %s]\n", fVerbose? "yes": "no" ); + Abc_Print( -2, "\t-w : toggles printing additional information [default = %s]\n", fVeryVerbose? "yes": "no" ); + Abc_Print( -2, "\t-h : print the command usage\n"); + return 1; +} + /**Function************************************************************* Synopsis [] diff --git a/src/base/acb/acbFunc.c b/src/base/acb/acbFunc.c index 8f72a00f..485a5e4e 100644 --- a/src/base/acb/acbFunc.c +++ b/src/base/acb/acbFunc.c @@ -1541,7 +1541,7 @@ char * Acb_EnumerateSatAssigns( sat_solver * pSat, int PivotVar, int FreeVar, Ve { if ( iMint == 1000 ) { - //if ( Vec_IntSize(vDivVars) == 0 ) + if ( Vec_IntSize(vDivVars) == 0 ) { printf( "Assuming constant 0 function.\n" ); Vec_StrClear( vTempSop ); @@ -2511,7 +2511,7 @@ int Acb_NtkEcoPerform( Acb_Ntk_t * pNtkF, Acb_Ntk_t * pNtkG, char * pFileName[4] abctime clk = Abc_Clock(); int nTargets = Vec_IntSize(&pNtkF->vTargets); - int TimeOut = fCisOnly ? 0 : 60; // 60 seconds + int TimeOut = fCisOnly ? 0 : 120; // 60 seconds int RetValue = 1; // compute various sets of nodes diff --git a/src/base/acb/acbUtil.c b/src/base/acb/acbUtil.c index 2243541b..8a51bd3e 100644 --- a/src/base/acb/acbUtil.c +++ b/src/base/acb/acbUtil.c @@ -671,6 +671,8 @@ int Acb_NtkExtract( char * pFileName0, char * pFileName1, int fUseXors, int fVer int nTargets = Vec_IntSize(&pNtkF->vTargets); Gia_Man_t * pGiaF = Acb_NtkToGia2( pNtkF, fUseBuf, fUseXors, &pNtkF->vTargets, 0 ); Gia_Man_t * pGiaG = Acb_NtkToGia2( pNtkG, 0, 0, NULL, nTargets ); + pGiaF->pSpec = Abc_UtilStrsav( pNtkF->pDesign->pSpec ); + pGiaG->pSpec = Abc_UtilStrsav( pNtkG->pDesign->pSpec ); assert( Acb_NtkCiNum(pNtkF) == Acb_NtkCiNum(pNtkG) ); assert( Acb_NtkCoNum(pNtkF) == Acb_NtkCoNum(pNtkG) ); *ppGiaF = pGiaF; @@ -784,6 +786,8 @@ int Abc_NtkExtract( char * pFileName0, char * pFileName1, int fUseXors, int fVer Gia_Man_t * pGiaG = Abc_NtkToGia2( pNtkG, 0 ); assert( Abc_NtkCiNum(pNtkF) == Abc_NtkCiNum(pNtkG) ); assert( Abc_NtkCoNum(pNtkF) == Abc_NtkCoNum(pNtkG) ); + pGiaF->pSpec = Abc_UtilStrsav( pNtkF->pSpec ); + pGiaG->pSpec = Abc_UtilStrsav( pNtkG->pSpec ); *ppGiaF = pGiaF; *ppGiaG = pGiaG; *pvNodes = Abc_NtkCollectCopies( pNtkF, pGiaF, pvNodesR, pvPolar ); -- cgit v1.2.3 From f026e6533987a1628be38cfe828f167d4aaff760 Mon Sep 17 00:00:00 2001 From: Alan Mishchenko Date: Sun, 3 May 2020 19:09:02 -0700 Subject: Compiler warnings and errors. --- src/base/abci/abc.c | 6 ++---- src/base/abci/abcNtbdd.c | 2 +- 2 files changed, 3 insertions(+), 5 deletions(-) (limited to 'src/base') diff --git a/src/base/abci/abc.c b/src/base/abci/abc.c index 70ef45ca..9107af22 100644 --- a/src/base/abci/abc.c +++ b/src/base/abci/abc.c @@ -32841,7 +32841,6 @@ usage: ***********************************************************************/ int Abc_CommandAbc9ReadSim( Abc_Frame_t * pAbc, int argc, char ** argv ) { - extern Vec_Wrd_t * Gia_ManSimPatRead( char * pFileName ); int c, fOutputs = 0, nWords = 4, fVerbose = 0; char ** pArgvNew; int nArgcNew; @@ -32893,7 +32892,7 @@ int Abc_CommandAbc9ReadSim( Abc_Frame_t * pAbc, int argc, char ** argv ) if ( fOutputs ) { Vec_WrdFreeP( &pAbc->pGia->vSimsPo ); - pAbc->pGia->vSimsPo = Gia_ManSimPatRead( pArgvNew[0] ); + pAbc->pGia->vSimsPo = Gia_ManSimPatRead( pArgvNew[0], NULL ); if ( Vec_WrdSize(pAbc->pGia->vSimsPo) % Gia_ManCoNum(pAbc->pGia) != 0 ) { Vec_WrdFreeP( &pAbc->pGia->vSimsPo ); @@ -32907,7 +32906,7 @@ int Abc_CommandAbc9ReadSim( Abc_Frame_t * pAbc, int argc, char ** argv ) else { Vec_WrdFreeP( &pAbc->pGia->vSimsPi ); - pAbc->pGia->vSimsPi = Gia_ManSimPatRead( pArgvNew[0] ); + pAbc->pGia->vSimsPi = Gia_ManSimPatRead( pArgvNew[0], NULL ); if ( Vec_WrdSize(pAbc->pGia->vSimsPi) % Gia_ManCiNum(pAbc->pGia) != 0 ) { Vec_WrdFreeP( &pAbc->pGia->vSimsPi ); @@ -32944,7 +32943,6 @@ usage: ***********************************************************************/ int Abc_CommandAbc9WriteSim( Abc_Frame_t * pAbc, int argc, char ** argv ) { - extern void Gia_ManSimPatWrite( char * pFileName, Vec_Wrd_t * vSimsIn, int nWords ); int c, fOutputs = 0, fVerbose = 0; char ** pArgvNew; int nArgcNew; diff --git a/src/base/abci/abcNtbdd.c b/src/base/abci/abcNtbdd.c index d3a19d83..aa35aa6a 100644 --- a/src/base/abci/abcNtbdd.c +++ b/src/base/abci/abcNtbdd.c @@ -286,7 +286,7 @@ int Abc_NtkBddToMuxesPerformGlo( Abc_Ntk_t * pNtk, Abc_Ntk_t * pNtkNew, int Limi // complement the global functions Abc_NtkForEachCo( pNtk, pObj, i ) { - DdNode * bFunc = Abc_ObjGlobalBdd(pObj); + DdNode * bFunc = (DdNode *)Abc_ObjGlobalBdd(pObj); pObjNew = Abc_NodeBddToMuxes_rec( dd, Cudd_Regular(bFunc), pNtkNew, tBdd2Node ); if ( Cudd_IsComplement(bFunc) ) pObjNew = Abc_NtkCreateNodeInv( pNtkNew, pObjNew ); -- cgit v1.2.3 From f543d39ec89dc0513784e189b537e6d45fd3db31 Mon Sep 17 00:00:00 2001 From: Alan Mishchenko Date: Sun, 3 May 2020 21:09:02 -0700 Subject: Experiment with permutations. --- src/base/abci/abc.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/base') diff --git a/src/base/abci/abc.c b/src/base/abci/abc.c index 9107af22..3aaf2cd0 100644 --- a/src/base/abci/abc.c +++ b/src/base/abci/abc.c @@ -13895,7 +13895,8 @@ int Abc_CommandTest( Abc_Frame_t * pAbc, int argc, char ** argv ) //Dau_NetworkEnumTest(); //Extra_SimulationTest( nDivMax, nNumOnes, fNewOrder ); //Mnist_ExperimentWithScaling( nDecMax ); - Gia_Gen2CodeTest(); + //Gia_Gen2CodeTest(); + Gia_EnumPerms( nDecMax ); return 0; usage: Abc_Print( -2, "usage: test [-CKDNM] [-aovwh] \n" ); -- cgit v1.2.3 From f8b6d615bf2eab6fbb44a44eab9773884cc28c17 Mon Sep 17 00:00:00 2001 From: Alan Mishchenko Date: Wed, 6 May 2020 12:48:11 -0700 Subject: Fixing the accidentally broken build. --- src/base/abci/abc.c | 1 - 1 file changed, 1 deletion(-) (limited to 'src/base') diff --git a/src/base/abci/abc.c b/src/base/abci/abc.c index 3aaf2cd0..798ec7d0 100644 --- a/src/base/abci/abc.c +++ b/src/base/abci/abc.c @@ -13896,7 +13896,6 @@ int Abc_CommandTest( Abc_Frame_t * pAbc, int argc, char ** argv ) //Extra_SimulationTest( nDivMax, nNumOnes, fNewOrder ); //Mnist_ExperimentWithScaling( nDecMax ); //Gia_Gen2CodeTest(); - Gia_EnumPerms( nDecMax ); return 0; usage: Abc_Print( -2, "usage: test [-CKDNM] [-aovwh] \n" ); -- cgit v1.2.3 From a3ada00d8648a53bb43676d89d1ac2fa7cead948 Mon Sep 17 00:00:00 2001 From: Alan Mishchenko Date: Sun, 10 May 2020 19:44:59 -0700 Subject: Adding new utility procedures. --- src/base/acb/acb.h | 6 +++ src/base/acb/acbFunc.c | 42 ++++++++++++---- src/base/acb/acbUtil.c | 133 +++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 172 insertions(+), 9 deletions(-) (limited to 'src/base') diff --git a/src/base/acb/acb.h b/src/base/acb/acb.h index 9aed414c..cfe090bb 100644 --- a/src/base/acb/acb.h +++ b/src/base/acb/acb.h @@ -1019,6 +1019,12 @@ static inline void Acb_ManPrintStats( Acb_Man_t * p, int nModules, int fVerbose extern Vec_Int_t * Acb_ObjCollectTfi( Acb_Ntk_t * p, int iObj, int fTerm ); extern Vec_Int_t * Acb_ObjCollectTfo( Acb_Ntk_t * p, int iObj, int fTerm ); +extern Vec_Int_t * Acb_ObjCollectTfiVec( Acb_Ntk_t * p, Vec_Int_t * vObjs ); +extern Vec_Int_t * Acb_ObjCollectTfoVec( Acb_Ntk_t * p, Vec_Int_t * vObjs ); +extern int Acb_NtkCountPiBuffers( Acb_Ntk_t * p, Vec_Int_t * vObjs ); +extern int Acb_NtkCountPoDrivers( Acb_Ntk_t * p, Vec_Int_t * vObjs ); +extern int Acb_NtkFindMffcSize( Acb_Ntk_t * p, Vec_Int_t * vObjs, int nGates[5] ); + extern int Acb_ObjComputeLevelD( Acb_Ntk_t * p, int iObj ); extern int Acb_NtkComputeLevelD( Acb_Ntk_t * p, Vec_Int_t * vTfo ); extern void Acb_NtkUpdateLevelD( Acb_Ntk_t * p, int iObj ); diff --git a/src/base/acb/acbFunc.c b/src/base/acb/acbFunc.c index 485a5e4e..4af33903 100644 --- a/src/base/acb/acbFunc.c +++ b/src/base/acb/acbFunc.c @@ -1897,6 +1897,14 @@ Vec_Ptr_t * Acb_GenerateSignalNames( Acb_Ntk_t * p, Vec_Int_t * vDivs, Vec_Int_t Vec_StrFree( vStr ); return vRes; } +Vec_Int_t * Acb_GetUsedDivs( Vec_Int_t * vDivs, Vec_Int_t * vUsed ) +{ + int i, iObj; + Vec_Int_t * vRes = Vec_IntAlloc( Vec_IntSize(vUsed) ); + Vec_IntForEachEntryInVec( vDivs, vUsed, iObj, i ) + Vec_IntPush( vRes, iObj ); + return vRes; +} Vec_Str_t * Acb_GeneratePatch( Acb_Ntk_t * p, Vec_Int_t * vDivs, Vec_Int_t * vUsed, Vec_Ptr_t * vSops, Vec_Ptr_t * vGias, Vec_Int_t * vTars ) { extern Vec_Wec_t * Abc_SopSynthesize( Vec_Ptr_t * vSops ); @@ -1904,10 +1912,16 @@ Vec_Str_t * Acb_GeneratePatch( Acb_Ntk_t * p, Vec_Int_t * vDivs, Vec_Int_t * vUs Vec_Wec_t * vGates = vGias ? Abc_GiaSynthesize(vGias, NULL) : Abc_SopSynthesize(vSops); Vec_Int_t * vGate; int nOuts = vGias ? Vec_PtrSize(vGias) : Vec_PtrSize(vSops); int i, k, iObj, nWires = Vec_WecSize(vGates) - Vec_IntSize(vUsed) - nOuts, fFirst = 1; + int nGates[5] = {0}, nInvs = 0, nBufs = 0, nNodes = 0, nConst[2] = {0}; Vec_Ptr_t * vNames = Acb_GenerateSignalNames( p, vDivs, vUsed, nWires, vTars, vGates ); Vec_Str_t * vStr = Vec_StrAlloc( 100 ); - - int nInvs = 0, nBufs = 0, nNodes = 0, nConst = 0; + Vec_Int_t * vSup = Acb_GetUsedDivs( vDivs, vUsed ); + Vec_Int_t * vTfi = Acb_ObjCollectTfiVec( p, vSup ); + Vec_Int_t * vTfo = Acb_ObjCollectTfoVec( p, vTars ); + int nPiCount = Acb_NtkCountPiBuffers( p, vSup ); + int nPoCount = Acb_NtkCountPoDrivers( p, vTars ); + int nMffc = Acb_NtkFindMffcSize( p, vSup, nGates ); + Vec_IntFree( vSup ); Vec_WecForEachLevelStartStop( vGates, vGate, i, Vec_IntSize(vUsed), Vec_IntSize(vUsed)+nWires ) { if ( Vec_IntSize(vGate) > 2 ) @@ -1918,13 +1932,17 @@ Vec_Str_t * Acb_GeneratePatch( Acb_Ntk_t * p, Vec_Int_t * vDivs, Vec_Int_t * vUs else if ( !strcmp(pName, "not") ) nInvs++; else - nNodes++; + nNodes += Vec_IntSize(vGate) - 3; } else - nConst++; + nConst[Vec_IntEntry(vGate, 0) == ABC_OPER_CONST_T]++; } - Vec_StrPrintF( vStr, "// Patch statistics: in = %d out = %d gate = %d (const = %d buf = %d inv = %d other = %d)\n\n", - Vec_IntSize(vUsed), nOuts, nWires, nConst, nBufs, nInvs, nNodes ); + + Vec_StrPrintF( vStr, "// Patch : in = %d out = %d : pi_in = %d po_out = %d : tfi = %d tfo = %d\n", Vec_IntSize(vUsed), nOuts, nPiCount, nPoCount, Vec_IntSize(vTfi), Vec_IntSize(vTfo) ); + Vec_StrPrintF( vStr, "// Added : gate =%4d : c0 =%2d c1 =%2d buf =%3d inv =%3d two-input =%4d\n", nWires, nConst[0], nConst[1], nBufs, nInvs, nNodes ); + Vec_StrPrintF( vStr, "// Removed : gate =%4d : c0 =%2d c1 =%2d buf =%3d inv =%3d two-input =%4d\n", nMffc, nGates[0], nGates[1], nGates[2], nGates[3], nGates[4] ); + Vec_StrPrintF( vStr, "// TOTAL : gate =%4d : c0 =%2d c1 =%2d buf =%3d inv =%3d two-input =%4d\n\n", nWires-nMffc, nConst[0]-nGates[0], nConst[1]-nGates[1], nBufs-nGates[2], nInvs-nGates[3], nNodes-nGates[4] ); + Vec_StrAppend( vStr, "module patch (" ); assert( Vec_IntSize(vTars) == nOuts ); @@ -1980,8 +1998,14 @@ Vec_Str_t * Acb_GeneratePatch( Acb_Ntk_t * p, Vec_Int_t * vDivs, Vec_Int_t * vUs Vec_PtrFreeFree( vNames ); Vec_WecFree( vGates ); - printf( "Synthesized patch with %d inputs, %d outputs and %d gates (const = %d buf = %d inv = %d other = %d).\n", - Vec_IntSize(vUsed), nOuts, nWires, nConst, nBufs, nInvs, nNodes ); +// printf( "Synthesized patch with %d inputs, %d outputs and %d gates (const = %d buf = %d inv = %d other = %d).\n", +// Vec_IntSize(vUsed), nOuts, nWires, nConst, nBufs, nInvs, nNodes ); +// printf( "Summary of the results\n" ); + printf( "\n" ); + printf( "Patch : in = %d out = %d : pi_in = %d po_out = %d : tfi = %d tfo = %d\n", Vec_IntSize(vUsed), nOuts, nPiCount, nPoCount, Vec_IntSize(vTfi), Vec_IntSize(vTfo) ); + printf( "Added : gate =%4d : c0 =%2d c1 =%2d buf =%3d inv =%3d two-input =%4d\n", nWires, nConst[0], nConst[1], nBufs, nInvs, nNodes ); + printf( "Removed : gate =%4d : c0 =%2d c1 =%2d buf =%3d inv =%3d two-input =%4d\n", nMffc, nGates[0], nGates[1], nGates[2], nGates[3], nGates[4] ); + printf( "TOTAL : gate =%4d : c0 =%2d c1 =%2d buf =%3d inv =%3d two-input =%4d\n", nWires-nMffc, nConst[0]-nGates[0], nConst[1]-nGates[1], nBufs-nGates[2], nInvs-nGates[3], nNodes-nGates[4] ); return vStr; } @@ -2479,7 +2503,7 @@ Vec_Ptr_t * Acb_TransformPatchFunctions( Vec_Ptr_t * vSops, Vec_Wec_t * vSupps, Vec_IntWriteEntry( vMap, iVar, Vec_IntSize(vUsed) ); Vec_IntPush( vUsed, iVar ); } - printf( "The number of used variables %d (out of %d).\n", Vec_IntSum(vPres), Vec_IntSize(vPres) ); + //printf( "The number of used variables %d (out of %d).\n", Vec_IntSum(vPres), Vec_IntSize(vPres) ); // remap SOPs Vec_WecForEachLevel( vSupps, vLevel, i ) { diff --git a/src/base/acb/acbUtil.c b/src/base/acb/acbUtil.c index 8a51bd3e..680dca12 100644 --- a/src/base/acb/acbUtil.c +++ b/src/base/acb/acbUtil.c @@ -71,6 +71,15 @@ Vec_Int_t * Acb_ObjCollectTfi( Acb_Ntk_t * p, int iObj, int fTerm ) Acb_ObjCollectTfi_rec( p, iObj, fTerm ); return &p->vArray0; } +Vec_Int_t * Acb_ObjCollectTfiVec( Acb_Ntk_t * p, Vec_Int_t * vObjs ) +{ + int i, iObj; + Vec_IntClear( &p->vArray0 ); + Acb_NtkIncTravId( p ); + Vec_IntForEachEntry( vObjs, iObj, i ) + Acb_ObjCollectTfi_rec( p, iObj, 0 ); + return &p->vArray0; +} void Acb_ObjCollectTfo_rec( Acb_Ntk_t * p, int iObj, int fTerm ) { @@ -95,6 +104,130 @@ Vec_Int_t * Acb_ObjCollectTfo( Acb_Ntk_t * p, int iObj, int fTerm ) Acb_ObjCollectTfo_rec( p, iObj, fTerm ); return &p->vArray1; } +Vec_Int_t * Acb_ObjCollectTfoVec( Acb_Ntk_t * p, Vec_Int_t * vObjs ) +{ + int i, iObj; + if ( !Acb_NtkHasObjFanout(p) ) + Acb_NtkCreateFanout( p ); + Vec_IntClear( &p->vArray1 ); + Acb_NtkIncTravId( p ); + Vec_IntForEachEntry( vObjs, iObj, i ) + Acb_ObjCollectTfo_rec( p, iObj, 0 ); + return &p->vArray1; +} + +/**Function************************************************************* + + Synopsis [Count the number of nodes driving the POs.] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +int Acb_NtkIsPiBuffers( Acb_Ntk_t * p, int iObj ) +{ + if ( Acb_ObjIsCi(p, iObj) ) + return 1; + if ( Acb_ObjFaninNum(p, iObj) != 1 ) + return 0; + return Acb_NtkIsPiBuffers( p, Acb_ObjFanin(p, iObj, 0) ); +} +int Acb_NtkCountPiBuffers( Acb_Ntk_t * p, Vec_Int_t * vObjs ) +{ + int i, iObj, Count = 0; + Vec_IntForEachEntry( vObjs, iObj, i ) + Count += Acb_NtkIsPiBuffers( p, iObj ); + return Count; +} +int Acb_NtkCountPoDrivers( Acb_Ntk_t * p, Vec_Int_t * vObjs ) +{ + int i, iObj, Count = 0; + Acb_NtkIncTravId( p ); + Acb_NtkForEachCo( p, iObj, i ) + Acb_ObjSetTravIdCur( p, iObj ); + Acb_NtkForEachCo( p, iObj, i ) + Acb_ObjSetTravIdCur( p, Acb_ObjFanin(p, iObj, 0) ); + Vec_IntForEachEntry( vObjs, iObj, i ) + Count += Acb_ObjIsTravIdCur(p, iObj); + return Count; +} + +/**Function************************************************************* + + Synopsis [Compute MFFC size.] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +int Acb_NtkNodeDeref_rec( Vec_Int_t * vRefs, Acb_Ntk_t * p, int iObj, int nGates[5] ) +{ + int i, Fanin, * pFanins, Counter = 1; + if ( Acb_ObjIsCi(p, iObj) ) + return 0; + if ( nGates ) + { + int Type = Acb_ObjType( p, iObj ); + if ( Type == ABC_OPER_CONST_F ) + nGates[0]++; + if ( Type == ABC_OPER_CONST_T ) + nGates[1]++; + if ( Type == ABC_OPER_BIT_BUF ) + nGates[2]++; + if ( Type == ABC_OPER_BIT_INV ) + nGates[3]++; + else + nGates[4] += Acb_ObjFaninNum(p, iObj)-1; + } + Acb_ObjForEachFaninFast( p, iObj, pFanins, Fanin, i ) + { + assert( Vec_IntEntry(vRefs, Fanin) > 0 ); + Vec_IntAddToEntry( vRefs, Fanin, -1 ); + if ( Vec_IntEntry(vRefs, Fanin) == 0 ) + Counter += Acb_NtkNodeDeref_rec( vRefs, p, Fanin, nGates ); + } + return Counter; +} +int Acb_NtkNodeRef_rec( Vec_Int_t * vRefs, Acb_Ntk_t * p, int iObj ) +{ + int i, Fanin, * pFanins, Counter = 1; + if ( Acb_ObjIsCi(p, iObj) ) + return 0; + Acb_ObjForEachFaninFast( p, iObj, pFanins, Fanin, i ) + { + if ( Vec_IntEntry(vRefs, Fanin) == 0 ) + Counter += Acb_NtkNodeRef_rec( vRefs, p, Fanin ); + Vec_IntAddToEntry( vRefs, Fanin, 1 ); + } + return Counter; +} +int Acb_NtkFindMffcSize( Acb_Ntk_t * p, Vec_Int_t * vObjs, int nGates[5] ) +{ + Vec_Int_t * vRefs = Vec_IntStart( Acb_NtkObjNumMax(p) ); + int i, iObj, Fanin, * pFanins, Count1 = 0, Count2 = 0; + Acb_NtkForEachObj( p, iObj ) + Acb_ObjForEachFaninFast( p, iObj, pFanins, Fanin, i ) + Vec_IntAddToEntry( vRefs, Fanin, 1 ); + //Vec_IntForEachEntry( vObjs, iObj, i ) + // assert( Vec_IntEntry(vRefs, iObj) > 0 ); + Vec_IntForEachEntry( vObjs, iObj, i ) + Vec_IntAddToEntry( vRefs, iObj, 1 ); + Vec_IntForEachEntry( vObjs, iObj, i ) + Count1 += Acb_NtkNodeDeref_rec( vRefs, p, iObj, nGates ); + Vec_IntForEachEntry( vObjs, iObj, i ) + Count2 += Acb_NtkNodeRef_rec( vRefs, p, iObj ); + Vec_IntForEachEntry( vObjs, iObj, i ) + Vec_IntAddToEntry( vRefs, iObj, -1 ); + assert( Count1 == Count2 ); + Vec_IntFree( vRefs ); + return Count1; +} /**Function************************************************************* -- cgit v1.2.3 From 1c0ea1022f0dcb25b7985750a4b091b1a1c3b62a Mon Sep 17 00:00:00 2001 From: Alan Mishchenko Date: Mon, 11 May 2020 17:08:00 -0700 Subject: Adding new utility procedures. --- src/base/acb/acb.h | 2 +- src/base/acb/acbFunc.c | 71 ++++++++++++++++++++++----- src/base/acb/acbUtil.c | 121 ++++++++++++++++++++++++++++++++++------------ src/base/main/main.h | 3 ++ src/base/main/mainFrame.c | 5 ++ src/base/main/mainInt.h | 2 + 6 files changed, 159 insertions(+), 45 deletions(-) (limited to 'src/base') diff --git a/src/base/acb/acb.h b/src/base/acb/acb.h index cfe090bb..0a188d0f 100644 --- a/src/base/acb/acb.h +++ b/src/base/acb/acb.h @@ -1023,7 +1023,7 @@ extern Vec_Int_t * Acb_ObjCollectTfiVec( Acb_Ntk_t * p, Vec_Int_t * vObjs ); extern Vec_Int_t * Acb_ObjCollectTfoVec( Acb_Ntk_t * p, Vec_Int_t * vObjs ); extern int Acb_NtkCountPiBuffers( Acb_Ntk_t * p, Vec_Int_t * vObjs ); extern int Acb_NtkCountPoDrivers( Acb_Ntk_t * p, Vec_Int_t * vObjs ); -extern int Acb_NtkFindMffcSize( Acb_Ntk_t * p, Vec_Int_t * vObjs, int nGates[5] ); +extern int Acb_NtkFindMffcSize( Acb_Ntk_t * p, Vec_Int_t * vObjsRefed, Vec_Int_t * vObjsDerefed, int nGates[5] ); extern int Acb_ObjComputeLevelD( Acb_Ntk_t * p, int iObj ); extern int Acb_NtkComputeLevelD( Acb_Ntk_t * p, Vec_Int_t * vTfo ); diff --git a/src/base/acb/acbFunc.c b/src/base/acb/acbFunc.c index 4af33903..565dbb06 100644 --- a/src/base/acb/acbFunc.c +++ b/src/base/acb/acbFunc.c @@ -1905,6 +1905,42 @@ Vec_Int_t * Acb_GetUsedDivs( Vec_Int_t * vDivs, Vec_Int_t * vUsed ) Vec_IntPush( vRes, iObj ); return vRes; } +Vec_Int_t * Acb_GetDerefedNodes( Acb_Ntk_t * p ) +{ + Vec_Ptr_t * vNames = Abc_FrameReadSignalNames(); + if ( vNames != NULL ) + { + Vec_Int_t * vNodes = Vec_IntAlloc( 100 ); + Vec_Int_t * vMap = Vec_IntStartFull( Abc_NamObjNumMax(p->pDesign->pStrs) ); + int i, iObj; char * pName; + Acb_NtkForEachObj( p, iObj ) + if ( Acb_ObjName(p, iObj) ) + Vec_IntWriteEntry( vMap, Acb_ObjName(p, iObj), iObj ); + Vec_PtrForEachEntry( char *, vNames, pName, i ) + { + int NameId = Abc_NamStrFindOrAdd( p->pDesign->pStrs, pName, NULL ); + if ( NameId == 0 ) + { + printf( "Cannot find name ID for name %s\n", pName ); + Vec_IntFree( vMap ); + Vec_IntFree( vNodes ); + return NULL; + } + else if ( Vec_IntEntry(vMap, NameId) == -1 ) + { + printf( "Cannot find obj ID for name %s\n", pName ); + Vec_IntFree( vMap ); + Vec_IntFree( vNodes ); + return NULL; + } + else + Vec_IntPush( vNodes, Vec_IntEntry(vMap, NameId) ); + } + Vec_IntFree( vMap ); + return vNodes; + } + return NULL; +} Vec_Str_t * Acb_GeneratePatch( Acb_Ntk_t * p, Vec_Int_t * vDivs, Vec_Int_t * vUsed, Vec_Ptr_t * vSops, Vec_Ptr_t * vGias, Vec_Int_t * vTars ) { extern Vec_Wec_t * Abc_SopSynthesize( Vec_Ptr_t * vSops ); @@ -1912,15 +1948,19 @@ Vec_Str_t * Acb_GeneratePatch( Acb_Ntk_t * p, Vec_Int_t * vDivs, Vec_Int_t * vUs Vec_Wec_t * vGates = vGias ? Abc_GiaSynthesize(vGias, NULL) : Abc_SopSynthesize(vSops); Vec_Int_t * vGate; int nOuts = vGias ? Vec_PtrSize(vGias) : Vec_PtrSize(vSops); int i, k, iObj, nWires = Vec_WecSize(vGates) - Vec_IntSize(vUsed) - nOuts, fFirst = 1; - int nGates[5] = {0}, nInvs = 0, nBufs = 0, nNodes = 0, nConst[2] = {0}; + int nGates1[5] = {0}, nGates0[5] = {0}; Vec_Ptr_t * vNames = Acb_GenerateSignalNames( p, vDivs, vUsed, nWires, vTars, vGates ); Vec_Str_t * vStr = Vec_StrAlloc( 100 ); Vec_Int_t * vSup = Acb_GetUsedDivs( vDivs, vUsed ); + Vec_Int_t * vDrf = Acb_GetDerefedNodes( p ); Vec_Int_t * vTfi = Acb_ObjCollectTfiVec( p, vSup ); Vec_Int_t * vTfo = Acb_ObjCollectTfoVec( p, vTars ); int nPiCount = Acb_NtkCountPiBuffers( p, vSup ); int nPoCount = Acb_NtkCountPoDrivers( p, vTars ); - int nMffc = Acb_NtkFindMffcSize( p, vSup, nGates ); + int nMffc = vDrf ? Vec_IntSize(vTars) + Acb_NtkFindMffcSize( p, vSup, vDrf, nGates1 ) : 0; + int * pCounts = Abc_FrameReadGateCounts(); + for ( i = 0; i < 5; i++ ) + nGates1[i] += pCounts[i]; Vec_IntFree( vSup ); Vec_WecForEachLevelStartStop( vGates, vGate, i, Vec_IntSize(vUsed), Vec_IntSize(vUsed)+nWires ) { @@ -1928,20 +1968,23 @@ Vec_Str_t * Acb_GeneratePatch( Acb_Ntk_t * p, Vec_Int_t * vDivs, Vec_Int_t * vUs { char * pName = Acb_Oper2Name(Vec_IntEntry(vGate, 0)); if ( !strcmp(pName, "buf") ) - nBufs++; + nGates0[2]++; else if ( !strcmp(pName, "not") ) - nInvs++; + nGates0[3]++; else - nNodes += Vec_IntSize(vGate) - 3; + nGates0[4] += Vec_IntSize(vGate) - 3; } else - nConst[Vec_IntEntry(vGate, 0) == ABC_OPER_CONST_T]++; + nGates0[Vec_IntEntry(vGate, 0) == ABC_OPER_CONST_T]++; } Vec_StrPrintF( vStr, "// Patch : in = %d out = %d : pi_in = %d po_out = %d : tfi = %d tfo = %d\n", Vec_IntSize(vUsed), nOuts, nPiCount, nPoCount, Vec_IntSize(vTfi), Vec_IntSize(vTfo) ); - Vec_StrPrintF( vStr, "// Added : gate =%4d : c0 =%2d c1 =%2d buf =%3d inv =%3d two-input =%4d\n", nWires, nConst[0], nConst[1], nBufs, nInvs, nNodes ); - Vec_StrPrintF( vStr, "// Removed : gate =%4d : c0 =%2d c1 =%2d buf =%3d inv =%3d two-input =%4d\n", nMffc, nGates[0], nGates[1], nGates[2], nGates[3], nGates[4] ); - Vec_StrPrintF( vStr, "// TOTAL : gate =%4d : c0 =%2d c1 =%2d buf =%3d inv =%3d two-input =%4d\n\n", nWires-nMffc, nConst[0]-nGates[0], nConst[1]-nGates[1], nBufs-nGates[2], nInvs-nGates[3], nNodes-nGates[4] ); + Vec_StrPrintF( vStr, "// Added : gate =%4d : c0 =%2d c1 =%2d buf =%3d inv =%3d two-input =%4d\n", nWires, nGates0[0], nGates0[1], nGates0[2], nGates0[3], nGates0[4] ); + if ( vDrf != NULL ) + Vec_StrPrintF( vStr, "// Removed : gate =%4d : c0 =%2d c1 =%2d buf =%3d inv =%3d two-input =%4d\n", nMffc, nGates1[0], nGates1[1], nGates1[2], nGates1[3], nGates1[4] ); + if ( vDrf != NULL ) + Vec_StrPrintF( vStr, "// TOTAL : gate =%4d : c0 =%2d c1 =%2d buf =%3d inv =%3d two-input =%4d\n", nWires-nMffc, nGates0[0]-nGates1[0], nGates0[1]-nGates1[1], nGates0[2]-nGates1[2], nGates0[3]-nGates1[3], nGates0[4]-nGates1[4] ); + Vec_StrPrintF( vStr, "\n" ); Vec_StrAppend( vStr, "module patch (" ); @@ -2003,9 +2046,13 @@ Vec_Str_t * Acb_GeneratePatch( Acb_Ntk_t * p, Vec_Int_t * vDivs, Vec_Int_t * vUs // printf( "Summary of the results\n" ); printf( "\n" ); printf( "Patch : in = %d out = %d : pi_in = %d po_out = %d : tfi = %d tfo = %d\n", Vec_IntSize(vUsed), nOuts, nPiCount, nPoCount, Vec_IntSize(vTfi), Vec_IntSize(vTfo) ); - printf( "Added : gate =%4d : c0 =%2d c1 =%2d buf =%3d inv =%3d two-input =%4d\n", nWires, nConst[0], nConst[1], nBufs, nInvs, nNodes ); - printf( "Removed : gate =%4d : c0 =%2d c1 =%2d buf =%3d inv =%3d two-input =%4d\n", nMffc, nGates[0], nGates[1], nGates[2], nGates[3], nGates[4] ); - printf( "TOTAL : gate =%4d : c0 =%2d c1 =%2d buf =%3d inv =%3d two-input =%4d\n", nWires-nMffc, nConst[0]-nGates[0], nConst[1]-nGates[1], nBufs-nGates[2], nInvs-nGates[3], nNodes-nGates[4] ); + printf( "Added : gate =%4d : c0 =%2d c1 =%2d buf =%3d inv =%3d two-input =%4d\n", nWires, nGates0[0], nGates0[1], nGates0[2], nGates0[3], nGates0[4] ); + if ( vDrf != NULL ) + printf( "Removed : gate =%4d : c0 =%2d c1 =%2d buf =%3d inv =%3d two-input =%4d\n", nMffc, nGates1[0], nGates1[1], nGates1[2], nGates1[3], nGates1[4] ); + if ( vDrf != NULL ) + printf( "TOTAL : gate =%4d : c0 =%2d c1 =%2d buf =%3d inv =%3d two-input =%4d\n", nWires-nMffc, nGates0[0]-nGates1[0], nGates0[1]-nGates1[1], nGates0[2]-nGates1[2], nGates0[3]-nGates1[3], nGates0[4]-nGates1[4] ); + printf( "\n" ); + Vec_IntFreeP( &vDrf ); return vStr; } diff --git a/src/base/acb/acbUtil.c b/src/base/acb/acbUtil.c index 680dca12..d707d136 100644 --- a/src/base/acb/acbUtil.c +++ b/src/base/acb/acbUtil.c @@ -21,6 +21,7 @@ #include "acb.h" #include "base/abc/abc.h" #include "base/io/ioAbc.h" +#include "base/main/main.h" ABC_NAMESPACE_IMPL_START @@ -166,67 +167,65 @@ int Acb_NtkCountPoDrivers( Acb_Ntk_t * p, Vec_Int_t * vObjs ) SeeAlso [] ***********************************************************************/ -int Acb_NtkNodeDeref_rec( Vec_Int_t * vRefs, Acb_Ntk_t * p, int iObj, int nGates[5] ) +int Acb_NtkNodeDeref_rec( Vec_Int_t * vRefs, Acb_Ntk_t * p, int iObj ) { int i, Fanin, * pFanins, Counter = 1; if ( Acb_ObjIsCi(p, iObj) ) return 0; - if ( nGates ) - { - int Type = Acb_ObjType( p, iObj ); - if ( Type == ABC_OPER_CONST_F ) - nGates[0]++; - if ( Type == ABC_OPER_CONST_T ) - nGates[1]++; - if ( Type == ABC_OPER_BIT_BUF ) - nGates[2]++; - if ( Type == ABC_OPER_BIT_INV ) - nGates[3]++; - else - nGates[4] += Acb_ObjFaninNum(p, iObj)-1; - } Acb_ObjForEachFaninFast( p, iObj, pFanins, Fanin, i ) { assert( Vec_IntEntry(vRefs, Fanin) > 0 ); Vec_IntAddToEntry( vRefs, Fanin, -1 ); if ( Vec_IntEntry(vRefs, Fanin) == 0 ) - Counter += Acb_NtkNodeDeref_rec( vRefs, p, Fanin, nGates ); + Counter += Acb_NtkNodeDeref_rec( vRefs, p, Fanin ); } return Counter; } -int Acb_NtkNodeRef_rec( Vec_Int_t * vRefs, Acb_Ntk_t * p, int iObj ) +int Acb_NtkNodeRef_rec( Vec_Int_t * vRefs, Acb_Ntk_t * p, int iObj, int nGates[5] ) { int i, Fanin, * pFanins, Counter = 1; if ( Acb_ObjIsCi(p, iObj) ) return 0; + if ( nGates ) + { + int nFan = Acb_ObjFaninNum(p, iObj); + int Type = Acb_ObjType( p, iObj ); + if ( Type == ABC_OPER_CONST_F ) + nGates[0]++; + else if ( Type == ABC_OPER_CONST_T ) + nGates[1]++; + else if ( Type == ABC_OPER_BIT_BUF || Type == ABC_OPER_CO ) + nGates[2]++; + else if ( Type == ABC_OPER_BIT_INV ) + nGates[3]++; + else + { + assert( nFan >= 2 ); + nGates[4] += Acb_ObjFaninNum(p, iObj)-1; + } + } Acb_ObjForEachFaninFast( p, iObj, pFanins, Fanin, i ) { if ( Vec_IntEntry(vRefs, Fanin) == 0 ) - Counter += Acb_NtkNodeRef_rec( vRefs, p, Fanin ); + Counter += Acb_NtkNodeRef_rec( vRefs, p, Fanin, nGates ); Vec_IntAddToEntry( vRefs, Fanin, 1 ); } return Counter; } -int Acb_NtkFindMffcSize( Acb_Ntk_t * p, Vec_Int_t * vObjs, int nGates[5] ) +int Acb_NtkFindMffcSize( Acb_Ntk_t * p, Vec_Int_t * vObjsRefed, Vec_Int_t * vObjsDerefed, int nGates[5] ) { Vec_Int_t * vRefs = Vec_IntStart( Acb_NtkObjNumMax(p) ); - int i, iObj, Fanin, * pFanins, Count1 = 0, Count2 = 0; + int i, iObj, Fanin, * pFanins, Count2 = 0; Acb_NtkForEachObj( p, iObj ) Acb_ObjForEachFaninFast( p, iObj, pFanins, Fanin, i ) Vec_IntAddToEntry( vRefs, Fanin, 1 ); - //Vec_IntForEachEntry( vObjs, iObj, i ) - // assert( Vec_IntEntry(vRefs, iObj) > 0 ); - Vec_IntForEachEntry( vObjs, iObj, i ) - Vec_IntAddToEntry( vRefs, iObj, 1 ); - Vec_IntForEachEntry( vObjs, iObj, i ) - Count1 += Acb_NtkNodeDeref_rec( vRefs, p, iObj, nGates ); - Vec_IntForEachEntry( vObjs, iObj, i ) - Count2 += Acb_NtkNodeRef_rec( vRefs, p, iObj ); - Vec_IntForEachEntry( vObjs, iObj, i ) - Vec_IntAddToEntry( vRefs, iObj, -1 ); - assert( Count1 == Count2 ); + Vec_IntForEachEntry( vObjsRefed, iObj, i ) + Acb_NtkNodeRef_rec( vRefs, p, iObj, NULL ); + Vec_IntForEachEntry( vObjsDerefed, iObj, i ) + if ( Vec_IntEntry(vRefs, iObj) == 0 ) + Count2 += Acb_NtkNodeRef_rec( vRefs, p, iObj, nGates ); Vec_IntFree( vRefs ); - return Count1; + return Count2; } /**Function************************************************************* @@ -942,6 +941,63 @@ int Abc_NtkExtract( char * pFileName0, char * pFileName1, int fUseXors, int fVer SeeAlso [] ***********************************************************************/ +void Acb_NtkFindNamesInPlaces( char * pBuffer, Vec_Int_t * vPlaces, Vec_Ptr_t * vPivots ) +{ + int * pCounts = Abc_FrameReadGateCounts(); + Vec_Ptr_t * vNames = Vec_PtrAlloc( 100 ); + int i, k, iObj, Pos; + for ( i = 0; i < 5; i++ ) + pCounts[i] = 0; + Vec_IntForEachEntryDouble( vPlaces, Pos, iObj, i ) + { + int nFanins = 0; + char pLocal[1000], * pTemp, * pName, * pSpot; + char * pPivot = (char *)Vec_PtrEntry(vPivots, iObj); + for ( k = 0; k < 1000; k++ ) + { + if ( pBuffer[Pos+k] == '\n' ) + { + pLocal[k] = 0; + break; + } + else + pLocal[k] = pBuffer[Pos+k]; + } + assert( k < 1000 ); + pSpot = strstr( pLocal, pPivot ); + if ( pSpot == NULL ) + { + printf( "Cannot find location of signal \"%s\" in this line.\n", pPivot ); + continue; + } + pTemp = strtok( pLocal, " \r\n\t,;()" ); + while ( pTemp ) + { + if ( !strcmp(pTemp, "1\'b0") ) + pCounts[0]++; + else if ( !strcmp(pTemp, "1\'b1") ) + pCounts[1]++; + else if ( !strcmp(pTemp, "buf") || !strcmp(pTemp, "assign") ) + pCounts[2]++; + else if ( !strcmp(pTemp, "not") ) + pCounts[3]++; + else if ( strcmp(pTemp, pPivot) && pTemp > pSpot ) + { + nFanins++; + Vec_PtrForEachEntry( char *, vNames, pName, k ) + if ( !strcmp(pName, pTemp) ) + break; + if ( k == Vec_PtrSize(vNames) ) + Vec_PtrPush( vNames, Abc_UtilStrsav(pTemp) ); + } + pTemp = strtok( NULL, " \r\n\t,;()" ); + } + if ( nFanins > 1 ) + pCounts[4] += nFanins-1; + } + //printf( "Found %d names\n", Vec_PtrSize(vNames) ); + Abc_FrameSetSignalNames( vNames ); +} Vec_Int_t * Acb_NtkPlaces( char * pFileName, Vec_Ptr_t * vNames ) { Vec_Int_t * vPlaces; int First = 1, Pos = -1, fComment = 0; @@ -1002,6 +1058,7 @@ void Acb_NtkInsert( char * pFileNameIn, char * pFileNameOut, Vec_Ptr_t * vNames, return; } vPlaces = Acb_NtkPlaces( pFileNameIn, vNames ); + Acb_NtkFindNamesInPlaces( pBuffer, vPlaces, vNames ); Vec_IntForEachEntryDouble( vPlaces, Pos, iObj, i ) { for ( k = Prev; k < Pos; k++ ) diff --git a/src/base/main/main.h b/src/base/main/main.h index 2efb3358..9ef8b6ff 100644 --- a/src/base/main/main.h +++ b/src/base/main/main.h @@ -105,6 +105,8 @@ extern ABC_DLL void * Abc_FrameReadManDd(); extern ABC_DLL void * Abc_FrameReadManDec(); extern ABC_DLL void * Abc_FrameReadManDsd(); extern ABC_DLL void * Abc_FrameReadManDsd2(); +extern ABC_DLL Vec_Ptr_t * Abc_FrameReadSignalNames(); +extern ABC_DLL int * Abc_FrameReadGateCounts(); extern ABC_DLL char * Abc_FrameReadFlag( char * pFlag ); extern ABC_DLL int Abc_FrameIsFlagEnabled( char * pFlag ); @@ -147,6 +149,7 @@ extern ABC_DLL void Abc_FrameSetCnf( Vec_Int_t * vInv ); extern ABC_DLL void Abc_FrameSetStr( Vec_Str_t * vInv ); extern ABC_DLL void Abc_FrameSetJsonStrs( Abc_Nam_t * pStrs ); extern ABC_DLL void Abc_FrameSetJsonObjs( Vec_Wec_t * vObjs ); +extern ABC_DLL void Abc_FrameSetSignalNames( Vec_Ptr_t * vNames ); extern ABC_DLL int Abc_FrameCheckPoConst( Abc_Frame_t * p, int iPoNum ); diff --git a/src/base/main/mainFrame.c b/src/base/main/mainFrame.c index 1d54f4e4..2743a90a 100644 --- a/src/base/main/mainFrame.c +++ b/src/base/main/mainFrame.c @@ -67,6 +67,8 @@ void * Abc_FrameReadManDec() { if ( s_GlobalFram void * Abc_FrameReadManDsd() { return s_GlobalFrame->pManDsd; } void * Abc_FrameReadManDsd2() { return s_GlobalFrame->pManDsd2; } char * Abc_FrameReadFlag( char * pFlag ) { return Cmd_FlagReadByName( s_GlobalFrame, pFlag ); } +Vec_Ptr_t * Abc_FrameReadSignalNames() { return s_GlobalFrame->vSignalNames; } +int * Abc_FrameReadGateCounts() { return s_GlobalFrame->pGateCounts; } int Abc_FrameReadBmcFrames( Abc_Frame_t * p ) { return s_GlobalFrame->nFrames; } int Abc_FrameReadProbStatus( Abc_Frame_t * p ) { return s_GlobalFrame->Status; } @@ -102,6 +104,7 @@ void Abc_FrameSetManDsd2( void * pMan ) { if (s_GlobalFrame void Abc_FrameSetInv( Vec_Int_t * vInv ) { Vec_IntFreeP(&s_GlobalFrame->pAbcWlcInv); s_GlobalFrame->pAbcWlcInv = vInv; } void Abc_FrameSetJsonStrs( Abc_Nam_t * pStrs ) { Abc_NamDeref( s_GlobalFrame->pJsonStrs ); s_GlobalFrame->pJsonStrs = pStrs; } void Abc_FrameSetJsonObjs( Vec_Wec_t * vObjs ) { Vec_WecFreeP(&s_GlobalFrame->vJsonObjs ); s_GlobalFrame->vJsonObjs = vObjs; } +void Abc_FrameSetSignalNames( Vec_Ptr_t * vNames ) { if ( s_GlobalFrame->vSignalNames ) Vec_PtrFreeFree( s_GlobalFrame->vSignalNames ); s_GlobalFrame->vSignalNames = vNames; } int Abc_FrameIsBatchMode() { return s_GlobalFrame ? s_GlobalFrame->fBatchMode : 0; } @@ -231,6 +234,8 @@ void Abc_FrameDeallocate( Abc_Frame_t * p ) } Vec_IntFreeP( &p->vIndFlops ); Vec_PtrFreeP( &p->vLTLProperties_global ); + if ( p->vSignalNames ) + Vec_PtrFreeFree( p->vSignalNames ); Abc_FrameDeleteAllNetworks( p ); ABC_FREE( p->pDrivingCell ); ABC_FREE( p->pCex2 ); diff --git a/src/base/main/mainInt.h b/src/base/main/mainInt.h index bc57ad2a..9eaa03d1 100644 --- a/src/base/main/mainInt.h +++ b/src/base/main/mainInt.h @@ -133,6 +133,8 @@ struct Abc_Frame_t_ int nFrames; // the number of time frames completed by BMC Vec_Ptr_t * vPlugInComBinPairs; // pairs of command and its binary name Vec_Ptr_t * vLTLProperties_global; // related to LTL + Vec_Ptr_t * vSignalNames; // temporary storage for signal names + int pGateCounts[5];// temporary gate counts void * pSave1; void * pSave2; void * pSave3; -- cgit v1.2.3 From 0ae0744e73b978593a054e8bf80c35723c9f4b03 Mon Sep 17 00:00:00 2001 From: Alan Mishchenko Date: Fri, 15 May 2020 22:11:10 -0700 Subject: Experimental resubstitution. --- src/base/abci/abc.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'src/base') diff --git a/src/base/abci/abc.c b/src/base/abci/abc.c index 798ec7d0..b7f0517e 100644 --- a/src/base/abci/abc.c +++ b/src/base/abci/abc.c @@ -32892,7 +32892,7 @@ int Abc_CommandAbc9ReadSim( Abc_Frame_t * pAbc, int argc, char ** argv ) if ( fOutputs ) { Vec_WrdFreeP( &pAbc->pGia->vSimsPo ); - pAbc->pGia->vSimsPo = Gia_ManSimPatRead( pArgvNew[0], NULL ); + pAbc->pGia->vSimsPo = Vec_WrdReadHex( pArgvNew[0], NULL, 1 ); if ( Vec_WrdSize(pAbc->pGia->vSimsPo) % Gia_ManCoNum(pAbc->pGia) != 0 ) { Vec_WrdFreeP( &pAbc->pGia->vSimsPo ); @@ -32906,7 +32906,7 @@ int Abc_CommandAbc9ReadSim( Abc_Frame_t * pAbc, int argc, char ** argv ) else { Vec_WrdFreeP( &pAbc->pGia->vSimsPi ); - pAbc->pGia->vSimsPi = Gia_ManSimPatRead( pArgvNew[0], NULL ); + pAbc->pGia->vSimsPi = Vec_WrdReadHex( pArgvNew[0], NULL, 1 ); if ( Vec_WrdSize(pAbc->pGia->vSimsPi) % Gia_ManCiNum(pAbc->pGia) != 0 ) { Vec_WrdFreeP( &pAbc->pGia->vSimsPi ); @@ -32988,12 +32988,12 @@ int Abc_CommandAbc9WriteSim( Abc_Frame_t * pAbc, int argc, char ** argv ) if ( fOutputs ) { assert( Vec_WrdSize(pAbc->pGia->vSimsPo) % Gia_ManCoNum(pAbc->pGia) == 0 ); - Gia_ManSimPatWrite( pArgvNew[0], pAbc->pGia->vSimsPo, Vec_WrdSize(pAbc->pGia->vSimsPo) / Gia_ManCoNum(pAbc->pGia) ); + Vec_WrdDumpHex( pArgvNew[0], pAbc->pGia->vSimsPo, Vec_WrdSize(pAbc->pGia->vSimsPo) / Gia_ManCoNum(pAbc->pGia), 1 ); } else { assert( Vec_WrdSize(pAbc->pGia->vSimsPi) % Gia_ManCiNum(pAbc->pGia) == 0 ); - Gia_ManSimPatWrite( pArgvNew[0], pAbc->pGia->vSimsPi, Vec_WrdSize(pAbc->pGia->vSimsPi) / Gia_ManCiNum(pAbc->pGia) ); + Vec_WrdDumpHex( pArgvNew[0], pAbc->pGia->vSimsPi, Vec_WrdSize(pAbc->pGia->vSimsPi) / Gia_ManCiNum(pAbc->pGia), 1 ); } return 0; @@ -47938,7 +47938,7 @@ int Abc_CommandAbc9Test( Abc_Frame_t * pAbc, int argc, char ** argv ) // return 1; // } // Abc_FrameUpdateGia( pAbc, Abc_Procedure(pAbc->pGia) ); -// Gia_SimQualityTest( pAbc->pGia ); +// Gia_ManTryResub( pAbc->pGia ); return 0; usage: Abc_Print( -2, "usage: &test [-FW num] [-svh]\n" ); -- cgit v1.2.3 From 97c826a6e63eb0020920819595f4da8f2cc674ba Mon Sep 17 00:00:00 2001 From: Alan Mishchenko Date: Mon, 18 May 2020 16:02:57 -0700 Subject: Dumping BDD variable order after 'clp'. --- src/base/abc/abc.h | 2 +- src/base/abci/abc.c | 14 ++++++++++---- src/base/abci/abcCollapse.c | 15 +++++++++++++-- src/base/abci/abcIvy.c | 2 +- src/base/abci/abcLutmin.c | 2 +- src/base/abci/abcProve.c | 2 +- 6 files changed, 27 insertions(+), 10 deletions(-) (limited to 'src/base') diff --git a/src/base/abc/abc.h b/src/base/abc/abc.h index 312354da..c36bde70 100644 --- a/src/base/abc/abc.h +++ b/src/base/abc/abc.h @@ -600,7 +600,7 @@ extern ABC_DLL int Abc_NtkCheckUniqueCiNames( Abc_Ntk_t * pNtk ); extern ABC_DLL int Abc_NtkCheckUniqueCoNames( Abc_Ntk_t * pNtk ); extern ABC_DLL int Abc_NtkCheckUniqueCioNames( Abc_Ntk_t * pNtk ); /*=== abcCollapse.c ==========================================================*/ -extern ABC_DLL Abc_Ntk_t * Abc_NtkCollapse( Abc_Ntk_t * pNtk, int fBddSizeMax, int fDualRail, int fReorder, int fReverse, int fVerbose ); +extern ABC_DLL Abc_Ntk_t * Abc_NtkCollapse( Abc_Ntk_t * pNtk, int fBddSizeMax, int fDualRail, int fReorder, int fReverse, int fDumpOrder, int fVerbose ); extern ABC_DLL Abc_Ntk_t * Abc_NtkCollapseSat( Abc_Ntk_t * pNtk, int nCubeLim, int nBTLimit, int nCostMax, int fCanon, int fReverse, int fCnfShared, int fVerbose ); extern ABC_DLL Gia_Man_t * Abc_NtkClpGia( Abc_Ntk_t * pNtk ); /*=== abcCut.c ==========================================================*/ diff --git a/src/base/abci/abc.c b/src/base/abci/abc.c index b7f0517e..411f66ed 100644 --- a/src/base/abci/abc.c +++ b/src/base/abci/abc.c @@ -3355,6 +3355,7 @@ int Abc_CommandCollapse( Abc_Frame_t * pAbc, int argc, char ** argv ) int fDualRail; int fReorder; int fReverse; + int fDumpOrder; int c; char * pLogFileName = NULL; pNtk = Abc_FrameReadNtk(pAbc); @@ -3364,9 +3365,10 @@ int Abc_CommandCollapse( Abc_Frame_t * pAbc, int argc, char ** argv ) fReorder = 1; fReverse = 0; fDualRail = 0; + fDumpOrder = 0; fBddSizeMax = ABC_INFINITY; Extra_UtilGetoptReset(); - while ( ( c = Extra_UtilGetopt( argc, argv, "BLrodvh" ) ) != EOF ) + while ( ( c = Extra_UtilGetopt( argc, argv, "BLrodxvh" ) ) != EOF ) { switch ( c ) { @@ -3399,6 +3401,9 @@ int Abc_CommandCollapse( Abc_Frame_t * pAbc, int argc, char ** argv ) case 'd': fDualRail ^= 1; break; + case 'x': + fDumpOrder ^= 1; + break; case 'v': fVerbose ^= 1; break; @@ -3423,11 +3428,11 @@ int Abc_CommandCollapse( Abc_Frame_t * pAbc, int argc, char ** argv ) // get the new network if ( Abc_NtkIsStrash(pNtk) ) - pNtkRes = Abc_NtkCollapse( pNtk, fBddSizeMax, fDualRail, fReorder, fReverse, fVerbose ); + pNtkRes = Abc_NtkCollapse( pNtk, fBddSizeMax, fDualRail, fReorder, fReverse, fDumpOrder, fVerbose ); else { pNtk = Abc_NtkStrash( pNtk, 0, 0, 0 ); - pNtkRes = Abc_NtkCollapse( pNtk, fBddSizeMax, fDualRail, fReorder, fReverse, fVerbose ); + pNtkRes = Abc_NtkCollapse( pNtk, fBddSizeMax, fDualRail, fReorder, fReverse, fDumpOrder, fVerbose ); Abc_NtkDelete( pNtk ); } if ( pNtkRes == NULL ) @@ -3450,13 +3455,14 @@ int Abc_CommandCollapse( Abc_Frame_t * pAbc, int argc, char ** argv ) return 0; usage: - Abc_Print( -2, "usage: collapse [-B ] [-L file] [-rodvh]\n" ); + Abc_Print( -2, "usage: collapse [-B ] [-L file] [-rodxvh]\n" ); Abc_Print( -2, "\t collapses the network by constructing global BDDs\n" ); Abc_Print( -2, "\t-B : limit on live BDD nodes during collapsing [default = %d]\n", fBddSizeMax ); Abc_Print( -2, "\t-L file : the log file name [default = %s]\n", pLogFileName ? pLogFileName : "no logging" ); Abc_Print( -2, "\t-r : toggles dynamic variable reordering [default = %s]\n", fReorder? "yes": "no" ); Abc_Print( -2, "\t-o : toggles reverse variable ordering [default = %s]\n", fReverse? "yes": "no" ); Abc_Print( -2, "\t-d : toggles dual-rail collapsing mode [default = %s]\n", fDualRail? "yes": "no" ); + Abc_Print( -2, "\t-x : toggles dumping file \"order.txt\" with variable order [default = %s]\n", fDumpOrder? "yes": "no" ); Abc_Print( -2, "\t-v : print verbose information [default = %s]\n", fVerbose? "yes": "no" ); Abc_Print( -2, "\t-h : print the command usage\n"); return 1; diff --git a/src/base/abci/abcCollapse.c b/src/base/abci/abcCollapse.c index ca54d542..136712cb 100644 --- a/src/base/abci/abcCollapse.c +++ b/src/base/abci/abcCollapse.c @@ -195,7 +195,16 @@ Abc_Ntk_t * Abc_NtkFromGlobalBdds( Abc_Ntk_t * pNtk, int fReverse ) Extra_ProgressBarStop( pProgress ); return pNtkNew; } -Abc_Ntk_t * Abc_NtkCollapse( Abc_Ntk_t * pNtk, int fBddSizeMax, int fDualRail, int fReorder, int fReverse, int fVerbose ) +void Abc_NtkDumpVariableOrder( Abc_Ntk_t * pNtk ) +{ + DdManager * dd = (DdManager *)Abc_NtkGlobalBddMan( pNtk ); + FILE * pFile = fopen( "order.txt", "wb" ); int i; + for ( i = 0; i < dd->size; i++ ) + fprintf( pFile, "%d ", dd->invperm[i] ); + fprintf( pFile, "\n" ); + fclose( pFile ); +} +Abc_Ntk_t * Abc_NtkCollapse( Abc_Ntk_t * pNtk, int fBddSizeMax, int fDualRail, int fReorder, int fReverse, int fDumpOrder, int fVerbose ) { Abc_Ntk_t * pNtkNew; abctime clk = Abc_Clock(); @@ -210,6 +219,8 @@ Abc_Ntk_t * Abc_NtkCollapse( Abc_Ntk_t * pNtk, int fBddSizeMax, int fDualRail, i printf( "Shared BDD size = %6d nodes. ", Cudd_ReadKeys(dd) - Cudd_ReadDead(dd) ); ABC_PRT( "BDD construction time", Abc_Clock() - clk ); } + if ( fDumpOrder ) + Abc_NtkDumpVariableOrder( pNtk ); // create the new network pNtkNew = Abc_NtkFromGlobalBdds( pNtk, fReverse ); @@ -236,7 +247,7 @@ Abc_Ntk_t * Abc_NtkCollapse( Abc_Ntk_t * pNtk, int fBddSizeMax, int fDualRail, i #else -Abc_Ntk_t * Abc_NtkCollapse( Abc_Ntk_t * pNtk, int fBddSizeMax, int fDualRail, int fReorder, int fReverse, int fVerbose ) +Abc_Ntk_t * Abc_NtkCollapse( Abc_Ntk_t * pNtk, int fBddSizeMax, int fDualRail, int fReorder, int fReverse, int fDumpOrder, int fVerbose ) { return NULL; } diff --git a/src/base/abci/abcIvy.c b/src/base/abci/abcIvy.c index 5dc125d0..3f268ea2 100644 --- a/src/base/abci/abcIvy.c +++ b/src/base/abci/abcIvy.c @@ -601,7 +601,7 @@ int Abc_NtkIvyProve( Abc_Ntk_t ** ppNtk, void * pPars ) printf( "Attempting BDDs with node limit %d ...\n", pParams->nBddSizeLimit ); fflush( stdout ); } - pNtk = Abc_NtkCollapse( pNtkTemp = pNtk, pParams->nBddSizeLimit, 0, pParams->fBddReorder, 0, 0 ); + pNtk = Abc_NtkCollapse( pNtkTemp = pNtk, pParams->nBddSizeLimit, 0, pParams->fBddReorder, 0, 0, 0 ); if ( pNtk ) { Abc_NtkDelete( pNtkTemp ); diff --git a/src/base/abci/abcLutmin.c b/src/base/abci/abcLutmin.c index 2ac44060..be01beb6 100644 --- a/src/base/abci/abcLutmin.c +++ b/src/base/abci/abcLutmin.c @@ -739,7 +739,7 @@ Abc_Ntk_t * Abc_NtkLutmin( Abc_Ntk_t * pNtkInit, int nLutSize, int fVerbose ) else pNtkNew = Abc_NtkStrash( pNtkInit, 0, 1, 0 ); // collapse the network - pNtkNew = Abc_NtkCollapse( pTemp = pNtkNew, 10000, 0, 1, 0, 0 ); + pNtkNew = Abc_NtkCollapse( pTemp = pNtkNew, 10000, 0, 1, 0, 0, 0 ); Abc_NtkDelete( pTemp ); if ( pNtkNew == NULL ) return NULL; diff --git a/src/base/abci/abcProve.c b/src/base/abci/abcProve.c index 03722926..b14c0827 100644 --- a/src/base/abci/abcProve.c +++ b/src/base/abci/abcProve.c @@ -201,7 +201,7 @@ int Abc_NtkMiterProve( Abc_Ntk_t ** ppNtk, void * pPars ) fflush( stdout ); } clk = Abc_Clock(); - pNtk = Abc_NtkCollapse( pNtkTemp = pNtk, pParams->nBddSizeLimit, 0, pParams->fBddReorder, 0, 0 ); + pNtk = Abc_NtkCollapse( pNtkTemp = pNtk, pParams->nBddSizeLimit, 0, pParams->fBddReorder, 0, 0, 0 ); if ( pNtk ) { Abc_NtkDelete( pNtkTemp ); -- cgit v1.2.3 From 491e4ebfd1fd0a484ce45ecb4baf21c9ae8ccb08 Mon Sep 17 00:00:00 2001 From: Alan Mishchenko Date: Wed, 3 Jun 2020 14:52:42 -0700 Subject: Experimental simulation. --- src/base/abci/abc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/base') diff --git a/src/base/abci/abc.c b/src/base/abci/abc.c index 411f66ed..1f7f4c7f 100644 --- a/src/base/abci/abc.c +++ b/src/base/abci/abc.c @@ -47944,7 +47944,7 @@ int Abc_CommandAbc9Test( Abc_Frame_t * pAbc, int argc, char ** argv ) // return 1; // } // Abc_FrameUpdateGia( pAbc, Abc_Procedure(pAbc->pGia) ); -// Gia_ManTryResub( pAbc->pGia ); + Gia_ManSimTest( pAbc->pGia ); return 0; usage: Abc_Print( -2, "usage: &test [-FW num] [-svh]\n" ); -- cgit v1.2.3 From a3c6f33a87c3bbee5f0ebb61907d0416ae5bc661 Mon Sep 17 00:00:00 2001 From: Alan Mishchenko Date: Thu, 4 Jun 2020 16:24:43 -0700 Subject: Experimental simulation. --- src/base/abci/abc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/base') diff --git a/src/base/abci/abc.c b/src/base/abci/abc.c index 1f7f4c7f..411f66ed 100644 --- a/src/base/abci/abc.c +++ b/src/base/abci/abc.c @@ -47944,7 +47944,7 @@ int Abc_CommandAbc9Test( Abc_Frame_t * pAbc, int argc, char ** argv ) // return 1; // } // Abc_FrameUpdateGia( pAbc, Abc_Procedure(pAbc->pGia) ); - Gia_ManSimTest( pAbc->pGia ); +// Gia_ManTryResub( pAbc->pGia ); return 0; usage: Abc_Print( -2, "usage: &test [-FW num] [-svh]\n" ); -- cgit v1.2.3 From 58e3a5caff7033200fce5136dd7e02eee87c4e8a Mon Sep 17 00:00:00 2001 From: Alan Mishchenko Date: Thu, 4 Jun 2020 16:48:06 -0700 Subject: Compiler error. --- src/base/abci/abc.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src/base') diff --git a/src/base/abci/abc.c b/src/base/abci/abc.c index 411f66ed..52475b50 100644 --- a/src/base/abci/abc.c +++ b/src/base/abci/abc.c @@ -34788,8 +34788,8 @@ usage: ***********************************************************************/ int Abc_CommandAbc9Resub( Abc_Frame_t * pAbc, int argc, char ** argv ) { - extern Gia_Man_t * Gia_ManResub1( char * pFileName, int nNodes, int nSupp, int nDivs, int fVerbose, int fVeryVerbose ); - extern Gia_Man_t * Gia_ManResub2( Gia_Man_t * pGia, int nNodes, int nSupp, int nDivs, int fVerbose, int fVeryVerbose ); + extern Gia_Man_t * Gia_ManResub1( char * pFileName, int nNodes, int nSupp, int nDivs, int iChoice, int fUseXor, int fVerbose, int fVeryVerbose ); + extern Gia_Man_t * Gia_ManResub2( Gia_Man_t * pGia, int nNodes, int nSupp, int nDivs, int iChoice, int fUseXor, int fVerbose, int fVeryVerbose ); Gia_Man_t * pTemp; int nNodes = 0; int nSupp = 0; @@ -34848,7 +34848,7 @@ int Abc_CommandAbc9Resub( Abc_Frame_t * pAbc, int argc, char ** argv ) } if ( argc == globalUtilOptind + 1 ) { - pTemp = Gia_ManResub1( argv[globalUtilOptind], nNodes, nSupp, nDivs, fVerbose, fVeryVerbose ); + pTemp = Gia_ManResub1( argv[globalUtilOptind], nNodes, nSupp, nDivs, 0, 0, fVerbose, fVeryVerbose ); Abc_FrameUpdateGia( pAbc, pTemp ); return 0; } @@ -34857,7 +34857,7 @@ int Abc_CommandAbc9Resub( Abc_Frame_t * pAbc, int argc, char ** argv ) Abc_Print( -1, "Abc_CommandAbc9Resub(): There is no AIG.\n" ); return 1; } - pTemp = Gia_ManResub2( pAbc->pGia, nNodes, nSupp, nDivs, fVerbose, fVeryVerbose ); + pTemp = Gia_ManResub2( pAbc->pGia, nNodes, nSupp, nDivs, 0, 0, fVerbose, fVeryVerbose ); Abc_FrameUpdateGia( pAbc, pTemp ); return 0; -- cgit v1.2.3 From 322cea8234aaa6a46c3f2f19c3c3246476231875 Mon Sep 17 00:00:00 2001 From: Alan Mishchenko Date: Wed, 24 Jun 2020 10:20:28 -0700 Subject: Bug fix in &cec (handling the case when the miter is disproved by the all-0 pattern). --- src/base/abci/abc.c | 28 +++++++++++++++++++++++----- 1 file changed, 23 insertions(+), 5 deletions(-) (limited to 'src/base') diff --git a/src/base/abci/abc.c b/src/base/abci/abc.c index 52475b50..69d72757 100644 --- a/src/base/abci/abc.c +++ b/src/base/abci/abc.c @@ -36950,13 +36950,31 @@ int Abc_CommandAbc9Cec( Abc_Frame_t * pAbc, int argc, char ** argv ) } else { - Gia_Man_t * pTemp; + abctime clk = Abc_Clock(); + Gia_Obj_t * pObj; int i; if ( !pPars->fSilent ) Abc_Print( 1, "Assuming the current network is a single-output miter.\n" ); - pTemp = Gia_ManDemiterToDual( pAbc->pGia ); - pAbc->Status = Cec_ManVerify( pTemp, pPars ); - ABC_SWAP( Abc_Cex_t *, pAbc->pGia->pCexComb, pTemp->pCexComb ); - Gia_ManStop( pTemp ); + // handle the case when the output is disproved by an all-0 primary input pattern + ABC_FREE( pAbc->pGia->pCexComb ); + Gia_ManSetPhase( pAbc->pGia ); + Gia_ManForEachCo( pAbc->pGia, pObj, i ) + if ( pObj->fPhase ) + { + pAbc->pGia->pCexComb = Abc_CexAlloc( 0, Gia_ManCiNum(pAbc->pGia), 1 ); + if ( !pPars->fSilent ) + { + Abc_Print( 1, "Networks are NOT EQUIVALENT. Output %d trivially differs (different phase). ", i ); + Abc_PrintTime( 1, "Time", Abc_Clock() - clk ); + } + break; + } + if ( pAbc->pGia->pCexComb == NULL ) + { + Gia_Man_t * pTemp = Gia_ManDemiterToDual( pAbc->pGia ); + pAbc->Status = Cec_ManVerify( pTemp, pPars ); + ABC_SWAP( Abc_Cex_t *, pAbc->pGia->pCexComb, pTemp->pCexComb ); + Gia_ManStop( pTemp ); + } } Abc_FrameReplaceCex( pAbc, &pAbc->pGia->pCexComb ); return 0; -- cgit v1.2.3 From 83f54185ef74a35e54a003a39810b7d755941af4 Mon Sep 17 00:00:00 2001 From: Alan Mishchenko Date: Wed, 24 Jun 2020 10:57:47 -0700 Subject: Bug fix in &cec (properly updating the status after the corner case bug fix\). --- src/base/abci/abc.c | 1 + 1 file changed, 1 insertion(+) (limited to 'src/base') diff --git a/src/base/abci/abc.c b/src/base/abci/abc.c index 69d72757..d9498510 100644 --- a/src/base/abci/abc.c +++ b/src/base/abci/abc.c @@ -36966,6 +36966,7 @@ int Abc_CommandAbc9Cec( Abc_Frame_t * pAbc, int argc, char ** argv ) Abc_Print( 1, "Networks are NOT EQUIVALENT. Output %d trivially differs (different phase). ", i ); Abc_PrintTime( 1, "Time", Abc_Clock() - clk ); } + pAbc->Status = 0;// satisfiable break; } if ( pAbc->pGia->pCexComb == NULL ) -- cgit v1.2.3 From 2ba092e4cc73ec8d6001cdc1a1784a799be745af Mon Sep 17 00:00:00 2001 From: Alan Mishchenko Date: Sat, 11 Jul 2020 10:14:43 -0700 Subject: Fixing commands 'putontop' and 'topmost'; adding command 'bottommost'. --- src/base/abci/abc.c | 99 +++++++++++++++++++++++++++++++++++++++++++---- src/base/abci/abcStrash.c | 88 ++++++++++++++++++++++++++++++++++++----- 2 files changed, 171 insertions(+), 16 deletions(-) (limited to 'src/base') diff --git a/src/base/abci/abc.c b/src/base/abci/abc.c index d9498510..ead8228a 100644 --- a/src/base/abci/abc.c +++ b/src/base/abci/abc.c @@ -193,6 +193,7 @@ static int Abc_CommandCone ( Abc_Frame_t * pAbc, int argc, cha static int Abc_CommandNode ( Abc_Frame_t * pAbc, int argc, char ** argv ); static int Abc_CommandCof ( Abc_Frame_t * pAbc, int argc, char ** argv ); static int Abc_CommandTopmost ( Abc_Frame_t * pAbc, int argc, char ** argv ); +static int Abc_CommandBottommost ( Abc_Frame_t * pAbc, int argc, char ** argv ); static int Abc_CommandTopAnd ( Abc_Frame_t * pAbc, int argc, char ** argv ); static int Abc_CommandTrim ( Abc_Frame_t * pAbc, int argc, char ** argv ); static int Abc_CommandShortNames ( Abc_Frame_t * pAbc, int argc, char ** argv ); @@ -915,6 +916,7 @@ void Abc_Init( Abc_Frame_t * pAbc ) Cmd_CommandAdd( pAbc, "Various", "node", Abc_CommandNode, 1 ); Cmd_CommandAdd( pAbc, "Various", "cof", Abc_CommandCof, 1 ); Cmd_CommandAdd( pAbc, "Various", "topmost", Abc_CommandTopmost, 1 ); + Cmd_CommandAdd( pAbc, "Various", "bottommost", Abc_CommandBottommost, 1 ); Cmd_CommandAdd( pAbc, "Various", "topand", Abc_CommandTopAnd, 1 ); Cmd_CommandAdd( pAbc, "Various", "trim", Abc_CommandTrim, 1 ); Cmd_CommandAdd( pAbc, "Various", "short_names", Abc_CommandShortNames, 0 ); @@ -10423,7 +10425,15 @@ int Abc_CommandPutOnTop( Abc_Frame_t * pAbc, int argc, char ** argv ) } // get the new network - pNtkRes = Abc_NtkPutOnTop( pNtk, pNtk2 ); + if ( Abc_NtkIsLogic(pNtk2) ) + pNtkRes = Abc_NtkPutOnTop( pNtk, pNtk2 ); + else if ( Abc_NtkIsStrash(pNtk2) ) + { + Abc_Ntk_t * pLogic = Abc_NtkToLogic( pNtk2 ); + pNtkRes = Abc_NtkPutOnTop( pNtk, pLogic ); + Abc_NtkDelete( pLogic ); + } + else assert( 0 ); Abc_NtkDelete( pNtk2 ); // replace the current network Abc_FrameReplaceCurrentNetwork( pAbc, pNtkRes ); @@ -11903,12 +11913,7 @@ int Abc_CommandTopmost( Abc_Frame_t * pAbc, int argc, char ** argv ) if ( Abc_NtkLatchNum(pNtk) > 0 ) { - Abc_Print( -1, "Currently can only works for combinational circuits.\n" ); - return 0; - } - if ( Abc_NtkPoNum(pNtk) != 1 ) - { - Abc_Print( -1, "Currently expects a single-output miter.\n" ); + Abc_Print( -1, "Currently only works for combinational circuits.\n" ); return 0; } @@ -11931,6 +11936,86 @@ usage: return 1; } +/**Function************************************************************* + + Synopsis [] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +int Abc_CommandBottommost( Abc_Frame_t * pAbc, int argc, char ** argv ) +{ + Abc_Ntk_t * pNtk, * pNtkRes; + int c, nLevels; + extern Abc_Ntk_t * Abc_NtkBottommost( Abc_Ntk_t * pNtk, int nLevels ); + + pNtk = Abc_FrameReadNtk(pAbc); + // set defaults + nLevels = 10; + Extra_UtilGetoptReset(); + while ( ( c = Extra_UtilGetopt( argc, argv, "Nh" ) ) != EOF ) + { + switch ( c ) + { + case 'N': + if ( globalUtilOptind >= argc ) + { + Abc_Print( -1, "Command line switch \"-N\" should be followed by an integer.\n" ); + goto usage; + } + nLevels = atoi(argv[globalUtilOptind]); + globalUtilOptind++; + if ( nLevels < 0 ) + goto usage; + break; + case 'h': + goto usage; + default: + goto usage; + } + } + + if ( pNtk == NULL ) + { + Abc_Print( -1, "Empty network.\n" ); + return 1; + } + + if ( !Abc_NtkIsStrash(pNtk) ) + { + Abc_Print( -1, "Currently only works for structurally hashed circuits.\n" ); + return 0; + } + + if ( Abc_NtkLatchNum(pNtk) > 0 ) + { + Abc_Print( -1, "Currently only works for combinational circuits.\n" ); + return 0; + } + + pNtkRes = Abc_NtkBottommost( pNtk, nLevels ); + if ( pNtkRes == NULL ) + { + Abc_Print( -1, "The command has failed.\n" ); + return 1; + } + // replace the current network + Abc_FrameReplaceCurrentNetwork( pAbc, pNtkRes ); + return 0; + +usage: + Abc_Print( -2, "usage: bottommost [-N num] [-h]\n" ); + Abc_Print( -2, "\t replaces the current network by several of its bottommost levels\n" ); + Abc_Print( -2, "\t-N num : max number of levels [default = %d]\n", nLevels ); + Abc_Print( -2, "\t-h : print the command usage\n"); + Abc_Print( -2, "\tname : the node name\n"); + return 1; +} + /**Function************************************************************* Synopsis [] diff --git a/src/base/abci/abcStrash.c b/src/base/abci/abcStrash.c index e4868d7e..050f3647 100644 --- a/src/base/abci/abcStrash.c +++ b/src/base/abci/abcStrash.c @@ -548,25 +548,27 @@ Abc_Obj_t * Abc_NtkTopmost_rec( Abc_Ntk_t * pNtkNew, Abc_Obj_t * pNode, int Leve Abc_Ntk_t * Abc_NtkTopmost( Abc_Ntk_t * pNtk, int nLevels ) { Abc_Ntk_t * pNtkNew; - Abc_Obj_t * pObjNew, * pObjPo; - int LevelCut; + Abc_Obj_t * pObjNew, * pObj; + int LevelCut, i; assert( Abc_NtkIsStrash(pNtk) ); - assert( Abc_NtkCoNum(pNtk) == 1 ); // get the cutoff level LevelCut = Abc_MaxInt( 0, Abc_AigLevel(pNtk) - nLevels ); // start the network pNtkNew = Abc_NtkAlloc( ABC_NTK_STRASH, ABC_FUNC_AIG, 1 ); pNtkNew->pName = Extra_UtilStrsav(pNtk->pName); - Abc_AigConst1(pNtk)->pCopy = Abc_AigConst1(pNtkNew); // create PIs below the cut and nodes above the cut Abc_NtkCleanCopy( pNtk ); - pObjNew = Abc_NtkTopmost_rec( pNtkNew, Abc_ObjFanin0(Abc_NtkPo(pNtk, 0)), LevelCut ); - pObjNew = Abc_ObjNotCond( pObjNew, Abc_ObjFaninC0(Abc_NtkPo(pNtk, 0)) ); + Abc_AigConst1(pNtk)->pCopy = Abc_AigConst1(pNtkNew); + Abc_NtkForEachCo( pNtk, pObj, i ) + { + pObjNew = Abc_NtkTopmost_rec( pNtkNew, Abc_ObjFanin0(pObj), LevelCut ); + pObjNew = Abc_ObjNotCond( pObjNew, Abc_ObjFaninC0(pObj) ); + Abc_ObjAddFanin( (pObj->pCopy = Abc_NtkCreatePo(pNtkNew)), pObjNew ); + } // add the PO node and name - pObjPo = Abc_NtkCreatePo(pNtkNew); - Abc_ObjAddFanin( pObjPo, pObjNew ); Abc_NtkAddDummyPiNames( pNtkNew ); - Abc_ObjAssignName( pObjPo, Abc_ObjName(Abc_NtkPo(pNtk, 0)), NULL ); + Abc_NtkForEachCo( pNtk, pObj, i ) + Abc_ObjAssignName( pObj->pCopy, Abc_ObjName(pObj), NULL ); // make sure everything is okay if ( !Abc_NtkCheck( pNtkNew ) ) { @@ -578,6 +580,74 @@ Abc_Ntk_t * Abc_NtkTopmost( Abc_Ntk_t * pNtk, int nLevels ) } +/**Function************************************************************* + + Synopsis [Copies the bottommost levels of the network.] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +Abc_Obj_t * Abc_NtkBottommost_rec( Abc_Ntk_t * pNtkNew, Abc_Obj_t * pNode, int LevelCut ) +{ + assert( !Abc_ObjIsComplement(pNode) ); + if ( pNode->pCopy ) + return pNode->pCopy; + Abc_NtkBottommost_rec( pNtkNew, Abc_ObjFanin0(pNode), LevelCut ); + Abc_NtkBottommost_rec( pNtkNew, Abc_ObjFanin1(pNode), LevelCut ); + if ( pNode->Level > (unsigned)LevelCut ) + return NULL; + return pNode->pCopy = Abc_AigAnd( (Abc_Aig_t *)pNtkNew->pManFunc, Abc_ObjChild0Copy(pNode), Abc_ObjChild1Copy(pNode) ); +} + +/**Function************************************************************* + + Synopsis [Copies the topmost levels of the network.] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +Abc_Ntk_t * Abc_NtkBottommost( Abc_Ntk_t * pNtk, int nLevels ) +{ + Abc_Ntk_t * pNtkNew; + Abc_Obj_t * pObj, * pObjNew; + int i; + assert( Abc_NtkIsStrash(pNtk) ); + assert( nLevels >= 0 ); + // start the network + pNtkNew = Abc_NtkAlloc( ABC_NTK_STRASH, ABC_FUNC_AIG, 1 ); + pNtkNew->pName = Extra_UtilStrsav(pNtk->pName); + // create PIs below the cut and nodes above the cut + Abc_NtkCleanCopy( pNtk ); + Abc_AigConst1(pNtk)->pCopy = Abc_AigConst1(pNtkNew); + Abc_NtkForEachCi( pNtk, pObj, i ) + pObj->pCopy = Abc_NtkCreatePi( pNtkNew ); + Abc_NtkForEachCo( pNtk, pObj, i ) + Abc_NtkBottommost_rec( pNtkNew, Abc_ObjFanin0(pObj), nLevels ); + // add POs to nodes without fanout + Abc_NtkForEachNode( pNtkNew, pObjNew, i ) + if ( Abc_ObjFanoutNum(pObjNew) == 0 ) + Abc_ObjAddFanin( Abc_NtkCreatePo(pNtkNew), pObjNew ); + Abc_NtkAddDummyPiNames( pNtkNew ); + Abc_NtkAddDummyPoNames( pNtkNew ); + // make sure everything is okay + if ( !Abc_NtkCheck( pNtkNew ) ) + { + printf( "Abc_NtkBottommost: The network check has failed.\n" ); + Abc_NtkDelete( pNtkNew ); + return NULL; + } + return pNtkNew; +} + + /**Function************************************************************* -- cgit v1.2.3 From 22d9b1d38b27a6a4c4f4b3b8f489704eed943351 Mon Sep 17 00:00:00 2001 From: Alan Mishchenko Date: Thu, 16 Jul 2020 20:33:03 -0700 Subject: Experiment with structural similarity. --- src/base/abci/abc.c | 60 ++++++++++++++++++++++++++++++++++++++++++++++++++ src/base/acb/acbFunc.c | 15 +++++++++++++ 2 files changed, 75 insertions(+) (limited to 'src/base') diff --git a/src/base/abci/abc.c b/src/base/abci/abc.c index ead8228a..b107bdc9 100644 --- a/src/base/abci/abc.c +++ b/src/base/abci/abc.c @@ -505,6 +505,7 @@ static int Abc_CommandAbc9Mesh ( Abc_Frame_t * pAbc, int argc, cha static int Abc_CommandAbc9Iso ( Abc_Frame_t * pAbc, int argc, char ** argv ); static int Abc_CommandAbc9IsoNpn ( Abc_Frame_t * pAbc, int argc, char ** argv ); static int Abc_CommandAbc9IsoSt ( Abc_Frame_t * pAbc, int argc, char ** argv ); +static int Abc_CommandAbc9Compare ( Abc_Frame_t * pAbc, int argc, char ** argv ); static int Abc_CommandAbc9CexInfo ( Abc_Frame_t * pAbc, int argc, char ** argv ); static int Abc_CommandAbc9Cycle ( Abc_Frame_t * pAbc, int argc, char ** argv ); static int Abc_CommandAbc9Cone ( Abc_Frame_t * pAbc, int argc, char ** argv ); @@ -1226,6 +1227,7 @@ void Abc_Init( Abc_Frame_t * pAbc ) Cmd_CommandAdd( pAbc, "ABC9", "&iso", Abc_CommandAbc9Iso, 0 ); Cmd_CommandAdd( pAbc, "ABC9", "&isonpn", Abc_CommandAbc9IsoNpn, 0 ); Cmd_CommandAdd( pAbc, "ABC9", "&isost", Abc_CommandAbc9IsoSt, 0 ); + Cmd_CommandAdd( pAbc, "ABC9", "&compare", Abc_CommandAbc9Compare, 0 ); Cmd_CommandAdd( pAbc, "ABC9", "&cexinfo", Abc_CommandAbc9CexInfo, 0 ); Cmd_CommandAdd( pAbc, "ABC9", "&cycle", Abc_CommandAbc9Cycle, 0 ); Cmd_CommandAdd( pAbc, "ABC9", "&cone", Abc_CommandAbc9Cone, 0 ); @@ -42280,6 +42282,64 @@ usage: return 1; } +/**Function************************************************************* + + Synopsis [] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +int Abc_CommandAbc9Compare( Abc_Frame_t * pAbc, int argc, char ** argv ) +{ + extern void Gia_Iso4TestTwo( Gia_Man_t * pGia0, Gia_Man_t * pGia1 ); + Gia_Man_t * pGia0, * pGia1; + char ** pArgvNew; int nArgcNew; + int c, fVerbose = 0; + Extra_UtilGetoptReset(); + while ( ( c = Extra_UtilGetopt( argc, argv, "vh" ) ) != EOF ) + { + switch ( c ) + { + case 'v': + fVerbose ^= 1; + break; + case 'h': + goto usage; + default: + goto usage; + } + } + pArgvNew = argv + globalUtilOptind; + nArgcNew = argc - globalUtilOptind; + if ( nArgcNew != 2 ) + { + Abc_Print( -1, "Abc_CommandAbc9Compare(): This command expects two AIG file names on the command line.\n" ); + return 1; + } + pGia0 = Gia_AigerRead( pArgvNew[0], 0, 0, 0 ); + pGia1 = Gia_AigerRead( pArgvNew[1], 0, 0, 0 ); + if ( pGia0 == NULL || pGia1 == NULL ) + { + Abc_Print( -1, "Abc_CommandAbc9Compare(): Reading input files did not work.\n" ); + return 1; + } + Gia_Iso4TestTwo( pGia0, pGia1 ); + Gia_ManStop( pGia0 ); + Gia_ManStop( pGia1 ); + return 0; + +usage: + Abc_Print( -2, "usage: &compare [-vh]\n" ); + Abc_Print( -2, "\t compared two AIGs for structural similarity\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/acb/acbFunc.c b/src/base/acb/acbFunc.c index 565dbb06..4d7df1b5 100644 --- a/src/base/acb/acbFunc.c +++ b/src/base/acb/acbFunc.c @@ -825,6 +825,21 @@ void Vec_IntPermute( Vec_Int_t * p ) } } +void Vec_IntPermute2( Vec_Int_t * p ) +{ + int i, nSize = Vec_IntSize( p ); + int * pArray = Vec_IntArray( p ); + srand( time(NULL) ); + for ( i = 0; i < nSize-1; i++ ) + { + if ( rand() % 3 == 0 ) + { + printf( "Permuting %d and %d\n", i, i+1 ); + ABC_SWAP( int, pArray[i], pArray[i+1] ); + } + } +} + void Acb_PrintPatterns( Vec_Wrd_t * vPats, int nPats, Vec_Int_t * vWeights ) { int i, k, Entry, nDivs = Vec_IntSize(vWeights); -- cgit v1.2.3 From aaeadb1438b1a0116cd5912c7c827b6249f22bc4 Mon Sep 17 00:00:00 2001 From: Alan Mishchenko Date: Wed, 29 Jul 2020 19:48:36 -0700 Subject: New ways of reading MiniAIG. --- src/base/abci/abc.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'src/base') diff --git a/src/base/abci/abc.c b/src/base/abci/abc.c index b107bdc9..d1ed5901 100644 --- a/src/base/abci/abc.c +++ b/src/base/abci/abc.c @@ -13988,7 +13988,6 @@ int Abc_CommandTest( Abc_Frame_t * pAbc, int argc, char ** argv ) //Dau_NetworkEnumTest(); //Extra_SimulationTest( nDivMax, nNumOnes, fNewOrder ); //Mnist_ExperimentWithScaling( nDecMax ); - //Gia_Gen2CodeTest(); return 0; usage: Abc_Print( -2, "usage: test [-CKDNM] [-aovwh] \n" ); @@ -29949,18 +29948,20 @@ usage: int Abc_CommandAbc9Read( Abc_Frame_t * pAbc, int argc, char ** argv ) { extern void Abc3_ReadShowHie( char * pFileName, int fFlat ); + extern Gia_Man_t * Gia_MiniAigSuperDerive( char * pFileName, int fVerbose ); Gia_Man_t * pAig = NULL; FILE * pFile; char ** pArgvNew; char * FileName, * pTemp; int c, nArgcNew; int fMiniAig = 0; + int fMiniAig2 = 0; int fMiniLut = 0; int fVerbose = 0; int fGiaSimple = 0; int fSkipStrash = 0; Extra_UtilGetoptReset(); - while ( ( c = Extra_UtilGetopt( argc, argv, "csmlvh" ) ) != EOF ) + while ( ( c = Extra_UtilGetopt( argc, argv, "csmnlvh" ) ) != EOF ) { switch ( c ) { @@ -29973,6 +29974,9 @@ int Abc_CommandAbc9Read( Abc_Frame_t * pAbc, int argc, char ** argv ) case 'm': fMiniAig ^= 1; break; + case 'n': + fMiniAig2 ^= 1; + break; case 'l': fMiniLut ^= 1; break; @@ -30009,6 +30013,8 @@ int Abc_CommandAbc9Read( Abc_Frame_t * pAbc, int argc, char ** argv ) if ( fMiniAig ) pAig = Gia_ManReadMiniAig( FileName ); + else if ( fMiniAig2 ) + pAig = Gia_MiniAigSuperDerive( FileName, fVerbose ); else if ( fMiniLut ) pAig = Gia_ManReadMiniLut( FileName ); // else if ( Extra_FileIsType( FileName, ".v", NULL, NULL ) ) @@ -30020,11 +30026,12 @@ int Abc_CommandAbc9Read( Abc_Frame_t * pAbc, int argc, char ** argv ) return 0; usage: - Abc_Print( -2, "usage: &r [-csmlvh] \n" ); + Abc_Print( -2, "usage: &r [-csmnlvh] \n" ); Abc_Print( -2, "\t reads the current AIG from the AIGER file\n" ); Abc_Print( -2, "\t-c : toggles reading simple AIG [default = %s]\n", fGiaSimple? "yes": "no" ); Abc_Print( -2, "\t-s : toggles structural hashing while reading [default = %s]\n", !fSkipStrash? "yes": "no" ); Abc_Print( -2, "\t-m : toggles reading MiniAIG rather than AIGER file [default = %s]\n", fMiniAig? "yes": "no" ); + Abc_Print( -2, "\t-n : toggles reading MiniAIG as a set of supergates [default = %s]\n", fMiniAig2? "yes": "no" ); Abc_Print( -2, "\t-l : toggles reading MiniLUT rather than AIGER file [default = %s]\n", fMiniLut? "yes": "no" ); Abc_Print( -2, "\t-v : toggles additional verbose output [default = %s]\n", fVerbose? "yes": "no" ); Abc_Print( -2, "\t-h : print the command usage\n"); -- cgit v1.2.3 From 850d39fec30b46b049717ae0a7a5743396b14ecd Mon Sep 17 00:00:00 2001 From: Alan Mishchenko Date: Wed, 12 Aug 2020 19:32:42 -0700 Subject: Making &cec use precomputed simulation info. --- src/base/abci/abc.c | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'src/base') diff --git a/src/base/abci/abc.c b/src/base/abci/abc.c index d1ed5901..3219cd9e 100644 --- a/src/base/abci/abc.c +++ b/src/base/abci/abc.c @@ -37156,6 +37156,11 @@ int Abc_CommandAbc9Cec( Abc_Frame_t * pAbc, int argc, char ** argv ) Abc_Print( 0, "The verification miter is written into file \"%s\".\n", "cec_miter.aig" ); Gia_AigerWrite( pMiter, "cec_miter.aig", 0, 0, 0 ); } + if ( pGias[0]->vSimsPi ) + { + pMiter->vSimsPi = Vec_WrdDup(pGias[0]->vSimsPi); + pMiter->nSimWords = pGias[0]->nSimWords; + } pAbc->Status = Cec_ManVerify( pMiter, pPars ); Abc_FrameReplaceCex( pAbc, &pGias[0]->pCexComb ); Gia_ManStop( pMiter ); -- cgit v1.2.3 From 26e03ef6a052ce71951d4b832cf8871cc272f27a Mon Sep 17 00:00:00 2001 From: Alan Mishchenko Date: Sat, 15 Aug 2020 17:12:41 -0700 Subject: Experiments with window computation. --- src/base/abci/abc.c | 1 + 1 file changed, 1 insertion(+) (limited to 'src/base') diff --git a/src/base/abci/abc.c b/src/base/abci/abc.c index 3219cd9e..2f924747 100644 --- a/src/base/abci/abc.c +++ b/src/base/abci/abc.c @@ -48121,6 +48121,7 @@ int Abc_CommandAbc9Test( Abc_Frame_t * pAbc, int argc, char ** argv ) // } // Abc_FrameUpdateGia( pAbc, Abc_Procedure(pAbc->pGia) ); // Gia_ManTryResub( pAbc->pGia ); + Gia_RsbEnumerateWindows( pAbc->pGia, 6, 5 ); return 0; usage: Abc_Print( -2, "usage: &test [-FW num] [-svh]\n" ); -- cgit v1.2.3 From 4b4646283fef561671191949cfb7149d87e06696 Mon Sep 17 00:00:00 2001 From: Alan Mishchenko Date: Thu, 3 Sep 2020 16:43:53 -0700 Subject: Experiments with ICCAD CAD benchmarks (Problem A). --- src/base/acb/acbFunc.c | 23 +- src/base/acb/acbTest.c | 611 +++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 627 insertions(+), 7 deletions(-) (limited to 'src/base') diff --git a/src/base/acb/acbFunc.c b/src/base/acb/acbFunc.c index 4d7df1b5..eced70e7 100644 --- a/src/base/acb/acbFunc.c +++ b/src/base/acb/acbFunc.c @@ -35,8 +35,6 @@ ABC_NAMESPACE_IMPL_START /// DECLARATIONS /// //////////////////////////////////////////////////////////////////////// -#define ACB_LAST_NAME_ID 14 - typedef enum { ACB_NONE = 0, // 0: unused ACB_MODULE, // 1: "module" @@ -52,6 +50,8 @@ typedef enum { ACB_NOR, // 11: "nor" ACB_XOR, // 12: "xor" ACB_XNOR, // 13: "xnor" + ACB_MUX, // 14: "_HMUX" + ACB_DC, // 15: "_DC" ACB_UNUSED // 14: unused } Acb_KeyWords_t; @@ -70,6 +70,8 @@ static inline char * Acb_Num2Name( int i ) if ( i == 11 ) return "nor"; if ( i == 12 ) return "xor"; if ( i == 13 ) return "xnor"; + if ( i == 14 ) return "_HMUX"; + if ( i == 15 ) return "_DC"; return NULL; } @@ -83,6 +85,8 @@ static inline int Acb_Type2Oper( int i ) if ( i == 11 ) return ABC_OPER_BIT_NOR; if ( i == 12 ) return ABC_OPER_BIT_XOR; if ( i == 13 ) return ABC_OPER_BIT_NXOR; + if ( i == 14 ) return ABC_OPER_BIT_MUX; + if ( i == 15 ) return ABC_OPER_TRI; assert( 0 ); return -1; } @@ -91,6 +95,7 @@ static inline char * Acb_Oper2Name( int i ) { if ( i == ABC_OPER_CONST_F ) return "const0"; if ( i == ABC_OPER_CONST_T ) return "const1"; + if ( i == ABC_OPER_CONST_X ) return "constX"; if ( i == ABC_OPER_BIT_BUF ) return "buf"; if ( i == ABC_OPER_BIT_INV ) return "not"; if ( i == ABC_OPER_BIT_AND ) return "and"; @@ -99,6 +104,8 @@ static inline char * Acb_Oper2Name( int i ) if ( i == ABC_OPER_BIT_NOR ) return "nor"; if ( i == ABC_OPER_BIT_XOR ) return "xor"; if ( i == ABC_OPER_BIT_NXOR ) return "xnor"; + if ( i == ABC_OPER_BIT_MUX ) return "mux"; + if ( i == ABC_OPER_TRI ) return "_DC"; assert( 0 ); return NULL; } @@ -245,14 +252,11 @@ void * Acb_VerilogSimpleParse( Vec_Int_t * vBuffer, Abc_Nam_t * pNames ) vCur = vOutputs; else if ( Token == ACB_WIRE ) vCur = vWires; - else if ( Token >= ACB_BUF && Token <= ACB_XNOR ) + else if ( Token >= ACB_BUF && Token < ACB_UNUSED ) { - //char * pToken = Abc_NamStr(pNames, Vec_IntEntry(vBuffer, i+1)); Vec_IntPush( vTypes, Token ); Vec_IntPush( vTypes, Vec_IntSize(vFanins) ); vCur = vFanins; - //if ( pToken[1] == 'z' && pToken[2] == '_' && pToken[3] == 'g' && pToken[4] == '_' ) - // i++; } else Vec_IntPush( vCur, Token ); @@ -288,6 +292,8 @@ void * Acb_VerilogSimpleParse( Vec_Int_t * vBuffer, Abc_Nam_t * pNames ) Ndr_AddObject( pDesign, ModuleID, ABC_OPER_CONST_F, 0, 0, 0, 0, 0, NULL, 1, &Token, NULL ); // no fanins if ( (Token = Abc_NamStrFind(pNames, "1\'b1")) ) Ndr_AddObject( pDesign, ModuleID, ABC_OPER_CONST_T, 0, 0, 0, 0, 0, NULL, 1, &Token, NULL ); // no fanins + if ( (Token = Abc_NamStrFind(pNames, "1\'bx")) ) + Ndr_AddObject( pDesign, ModuleID, ABC_OPER_CONST_X, 0, 0, 0, 0, 0, NULL, 1, &Token, NULL ); // no fanins Vec_IntForEachEntryDouble( vTypes, Token, Size, i ) if ( Token > 0 ) { @@ -440,7 +446,10 @@ void Acb_VerilogSimpleWrite( Acb_Ntk_t * p, char * pFileName ) { assert( Acb_ObjType(p, iObj) == ABC_OPER_CONST_F || Acb_ObjType(p, iObj) == ABC_OPER_CONST_T ); fprintf( pFile, " %s (", Acb_Oper2Name( ABC_OPER_BIT_BUF ) ); - fprintf( pFile, " 1\'b%d", Acb_ObjType(p, iObj) == ABC_OPER_CONST_T ); + if ( Acb_ObjType(p, iObj) == ABC_OPER_CONST_X ) + fprintf( pFile, " 1\'bx" ); + else + fprintf( pFile, " 1\'b%d", Acb_ObjType(p, iObj) == ABC_OPER_CONST_T ); fprintf( pFile, " );\n" ); } diff --git a/src/base/acb/acbTest.c b/src/base/acb/acbTest.c index fa632ca0..340e3551 100644 --- a/src/base/acb/acbTest.c +++ b/src/base/acb/acbTest.c @@ -19,6 +19,11 @@ ***********************************************************************/ #include "acb.h" +#include "aig/saig/saig.h" +#include "aig/gia/giaAig.h" +#include "base/abc/abc.h" +#include "proof/fraig/fraig.h" +#include "misc/util/utilTruth.h" ABC_NAMESPACE_IMPL_START @@ -26,10 +31,571 @@ ABC_NAMESPACE_IMPL_START /// DECLARATIONS /// //////////////////////////////////////////////////////////////////////// +static int fForceZero = 0; + //////////////////////////////////////////////////////////////////////// /// FUNCTION DEFINITIONS /// //////////////////////////////////////////////////////////////////////// +/**Function************************************************************* + + Synopsis [] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +void Gia_ManSimTry( Gia_Man_t * pF, Gia_Man_t * pG ) +{ + int i, j, n, nWords = 500; + Vec_Wrd_t * vSimsF, * vSimsG; + Abc_Random(1); + Vec_WrdFreeP( &pF->vSimsPi ); + Vec_WrdFreeP( &pG->vSimsPi ); + pF->vSimsPi = Vec_WrdStartRandom( Gia_ManCiNum(pF) * nWords ); + pG->vSimsPi = Vec_WrdDup( pF->vSimsPi ); + vSimsF = Gia_ManSimPatSim( pF ); + vSimsG = Gia_ManSimPatSim( pG ); + assert( Gia_ManObjNum(pF) * nWords == Vec_WrdSize(vSimsF) ); + for ( i = 0; i < Gia_ManCoNum(pF)/2; i++ ) + { + Gia_Obj_t * pObjFb = Gia_ManCo( pF, 2*i+0 ); + Gia_Obj_t * pObjFx = Gia_ManCo( pF, 2*i+1 ); + Gia_Obj_t * pObjGb = Gia_ManCo( pG, 2*i+0 ); + Gia_Obj_t * pObjGx = Gia_ManCo( pG, 2*i+1 ); + word * pSimFb = Vec_WrdEntryP(vSimsF, Gia_ObjId(pF, pObjFb)*nWords); + word * pSimFx = Vec_WrdEntryP(vSimsF, Gia_ObjId(pF, pObjFx)*nWords); + word * pSimGb = Vec_WrdEntryP(vSimsG, Gia_ObjId(pG, pObjGb)*nWords); + word * pSimGx = Vec_WrdEntryP(vSimsG, Gia_ObjId(pG, pObjGx)*nWords); + + int nBitsFx = Abc_TtCountOnesVec(pSimFx, nWords); + int nBitsF1 = Abc_TtCountOnesVecMask(pSimFx, pSimFb, nWords, 1); + int nBitsF0 = nWords*64 - nBitsFx - nBitsF1; + + int nBitsGx = Abc_TtCountOnesVec(pSimGx, nWords); + int nBitsG1 = Abc_TtCountOnesVecMask(pSimGx, pSimGb, nWords, 1); + int nBitsG0 = nWords*64 - nBitsGx - nBitsG1; + + printf( "Output %4d : ", i ); + + printf( " RF : " ); + printf( "0 =%7.3f %% ", 100.0*nBitsF0/64/nWords ); + printf( "1 =%7.3f %% ", 100.0*nBitsF1/64/nWords ); + printf( "X =%7.3f %% ", 100.0*nBitsFx/64/nWords ); + + printf( " GF : " ); + printf( "0 =%7.3f %% ", 100.0*nBitsG0/64/nWords ); + printf( "1 =%7.3f %% ", 100.0*nBitsG1/64/nWords ); + printf( "X =%7.3f %% ", 100.0*nBitsGx/64/nWords ); + + printf( "\n" ); + if ( i == 20 ) + break; + } + + printf( "\n" ); + for ( j = 0; j < 20; j++ ) + { + for ( n = 0; n < 2; n++ ) + { + for ( i = 0; i < Gia_ManCoNum(pF)/2; i++ ) + { + Gia_Obj_t * pObjFb = Gia_ManCo( pF, 2*i+0 ); + Gia_Obj_t * pObjFx = Gia_ManCo( pF, 2*i+1 ); + Gia_Obj_t * pObjGb = Gia_ManCo( pG, 2*i+0 ); + Gia_Obj_t * pObjGx = Gia_ManCo( pG, 2*i+1 ); + word * pSimFb = Vec_WrdEntryP(vSimsF, Gia_ObjId(pF, pObjFb)*nWords); + word * pSimFx = Vec_WrdEntryP(vSimsF, Gia_ObjId(pF, pObjFx)*nWords); + word * pSimGb = Vec_WrdEntryP(vSimsG, Gia_ObjId(pG, pObjGb)*nWords); + word * pSimGx = Vec_WrdEntryP(vSimsG, Gia_ObjId(pG, pObjGx)*nWords); + word * pSimb = n ? pSimGb : pSimFb; + word * pSimx = n ? pSimGx : pSimFx; + if ( Abc_TtGetBit(pSimx, j) ) + printf( "x" ); + else if ( Abc_TtGetBit(pSimb, j) ) + printf( "1" ); + else + printf( "0" ); + } + printf( "\n" ); + } + printf( "\n" ); + } + + Vec_WrdFree( vSimsF ); + Vec_WrdFree( vSimsG ); + printf( "\n" ); +} + +/**Function************************************************************* + + Synopsis [] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +void Gia_ManDualNot( Gia_Man_t * p, int LitA[2], int LitZ[2] ) +{ + LitZ[0] = Abc_LitNot(LitA[0]); + LitZ[1] = LitA[1]; + + if ( fForceZero ) LitZ[0] = Gia_ManHashAnd( p, LitZ[0], Abc_LitNot(LitZ[1]) ); +} +// computes Z = XOR(A, B) where A, B, Z belong to {0,1,x} encoded as 0=00, 1=01, x=1- +void Gia_ManDualXor2( Gia_Man_t * p, int LitA[2], int LitB[2], int LitZ[2] ) +{ + LitZ[0] = Gia_ManHashXor( p, LitA[0], LitB[0] ); + LitZ[1] = Gia_ManHashOr( p, LitA[1], LitB[1] ); + + if ( fForceZero ) LitZ[0] = Gia_ManHashAnd( p, LitZ[0], Abc_LitNot(LitZ[1]) ); +} +void Gia_ManDualXorN( Gia_Man_t * p, int * pLits, int n, int LitZ[2] ) +{ + int i; + LitZ[0] = 0; + LitZ[1] = 0; + for ( i = 0; i < n; i++ ) + { + LitZ[0] = Gia_ManHashXor( p, LitZ[0], pLits[2*i] ); + LitZ[1] = Gia_ManHashOr ( p, LitZ[1], pLits[2*i+1] ); + } +} +// computes Z = AND(A, B) where A, B, Z belong to {0,1,x} encoded as 0=00, 1=01, z=1- +void Gia_ManDualAnd2( Gia_Man_t * p, int LitA[2], int LitB[2], int LitZ[2] ) +{ + int ZeroA = Gia_ManHashAnd( p, Abc_LitNot(LitA[0]), Abc_LitNot(LitA[1]) ); + int ZeroB = Gia_ManHashAnd( p, Abc_LitNot(LitB[0]), Abc_LitNot(LitB[1]) ); + int ZeroZ = Gia_ManHashOr( p, ZeroA, ZeroB ); + LitZ[0] = Gia_ManHashAnd( p, LitA[0], LitB[0] ); + LitZ[1] = Gia_ManHashAnd( p, Gia_ManHashOr( p, LitA[1], LitB[1] ), Abc_LitNot(ZeroZ) ); + + //LitZ[0] = Gia_ManHashAnd( p, Gia_ManHashAnd(p, LitA[0], Abc_LitNot(LitA[1])), Gia_ManHashAnd(p, LitB[0], Abc_LitNot(LitB[1])) ); + //LitZ[1] = Gia_ManHashAnd( p, Gia_ManHashOr(p, LitA[0], LitA[1]), Gia_ManHashOr(p, LitB[0], LitB[1]) ); + //LitZ[1] = Gia_ManHashAnd( p, LitZ[1], Abc_LitNot(LitZ[0]) ); +} +void Gia_ManDualAndN( Gia_Man_t * p, int * pLits, int n, int LitZ[2] ) +{ + int i, LitZero = 0, LitOne = 0; + LitZ[0] = 1; + for ( i = 0; i < n; i++ ) + { + int Lit = Gia_ManHashAnd( p, Abc_LitNot(pLits[2*i]), Abc_LitNot(pLits[2*i+1]) ); + LitZero = Gia_ManHashOr( p, LitZero, Lit ); + LitOne = Gia_ManHashOr( p, LitOne, pLits[2*i+1] ); + LitZ[0] = Gia_ManHashAnd( p, LitZ[0], pLits[2*i] ); + } + LitZ[1] = Gia_ManHashAnd( p, LitOne, Abc_LitNot(LitZero) ); + + if ( fForceZero ) LitZ[0] = Gia_ManHashAnd( p, LitZ[0], Abc_LitNot(LitZ[1]) ); +} +/* +module _DC(O, C, D); + output O; + input C, D; + assign O = D ? 1'bx : C; +endmodule +*/ +void Gia_ManDualDc( Gia_Man_t * p, int LitC[2], int LitD[2], int LitZ[2] ) +{ + LitZ[0] = LitC[0]; +// LitZ[0] = Gia_ManHashMux( p, LitD[0], 0, LitC[0] ); + LitZ[1] = Gia_ManHashOr(p, Gia_ManHashOr(p,LitD[0],LitD[1]), LitC[1] ); + + if ( fForceZero ) LitZ[0] = Gia_ManHashAnd( p, LitZ[0], Abc_LitNot(LitZ[1]) ); +} +void Gia_ManDualMux( Gia_Man_t * p, int LitC[2], int LitT[2], int LitE[2], int LitZ[2] ) +{ +/* + // total logic size: 18 nodes + int Xnor = Gia_ManHashXor( p, Abc_LitNot(LitT[0]), LitE[0] ); + int Cond = Gia_ManHashAnd( p, Abc_LitNot(LitT[1]), Abc_LitNot(LitE[1]) ); + int pTempE[2], pTempT[2]; + pTempE[0] = Gia_ManHashMux( p, LitC[0], LitT[0], LitE[0] ); + pTempE[1] = Gia_ManHashMux( p, LitC[0], LitT[1], LitE[1] ); + //pTempT[0] = LitT[0]; + pTempT[0] = Gia_ManHashAnd( p, LitT[0], LitE[0] ); + pTempT[1] = Gia_ManHashAnd( p, Cond, Xnor ); + LitZ[0] = Gia_ManHashMux( p, LitC[1], pTempT[0], pTempE[0] ); + LitZ[1] = Gia_ManHashMux( p, LitC[1], pTempT[1], pTempE[1] ); +*/ + // total logic size: 14 nodes + int Xnor = Gia_ManHashXor( p, Abc_LitNot(LitT[0]), LitE[0] ); + int Cond = Gia_ManHashAnd( p, Abc_LitNot(LitT[1]), Abc_LitNot(LitE[1]) ); + int XVal1 = Abc_LitNot( Gia_ManHashAnd( p, Cond, Xnor ) ); + int XVal0 = Gia_ManHashMux( p, LitC[0], LitT[1], LitE[1] ); + LitZ[0] = Gia_ManHashMux( p, LitC[0], LitT[0], LitE[0] ); + LitZ[1] = Gia_ManHashMux( p, LitC[1], XVal1, XVal0 ); + + if ( fForceZero ) LitZ[0] = Gia_ManHashAnd( p, LitZ[0], Abc_LitNot(LitZ[1]) ); +} +int Gia_ManDualCompare( Gia_Man_t * p, int LitF[2], int LitS[2] ) +{ + int iMiter = Gia_ManHashXor( p, LitF[0], LitS[0] ); + iMiter = Gia_ManHashOr( p, LitF[1], iMiter ); + iMiter = Gia_ManHashAnd( p, Abc_LitNot(LitS[1]), iMiter ); + return iMiter; +} + +/**Function************************************************************* + + Synopsis [] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +void Acb_ObjToGiaDual( Gia_Man_t * pNew, Acb_Ntk_t * p, int iObj, Vec_Int_t * vTemp, Vec_Int_t * vCopies, int pRes[2] ) +{ + //char * pName = Abc_NamStr( p->pDesign->pStrs, Acb_ObjName(p, iObj) ); + int * pFanin, iFanin, k, Type; + assert( !Acb_ObjIsCio(p, iObj) ); + Vec_IntClear( vTemp ); + Acb_ObjForEachFaninFast( p, iObj, pFanin, iFanin, k ) + { + int * pLits = Vec_IntEntryP( vCopies, 2*iFanin ); + assert( pLits[0] >= 0 && pLits[1] >= 0 ); + Vec_IntPushTwo( vTemp, pLits[0], pLits[1] ); + } + Type = Acb_ObjType( p, iObj ); + if ( Type == ABC_OPER_CONST_F ) + { + pRes[0] = 0; + pRes[1] = 0; + return; + } + if ( Type == ABC_OPER_CONST_T ) + { + pRes[0] = 1; + pRes[1] = 0; + return; + } + if ( Type == ABC_OPER_CONST_X ) + { + pRes[0] = 0; + pRes[1] = 1; + return; + } + if ( Type == ABC_OPER_BIT_BUF ) + { + pRes[0] = Vec_IntEntry(vTemp, 0); + pRes[1] = Vec_IntEntry(vTemp, 1); + return; + } + if ( Type == ABC_OPER_BIT_INV ) + { + Gia_ManDualNot( pNew, Vec_IntArray(vTemp), pRes ); + return; + } + if ( Type == ABC_OPER_TRI ) + { + // in the file inputs are ordered as follows: _DC \n6_5[9] ( .O(\108 ), .C(\96 ), .D(\107 )); + // in this code, we expect them as follows: void Gia_ManDualDc( Gia_Man_t * p, int LitC[2], int LitD[2], int LitZ[2] ) + assert( Vec_IntSize(vTemp) == 4 ); + Gia_ManDualDc( pNew, Vec_IntArray(vTemp), Vec_IntArray(vTemp) + 2, pRes ); + return; + } + if ( Type == ABC_OPER_BIT_MUX ) + { + // in the file inputs are ordered as follows: _HMUX \U$1 ( .O(\282 ), .I0(1'b1), .I1(\277 ), .S(\281 )); + // in this code, we expect them as follows: void Gia_ManDualMux( Gia_Man_t * p, int LitC[2], int LitT[2], int LitE[2], int LitZ[2] ) + assert( Vec_IntSize(vTemp) == 6 ); + ABC_SWAP( int, Vec_IntArray(vTemp)[0], Vec_IntArray(vTemp)[4] ); + ABC_SWAP( int, Vec_IntArray(vTemp)[1], Vec_IntArray(vTemp)[5] ); + Gia_ManDualMux( pNew, Vec_IntArray(vTemp), Vec_IntArray(vTemp) + 2, Vec_IntArray(vTemp) + 4, pRes ); + return; + } + if ( Type == ABC_OPER_BIT_AND || Type == ABC_OPER_BIT_NAND ) + { + Gia_ManDualAndN( pNew, Vec_IntArray(vTemp), Vec_IntSize(vTemp)/2, pRes ); + if ( Type == ABC_OPER_BIT_NAND ) + pRes[0] = Abc_LitNot( pRes[0] ); + return; + } + if ( Type == ABC_OPER_BIT_OR || Type == ABC_OPER_BIT_NOR ) + { + int * pArray = Vec_IntArray( vTemp ); + for ( k = 0; k < Vec_IntSize(vTemp)/2; k++ ) + pArray[2*k] = Abc_LitNot( pArray[2*k] ); + Gia_ManDualAndN( pNew, pArray, Vec_IntSize(vTemp)/2, pRes ); + if ( Type == ABC_OPER_BIT_OR ) + pRes[0] = Abc_LitNot( pRes[0] ); + return; + } + if ( Type == ABC_OPER_BIT_XOR || Type == ABC_OPER_BIT_NXOR ) + { + assert( Vec_IntSize(vTemp) == 4 ); + Gia_ManDualXor2( pNew, Vec_IntArray(vTemp), Vec_IntArray(vTemp) + 2, pRes ); + if ( Type == ABC_OPER_BIT_NXOR ) + pRes[0] = Abc_LitNot( pRes[0] ); + return; + } + assert( 0 ); +} +Gia_Man_t * Acb_NtkGiaDeriveDual( Acb_Ntk_t * p ) +{ + extern Vec_Int_t * Acb_NtkFindNodes2( Acb_Ntk_t * p ); + Gia_Man_t * pNew, * pOne; + Vec_Int_t * vFanins, * vNodes; + Vec_Int_t * vCopies = Vec_IntStartFull( 2*Acb_NtkObjNum(p) ); + int i, iObj, * pLits; + pNew = Gia_ManStart( 5 * Acb_NtkObjNum(p) ); + pNew->pName = Abc_UtilStrsav(Acb_NtkName(p)); + Gia_ManHashAlloc( pNew ); + pLits = Vec_IntEntryP( vCopies, 0 ); + pLits[0] = 0; + pLits[1] = 0; + Acb_NtkForEachCi( p, iObj, i ) + { + pLits = Vec_IntEntryP( vCopies, 2*iObj ); + pLits[0] = Gia_ManAppendCi(pNew); + pLits[1] = 0; + } + vFanins = Vec_IntAlloc( 4 ); + vNodes = Acb_NtkFindNodes2( p ); + Vec_IntForEachEntry( vNodes, iObj, i ) + { + pLits = Vec_IntEntryP( vCopies, 2*iObj ); + Acb_ObjToGiaDual( pNew, p, iObj, vFanins, vCopies, pLits ); + } + Vec_IntFree( vNodes ); + Vec_IntFree( vFanins ); + Acb_NtkForEachCo( p, iObj, i ) + { + pLits = Vec_IntEntryP( vCopies, 2*Acb_ObjFanin(p, iObj, 0) ); + Gia_ManAppendCo( pNew, pLits[0] ); + Gia_ManAppendCo( pNew, pLits[1] ); + } + Vec_IntFree( vCopies ); + pNew = Gia_ManCleanup( pOne = pNew ); + Gia_ManStop( pOne ); + return pNew; +} + +/**Function************************************************************* + + Synopsis [] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +Gia_Man_t * Acb_NtkGiaDeriveMiter( Gia_Man_t * pOne, Gia_Man_t * pTwo, int Type ) +{ + Gia_Man_t * pNew, * pTemp; + Gia_Obj_t * pObj; + int i; + assert( Gia_ManCiNum(pOne) == Gia_ManCiNum(pTwo) ); + assert( Gia_ManCoNum(pOne) == Gia_ManCoNum(pTwo) ); + pNew = Gia_ManStart( Gia_ManObjNum(pOne) + Gia_ManObjNum(pTwo) + 5*Gia_ManCoNum(pOne)/2 ); + pNew->pName = Abc_UtilStrsav( "miter" ); + pNew->pSpec = NULL; + Gia_ManHashAlloc( pNew ); + Gia_ManConst0(pOne)->Value = 0; + Gia_ManConst0(pTwo)->Value = 0; + Gia_ManForEachCi( pOne, pObj, i ) + pObj->Value = Gia_ManAppendCi( pNew ); + Gia_ManForEachCi( pTwo, pObj, i ) + pObj->Value = Gia_ManCi(pOne, i)->Value; + Gia_ManForEachAnd( pOne, pObj, i ) + pObj->Value = Gia_ManHashAnd( pNew, Gia_ObjFanin0Copy(pObj), Gia_ObjFanin1Copy(pObj) ); + Gia_ManForEachAnd( pTwo, pObj, i ) + pObj->Value = Gia_ManHashAnd( pNew, Gia_ObjFanin0Copy(pObj), Gia_ObjFanin1Copy(pObj) ); + Gia_ManForEachCo( pOne, pObj, i ) + pObj->Value = Gia_ObjFanin0Copy(pObj); + Gia_ManForEachCo( pTwo, pObj, i ) + pObj->Value = Gia_ObjFanin0Copy(pObj); + if ( Type == 0 ) // only main circuit + { + for ( i = 0; i < Gia_ManCoNum(pOne); i += 2 ) + { + int pLitsF[2] = { Gia_ManCo(pOne, i)->Value, Gia_ManCo(pOne, i+1)->Value }; + int pLitsS[2] = { Gia_ManCo(pTwo, i)->Value, Gia_ManCo(pTwo, i+1)->Value }; + Gia_ManAppendCo( pNew, pLitsF[0] ); + Gia_ManAppendCo( pNew, pLitsS[0] ); + } + } + else if ( Type == 1 ) // only shadow circuit + { + for ( i = 0; i < Gia_ManCoNum(pOne); i += 2 ) + { + int pLitsF[2] = { Gia_ManCo(pOne, i)->Value, Gia_ManCo(pOne, i+1)->Value }; + int pLitsS[2] = { Gia_ManCo(pTwo, i)->Value, Gia_ManCo(pTwo, i+1)->Value }; + Gia_ManAppendCo( pNew, pLitsF[1] ); + Gia_ManAppendCo( pNew, pLitsS[1] ); + } + } + else // comparator of the two + { + for ( i = 0; i < Gia_ManCoNum(pOne); i += 2 ) + { + int pLitsF[2] = { Gia_ManCo(pOne, i)->Value, Gia_ManCo(pOne, i+1)->Value }; + int pLitsS[2] = { Gia_ManCo(pTwo, i)->Value, Gia_ManCo(pTwo, i+1)->Value }; + Gia_ManAppendCo( pNew, Gia_ManDualCompare( pNew, pLitsF, pLitsS ) ); + } + } + Gia_ManHashStop( pNew ); + pNew = Gia_ManCleanup( pTemp = pNew ); + Gia_ManStop( pTemp ); + return pNew; +} + + +/**Function************************************************************* + + Synopsis [] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +void Acb_OutputFile( char * pFileName, Acb_Ntk_t * pNtkF, int * pModel ) +{ + char * pFileName0 = pFileName? pFileName : "output"; + FILE * pFile = fopen( pFileName0, "wb" ); + if ( pFile == NULL ) + { + printf( "Cannot open results file \"%s\".\n", pFileName0 ); + return; + } + if ( pModel == NULL ) + fprintf( pFile, "EQ\n" ); + else + { + /* + NEQ + in 1 + a 1 + b 0 + */ + int i, iObj; + fprintf( pFile, "NEQ\n" ); + Acb_NtkForEachPi( pNtkF, iObj, i ) + fprintf( pFile, "%s %d\n", Acb_ObjNameStr(pNtkF, iObj), pModel[i] ); + } + fclose( pFile ); + printf( "Produced output file \"%s\".\n\n", pFileName0 ); +} +int * Acb_NtkSolve( Gia_Man_t * p ) +{ + extern Abc_Ntk_t * Abc_NtkFromAigPhase( Aig_Man_t * pMan ); + Aig_Man_t * pMan = Gia_ManToAig( p, 0 ); + Abc_Ntk_t * pNtkTemp = Abc_NtkFromAigPhase( pMan ); + Prove_Params_t Params, * pParams = &Params; + Prove_ParamsSetDefault( pParams ); + pParams->fUseRewriting = 1; + pParams->fVerbose = 0; + Aig_ManStop( pMan ); + if ( pNtkTemp ) + { + abctime clk = Abc_Clock(); + int RetValue = Abc_NtkIvyProve( &pNtkTemp, pParams ); + int * pModel = pNtkTemp->pModel; + pNtkTemp->pModel = NULL; + Abc_NtkDelete( pNtkTemp ); + printf( "The networks are %s. ", RetValue == 1 ? "equivalent" : (RetValue == 0 ? "NOT equivalent" : "UNDECIDED") ); + Abc_PrintTime( 1, "Time", Abc_Clock() - clk ); + if ( RetValue == 0 ) + return pModel; + } + return NULL; +} + +/**Function************************************************************* + + Synopsis [Various statistics.] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +void Acb_NtkPrintCecStats( Acb_Ntk_t * pNtk ) +{ + int iObj, nDcs = 0, nMuxes = 0; + Acb_NtkForEachNode( pNtk, iObj ) + if ( Acb_ObjType( pNtk, iObj ) == ABC_OPER_TRI ) + nDcs++; + else if ( Acb_ObjType( pNtk, iObj ) == ABC_OPER_BIT_MUX ) + nMuxes++; + + printf( "PI = %6d ", Acb_NtkCiNum(pNtk) ); + printf( "PO = %6d ", Acb_NtkCoNum(pNtk) ); + printf( "Obj = %6d ", Acb_NtkObjNum(pNtk) ); + printf( "DC = %4d ", nDcs ); + printf( "Mux = %4d ", nMuxes ); + printf( "\n" ); +} + +/**Function************************************************************* + + Synopsis [Changing the PI order.] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +void Acb_NtkUpdateCiOrder( Acb_Ntk_t * pNtkF, Acb_Ntk_t * pNtkG ) +{ + int i, iObj; + Vec_Int_t * vMap = Vec_IntStartFull( Acb_ManNameIdMax(pNtkG->pDesign) ); + Vec_Int_t * vOrder = Vec_IntStartFull( Acb_NtkCiNum(pNtkG) ); + Acb_NtkForEachCi( pNtkG, iObj, i ) + Vec_IntWriteEntry( vMap, Acb_ObjName(pNtkG, iObj), i ); + Acb_NtkForEachCi( pNtkF, iObj, i ) + { + int NameIdG = Acb_ManStrId( pNtkG->pDesign, Acb_ObjNameStr(pNtkF, iObj) ); + int iPerm = NameIdG < Vec_IntSize(vMap) ? Vec_IntEntry( vMap, NameIdG ) : -1; + if ( iPerm == -1 ) + printf( "Cannot find name \"%s\" of PI %d of F among PIs of G.\n", Acb_ObjNameStr(pNtkF, iObj), i ); + else + Vec_IntWriteEntry( vOrder, iPerm, iObj ); + } + Vec_IntClear( &pNtkF->vCis ); + Vec_IntAppend( &pNtkF->vCis, vOrder ); + Vec_IntFree( vOrder ); + Vec_IntFree( vMap ); +} +int Acb_NtkCheckPiOrder( Acb_Ntk_t * pNtkF, Acb_Ntk_t * pNtkG ) +{ + int i, nPis = Acb_NtkCiNum(pNtkF); + for ( i = 0; i < nPis; i++ ) + { + char * pNameF = Acb_ObjNameStr( pNtkF, Acb_NtkCi(pNtkF, i) ); + char * pNameG = Acb_ObjNameStr( pNtkG, Acb_NtkCi(pNtkG, i) ); + if ( strcmp(pNameF, pNameG) ) + { +// printf( "PI %d has different names (%s and %s) in these networks.\n", i, pNameF, pNameG ); + printf( "Networks have different PI names. Reordering PIs of the implementation network.\n" ); + Acb_NtkUpdateCiOrder( pNtkF, pNtkG ); + break; + } + } + if ( i == nPis ) + printf( "Networks have the same PI names.\n" ); + return i == nPis; +} + /**Function************************************************************* Synopsis [] @@ -43,6 +609,51 @@ ABC_NAMESPACE_IMPL_START ***********************************************************************/ void Acb_NtkRunTest( char * pFileNames[4], int fFancy, int fVerbose ) { + extern Acb_Ntk_t * Acb_VerilogSimpleRead( char * pFileName, char * pFileNameW ); + extern void Gia_AigerWrite( Gia_Man_t * p, char * pFileName, int fWriteSymbols, int fCompact, int fWriteNewLine ); + + int fSolve = 1; + int * pModel = NULL; + Gia_Man_t * pGiaF = NULL; + Gia_Man_t * pGiaG = NULL; + Gia_Man_t * pGia = NULL; + Acb_Ntk_t * pNtkF = Acb_VerilogSimpleRead( pFileNames[0], NULL ); + Acb_Ntk_t * pNtkG = Acb_VerilogSimpleRead( pFileNames[1], NULL ); + if ( !pNtkF || !pNtkG ) + return; + + assert( Acb_NtkCiNum(pNtkF) == Acb_NtkCiNum(pNtkG) ); + assert( Acb_NtkCoNum(pNtkF) == Acb_NtkCoNum(pNtkG) ); + + Acb_NtkCheckPiOrder( pNtkF, pNtkG ); + //Acb_NtkCheckPiOrder( pNtkG, pNtkF ); + Acb_NtkPrintCecStats( pNtkF ); + Acb_NtkPrintCecStats( pNtkG ); + + pGiaF = Acb_NtkGiaDeriveDual( pNtkF ); + pGiaG = Acb_NtkGiaDeriveDual( pNtkG ); + pGia = Acb_NtkGiaDeriveMiter( pGiaF, pGiaG, 0 ); + //Gia_AigerWrite( pGiaF, Extra_FileNameGenericAppend(pFileNames[1], "_f2.aig"), 0, 0, 0 ); + //Gia_AigerWrite( pGiaG, Extra_FileNameGenericAppend(pFileNames[1], "_g2.aig"), 0, 0, 0 ); + //Gia_AigerWrite( pGia, Extra_FileNameGenericAppend(pFileNames[1], "_miter_0.aig"), 0, 0, 0 ); + //printf( "Written the miter info file \"%s\".\n", Extra_FileNameGenericAppend(pFileNames[1], "_miter_0.aig") ); + + //Gia_ManPrintStats( pGia, NULL ); + //Gia_ManSimTry( pGiaF, pGiaG ); + + if ( fSolve ) + { + pModel = Acb_NtkSolve( pGia ); + Acb_OutputFile( pFileNames[2], pNtkF, pModel ); + ABC_FREE( pModel ); + } + + Gia_ManStop( pGia ); + Gia_ManStop( pGiaF ); + Gia_ManStop( pGiaG ); + + Acb_ManFree( pNtkF->pDesign ); + Acb_ManFree( pNtkG->pDesign ); } -- cgit v1.2.3 From 8ef44045420766b66aed22e1d4ed9ce3cd16906a Mon Sep 17 00:00:00 2001 From: Alan Mishchenko Date: Sun, 6 Sep 2020 22:34:45 -0700 Subject: Verifying new resub code. --- src/base/abci/abc.c | 1 + 1 file changed, 1 insertion(+) (limited to 'src/base') diff --git a/src/base/abci/abc.c b/src/base/abci/abc.c index 2f924747..ff288dc3 100644 --- a/src/base/abci/abc.c +++ b/src/base/abci/abc.c @@ -48059,6 +48059,7 @@ usage: ***********************************************************************/ int Abc_CommandAbc9Test( Abc_Frame_t * pAbc, int argc, char ** argv ) { + extern void Gia_RsbEnumerateWindows( Gia_Man_t * p, int nInputsMax, int nLevelsMax ); int c, fVerbose = 0; int nFrames = 5; int fSwitch = 0; -- cgit v1.2.3 From fe968e9d794af292ad5ecbfb7d91a8dbfde20b4f Mon Sep 17 00:00:00 2001 From: Alan Mishchenko Date: Sun, 6 Sep 2020 22:53:24 -0700 Subject: Fixing a typo in setting the miter type. --- src/base/acb/acbTest.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/base') diff --git a/src/base/acb/acbTest.c b/src/base/acb/acbTest.c index 340e3551..1faea72a 100644 --- a/src/base/acb/acbTest.c +++ b/src/base/acb/acbTest.c @@ -632,7 +632,7 @@ void Acb_NtkRunTest( char * pFileNames[4], int fFancy, int fVerbose ) pGiaF = Acb_NtkGiaDeriveDual( pNtkF ); pGiaG = Acb_NtkGiaDeriveDual( pNtkG ); - pGia = Acb_NtkGiaDeriveMiter( pGiaF, pGiaG, 0 ); + pGia = Acb_NtkGiaDeriveMiter( pGiaF, pGiaG, 2 ); //Gia_AigerWrite( pGiaF, Extra_FileNameGenericAppend(pFileNames[1], "_f2.aig"), 0, 0, 0 ); //Gia_AigerWrite( pGiaG, Extra_FileNameGenericAppend(pFileNames[1], "_g2.aig"), 0, 0, 0 ); //Gia_AigerWrite( pGia, Extra_FileNameGenericAppend(pFileNames[1], "_miter_0.aig"), 0, 0, 0 ); -- cgit v1.2.3 From d556ad65ff4b1ef172ec041a0b4c85f4e1ae909e Mon Sep 17 00:00:00 2001 From: Alan Mishchenko Date: Sun, 6 Sep 2020 23:15:21 -0700 Subject: Adding switch &cec -w to print SAT solver stats. --- src/base/abci/abc.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'src/base') diff --git a/src/base/abci/abc.c b/src/base/abci/abc.c index ff288dc3..52bd1050 100644 --- a/src/base/abci/abc.c +++ b/src/base/abci/abc.c @@ -36972,7 +36972,7 @@ int Abc_CommandAbc9Cec( Abc_Frame_t * pAbc, int argc, char ** argv ) int c, nArgcNew, fMiter = 0, fDualOutput = 0, fDumpMiter = 0; Cec_ManCecSetDefaultParams( pPars ); Extra_UtilGetoptReset(); - while ( ( c = Extra_UtilGetopt( argc, argv, "CTnmdasvh" ) ) != EOF ) + while ( ( c = Extra_UtilGetopt( argc, argv, "CTnmdasvwh" ) ) != EOF ) { switch ( c ) { @@ -37016,6 +37016,9 @@ int Abc_CommandAbc9Cec( Abc_Frame_t * pAbc, int argc, char ** argv ) case 'v': pPars->fVerbose ^= 1; break; + case 'w': + pPars->fVeryVerbose ^= 1; + break; case 'h': goto usage; default: @@ -37171,7 +37174,7 @@ int Abc_CommandAbc9Cec( Abc_Frame_t * pAbc, int argc, char ** argv ) return 0; usage: - Abc_Print( -2, "usage: &cec [-CT num] [-nmdasvh]\n" ); + Abc_Print( -2, "usage: &cec [-CT num] [-nmdasvwh]\n" ); Abc_Print( -2, "\t new combinational equivalence checker\n" ); Abc_Print( -2, "\t-C num : the max number of conflicts at a node [default = %d]\n", pPars->nBTLimit ); Abc_Print( -2, "\t-T num : approximate runtime limit in seconds [default = %d]\n", pPars->TimeLimit ); @@ -37181,6 +37184,7 @@ usage: Abc_Print( -2, "\t-a : toggle writing dual-output miter [default = %s]\n", fDumpMiter? "yes":"no"); Abc_Print( -2, "\t-s : toggle silent operation [default = %s]\n", pPars->fSilent ? "yes":"no"); Abc_Print( -2, "\t-v : toggle verbose output [default = %s]\n", pPars->fVerbose? "yes":"no"); + Abc_Print( -2, "\t-w : toggle printing SAT solver statistics [default = %s]\n", pPars->fVeryVerbose? "yes":"no"); Abc_Print( -2, "\t-h : print the command usage\n"); return 1; } -- cgit v1.2.3 From 07bf95f48019dd5472ffffbd32587879e1bcbb9f Mon Sep 17 00:00:00 2001 From: Alan Mishchenko Date: Sun, 13 Sep 2020 19:17:16 -0700 Subject: Experiments with iterative synthesis. --- src/base/abc/abcUtil.c | 3 ++- src/base/abci/abc.c | 68 ++++++++++++++++++++++++++++++++++++++------------ src/base/acb/acbFunc.c | 33 ++++++++++++++++-------- src/base/acb/acbUtil.c | 53 +++++++++++++++++++++++++++++++-------- 4 files changed, 120 insertions(+), 37 deletions(-) (limited to 'src/base') diff --git a/src/base/abc/abcUtil.c b/src/base/abc/abcUtil.c index 1f0c9725..922b34ae 100644 --- a/src/base/abc/abcUtil.c +++ b/src/base/abc/abcUtil.c @@ -3122,7 +3122,8 @@ Vec_Wec_t * Abc_SopSynthesize( Vec_Ptr_t * vSops ) Abc_Obj_t * pObj, * pFanin; int i, k, iNode = 0; Abc_FrameReplaceCurrentNetwork( Abc_FrameReadGlobalFrame(), pNtk ); - Cmd_CommandExecute( Abc_FrameGetGlobalFrame(), "fx; strash; balance; dc2; map -a" ); + //Cmd_CommandExecute( Abc_FrameGetGlobalFrame(), "fx; strash; balance; dc2; map -a" ); + Cmd_CommandExecute( Abc_FrameGetGlobalFrame(), "st; collapse; sop; fx; strash; &get; &ps; &deepsyn -I 4 -J 50 -T 5 -S 111 -t; &ps; &put; map -a" ); pNtkNew = Abc_FrameReadNtk( Abc_FrameReadGlobalFrame() ); vRes = Vec_WecStart( Abc_NtkPiNum(pNtkNew) + Abc_NtkNodeNum(pNtkNew) + Abc_NtkPoNum(pNtkNew) ); Abc_NtkForEachPi( pNtkNew, pObj, i ) diff --git a/src/base/abci/abc.c b/src/base/abci/abc.c index 52bd1050..7b4db87a 100644 --- a/src/base/abci/abc.c +++ b/src/base/abci/abc.c @@ -7063,11 +7063,11 @@ usage: ***********************************************************************/ int Abc_CommandRunEco( Abc_Frame_t * pAbc, int argc, char ** argv ) { - extern void Acb_NtkRunEco( char * pFileNames[4], int fCheck, int fRandom, int fVerbose, int fVeryVerbose ); + extern void Acb_NtkRunEco( char * pFileNames[4], int fCheck, int fRandom, int fInputs, int fVerbose, int fVeryVerbose ); char * pFileNames[4] = {NULL}; - int c, fCheck = 0, fRandom = 0, fVerbose = 0, fVeryVerbose = 0; + int c, fCheck = 0, fRandom = 0, fInputs = 0, fVerbose = 0, fVeryVerbose = 0; Extra_UtilGetoptReset(); - while ( ( c = Extra_UtilGetopt( argc, argv, "crvwh" ) ) != EOF ) + while ( ( c = Extra_UtilGetopt( argc, argv, "crivwh" ) ) != EOF ) { switch ( c ) { @@ -7077,6 +7077,9 @@ int Abc_CommandRunEco( Abc_Frame_t * pAbc, int argc, char ** argv ) case 'r': fRandom ^= 1; break; + case 'i': + fInputs ^= 1; + break; case 'v': fVerbose ^= 1; break; @@ -7108,11 +7111,11 @@ int Abc_CommandRunEco( Abc_Frame_t * pAbc, int argc, char ** argv ) fclose( pFile ); pFileNames[c] = argv[globalUtilOptind+c]; } - Acb_NtkRunEco( pFileNames, fCheck, fRandom, fVerbose, fVeryVerbose ); + Acb_NtkRunEco( pFileNames, fCheck, fRandom, fInputs, fVerbose, fVeryVerbose ); return 0; usage: - Abc_Print( -2, "usage: runeco [-crvwh] \n" ); + Abc_Print( -2, "usage: runeco [-crivwh] \n" ); Abc_Print( -2, "\t performs computation of patch functions during ECO,\n" ); Abc_Print( -2, "\t as described in the following paper: A. Q. Dao et al\n" ); Abc_Print( -2, "\t \"Efficient computation of ECO patch functions\", Proc. DAC\'18\n" ); @@ -7122,6 +7125,7 @@ usage: Abc_Print( -2, "\t \"runeco unit1/F.v unit1/G.v unit1/weight.txt; cec -n out.v unit1/G.v\")\n" ); Abc_Print( -2, "\t-c : toggle checking that the problem has a solution [default = %s]\n", fCheck? "yes": "no" ); Abc_Print( -2, "\t-r : toggle using random permutation of support variables [default = %s]\n", fRandom? "yes": "no" ); + Abc_Print( -2, "\t-i : toggle using primary inputs as support variables [default = %s]\n", fInputs? "yes": "no" ); Abc_Print( -2, "\t-v : toggle printing verbose information [default = %s]\n", fVerbose? "yes": "no" ); Abc_Print( -2, "\t-w : toggle printing more verbose information [default = %s]\n", fVeryVerbose? "yes": "no" ); Abc_Print( -2, "\t-h : print the command usage\n"); @@ -7190,11 +7194,11 @@ usage: ***********************************************************************/ int Abc_CommandRunSim( Abc_Frame_t * pAbc, int argc, char ** argv ) { - extern void Acb_NtkRunSim( char * pFileName[4], int nWords, int nBeam, int LevL, int LevU, int fOrder, int fFancy, int fUseBuf, int fRandom, int fUseWeights, int fVerbose, int fVeryVerbose ); + extern void Acb_NtkRunSim( char * pFileName[4], int nWords, int nBeam, int LevL, int LevU, int fOrder, int fFancy, int fUseBuf, int fRandom, int fUseWeights, int fInputs, int fVerbose, int fVeryVerbose ); char * pFileNames[4] = {NULL, NULL, "out.v", NULL}; - int c, nWords = 8, nBeam = 4, LevL = -1, LevU = -1, fOrder = 0, fFancy = 0, fUseBuf = 0, fRandom = 0, fUseWeights = 0, fVerbose = 0, fVeryVerbose = 0; + int c, nWords = 8, nBeam = 4, LevL = -1, LevU = -1, fOrder = 0, fFancy = 0, fUseBuf = 0, fRandom = 0, fUseWeights = 0, fInputs = 0, fVerbose = 0, fVeryVerbose = 0; Extra_UtilGetoptReset(); - while ( ( c = Extra_UtilGetopt( argc, argv, "WBLUofbruvwh" ) ) != EOF ) + while ( ( c = Extra_UtilGetopt( argc, argv, "WBLUofbruivwh" ) ) != EOF ) { switch ( c ) { @@ -7257,6 +7261,9 @@ int Abc_CommandRunSim( Abc_Frame_t * pAbc, int argc, char ** argv ) case 'u': fUseWeights ^= 1; break; + case 'i': + fInputs ^= 1; + break; case 'v': fVerbose ^= 1; break; @@ -7288,11 +7295,11 @@ int Abc_CommandRunSim( Abc_Frame_t * pAbc, int argc, char ** argv ) else fclose( pFile ); } - Acb_NtkRunSim( pFileNames, nWords, nBeam, LevL, LevU, fOrder, fFancy, fUseBuf, fRandom, fUseWeights, fVerbose, fVeryVerbose ); + Acb_NtkRunSim( pFileNames, nWords, nBeam, LevL, LevU, fOrder, fFancy, fUseBuf, fRandom, fUseWeights, fInputs, fVerbose, fVeryVerbose ); return 0; usage: - Abc_Print( -2, "usage: runsim [-WBLU] [-ofbruvwh] [-N ] \n" ); + Abc_Print( -2, "usage: runsim [-WBLU] [-ofbruivwh] [-N ] \n" ); Abc_Print( -2, "\t experimental simulation command\n" ); Abc_Print( -2, "\t-W : the number of words of simulation info [default = %d]\n", nWords ); Abc_Print( -2, "\t-B : the beam width parameter [default = %d]\n", nBeam ); @@ -7303,6 +7310,7 @@ usage: Abc_Print( -2, "\t-b : toggle using buffers [default = %s]\n", fUseBuf? "yes": "no" ); Abc_Print( -2, "\t-r : toggle using random permutation of support variables [default = %s]\n", fRandom? "yes": "no" ); Abc_Print( -2, "\t-u : toggle using topological info to select support variables [default = %s]\n", fUseWeights? "yes": "no" ); + Abc_Print( -2, "\t-i : toggle using primary inputs as support variables [default = %s]\n", fInputs? "yes": "no" ); Abc_Print( -2, "\t-v : toggle printing verbose information [default = %s]\n", fVerbose? "yes": "no" ); Abc_Print( -2, "\t-w : toggle printing more verbose information [default = %s]\n", fVeryVerbose? "yes": "no" ); Abc_Print( -2, "\t-h : print the command usage\n"); @@ -46327,13 +46335,35 @@ usage: ***********************************************************************/ int Abc_CommandAbc9DeepSyn( Abc_Frame_t * pAbc, int argc, char ** argv ) { - extern Gia_Man_t * Gia_ManDeepSyn( Gia_Man_t * pGia, int TimeOut, int nAnds, int Seed, int fVerbose ); - Gia_Man_t * pTemp; int c, TimeOut = 0, nAnds = 0, Seed = 0, fVerbose = 0; + extern Gia_Man_t * Gia_ManDeepSyn( Gia_Man_t * pGia, int nIters, int nNoImpr, int TimeOut, int nAnds, int Seed, int fUseTwo, int fVerbose ); + Gia_Man_t * pTemp; int c, nIters = 1, nNoImpr = ABC_INFINITY, TimeOut = 0, nAnds = 0, Seed = 0, fUseTwo = 0, fVerbose = 0; Extra_UtilGetoptReset(); - while ( ( c = Extra_UtilGetopt( argc, argv, "TASvh" ) ) != EOF ) + while ( ( c = Extra_UtilGetopt( argc, argv, "IJTAStvh" ) ) != 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++; + if ( nIters < 0 ) + goto usage; + break; + case 'J': + if ( globalUtilOptind >= argc ) + { + Abc_Print( -1, "Command line switch \"-J\" should be followed by an integer.\n" ); + goto usage; + } + nNoImpr = atoi(argv[globalUtilOptind]); + globalUtilOptind++; + if ( nNoImpr < 0 ) + goto usage; + break; case 'T': if ( globalUtilOptind >= argc ) { @@ -46367,6 +46397,9 @@ int Abc_CommandAbc9DeepSyn( Abc_Frame_t * pAbc, int argc, char ** argv ) if ( Seed < 0 ) goto usage; break; + case 't': + fUseTwo ^= 1; + break; case 'v': fVerbose ^= 1; break; @@ -46381,16 +46414,19 @@ int Abc_CommandAbc9DeepSyn( Abc_Frame_t * pAbc, int argc, char ** argv ) Abc_Print( -1, "Abc_CommandAbc9DeepSyn(): There is no AIG.\n" ); return 0; } - pTemp = Gia_ManDeepSyn( pAbc->pGia, TimeOut, nAnds, Seed, fVerbose ); + pTemp = Gia_ManDeepSyn( pAbc->pGia, nIters, nNoImpr, TimeOut, nAnds, Seed, fUseTwo, fVerbose ); Abc_FrameUpdateGia( pAbc, pTemp ); return 0; usage: - Abc_Print( -2, "usage: &deepsyn [-TAS ] [-vh]\n" ); + Abc_Print( -2, "usage: &deepsyn [-IJTAS ] [-tvh]\n" ); Abc_Print( -2, "\t performs synthesis\n" ); + Abc_Print( -2, "\t-I : the number of iterations [default = %d]\n", nIters ); + Abc_Print( -2, "\t-J : the number of steps without improvements [default = %d]\n", nNoImpr ); Abc_Print( -2, "\t-T : the timeout in seconds (0 = no timeout) [default = %d]\n", TimeOut ); Abc_Print( -2, "\t-A : the number of nodes to stop (0 = no limit) [default = %d]\n", nAnds ); - Abc_Print( -2, "\t-S : user-specified random seed (0 <= num <= 100) [default = %d]\n", Seed ); + Abc_Print( -2, "\t-S : user-specified random seed (0 <= num <= 100) [default = %d]\n", Seed ); + Abc_Print( -2, "\t-t : toggle using two-input LUTs [default = %s]\n", fUseTwo? "yes": "no" ); Abc_Print( -2, "\t-v : toggle printing optimization summary [default = %s]\n", fVerbose? "yes": "no" ); Abc_Print( -2, "\t-h : print the command usage\n"); return 1; diff --git a/src/base/acb/acbFunc.c b/src/base/acb/acbFunc.c index eced70e7..6d5bdaad 100644 --- a/src/base/acb/acbFunc.c +++ b/src/base/acb/acbFunc.c @@ -145,15 +145,28 @@ char * pLibStr[25] = { "GATE zero 0 O=CONST0;\n" "GATE one 0 O=CONST1;\n" }; -void Acb_IntallLibrary() +char * pLibStr2[25] = { + "GATE buf 1 O=a; PIN * INV 1 999 1.0 0.0 1.0 0.0\n" + "GATE inv 1 O=!a; PIN * INV 1 999 1.0 0.0 1.0 0.0\n" + "GATE and2 1 O=a*b; PIN * INV 1 999 1.0 0.0 1.0 0.0\n" + "GATE or2 1 O=a+b; PIN * INV 1 999 1.0 0.0 1.0 0.0\n" + "GATE nand2 1 O=!(a*b); PIN * INV 1 999 1.0 0.0 1.0 0.0\n" + "GATE nor2 1 O=!(a+b); PIN * INV 1 999 1.0 0.0 1.0 0.0\n" + "GATE xor 1 O=!a*b+a*!b; PIN * INV 1 999 1.0 0.0 1.0 0.0\n" + "GATE xnor 1 O=a*b+!a*!b; PIN * INV 1 999 1.0 0.0 1.0 0.0\n" + "GATE zero 0 O=CONST0;\n" + "GATE one 0 O=CONST1;\n" +}; +void Acb_IntallLibrary( int f2Ins ) { extern Mio_Library_t * Mio_LibraryReadBuffer( char * pBuffer, int fExtendedFormat, st__table * tExcludeGate, int fVerbose ); Mio_Library_t * pLib; int i; // create library string Vec_Str_t * vLibStr = Vec_StrAlloc( 1000 ); - for ( i = 0; pLibStr[i]; i++ ) - Vec_StrAppend( vLibStr, pLibStr[i] ); + char ** ppLibStr = f2Ins ? pLibStr2 : pLibStr; + for ( i = 0; ppLibStr[i]; i++ ) + Vec_StrAppend( vLibStr, ppLibStr[i] ); Vec_StrPush( vLibStr, '\0' ); // create library pLib = Mio_LibraryReadBuffer( Vec_StrArray(vLibStr), 0, NULL, 0 ); @@ -2600,7 +2613,7 @@ Vec_Ptr_t * Acb_TransformPatchFunctions( Vec_Ptr_t * vSops, Vec_Wec_t * vSupps, SeeAlso [] ***********************************************************************/ -int Acb_NtkEcoPerform( Acb_Ntk_t * pNtkF, Acb_Ntk_t * pNtkG, char * pFileName[4], int fCisOnly, int fCheck, int fVerbose, int fVeryVerbose ) +int Acb_NtkEcoPerform( Acb_Ntk_t * pNtkF, Acb_Ntk_t * pNtkG, char * pFileName[4], int fCisOnly, int fInputs, int fCheck, int fVerbose, int fVeryVerbose ) { extern Gia_Man_t * Abc_SopSynthesizeOne( char * pSop, int fClp ); @@ -2615,7 +2628,7 @@ int Acb_NtkEcoPerform( Acb_Ntk_t * pNtkF, Acb_Ntk_t * pNtkG, char * pFileName[4] Vec_Int_t * vSuppF = Acb_NtkFindSupp( pNtkF, vRoots ); Vec_Int_t * vSuppG = Acb_NtkFindSupp( pNtkG, vRoots ); Vec_Int_t * vSupp = Vec_IntTwoMerge( vSuppF, vSuppG ); - Vec_Int_t * vDivs = fCisOnly ? Acb_NtkFindDivsCis( pNtkF, vSupp ) : Acb_NtkFindDivs( pNtkF, vSupp, vBlock, fVerbose ); + Vec_Int_t * vDivs = (fCisOnly || fInputs) ? Acb_NtkFindDivsCis( pNtkF, vSupp ) : Acb_NtkFindDivs( pNtkF, vSupp, vBlock, fVerbose ); Vec_Int_t * vNodesF = Acb_NtkFindNodes( pNtkF, vRoots, vDivs ); Vec_Int_t * vNodesG = Acb_NtkFindNodes( pNtkG, vRoots, NULL ); @@ -2829,7 +2842,7 @@ void Acb_NtkTestRun2( char * pFileNames[3], int fVerbose ) Acb_Ntk_t * pNtk = Acb_VerilogSimpleRead( pFileNames[0], pFileNames[2] ); Acb_VerilogSimpleWrite( pNtk, pFileNameOut ); Acb_ManFree( pNtk->pDesign ); - Acb_IntallLibrary(); + Acb_IntallLibrary( 0 ); } /**Function************************************************************* @@ -2843,7 +2856,7 @@ void Acb_NtkTestRun2( char * pFileNames[3], int fVerbose ) SeeAlso [] ***********************************************************************/ -void Acb_NtkRunEco( char * pFileNames[4], int fCheck, int fRandom, int fVerbose, int fVeryVerbose ) +void Acb_NtkRunEco( char * pFileNames[4], int fCheck, int fRandom, int fInputs, int fVerbose, int fVeryVerbose ) { char Command[1000]; int Result = 1; Acb_Ntk_t * pNtkF = Acb_VerilogSimpleRead( pFileNames[0], pFileNames[2] ); @@ -2863,12 +2876,12 @@ void Acb_NtkRunEco( char * pFileNames[4], int fCheck, int fRandom, int fVerbose, assert( Acb_NtkCiNum(pNtkF) == Acb_NtkCiNum(pNtkG) ); assert( Acb_NtkCoNum(pNtkF) == Acb_NtkCoNum(pNtkG) ); - Acb_IntallLibrary(); + Acb_IntallLibrary( Abc_FrameReadSignalNames() != NULL ); - if ( !Acb_NtkEcoPerform( pNtkF, pNtkG, pFileNames, 0, fCheck, fVerbose, fVeryVerbose ) ) + if ( !Acb_NtkEcoPerform( pNtkF, pNtkG, pFileNames, 0, fInputs, fCheck, fVerbose, fVeryVerbose ) ) { // printf( "General computation timed out. Trying inputs only.\n\n" ); -// if ( !Acb_NtkEcoPerform( pNtkF, pNtkG, pFileNames, 1, fCheck, fVerbose, fVeryVerbose ) ) +// if ( !Acb_NtkEcoPerform( pNtkF, pNtkG, pFileNames, 1, fInputs, fCheck, fVerbose, fVeryVerbose ) ) // printf( "Input-only computation also timed out.\n\n" ); printf( "Computation did not succeed.\n" ); Result = 0; diff --git a/src/base/acb/acbUtil.c b/src/base/acb/acbUtil.c index d707d136..dab8239d 100644 --- a/src/base/acb/acbUtil.c +++ b/src/base/acb/acbUtil.c @@ -167,17 +167,35 @@ int Acb_NtkCountPoDrivers( Acb_Ntk_t * p, Vec_Int_t * vObjs ) SeeAlso [] ***********************************************************************/ -int Acb_NtkNodeDeref_rec( Vec_Int_t * vRefs, Acb_Ntk_t * p, int iObj ) +int Acb_NtkNodeDeref_rec( Vec_Int_t * vRefs, Acb_Ntk_t * p, int iObj, int nGates[5] ) { int i, Fanin, * pFanins, Counter = 1; if ( Acb_ObjIsCi(p, iObj) ) return 0; + if ( nGates ) + { + int nFan = Acb_ObjFaninNum(p, iObj); + int Type = Acb_ObjType( p, iObj ); + if ( Type == ABC_OPER_CONST_F ) + nGates[0]++; + else if ( Type == ABC_OPER_CONST_T ) + nGates[1]++; + else if ( Type == ABC_OPER_BIT_BUF || Type == ABC_OPER_CO ) + nGates[2]++; + else if ( Type == ABC_OPER_BIT_INV ) + nGates[3]++; + else + { + assert( nFan >= 2 ); + nGates[4] += Acb_ObjFaninNum(p, iObj)-1; + } + } Acb_ObjForEachFaninFast( p, iObj, pFanins, Fanin, i ) { assert( Vec_IntEntry(vRefs, Fanin) > 0 ); Vec_IntAddToEntry( vRefs, Fanin, -1 ); if ( Vec_IntEntry(vRefs, Fanin) == 0 ) - Counter += Acb_NtkNodeDeref_rec( vRefs, p, Fanin ); + Counter += Acb_NtkNodeDeref_rec( vRefs, p, Fanin, nGates ); } return Counter; } @@ -220,10 +238,10 @@ int Acb_NtkFindMffcSize( Acb_Ntk_t * p, Vec_Int_t * vObjsRefed, Vec_Int_t * vObj Acb_ObjForEachFaninFast( p, iObj, pFanins, Fanin, i ) Vec_IntAddToEntry( vRefs, Fanin, 1 ); Vec_IntForEachEntry( vObjsRefed, iObj, i ) - Acb_NtkNodeRef_rec( vRefs, p, iObj, NULL ); + Vec_IntAddToEntry( vRefs, iObj, 1 ); Vec_IntForEachEntry( vObjsDerefed, iObj, i ) - if ( Vec_IntEntry(vRefs, iObj) == 0 ) - Count2 += Acb_NtkNodeRef_rec( vRefs, p, iObj, nGates ); + //if ( Vec_IntEntry(vRefs, iObj) != 0 || Acb_ObjIsCo(p, iObj) ) + Count2 += Acb_NtkNodeDeref_rec( vRefs, p, iObj, nGates ); Vec_IntFree( vRefs ); return Count2; } @@ -1133,7 +1151,7 @@ void Acb_Ntk4CollectRing( Acb_Ntk_t * pNtk, Vec_Int_t * vStart, Vec_Int_t * vRes } void Acb_Ntk4DumpWeightsInt( Acb_Ntk_t * pNtk, Vec_Int_t * vObjs, char * pFileName ) { - int i, iObj;//, Weight; + int i, iObj, Count = 0;//, Weight; Vec_Int_t * vDists, * vStart, * vNexts; FILE * pFile = fopen( pFileName, "wb" ); if ( pFile == NULL ) @@ -1165,15 +1183,30 @@ void Acb_Ntk4DumpWeightsInt( Acb_Ntk_t * pNtk, Vec_Int_t * vObjs, char * pFileNa // Vec_IntForEachEntry( vDists, Weight, i ) // if ( Weight && Acb_ObjNameStr(pNtk, i)[0] != '1' ) // fprintf( pFile, "%s %d\n", Acb_ObjNameStr(pNtk, i), 10000+Weight ); +/* + // mark reachable + Vec_IntClear( &pNtk->vArray0 ); + Acb_NtkIncTravId( pNtk ); + Acb_NtkForEachCo( pNtk, iObj, i ) + if ( !Vec_IntEntry(vStatus, i) ) + Acb_ObjCollectTfi_rec( pNtk, iObj, 0 ); +*/ Acb_NtkForEachObj( pNtk, iObj ) { char * pName = Acb_ObjNameStr(pNtk, iObj); int Weight = Vec_IntEntry(vDists, iObj); if ( Weight == 0 ) Weight = 10000; +/* + if ( !Acb_ObjSetTravIdCur(pNtk, iObj) ) + { + Count++; + continue; + } +*/ fprintf( pFile, "%s %d\n", pName, 100000+Weight ); } - + //printf( "Skipped %d nodes.\n", Count ); Vec_IntFree( vDists ); fclose( pFile ); } @@ -1205,13 +1238,13 @@ void Acb_Ntk4DumpWeights( char * pFileNameIn, Vec_Ptr_t * vObjNames, char * pFil SeeAlso [] ***********************************************************************/ -void Acb_NtkRunSim( char * pFileName[4], int nWords, int nBeam, int LevL, int LevU, int fOrder, int fFancy, int fUseBuf, int fRandom, int fUseWeights, int fVerbose, int fVeryVerbose ) +void Acb_NtkRunSim( char * pFileName[4], int nWords, int nBeam, int LevL, int LevU, int fOrder, int fFancy, int fUseBuf, int fRandom, int fUseWeights, int fInputs, int fVerbose, int fVeryVerbose ) { extern int Gia_Sim4Try( char * pFileName0, char * pFileName1, char * pFileName2, int nWords, int nBeam, int LevL, int LevU, int fOrder, int fFancy, int fUseBuf, int fVerbose ); - extern void Acb_NtkRunEco( char * pFileNames[4], int fCheck, int fRandom, int fVerbose, int fVeryVerbose ); + extern void Acb_NtkRunEco( char * pFileNames[4], int fCheck, int fRandom, int fInputs, int fVerbose, int fVeryVerbose ); char * pFileNames[4] = { pFileName[2], pFileName[1], fUseWeights ? (char *)"weights.txt" : NULL, pFileName[2] }; if ( Gia_Sim4Try( pFileName[0], pFileName[1], pFileName[2], nWords, nBeam, LevL, LevU, fOrder, fFancy, fUseBuf, fVerbose ) ) - Acb_NtkRunEco( pFileNames, 1, fRandom, fVerbose, fVeryVerbose ); + Acb_NtkRunEco( pFileNames, 1, fRandom, fInputs, fVerbose, fVeryVerbose ); } -- cgit v1.2.3 From bab462d5cddf4c7d607cf5396f4cbb0498978a5c Mon Sep 17 00:00:00 2001 From: Alan Mishchenko Date: Sun, 13 Sep 2020 20:33:59 -0700 Subject: Compiler warnings. --- src/base/acb/acbUtil.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/base') diff --git a/src/base/acb/acbUtil.c b/src/base/acb/acbUtil.c index dab8239d..070754af 100644 --- a/src/base/acb/acbUtil.c +++ b/src/base/acb/acbUtil.c @@ -1151,7 +1151,7 @@ void Acb_Ntk4CollectRing( Acb_Ntk_t * pNtk, Vec_Int_t * vStart, Vec_Int_t * vRes } void Acb_Ntk4DumpWeightsInt( Acb_Ntk_t * pNtk, Vec_Int_t * vObjs, char * pFileName ) { - int i, iObj, Count = 0;//, Weight; + int i, iObj;//, Count = 0;//, Weight; Vec_Int_t * vDists, * vStart, * vNexts; FILE * pFile = fopen( pFileName, "wb" ); if ( pFile == NULL ) -- cgit v1.2.3 From 083c1218e5a1742e881d0ce9e90c8cd0b53748a7 Mon Sep 17 00:00:00 2001 From: Alan Mishchenko Date: Thu, 17 Sep 2020 13:04:09 -0700 Subject: Improving MFFC computation code. --- src/base/abci/abc.c | 14 ++- src/base/acb/acbFunc.c | 66 ++++-------- src/base/acb/acbUtil.c | 264 ++++++++++++++++++++++++++-------------------- src/base/main/main.h | 3 +- src/base/main/mainFrame.c | 4 +- src/base/main/mainInt.h | 2 +- 6 files changed, 181 insertions(+), 172 deletions(-) (limited to 'src/base') diff --git a/src/base/abci/abc.c b/src/base/abci/abc.c index 7b4db87a..76f60a36 100644 --- a/src/base/abci/abc.c +++ b/src/base/abci/abc.c @@ -7194,11 +7194,11 @@ usage: ***********************************************************************/ int Abc_CommandRunSim( Abc_Frame_t * pAbc, int argc, char ** argv ) { - extern void Acb_NtkRunSim( char * pFileName[4], int nWords, int nBeam, int LevL, int LevU, int fOrder, int fFancy, int fUseBuf, int fRandom, int fUseWeights, int fInputs, int fVerbose, int fVeryVerbose ); + extern void Acb_NtkRunSim( char * pFileName[4], int nWords, int nBeam, int LevL, int LevU, int fOrder, int fFancy, int fUseBuf, int fRandom, int fUseWeights, int fInputs, int fSkipMffc, int fVerbose, int fVeryVerbose ); char * pFileNames[4] = {NULL, NULL, "out.v", NULL}; - int c, nWords = 8, nBeam = 4, LevL = -1, LevU = -1, fOrder = 0, fFancy = 0, fUseBuf = 0, fRandom = 0, fUseWeights = 0, fInputs = 0, fVerbose = 0, fVeryVerbose = 0; + int c, nWords = 8, nBeam = 4, LevL = -1, LevU = -1, fOrder = 0, fFancy = 0, fUseBuf = 0, fRandom = 0, fUseWeights = 0, fInputs = 0, fSkipMffc = 0, fVerbose = 0, fVeryVerbose = 0; Extra_UtilGetoptReset(); - while ( ( c = Extra_UtilGetopt( argc, argv, "WBLUofbruivwh" ) ) != EOF ) + while ( ( c = Extra_UtilGetopt( argc, argv, "WBLUofbruimvwh" ) ) != EOF ) { switch ( c ) { @@ -7264,6 +7264,9 @@ int Abc_CommandRunSim( Abc_Frame_t * pAbc, int argc, char ** argv ) case 'i': fInputs ^= 1; break; + case 'm': + fSkipMffc ^= 1; + break; case 'v': fVerbose ^= 1; break; @@ -7295,11 +7298,11 @@ int Abc_CommandRunSim( Abc_Frame_t * pAbc, int argc, char ** argv ) else fclose( pFile ); } - Acb_NtkRunSim( pFileNames, nWords, nBeam, LevL, LevU, fOrder, fFancy, fUseBuf, fRandom, fUseWeights, fInputs, fVerbose, fVeryVerbose ); + Acb_NtkRunSim( pFileNames, nWords, nBeam, LevL, LevU, fOrder, fFancy, fUseBuf, fRandom, fUseWeights, fInputs, fSkipMffc, fVerbose, fVeryVerbose ); return 0; usage: - Abc_Print( -2, "usage: runsim [-WBLU] [-ofbruivwh] [-N ] \n" ); + Abc_Print( -2, "usage: runsim [-WBLU] [-ofbruimvwh] [-N ] \n" ); Abc_Print( -2, "\t experimental simulation command\n" ); Abc_Print( -2, "\t-W : the number of words of simulation info [default = %d]\n", nWords ); Abc_Print( -2, "\t-B : the beam width parameter [default = %d]\n", nBeam ); @@ -7311,6 +7314,7 @@ usage: Abc_Print( -2, "\t-r : toggle using random permutation of support variables [default = %s]\n", fRandom? "yes": "no" ); Abc_Print( -2, "\t-u : toggle using topological info to select support variables [default = %s]\n", fUseWeights? "yes": "no" ); Abc_Print( -2, "\t-i : toggle using primary inputs as support variables [default = %s]\n", fInputs? "yes": "no" ); + Abc_Print( -2, "\t-m : toggle MFFC nodes as candidate divisors [default = %s]\n", fSkipMffc? "yes": "no" ); Abc_Print( -2, "\t-v : toggle printing verbose information [default = %s]\n", fVerbose? "yes": "no" ); Abc_Print( -2, "\t-w : toggle printing more verbose information [default = %s]\n", fVeryVerbose? "yes": "no" ); Abc_Print( -2, "\t-h : print the command usage\n"); diff --git a/src/base/acb/acbFunc.c b/src/base/acb/acbFunc.c index 6d5bdaad..cc9c425b 100644 --- a/src/base/acb/acbFunc.c +++ b/src/base/acb/acbFunc.c @@ -1942,44 +1942,17 @@ Vec_Int_t * Acb_GetUsedDivs( Vec_Int_t * vDivs, Vec_Int_t * vUsed ) Vec_IntPush( vRes, iObj ); return vRes; } -Vec_Int_t * Acb_GetDerefedNodes( Acb_Ntk_t * p ) -{ - Vec_Ptr_t * vNames = Abc_FrameReadSignalNames(); - if ( vNames != NULL ) - { - Vec_Int_t * vNodes = Vec_IntAlloc( 100 ); - Vec_Int_t * vMap = Vec_IntStartFull( Abc_NamObjNumMax(p->pDesign->pStrs) ); - int i, iObj; char * pName; - Acb_NtkForEachObj( p, iObj ) - if ( Acb_ObjName(p, iObj) ) - Vec_IntWriteEntry( vMap, Acb_ObjName(p, iObj), iObj ); - Vec_PtrForEachEntry( char *, vNames, pName, i ) - { - int NameId = Abc_NamStrFindOrAdd( p->pDesign->pStrs, pName, NULL ); - if ( NameId == 0 ) - { - printf( "Cannot find name ID for name %s\n", pName ); - Vec_IntFree( vMap ); - Vec_IntFree( vNodes ); - return NULL; - } - else if ( Vec_IntEntry(vMap, NameId) == -1 ) - { - printf( "Cannot find obj ID for name %s\n", pName ); - Vec_IntFree( vMap ); - Vec_IntFree( vNodes ); - return NULL; - } - else - Vec_IntPush( vNodes, Vec_IntEntry(vMap, NameId) ); - } - Vec_IntFree( vMap ); - return vNodes; - } - return NULL; +Vec_Ptr_t * Acb_SignalNames( Acb_Ntk_t * p, Vec_Int_t * vObjs ) +{ + Vec_Ptr_t * vNames = Vec_PtrAlloc( Vec_IntSize(vObjs) ); + int i, iObj; + Vec_IntForEachEntry( vObjs, iObj, i ) + Vec_PtrPush( vNames, Acb_ObjNameStr(p, iObj) ); + return vNames; } Vec_Str_t * Acb_GeneratePatch( Acb_Ntk_t * p, Vec_Int_t * vDivs, Vec_Int_t * vUsed, Vec_Ptr_t * vSops, Vec_Ptr_t * vGias, Vec_Int_t * vTars ) { + extern int Acb_NtkCollectMfsGates( char * pFileName, Vec_Ptr_t * vNamesRefed, Vec_Ptr_t * vNamesDerefed, int nGates1[5] ); extern Vec_Wec_t * Abc_SopSynthesize( Vec_Ptr_t * vSops ); extern Vec_Wec_t * Abc_GiaSynthesize( Vec_Ptr_t * vGias, Gia_Man_t * pMulti ); Vec_Wec_t * vGates = vGias ? Abc_GiaSynthesize(vGias, NULL) : Abc_SopSynthesize(vSops); Vec_Int_t * vGate; @@ -1989,15 +1962,13 @@ Vec_Str_t * Acb_GeneratePatch( Acb_Ntk_t * p, Vec_Int_t * vDivs, Vec_Int_t * vUs Vec_Ptr_t * vNames = Acb_GenerateSignalNames( p, vDivs, vUsed, nWires, vTars, vGates ); Vec_Str_t * vStr = Vec_StrAlloc( 100 ); Vec_Int_t * vSup = Acb_GetUsedDivs( vDivs, vUsed ); - Vec_Int_t * vDrf = Acb_GetDerefedNodes( p ); + Vec_Ptr_t * vSpN = Acb_SignalNames( p, vSup ); Vec_Int_t * vTfi = Acb_ObjCollectTfiVec( p, vSup ); Vec_Int_t * vTfo = Acb_ObjCollectTfoVec( p, vTars ); int nPiCount = Acb_NtkCountPiBuffers( p, vSup ); int nPoCount = Acb_NtkCountPoDrivers( p, vTars ); - int nMffc = vDrf ? Vec_IntSize(vTars) + Acb_NtkFindMffcSize( p, vSup, vDrf, nGates1 ) : 0; - int * pCounts = Abc_FrameReadGateCounts(); - for ( i = 0; i < 5; i++ ) - nGates1[i] += pCounts[i]; + int nMffc = Abc_FrameReadSpecName() ? Acb_NtkCollectMfsGates( Abc_FrameReadSpecName(), vSpN, Abc_FrameReadSignalNames(), nGates1 ) : 0; + Vec_PtrFree( vSpN ); Vec_IntFree( vSup ); Vec_WecForEachLevelStartStop( vGates, vGate, i, Vec_IntSize(vUsed), Vec_IntSize(vUsed)+nWires ) { @@ -2017,9 +1988,9 @@ Vec_Str_t * Acb_GeneratePatch( Acb_Ntk_t * p, Vec_Int_t * vDivs, Vec_Int_t * vUs Vec_StrPrintF( vStr, "// Patch : in = %d out = %d : pi_in = %d po_out = %d : tfi = %d tfo = %d\n", Vec_IntSize(vUsed), nOuts, nPiCount, nPoCount, Vec_IntSize(vTfi), Vec_IntSize(vTfo) ); Vec_StrPrintF( vStr, "// Added : gate =%4d : c0 =%2d c1 =%2d buf =%3d inv =%3d two-input =%4d\n", nWires, nGates0[0], nGates0[1], nGates0[2], nGates0[3], nGates0[4] ); - if ( vDrf != NULL ) + if ( Abc_FrameReadSpecName() ) Vec_StrPrintF( vStr, "// Removed : gate =%4d : c0 =%2d c1 =%2d buf =%3d inv =%3d two-input =%4d\n", nMffc, nGates1[0], nGates1[1], nGates1[2], nGates1[3], nGates1[4] ); - if ( vDrf != NULL ) + if ( Abc_FrameReadSpecName() ) Vec_StrPrintF( vStr, "// TOTAL : gate =%4d : c0 =%2d c1 =%2d buf =%3d inv =%3d two-input =%4d\n", nWires-nMffc, nGates0[0]-nGates1[0], nGates0[1]-nGates1[1], nGates0[2]-nGates1[2], nGates0[3]-nGates1[3], nGates0[4]-nGates1[4] ); Vec_StrPrintF( vStr, "\n" ); @@ -2084,12 +2055,11 @@ Vec_Str_t * Acb_GeneratePatch( Acb_Ntk_t * p, Vec_Int_t * vDivs, Vec_Int_t * vUs printf( "\n" ); printf( "Patch : in = %d out = %d : pi_in = %d po_out = %d : tfi = %d tfo = %d\n", Vec_IntSize(vUsed), nOuts, nPiCount, nPoCount, Vec_IntSize(vTfi), Vec_IntSize(vTfo) ); printf( "Added : gate =%4d : c0 =%2d c1 =%2d buf =%3d inv =%3d two-input =%4d\n", nWires, nGates0[0], nGates0[1], nGates0[2], nGates0[3], nGates0[4] ); - if ( vDrf != NULL ) + if ( Abc_FrameReadSpecName() ) printf( "Removed : gate =%4d : c0 =%2d c1 =%2d buf =%3d inv =%3d two-input =%4d\n", nMffc, nGates1[0], nGates1[1], nGates1[2], nGates1[3], nGates1[4] ); - if ( vDrf != NULL ) + if ( Abc_FrameReadSpecName() ) printf( "TOTAL : gate =%4d : c0 =%2d c1 =%2d buf =%3d inv =%3d two-input =%4d\n", nWires-nMffc, nGates0[0]-nGates1[0], nGates0[1]-nGates1[1], nGates0[2]-nGates1[2], nGates0[3]-nGates1[3], nGates0[4]-nGates1[4] ); printf( "\n" ); - Vec_IntFreeP( &vDrf ); return vStr; } @@ -2209,11 +2179,11 @@ Vec_Str_t * Acb_GeneratePatch2( Gia_Man_t * pGia, Vec_Ptr_t * vIns, Vec_Ptr_t * printf( "Synthesized patch with %d inputs, %d outputs and %d gates.\n", nIns, nOuts, nWires ); return vStr; } -void Acb_GenerateFile2( Gia_Man_t * pGia, Vec_Ptr_t * vIns, Vec_Ptr_t * vOuts, char * pFileName, char * pFileNameOut ) +void Acb_GenerateFile2( Gia_Man_t * pGia, Vec_Ptr_t * vIns, Vec_Ptr_t * vOuts, char * pFileName, char * pFileNameOut, int fSkipMffc ) { extern void Acb_GenerateFilePatch( Vec_Str_t * p, char * pFileNamePatch ); extern void Acb_GenerateFileOut( Vec_Str_t * vPatchLine, char * pFileNameF, char * pFileNameOut, Vec_Str_t * vPatch ); - extern void Acb_NtkInsert( char * pFileNameIn, char * pFileNameOut, Vec_Ptr_t * vNames, int fNumber ); + extern void Acb_NtkInsert( char * pFileNameIn, char * pFileNameOut, Vec_Ptr_t * vNames, int fNumber, int fSkipMffc ); Vec_Str_t * vInst = Acb_GenerateInstance2( vIns, vOuts ); Vec_Str_t * vPatch = Acb_GeneratePatch2( pGia, vIns, vOuts ); //printf( "%s", Vec_StrArray(vPatch) ); @@ -2221,7 +2191,7 @@ void Acb_GenerateFile2( Gia_Man_t * pGia, Vec_Ptr_t * vIns, Vec_Ptr_t * vOuts, c // generate output files Acb_GenerateFilePatch( vPatch, "patch.v" ); printf( "Finished dumping patch file \"%s\".\n", "patch.v" ); - Acb_NtkInsert( pFileName, "temp.v", vOuts, 0 ); + Acb_NtkInsert( pFileName, "temp.v", vOuts, 0, fSkipMffc ); printf( "Finished dumping intermediate file \"%s\".\n", "temp.v" ); Acb_GenerateFileOut( vInst, "temp.v", pFileNameOut, vPatch ); printf( "Finished dumping the resulting file \"%s\".\n", pFileNameOut ); diff --git a/src/base/acb/acbUtil.c b/src/base/acb/acbUtil.c index 070754af..2cfae6ea 100644 --- a/src/base/acb/acbUtil.c +++ b/src/base/acb/acbUtil.c @@ -148,9 +148,13 @@ int Acb_NtkCountPoDrivers( Acb_Ntk_t * p, Vec_Int_t * vObjs ) int i, iObj, Count = 0; Acb_NtkIncTravId( p ); Acb_NtkForEachCo( p, iObj, i ) + { + int Fanin0 = Acb_ObjFanin0(p, iObj); Acb_ObjSetTravIdCur( p, iObj ); - Acb_NtkForEachCo( p, iObj, i ) - Acb_ObjSetTravIdCur( p, Acb_ObjFanin(p, iObj, 0) ); + Acb_ObjSetTravIdCur( p, Fanin0 ); + if ( Acb_ObjFaninNum(p, Fanin0) == 1 ) + Acb_ObjSetTravIdCur( p, Acb_ObjFanin0(p, Fanin0) ); + } Vec_IntForEachEntry( vObjs, iObj, i ) Count += Acb_ObjIsTravIdCur(p, iObj); return Count; @@ -167,47 +171,117 @@ int Acb_NtkCountPoDrivers( Acb_Ntk_t * p, Vec_Int_t * vObjs ) SeeAlso [] ***********************************************************************/ -int Acb_NtkNodeDeref_rec( Vec_Int_t * vRefs, Acb_Ntk_t * p, int iObj, int nGates[5] ) +int Acb_NtkNodeDeref_rec( Vec_Int_t * vRefs, Acb_Ntk_t * p, int iObj ) { int i, Fanin, * pFanins, Counter = 1; if ( Acb_ObjIsCi(p, iObj) ) return 0; - if ( nGates ) - { - int nFan = Acb_ObjFaninNum(p, iObj); - int Type = Acb_ObjType( p, iObj ); - if ( Type == ABC_OPER_CONST_F ) - nGates[0]++; - else if ( Type == ABC_OPER_CONST_T ) - nGates[1]++; - else if ( Type == ABC_OPER_BIT_BUF || Type == ABC_OPER_CO ) - nGates[2]++; - else if ( Type == ABC_OPER_BIT_INV ) - nGates[3]++; - else - { - assert( nFan >= 2 ); - nGates[4] += Acb_ObjFaninNum(p, iObj)-1; - } - } Acb_ObjForEachFaninFast( p, iObj, pFanins, Fanin, i ) { assert( Vec_IntEntry(vRefs, Fanin) > 0 ); Vec_IntAddToEntry( vRefs, Fanin, -1 ); if ( Vec_IntEntry(vRefs, Fanin) == 0 ) - Counter += Acb_NtkNodeDeref_rec( vRefs, p, Fanin, nGates ); + Counter += Acb_NtkNodeDeref_rec( vRefs, p, Fanin ); } return Counter; } -int Acb_NtkNodeRef_rec( Vec_Int_t * vRefs, Acb_Ntk_t * p, int iObj, int nGates[5] ) +int Acb_NtkNodeRef_rec( Vec_Int_t * vRefs, Acb_Ntk_t * p, int iObj ) { int i, Fanin, * pFanins, Counter = 1; if ( Acb_ObjIsCi(p, iObj) ) return 0; - if ( nGates ) + Acb_ObjForEachFaninFast( p, iObj, pFanins, Fanin, i ) { - int nFan = Acb_ObjFaninNum(p, iObj); - int Type = Acb_ObjType( p, iObj ); + if ( Vec_IntEntry(vRefs, Fanin) == 0 ) + Counter += Acb_NtkNodeRef_rec( vRefs, p, Fanin ); + Vec_IntAddToEntry( vRefs, Fanin, 1 ); + } + return Counter; +} + +/**Function************************************************************* + + Synopsis [Computing and updating direct and reverse logic level.] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +void Acb_NtkCollectDeref_rec( Vec_Int_t * vRefs, Acb_Ntk_t * p, int iObj, Vec_Int_t * vRes ) +{ + int i, Fanin, * pFanins; + if ( Acb_ObjIsCi(p, iObj) ) + return; + Vec_IntPush( vRes, iObj ); + Acb_ObjForEachFaninFast( p, iObj, pFanins, Fanin, i ) + { + assert( Vec_IntEntry(vRefs, Fanin) > 0 ); + Vec_IntAddToEntry( vRefs, Fanin, -1 ); + if ( Vec_IntEntry(vRefs, Fanin) == 0 ) + Acb_NtkCollectDeref_rec( vRefs, p, Fanin, vRes ); + } +} +Vec_Int_t * Acb_NtkCollectMffc( Acb_Ntk_t * p, Vec_Int_t * vObjsRefed, Vec_Int_t * vObjsDerefed ) +{ + Vec_Int_t * vRes = Vec_IntAlloc( 100 ); + Vec_Int_t * vRefs = Vec_IntStart( Acb_NtkObjNumMax(p) ); + int i, iObj, Fanin, * pFanins; + Acb_NtkForEachObj( p, iObj ) + Acb_ObjForEachFaninFast( p, iObj, pFanins, Fanin, i ) + Vec_IntAddToEntry( vRefs, Fanin, 1 ); + Acb_NtkForEachCo( p, iObj, i ) + Vec_IntAddToEntry( vRefs, iObj, 1 ); + if ( vObjsRefed ) + Vec_IntForEachEntry( vObjsRefed, iObj, i ) + Vec_IntAddToEntry( vRefs, iObj, 1 ); + Vec_IntForEachEntry( vObjsDerefed, iObj, i ) + { + if ( Acb_ObjIsCo(p, iObj) ) + iObj = Acb_ObjFanin0(p, iObj); + if ( Vec_IntEntry(vRefs, iObj) != 0 ) + Acb_NtkCollectDeref_rec( vRefs, p, iObj, vRes ); + } + Vec_IntFree( vRefs ); + Vec_IntUniqify( vRes ); + return vRes; +} + +Vec_Int_t * Acb_NamesToIds( Acb_Ntk_t * pNtk, Vec_Int_t * vNamesInv, Vec_Ptr_t * vNames ) +{ + Vec_Int_t * vRes = Vec_IntAlloc( Vec_PtrSize(vNames) ); + char * pName; int i; + Vec_PtrForEachEntry( char *, vNames, pName, i ) + { + int NameId = Acb_NtkStrId(pNtk, pName); + int iObjId = 0; + if ( NameId < 1 ) + printf( "Cannot find name \"%s\" in the network \"%s\".\n", pName, pNtk->pDesign->pName ); + else + iObjId = Vec_IntEntry( vNamesInv, NameId ); + Vec_IntPush( vRes, iObjId ); + } + return vRes; +} +int Acb_NtkCollectMfsGates( char * pFileName, Vec_Ptr_t * vNamesRefed, Vec_Ptr_t * vNamesDerefed, int nGates[5] ) +{ + Acb_Ntk_t * pNtkF = Acb_VerilogSimpleRead( pFileName, NULL ); + Vec_Int_t * vNamesInv = Vec_IntInvert( &pNtkF->vObjName, 0 ) ; + Vec_Int_t * vObjsRefed = Acb_NamesToIds( pNtkF, vNamesInv, vNamesRefed ); + Vec_Int_t * vObjsDerefed = Acb_NamesToIds( pNtkF, vNamesInv, vNamesDerefed ); + Vec_Int_t * vNodes = Acb_NtkCollectMffc( pNtkF, vObjsRefed, vObjsDerefed ); + int i, iObj, RetValue = Vec_IntSize(vNodes); + Vec_IntFree( vNamesInv ); + Vec_IntFree( vObjsRefed ); + Vec_IntFree( vObjsDerefed ); + for ( i = 0; i < 5; i++ ) + nGates[i] = 0; + Vec_IntForEachEntry( vNodes, iObj, i ) + { + int nFan = Acb_ObjFaninNum(pNtkF, iObj); + int Type = Acb_ObjType( pNtkF, iObj ); if ( Type == ABC_OPER_CONST_F ) nGates[0]++; else if ( Type == ABC_OPER_CONST_T ) @@ -219,31 +293,30 @@ int Acb_NtkNodeRef_rec( Vec_Int_t * vRefs, Acb_Ntk_t * p, int iObj, int nGates[5 else { assert( nFan >= 2 ); - nGates[4] += Acb_ObjFaninNum(p, iObj)-1; + nGates[4] += Acb_ObjFaninNum(pNtkF, iObj)-1; } } - Acb_ObjForEachFaninFast( p, iObj, pFanins, Fanin, i ) - { - if ( Vec_IntEntry(vRefs, Fanin) == 0 ) - Counter += Acb_NtkNodeRef_rec( vRefs, p, Fanin, nGates ); - Vec_IntAddToEntry( vRefs, Fanin, 1 ); - } - return Counter; + Vec_IntFree( vNodes ); + Acb_ManFree( pNtkF->pDesign ); + return RetValue; } -int Acb_NtkFindMffcSize( Acb_Ntk_t * p, Vec_Int_t * vObjsRefed, Vec_Int_t * vObjsDerefed, int nGates[5] ) +Vec_Ptr_t * Acb_NtkReturnMfsGates( char * pFileName, Vec_Ptr_t * vNodes ) { - Vec_Int_t * vRefs = Vec_IntStart( Acb_NtkObjNumMax(p) ); - int i, iObj, Fanin, * pFanins, Count2 = 0; - Acb_NtkForEachObj( p, iObj ) - Acb_ObjForEachFaninFast( p, iObj, pFanins, Fanin, i ) - Vec_IntAddToEntry( vRefs, Fanin, 1 ); - Vec_IntForEachEntry( vObjsRefed, iObj, i ) - Vec_IntAddToEntry( vRefs, iObj, 1 ); - Vec_IntForEachEntry( vObjsDerefed, iObj, i ) - //if ( Vec_IntEntry(vRefs, iObj) != 0 || Acb_ObjIsCo(p, iObj) ) - Count2 += Acb_NtkNodeDeref_rec( vRefs, p, iObj, nGates ); - Vec_IntFree( vRefs ); - return Count2; + Vec_Ptr_t * vMffc = Vec_PtrAlloc( 100 ); + Acb_Ntk_t * pNtkF = Acb_VerilogSimpleRead( pFileName, NULL ); + Vec_Int_t * vNamesInv = Vec_IntInvert( &pNtkF->vObjName, 0 ) ; + Vec_Int_t * vNodeObjs = Acb_NamesToIds( pNtkF, vNamesInv, vNodes ); + Vec_Int_t * vNodeMffc = Acb_NtkCollectMffc( pNtkF, NULL, vNodeObjs ); + int i, iObj; + Vec_IntForEachEntry( vNodeMffc, iObj, i ) + Vec_PtrPush( vMffc, Abc_UtilStrsav( Acb_ObjNameStr(pNtkF, iObj) ) ); +//Vec_IntPrint( vNodeMffc ); +//Vec_PtrPrintNames( vMffc ); + Vec_IntFree( vNodeMffc ); + Vec_IntFree( vNodeObjs ); + Vec_IntFree( vNamesInv ); + Acb_ManFree( pNtkF->pDesign ); + return vMffc; } /**Function************************************************************* @@ -959,63 +1032,6 @@ int Abc_NtkExtract( char * pFileName0, char * pFileName1, int fUseXors, int fVer SeeAlso [] ***********************************************************************/ -void Acb_NtkFindNamesInPlaces( char * pBuffer, Vec_Int_t * vPlaces, Vec_Ptr_t * vPivots ) -{ - int * pCounts = Abc_FrameReadGateCounts(); - Vec_Ptr_t * vNames = Vec_PtrAlloc( 100 ); - int i, k, iObj, Pos; - for ( i = 0; i < 5; i++ ) - pCounts[i] = 0; - Vec_IntForEachEntryDouble( vPlaces, Pos, iObj, i ) - { - int nFanins = 0; - char pLocal[1000], * pTemp, * pName, * pSpot; - char * pPivot = (char *)Vec_PtrEntry(vPivots, iObj); - for ( k = 0; k < 1000; k++ ) - { - if ( pBuffer[Pos+k] == '\n' ) - { - pLocal[k] = 0; - break; - } - else - pLocal[k] = pBuffer[Pos+k]; - } - assert( k < 1000 ); - pSpot = strstr( pLocal, pPivot ); - if ( pSpot == NULL ) - { - printf( "Cannot find location of signal \"%s\" in this line.\n", pPivot ); - continue; - } - pTemp = strtok( pLocal, " \r\n\t,;()" ); - while ( pTemp ) - { - if ( !strcmp(pTemp, "1\'b0") ) - pCounts[0]++; - else if ( !strcmp(pTemp, "1\'b1") ) - pCounts[1]++; - else if ( !strcmp(pTemp, "buf") || !strcmp(pTemp, "assign") ) - pCounts[2]++; - else if ( !strcmp(pTemp, "not") ) - pCounts[3]++; - else if ( strcmp(pTemp, pPivot) && pTemp > pSpot ) - { - nFanins++; - Vec_PtrForEachEntry( char *, vNames, pName, k ) - if ( !strcmp(pName, pTemp) ) - break; - if ( k == Vec_PtrSize(vNames) ) - Vec_PtrPush( vNames, Abc_UtilStrsav(pTemp) ); - } - pTemp = strtok( NULL, " \r\n\t,;()" ); - } - if ( nFanins > 1 ) - pCounts[4] += nFanins-1; - } - //printf( "Found %d names\n", Vec_PtrSize(vNames) ); - Abc_FrameSetSignalNames( vNames ); -} Vec_Int_t * Acb_NtkPlaces( char * pFileName, Vec_Ptr_t * vNames ) { Vec_Int_t * vPlaces; int First = 1, Pos = -1, fComment = 0; @@ -1057,7 +1073,7 @@ Vec_Int_t * Acb_NtkPlaces( char * pFileName, Vec_Ptr_t * vNames ) ABC_FREE( pBuffer ); return vPlaces; } -void Acb_NtkInsert( char * pFileNameIn, char * pFileNameOut, Vec_Ptr_t * vNames, int fNumber ) +void Acb_NtkInsert( char * pFileNameIn, char * pFileNameOut, Vec_Ptr_t * vNames, int fNumber, int fSkipMffc ) { int i, k, Prev = 0, Pos, Pos2, iObj; Vec_Int_t * vPlaces; @@ -1075,16 +1091,32 @@ void Acb_NtkInsert( char * pFileNameIn, char * pFileNameOut, Vec_Ptr_t * vNames, printf( "Cannot open input file \"%s\".\n", pFileNameIn ); return; } - vPlaces = Acb_NtkPlaces( pFileNameIn, vNames ); - Acb_NtkFindNamesInPlaces( pBuffer, vPlaces, vNames ); - Vec_IntForEachEntryDouble( vPlaces, Pos, iObj, i ) + if ( fSkipMffc ) { - for ( k = Prev; k < Pos; k++ ) - fputc( pBuffer[k], pFile ); - fprintf( pFile, "// [t_%d = %s] //", iObj, (char *)Vec_PtrEntry(vNames, iObj) ); - Prev = Pos; + Vec_Ptr_t * vMffcNames = Acb_NtkReturnMfsGates( pFileNameIn, vNames ); + vPlaces = Acb_NtkPlaces( pFileNameIn, vMffcNames ); + Vec_IntForEachEntryDouble( vPlaces, Pos, iObj, i ) + { + for ( k = Prev; k < Pos; k++ ) + fputc( pBuffer[k], pFile ); + fprintf( pFile, "// MFFC %d = %s //", iObj, (char *)Vec_PtrEntry(vMffcNames, iObj) ); + Prev = Pos; + } + Vec_IntFree( vPlaces ); + Vec_PtrFreeFree( vMffcNames ); + } + else + { + vPlaces = Acb_NtkPlaces( pFileNameIn, vNames ); + Vec_IntForEachEntryDouble( vPlaces, Pos, iObj, i ) + { + for ( k = Prev; k < Pos; k++ ) + fputc( pBuffer[k], pFile ); + fprintf( pFile, "// [t_%d = %s] //", iObj, (char *)Vec_PtrEntry(vNames, iObj) ); + Prev = Pos; + } + Vec_IntFree( vPlaces ); } - Vec_IntFree( vPlaces ); pName = strstr(pBuffer, "endmodule"); Pos2 = pName - pBuffer; for ( k = Prev; k < Pos2; k++ ) @@ -1238,12 +1270,12 @@ void Acb_Ntk4DumpWeights( char * pFileNameIn, Vec_Ptr_t * vObjNames, char * pFil SeeAlso [] ***********************************************************************/ -void Acb_NtkRunSim( char * pFileName[4], int nWords, int nBeam, int LevL, int LevU, int fOrder, int fFancy, int fUseBuf, int fRandom, int fUseWeights, int fInputs, int fVerbose, int fVeryVerbose ) +void Acb_NtkRunSim( char * pFileName[4], int nWords, int nBeam, int LevL, int LevU, int fOrder, int fFancy, int fUseBuf, int fRandom, int fUseWeights, int fInputs, int fSkipMffc, int fVerbose, int fVeryVerbose ) { - extern int Gia_Sim4Try( char * pFileName0, char * pFileName1, char * pFileName2, int nWords, int nBeam, int LevL, int LevU, int fOrder, int fFancy, int fUseBuf, int fVerbose ); + extern int Gia_Sim4Try( char * pFileName0, char * pFileName1, char * pFileName2, int nWords, int nBeam, int LevL, int LevU, int fOrder, int fFancy, int fUseBuf, int fSkipMffc, int fVerbose ); extern void Acb_NtkRunEco( char * pFileNames[4], int fCheck, int fRandom, int fInputs, int fVerbose, int fVeryVerbose ); char * pFileNames[4] = { pFileName[2], pFileName[1], fUseWeights ? (char *)"weights.txt" : NULL, pFileName[2] }; - if ( Gia_Sim4Try( pFileName[0], pFileName[1], pFileName[2], nWords, nBeam, LevL, LevU, fOrder, fFancy, fUseBuf, fVerbose ) ) + if ( Gia_Sim4Try( pFileName[0], pFileName[1], pFileName[2], nWords, nBeam, LevL, LevU, fOrder, fFancy, fUseBuf, fSkipMffc, fVerbose ) ) Acb_NtkRunEco( pFileNames, 1, fRandom, fInputs, fVerbose, fVeryVerbose ); } diff --git a/src/base/main/main.h b/src/base/main/main.h index 9ef8b6ff..a310972d 100644 --- a/src/base/main/main.h +++ b/src/base/main/main.h @@ -106,7 +106,7 @@ extern ABC_DLL void * Abc_FrameReadManDec(); extern ABC_DLL void * Abc_FrameReadManDsd(); extern ABC_DLL void * Abc_FrameReadManDsd2(); extern ABC_DLL Vec_Ptr_t * Abc_FrameReadSignalNames(); -extern ABC_DLL int * Abc_FrameReadGateCounts(); +extern ABC_DLL char * Abc_FrameReadSpecName(); extern ABC_DLL char * Abc_FrameReadFlag( char * pFlag ); extern ABC_DLL int Abc_FrameIsFlagEnabled( char * pFlag ); @@ -150,6 +150,7 @@ extern ABC_DLL void Abc_FrameSetStr( Vec_Str_t * vInv ); extern ABC_DLL void Abc_FrameSetJsonStrs( Abc_Nam_t * pStrs ); extern ABC_DLL void Abc_FrameSetJsonObjs( Vec_Wec_t * vObjs ); extern ABC_DLL void Abc_FrameSetSignalNames( Vec_Ptr_t * vNames ); +extern ABC_DLL void Abc_FrameSetSpecName( char * pFileName ); extern ABC_DLL int Abc_FrameCheckPoConst( Abc_Frame_t * p, int iPoNum ); diff --git a/src/base/main/mainFrame.c b/src/base/main/mainFrame.c index 2743a90a..b7d76e93 100644 --- a/src/base/main/mainFrame.c +++ b/src/base/main/mainFrame.c @@ -68,7 +68,7 @@ void * Abc_FrameReadManDsd() { return s_GlobalFr void * Abc_FrameReadManDsd2() { return s_GlobalFrame->pManDsd2; } char * Abc_FrameReadFlag( char * pFlag ) { return Cmd_FlagReadByName( s_GlobalFrame, pFlag ); } Vec_Ptr_t * Abc_FrameReadSignalNames() { return s_GlobalFrame->vSignalNames; } -int * Abc_FrameReadGateCounts() { return s_GlobalFrame->pGateCounts; } +char * Abc_FrameReadSpecName() { return s_GlobalFrame->pSpecName; } int Abc_FrameReadBmcFrames( Abc_Frame_t * p ) { return s_GlobalFrame->nFrames; } int Abc_FrameReadProbStatus( Abc_Frame_t * p ) { return s_GlobalFrame->Status; } @@ -105,6 +105,7 @@ void Abc_FrameSetInv( Vec_Int_t * vInv ) { Vec_IntFreeP(&s_G void Abc_FrameSetJsonStrs( Abc_Nam_t * pStrs ) { Abc_NamDeref( s_GlobalFrame->pJsonStrs ); s_GlobalFrame->pJsonStrs = pStrs; } void Abc_FrameSetJsonObjs( Vec_Wec_t * vObjs ) { Vec_WecFreeP(&s_GlobalFrame->vJsonObjs ); s_GlobalFrame->vJsonObjs = vObjs; } void Abc_FrameSetSignalNames( Vec_Ptr_t * vNames ) { if ( s_GlobalFrame->vSignalNames ) Vec_PtrFreeFree( s_GlobalFrame->vSignalNames ); s_GlobalFrame->vSignalNames = vNames; } +void Abc_FrameSetSpecName( char * pFileName ) { ABC_FREE( s_GlobalFrame->pSpecName ); s_GlobalFrame->pSpecName = pFileName; } int Abc_FrameIsBatchMode() { return s_GlobalFrame ? s_GlobalFrame->fBatchMode : 0; } @@ -236,6 +237,7 @@ void Abc_FrameDeallocate( Abc_Frame_t * p ) Vec_PtrFreeP( &p->vLTLProperties_global ); if ( p->vSignalNames ) Vec_PtrFreeFree( p->vSignalNames ); + ABC_FREE( p->pSpecName ); Abc_FrameDeleteAllNetworks( p ); ABC_FREE( p->pDrivingCell ); ABC_FREE( p->pCex2 ); diff --git a/src/base/main/mainInt.h b/src/base/main/mainInt.h index 9eaa03d1..e860878e 100644 --- a/src/base/main/mainInt.h +++ b/src/base/main/mainInt.h @@ -134,7 +134,7 @@ struct Abc_Frame_t_ Vec_Ptr_t * vPlugInComBinPairs; // pairs of command and its binary name Vec_Ptr_t * vLTLProperties_global; // related to LTL Vec_Ptr_t * vSignalNames; // temporary storage for signal names - int pGateCounts[5];// temporary gate counts + char * pSpecName; void * pSave1; void * pSave2; void * pSave3; -- cgit v1.2.3 From f21bafeb230d99b264b84dd316f29b45b94df034 Mon Sep 17 00:00:00 2001 From: Alan Mishchenko Date: Thu, 24 Sep 2020 23:49:01 -0700 Subject: Changing SAT sweepers (ifraig and &fraig) to be stronger by default. --- src/base/abci/abc.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/base') diff --git a/src/base/abci/abc.c b/src/base/abci/abc.c index 76f60a36..ab8e3659 100644 --- a/src/base/abci/abc.c +++ b/src/base/abci/abc.c @@ -15443,7 +15443,7 @@ int Abc_CommandIFraig( Abc_Frame_t * pAbc, int argc, char ** argv ) nPartSize = 0; nLevelMax = 0; nConfLimit = 100; - fDoSparse = 0; + fDoSparse = 1; fProve = 0; fVerbose = 0; Extra_UtilGetoptReset(); @@ -36287,6 +36287,7 @@ int Abc_CommandAbc9Fraig( Abc_Frame_t * pAbc, int argc, char ** argv ) int c, fUseAlgo = 0, fUseAlgoG = 0; Cec_ManFraSetDefaultParams( pPars ); pPars->fSatSweeping = 1; + pPars->nItersMax = 1000000; Extra_UtilGetoptReset(); while ( ( c = Extra_UtilGetopt( argc, argv, "WRILDCrmdckngwvh" ) ) != EOF ) { -- cgit v1.2.3 From ada073110ef495115fdc43d3a2ef4df16e36dfeb Mon Sep 17 00:00:00 2001 From: Alan Mishchenko Date: Thu, 1 Oct 2020 21:24:32 -0700 Subject: New command 'read_sf'. --- src/base/io/io.c | 73 ++++++++++++++++++++++++++++++++++++++++++++++++++++ src/base/io/ioUtil.c | 55 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 128 insertions(+) (limited to 'src/base') diff --git a/src/base/io/io.c b/src/base/io/io.c index a5cffbf4..c2363cb5 100644 --- a/src/base/io/io.c +++ b/src/base/io/io.c @@ -24,6 +24,10 @@ #include "proof/abs/abs.h" #include "sat/bmc/bmc.h" +#ifdef WIN32 +#define unlink _unlink +#endif + ABC_NAMESPACE_IMPL_START //////////////////////////////////////////////////////////////////////// @@ -49,6 +53,7 @@ static int IoCommandReadVerilog ( Abc_Frame_t * pAbc, int argc, char **argv ); static int IoCommandReadStatus ( Abc_Frame_t * pAbc, int argc, char **argv ); static int IoCommandReadGig ( Abc_Frame_t * pAbc, int argc, char **argv ); static int IoCommandReadJson ( Abc_Frame_t * pAbc, int argc, char **argv ); +static int IoCommandReadSF ( Abc_Frame_t * pAbc, int argc, char **argv ); static int IoCommandWrite ( Abc_Frame_t * pAbc, int argc, char **argv ); static int IoCommandWriteHie ( Abc_Frame_t * pAbc, int argc, char **argv ); @@ -118,6 +123,7 @@ void Io_Init( Abc_Frame_t * pAbc ) Cmd_CommandAdd( pAbc, "I/O", "read_status", IoCommandReadStatus, 0 ); Cmd_CommandAdd( pAbc, "I/O", "&read_gig", IoCommandReadGig, 0 ); Cmd_CommandAdd( pAbc, "I/O", "read_json", IoCommandReadJson, 0 ); + Cmd_CommandAdd( pAbc, "I/O", "read_sf", IoCommandReadSF, 0 ); Cmd_CommandAdd( pAbc, "I/O", "write", IoCommandWrite, 0 ); Cmd_CommandAdd( pAbc, "I/O", "write_hie", IoCommandWriteHie, 0 ); @@ -1415,6 +1421,73 @@ usage: return 1; } +/**Function************************************************************* + + Synopsis [] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +int IoCommandReadSF( Abc_Frame_t * pAbc, int argc, char ** argv ) +{ + extern void Io_TransformSF2PLA( char * pNameIn, char * pNameOut ); + + Abc_Ntk_t * pNtk; + FILE * pFile; + char * pFileName, * pFileTemp = "_temp_sf_.pla"; + int c; + + Extra_UtilGetoptReset(); + while ( ( c = Extra_UtilGetopt( argc, argv, "h" ) ) != EOF ) + { + switch ( c ) + { + case 'h': + goto usage; + default: + goto usage; + } + } + if ( argc != globalUtilOptind + 1 ) + { + goto usage; + } + + // get the input file name + pFileName = argv[globalUtilOptind]; + if ( (pFile = fopen( pFileName, "r" )) == NULL ) + { + fprintf( pAbc->Err, "Cannot open input file \"%s\". \n", pFileName ); + return 1; + } + fclose( pFile ); + Io_TransformSF2PLA( pFileName, pFileTemp ); + pNtk = Io_Read( pFileTemp, IO_FILE_PLA, 1, 0 ); + unlink( pFileTemp ); + if ( pNtk == NULL ) + return 1; + ABC_FREE( pNtk->pName ); + pNtk->pName = Extra_FileNameGeneric( pFileName ); + ABC_FREE( pNtk->pSpec ); + pNtk->pSpec = Abc_UtilStrsav( pFileName ); + // replace the current network + Abc_FrameReplaceCurrentNetwork( pAbc, pNtk ); + Abc_FrameClearVerifStatus( pAbc ); + + return 0; + +usage: + fprintf( pAbc->Err, "usage: read_sf [-h] \n" ); + fprintf( pAbc->Err, "\t reads file in SF format\n" ); + fprintf( pAbc->Err, "\t-h : prints the command summary\n" ); + fprintf( pAbc->Err, "\tfile : the name of a file to read\n" ); + return 1; +} + /**Function************************************************************* diff --git a/src/base/io/ioUtil.c b/src/base/io/ioUtil.c index c6b47b11..01fe4f45 100644 --- a/src/base/io/ioUtil.c +++ b/src/base/io/ioUtil.c @@ -862,6 +862,61 @@ FILE * Io_FileOpen( const char * FileName, const char * PathVar, const char * Mo } } +/**Function************************************************************* + + Synopsis [Tranform SF into PLA.] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +void Io_TransformSF2PLA( char * pNameIn, char * pNameOut ) +{ + int fStart = 0, Size = 1000000; + char * pBuffer, * pToken; + FILE * pFileIn = fopen( pNameIn, "rb" ); + FILE * pFileOut = fopen( pNameOut, "wb" ); + if ( pFileIn == NULL ) + { + if ( pFileOut ) fclose( pFileOut ); + printf( "Cannot open file \"%s\" for reading.\n", pNameIn ); + return; + } + if ( pFileOut == NULL ) + { + if ( pFileIn ) fclose( pFileIn ); + printf( "Cannot open file \"%s\" for reading.\n", pNameOut ); + return; + } + pBuffer = ABC_ALLOC( char, Size ); + fprintf( pFileOut, ".type fd\n" ); + while ( fgets(pBuffer, Size, pFileIn) ) + { + if ( strstr(pBuffer, "END_SDF") ) + break; + if ( strstr(pBuffer, "SDF") ) + { + fgets(pBuffer, Size, pFileIn); + if ( (pToken = strtok( pBuffer, " \t\r\n" )) ) + fprintf( pFileOut, ".i %d\n", atoi(pToken) ); + if ( (pToken = strtok( NULL, " \t\r\n" )) ) + fprintf( pFileOut, ".o %d\n", atoi(pToken) ); + if ( (pToken = strtok( NULL, " \t\r\n" )) ) + fprintf( pFileOut, ".p %d\n", atoi(pToken) ); + fStart = 1; + } + else if ( fStart ) + fprintf( pFileOut, "%s", pBuffer ); + } + fprintf( pFileOut, ".e\n" ); + fclose( pFileIn ); + fclose( pFileOut ); + ABC_FREE( pBuffer ); +} + //////////////////////////////////////////////////////////////////////// /// END OF FILE /// //////////////////////////////////////////////////////////////////////// -- cgit v1.2.3 From b2aa245eaacb47837d9a9d63b231903888adfe13 Mon Sep 17 00:00:00 2001 From: Alan Mishchenko Date: Fri, 9 Oct 2020 23:28:23 -0700 Subject: Fixing a clang error related to 'unlink'. --- src/base/io/io.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src/base') diff --git a/src/base/io/io.c b/src/base/io/io.c index c2363cb5..63f1b7d1 100644 --- a/src/base/io/io.c +++ b/src/base/io/io.c @@ -25,7 +25,10 @@ #include "sat/bmc/bmc.h" #ifdef WIN32 +#include #define unlink _unlink +#else +#include #endif ABC_NAMESPACE_IMPL_START -- cgit v1.2.3 From f9af41ba1bb6dff04e888c285052a9e1ec6d6456 Mon Sep 17 00:00:00 2001 From: Alan Mishchenko Date: Sat, 31 Oct 2020 15:08:40 -0700 Subject: Adding an option to write Verilog with LUT instances. --- src/base/io/io.c | 22 +++++- src/base/io/ioWriteVerilog.c | 177 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 196 insertions(+), 3 deletions(-) (limited to 'src/base') diff --git a/src/base/io/io.c b/src/base/io/io.c index 63f1b7d1..752efdfd 100644 --- a/src/base/io/io.c +++ b/src/base/io/io.c @@ -2982,14 +2982,27 @@ usage: ***********************************************************************/ int IoCommandWriteVerilog( Abc_Frame_t * pAbc, int argc, char **argv ) { + extern void Io_WriteVerilogLut( Abc_Ntk_t * pNtk, char * pFileName, int nLutSize ); char * pFileName; int c, fOnlyAnds = 0; + int nLutSize = -1; Extra_UtilGetoptReset(); - while ( ( c = Extra_UtilGetopt( argc, argv, "ah" ) ) != EOF ) + while ( ( c = Extra_UtilGetopt( argc, argv, "Kah" ) ) != EOF ) { switch ( c ) { + 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 < 2 || nLutSize > 6 ) + goto usage; + break; case 'a': fOnlyAnds ^= 1; break; @@ -3017,13 +3030,16 @@ int IoCommandWriteVerilog( Abc_Frame_t * pAbc, int argc, char **argv ) Io_WriteVerilog( pNtkTemp, pFileName, 1 ); Abc_NtkDelete( pNtkTemp ); } + else if ( nLutSize >= 2 && nLutSize <= 6 ) + Io_WriteVerilogLut( pAbc->pNtkCur, pFileName, nLutSize ); else - Io_Write( pAbc->pNtkCur, pFileName, IO_FILE_VERILOG ); + Io_Write( pAbc->pNtkCur, pFileName, IO_FILE_VERILOG ); return 0; usage: - fprintf( pAbc->Err, "usage: write_verilog [-ah] \n" ); + fprintf( pAbc->Err, "usage: write_verilog [-K num] [-ah] \n" ); fprintf( pAbc->Err, "\t writes the current network in Verilog format\n" ); + fprintf( pAbc->Err, "\t-K num : write the network using instances of K-LUTs (2 <= K <= %d) [default = not used]\n", 6, nLutSize ); fprintf( pAbc->Err, "\t-a : toggle writing expressions with only ANDs (without XORs and MUXes) [default = %s]\n", fOnlyAnds? "yes":"no" ); fprintf( pAbc->Err, "\t-h : print the help massage\n" ); fprintf( pAbc->Err, "\tfile : the name of the file to write\n" ); diff --git a/src/base/io/ioWriteVerilog.c b/src/base/io/ioWriteVerilog.c index 2e481324..f524690f 100644 --- a/src/base/io/ioWriteVerilog.c +++ b/src/base/io/ioWriteVerilog.c @@ -653,6 +653,183 @@ char * Io_WriteVerilogGetName( char * pName ) return Buffer; } + +/**Function************************************************************* + + Synopsis [Write the network of K-input LUTs.] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +void Io_WriteLutModule( FILE * pFile, int nLutSize ) +{ + fprintf( pFile, "module lut%d #( parameter TT = %d\'h0 ) ( input [%d:0] in, output out );\n", nLutSize, 1<pData; + fprintf( pFile, " %s box%0*d", pNtkBox->pName, nDigits, Counter++ ); + fprintf( pFile, "(" ); + Abc_NtkForEachPi( pNtkBox, pTerm, k ) + { + fprintf( pFile, ".%s", Io_WriteVerilogGetName(Abc_ObjName(Abc_ObjFanout0(pTerm))) ); + fprintf( pFile, "(%s), ", Io_WriteVerilogGetName(Abc_ObjName(Abc_ObjFanin0(Abc_ObjFanin(pObj,k)))) ); + } + Abc_NtkForEachPo( pNtkBox, pTerm, k ) + { + fprintf( pFile, ".%s", Io_WriteVerilogGetName(Abc_ObjName(Abc_ObjFanin0(pTerm))) ); + fprintf( pFile, "(%s)%s", Io_WriteVerilogGetName(Abc_ObjName(Abc_ObjFanout0(Abc_ObjFanout(pObj,k)))), k==Abc_NtkPoNum(pNtkBox)-1? "":", " ); + } + fprintf( pFile, ");\n" ); + } + + // find the longest signal name + Abc_NtkForEachNode( pNtk, pObj, i ) + { + Length = Abc_MaxInt( Length, strlen(Io_WriteVerilogGetName(Abc_ObjName(Abc_ObjFanout0(pObj)))) ); + Abc_ObjForEachFanin( pObj, pTerm, k ) + Length = Abc_MaxInt( Length, strlen(Io_WriteVerilogGetName(Abc_ObjName(pTerm))) ); + } + + // write LUT instances + nDigits = Abc_Base10Log( Abc_NtkNodeNum(pNtk) ); + Counter = 0; + Abc_NtkForEachNode( pNtk, pObj, i ) + { + word Truth = Abc_SopToTruth( (char *)pObj->pData, Abc_ObjFaninNum(pObj) ); + fprintf( pFile, " lut%d #(%d\'h", nLutSize, 1<> 32), (unsigned)Truth ); + else + fprintf( pFile, "%0*x", 1<<(nLutSize-2), Abc_InfoMask(1 << nLutSize) & Truth ); + fprintf( pFile, ") lut_%0*d ( {", nDigits, Counter++ ); + for ( k = nLutSize - 1; k >= Abc_ObjFaninNum(pObj); k-- ) + fprintf( pFile, "%*s, ", Length, "1\'b0" ); + for ( k = Abc_ObjFaninNum(pObj) - 1; k >= 0; k-- ) + fprintf( pFile, "%*s%s", Length, Io_WriteVerilogGetName(Abc_ObjName(Abc_ObjFanin(pObj, k))), k==0 ? "":", " ); + fprintf( pFile, "}, %*s );\n", Length, Io_WriteVerilogGetName(Abc_ObjName(Abc_ObjFanout0(pObj))) ); + } +} +void Io_WriteVerilogLutInt( FILE * pFile, Abc_Ntk_t * pNtk, int nLutSize ) +{ + // write inputs and outputs +// fprintf( pFile, "module %s ( gclk,\n ", Abc_NtkName(pNtk) ); + fprintf( pFile, "module %s ( ", Io_WriteVerilogGetName(Abc_NtkName(pNtk)) ); + // add the clock signal if it does not exist + if ( Abc_NtkLatchNum(pNtk) > 0 && Nm_ManFindIdByName(pNtk->pManName, "clock", ABC_OBJ_PI) == -1 ) + fprintf( pFile, "clock, " ); + // write other primary inputs + fprintf( pFile, "\n " ); + if ( Abc_NtkPiNum(pNtk) > 0 ) + { + Io_WriteVerilogPis( pFile, pNtk, 3 ); + fprintf( pFile, ",\n " ); + } + if ( Abc_NtkPoNum(pNtk) > 0 ) + Io_WriteVerilogPos( pFile, pNtk, 3 ); + fprintf( pFile, " );\n\n" ); + // add the clock signal if it does not exist + if ( Abc_NtkLatchNum(pNtk) > 0 && Nm_ManFindIdByName(pNtk->pManName, "clock", ABC_OBJ_PI) == -1 ) + fprintf( pFile, " input clock;\n" ); + // write inputs, outputs, registers, and wires + if ( Abc_NtkPiNum(pNtk) > 0 ) + { +// fprintf( pFile, " input gclk," ); + fprintf( pFile, " input " ); + Io_WriteVerilogPis( pFile, pNtk, 10 ); + fprintf( pFile, ";\n" ); + } + if ( Abc_NtkPoNum(pNtk) > 0 ) + { + fprintf( pFile, " output" ); + Io_WriteVerilogPos( pFile, pNtk, 5 ); + fprintf( pFile, ";\n\n" ); + } + // if this is not a blackbox, write internal signals + if ( !Abc_NtkHasBlackbox(pNtk) ) + { + if ( Abc_NtkLatchNum(pNtk) > 0 ) + { + fprintf( pFile, " reg" ); + Io_WriteVerilogRegs( pFile, pNtk, 4 ); + fprintf( pFile, ";\n\n" ); + } + if ( Io_WriteVerilogWiresCount(pNtk) > 0 ) + { + fprintf( pFile, " wire" ); + Io_WriteVerilogWires( pFile, pNtk, 4 ); + fprintf( pFile, ";\n\n" ); + } + // write nodes + Io_WriteVerilogObjectsLut( pFile, pNtk, nLutSize ); + // write registers + if ( Abc_NtkLatchNum(pNtk) > 0 ) + { + fprintf( pFile, "\n" ); + Io_WriteVerilogLatches( pFile, pNtk ); + } + } + // finalize the file + fprintf( pFile, "\nendmodule\n\n" ); +} +void Io_WriteVerilogLut( Abc_Ntk_t * pNtk, char * pFileName, int nLutSize ) +{ + FILE * pFile; + Abc_Ntk_t * pNtkTemp; + Abc_Obj_t * pObj; + int i, Counter = 0; + Abc_NtkForEachNode( pNtk, pObj, i ) + if ( Abc_ObjFaninNum(pObj) > nLutSize ) + { + if ( Counter < 3 ) + printf( "Node \"%s\" has the fanin count (%d) larger than the LUT size (%d).\n", Abc_ObjName(pObj), Abc_ObjFaninNum(pObj), nLutSize ); + Counter++; + } + if ( Counter ) + { + printf( "In total, %d internal logic nodes exceeded the fanout count limit.\n", Counter ); + return; + } + + // start the output stream + pFile = fopen( pFileName, "w" ); + if ( pFile == NULL ) + { + fprintf( stdout, "Io_WriteVerilog(): Cannot open the output file \"%s\".\n", pFileName ); + return; + } + + // write the equations for the network + fprintf( pFile, "// Benchmark \"%s\" written by ABC on %s\n", pNtk->pName, Extra_TimeStamp() ); + fprintf( pFile, "\n" ); + Io_WriteLutModule( pFile, nLutSize ); + + pNtkTemp = Abc_NtkToNetlist( pNtk ); + Abc_NtkToSop( pNtkTemp, -1, ABC_INFINITY ); + Io_WriteVerilogLutInt( pFile, pNtkTemp, nLutSize ); + Abc_NtkDelete( pNtkTemp ); + + fprintf( pFile, "\n" ); + fclose( pFile ); +} + //////////////////////////////////////////////////////////////////////// /// END OF FILE /// //////////////////////////////////////////////////////////////////////// -- cgit v1.2.3 From 2325cd77e3d6072b335dd551b3eda2ef20eaa92c Mon Sep 17 00:00:00 2001 From: Alan Mishchenko Date: Sat, 31 Oct 2020 16:14:52 -0700 Subject: Adding an option to write Verilog with LUT instances (compiler warnings). --- src/base/io/io.c | 2 +- src/base/io/ioWriteVerilog.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'src/base') diff --git a/src/base/io/io.c b/src/base/io/io.c index 752efdfd..dec5ee45 100644 --- a/src/base/io/io.c +++ b/src/base/io/io.c @@ -3039,7 +3039,7 @@ int IoCommandWriteVerilog( Abc_Frame_t * pAbc, int argc, char **argv ) usage: fprintf( pAbc->Err, "usage: write_verilog [-K num] [-ah] \n" ); fprintf( pAbc->Err, "\t writes the current network in Verilog format\n" ); - fprintf( pAbc->Err, "\t-K num : write the network using instances of K-LUTs (2 <= K <= %d) [default = not used]\n", 6, nLutSize ); + fprintf( pAbc->Err, "\t-K num : write the network using instances of K-LUTs (2 <= K <= 6) [default = not used]\n" ); fprintf( pAbc->Err, "\t-a : toggle writing expressions with only ANDs (without XORs and MUXes) [default = %s]\n", fOnlyAnds? "yes":"no" ); fprintf( pAbc->Err, "\t-h : print the help massage\n" ); fprintf( pAbc->Err, "\tfile : the name of the file to write\n" ); diff --git a/src/base/io/ioWriteVerilog.c b/src/base/io/ioWriteVerilog.c index f524690f..ad49e93a 100644 --- a/src/base/io/ioWriteVerilog.c +++ b/src/base/io/ioWriteVerilog.c @@ -718,7 +718,7 @@ void Io_WriteVerilogObjectsLut( FILE * pFile, Abc_Ntk_t * pNtk, int nLutSize ) if ( nLutSize == 6 ) fprintf( pFile, "%08x%08x", (unsigned)(Truth >> 32), (unsigned)Truth ); else - fprintf( pFile, "%0*x", 1<<(nLutSize-2), Abc_InfoMask(1 << nLutSize) & Truth ); + fprintf( pFile, "%0*x", 1<<(nLutSize-2), Abc_InfoMask(1 << nLutSize) & (unsigned)Truth ); fprintf( pFile, ") lut_%0*d ( {", nDigits, Counter++ ); for ( k = nLutSize - 1; k >= Abc_ObjFaninNum(pObj); k-- ) fprintf( pFile, "%*s, ", Length, "1\'b0" ); @@ -804,7 +804,7 @@ void Io_WriteVerilogLut( Abc_Ntk_t * pNtk, char * pFileName, int nLutSize ) } if ( Counter ) { - printf( "In total, %d internal logic nodes exceeded the fanout count limit.\n", Counter ); + printf( "In total, %d internal logic nodes exceed the fanin count limit. Verilog is not written.\n", Counter ); return; } -- cgit v1.2.3 From 3a7b3d27f19e1d8b43cfe974b6c8c3ab5c79d351 Mon Sep 17 00:00:00 2001 From: Alan Mishchenko Date: Sun, 1 Nov 2020 09:56:01 -0800 Subject: Experimental cost function in technology mapping. --- src/base/abci/abc.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'src/base') diff --git a/src/base/abci/abc.c b/src/base/abci/abc.c index ab8e3659..71026b28 100644 --- a/src/base/abci/abc.c +++ b/src/base/abci/abc.c @@ -39541,7 +39541,7 @@ int Abc_CommandAbc9Mf( Abc_Frame_t * pAbc, int argc, char ** argv ) Gia_Man_t * pNew; int c; Mf_ManSetDefaultPars( pPars ); Extra_UtilGetoptReset(); - while ( ( c = Extra_UtilGetopt( argc, argv, "KCFARLEDWaekmcgvwh" ) ) != EOF ) + while ( ( c = Extra_UtilGetopt( argc, argv, "KCFARLEDWaekmclgvwh" ) ) != EOF ) { switch ( c ) { @@ -39665,6 +39665,9 @@ int Abc_CommandAbc9Mf( Abc_Frame_t * pAbc, int argc, char ** argv ) case 'c': pPars->fGenCnf ^= 1; break; + case 'l': + pPars->fGenLit ^= 1; + break; case 'g': pPars->fPureAig ^= 1; break; @@ -39717,6 +39720,7 @@ usage: Abc_Print( -2, "\t-k : toggles coarsening the subject graph [default = %s]\n", pPars->fCoarsen? "yes": "no" ); Abc_Print( -2, "\t-m : toggles cut minimization [default = %s]\n", pPars->fCutMin? "yes": "no" ); Abc_Print( -2, "\t-c : toggles mapping for CNF generation [default = %s]\n", pPars->fGenCnf? "yes": "no" ); + Abc_Print( -2, "\t-l : toggles mapping for literals [default = %s]\n", pPars->fGenLit? "yes": "no" ); Abc_Print( -2, "\t-g : toggles generating AIG without mapping [default = %s]\n", pPars->fPureAig? "yes": "no" ); Abc_Print( -2, "\t-v : toggles verbose output [default = %s]\n", pPars->fVerbose? "yes": "no" ); Abc_Print( -2, "\t-w : toggles very verbose output [default = %s]\n", pPars->fVeryVerbose? "yes": "no" ); -- cgit v1.2.3 From ce95366e513631b1b052b55c4f8e2e83ff7e4149 Mon Sep 17 00:00:00 2001 From: Alan Mishchenko Date: Sun, 1 Nov 2020 14:23:17 -0800 Subject: Trying to explicitly compute don't-cares during optimization. --- src/base/abci/abc.c | 16 ++++++++++++---- src/base/io/ioUtil.c | 3 ++- 2 files changed, 14 insertions(+), 5 deletions(-) (limited to 'src/base') diff --git a/src/base/abci/abc.c b/src/base/abci/abc.c index 71026b28..1f21d931 100644 --- a/src/base/abci/abc.c +++ b/src/base/abci/abc.c @@ -5429,7 +5429,7 @@ int Abc_CommandMfs2( Abc_Frame_t * pAbc, int argc, char ** argv ) // set defaults Sfm_ParSetDefault( pPars ); Extra_UtilGetoptReset(); - while ( ( c = Extra_UtilGetopt( argc, argv, "WFDMLCZNIdaeijvwh" ) ) != EOF ) + while ( ( c = Extra_UtilGetopt( argc, argv, "WFDMLCZNIdaeijlvwh" ) ) != EOF ) { switch ( c ) { @@ -5547,6 +5547,9 @@ int Abc_CommandMfs2( Abc_Frame_t * pAbc, int argc, char ** argv ) case 'j': fUseAllFfs ^= 1; break; + case 'l': + pPars->fUseDcs ^= 1; + break; case 'v': pPars->fVerbose ^= 1; break; @@ -5618,7 +5621,7 @@ int Abc_CommandMfs2( Abc_Frame_t * pAbc, int argc, char ** argv ) return 0; usage: - Abc_Print( -2, "usage: mfs2 [-WFDMLCZNI ] [-daeijvwh]\n" ); + Abc_Print( -2, "usage: mfs2 [-WFDMLCZNI ] [-daeijlvwh]\n" ); Abc_Print( -2, "\t performs don't-care-based optimization of logic networks\n" ); Abc_Print( -2, "\t-W : the number of levels in the TFO cone (0 <= num) [default = %d]\n", pPars->nTfoLevMax ); Abc_Print( -2, "\t-F : the max number of fanouts to skip (1 <= num) [default = %d]\n", pPars->nFanoutMax ); @@ -5634,6 +5637,7 @@ usage: Abc_Print( -2, "\t-i : toggle using inductive don't-cares [default = %s]\n", fIndDCs? "yes": "no" ); Abc_Print( -2, "\t-j : toggle using all flops when \"-i\" is enabled [default = %s]\n", fUseAllFfs? "yes": "no" ); Abc_Print( -2, "\t-I : the number of additional frames inserted [default = %d]\n", nFramesAdd ); + Abc_Print( -2, "\t-l : toggle deriving don't-cares [default = %s]\n", pPars->fUseDcs? "yes": "no" ); Abc_Print( -2, "\t-v : toggle printing optimization summary [default = %s]\n", pPars->fVerbose? "yes": "no" ); Abc_Print( -2, "\t-w : toggle printing detailed stats for each node [default = %s]\n", pPars->fVeryVerbose? "yes": "no" ); Abc_Print( -2, "\t-h : print the command usage\n"); @@ -46004,7 +46008,7 @@ int Abc_CommandAbc9Mfs( Abc_Frame_t * pAbc, int argc, char ** argv ) pPars->nDepthMax = 100; pPars->nWinSizeMax = 2000; Extra_UtilGetoptReset(); - while ( ( c = Extra_UtilGetopt( argc, argv, "WFDMLCNdaebvwh" ) ) != EOF ) + while ( ( c = Extra_UtilGetopt( argc, argv, "WFDMLCNdaeblvwh" ) ) != EOF ) { switch ( c ) { @@ -46097,6 +46101,9 @@ int Abc_CommandAbc9Mfs( Abc_Frame_t * pAbc, int argc, char ** argv ) case 'b': pPars->fAllBoxes ^= 1; break; + case 'l': + pPars->fUseDcs ^= 1; + break; case 'v': pPars->fVerbose ^= 1; break; @@ -46141,7 +46148,7 @@ int Abc_CommandAbc9Mfs( Abc_Frame_t * pAbc, int argc, char ** argv ) return 0; usage: - Abc_Print( -2, "usage: &mfs [-WFDMLCN ] [-daebvwh]\n" ); + Abc_Print( -2, "usage: &mfs [-WFDMLCN ] [-daeblvwh]\n" ); Abc_Print( -2, "\t performs don't-care-based optimization of logic networks\n" ); Abc_Print( -2, "\t-W : the number of levels in the TFO cone (0 <= num) [default = %d]\n", pPars->nTfoLevMax ); Abc_Print( -2, "\t-F : the max number of fanouts to skip (1 <= num) [default = %d]\n", pPars->nFanoutMax ); @@ -46154,6 +46161,7 @@ usage: Abc_Print( -2, "\t-a : toggle minimizing area or area+edges [default = %s]\n", pPars->fArea? "area": "area+edges" ); Abc_Print( -2, "\t-e : toggle high-effort resubstitution [default = %s]\n", pPars->fMoreEffort? "yes": "no" ); Abc_Print( -2, "\t-b : toggle preserving all white boxes [default = %s]\n", pPars->fAllBoxes? "yes": "no" ); + Abc_Print( -2, "\t-l : toggle deriving don't-cares [default = %s]\n", pPars->fUseDcs? "yes": "no" ); Abc_Print( -2, "\t-v : toggle printing optimization summary [default = %s]\n", pPars->fVerbose? "yes": "no" ); Abc_Print( -2, "\t-w : toggle printing detailed stats for each node [default = %s]\n", pPars->fVeryVerbose? "yes": "no" ); Abc_Print( -2, "\t-h : print the command usage\n"); diff --git a/src/base/io/ioUtil.c b/src/base/io/ioUtil.c index 01fe4f45..ddfcc91a 100644 --- a/src/base/io/ioUtil.c +++ b/src/base/io/ioUtil.c @@ -899,7 +899,8 @@ void Io_TransformSF2PLA( char * pNameIn, char * pNameOut ) break; if ( strstr(pBuffer, "SDF") ) { - fgets(pBuffer, Size, pFileIn); + char * pRes = fgets(pBuffer, Size, pFileIn); + assert( pRes != NULL ); if ( (pToken = strtok( pBuffer, " \t\r\n" )) ) fprintf( pFileOut, ".i %d\n", atoi(pToken) ); if ( (pToken = strtok( NULL, " \t\r\n" )) ) -- cgit v1.2.3 From 40bfe2fb88b4a4dc32fa280e66f66dcefb4a4b1d Mon Sep 17 00:00:00 2001 From: Alan Mishchenko Date: Mon, 9 Nov 2020 13:24:07 -0800 Subject: Experiments with SAT sweeping. --- src/base/abci/abc.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'src/base') diff --git a/src/base/abci/abc.c b/src/base/abci/abc.c index 1f21d931..408c2266 100644 --- a/src/base/abci/abc.c +++ b/src/base/abci/abc.c @@ -36286,14 +36286,15 @@ int Abc_CommandAbc9Fraig( Abc_Frame_t * pAbc, int argc, char ** argv ) { extern Gia_Man_t * Cec2_ManSimulateTest( Gia_Man_t * p, Cec_ParFra_t * pPars ); extern Gia_Man_t * Cec3_ManSimulateTest( Gia_Man_t * p, Cec_ParFra_t * pPars ); + extern Gia_Man_t * Cec4_ManSimulateTest( Gia_Man_t * p, Cec_ParFra_t * pPars ); Cec_ParFra_t ParsFra, * pPars = &ParsFra; Gia_Man_t * pTemp; - int c, fUseAlgo = 0, fUseAlgoG = 0; + int c, fUseAlgo = 0, fUseAlgoG = 0, fUseAlgoG2 = 0; Cec_ManFraSetDefaultParams( pPars ); pPars->fSatSweeping = 1; pPars->nItersMax = 1000000; Extra_UtilGetoptReset(); - while ( ( c = Extra_UtilGetopt( argc, argv, "WRILDCrmdckngwvh" ) ) != EOF ) + while ( ( c = Extra_UtilGetopt( argc, argv, "WRILDCrmdckngxwvh" ) ) != EOF ) { switch ( c ) { @@ -36384,6 +36385,9 @@ int Abc_CommandAbc9Fraig( Abc_Frame_t * pAbc, int argc, char ** argv ) case 'g': fUseAlgoG ^= 1; break; + case 'x': + fUseAlgoG2 ^= 1; + break; case 'w': pPars->fVeryVerbose ^= 1; break; @@ -36403,6 +36407,8 @@ int Abc_CommandAbc9Fraig( Abc_Frame_t * pAbc, int argc, char ** argv ) pTemp = Cec2_ManSimulateTest( pAbc->pGia, pPars ); else if ( fUseAlgoG ) pTemp = Cec3_ManSimulateTest( pAbc->pGia, pPars ); + else if ( fUseAlgoG2 ) + pTemp = Cec4_ManSimulateTest( pAbc->pGia, pPars ); else pTemp = Cec_ManSatSweeping( pAbc->pGia, pPars, 0 ); Abc_FrameUpdateGia( pAbc, pTemp ); -- cgit v1.2.3 From 3da87edbb4e9cb15540085b98cb370034cc1155d Mon Sep 17 00:00:00 2001 From: Alan Mishchenko Date: Mon, 9 Nov 2020 15:25:32 -0800 Subject: Setting default conflict limit in &fraig to be high. --- src/base/abci/abc.c | 1 + 1 file changed, 1 insertion(+) (limited to 'src/base') diff --git a/src/base/abci/abc.c b/src/base/abci/abc.c index 408c2266..403c8e19 100644 --- a/src/base/abci/abc.c +++ b/src/base/abci/abc.c @@ -36293,6 +36293,7 @@ int Abc_CommandAbc9Fraig( Abc_Frame_t * pAbc, int argc, char ** argv ) Cec_ManFraSetDefaultParams( pPars ); pPars->fSatSweeping = 1; pPars->nItersMax = 1000000; + pPars->nBTLimit = 1000000; Extra_UtilGetoptReset(); while ( ( c = Extra_UtilGetopt( argc, argv, "WRILDCrmdckngxwvh" ) ) != EOF ) { -- cgit v1.2.3 From c0bb4bb0478c233d99ded3c9f478a5d49ff37cf2 Mon Sep 17 00:00:00 2001 From: Alan Mishchenko Date: Tue, 10 Nov 2020 23:15:42 -0800 Subject: Experiments with SAT sweeping. --- src/base/abci/abc.c | 30 +++++++++++++++++++++++------- 1 file changed, 23 insertions(+), 7 deletions(-) (limited to 'src/base') diff --git a/src/base/abci/abc.c b/src/base/abci/abc.c index 403c8e19..2ed1f5ef 100644 --- a/src/base/abci/abc.c +++ b/src/base/abci/abc.c @@ -36287,15 +36287,19 @@ int Abc_CommandAbc9Fraig( Abc_Frame_t * pAbc, int argc, char ** argv ) extern Gia_Man_t * Cec2_ManSimulateTest( Gia_Man_t * p, Cec_ParFra_t * pPars ); extern Gia_Man_t * Cec3_ManSimulateTest( Gia_Man_t * p, Cec_ParFra_t * pPars ); extern Gia_Man_t * Cec4_ManSimulateTest( Gia_Man_t * p, Cec_ParFra_t * pPars ); - Cec_ParFra_t ParsFra, * pPars = &ParsFra; - Gia_Man_t * pTemp; + Cec_ParFra_t ParsFra, * pPars = &ParsFra; Gia_Man_t * pTemp; int c, fUseAlgo = 0, fUseAlgoG = 0, fUseAlgoG2 = 0; Cec_ManFraSetDefaultParams( pPars ); - pPars->fSatSweeping = 1; - pPars->nItersMax = 1000000; - pPars->nBTLimit = 1000000; + pPars->fSatSweeping = 1; // conflict limit at a node + pPars->nWords = 4; // simulation words + pPars->nRounds = 250; // simulation rounds + pPars->nItersMax = 1000000; // this is a miter + pPars->nBTLimit = 1000000; // use logic cones + pPars->nSatVarMax = 1000; // the max number of SAT variables before recycling SAT solver + pPars->nCallsRecycle = 500; // calls to perform before recycling SAT solver + pPars->nGenIters = 5; // pattern generation iterations Extra_UtilGetoptReset(); - while ( ( c = Extra_UtilGetopt( argc, argv, "WRILDCrmdckngxwvh" ) ) != EOF ) + while ( ( c = Extra_UtilGetopt( argc, argv, "WRILDCPrmdckngxwvh" ) ) != EOF ) { switch ( c ) { @@ -36365,6 +36369,17 @@ int Abc_CommandAbc9Fraig( Abc_Frame_t * pAbc, int argc, char ** argv ) if ( pPars->nBTLimit < 0 ) goto usage; break; + case 'P': + if ( globalUtilOptind >= argc ) + { + Abc_Print( -1, "Command line switch \"-P\" should be followed by an integer.\n" ); + goto usage; + } + pPars->nGenIters = atoi(argv[globalUtilOptind]); + globalUtilOptind++; + if ( pPars->nGenIters < 0 ) + goto usage; + break; case 'r': pPars->fRewriting ^= 1; break; @@ -36416,7 +36431,7 @@ int Abc_CommandAbc9Fraig( Abc_Frame_t * pAbc, int argc, char ** argv ) return 0; usage: - Abc_Print( -2, "usage: &fraig [-WRILDC ] [-rmdckngwvh]\n" ); + Abc_Print( -2, "usage: &fraig [-WRILDCP ] [-rmdckngwvh]\n" ); Abc_Print( -2, "\t performs combinational SAT sweeping\n" ); Abc_Print( -2, "\t-W num : the number of simulation words [default = %d]\n", pPars->nWords ); Abc_Print( -2, "\t-R num : the number of simulation rounds [default = %d]\n", pPars->nRounds ); @@ -36424,6 +36439,7 @@ usage: Abc_Print( -2, "\t-L num : the max number of levels of nodes to consider [default = %d]\n", pPars->nLevelMax ); Abc_Print( -2, "\t-D num : the max number of steps of speculative reduction [default = %d]\n", pPars->nDepthMax ); Abc_Print( -2, "\t-C num : the max number of conflicts at a node [default = %d]\n", pPars->nBTLimit ); + Abc_Print( -2, "\t-P num : the number of pattern generation iterations [default = %d]\n", pPars->nGenIters ); Abc_Print( -2, "\t-r : toggle the use of AIG rewriting [default = %s]\n", pPars->fRewriting? "yes": "no" ); Abc_Print( -2, "\t-m : toggle miter vs. any circuit [default = %s]\n", pPars->fCheckMiter? "miter": "circuit" ); Abc_Print( -2, "\t-d : toggle using double output miters [default = %s]\n", pPars->fDualOut? "yes": "no" ); -- cgit v1.2.3 From b3d3f7dd3aeb5c7648caf9c424f6dc341ad27ac0 Mon Sep 17 00:00:00 2001 From: Alan Mishchenko Date: Thu, 12 Nov 2020 23:57:46 -0800 Subject: Duplicating Glucose package. --- src/base/main/mainInit.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src/base') diff --git a/src/base/main/mainInit.c b/src/base/main/mainInit.c index d85d7b67..d7ab7ae2 100644 --- a/src/base/main/mainInit.c +++ b/src/base/main/mainInit.c @@ -65,6 +65,8 @@ extern void Abc85_Init( Abc_Frame_t * pAbc ); extern void Abc85_End( Abc_Frame_t * pAbc ); extern void Glucose_Init( Abc_Frame_t *pAbc ); extern void Glucose_End( Abc_Frame_t * pAbc ); +extern void Glucose2_Init( Abc_Frame_t *pAbc ); +extern void Glucose2_End( Abc_Frame_t * pAbc ); static Abc_FrameInitializer_t* s_InitializerStart = NULL; static Abc_FrameInitializer_t* s_InitializerEnd = NULL; @@ -120,6 +122,7 @@ void Abc_FrameInit( Abc_Frame_t * pAbc ) Sim_Init( pAbc ); Test_Init( pAbc ); Glucose_Init( pAbc ); + Glucose2_Init( pAbc ); for( p = s_InitializerStart ; p ; p = p->next ) if(p->init) p->init(pAbc); -- cgit v1.2.3 From 22388f901a88dddfe629dd3c1406b06fafa9675d Mon Sep 17 00:00:00 2001 From: Alan Mishchenko Date: Fri, 13 Nov 2020 10:29:31 -0800 Subject: Adding and integrating new SAT solver APIs. --- src/base/abci/abc.c | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) (limited to 'src/base') diff --git a/src/base/abci/abc.c b/src/base/abci/abc.c index 2ed1f5ef..8277a0b3 100644 --- a/src/base/abci/abc.c +++ b/src/base/abci/abc.c @@ -36290,6 +36290,7 @@ int Abc_CommandAbc9Fraig( Abc_Frame_t * pAbc, int argc, char ** argv ) Cec_ParFra_t ParsFra, * pPars = &ParsFra; Gia_Man_t * pTemp; int c, fUseAlgo = 0, fUseAlgoG = 0, fUseAlgoG2 = 0; Cec_ManFraSetDefaultParams( pPars ); + pPars->jType = 0; // solver type pPars->fSatSweeping = 1; // conflict limit at a node pPars->nWords = 4; // simulation words pPars->nRounds = 250; // simulation rounds @@ -36299,10 +36300,21 @@ int Abc_CommandAbc9Fraig( Abc_Frame_t * pAbc, int argc, char ** argv ) pPars->nCallsRecycle = 500; // calls to perform before recycling SAT solver pPars->nGenIters = 5; // pattern generation iterations Extra_UtilGetoptReset(); - while ( ( c = Extra_UtilGetopt( argc, argv, "WRILDCPrmdckngxwvh" ) ) != EOF ) + while ( ( c = Extra_UtilGetopt( argc, argv, "JWRILDCPrmdckngxwvh" ) ) != EOF ) { switch ( c ) { + case 'J': + if ( globalUtilOptind >= argc ) + { + Abc_Print( -1, "Command line switch \"-J\" should be followed by an integer.\n" ); + goto usage; + } + pPars->jType = atoi(argv[globalUtilOptind]); + globalUtilOptind++; + if ( pPars->jType < 0 ) + goto usage; + break; case 'W': if ( globalUtilOptind >= argc ) { @@ -36431,8 +36443,9 @@ int Abc_CommandAbc9Fraig( Abc_Frame_t * pAbc, int argc, char ** argv ) return 0; usage: - Abc_Print( -2, "usage: &fraig [-WRILDCP ] [-rmdckngwvh]\n" ); + Abc_Print( -2, "usage: &fraig [-JWRILDCP ] [-rmdckngwvh]\n" ); Abc_Print( -2, "\t performs combinational SAT sweeping\n" ); + Abc_Print( -2, "\t-J num : the solver type [default = %d]\n", pPars->jType ); Abc_Print( -2, "\t-W num : the number of simulation words [default = %d]\n", pPars->nWords ); Abc_Print( -2, "\t-R num : the number of simulation rounds [default = %d]\n", pPars->nRounds ); Abc_Print( -2, "\t-I num : the number of sweeping iterations [default = %d]\n", pPars->nItersMax ); -- cgit v1.2.3 From cc840d8bd83775f911bc373aa3284d518dc050d0 Mon Sep 17 00:00:00 2001 From: Alan Mishchenko Date: Fri, 13 Nov 2020 19:12:34 -0800 Subject: Improvements to the SAT sweeper. --- src/base/abci/abc.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/base') diff --git a/src/base/abci/abc.c b/src/base/abci/abc.c index 8277a0b3..b6b3dba5 100644 --- a/src/base/abci/abc.c +++ b/src/base/abci/abc.c @@ -36292,13 +36292,13 @@ int Abc_CommandAbc9Fraig( Abc_Frame_t * pAbc, int argc, char ** argv ) Cec_ManFraSetDefaultParams( pPars ); pPars->jType = 0; // solver type pPars->fSatSweeping = 1; // conflict limit at a node - pPars->nWords = 4; // simulation words - pPars->nRounds = 250; // simulation rounds + pPars->nWords = 8; // simulation words + pPars->nRounds = 10; // simulation rounds pPars->nItersMax = 1000000; // this is a miter pPars->nBTLimit = 1000000; // use logic cones pPars->nSatVarMax = 1000; // the max number of SAT variables before recycling SAT solver pPars->nCallsRecycle = 500; // calls to perform before recycling SAT solver - pPars->nGenIters = 5; // pattern generation iterations + pPars->nGenIters = 100; // pattern generation iterations Extra_UtilGetoptReset(); while ( ( c = Extra_UtilGetopt( argc, argv, "JWRILDCPrmdckngxwvh" ) ) != EOF ) { -- cgit v1.2.3 From bab4c1ddfc3e7bb88d649daed8bd412a98850cf9 Mon Sep 17 00:00:00 2001 From: Alan Mishchenko Date: Sat, 14 Nov 2020 14:23:49 -0800 Subject: Upgrading the SAT solvers. --- src/base/abci/abc.c | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) (limited to 'src/base') diff --git a/src/base/abci/abc.c b/src/base/abci/abc.c index b6b3dba5..e7026d74 100644 --- a/src/base/abci/abc.c +++ b/src/base/abci/abc.c @@ -36290,7 +36290,7 @@ int Abc_CommandAbc9Fraig( Abc_Frame_t * pAbc, int argc, char ** argv ) Cec_ParFra_t ParsFra, * pPars = &ParsFra; Gia_Man_t * pTemp; int c, fUseAlgo = 0, fUseAlgoG = 0, fUseAlgoG2 = 0; Cec_ManFraSetDefaultParams( pPars ); - pPars->jType = 0; // solver type + pPars->jType = 2; // solver type pPars->fSatSweeping = 1; // conflict limit at a node pPars->nWords = 8; // simulation words pPars->nRounds = 10; // simulation rounds @@ -36300,7 +36300,7 @@ int Abc_CommandAbc9Fraig( Abc_Frame_t * pAbc, int argc, char ** argv ) pPars->nCallsRecycle = 500; // calls to perform before recycling SAT solver pPars->nGenIters = 100; // pattern generation iterations Extra_UtilGetoptReset(); - while ( ( c = Extra_UtilGetopt( argc, argv, "JWRILDCPrmdckngxwvh" ) ) != EOF ) + while ( ( c = Extra_UtilGetopt( argc, argv, "JWRILDCNPrmdckngxwvh" ) ) != EOF ) { switch ( c ) { @@ -36381,6 +36381,17 @@ int Abc_CommandAbc9Fraig( Abc_Frame_t * pAbc, int argc, char ** argv ) if ( pPars->nBTLimit < 0 ) goto usage; break; + case 'N': + if ( globalUtilOptind >= argc ) + { + Abc_Print( -1, "Command line switch \"-N\" should be followed by an integer.\n" ); + goto usage; + } + pPars->nCallsRecycle = atoi(argv[globalUtilOptind]); + globalUtilOptind++; + if ( pPars->nCallsRecycle < 0 ) + goto usage; + break; case 'P': if ( globalUtilOptind >= argc ) { @@ -36443,7 +36454,7 @@ int Abc_CommandAbc9Fraig( Abc_Frame_t * pAbc, int argc, char ** argv ) return 0; usage: - Abc_Print( -2, "usage: &fraig [-JWRILDCP ] [-rmdckngwvh]\n" ); + Abc_Print( -2, "usage: &fraig [-JWRILDCNP ] [-rmdckngwvh]\n" ); Abc_Print( -2, "\t performs combinational SAT sweeping\n" ); Abc_Print( -2, "\t-J num : the solver type [default = %d]\n", pPars->jType ); Abc_Print( -2, "\t-W num : the number of simulation words [default = %d]\n", pPars->nWords ); @@ -36452,6 +36463,7 @@ usage: Abc_Print( -2, "\t-L num : the max number of levels of nodes to consider [default = %d]\n", pPars->nLevelMax ); Abc_Print( -2, "\t-D num : the max number of steps of speculative reduction [default = %d]\n", pPars->nDepthMax ); Abc_Print( -2, "\t-C num : the max number of conflicts at a node [default = %d]\n", pPars->nBTLimit ); + Abc_Print( -2, "\t-N num : the min number of calls to recycle the solver [default = %d]\n", pPars->nCallsRecycle ); Abc_Print( -2, "\t-P num : the number of pattern generation iterations [default = %d]\n", pPars->nGenIters ); Abc_Print( -2, "\t-r : toggle the use of AIG rewriting [default = %s]\n", pPars->fRewriting? "yes": "no" ); Abc_Print( -2, "\t-m : toggle miter vs. any circuit [default = %s]\n", pPars->fCheckMiter? "miter": "circuit" ); -- cgit v1.2.3 From dd07ec57be48b79d07b39d4e5607f4178a32dc1b Mon Sep 17 00:00:00 2001 From: Alan Mishchenko Date: Sun, 15 Nov 2020 19:02:41 -0800 Subject: Extending sweeper to handle XORs. --- src/base/abci/abc.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/base') diff --git a/src/base/abci/abc.c b/src/base/abci/abc.c index e7026d74..7bf97aa6 100644 --- a/src/base/abci/abc.c +++ b/src/base/abci/abc.c @@ -36292,9 +36292,9 @@ int Abc_CommandAbc9Fraig( Abc_Frame_t * pAbc, int argc, char ** argv ) Cec_ManFraSetDefaultParams( pPars ); pPars->jType = 2; // solver type pPars->fSatSweeping = 1; // conflict limit at a node - pPars->nWords = 8; // simulation words + pPars->nWords = 4; // simulation words pPars->nRounds = 10; // simulation rounds - pPars->nItersMax = 1000000; // this is a miter + pPars->nItersMax = 2000; // this is a miter pPars->nBTLimit = 1000000; // use logic cones pPars->nSatVarMax = 1000; // the max number of SAT variables before recycling SAT solver pPars->nCallsRecycle = 500; // calls to perform before recycling SAT solver -- cgit v1.2.3 From 48f71adacd7727280498f414ad992257c23d76d7 Mon Sep 17 00:00:00 2001 From: Alan Mishchenko Date: Thu, 19 Nov 2020 19:22:27 -0800 Subject: Integration with several commands. --- src/base/abci/abc.c | 59 +++++++++++++++++++++++++++++++++++++---------------- 1 file changed, 41 insertions(+), 18 deletions(-) (limited to 'src/base') diff --git a/src/base/abci/abc.c b/src/base/abci/abc.c index 7bf97aa6..2819195f 100644 --- a/src/base/abci/abc.c +++ b/src/base/abci/abc.c @@ -36284,21 +36284,13 @@ usage: ***********************************************************************/ int Abc_CommandAbc9Fraig( Abc_Frame_t * pAbc, int argc, char ** argv ) { + extern void Cec4_ManSetParams( Cec_ParFra_t * pPars ); extern Gia_Man_t * Cec2_ManSimulateTest( Gia_Man_t * p, Cec_ParFra_t * pPars ); extern Gia_Man_t * Cec3_ManSimulateTest( Gia_Man_t * p, Cec_ParFra_t * pPars ); extern Gia_Man_t * Cec4_ManSimulateTest( Gia_Man_t * p, Cec_ParFra_t * pPars ); Cec_ParFra_t ParsFra, * pPars = &ParsFra; Gia_Man_t * pTemp; int c, fUseAlgo = 0, fUseAlgoG = 0, fUseAlgoG2 = 0; - Cec_ManFraSetDefaultParams( pPars ); - pPars->jType = 2; // solver type - pPars->fSatSweeping = 1; // conflict limit at a node - pPars->nWords = 4; // simulation words - pPars->nRounds = 10; // simulation rounds - pPars->nItersMax = 2000; // this is a miter - pPars->nBTLimit = 1000000; // use logic cones - pPars->nSatVarMax = 1000; // the max number of SAT variables before recycling SAT solver - pPars->nCallsRecycle = 500; // calls to perform before recycling SAT solver - pPars->nGenIters = 100; // pattern generation iterations + Cec4_ManSetParams( pPars ); Extra_UtilGetoptReset(); while ( ( c = Extra_UtilGetopt( argc, argv, "JWRILDCNPrmdckngxwvh" ) ) != EOF ) { @@ -37034,10 +37026,10 @@ int Abc_CommandAbc9Cec( Abc_Frame_t * pAbc, int argc, char ** argv ) FILE * pFile; Gia_Man_t * pGias[2] = {NULL, NULL}, * pMiter; char ** pArgvNew; - int c, nArgcNew, fMiter = 0, fDualOutput = 0, fDumpMiter = 0; + int c, nArgcNew, fUseNew = 0, fMiter = 0, fDualOutput = 0, fDumpMiter = 0; Cec_ManCecSetDefaultParams( pPars ); Extra_UtilGetoptReset(); - while ( ( c = Extra_UtilGetopt( argc, argv, "CTnmdasvwh" ) ) != EOF ) + while ( ( c = Extra_UtilGetopt( argc, argv, "CTnmdasxvwh" ) ) != EOF ) { switch ( c ) { @@ -37078,6 +37070,9 @@ int Abc_CommandAbc9Cec( Abc_Frame_t * pAbc, int argc, char ** argv ) case 's': pPars->fSilent ^= 1; break; + case 'x': + fUseNew ^= 1; + break; case 'v': pPars->fVerbose ^= 1; break; @@ -37216,7 +37211,7 @@ int Abc_CommandAbc9Cec( Abc_Frame_t * pAbc, int argc, char ** argv ) } } // compute the miter - pMiter = Gia_ManMiter( pGias[0], pGias[1], 0, 1, 0, 0, pPars->fVerbose ); + pMiter = Gia_ManMiter( pGias[0], pGias[1], 0, !fUseNew, 0, 0, pPars->fVerbose ); if ( pMiter ) { if ( fDumpMiter ) @@ -37229,8 +37224,23 @@ int Abc_CommandAbc9Cec( Abc_Frame_t * pAbc, int argc, char ** argv ) pMiter->vSimsPi = Vec_WrdDup(pGias[0]->vSimsPi); pMiter->nSimWords = pGias[0]->nSimWords; } - pAbc->Status = Cec_ManVerify( pMiter, pPars ); - Abc_FrameReplaceCex( pAbc, &pGias[0]->pCexComb ); + if ( fUseNew ) + { + abctime clk = Abc_Clock(); + extern Gia_Man_t * Cec4_ManSimulateTest3( Gia_Man_t * p, int fVerbose ); + Gia_Man_t * pNew = Cec4_ManSimulateTest3( pMiter, pPars->fVerbose ); + if ( Gia_ManAndNum(pNew) == 0 ) + Abc_Print( 1, "Networks are equivalent. " ); + else + Abc_Print( 1, "Networks are NOT EQUIVALENT. " ); + Abc_PrintTime( 1, "Time", Abc_Clock() - clk ); + Gia_ManStop( pNew ); + } + else + { + pAbc->Status = Cec_ManVerify( pMiter, pPars ); + Abc_FrameReplaceCex( pAbc, &pGias[0]->pCexComb ); + } Gia_ManStop( pMiter ); } if ( pGias[0] != pAbc->pGia ) @@ -37239,7 +37249,7 @@ int Abc_CommandAbc9Cec( Abc_Frame_t * pAbc, int argc, char ** argv ) return 0; usage: - Abc_Print( -2, "usage: &cec [-CT num] [-nmdasvwh]\n" ); + Abc_Print( -2, "usage: &cec [-CT num] [-nmdasxvwh]\n" ); Abc_Print( -2, "\t new combinational equivalence checker\n" ); Abc_Print( -2, "\t-C num : the max number of conflicts at a node [default = %d]\n", pPars->nBTLimit ); Abc_Print( -2, "\t-T num : approximate runtime limit in seconds [default = %d]\n", pPars->TimeLimit ); @@ -37248,6 +37258,7 @@ usage: Abc_Print( -2, "\t-d : toggle using dual output miter [default = %s]\n", fDualOutput? "yes":"no"); Abc_Print( -2, "\t-a : toggle writing dual-output miter [default = %s]\n", fDumpMiter? "yes":"no"); Abc_Print( -2, "\t-s : toggle silent operation [default = %s]\n", pPars->fSilent ? "yes":"no"); + Abc_Print( -2, "\t-x : toggle using new solver [default = %s]\n", fUseNew? "yes":"no"); Abc_Print( -2, "\t-v : toggle verbose output [default = %s]\n", pPars->fVerbose? "yes":"no"); Abc_Print( -2, "\t-w : toggle printing SAT solver statistics [default = %s]\n", pPars->fVeryVerbose? "yes":"no"); Abc_Print( -2, "\t-h : print the command usage\n"); @@ -40970,7 +40981,7 @@ int Abc_CommandAbc9Dch( Abc_Frame_t * pAbc, int argc, char ** argv ) // set defaults Dch_ManSetDefaultParams( pPars ); Extra_UtilGetoptReset(); - while ( ( c = Extra_UtilGetopt( argc, argv, "WCSsptfremvh" ) ) != EOF ) + while ( ( c = Extra_UtilGetopt( argc, argv, "WCSsptfremgcxvh" ) ) != EOF ) { switch ( c ) { @@ -41028,6 +41039,15 @@ int Abc_CommandAbc9Dch( Abc_Frame_t * pAbc, int argc, char ** argv ) case 'm': fMinLevel ^= 1; break; + case 'g': + pPars->fUseGia ^= 1; + break; + case 'c': + pPars->fUseCSat ^= 1; + break; + case 'x': + pPars->fUseNew ^= 1; + break; case 'v': pPars->fVerbose ^= 1; break; @@ -41067,7 +41087,7 @@ int Abc_CommandAbc9Dch( Abc_Frame_t * pAbc, int argc, char ** argv ) return 0; usage: - Abc_Print( -2, "usage: &dch [-WCS num] [-sptfremvh]\n" ); + Abc_Print( -2, "usage: &dch [-WCS num] [-sptfremgcxvh]\n" ); Abc_Print( -2, "\t computes structural choices using a new approach\n" ); Abc_Print( -2, "\t-W num : the max number of simulation words [default = %d]\n", pPars->nWords ); Abc_Print( -2, "\t-C num : the max number of conflicts at a node [default = %d]\n", pPars->nBTLimit ); @@ -41079,6 +41099,9 @@ usage: Abc_Print( -2, "\t-r : toggle skipping choices with redundant support [default = %s]\n", pPars->fSkipRedSupp? "yes": "no" ); Abc_Print( -2, "\t-e : toggle computing and merging equivalences [default = %s]\n", fEquiv? "yes": "no" ); Abc_Print( -2, "\t-m : toggle minimizing logic level after merging equivalences [default = %s]\n", fMinLevel? "yes": "no" ); + Abc_Print( -2, "\t-g : toggle using GIA to prove equivalences [default = %s]\n", pPars->fUseGia? "yes": "no" ); + Abc_Print( -2, "\t-c : toggle using circuit-based SAT vs. MiniSat [default = %s]\n", pPars->fUseCSat? "yes": "no" ); + Abc_Print( -2, "\t-x : toggle using new choice computation [default = %s]\n", pPars->fUseNew? "yes": "no" ); Abc_Print( -2, "\t-v : toggle verbose printout [default = %s]\n", pPars->fVerbose? "yes": "no" ); Abc_Print( -2, "\t-h : print the command usage\n"); return 1; -- cgit v1.2.3 From 2e92256fb7bb64454a9f2c7b0bf8d1020b0ac78f Mon Sep 17 00:00:00 2001 From: Alan Mishchenko Date: Sun, 22 Nov 2020 21:34:33 -1000 Subject: Passing conflict limit to &cec. --- src/base/abci/abc.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/base') diff --git a/src/base/abci/abc.c b/src/base/abci/abc.c index 2819195f..206e668c 100644 --- a/src/base/abci/abc.c +++ b/src/base/abci/abc.c @@ -37227,8 +37227,8 @@ int Abc_CommandAbc9Cec( Abc_Frame_t * pAbc, int argc, char ** argv ) if ( fUseNew ) { abctime clk = Abc_Clock(); - extern Gia_Man_t * Cec4_ManSimulateTest3( Gia_Man_t * p, int fVerbose ); - Gia_Man_t * pNew = Cec4_ManSimulateTest3( pMiter, pPars->fVerbose ); + extern Gia_Man_t * Cec4_ManSimulateTest3( Gia_Man_t * p, int nBTLimit, int fVerbose ); + Gia_Man_t * pNew = Cec4_ManSimulateTest3( pMiter, pPars->nBTLimit, pPars->fVerbose ); if ( Gia_ManAndNum(pNew) == 0 ) Abc_Print( 1, "Networks are equivalent. " ); else -- cgit v1.2.3 From 22f36299aa6597cb5716bb73e94f56cd8f74ca04 Mon Sep 17 00:00:00 2001 From: Alan Mishchenko Date: Sun, 22 Nov 2020 23:02:35 -1000 Subject: Added an option to keep PI/PO names unchanged in 'short_names'. --- src/base/abc/abc.h | 1 + src/base/abc/abcNames.c | 11 +++++++++++ src/base/abci/abc.c | 15 +++++++++++---- 3 files changed, 23 insertions(+), 4 deletions(-) (limited to 'src/base') diff --git a/src/base/abc/abc.h b/src/base/abc/abc.h index c36bde70..65ab604c 100644 --- a/src/base/abc/abc.h +++ b/src/base/abc/abc.h @@ -752,6 +752,7 @@ extern ABC_DLL void Abc_NtkAddDummyPiNames( Abc_Ntk_t * pNtk ); extern ABC_DLL void Abc_NtkAddDummyPoNames( Abc_Ntk_t * pNtk ); extern ABC_DLL void Abc_NtkAddDummyBoxNames( Abc_Ntk_t * pNtk ); extern ABC_DLL void Abc_NtkShortNames( Abc_Ntk_t * pNtk ); +extern ABC_DLL void Abc_NtkCleanNames( Abc_Ntk_t * pNtk ); extern ABC_DLL void Abc_NtkStartNameIds( Abc_Ntk_t * p ); extern ABC_DLL void Abc_NtkTransferNameIds( Abc_Ntk_t * p, Abc_Ntk_t * pNew ); extern ABC_DLL void Abc_NtkUpdateNameIds( Abc_Ntk_t * p ); diff --git a/src/base/abc/abcNames.c b/src/base/abc/abcNames.c index fe9b3dca..dec5f01e 100644 --- a/src/base/abc/abcNames.c +++ b/src/base/abc/abcNames.c @@ -606,6 +606,17 @@ void Abc_NtkShortNames( Abc_Ntk_t * pNtk ) Abc_NtkAddDummyPoNames( pNtk ); Abc_NtkAddDummyBoxNames( pNtk ); } +void Abc_NtkCleanNames( Abc_Ntk_t * pNtk ) +{ + Abc_Obj_t * pObj; int i; + Nm_Man_t * pManName = Nm_ManCreate( Abc_NtkCiNum(pNtk) + Abc_NtkCoNum(pNtk) + Abc_NtkBoxNum(pNtk) ); + Abc_NtkForEachCi( pNtk, pObj, i ) + Nm_ManStoreIdName( pManName, pObj->Id, pObj->Type, Abc_ObjName(pObj), NULL ); + Abc_NtkForEachCo( pNtk, pObj, i ) + Nm_ManStoreIdName( pManName, pObj->Id, pObj->Type, Abc_ObjName(pObj), NULL ); + Nm_ManFree( pNtk->pManName ); + pNtk->pManName = pManName; +} /**Function************************************************************* diff --git a/src/base/abci/abc.c b/src/base/abci/abc.c index 206e668c..144a6bd0 100644 --- a/src/base/abci/abc.c +++ b/src/base/abci/abc.c @@ -12196,13 +12196,16 @@ usage: int Abc_CommandShortNames( Abc_Frame_t * pAbc, int argc, char ** argv ) { Abc_Ntk_t * pNtk = Abc_FrameReadNtk(pAbc); - int c; + int c, fKeepIo = 0; // set defaults Extra_UtilGetoptReset(); - while ( ( c = Extra_UtilGetopt( argc, argv, "h" ) ) != EOF ) + while ( ( c = Extra_UtilGetopt( argc, argv, "kh" ) ) != EOF ) { switch ( c ) { + case 'k': + fKeepIo ^= 1; + break; case 'h': goto usage; default: @@ -12215,12 +12218,16 @@ int Abc_CommandShortNames( Abc_Frame_t * pAbc, int argc, char ** argv ) Abc_Print( -1, "Empty network.\n" ); return 1; } - Abc_NtkShortNames( pNtk ); + if ( fKeepIo ) + Abc_NtkCleanNames( pNtk ); + else + Abc_NtkShortNames( pNtk ); return 0; usage: - Abc_Print( -2, "usage: short_names [-h]\n" ); + Abc_Print( -2, "usage: short_names [-kh]\n" ); Abc_Print( -2, "\t replaces PI/PO/latch names by short char strings\n" ); + Abc_Print( -2, "\t-k : toggle keeping PI/PO names unchanged [default = %s]\n", fKeepIo? "yes": "no" ); Abc_Print( -2, "\t-h : print the command usage\n"); return 1; } -- cgit v1.2.3 From d4fb192575cd319de68764eac5b7e049f575f43e Mon Sep 17 00:00:00 2001 From: Alan Mishchenko Date: Mon, 23 Nov 2020 07:31:54 -1000 Subject: Renaming one command. --- src/base/abci/abc.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/base') diff --git a/src/base/abci/abc.c b/src/base/abci/abc.c index 144a6bd0..f1a93979 100644 --- a/src/base/abci/abc.c +++ b/src/base/abci/abc.c @@ -862,7 +862,7 @@ void Abc_Init( Abc_Frame_t * pAbc ) Cmd_CommandAdd( pAbc, "Synthesis", "runeco", Abc_CommandRunEco, 0 ); Cmd_CommandAdd( pAbc, "Synthesis", "rungen", Abc_CommandRunGen, 0 ); Cmd_CommandAdd( pAbc, "Synthesis", "runsim", Abc_CommandRunSim, 0 ); - Cmd_CommandAdd( pAbc, "Synthesis", "runtest", Abc_CommandRunTest, 0 ); + Cmd_CommandAdd( pAbc, "Synthesis", "xec", Abc_CommandRunTest, 0 ); Cmd_CommandAdd( pAbc, "Synthesis", "rewrite", Abc_CommandRewrite, 1 ); Cmd_CommandAdd( pAbc, "Synthesis", "refactor", Abc_CommandRefactor, 1 ); @@ -7370,8 +7370,8 @@ int Abc_CommandRunTest( Abc_Frame_t * pAbc, int argc, char ** argv ) return 0; usage: - Abc_Print( -2, "usage: runtest [-fvh] \n" ); - Abc_Print( -2, "\t experimental simulation command\n" ); + Abc_Print( -2, "usage: xec [-fvh] \n" ); + Abc_Print( -2, "\t combinational equivalence checking with x-values\n" ); Abc_Print( -2, "\t-f : toggle using experimental feature [default = %s]\n", fFancy? "yes": "no" ); 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"); -- cgit v1.2.3 From 6eee09c51cb44a71293c9d2dbeea52cd9e3af321 Mon Sep 17 00:00:00 2001 From: Alan Mishchenko Date: Sun, 29 Nov 2020 13:46:21 -1000 Subject: Added switch -y to control blasting divide-by-zero condition. --- src/base/wlc/wlc.h | 2 ++ src/base/wlc/wlcBlast.c | 2 +- src/base/wlc/wlcCom.c | 8 ++++++-- 3 files changed, 9 insertions(+), 3 deletions(-) (limited to 'src/base') diff --git a/src/base/wlc/wlc.h b/src/base/wlc/wlc.h index 0a4f745c..0b3bed6c 100644 --- a/src/base/wlc/wlc.h +++ b/src/base/wlc/wlc.h @@ -217,6 +217,7 @@ struct Wlc_BstPar_t_ int fBooth; int fNonRest; int fCla; + int fDivBy0; int fNoCleanup; int fCreateMiter; int fCreateWordMiter; @@ -238,6 +239,7 @@ static inline void Wlc_BstParDefault( Wlc_BstPar_t * pPar ) pPar->fMulti = 0; pPar->fBooth = 0; pPar->fCla = 0; + pPar->fDivBy0 = 0; pPar->fCreateMiter = 0; pPar->fCreateWordMiter = 0; pPar->fDecMuxes = 0; diff --git a/src/base/wlc/wlcBlast.c b/src/base/wlc/wlcBlast.c index 3a01e238..aec80a2c 100644 --- a/src/base/wlc/wlcBlast.c +++ b/src/base/wlc/wlcBlast.c @@ -1815,7 +1815,7 @@ Gia_Man_t * Wlc_NtkBitBlast( Wlc_Ntk_t * p, Wlc_BstPar_t * pParIn ) else Wlc_BlastDivider( pNew, pArg0, nRangeMax, pArg1, nRangeMax, pObj->Type == WLC_OBJ_ARI_DIVIDE, vRes ); Vec_IntShrink( vRes, nRange ); - //if ( pObj->Type == WLC_OBJ_ARI_DIVIDE ) + if ( !pPar->fDivBy0 ) Wlc_BlastZeroCondition( pNew, pFans1, nRange1, vRes ); } else if ( pObj->Type == WLC_OBJ_ARI_MINUS ) diff --git a/src/base/wlc/wlcCom.c b/src/base/wlc/wlcCom.c index 51f15597..e6294f41 100644 --- a/src/base/wlc/wlcCom.c +++ b/src/base/wlc/wlcCom.c @@ -1037,7 +1037,7 @@ int Abc_CommandBlast( Abc_Frame_t * pAbc, int argc, char ** argv ) Wlc_BstParDefault( pPar ); pPar->nOutputRange = 2; Extra_UtilGetoptReset(); - while ( ( c = Extra_UtilGetopt( argc, argv, "ORAMcombqadestnizvh" ) ) != EOF ) + while ( ( c = Extra_UtilGetopt( argc, argv, "ORAMcombqaydestnizvh" ) ) != EOF ) { switch ( c ) { @@ -1103,6 +1103,9 @@ int Abc_CommandBlast( Abc_Frame_t * pAbc, int argc, char ** argv ) case 'a': pPar->fCla ^= 1; break; + case 'y': + pPar->fDivBy0 ^= 1; + break; case 'd': pPar->fCreateMiter ^= 1; break; @@ -1198,7 +1201,7 @@ int Abc_CommandBlast( Abc_Frame_t * pAbc, int argc, char ** argv ) Abc_FrameUpdateGia( pAbc, pNew ); return 0; usage: - Abc_Print( -2, "usage: %%blast [-ORAM num] [-combqadestnizvh]\n" ); + Abc_Print( -2, "usage: %%blast [-ORAM num] [-combqaydestnizvh]\n" ); Abc_Print( -2, "\t performs bit-blasting of the word-level design\n" ); Abc_Print( -2, "\t-O num : zero-based index of the first word-level PO to bit-blast [default = %d]\n", pPar->iOutput ); Abc_Print( -2, "\t-R num : the total number of word-level POs to bit-blast [default = %d]\n", pPar->nOutputRange ); @@ -1210,6 +1213,7 @@ usage: Abc_Print( -2, "\t-b : toggle generating radix-4 Booth multipliers [default = %s]\n", pPar->fBooth? "yes": "no" ); Abc_Print( -2, "\t-q : toggle generating non-restoring square root [default = %s]\n", pPar->fNonRest? "yes": "no" ); Abc_Print( -2, "\t-a : toggle generating carry-look-ahead adder [default = %s]\n", pPar->fCla? "yes": "no" ); + Abc_Print( -2, "\t-y : toggle creating different divide-by-0 condition [default = %s]\n", pPar->fDivBy0? "yes": "no" ); Abc_Print( -2, "\t-d : toggle creating dual-output multi-output miter [default = %s]\n", pPar->fCreateMiter? "yes": "no" ); Abc_Print( -2, "\t-e : toggle creating miter with output word bits combined [default = %s]\n", pPar->fCreateWordMiter? "yes": "no" ); Abc_Print( -2, "\t-s : toggle creating decoded MUXes [default = %s]\n", pPar->fDecMuxes? "yes": "no" ); -- cgit v1.2.3 From 5b8e56b2e51ea01a54f668d9ec139f37f7fec10f Mon Sep 17 00:00:00 2001 From: Alan Mishchenko Date: Mon, 7 Dec 2020 17:15:31 -1000 Subject: Adding timeout to several commands. --- src/base/abci/abc.c | 44 ++++++++++++++++++++++++++++++++++---------- src/base/acb/acbFunc.c | 17 +++++++++++++---- src/base/acb/acbUtil.c | 10 +++++----- 3 files changed, 52 insertions(+), 19 deletions(-) (limited to 'src/base') diff --git a/src/base/abci/abc.c b/src/base/abci/abc.c index f1a93979..fd108107 100644 --- a/src/base/abci/abc.c +++ b/src/base/abci/abc.c @@ -7067,14 +7067,25 @@ usage: ***********************************************************************/ int Abc_CommandRunEco( Abc_Frame_t * pAbc, int argc, char ** argv ) { - extern void Acb_NtkRunEco( char * pFileNames[4], int fCheck, int fRandom, int fInputs, int fVerbose, int fVeryVerbose ); + extern void Acb_NtkRunEco( char * pFileNames[4], int nTimeout, int fCheck, int fRandom, int fInputs, int fVerbose, int fVeryVerbose ); char * pFileNames[4] = {NULL}; - int c, fCheck = 0, fRandom = 0, fInputs = 0, fVerbose = 0, fVeryVerbose = 0; + int c, nTimeout = 0, fCheck = 0, fRandom = 0, fInputs = 0, fVerbose = 0, fVeryVerbose = 0; Extra_UtilGetoptReset(); - while ( ( c = Extra_UtilGetopt( argc, argv, "crivwh" ) ) != EOF ) + while ( ( c = Extra_UtilGetopt( argc, argv, "Tcrivwh" ) ) != EOF ) { switch ( c ) { + case 'T': + if ( globalUtilOptind >= argc ) + { + Abc_Print( -1, "Command line switch \"-T\" should be followed by an integer.\n" ); + goto usage; + } + nTimeout = atoi(argv[globalUtilOptind]); + globalUtilOptind++; + if ( nTimeout < 0 ) + goto usage; + break; case 'c': fCheck ^= 1; break; @@ -7115,11 +7126,11 @@ int Abc_CommandRunEco( Abc_Frame_t * pAbc, int argc, char ** argv ) fclose( pFile ); pFileNames[c] = argv[globalUtilOptind+c]; } - Acb_NtkRunEco( pFileNames, fCheck, fRandom, fInputs, fVerbose, fVeryVerbose ); + Acb_NtkRunEco( pFileNames, nTimeout, fCheck, fRandom, fInputs, fVerbose, fVeryVerbose ); return 0; usage: - Abc_Print( -2, "usage: runeco [-crivwh] \n" ); + Abc_Print( -2, "usage: runeco [-T num] [-crivwh] \n" ); Abc_Print( -2, "\t performs computation of patch functions during ECO,\n" ); Abc_Print( -2, "\t as described in the following paper: A. Q. Dao et al\n" ); Abc_Print( -2, "\t \"Efficient computation of ECO patch functions\", Proc. DAC\'18\n" ); @@ -7127,6 +7138,7 @@ usage: Abc_Print( -2, "\t (currently only applicable to benchmarks from 2017 ICCAD CAD competition\n" ); Abc_Print( -2, "\t http://cad-contest-2017.el.cycu.edu.tw/Problem_A/default.html as follows:\n" ); Abc_Print( -2, "\t \"runeco unit1/F.v unit1/G.v unit1/weight.txt; cec -n out.v unit1/G.v\")\n" ); + Abc_Print( -2, "\t-T num : the timeout in seconds [default = %d]\n", nTimeout ); Abc_Print( -2, "\t-c : toggle checking that the problem has a solution [default = %s]\n", fCheck? "yes": "no" ); Abc_Print( -2, "\t-r : toggle using random permutation of support variables [default = %s]\n", fRandom? "yes": "no" ); Abc_Print( -2, "\t-i : toggle using primary inputs as support variables [default = %s]\n", fInputs? "yes": "no" ); @@ -7198,14 +7210,25 @@ usage: ***********************************************************************/ int Abc_CommandRunSim( Abc_Frame_t * pAbc, int argc, char ** argv ) { - extern void Acb_NtkRunSim( char * pFileName[4], int nWords, int nBeam, int LevL, int LevU, int fOrder, int fFancy, int fUseBuf, int fRandom, int fUseWeights, int fInputs, int fSkipMffc, int fVerbose, int fVeryVerbose ); + extern void Acb_NtkRunSim( char * pFileName[4], int nTimeout, int nWords, int nBeam, int LevL, int LevU, int fOrder, int fFancy, int fUseBuf, int fRandom, int fUseWeights, int fInputs, int fSkipMffc, int fVerbose, int fVeryVerbose ); char * pFileNames[4] = {NULL, NULL, "out.v", NULL}; - int c, nWords = 8, nBeam = 4, LevL = -1, LevU = -1, fOrder = 0, fFancy = 0, fUseBuf = 0, fRandom = 0, fUseWeights = 0, fInputs = 0, fSkipMffc = 0, fVerbose = 0, fVeryVerbose = 0; + int c, nTimeout = 0, nWords = 8, nBeam = 4, LevL = -1, LevU = -1, fOrder = 0, fFancy = 0, fUseBuf = 0, fRandom = 0, fUseWeights = 0, fInputs = 0, fSkipMffc = 0, fVerbose = 0, fVeryVerbose = 0; Extra_UtilGetoptReset(); - while ( ( c = Extra_UtilGetopt( argc, argv, "WBLUofbruimvwh" ) ) != EOF ) + while ( ( c = Extra_UtilGetopt( argc, argv, "TWBLUofbruimvwh" ) ) != EOF ) { switch ( c ) { + case 'T': + if ( globalUtilOptind >= argc ) + { + Abc_Print( -1, "Command line switch \"-T\" should be followed by an integer.\n" ); + goto usage; + } + nTimeout = atoi(argv[globalUtilOptind]); + globalUtilOptind++; + if ( nTimeout < 0 ) + goto usage; + break; case 'W': if ( globalUtilOptind >= argc ) { @@ -7302,12 +7325,13 @@ int Abc_CommandRunSim( Abc_Frame_t * pAbc, int argc, char ** argv ) else fclose( pFile ); } - Acb_NtkRunSim( pFileNames, nWords, nBeam, LevL, LevU, fOrder, fFancy, fUseBuf, fRandom, fUseWeights, fInputs, fSkipMffc, fVerbose, fVeryVerbose ); + Acb_NtkRunSim( pFileNames, nTimeout, nWords, nBeam, LevL, LevU, fOrder, fFancy, fUseBuf, fRandom, fUseWeights, fInputs, fSkipMffc, fVerbose, fVeryVerbose ); return 0; usage: - Abc_Print( -2, "usage: runsim [-WBLU] [-ofbruimvwh] [-N ] \n" ); + Abc_Print( -2, "usage: runsim [-TWBLU] [-ofbruimvwh] [-N ] \n" ); Abc_Print( -2, "\t experimental simulation command\n" ); + Abc_Print( -2, "\t-T : the timeout in seconds [default = %d]\n", nTimeout ); Abc_Print( -2, "\t-W : the number of words of simulation info [default = %d]\n", nWords ); Abc_Print( -2, "\t-B : the beam width parameter [default = %d]\n", nBeam ); Abc_Print( -2, "\t-L : the lower bound on level [default = %d]\n", LevL ); diff --git a/src/base/acb/acbFunc.c b/src/base/acb/acbFunc.c index cc9c425b..55918f49 100644 --- a/src/base/acb/acbFunc.c +++ b/src/base/acb/acbFunc.c @@ -2583,10 +2583,11 @@ Vec_Ptr_t * Acb_TransformPatchFunctions( Vec_Ptr_t * vSops, Vec_Wec_t * vSupps, SeeAlso [] ***********************************************************************/ -int Acb_NtkEcoPerform( Acb_Ntk_t * pNtkF, Acb_Ntk_t * pNtkG, char * pFileName[4], int fCisOnly, int fInputs, int fCheck, int fVerbose, int fVeryVerbose ) +int Acb_NtkEcoPerform( Acb_Ntk_t * pNtkF, Acb_Ntk_t * pNtkG, char * pFileName[4], int nTimeout, int fCisOnly, int fInputs, int fCheck, int fVerbose, int fVeryVerbose ) { extern Gia_Man_t * Abc_SopSynthesizeOne( char * pSop, int fClp ); + abctime clkStart = Abc_Clock(); abctime clk = Abc_Clock(); int nTargets = Vec_IntSize(&pNtkF->vTargets); int TimeOut = fCisOnly ? 0 : 120; // 60 seconds @@ -2700,6 +2701,14 @@ int Acb_NtkEcoPerform( Acb_Ntk_t * pNtkF, Acb_Ntk_t * pNtkG, char * pFileName[4] RetValue = 0; goto cleanup; } + if ( nTimeout && (Abc_Clock() - clkStart)/CLOCKS_PER_SEC >= nTimeout ) + { + Vec_IntFreeP( &vSupp ); + ABC_FREE( pSop ); + printf( "The target computation timed out after %d seconds.\n", nTimeout ); + RetValue = 0; + goto cleanup; + } // add new function to the miter pOne = Abc_SopSynthesizeOne( pSop, 1 ); @@ -2826,7 +2835,7 @@ void Acb_NtkTestRun2( char * pFileNames[3], int fVerbose ) SeeAlso [] ***********************************************************************/ -void Acb_NtkRunEco( char * pFileNames[4], int fCheck, int fRandom, int fInputs, int fVerbose, int fVeryVerbose ) +void Acb_NtkRunEco( char * pFileNames[4], int nTimeout, int fCheck, int fRandom, int fInputs, int fVerbose, int fVeryVerbose ) { char Command[1000]; int Result = 1; Acb_Ntk_t * pNtkF = Acb_VerilogSimpleRead( pFileNames[0], pFileNames[2] ); @@ -2848,10 +2857,10 @@ void Acb_NtkRunEco( char * pFileNames[4], int fCheck, int fRandom, int fInputs, Acb_IntallLibrary( Abc_FrameReadSignalNames() != NULL ); - if ( !Acb_NtkEcoPerform( pNtkF, pNtkG, pFileNames, 0, fInputs, fCheck, fVerbose, fVeryVerbose ) ) + if ( !Acb_NtkEcoPerform( pNtkF, pNtkG, pFileNames, nTimeout, 0, fInputs, fCheck, fVerbose, fVeryVerbose ) ) { // printf( "General computation timed out. Trying inputs only.\n\n" ); -// if ( !Acb_NtkEcoPerform( pNtkF, pNtkG, pFileNames, 1, fInputs, fCheck, fVerbose, fVeryVerbose ) ) +// if ( !Acb_NtkEcoPerform( pNtkF, pNtkG, pFileNames, nTimeout, 1, fInputs, fCheck, fVerbose, fVeryVerbose ) ) // printf( "Input-only computation also timed out.\n\n" ); printf( "Computation did not succeed.\n" ); Result = 0; diff --git a/src/base/acb/acbUtil.c b/src/base/acb/acbUtil.c index 2cfae6ea..d0d53e18 100644 --- a/src/base/acb/acbUtil.c +++ b/src/base/acb/acbUtil.c @@ -1270,13 +1270,13 @@ void Acb_Ntk4DumpWeights( char * pFileNameIn, Vec_Ptr_t * vObjNames, char * pFil SeeAlso [] ***********************************************************************/ -void Acb_NtkRunSim( char * pFileName[4], int nWords, int nBeam, int LevL, int LevU, int fOrder, int fFancy, int fUseBuf, int fRandom, int fUseWeights, int fInputs, int fSkipMffc, int fVerbose, int fVeryVerbose ) +void Acb_NtkRunSim( char * pFileName[4], int nTimeout, int nWords, int nBeam, int LevL, int LevU, int fOrder, int fFancy, int fUseBuf, int fRandom, int fUseWeights, int fInputs, int fSkipMffc, int fVerbose, int fVeryVerbose ) { - extern int Gia_Sim4Try( char * pFileName0, char * pFileName1, char * pFileName2, int nWords, int nBeam, int LevL, int LevU, int fOrder, int fFancy, int fUseBuf, int fSkipMffc, int fVerbose ); - extern void Acb_NtkRunEco( char * pFileNames[4], int fCheck, int fRandom, int fInputs, int fVerbose, int fVeryVerbose ); + extern int Gia_Sim4Try( char * pFileName0, char * pFileName1, char * pFileName2, int nTimeout, int nWords, int nBeam, int LevL, int LevU, int fOrder, int fFancy, int fUseBuf, int fSkipMffc, int fVerbose ); + extern void Acb_NtkRunEco( char * pFileNames[4], int nTimeout, int fCheck, int fRandom, int fInputs, int fVerbose, int fVeryVerbose ); char * pFileNames[4] = { pFileName[2], pFileName[1], fUseWeights ? (char *)"weights.txt" : NULL, pFileName[2] }; - if ( Gia_Sim4Try( pFileName[0], pFileName[1], pFileName[2], nWords, nBeam, LevL, LevU, fOrder, fFancy, fUseBuf, fSkipMffc, fVerbose ) ) - Acb_NtkRunEco( pFileNames, 1, fRandom, fInputs, fVerbose, fVeryVerbose ); + if ( Gia_Sim4Try( pFileName[0], pFileName[1], pFileName[2], nTimeout, nWords, nBeam, LevL, LevU, fOrder, fFancy, fUseBuf, fSkipMffc, fVerbose ) ) + Acb_NtkRunEco( pFileNames, nTimeout, 1, fRandom, fInputs, fVerbose, fVeryVerbose ); } -- cgit v1.2.3 From 901560bb238f8c4e4dafc4d2489eaa77df4defb3 Mon Sep 17 00:00:00 2001 From: Alan Mishchenko Date: Wed, 9 Dec 2020 21:59:49 -1000 Subject: Deriving equivalent nets from proved equivalences. --- src/base/abci/abcDress2.c | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) (limited to 'src/base') diff --git a/src/base/abci/abcDress2.c b/src/base/abci/abcDress2.c index 1b1eb9bf..e7adb41f 100644 --- a/src/base/abci/abcDress2.c +++ b/src/base/abci/abcDress2.c @@ -21,6 +21,7 @@ #include "base/abc/abc.h" #include "aig/aig/aig.h" #include "proof/dch/dch.h" +#include "aig/gia/giaAig.h" ABC_NAMESPACE_IMPL_START @@ -272,6 +273,32 @@ Vec_Ptr_t * Abc_NtkDressMapIds( Aig_Man_t * pMiter, Abc_Ntk_t * pNtk1, Abc_Ntk_t return vRes; } +/**Function************************************************************* + + Synopsis [Alternative way to compute equivalences.] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +void Dch_ComputeEquivalences2( Aig_Man_t * pMiter, Dch_Pars_t * pPars ) +{ + extern Gia_Man_t * Cec4_ManSimulateTest3( Gia_Man_t * p, int nBTLimit, int fVerbose ); + Gia_Man_t * pGia = Gia_ManFromAigSimple(pMiter); + Gia_Man_t * pNew = Cec4_ManSimulateTest3( pGia, pPars->nBTLimit, pPars->fVerbose ); + int i, k; + ABC_FREE( pMiter->pReprs ); + pMiter->pReprs = ABC_CALLOC( Aig_Obj_t *, Aig_ManObjNumMax(pMiter) ); + Gia_ManForEachClass( pGia, i ) + Gia_ClassForEachObj1( pGia, i, k ) + pMiter->pReprs[k] = Aig_ManObj( pMiter, i ); + Gia_ManStop( pGia ); + Gia_ManStop( pNew ); +} + /**Function************************************************************* Synopsis [Computes equivalence classes of objects in pNtk1 and pNtk2.] @@ -307,7 +334,7 @@ Vec_Ptr_t * Abc_NtkDressComputeEquivs( Abc_Ntk_t * pNtk1, Abc_Ntk_t * pNtk2, int pPars->nBTLimit = nConflictLimit; pPars->fVerbose = fVerbose; // perform SAT sweeping - Dch_ComputeEquivalences( pMiter, pPars ); + Dch_ComputeEquivalences2( pMiter, pPars ); // now, pMiter is annotated with the equivl class info // convert this info into the resulting array vRes = Abc_NtkDressMapIds( pMiter, pNtk1, pNtk2 ); -- cgit v1.2.3 From 06094ade87fbec6000619bf007aaad596e8bc0a2 Mon Sep 17 00:00:00 2001 From: Alan Mishchenko Date: Wed, 16 Dec 2020 00:06:31 -0800 Subject: Adding switch to replace proved outputs by const0. --- src/base/abci/abc.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) (limited to 'src/base') diff --git a/src/base/abci/abc.c b/src/base/abci/abc.c index fd108107..29281af4 100644 --- a/src/base/abci/abc.c +++ b/src/base/abci/abc.c @@ -36120,10 +36120,10 @@ int Abc_CommandAbc9Sat( Abc_Frame_t * pAbc, int argc, char ** argv ) Cec_ParSat_t ParsSat, * pPars = &ParsSat; Gia_Man_t * pTemp; int c; - int fNewSolver = 0, fCSat = 0; + int fNewSolver = 0, fCSat = 0, f0Proved = 0; Cec_ManSatSetDefaultParams( pPars ); Extra_UtilGetoptReset(); - while ( ( c = Extra_UtilGetopt( argc, argv, "CSNanmtcxvh" ) ) != EOF ) + while ( ( c = Extra_UtilGetopt( argc, argv, "CSNanmtcxzvh" ) ) != EOF ) { switch ( c ) { @@ -36178,6 +36178,9 @@ int Abc_CommandAbc9Sat( Abc_Frame_t * pAbc, int argc, char ** argv ) case 'x': fNewSolver ^= 1; break; + case 'z': + f0Proved ^= 1; + break; case 'v': pPars->fVerbose ^= 1; break; @@ -36199,7 +36202,7 @@ int Abc_CommandAbc9Sat( Abc_Frame_t * pAbc, int argc, char ** argv ) else if ( pPars->fLearnCls ) vCounters = Tas_ManSolveMiterNc( pAbc->pGia, pPars->nBTLimit, &vStatus, pPars->fVerbose ); else if ( pPars->fNonChrono ) - vCounters = Cbs_ManSolveMiterNc( pAbc->pGia, pPars->nBTLimit, &vStatus, pPars->fVerbose ); + vCounters = Cbs_ManSolveMiterNc( pAbc->pGia, pPars->nBTLimit, &vStatus, f0Proved, pPars->fVerbose ); else vCounters = Cbs_ManSolveMiter( pAbc->pGia, pPars->nBTLimit, &vStatus, pPars->fVerbose ); Vec_IntFree( vCounters ); @@ -36207,7 +36210,7 @@ int Abc_CommandAbc9Sat( Abc_Frame_t * pAbc, int argc, char ** argv ) } else { - pTemp = Cec_ManSatSolving( pAbc->pGia, pPars ); + pTemp = Cec_ManSatSolving( pAbc->pGia, pPars, f0Proved ); Abc_FrameUpdateGia( pAbc, pTemp ); } if ( pAbc->pGia->vSeqModelVec ) @@ -36219,7 +36222,7 @@ int Abc_CommandAbc9Sat( Abc_Frame_t * pAbc, int argc, char ** argv ) return 0; usage: - Abc_Print( -2, "usage: &sat [-CSN ] [-anmctxvh]\n" ); + Abc_Print( -2, "usage: &sat [-CSN ] [-anmctxzvh]\n" ); Abc_Print( -2, "\t performs SAT solving for the combinational outputs\n" ); Abc_Print( -2, "\t-C num : the max number of conflicts at a node [default = %d]\n", pPars->nBTLimit ); Abc_Print( -2, "\t-S num : the min number of variables to recycle the solver [default = %d]\n", pPars->nSatVarMax ); @@ -36230,6 +36233,7 @@ usage: Abc_Print( -2, "\t-c : toggle using circuit-based SAT solver [default = %s]\n", fCSat? "yes": "no" ); Abc_Print( -2, "\t-t : toggle using learning in curcuit-based solver [default = %s]\n", pPars->fLearnCls? "yes": "no" ); Abc_Print( -2, "\t-x : toggle using new solver [default = %s]\n", fNewSolver? "yes": "no" ); + Abc_Print( -2, "\t-z : toggle replacing proved cones by const0 [default = %s]\n", f0Proved? "yes": "no" ); Abc_Print( -2, "\t-v : toggle printing verbose information [default = %s]\n", pPars->fVerbose? "yes": "no" ); Abc_Print( -2, "\t-h : print the command usage\n"); return 1; -- cgit v1.2.3 From 8066fdbcb53f0e9ea617f24de1a73bc9f0cb69f6 Mon Sep 17 00:00:00 2001 From: Alan Mishchenko Date: Wed, 16 Dec 2020 10:31:25 -0800 Subject: Adding generation of combinational speculative miters. --- src/base/abci/abc.c | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) (limited to 'src/base') diff --git a/src/base/abci/abc.c b/src/base/abci/abc.c index 29281af4..feabe0bb 100644 --- a/src/base/abci/abc.c +++ b/src/base/abci/abc.c @@ -36606,8 +36606,9 @@ int Abc_CommandAbc9Srm( Abc_Frame_t * pAbc, int argc, char ** argv ) int fSpeculate = 1; int fSkipSome = 0; int fDualOut = 0; + int fComb = 0; Extra_UtilGetoptReset(); - while ( ( c = Extra_UtilGetopt( argc, argv, "Adrsfvh" ) ) != EOF ) + while ( ( c = Extra_UtilGetopt( argc, argv, "Adrsfcvh" ) ) != EOF ) { switch ( c ) { @@ -36632,6 +36633,9 @@ int Abc_CommandAbc9Srm( Abc_Frame_t * pAbc, int argc, char ** argv ) case 'f': fSkipSome ^= 1; break; + case 'c': + fComb ^= 1; + break; case 'v': fVerbose ^= 1; break; @@ -36646,6 +36650,15 @@ int Abc_CommandAbc9Srm( Abc_Frame_t * pAbc, int argc, char ** argv ) Abc_Print( -1, "Abc_CommandAbc9Srm(): There is no AIG.\n" ); return 1; } + if ( fComb ) + { + extern int Cec4_ManSimulateOnlyTest( Gia_Man_t * p, int fVerbose ); + int Result = Cec4_ManSimulateOnlyTest( pAbc->pGia, fVerbose ); + extern Gia_Man_t * Gia_ManCombSpecReduce( Gia_Man_t * p ); + pTemp = Gia_ManCombSpecReduce( pAbc->pGia ); + Abc_FrameUpdateGia( pAbc, pTemp ); + return 0; + } sprintf(pFileName, "gsrm%s.aig", fSpeculate? "" : "s" ); sprintf(pFileName2, "gsyn%s.aig", fSpeculate? "" : "s" ); pTemp = Gia_ManSpecReduce( pAbc->pGia, fDualOut, fSynthesis, fSpeculate, fSkipSome, fVerbose ); @@ -36678,13 +36691,14 @@ int Abc_CommandAbc9Srm( Abc_Frame_t * pAbc, int argc, char ** argv ) return 0; usage: - Abc_Print( -2, "usage: &srm [-A file] [-drsfvh]\n" ); - Abc_Print( -2, "\t writes speculatively reduced model into file \"%s\"\n", pFileName ); + Abc_Print( -2, "usage: &srm [-A file] [-drsfcvh]\n" ); + Abc_Print( -2, "\t derives or writes speculatively reduced model into file \"%s\"\n", pFileName ); Abc_Print( -2, "\t-A file : file name for dumping speculative-reduced model [default = \"gsrm.aig\"]\n" ); Abc_Print( -2, "\t-d : toggle creating dual-output miter [default = %s]\n", fDualOut? "yes": "no" ); Abc_Print( -2, "\t-r : toggle writing reduced network for synthesis [default = %s]\n", fSynthesis? "yes": "no" ); Abc_Print( -2, "\t-s : toggle using speculation at the internal nodes [default = %s]\n", fSpeculate? "yes": "no" ); Abc_Print( -2, "\t-f : toggle filtering to remove redundant equivalences [default = %s]\n", fSkipSome? "yes": "no" ); + Abc_Print( -2, "\t-c : toggle using combinational speculation [default = %s]\n", fComb? "yes": "no" ); 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; -- cgit v1.2.3 From 73dcdab6d836440ae5edf6fd23f9a409f9e519c2 Mon Sep 17 00:00:00 2001 From: Alan Mishchenko Date: Wed, 16 Dec 2020 22:04:06 -0800 Subject: Adding solver type in &sat. --- src/base/abci/abc.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) (limited to 'src/base') diff --git a/src/base/abci/abc.c b/src/base/abci/abc.c index feabe0bb..13f8caea 100644 --- a/src/base/abci/abc.c +++ b/src/base/abci/abc.c @@ -36123,10 +36123,21 @@ int Abc_CommandAbc9Sat( Abc_Frame_t * pAbc, int argc, char ** argv ) int fNewSolver = 0, fCSat = 0, f0Proved = 0; Cec_ManSatSetDefaultParams( pPars ); Extra_UtilGetoptReset(); - while ( ( c = Extra_UtilGetopt( argc, argv, "CSNanmtcxzvh" ) ) != EOF ) + while ( ( c = Extra_UtilGetopt( argc, argv, "JCSNanmtcxzvh" ) ) != EOF ) { switch ( c ) { + case 'J': + if ( globalUtilOptind >= argc ) + { + Abc_Print( -1, "Command line switch \"-J\" should be followed by an integer.\n" ); + goto usage; + } + pPars->SolverType = atoi(argv[globalUtilOptind]); + globalUtilOptind++; + if ( pPars->SolverType < 0 ) + goto usage; + break; case 'C': if ( globalUtilOptind >= argc ) { @@ -36222,8 +36233,9 @@ int Abc_CommandAbc9Sat( Abc_Frame_t * pAbc, int argc, char ** argv ) return 0; usage: - Abc_Print( -2, "usage: &sat [-CSN ] [-anmctxzvh]\n" ); + Abc_Print( -2, "usage: &sat [-JCSN ] [-anmctxzvh]\n" ); Abc_Print( -2, "\t performs SAT solving for the combinational outputs\n" ); + Abc_Print( -2, "\t-J num : the SAT solver type [default = %d]\n", pPars->SolverType ); Abc_Print( -2, "\t-C num : the max number of conflicts at a node [default = %d]\n", pPars->nBTLimit ); Abc_Print( -2, "\t-S num : the min number of variables to recycle the solver [default = %d]\n", pPars->nSatVarMax ); Abc_Print( -2, "\t-N num : the min number of calls to recycle the solver [default = %d]\n", pPars->nCallsRecycle ); -- cgit v1.2.3 From f06217e25a9905e5ebb9bce27ac06c456b9cf5f8 Mon Sep 17 00:00:00 2001 From: Alan Mishchenko Date: Mon, 21 Dec 2020 12:45:50 -0800 Subject: Compiler warnings. --- src/base/abci/abc.c | 1 + 1 file changed, 1 insertion(+) (limited to 'src/base') diff --git a/src/base/abci/abc.c b/src/base/abci/abc.c index 13f8caea..7aef638d 100644 --- a/src/base/abci/abc.c +++ b/src/base/abci/abc.c @@ -36669,6 +36669,7 @@ int Abc_CommandAbc9Srm( Abc_Frame_t * pAbc, int argc, char ** argv ) extern Gia_Man_t * Gia_ManCombSpecReduce( Gia_Man_t * p ); pTemp = Gia_ManCombSpecReduce( pAbc->pGia ); Abc_FrameUpdateGia( pAbc, pTemp ); + Result = 0; return 0; } sprintf(pFileName, "gsrm%s.aig", fSpeculate? "" : "s" ); -- cgit v1.2.3 From cd8843c06ce2a37067edb5116f0c735ce3e3b7c7 Mon Sep 17 00:00:00 2001 From: Alan Mishchenko Date: Sat, 9 Jan 2021 13:06:45 -0800 Subject: Preventing command history from being overwritten by internal scripts. --- src/base/abc/abcUtil.c | 6 ++++++ src/base/cmd/cmdHist.c | 3 ++- src/base/main/main.h | 1 + src/base/main/mainFrame.c | 1 + 4 files changed, 10 insertions(+), 1 deletion(-) (limited to 'src/base') diff --git a/src/base/abc/abcUtil.c b/src/base/abc/abcUtil.c index 922b34ae..51d31527 100644 --- a/src/base/abc/abcUtil.c +++ b/src/base/abc/abcUtil.c @@ -3123,7 +3123,9 @@ Vec_Wec_t * Abc_SopSynthesize( Vec_Ptr_t * vSops ) int i, k, iNode = 0; Abc_FrameReplaceCurrentNetwork( Abc_FrameReadGlobalFrame(), pNtk ); //Cmd_CommandExecute( Abc_FrameGetGlobalFrame(), "fx; strash; balance; dc2; map -a" ); + Abc_FrameSetBatchMode( 1 ); Cmd_CommandExecute( Abc_FrameGetGlobalFrame(), "st; collapse; sop; fx; strash; &get; &ps; &deepsyn -I 4 -J 50 -T 5 -S 111 -t; &ps; &put; map -a" ); + Abc_FrameSetBatchMode( 0 ); pNtkNew = Abc_FrameReadNtk( Abc_FrameReadGlobalFrame() ); vRes = Vec_WecStart( Abc_NtkPiNum(pNtkNew) + Abc_NtkNodeNum(pNtkNew) + Abc_NtkPoNum(pNtkNew) ); Abc_NtkForEachPi( pNtkNew, pObj, i ) @@ -3150,7 +3152,9 @@ Vec_Wec_t * Abc_GiaSynthesize( Vec_Ptr_t * vGias, Gia_Man_t * pMulti ) Abc_Obj_t * pObj, * pFanin; int i, k, iNode = 0; Abc_FrameReplaceCurrentNetwork( Abc_FrameReadGlobalFrame(), pNtk ); + Abc_FrameSetBatchMode( 1 ); Cmd_CommandExecute( Abc_FrameGetGlobalFrame(), "compress2rs; dch; map -a; strash; compress2rs; dch; map -a; strash; compress2rs; dch; map -a" ); + Abc_FrameSetBatchMode( 0 ); pNtkNew = Abc_FrameReadNtk( Abc_FrameReadGlobalFrame() ); vRes = Vec_WecStart( Abc_NtkPiNum(pNtkNew) + Abc_NtkNodeNum(pNtkNew) + Abc_NtkPoNum(pNtkNew) ); Abc_NtkForEachPi( pNtkNew, pObj, i ) @@ -3254,9 +3258,11 @@ Gia_Man_t * Abc_SopSynthesizeOne( char * pSop, int fClp ) pNtk = Abc_NtkCreateFromSops( "top", vSops ); Vec_PtrFree( vSops ); Abc_FrameReplaceCurrentNetwork( Abc_FrameReadGlobalFrame(), pNtk ); + Abc_FrameSetBatchMode( 1 ); if ( fClp ) Cmd_CommandExecute( Abc_FrameGetGlobalFrame(), "clp; sop" ); Cmd_CommandExecute( Abc_FrameGetGlobalFrame(), "fx; strash; balance; dc2" ); + Abc_FrameSetBatchMode( 0 ); pNtkNew = Abc_FrameReadNtk( Abc_FrameReadGlobalFrame() ); return Abc_NtkStrashToGia( pNtkNew ); } diff --git a/src/base/cmd/cmdHist.c b/src/base/cmd/cmdHist.c index 218d832f..b8cfc98f 100644 --- a/src/base/cmd/cmdHist.c +++ b/src/base/cmd/cmdHist.c @@ -65,7 +65,8 @@ void Cmd_HistoryAddCommand( Abc_Frame_t * p, const char * command ) strncmp(Buffer,"time",4) && strncmp(Buffer,"quit",4) && strncmp(Buffer,"alias",5) && -// strncmp(Buffer,"source",6) && + strncmp(Buffer,"source abc.rc",13) && + strncmp(Buffer,"source ..\\abc.rc",16) && strncmp(Buffer,"history",7) && strncmp(Buffer,"hi ", 3) && strcmp(Buffer,"hi") && Buffer[strlen(Buffer)-1] != '?' ) { diff --git a/src/base/main/main.h b/src/base/main/main.h index a310972d..f3457e27 100644 --- a/src/base/main/main.h +++ b/src/base/main/main.h @@ -111,6 +111,7 @@ extern ABC_DLL char * Abc_FrameReadSpecName(); extern ABC_DLL char * Abc_FrameReadFlag( char * pFlag ); extern ABC_DLL int Abc_FrameIsFlagEnabled( char * pFlag ); extern ABC_DLL int Abc_FrameIsBatchMode(); +extern ABC_DLL void Abc_FrameSetBatchMode( int Mode ); extern ABC_DLL int Abc_FrameIsBridgeMode(); extern ABC_DLL void Abc_FrameSetBridgeMode(); diff --git a/src/base/main/mainFrame.c b/src/base/main/mainFrame.c index b7d76e93..ba41d4c1 100644 --- a/src/base/main/mainFrame.c +++ b/src/base/main/mainFrame.c @@ -108,6 +108,7 @@ void Abc_FrameSetSignalNames( Vec_Ptr_t * vNames ) { if ( s_GlobalFram void Abc_FrameSetSpecName( char * pFileName ) { ABC_FREE( s_GlobalFrame->pSpecName ); s_GlobalFrame->pSpecName = pFileName; } int Abc_FrameIsBatchMode() { return s_GlobalFrame ? s_GlobalFrame->fBatchMode : 0; } +void Abc_FrameSetBatchMode( int Mode ) { if ( s_GlobalFrame ) s_GlobalFrame->fBatchMode = Mode; } int Abc_FrameIsBridgeMode() { return s_GlobalFrame ? s_GlobalFrame->fBridgeMode : 0; } void Abc_FrameSetBridgeMode() { if ( s_GlobalFrame ) s_GlobalFrame->fBridgeMode = 1; } -- cgit v1.2.3 From b2ca83752154bf8366fa767244c886f24f674f41 Mon Sep 17 00:00:00 2001 From: Alan Mishchenko Date: Thu, 11 Mar 2021 17:45:01 -1000 Subject: Adding a random seed to control randomness in 'permute'. --- src/base/abci/abc.c | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) (limited to 'src/base') diff --git a/src/base/abci/abc.c b/src/base/abci/abc.c index 7aef638d..3ad5ff18 100644 --- a/src/base/abci/abc.c +++ b/src/base/abci/abc.c @@ -23681,12 +23681,24 @@ int Abc_CommandPermute( Abc_Frame_t * pAbc, int argc, char ** argv ) int fFlops = 1; int fNodes = 1; int fFanout = 0; + int Seed = -1; int c; Extra_UtilGetoptReset(); - while ( ( c = Extra_UtilGetopt( argc, argv, "Fiofnxh" ) ) != EOF ) + while ( ( c = Extra_UtilGetopt( argc, argv, "SFiofnxh" ) ) != EOF ) { switch ( c ) { + case 'S': + if ( globalUtilOptind >= argc ) + { + Abc_Print( -1, "Command line switch \"-S\" should be followed by an integer.\n" ); + goto usage; + } + Seed = atoi(argv[globalUtilOptind]); + globalUtilOptind++; + if ( Seed < 0 ) + goto usage; + break; case 'F': if ( globalUtilOptind >= argc ) { @@ -23747,13 +23759,16 @@ int Abc_CommandPermute( Abc_Frame_t * pAbc, int argc, char ** argv ) Abc_Print( -1, "Command \"permute\" has failed.\n" ); return 1; } + if ( Seed >= 0 ) + srand( (unsigned)Seed ); Abc_NtkPermute( pNtkRes, fInputs, fOutputs, fFlops, pFlopPermFile ); Abc_FrameReplaceCurrentNetwork( pAbc, pNtkRes ); return 0; usage: - Abc_Print( -2, "usage: permute [-iofnxh] [-F filename]\n" ); + Abc_Print( -2, "usage: permute [-S num] [-iofnxh] [-F filename]\n" ); Abc_Print( -2, "\t performs random permutation of inputs/outputs/flops\n" ); + Abc_Print( -2, "\t-S num : the random seed to generate permutations (0 <= num < INT_MAX) [default = %d]\n", Seed ); Abc_Print( -2, "\t-i : toggle permuting primary inputs [default = %s]\n", fInputs? "yes": "no" ); Abc_Print( -2, "\t-o : toggle permuting primary outputs [default = %s]\n", fOutputs? "yes": "no" ); Abc_Print( -2, "\t-f : toggle permuting flip-flops [default = %s]\n", fFlops? "yes": "no" ); -- cgit v1.2.3 From 66098723ebb9bede7a84ebb1d85b2d72c874bac5 Mon Sep 17 00:00:00 2001 From: Alan Mishchenko Date: Thu, 11 Mar 2021 17:50:56 -1000 Subject: Adding a random seed to control randomness in 'permute' (correction). --- src/base/abci/abc.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/base') diff --git a/src/base/abci/abc.c b/src/base/abci/abc.c index 3ad5ff18..81ce3a01 100644 --- a/src/base/abci/abc.c +++ b/src/base/abci/abc.c @@ -23730,6 +23730,8 @@ int Abc_CommandPermute( Abc_Frame_t * pAbc, int argc, char ** argv ) goto usage; } } + if ( Seed >= 0 ) + srand( (unsigned)Seed ); if ( pNtk == NULL ) { Abc_Print( -1, "Empty network.\n" ); @@ -23759,8 +23761,6 @@ int Abc_CommandPermute( Abc_Frame_t * pAbc, int argc, char ** argv ) Abc_Print( -1, "Command \"permute\" has failed.\n" ); return 1; } - if ( Seed >= 0 ) - srand( (unsigned)Seed ); Abc_NtkPermute( pNtkRes, fInputs, fOutputs, fFlops, pFlopPermFile ); Abc_FrameReplaceCurrentNetwork( pAbc, pNtkRes ); return 0; -- cgit v1.2.3 From 6a03ece98d0da3f6ec14d86f0bff36e6f36ba8bd Mon Sep 17 00:00:00 2001 From: Alan Mishchenko Date: Sun, 28 Mar 2021 14:49:27 -1000 Subject: Command &iwls21test for evaluating the results of 2021 IWLS Contest. --- src/base/abci/abc.c | 92 +++++++++++++++++++++++++++++++++++++++++++++++++ src/base/wlc/wlcBlast.c | 92 +++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 184 insertions(+) (limited to 'src/base') diff --git a/src/base/abci/abc.c b/src/base/abci/abc.c index 81ce3a01..94a98037 100644 --- a/src/base/abci/abc.c +++ b/src/base/abci/abc.c @@ -416,6 +416,7 @@ static int Abc_CommandAbc9Sim ( Abc_Frame_t * pAbc, int argc, cha static int Abc_CommandAbc9Sim3 ( Abc_Frame_t * pAbc, int argc, char ** argv ); static int Abc_CommandAbc9MLGen ( Abc_Frame_t * pAbc, int argc, char ** argv ); static int Abc_CommandAbc9MLTest ( Abc_Frame_t * pAbc, int argc, char ** argv ); +static int Abc_CommandAbc9Iwls21Test ( Abc_Frame_t * pAbc, int argc, char ** argv ); static int Abc_CommandAbc9ReadSim ( Abc_Frame_t * pAbc, int argc, char ** argv ); static int Abc_CommandAbc9WriteSim ( Abc_Frame_t * pAbc, int argc, char ** argv ); static int Abc_CommandAbc9PrintSim ( Abc_Frame_t * pAbc, int argc, char ** argv ); @@ -1138,6 +1139,7 @@ void Abc_Init( Abc_Frame_t * pAbc ) Cmd_CommandAdd( pAbc, "ABC9", "&sim3", Abc_CommandAbc9Sim3, 0 ); Cmd_CommandAdd( pAbc, "ABC9", "&mlgen", Abc_CommandAbc9MLGen, 0 ); Cmd_CommandAdd( pAbc, "ABC9", "&mltest", Abc_CommandAbc9MLTest, 0 ); + Cmd_CommandAdd( pAbc, "ABC9", "&iwls21test", Abc_CommandAbc9Iwls21Test, 0 ); Cmd_CommandAdd( pAbc, "ABC9", "&sim_read", Abc_CommandAbc9ReadSim, 0 ); Cmd_CommandAdd( pAbc, "ABC9", "&sim_write", Abc_CommandAbc9WriteSim, 0 ); Cmd_CommandAdd( pAbc, "ABC9", "&sim_print", Abc_CommandAbc9PrintSim, 0 ); @@ -32990,6 +32992,96 @@ usage: return 1; } +/**Function************************************************************* + + Synopsis [] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +int Abc_CommandAbc9Iwls21Test( Abc_Frame_t * pAbc, int argc, char ** argv ) +{ + extern void Gia_ManTestWordFile( Gia_Man_t * p, char * pFileName, char * pDumpFile, int fVerbose ); + int c, fVerbose = 0; + char * pDumpFile = NULL; + char ** pArgvNew; + int nArgcNew; + Extra_UtilGetoptReset(); + while ( ( c = Extra_UtilGetopt( argc, argv, "Dvh" ) ) != EOF ) + { + switch ( c ) + { + case 'D': + if ( globalUtilOptind >= argc ) + { + Abc_Print( -1, "Command line switch \"-D\" should be followed by a file name.\n" ); + goto usage; + } + pDumpFile = argv[globalUtilOptind]; + globalUtilOptind++; + break; + case 'v': + fVerbose ^= 1; + break; + case 'h': + goto usage; + default: + goto usage; + } + } + pArgvNew = argv + globalUtilOptind; + nArgcNew = argc - globalUtilOptind; + if ( nArgcNew == 2 ) + { + Gia_Man_t * pAig = Gia_AigerRead( pArgvNew[0], 0, 0, 0 ); + if ( pAig == NULL ) + { + Abc_Print( -1, "Reading AIGER from file \"%s\" has failed.\n", pArgvNew[0] ); + return 0; + } + if ( pAbc->pGia == NULL ) + { + Abc_Print( -1, "Abc_CommandAbc9Iwls21Test(): There is no AIG.\n" ); + return 1; + } + Gia_ManTestWordFile( pAig, pArgvNew[1], pDumpFile, fVerbose ); + Gia_ManStop( pAig ); + return 0; + } + if ( pAbc->pGia == NULL ) + { + Abc_Print( -1, "Abc_CommandAbc9Iwls21Test(): There is no AIG.\n" ); + return 1; + } + if ( nArgcNew != 1 ) + { + Abc_Print( -1, "Abc_CommandAbc9Iwls21Test(): Expecting data file name on the command line.\n" ); + return 0; + } + if ( Gia_ManRegNum(pAbc->pGia) > 0 ) + { + Abc_Print( -1, "Abc_CommandAbc9Iwls21Test(): This command works only for combinational AIGs.\n" ); + return 0; + } + Vec_WrdFreeP( &pAbc->pGia->vSimsPi ); + Gia_ManTestWordFile( pAbc->pGia, pArgvNew[0], pDumpFile, fVerbose ); + return 0; + +usage: + Abc_Print( -2, "usage: &iwls21test [-vh] [-D file] \n" ); + Abc_Print( -2, "\t this command evaluates AIG for 2021 IWLS ML+LS Contest\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"); + Abc_Print( -2, "\t-D file : file name to dump statistics [default = none]\n" ); + Abc_Print( -2, "\tfile1 : file with input AIG (or \"&read ; &iwls21test \" can be used)\n"); + Abc_Print( -2, "\tfile2 : file with CIFAR10 image data (https://www.cs.toronto.edu/~kriz/cifar.html)\n"); + return 1; +} + /**Function************************************************************* Synopsis [] diff --git a/src/base/wlc/wlcBlast.c b/src/base/wlc/wlcBlast.c index aec80a2c..8ff8d287 100644 --- a/src/base/wlc/wlcBlast.c +++ b/src/base/wlc/wlcBlast.c @@ -2490,6 +2490,98 @@ Gia_Man_t * Wlc_NtkBitBlast( Wlc_Ntk_t * p, Wlc_BstPar_t * pParIn ) return pNew; } + +/**Function************************************************************* + + Synopsis [] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +float * Extra_FileReadFloat( FILE * pFile, int * pnFileSize ) +{ + float * pBuffer; + int RetValue, nFileSize; + fseek( pFile, 0, SEEK_END ); + nFileSize = *pnFileSize = ftell( pFile ); + rewind( pFile ); + assert( nFileSize%4 == 0 ); + pBuffer = ABC_CALLOC( float, nFileSize/4 ); + RetValue = fread( pBuffer, nFileSize, 1, pFile ); + return pBuffer; +} +float * Extra_FileReadFloatContents( char * pFileName, int * pnFileSize ) +{ + FILE * pFile; + float * pBuffer; + pFile = fopen( pFileName, "rb" ); + pBuffer = pFile ? Extra_FileReadFloat( pFile, pnFileSize ) : NULL; + if ( pFile ) fclose( pFile ); + return pBuffer; +} +static inline int Extra_FixedFound( int Value, int Fixed ) +{ + Value += 1 << (Fixed-1); + Value >>= Fixed; + return Value; +} +static inline int Extra_ConvertFloat8( float Value ) +{ + return Extra_FixedFound( (int)(Value * (1 << 16)), 8 ); +} +Gia_Man_t * Wlc_BlastArray( char * pFileName ) +{ + int nFileSize = 0; + float * pBuffer = Extra_FileReadFloatContents( pFileName, &nFileSize ); + int i, v, Value, nInputs = nFileSize/4 - 1; + Vec_Int_t * vArg0 = Vec_IntAlloc( 100 ); + Vec_Int_t * vArg1 = Vec_IntAlloc( 100 ); + Vec_Int_t * vTemp = Vec_IntAlloc( 100 ); + Vec_Int_t * vRes = Vec_IntAlloc( 100 ); + Vec_Int_t * vSum = Vec_IntAlloc( 100 ); + Gia_Man_t * pTemp, * pNew = Gia_ManStart( 10000 ); + pNew->pName = Abc_UtilStrsav( "blast" ); + Gia_ManHashAlloc( pNew ); + for ( i = 0; i < 8*nInputs; i++ ) + Gia_ManAppendCi(pNew); + + Value = (Extra_ConvertFloat8(pBuffer[0]) << 8) | (1 << 7); + for ( v = 0; v < 20; v++ ) + Vec_IntPush( vSum, (Value >> v) & 1 ); + + for ( i = 0; i < nInputs; i++ ) + { + Value = Extra_ConvertFloat8( pBuffer[1+i] ); + + Vec_IntClear( vArg0 ); + for ( v = 0; v < 8; v++ ) + Vec_IntPush( vArg0, Gia_ManCiLit(pNew, 8*i+v) ); + + Vec_IntClear( vArg1 ); + for ( v = 0; v < 12; v++ ) + Vec_IntPush( vArg1, (Value >> v) & 1 ); + + Wlc_BlastMultiplier( pNew, Vec_IntArray(vArg0), Vec_IntArray(vArg1), 8, 12, vTemp, vRes, 1 ); + Wlc_BlastAdder( pNew, Vec_IntArray(vSum), Vec_IntArray(vRes), 20, 0 ); + } + ABC_FREE( pBuffer ); + for ( v = 8; v < 16; v++ ) + Gia_ManAppendCo( pNew, Vec_IntEntry(vSum, v) ); + Vec_IntFree( vArg0 ); + Vec_IntFree( vArg1 ); + Vec_IntFree( vTemp ); + Vec_IntFree( vRes ); + Vec_IntFree( vSum ); + + pNew = Gia_ManCleanup( pTemp = pNew ); + Gia_ManStop( pTemp ); + return pNew; +} + //////////////////////////////////////////////////////////////////////// /// END OF FILE /// //////////////////////////////////////////////////////////////////////// -- cgit v1.2.3 From 18088bd7dcf3de03cc4f9a439e6b41d04e2f8413 Mon Sep 17 00:00:00 2001 From: Alan Mishchenko Date: Sun, 28 Mar 2021 14:54:07 -1000 Subject: Compiler warnings. --- src/base/abci/abc.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/base') diff --git a/src/base/abci/abc.c b/src/base/abci/abc.c index 94a98037..35281f77 100644 --- a/src/base/abci/abc.c +++ b/src/base/abci/abc.c @@ -33043,10 +33043,10 @@ int Abc_CommandAbc9Iwls21Test( Abc_Frame_t * pAbc, int argc, char ** argv ) Abc_Print( -1, "Reading AIGER from file \"%s\" has failed.\n", pArgvNew[0] ); return 0; } - if ( pAbc->pGia == NULL ) + if ( Gia_ManRegNum(pAig) > 0 ) { - Abc_Print( -1, "Abc_CommandAbc9Iwls21Test(): There is no AIG.\n" ); - return 1; + Abc_Print( -1, "Abc_CommandAbc9Iwls21Test(): This command works only for combinational AIGs.\n" ); + return 0; } Gia_ManTestWordFile( pAig, pArgvNew[1], pDumpFile, fVerbose ); Gia_ManStop( pAig ); -- cgit v1.2.3 From 9145a5c20d5fe85523364d7fe2727b8d83c90aaa Mon Sep 17 00:00:00 2001 From: Alan Mishchenko Date: Sun, 28 Mar 2021 15:40:27 -1000 Subject: An option to extend the number of primary inputs. --- src/base/abci/abc.c | 34 ++++++++++++++++++++++++++++++++-- 1 file changed, 32 insertions(+), 2 deletions(-) (limited to 'src/base') diff --git a/src/base/abci/abc.c b/src/base/abci/abc.c index 35281f77..df7ae5ab 100644 --- a/src/base/abci/abc.c +++ b/src/base/abci/abc.c @@ -32068,13 +32068,14 @@ int Abc_CommandAbc9Strash( Abc_Frame_t * pAbc, int argc, char ** argv ) extern Gia_Man_t * Gia_ManDupMuxRestructure( Gia_Man_t * p ); Gia_Man_t * pTemp; int c, Limit = 2; + int Multi = 0; int fAddStrash = 0; int fCollapse = 0; int fAddMuxes = 0; int fStrMuxes = 0; int fRehashMap = 0; Extra_UtilGetoptReset(); - while ( ( c = Extra_UtilGetopt( argc, argv, "Lacmrsh" ) ) != EOF ) + while ( ( c = Extra_UtilGetopt( argc, argv, "LMacmrsh" ) ) != EOF ) { switch ( c ) { @@ -32089,6 +32090,17 @@ int Abc_CommandAbc9Strash( Abc_Frame_t * pAbc, int argc, char ** argv ) if ( Limit < 0 ) goto usage; break; + case 'M': + if ( globalUtilOptind >= argc ) + { + Abc_Print( -1, "Command line switch \"-M\" should be followed by an integer.\n" ); + goto usage; + } + Multi = atoi(argv[globalUtilOptind]); + globalUtilOptind++; + if ( Multi <= 0 ) + goto usage; + break; case 'a': fAddStrash ^= 1; break; @@ -32115,6 +32127,13 @@ int Abc_CommandAbc9Strash( Abc_Frame_t * pAbc, int argc, char ** argv ) Abc_Print( -1, "Abc_CommandAbc9Strash(): There is no AIG.\n" ); return 1; } + if ( Multi > 0 ) + { + extern Gia_Man_t * Gia_ManDupAddPis( Gia_Man_t * p, int nMulti ); + pTemp = Gia_ManDupAddPis( pAbc->pGia, Multi ); + Abc_FrameUpdateGia( pAbc, pTemp ); + return 0; + } if ( fStrMuxes ) { if ( Gia_ManHasMapping(pAbc->pGia) ) @@ -32182,13 +32201,14 @@ int Abc_CommandAbc9Strash( Abc_Frame_t * pAbc, int argc, char ** argv ) return 0; usage: - Abc_Print( -2, "usage: &st [-L num] [-acmrsh]\n" ); + Abc_Print( -2, "usage: &st [-LM num] [-acmrsh]\n" ); Abc_Print( -2, "\t performs structural hashing\n" ); Abc_Print( -2, "\t-a : toggle additional hashing [default = %s]\n", fAddStrash? "yes": "no" ); Abc_Print( -2, "\t-c : toggle collapsing hierarchical AIG [default = %s]\n", fCollapse? "yes": "no" ); Abc_Print( -2, "\t-m : toggle converting to larger gates [default = %s]\n", fAddMuxes? "yes": "no" ); Abc_Print( -2, "\t-L num : create MUX when sum of refs does not exceed this limit [default = %d]\n", Limit ); Abc_Print( -2, "\t (use L = 1 to create AIG with XORs but without MUXes)\n" ); + Abc_Print( -2, "\t-M num : create an AIG with additional primary inputs [default = %d]\n", Multi ); Abc_Print( -2, "\t-r : toggle rehashing AIG while preserving mapping [default = %s]\n", fRehashMap? "yes": "no" ); Abc_Print( -2, "\t-s : toggle using MUX restructuring [default = %s]\n", fStrMuxes? "yes": "no" ); Abc_Print( -2, "\t-h : print the command usage\n"); @@ -33048,6 +33068,11 @@ int Abc_CommandAbc9Iwls21Test( Abc_Frame_t * pAbc, int argc, char ** argv ) Abc_Print( -1, "Abc_CommandAbc9Iwls21Test(): This command works only for combinational AIGs.\n" ); return 0; } + if ( Gia_ManCoNum(pAig) != 10 ) + { + Abc_Print( -1, "Abc_CommandAbc9Iwls21Test(): Expecting an AIG with 10 outputs.\n" ); + return 0; + } Gia_ManTestWordFile( pAig, pArgvNew[1], pDumpFile, fVerbose ); Gia_ManStop( pAig ); return 0; @@ -33057,6 +33082,11 @@ int Abc_CommandAbc9Iwls21Test( Abc_Frame_t * pAbc, int argc, char ** argv ) Abc_Print( -1, "Abc_CommandAbc9Iwls21Test(): There is no AIG.\n" ); return 1; } + if ( Gia_ManCoNum(pAbc->pGia) != 10 ) + { + Abc_Print( -1, "Abc_CommandAbc9Iwls21Test(): Expecting an AIG with 10 outputs.\n" ); + return 0; + } if ( nArgcNew != 1 ) { Abc_Print( -1, "Abc_CommandAbc9Iwls21Test(): Expecting data file name on the command line.\n" ); -- cgit v1.2.3 From 75981f7feebc4065980f99551654ac101edb4afa Mon Sep 17 00:00:00 2001 From: Alan Mishchenko Date: Fri, 9 Apr 2021 13:46:52 -0700 Subject: Computing sum of PO support sizes. --- src/base/abci/abc.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/base') diff --git a/src/base/abci/abc.c b/src/base/abci/abc.c index df7ae5ab..417c7909 100644 --- a/src/base/abci/abc.c +++ b/src/base/abci/abc.c @@ -48387,6 +48387,7 @@ usage: int Abc_CommandAbc9Test( Abc_Frame_t * pAbc, int argc, char ** argv ) { extern void Gia_RsbEnumerateWindows( Gia_Man_t * p, int nInputsMax, int nLevelsMax ); + extern int Gia_ManSumTotalOfSupportSizes( Gia_Man_t * p ); int c, fVerbose = 0; int nFrames = 5; int fSwitch = 0; @@ -48449,7 +48450,7 @@ int Abc_CommandAbc9Test( Abc_Frame_t * pAbc, int argc, char ** argv ) // } // Abc_FrameUpdateGia( pAbc, Abc_Procedure(pAbc->pGia) ); // Gia_ManTryResub( pAbc->pGia ); - Gia_RsbEnumerateWindows( pAbc->pGia, 6, 5 ); + printf( "AIG in \"%s\" has the sum of output support sizes equal to %d.\n", pAbc->pGia->pSpec, Gia_ManSumTotalOfSupportSizes(pAbc->pGia) ); return 0; usage: Abc_Print( -2, "usage: &test [-FW num] [-svh]\n" ); -- cgit v1.2.3 From de71e5f61038748b59bcbb2bf6f0c8666b45190a Mon Sep 17 00:00:00 2001 From: Alan Mishchenko Date: Mon, 26 Apr 2021 18:52:44 -0700 Subject: Passing node labels. --- src/base/abc/abcObj.c | 1 + src/base/abci/abcDar.c | 1 + src/base/io/ioWriteVerilog.c | 8 ++++++++ 3 files changed, 10 insertions(+) (limited to 'src/base') diff --git a/src/base/abc/abcObj.c b/src/base/abc/abcObj.c index 533f1f73..65ea91dc 100644 --- a/src/base/abc/abcObj.c +++ b/src/base/abc/abcObj.c @@ -393,6 +393,7 @@ Abc_Obj_t * Abc_NtkDupObj( Abc_Ntk_t * pNtkNew, Abc_Obj_t * pObj, int fCopyName } else if ( Abc_ObjIsLatch(pObj) ) // copy the reset value pObjNew->pData = pObj->pData; + pObjNew->fPersist = pObj->fPersist; // transfer HAIG // pObjNew->pEquiv = pObj->pEquiv; // remember the new node in the old node diff --git a/src/base/abci/abcDar.c b/src/base/abci/abcDar.c index 56eb139a..8911780d 100644 --- a/src/base/abci/abcDar.c +++ b/src/base/abci/abcDar.c @@ -858,6 +858,7 @@ Abc_Ntk_t * Abc_NtkFromMappedGia( Gia_Man_t * p, int fFindEnables, int fUseBuffs Gia_LutForEachFanin( p, i, iFan, k ) Abc_ObjAddFanin( pObjNew, Abc_NtkObj(pNtkNew, Gia_ObjValue(Gia_ManObj(p, iFan))) ); pObjNew->pData = Abc_ObjHopFromGia( (Hop_Man_t *)pNtkNew->pManFunc, p, i, vReflect ); + pObjNew->fPersist = Gia_ObjLutIsMux(p, i); pObj->Value = Abc_ObjId( pObjNew ); } Vec_PtrFree( vReflect ); diff --git a/src/base/io/ioWriteVerilog.c b/src/base/io/ioWriteVerilog.c index ad49e93a..4c55b599 100644 --- a/src/base/io/ioWriteVerilog.c +++ b/src/base/io/ioWriteVerilog.c @@ -567,6 +567,14 @@ void Io_WriteVerilogObjects( FILE * pFile, Abc_Ntk_t * pNtk, int fOnlyAnds ) Hop_IthVar((Hop_Man_t *)pNtk->pManFunc, k)->pData = Extra_UtilStrsav(Io_WriteVerilogGetName(Abc_ObjName(pFanin))); // write the formula Hop_ObjPrintVerilog( pFile, pFunc, vLevels, 0, fOnlyAnds ); + if ( pObj->fPersist ) + { + Abc_Obj_t * pFan0 = Abc_ObjFanin0(Abc_ObjFanin(pObj, 0)); + Abc_Obj_t * pFan1 = Abc_ObjFanin0(Abc_ObjFanin(pObj, 1)); + int Cond = Abc_ObjIsNode(pFan0) && Abc_ObjIsNode(pFan1) && !pFan0->fPersist && !pFan1->fPersist; + fprintf( pFile, "; // MUXF7 %s\n", Cond ? "":"to be legalized" ); + } + else fprintf( pFile, ";\n" ); // clear the input names Abc_ObjForEachFanin( pObj, pFanin, k ) -- cgit v1.2.3 From 9b759067405c1a5e82c4424db642b6436dbc6647 Mon Sep 17 00:00:00 2001 From: Alan Mishchenko Date: Wed, 28 Apr 2021 00:11:02 -0700 Subject: Several changes for standard mapping. --- src/base/abci/abc.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'src/base') diff --git a/src/base/abci/abc.c b/src/base/abci/abc.c index 417c7909..4297c81d 100644 --- a/src/base/abci/abc.c +++ b/src/base/abci/abc.c @@ -29886,8 +29886,10 @@ static inline int Abc_NtkCompareWithBest( Abc_Ntk_t * pBest, Abc_Ntk_t * p, Abc_NtkPoNum(pBest) != Abc_NtkPoNum(p) || Abc_NtkLatchNum(pBest) != Abc_NtkLatchNum(p) || strcmp(Abc_NtkName(pBest), Abc_NtkName(p)) || - (!fArea && (*pnBestNtkLevels > nNtkLevels || (*pnBestNtkLevels == nNtkLevels && *pnBestNtkDelay > nNtkDelay ))) || - ( fArea && (*pnBestNtkNodes > nNtkNodes || (*pnBestNtkNodes == nNtkNodes && *pnBestNtkArea > nNtkArea ))) +// (!fArea && (*pnBestNtkLevels > nNtkLevels || (*pnBestNtkLevels == nNtkLevels && *pnBestNtkDelay > nNtkDelay ))) || +// ( fArea && (*pnBestNtkNodes > nNtkNodes || (*pnBestNtkNodes == nNtkNodes && *pnBestNtkArea > nNtkArea ))) + (!fArea && (*pnBestNtkDelay > nNtkDelay || (*pnBestNtkDelay == nNtkDelay && *pnBestNtkArea > nNtkArea ))) || + ( fArea && (*pnBestNtkArea > nNtkArea || (*pnBestNtkArea == nNtkArea && *pnBestNtkDelay > nNtkDelay ))) ) { *pnBestNtkArea = nNtkArea; -- cgit v1.2.3 From 645752f7d651b07a0ebd7cac827d6ce5dd5bd266 Mon Sep 17 00:00:00 2001 From: Alan Mishchenko Date: Fri, 30 Apr 2021 16:12:15 -0700 Subject: Making sure read_bench can read nodes up to 15 inputs. --- src/base/io/ioReadBench.c | 4 ++-- src/base/io/ioReadBlifMv.c | 7 ++++--- 2 files changed, 6 insertions(+), 5 deletions(-) (limited to 'src/base') diff --git a/src/base/io/ioReadBench.c b/src/base/io/ioReadBench.c index 3ea3fb70..42eb908d 100644 --- a/src/base/io/ioReadBench.c +++ b/src/base/io/ioReadBench.c @@ -88,7 +88,7 @@ Abc_Ntk_t * Io_ReadBenchNetwork( Extra_FileReader_t * p ) Abc_Ntk_t * pNtk; Abc_Obj_t * pNode, * pNet; Vec_Str_t * vString; - unsigned uTruth[8]; + unsigned uTruth[2048]; char * pType, ** ppNames, * pString; int iLine, nNames, nDigits, fLutsPresent = 0; @@ -161,7 +161,7 @@ Abc_Ntk_t * Io_ReadBenchNetwork( Extra_FileReader_t * p ) ppNames = (char **)vTokens->pArray + 3; nNames = vTokens->nSize - 3; // check the number of inputs - if ( nNames > 8 ) + if ( nNames > 15 ) { printf( "%s: Currently cannot read truth tables with more than 8 inputs (%d).\n", Extra_FileReaderGetFileName(p), nNames ); Vec_StrFree( vString ); diff --git a/src/base/io/ioReadBlifMv.c b/src/base/io/ioReadBlifMv.c index c1808ef5..098f94a1 100644 --- a/src/base/io/ioReadBlifMv.c +++ b/src/base/io/ioReadBlifMv.c @@ -1351,7 +1351,8 @@ static int Io_MvParseLineSubckt( Io_MvMod_t * p, char * pLine ) Abc_Ntk_t * pModel; Abc_Obj_t * pBox, * pNet, * pTerm; char * pToken, * pName, * pName2, ** ppNames; - int nEquals, Last, i, k; + int nEquals, i, k; + word Last; // split the line into tokens nEquals = Io_MvCountChars( pLine, '=' ); @@ -1404,9 +1405,9 @@ static int Io_MvParseLineSubckt( Io_MvMod_t * p, char * pLine ) pName2 = NULL; pName = Abc_ObjName(Abc_ObjFanout0(pTerm)); for ( k = 0; k < nEquals; k++ ) - if ( !strcmp( ppNames[2*((k+Last)%nEquals)], pName ) ) + if ( !strcmp( ppNames[2*(int)((k+Last)%nEquals)], pName ) ) { - pName2 = ppNames[2*((k+Last)%nEquals)+1]; + pName2 = ppNames[2*(int)((k+Last)%nEquals)+1]; Last = k+Last+1; break; } -- cgit v1.2.3 From 7d90895dcf97c726deab121bb042e68abda301e9 Mon Sep 17 00:00:00 2001 From: Alan Mishchenko Date: Sat, 1 May 2021 22:44:29 -0700 Subject: Experiments with LUT mapping for small functions. --- src/base/abci/abc.c | 68 ++++++++++++++++++++++++++++++++++++++++++++++++ src/base/abci/abcNtbdd.c | 9 ++++--- 2 files changed, 73 insertions(+), 4 deletions(-) (limited to 'src/base') diff --git a/src/base/abci/abc.c b/src/base/abci/abc.c index 4297c81d..65aaf360 100644 --- a/src/base/abci/abc.c +++ b/src/base/abci/abc.c @@ -485,6 +485,7 @@ static int Abc_CommandAbc9Of ( Abc_Frame_t * pAbc, int argc, cha static int Abc_CommandAbc9Pack ( Abc_Frame_t * pAbc, int argc, char ** argv ); static int Abc_CommandAbc9Edge ( Abc_Frame_t * pAbc, int argc, char ** argv ); static int Abc_CommandAbc9SatLut ( Abc_Frame_t * pAbc, int argc, char ** argv ); +static int Abc_CommandAbc9MinLut ( Abc_Frame_t * pAbc, int argc, char ** argv ); static int Abc_CommandAbc9Unmap ( Abc_Frame_t * pAbc, int argc, char ** argv ); static int Abc_CommandAbc9Struct ( Abc_Frame_t * pAbc, int argc, char ** argv ); static int Abc_CommandAbc9Trace ( Abc_Frame_t * pAbc, int argc, char ** argv ); @@ -1208,6 +1209,7 @@ void Abc_Init( Abc_Frame_t * pAbc ) Cmd_CommandAdd( pAbc, "ABC9", "&pack", Abc_CommandAbc9Pack, 0 ); Cmd_CommandAdd( pAbc, "ABC9", "&edge", Abc_CommandAbc9Edge, 0 ); Cmd_CommandAdd( pAbc, "ABC9", "&satlut", Abc_CommandAbc9SatLut, 0 ); + Cmd_CommandAdd( pAbc, "ABC9", "&minlut", Abc_CommandAbc9MinLut, 0 ); Cmd_CommandAdd( pAbc, "ABC9", "&unmap", Abc_CommandAbc9Unmap, 0 ); Cmd_CommandAdd( pAbc, "ABC9", "&struct", Abc_CommandAbc9Struct, 0 ); Cmd_CommandAdd( pAbc, "ABC9", "&trace", Abc_CommandAbc9Trace, 0 ); @@ -40810,6 +40812,72 @@ usage: return 1; } +/**Function************************************************************* + + Synopsis [] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +int Abc_CommandAbc9MinLut( Abc_Frame_t * pAbc, int argc, char ** argv ) +{ + extern Gia_Man_t * Gia_ManPerformMinLut( Gia_Man_t * p, int GroupSize, int LutSize, int fVerbose ); + Gia_Man_t * pTemp; + int c, LutSize = 6, GroupSize = 3, fVerbose = 0; + Extra_UtilGetoptReset(); + while ( ( c = Extra_UtilGetopt( argc, argv, "KGvh" ) ) != EOF ) + { + switch ( c ) + { + case 'K': + if ( globalUtilOptind >= argc ) + { + Abc_Print( -1, "Command line switch \"-K\" should be followed by a positive integer.\n" ); + goto usage; + } + LutSize = atoi(argv[globalUtilOptind]); + globalUtilOptind++; + break; + case 'G': + if ( globalUtilOptind >= argc ) + { + Abc_Print( -1, "Command line switch \"-G\" should be followed by a positive integer.\n" ); + goto usage; + } + GroupSize = atoi(argv[globalUtilOptind]); + globalUtilOptind++; + break; + case 'v': + fVerbose ^= 1; + break; + case 'h': + default: + goto usage; + } + } + if ( pAbc->pGia == NULL ) + { + Abc_Print( -1, "Empty GIA network.\n" ); + return 1; + } + pTemp = Gia_ManPerformMinLut( pAbc->pGia, GroupSize, LutSize, fVerbose ); + //Abc_FrameUpdateGia( pAbc, pTemp ); + return 0; + +usage: + Abc_Print( -2, "usage: &minlut [-KG num] [-vh]\n" ); + Abc_Print( -2, "\t performs specialized LUT mapping\n" ); + Abc_Print( -2, "\t-K num : the LUT size for mapping [default = %d]\n", LutSize ); + Abc_Print( -2, "\t-G num : the output group size [default = %d]\n", GroupSize ); + Abc_Print( -2, "\t-v : toggles verbose output [default = %s]\n", fVerbose? "yes": "no" ); + Abc_Print( -2, "\t-h : prints the command usage\n"); + return 1; +} + /**Function************************************************************* Synopsis [] diff --git a/src/base/abci/abcNtbdd.c b/src/base/abci/abcNtbdd.c index aa35aa6a..185696f2 100644 --- a/src/base/abci/abcNtbdd.c +++ b/src/base/abci/abcNtbdd.c @@ -34,7 +34,7 @@ ABC_NAMESPACE_IMPL_START #ifdef ABC_USE_CUDD -static int Abc_NtkBddToMuxesPerformGlo( Abc_Ntk_t * pNtk, Abc_Ntk_t * pNtkNew, int Limit ); + int Abc_NtkBddToMuxesPerformGlo( Abc_Ntk_t * pNtk, Abc_Ntk_t * pNtkNew, int Limit, int fReorder ); static void Abc_NtkBddToMuxesPerform( Abc_Ntk_t * pNtk, Abc_Ntk_t * pNtkNew ); static Abc_Obj_t * Abc_NodeBddToMuxes( Abc_Obj_t * pNodeOld, Abc_Ntk_t * pNtkNew ); static Abc_Obj_t * Abc_NodeBddToMuxes_rec( DdManager * dd, DdNode * bFunc, Abc_Ntk_t * pNtkNew, st__table * tBdd2Node ); @@ -135,7 +135,7 @@ Abc_Ntk_t * Abc_NtkBddToMuxes( Abc_Ntk_t * pNtk, int fGlobal, int Limit ) pNtkNew = Abc_NtkStartFrom( pNtk, ABC_NTK_LOGIC, ABC_FUNC_SOP ); if ( fGlobal ) { - if ( !Abc_NtkBddToMuxesPerformGlo( pNtk, pNtkNew, Limit ) ) + if ( !Abc_NtkBddToMuxesPerformGlo( pNtk, pNtkNew, Limit, 0 ) ) { Abc_NtkDelete( pNtkNew ); return NULL; @@ -265,13 +265,13 @@ Abc_Obj_t * Abc_NodeBddToMuxes_rec( DdManager * dd, DdNode * bFunc, Abc_Ntk_t * SeeAlso [] ***********************************************************************/ -int Abc_NtkBddToMuxesPerformGlo( Abc_Ntk_t * pNtk, Abc_Ntk_t * pNtkNew, int Limit ) +int Abc_NtkBddToMuxesPerformGlo( Abc_Ntk_t * pNtk, Abc_Ntk_t * pNtkNew, int Limit, int fReorder ) { DdManager * dd; Abc_Obj_t * pObj, * pObjNew; int i; st__table * tBdd2Node; assert( Abc_NtkIsStrash(pNtk) ); - dd = (DdManager *)Abc_NtkBuildGlobalBdds( pNtk, Limit, 1, 1, 0, 0 ); + dd = (DdManager *)Abc_NtkBuildGlobalBdds( pNtk, Limit, 1, 1, fReorder, 0 ); if ( dd == NULL ) { printf( "Construction of global BDDs has failed.\n" ); @@ -410,6 +410,7 @@ void * Abc_NtkBuildGlobalBdds( Abc_Ntk_t * pNtk, int nBddSizeMax, int fDropInter if ( fReorder ) { Cudd_ReduceHeap( dd, CUDD_REORDER_SYMM_SIFT, 1 ); +// Cudd_ReduceHeap( dd, CUDD_REORDER_SYMM_SIFT, 1 ); Cudd_AutodynDisable( dd ); } // Cudd_PrintInfo( dd, stdout ); -- cgit v1.2.3 From 17476146caa0184f908cfc908520375d788a8ba1 Mon Sep 17 00:00:00 2001 From: Alan Mishchenko Date: Sat, 8 May 2021 19:07:10 -0700 Subject: Fixing mismatch in &cec -x which should return undecided rather than non-equivalent when the miter cannot be reduced to constant 0. --- src/base/abci/abc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/base') diff --git a/src/base/abci/abc.c b/src/base/abci/abc.c index 65aaf360..f1e09980 100644 --- a/src/base/abci/abc.c +++ b/src/base/abci/abc.c @@ -37435,7 +37435,7 @@ int Abc_CommandAbc9Cec( Abc_Frame_t * pAbc, int argc, char ** argv ) if ( Gia_ManAndNum(pNew) == 0 ) Abc_Print( 1, "Networks are equivalent. " ); else - Abc_Print( 1, "Networks are NOT EQUIVALENT. " ); + Abc_Print( 1, "Networks are UNDECIDED. " ); Abc_PrintTime( 1, "Time", Abc_Clock() - clk ); Gia_ManStop( pNew ); } -- cgit v1.2.3 From 76bed2055cc171109a86bf56c6da00aa4d251a30 Mon Sep 17 00:00:00 2001 From: Alan Mishchenko Date: Sat, 8 May 2021 20:10:44 -0700 Subject: Updating LUT synthesis code. --- src/base/abci/abc.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'src/base') diff --git a/src/base/abci/abc.c b/src/base/abci/abc.c index f1e09980..15a4857b 100644 --- a/src/base/abci/abc.c +++ b/src/base/abci/abc.c @@ -48456,6 +48456,7 @@ usage: ***********************************************************************/ int Abc_CommandAbc9Test( Abc_Frame_t * pAbc, int argc, char ** argv ) { + extern void Gia_ManSimInfoTryTest( Gia_Man_t * p, int fSmall ); extern void Gia_RsbEnumerateWindows( Gia_Man_t * p, int nInputsMax, int nLevelsMax ); extern int Gia_ManSumTotalOfSupportSizes( Gia_Man_t * p ); int c, fVerbose = 0; @@ -48519,8 +48520,8 @@ int Abc_CommandAbc9Test( Abc_Frame_t * pAbc, int argc, char ** argv ) // return 1; // } // Abc_FrameUpdateGia( pAbc, Abc_Procedure(pAbc->pGia) ); -// Gia_ManTryResub( pAbc->pGia ); - printf( "AIG in \"%s\" has the sum of output support sizes equal to %d.\n", pAbc->pGia->pSpec, Gia_ManSumTotalOfSupportSizes(pAbc->pGia) ); + Gia_ManSimInfoTryTest( pAbc->pGia, fSwitch ); +// printf( "AIG in \"%s\" has the sum of output support sizes equal to %d.\n", pAbc->pGia->pSpec, Gia_ManSumTotalOfSupportSizes(pAbc->pGia) ); return 0; usage: Abc_Print( -2, "usage: &test [-FW num] [-svh]\n" ); -- cgit v1.2.3 From aa9fe1f24094d0423cc32cbd6e9682ea2a3935cb Mon Sep 17 00:00:00 2001 From: Alan Mishchenko Date: Tue, 11 May 2021 15:04:15 -0700 Subject: Updating LUT synthesis code. --- src/base/abci/abc.c | 100 +++++++++++++++++++++++++++++++++++++++++---- src/base/io/ioWriteBench.c | 2 +- 2 files changed, 92 insertions(+), 10 deletions(-) (limited to 'src/base') diff --git a/src/base/abci/abc.c b/src/base/abci/abc.c index 15a4857b..ae97e4dd 100644 --- a/src/base/abci/abc.c +++ b/src/base/abci/abc.c @@ -486,6 +486,7 @@ static int Abc_CommandAbc9Pack ( Abc_Frame_t * pAbc, int argc, cha static int Abc_CommandAbc9Edge ( Abc_Frame_t * pAbc, int argc, char ** argv ); static int Abc_CommandAbc9SatLut ( Abc_Frame_t * pAbc, int argc, char ** argv ); static int Abc_CommandAbc9MinLut ( Abc_Frame_t * pAbc, int argc, char ** argv ); +static int Abc_CommandAbc9MinSim ( Abc_Frame_t * pAbc, int argc, char ** argv ); static int Abc_CommandAbc9Unmap ( Abc_Frame_t * pAbc, int argc, char ** argv ); static int Abc_CommandAbc9Struct ( Abc_Frame_t * pAbc, int argc, char ** argv ); static int Abc_CommandAbc9Trace ( Abc_Frame_t * pAbc, int argc, char ** argv ); @@ -1210,6 +1211,7 @@ void Abc_Init( Abc_Frame_t * pAbc ) Cmd_CommandAdd( pAbc, "ABC9", "&edge", Abc_CommandAbc9Edge, 0 ); Cmd_CommandAdd( pAbc, "ABC9", "&satlut", Abc_CommandAbc9SatLut, 0 ); Cmd_CommandAdd( pAbc, "ABC9", "&minlut", Abc_CommandAbc9MinLut, 0 ); + Cmd_CommandAdd( pAbc, "ABC9", "&minsim", Abc_CommandAbc9MinSim, 0 ); Cmd_CommandAdd( pAbc, "ABC9", "&unmap", Abc_CommandAbc9Unmap, 0 ); Cmd_CommandAdd( pAbc, "ABC9", "&struct", Abc_CommandAbc9Struct, 0 ); Cmd_CommandAdd( pAbc, "ABC9", "&trace", Abc_CommandAbc9Trace, 0 ); @@ -40825,11 +40827,13 @@ usage: ***********************************************************************/ int Abc_CommandAbc9MinLut( Abc_Frame_t * pAbc, int argc, char ** argv ) { - extern Gia_Man_t * Gia_ManPerformMinLut( Gia_Man_t * p, int GroupSize, int LutSize, int fVerbose ); - Gia_Man_t * pTemp; - int c, LutSize = 6, GroupSize = 3, fVerbose = 0; + extern void Gia_ManSimInfoSynth( Gia_Man_t * p, char * pFileName, int GroupSize, int Thresh ); + //extern Gia_Man_t * Gia_ManPerformMinLut( Gia_Man_t * p, int GroupSize, int LutSize, int fVerbose ); + //Gia_Man_t * pTemp; + char * pFileName = NULL; + int c, LutSize = 6, GroupSize = 3, Limit = 0, fVerbose = 0; Extra_UtilGetoptReset(); - while ( ( c = Extra_UtilGetopt( argc, argv, "KGvh" ) ) != EOF ) + while ( ( c = Extra_UtilGetopt( argc, argv, "KGLvh" ) ) != EOF ) { switch ( c ) { @@ -40851,6 +40855,15 @@ int Abc_CommandAbc9MinLut( Abc_Frame_t * pAbc, int argc, char ** argv ) GroupSize = atoi(argv[globalUtilOptind]); globalUtilOptind++; break; + case 'L': + if ( globalUtilOptind >= argc ) + { + Abc_Print( -1, "Command line switch \"-L\" should be followed by a positive integer.\n" ); + goto usage; + } + Limit = atoi(argv[globalUtilOptind]); + globalUtilOptind++; + break; case 'v': fVerbose ^= 1; break; @@ -40864,17 +40877,86 @@ int Abc_CommandAbc9MinLut( Abc_Frame_t * pAbc, int argc, char ** argv ) Abc_Print( -1, "Empty GIA network.\n" ); return 1; } - pTemp = Gia_ManPerformMinLut( pAbc->pGia, GroupSize, LutSize, fVerbose ); + if ( argc == globalUtilOptind + 1 ) + { + FILE * pFile = fopen( argv[globalUtilOptind], "rb" ); + if ( pFile == NULL ) + { + Abc_Print( -1, "Abc_CommandAbc9BCore(): Cannot open file \"%s\" for writing the proof.\n", argv[globalUtilOptind] ); + return 0; + } + fclose( pFile ); + pFileName = argv[globalUtilOptind]; + } + //pTemp = Gia_ManPerformMinLut( pAbc->pGia, GroupSize, LutSize, fVerbose ); //Abc_FrameUpdateGia( pAbc, pTemp ); + Gia_ManSimInfoSynth( pAbc->pGia, pFileName, GroupSize, Limit ); return 0; usage: - Abc_Print( -2, "usage: &minlut [-KG num] [-vh]\n" ); + Abc_Print( -2, "usage: &minlut [-KGL num] [-vh] \n" ); Abc_Print( -2, "\t performs specialized LUT mapping\n" ); - Abc_Print( -2, "\t-K num : the LUT size for mapping [default = %d]\n", LutSize ); - Abc_Print( -2, "\t-G num : the output group size [default = %d]\n", GroupSize ); - Abc_Print( -2, "\t-v : toggles verbose output [default = %s]\n", fVerbose? "yes": "no" ); + Abc_Print( -2, "\t-K num : the LUT size for mapping [default = %d]\n", LutSize ); + Abc_Print( -2, "\t-G num : the output group size [default = %d]\n", GroupSize ); + Abc_Print( -2, "\t-L num : the limit when patterns count [default = %d]\n", Limit ); + Abc_Print( -2, "\t-v : toggles verbose output [default = %s]\n", fVerbose? "yes": "no" ); + Abc_Print( -2, "\t-h : prints the command usage\n"); + Abc_Print( -2, "\t : file name with simulation information\n"); + return 1; +} + +/**Function************************************************************* + + Synopsis [] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +int Abc_CommandAbc9MinSim( Abc_Frame_t * pAbc, int argc, char ** argv ) +{ + extern void Gia_ManSimInfoPassTest( Gia_Man_t * p, char * pFileName, char * pFileName2, int fCompare ); + int c, fCompare = 0, fVerbose = 0; + Extra_UtilGetoptReset(); + while ( ( c = Extra_UtilGetopt( argc, argv, "cvh" ) ) != EOF ) + { + switch ( c ) + { + case 'c': + fCompare ^= 1; + break; + case 'v': + fVerbose ^= 1; + break; + case 'h': + default: + goto usage; + } + } + if ( pAbc->pGia == NULL ) + { + Abc_Print( -1, "Empty GIA network.\n" ); + return 1; + } + if ( argc != globalUtilOptind + 2 ) + { + Abc_Print( -1, "Expecting two file names on the command line.\n" ); + return 1; + } + Gia_ManSimInfoPassTest( pAbc->pGia, argv[globalUtilOptind], argv[globalUtilOptind+1], fCompare ); + return 0; + +usage: + Abc_Print( -2, "usage: &minsim [-cvh] \n" ); + Abc_Print( -2, "\t performs specialized AIG simulation\n" ); + Abc_Print( -2, "\t-c : toggles comparing simulation patterns [default = %s]\n", fCompare? "yes": "no" ); + Abc_Print( -2, "\t-v : toggles verbose output [default = %s]\n", fVerbose? "yes": "no" ); Abc_Print( -2, "\t-h : prints the command usage\n"); + Abc_Print( -2, "\t : file name with simulation information\n"); + Abc_Print( -2, "\t : file name with simulation information\n"); return 1; } diff --git a/src/base/io/ioWriteBench.c b/src/base/io/ioWriteBench.c index 81d64582..23de719e 100644 --- a/src/base/io/ioWriteBench.c +++ b/src/base/io/ioWriteBench.c @@ -259,7 +259,7 @@ int Io_WriteBenchLutOneNode( FILE * pFile, Abc_Obj_t * pNode, Vec_Int_t * vTruth int i, nFanins; assert( Abc_ObjIsNode(pNode) ); nFanins = Abc_ObjFaninNum(pNode); - assert( nFanins <= 8 ); + assert( nFanins <= 15 ); // compute the truth table pTruth = Hop_ManConvertAigToTruth( (Hop_Man_t *)pNode->pNtk->pManFunc, Hop_Regular((Hop_Obj_t *)pNode->pData), nFanins, vTruth, 0 ); if ( Hop_IsComplement((Hop_Obj_t *)pNode->pData) ) -- cgit v1.2.3 From e6a47c3e41486f238be6d798fbf68a83cd11810a Mon Sep 17 00:00:00 2001 From: Alan Mishchenko Date: Tue, 11 May 2021 15:54:43 -0700 Subject: Disable cube-sort when deriving SOPs. --- src/base/abc/abc.h | 2 +- src/base/abc/abcFunc.c | 13 +++++++------ src/base/abci/abc.c | 15 ++++++++++++--- src/base/abci/abcEspresso.c | 2 +- src/base/abci/abcFxu.c | 2 +- src/base/abci/abcIvy.c | 4 ++-- src/base/abci/abcMap.c | 2 +- src/base/abci/abcPrint.c | 2 +- src/base/abci/abcUnreach.c | 2 +- src/base/io/ioWriteDot.c | 4 ++-- 10 files changed, 29 insertions(+), 19 deletions(-) (limited to 'src/base') diff --git a/src/base/abc/abc.h b/src/base/abc/abc.h index 65ab604c..e7982b02 100644 --- a/src/base/abc/abc.h +++ b/src/base/abc/abc.h @@ -671,7 +671,7 @@ extern ABC_DLL Abc_Ntk_t * Abc_NtkFraigRestore( int nPatsRand, int nPatsD extern ABC_DLL void Abc_NtkFraigStoreClean(); /*=== abcFunc.c ==========================================================*/ extern ABC_DLL int Abc_NtkSopToBdd( Abc_Ntk_t * pNtk ); -extern ABC_DLL int Abc_NtkBddToSop( Abc_Ntk_t * pNtk, int fMode, int nCubeLimit ); +extern ABC_DLL int Abc_NtkBddToSop( Abc_Ntk_t * pNtk, int fMode, int nCubeLimit, int fCubeSort ); extern ABC_DLL void Abc_NodeBddToCnf( Abc_Obj_t * pNode, Mem_Flex_t * pMmMan, Vec_Str_t * vCube, int fAllPrimes, char ** ppSop0, char ** ppSop1 ); extern ABC_DLL void Abc_NtkLogicMakeDirectSops( Abc_Ntk_t * pNtk ); extern ABC_DLL int Abc_NtkSopToAig( Abc_Ntk_t * pNtk ); diff --git a/src/base/abc/abcFunc.c b/src/base/abc/abcFunc.c index 8f68d4be..84ecf7bf 100644 --- a/src/base/abc/abcFunc.c +++ b/src/base/abc/abcFunc.c @@ -356,7 +356,7 @@ char * Abc_ConvertBddToSop( Mem_Flex_t * pMan, DdManager * dd, DdNode * bFuncOn, SeeAlso [] ***********************************************************************/ -int Abc_NtkBddToSop( Abc_Ntk_t * pNtk, int fMode, int nCubeLimit ) +int Abc_NtkBddToSop( Abc_Ntk_t * pNtk, int fMode, int nCubeLimit, int fCubeSort ) { Vec_Int_t * vGuide; Vec_Str_t * vCube; @@ -445,6 +445,7 @@ int Abc_NtkBddToSop( Abc_Ntk_t * pNtk, int fMode, int nCubeLimit ) Extra_StopManager( dd ); // reorder fanins and cubes to make SOPs more human-readable + if ( fCubeSort ) Abc_NtkSortSops( pNtk ); return 1; } @@ -788,7 +789,7 @@ DdNode * Abc_ConvertAigToBdd( DdManager * dd, Hop_Obj_t * pRoot ) #else int Abc_NtkSopToBdd( Abc_Ntk_t * pNtk ) { return 1; } -int Abc_NtkBddToSop( Abc_Ntk_t * pNtk, int fMode, int nCubeLimit ) { return 1; } +int Abc_NtkBddToSop( Abc_Ntk_t * pNtk, int fMode, int nCubeLimit, int fCubeSort ) { return 1; } void Abc_NodeBddToCnf( Abc_Obj_t * pNode, Mem_Flex_t * pMmMan, Vec_Str_t * vCube, int fAllPrimes, char ** ppSop0, char ** ppSop1 ) {} void Abc_NtkLogicMakeDirectSops( Abc_Ntk_t * pNtk ) {} int Abc_NtkAigToBdd( Abc_Ntk_t * pNtk ) { return 1; } @@ -1178,17 +1179,17 @@ int Abc_NtkToSop( Abc_Ntk_t * pNtk, int fMode, int nCubeLimit ) return 1; if ( !Abc_NtkSopToBdd(pNtk) ) return 0; - return Abc_NtkBddToSop(pNtk, fMode, nCubeLimit); + return Abc_NtkBddToSop(pNtk, fMode, nCubeLimit, 1); } if ( Abc_NtkHasMapping(pNtk) ) return Abc_NtkMapToSop(pNtk); if ( Abc_NtkHasBdd(pNtk) ) - return Abc_NtkBddToSop(pNtk, fMode, nCubeLimit); + return Abc_NtkBddToSop(pNtk, fMode, nCubeLimit, 1); if ( Abc_NtkHasAig(pNtk) ) { if ( !Abc_NtkAigToBdd(pNtk) ) return 0; - return Abc_NtkBddToSop(pNtk, fMode, nCubeLimit); + return Abc_NtkBddToSop(pNtk, fMode, nCubeLimit, 1); } assert( 0 ); return 0; @@ -1253,7 +1254,7 @@ int Abc_NtkToAig( Abc_Ntk_t * pNtk ) } if ( Abc_NtkHasBdd(pNtk) ) { - if ( !Abc_NtkBddToSop(pNtk, -1, ABC_INFINITY) ) + if ( !Abc_NtkBddToSop(pNtk, -1, ABC_INFINITY, 1) ) return 0; return Abc_NtkSopToAig(pNtk); } diff --git a/src/base/abci/abc.c b/src/base/abci/abc.c index ae97e4dd..7fd645ad 100644 --- a/src/base/abci/abc.c +++ b/src/base/abci/abc.c @@ -10706,11 +10706,11 @@ usage: int Abc_CommandSop( Abc_Frame_t * pAbc, int argc, char ** argv ) { Abc_Ntk_t * pNtk = Abc_FrameReadNtk(pAbc); - int c, fMode = -1, nCubeLimit = 1000000; + int c, fCubeSort = 1, fMode = -1, nCubeLimit = 1000000; // set defaults Extra_UtilGetoptReset(); - while ( ( c = Extra_UtilGetopt( argc, argv, "Cdnh" ) ) != EOF ) + while ( ( c = Extra_UtilGetopt( argc, argv, "Csdnh" ) ) != EOF ) { switch ( c ) { @@ -10725,6 +10725,9 @@ int Abc_CommandSop( Abc_Frame_t * pAbc, int argc, char ** argv ) if ( nCubeLimit < 0 ) goto usage; break; + case 's': + fCubeSort ^= 1; + break; case 'd': fMode = 1; break; @@ -10747,6 +10750,11 @@ int Abc_CommandSop( Abc_Frame_t * pAbc, int argc, char ** argv ) Abc_Print( -1, "Converting to SOP is possible only for logic networks.\n" ); return 1; } + if ( !fCubeSort && Abc_NtkHasBdd(pNtk) && !Abc_NtkBddToSop(pNtk, -1, ABC_INFINITY, 0) ) + { + Abc_Print( -1, "Converting to SOP has failed.\n" ); + return 0; + } if ( !Abc_NtkToSop(pNtk, fMode, nCubeLimit) ) { Abc_Print( -1, "Converting to SOP has failed.\n" ); @@ -10755,9 +10763,10 @@ int Abc_CommandSop( Abc_Frame_t * pAbc, int argc, char ** argv ) return 0; usage: - Abc_Print( -2, "usage: sop [-C num] [-dnh]\n" ); + Abc_Print( -2, "usage: sop [-C num] [-sdnh]\n" ); Abc_Print( -2, "\t converts node functions to SOP\n" ); Abc_Print( -2, "\t-C num : the limit on the number of cubes at a node [default = %d]\n", nCubeLimit ); + Abc_Print( -2, "\t-s : toggles cube sort when converting from BDDs [default = %s]\n", fCubeSort ? "yes": "no" ); Abc_Print( -2, "\t-d : toggles using only positive polarity [default = %s]\n", fMode == 1 ? "yes": "no" ); Abc_Print( -2, "\t-n : toggles using only negative polarity [default = %s]\n", fMode == 0 ? "yes": "no" ); Abc_Print( -2, "\t-h : print the command usage\n"); diff --git a/src/base/abci/abcEspresso.c b/src/base/abci/abcEspresso.c index 2da389da..9296b1e7 100644 --- a/src/base/abci/abcEspresso.c +++ b/src/base/abci/abcEspresso.c @@ -58,7 +58,7 @@ void Abc_NtkEspresso( Abc_Ntk_t * pNtk, int fVerbose ) Abc_NtkMapToSop(pNtk); else if ( Abc_NtkHasBdd(pNtk) ) { - if ( !Abc_NtkBddToSop(pNtk, -1, ABC_INFINITY) ) + if ( !Abc_NtkBddToSop(pNtk, -1, ABC_INFINITY, 1) ) { printf( "Abc_NtkEspresso(): Converting to SOPs has failed.\n" ); return; diff --git a/src/base/abci/abcFxu.c b/src/base/abci/abcFxu.c index 8da306bf..99b3a5eb 100644 --- a/src/base/abci/abcFxu.c +++ b/src/base/abci/abcFxu.c @@ -88,7 +88,7 @@ int Abc_NtkFastExtract( Abc_Ntk_t * pNtk, Fxu_Data_t * p ) if ( Abc_NtkIsSopLogic(pNtk) ) { // to make sure the SOPs are SCC-free // Abc_NtkSopToBdd(pNtk); -// Abc_NtkBddToSop(pNtk); +// Abc_NtkBddToSop(pNtk, 1); } // get the network in the SOP form if ( !Abc_NtkToSop(pNtk, -1, ABC_INFINITY) ) diff --git a/src/base/abci/abcIvy.c b/src/base/abci/abcIvy.c index 3f268ea2..c680f85a 100644 --- a/src/base/abci/abcIvy.c +++ b/src/base/abci/abcIvy.c @@ -91,7 +91,7 @@ Ivy_Man_t * Abc_NtkIvyBefore( Abc_Ntk_t * pNtk, int fSeq, int fUseDc ) assert( !Abc_NtkIsNetlist(pNtk) ); if ( Abc_NtkIsBddLogic(pNtk) ) { - if ( !Abc_NtkBddToSop(pNtk, -1, ABC_INFINITY) ) + if ( !Abc_NtkBddToSop(pNtk, -1, ABC_INFINITY, 1) ) { printf( "Abc_NtkIvyBefore(): Converting to SOPs has failed.\n" ); return NULL; @@ -640,7 +640,7 @@ Abc_Ntk_t * Abc_NtkIvy( Abc_Ntk_t * pNtk ) assert( !Abc_NtkIsNetlist(pNtk) ); if ( Abc_NtkIsBddLogic(pNtk) ) { - if ( !Abc_NtkBddToSop(pNtk, -1, ABC_INFINITY) ) + if ( !Abc_NtkBddToSop(pNtk, -1, ABC_INFINITY, 1) ) { Vec_IntFree( vInit ); printf( "Abc_NtkIvy(): Converting to SOPs has failed.\n" ); diff --git a/src/base/abci/abcMap.c b/src/base/abci/abcMap.c index 5389b669..cef96351 100644 --- a/src/base/abci/abcMap.c +++ b/src/base/abci/abcMap.c @@ -612,7 +612,7 @@ Abc_Ntk_t * Abc_NtkFromMapSuperChoice( Map_Man_t * pMan, Abc_Ntk_t * pNtk ) // duplicate the network pNtkNew2 = Abc_NtkDup( pNtk ); pNtkNew = Abc_NtkMulti( pNtkNew2, 0, 20, 0, 0, 1, 0 ); - if ( !Abc_NtkBddToSop( pNtkNew, -1, ABC_INFINITY ) ) + if ( !Abc_NtkBddToSop( pNtkNew, -1, ABC_INFINITY, 1 ) ) { printf( "Abc_NtkFromMapSuperChoice(): Converting to SOPs has failed.\n" ); return NULL; diff --git a/src/base/abci/abcPrint.c b/src/base/abci/abcPrint.c index ad5fba91..4ffb18a9 100644 --- a/src/base/abci/abcPrint.c +++ b/src/base/abci/abcPrint.c @@ -1399,7 +1399,7 @@ void Abc_NtkPrintGates( Abc_Ntk_t * pNtk, int fUseLibrary, int fUpdateProfile ) // transform logic functions from BDD to SOP if ( (fHasBdds = Abc_NtkIsBddLogic(pNtk)) ) { - if ( !Abc_NtkBddToSop(pNtk, -1, ABC_INFINITY) ) + if ( !Abc_NtkBddToSop(pNtk, -1, ABC_INFINITY, 1) ) { printf( "Abc_NtkPrintGates(): Converting to SOPs has failed.\n" ); return; diff --git a/src/base/abci/abcUnreach.c b/src/base/abci/abcUnreach.c index ae4bc84b..5a20e5d8 100644 --- a/src/base/abci/abcUnreach.c +++ b/src/base/abci/abcUnreach.c @@ -342,7 +342,7 @@ Abc_Ntk_t * Abc_NtkConstructExdc( DdManager * dd, Abc_Ntk_t * pNtk, DdNode * bUn Abc_NtkLogicMakeSimpleCos( pNtkNew, 0 ); // transform the network to the SOP representation - if ( !Abc_NtkBddToSop( pNtkNew, -1, ABC_INFINITY ) ) + if ( !Abc_NtkBddToSop( pNtkNew, -1, ABC_INFINITY, 1 ) ) { printf( "Abc_NtkConstructExdc(): Converting to SOPs has failed.\n" ); return NULL; diff --git a/src/base/io/ioWriteDot.c b/src/base/io/ioWriteDot.c index d9687c6e..0ab3c4d2 100644 --- a/src/base/io/ioWriteDot.c +++ b/src/base/io/ioWriteDot.c @@ -100,7 +100,7 @@ void Io_WriteDotNtk( Abc_Ntk_t * pNtk, Vec_Ptr_t * vNodes, Vec_Ptr_t * vNodesSho // transform logic functions from BDD to SOP if ( (fHasBdds = Abc_NtkIsBddLogic(pNtk)) ) { - if ( !Abc_NtkBddToSop(pNtk, -1, ABC_INFINITY) ) + if ( !Abc_NtkBddToSop(pNtk, -1, ABC_INFINITY, 1) ) { printf( "Io_WriteDotNtk(): Converting to SOPs has failed.\n" ); return; @@ -463,7 +463,7 @@ void Io_WriteDotSeq( Abc_Ntk_t * pNtk, Vec_Ptr_t * vNodes, Vec_Ptr_t * vNodesSho // transform logic functions from BDD to SOP if ( (fHasBdds = Abc_NtkIsBddLogic(pNtk)) ) { - if ( !Abc_NtkBddToSop(pNtk, -1, ABC_INFINITY) ) + if ( !Abc_NtkBddToSop(pNtk, -1, ABC_INFINITY, 1) ) { printf( "Io_WriteDotNtk(): Converting to SOPs has failed.\n" ); return; -- cgit v1.2.3 From ed13c6d4d26460b0ffa2c72b1d2decc11f8ebf0d Mon Sep 17 00:00:00 2001 From: Alan Mishchenko Date: Tue, 11 May 2021 17:45:20 -0700 Subject: Updating LUT synthesis code. --- src/base/abci/abc.c | 39 +++++++++++++++++++++++++-------------- 1 file changed, 25 insertions(+), 14 deletions(-) (limited to 'src/base') diff --git a/src/base/abci/abc.c b/src/base/abci/abc.c index 7fd645ad..75099209 100644 --- a/src/base/abci/abc.c +++ b/src/base/abci/abc.c @@ -40836,32 +40836,41 @@ usage: ***********************************************************************/ int Abc_CommandAbc9MinLut( Abc_Frame_t * pAbc, int argc, char ** argv ) { - extern void Gia_ManSimInfoSynth( Gia_Man_t * p, char * pFileName, int GroupSize, int Thresh ); + extern Gia_Man_t * Gia_ManSimInfoSynth( Gia_Man_t * p, char * pFileName, int nIns, int nOuts, int LutSize, int Thresh, int fVerbose ); //extern Gia_Man_t * Gia_ManPerformMinLut( Gia_Man_t * p, int GroupSize, int LutSize, int fVerbose ); - //Gia_Man_t * pTemp; + Gia_Man_t * pTemp; char * pFileName = NULL; - int c, LutSize = 6, GroupSize = 3, Limit = 0, fVerbose = 0; + int c, nIns = 6, nOuts = 2, LutSize = 6, Limit = -1, fVerbose = 0; Extra_UtilGetoptReset(); - while ( ( c = Extra_UtilGetopt( argc, argv, "KGLvh" ) ) != EOF ) + while ( ( c = Extra_UtilGetopt( argc, argv, "IOKLvh" ) ) != EOF ) { switch ( c ) { - case 'K': + case 'I': if ( globalUtilOptind >= argc ) { - Abc_Print( -1, "Command line switch \"-K\" should be followed by a positive integer.\n" ); + Abc_Print( -1, "Command line switch \"-I\" should be followed by a positive integer.\n" ); goto usage; } - LutSize = atoi(argv[globalUtilOptind]); + nIns = atoi(argv[globalUtilOptind]); globalUtilOptind++; break; - case 'G': + case 'O': + if ( globalUtilOptind >= argc ) + { + Abc_Print( -1, "Command line switch \"-O\" should be followed by a positive integer.\n" ); + goto usage; + } + nOuts = atoi(argv[globalUtilOptind]); + globalUtilOptind++; + break; + case 'K': if ( globalUtilOptind >= argc ) { - Abc_Print( -1, "Command line switch \"-G\" should be followed by a positive integer.\n" ); + Abc_Print( -1, "Command line switch \"-K\" should be followed by a positive integer.\n" ); goto usage; } - GroupSize = atoi(argv[globalUtilOptind]); + LutSize = atoi(argv[globalUtilOptind]); globalUtilOptind++; break; case 'L': @@ -40899,15 +40908,17 @@ int Abc_CommandAbc9MinLut( Abc_Frame_t * pAbc, int argc, char ** argv ) } //pTemp = Gia_ManPerformMinLut( pAbc->pGia, GroupSize, LutSize, fVerbose ); //Abc_FrameUpdateGia( pAbc, pTemp ); - Gia_ManSimInfoSynth( pAbc->pGia, pFileName, GroupSize, Limit ); + pTemp = Gia_ManSimInfoSynth( pAbc->pGia, pFileName, nIns, nOuts, LutSize, Limit, fVerbose ); + Abc_FrameUpdateGia( pAbc, pTemp ); return 0; usage: - Abc_Print( -2, "usage: &minlut [-KGL num] [-vh] \n" ); + Abc_Print( -2, "usage: &minlut [-IOKL num] [-vh] \n" ); Abc_Print( -2, "\t performs specialized LUT mapping\n" ); + Abc_Print( -2, "\t-I num : the input support size [default = %d]\n", nIns ); + Abc_Print( -2, "\t-O num : the output group size [default = %d]\n", nOuts ); Abc_Print( -2, "\t-K num : the LUT size for mapping [default = %d]\n", LutSize ); - Abc_Print( -2, "\t-G num : the output group size [default = %d]\n", GroupSize ); - Abc_Print( -2, "\t-L num : the limit when patterns count [default = %d]\n", Limit ); + Abc_Print( -2, "\t-L num : patterns count after this limit [default = %d]\n", Limit ); Abc_Print( -2, "\t-v : toggles verbose output [default = %s]\n", fVerbose? "yes": "no" ); Abc_Print( -2, "\t-h : prints the command usage\n"); Abc_Print( -2, "\t : file name with simulation information\n"); -- cgit v1.2.3 From 610a3d3fc2a7e593c52a2532dc31d67cbd8af6ce Mon Sep 17 00:00:00 2001 From: Alan Mishchenko Date: Sat, 15 May 2021 13:28:06 -0700 Subject: Adding switch muxes -a to create networks of ADDs. --- src/base/abc/abc.h | 2 +- src/base/abci/abc.c | 12 ++++++++---- src/base/abci/abcNtbdd.c | 37 ++++++++++++++++++++++++++++--------- 3 files changed, 37 insertions(+), 14 deletions(-) (limited to 'src/base') diff --git a/src/base/abc/abc.h b/src/base/abc/abc.h index e7982b02..e7f6c0ad 100644 --- a/src/base/abc/abc.h +++ b/src/base/abc/abc.h @@ -762,7 +762,7 @@ extern ABC_DLL Abc_Ntk_t * Abc_NtkToNetlist( Abc_Ntk_t * pNtk ); extern ABC_DLL Abc_Ntk_t * Abc_NtkToNetlistBench( Abc_Ntk_t * pNtk ); /*=== abcNtbdd.c ==========================================================*/ extern ABC_DLL Abc_Ntk_t * Abc_NtkDeriveFromBdd( void * dd, void * bFunc, char * pNamePo, Vec_Ptr_t * vNamesPi ); -extern ABC_DLL Abc_Ntk_t * Abc_NtkBddToMuxes( Abc_Ntk_t * pNtk, int fGlobal, int Limit ); +extern ABC_DLL Abc_Ntk_t * Abc_NtkBddToMuxes( Abc_Ntk_t * pNtk, int fGlobal, int Limit, int fUseAdd ); extern ABC_DLL void * Abc_NtkBuildGlobalBdds( Abc_Ntk_t * pNtk, int fBddSizeMax, int fDropInternal, int fReorder, int fReverse, int fVerbose ); extern ABC_DLL void * Abc_NtkFreeGlobalBdds( Abc_Ntk_t * pNtk, int fFreeMan ); extern ABC_DLL int Abc_NtkSizeOfGlobalBdds( Abc_Ntk_t * pNtk ); diff --git a/src/base/abci/abc.c b/src/base/abci/abc.c index 75099209..84734e6f 100644 --- a/src/base/abci/abc.c +++ b/src/base/abci/abc.c @@ -11111,11 +11111,11 @@ usage: int Abc_CommandMuxes( Abc_Frame_t * pAbc, int argc, char ** argv ) { Abc_Ntk_t * pNtk, * pNtkRes; - int c, fGlobal = 0, Limit = 1000000; + int c, fGlobal = 0, fUseAdd = 0, Limit = 1000000; pNtk = Abc_FrameReadNtk(pAbc); // set defaults Extra_UtilGetoptReset(); - while ( ( c = Extra_UtilGetopt( argc, argv, "Bgh" ) ) != EOF ) + while ( ( c = Extra_UtilGetopt( argc, argv, "Bgah" ) ) != EOF ) { switch ( c ) { @@ -11133,6 +11133,9 @@ int Abc_CommandMuxes( Abc_Frame_t * pAbc, int argc, char ** argv ) case 'g': fGlobal ^= 1; break; + case 'a': + fUseAdd ^= 1; + break; case 'h': goto usage; default: @@ -11164,7 +11167,7 @@ int Abc_CommandMuxes( Abc_Frame_t * pAbc, int argc, char ** argv ) } // get the new network - pNtkRes = Abc_NtkBddToMuxes( pNtk, fGlobal, Limit ); + pNtkRes = Abc_NtkBddToMuxes( pNtk, fGlobal, Limit, fUseAdd ); if ( pNtkRes == NULL ) { Abc_Print( 0, "Converting to MUXes has failed.\n" ); @@ -11175,11 +11178,12 @@ int Abc_CommandMuxes( Abc_Frame_t * pAbc, int argc, char ** argv ) return 0; usage: - Abc_Print( -2, "usage: muxes [-B num] [-gh]\n" ); + Abc_Print( -2, "usage: muxes [-B num] [-gah]\n" ); Abc_Print( -2, "\t converts the current network into a network derived by\n" ); Abc_Print( -2, "\t replacing all nodes by DAGs isomorphic to the local BDDs\n" ); Abc_Print( -2, "\t-B : limit on live BDD nodes during collapsing [default = %d]\n", Limit ); Abc_Print( -2, "\t-g : toggle visualizing the global BDDs of primary outputs [default = %s].\n", fGlobal? "yes": "no" ); + Abc_Print( -2, "\t-a : toggle using ADDs instead of BDDs [default = %s].\n", fUseAdd? "yes": "no" ); Abc_Print( -2, "\t-h : print the command usage\n"); return 1; } diff --git a/src/base/abci/abcNtbdd.c b/src/base/abci/abcNtbdd.c index 185696f2..3c28ce4f 100644 --- a/src/base/abci/abcNtbdd.c +++ b/src/base/abci/abcNtbdd.c @@ -34,7 +34,7 @@ ABC_NAMESPACE_IMPL_START #ifdef ABC_USE_CUDD - int Abc_NtkBddToMuxesPerformGlo( Abc_Ntk_t * pNtk, Abc_Ntk_t * pNtkNew, int Limit, int fReorder ); + int Abc_NtkBddToMuxesPerformGlo( Abc_Ntk_t * pNtk, Abc_Ntk_t * pNtkNew, int Limit, int fReorder, int fUseAdd ); static void Abc_NtkBddToMuxesPerform( Abc_Ntk_t * pNtk, Abc_Ntk_t * pNtkNew ); static Abc_Obj_t * Abc_NodeBddToMuxes( Abc_Obj_t * pNodeOld, Abc_Ntk_t * pNtkNew ); static Abc_Obj_t * Abc_NodeBddToMuxes_rec( DdManager * dd, DdNode * bFunc, Abc_Ntk_t * pNtkNew, st__table * tBdd2Node ); @@ -129,13 +129,13 @@ Abc_Ntk_t * Abc_NtkDeriveFromBdd( void * dd0, void * bFunc, char * pNamePo, Vec_ SeeAlso [] ***********************************************************************/ -Abc_Ntk_t * Abc_NtkBddToMuxes( Abc_Ntk_t * pNtk, int fGlobal, int Limit ) +Abc_Ntk_t * Abc_NtkBddToMuxes( Abc_Ntk_t * pNtk, int fGlobal, int Limit, int fUseAdd ) { Abc_Ntk_t * pNtkNew; pNtkNew = Abc_NtkStartFrom( pNtk, ABC_NTK_LOGIC, ABC_FUNC_SOP ); if ( fGlobal ) { - if ( !Abc_NtkBddToMuxesPerformGlo( pNtk, pNtkNew, Limit, 0 ) ) + if ( !Abc_NtkBddToMuxesPerformGlo( pNtk, pNtkNew, Limit, 0, fUseAdd ) ) { Abc_NtkDelete( pNtkNew ); return NULL; @@ -237,8 +237,10 @@ Abc_Obj_t * Abc_NodeBddToMuxes_rec( DdManager * dd, DdNode * bFunc, Abc_Ntk_t * { Abc_Obj_t * pNodeNew, * pNodeNew0, * pNodeNew1, * pNodeNewC; assert( !Cudd_IsComplement(bFunc) ); - if ( bFunc == b1 ) + if ( bFunc == b1 || bFunc == a1 ) return Abc_NtkCreateNodeConst1(pNtkNew); + if ( bFunc == a0 ) + return Abc_NtkCreateNodeConst0(pNtkNew); if ( st__lookup( tBdd2Node, (char *)bFunc, (char **)&pNodeNew ) ) return pNodeNew; // solve for the children nodes @@ -265,9 +267,10 @@ Abc_Obj_t * Abc_NodeBddToMuxes_rec( DdManager * dd, DdNode * bFunc, Abc_Ntk_t * SeeAlso [] ***********************************************************************/ -int Abc_NtkBddToMuxesPerformGlo( Abc_Ntk_t * pNtk, Abc_Ntk_t * pNtkNew, int Limit, int fReorder ) +int Abc_NtkBddToMuxesPerformGlo( Abc_Ntk_t * pNtk, Abc_Ntk_t * pNtkNew, int Limit, int fReorder, int fUseAdd ) { DdManager * dd; + Vec_Ptr_t * vAdds = fUseAdd ? Vec_PtrAlloc(100) : NULL; Abc_Obj_t * pObj, * pObjNew; int i; st__table * tBdd2Node; assert( Abc_NtkIsStrash(pNtk) ); @@ -287,15 +290,31 @@ int Abc_NtkBddToMuxesPerformGlo( Abc_Ntk_t * pNtk, Abc_Ntk_t * pNtkNew, int Limi Abc_NtkForEachCo( pNtk, pObj, i ) { DdNode * bFunc = (DdNode *)Abc_ObjGlobalBdd(pObj); - pObjNew = Abc_NodeBddToMuxes_rec( dd, Cudd_Regular(bFunc), pNtkNew, tBdd2Node ); - if ( Cudd_IsComplement(bFunc) ) - pObjNew = Abc_NtkCreateNodeInv( pNtkNew, pObjNew ); + if ( fUseAdd ) + { + DdNode * aFunc = Cudd_BddToAdd( dd, bFunc ); Cudd_Ref( aFunc ); + pObjNew = Abc_NodeBddToMuxes_rec( dd, aFunc, pNtkNew, tBdd2Node ); + Vec_PtrPush( vAdds, aFunc ); + } + else + { + pObjNew = Abc_NodeBddToMuxes_rec( dd, Cudd_Regular(bFunc), pNtkNew, tBdd2Node ); + if ( Cudd_IsComplement(bFunc) ) + pObjNew = Abc_NtkCreateNodeInv( pNtkNew, pObjNew ); + } Abc_ObjAddFanin( pObj->pCopy, pObjNew ); } // cleanup st__free_table( tBdd2Node ); Abc_NtkFreeGlobalBdds( pNtk, 0 ); + if ( vAdds ) + { + DdNode * aTemp; + Vec_PtrForEachEntry( DdNode *, vAdds, aTemp, i ) + Cudd_RecursiveDeref( dd, aTemp ); + Vec_PtrFree( vAdds ); + } Extra_StopManager( dd ); Abc_NtkCleanCopy( pNtk ); return 1; @@ -663,7 +682,7 @@ ABC_PRT( "Time", Abc_Clock() - clk ); #else double Abc_NtkSpacePercentage( Abc_Obj_t * pNode ) { return 0.0; } -Abc_Ntk_t * Abc_NtkBddToMuxes( Abc_Ntk_t * pNtk, int fGlobal, int Limit ) { return NULL; } +Abc_Ntk_t * Abc_NtkBddToMuxes( Abc_Ntk_t * pNtk, int fGlobal, int Limit, int fUseAdd ) { return NULL; } #endif -- cgit v1.2.3 From 0ce11851bcb364abfd5d65685ab779faed4398ec Mon Sep 17 00:00:00 2001 From: Alan Mishchenko Date: Sun, 16 May 2021 20:33:53 -0700 Subject: Updating LUT synthesis code. --- src/base/abc/abcNtk.c | 9 +- src/base/abci/abc.c | 229 ++++++++++++++++++++++++++++++++++--------- src/base/abci/abcLut.c | 158 +++++++++++++++++++++++++++++ src/base/abci/abcNtbdd.c | 2 +- src/base/io/io.c | 20 +++- src/base/io/ioWriteVerilog.c | 85 +++++++++++++--- 6 files changed, 439 insertions(+), 64 deletions(-) (limited to 'src/base') diff --git a/src/base/abc/abcNtk.c b/src/base/abc/abcNtk.c index 7c54f3c4..f8e40b41 100644 --- a/src/base/abc/abcNtk.c +++ b/src/base/abc/abcNtk.c @@ -1286,6 +1286,7 @@ void Abc_NtkDelete( Abc_Ntk_t * pNtk ) Abc_Obj_t * pObj; void * pAttrMan; int TotalMemory, i; + int fWarning = 0; // int LargePiece = (4 << ABC_NUM_STEPS); if ( pNtk == NULL ) return; @@ -1310,9 +1311,11 @@ void Abc_NtkDelete( Abc_Ntk_t * pNtk ) // ABC_FREE( pObj->vFanouts.pArray ); // these flags should be always zero // if this is not true, something is wrong somewhere - assert( pObj->fMarkA == 0 ); - assert( pObj->fMarkB == 0 ); - assert( pObj->fMarkC == 0 ); +// assert( pObj->fMarkA == 0 ); +// assert( pObj->fMarkB == 0 ); +// assert( pObj->fMarkC == 0 ); + if ( !fWarning && (pObj->fMarkA || pObj->fMarkB || pObj->fMarkC) ) + { printf( "Flags A, B, or C are not zero.\n" ), fWarning = 1; } } // free the nodes if ( pNtk->pMmStep == NULL ) diff --git a/src/base/abci/abc.c b/src/base/abci/abc.c index 84734e6f..ab80eef3 100644 --- a/src/base/abci/abc.c +++ b/src/base/abci/abc.c @@ -485,8 +485,9 @@ static int Abc_CommandAbc9Of ( Abc_Frame_t * pAbc, int argc, cha static int Abc_CommandAbc9Pack ( Abc_Frame_t * pAbc, int argc, char ** argv ); static int Abc_CommandAbc9Edge ( Abc_Frame_t * pAbc, int argc, char ** argv ); static int Abc_CommandAbc9SatLut ( Abc_Frame_t * pAbc, int argc, char ** argv ); -static int Abc_CommandAbc9MinLut ( Abc_Frame_t * pAbc, int argc, char ** argv ); -static int Abc_CommandAbc9MinSim ( Abc_Frame_t * pAbc, int argc, char ** argv ); +static int Abc_CommandAbc9LNetSim ( Abc_Frame_t * pAbc, int argc, char ** argv ); +static int Abc_CommandAbc9LNetOpt ( Abc_Frame_t * pAbc, int argc, char ** argv ); +static int Abc_CommandAbc9LNetMap ( Abc_Frame_t * pAbc, int argc, char ** argv ); static int Abc_CommandAbc9Unmap ( Abc_Frame_t * pAbc, int argc, char ** argv ); static int Abc_CommandAbc9Struct ( Abc_Frame_t * pAbc, int argc, char ** argv ); static int Abc_CommandAbc9Trace ( Abc_Frame_t * pAbc, int argc, char ** argv ); @@ -1210,8 +1211,9 @@ void Abc_Init( Abc_Frame_t * pAbc ) Cmd_CommandAdd( pAbc, "ABC9", "&pack", Abc_CommandAbc9Pack, 0 ); Cmd_CommandAdd( pAbc, "ABC9", "&edge", Abc_CommandAbc9Edge, 0 ); Cmd_CommandAdd( pAbc, "ABC9", "&satlut", Abc_CommandAbc9SatLut, 0 ); - Cmd_CommandAdd( pAbc, "ABC9", "&minlut", Abc_CommandAbc9MinLut, 0 ); - Cmd_CommandAdd( pAbc, "ABC9", "&minsim", Abc_CommandAbc9MinSim, 0 ); + Cmd_CommandAdd( pAbc, "ABC9", "&lnetsim", Abc_CommandAbc9LNetSim, 0 ); + Cmd_CommandAdd( pAbc, "ABC9", "&lnetopt", Abc_CommandAbc9LNetOpt, 0 ); + Cmd_CommandAdd( pAbc, "ABC9", "&lnetmap", Abc_CommandAbc9LNetMap, 0 ); Cmd_CommandAdd( pAbc, "ABC9", "&unmap", Abc_CommandAbc9Unmap, 0 ); Cmd_CommandAdd( pAbc, "ABC9", "&struct", Abc_CommandAbc9Struct, 0 ); Cmd_CommandAdd( pAbc, "ABC9", "&trace", Abc_CommandAbc9Trace, 0 ); @@ -10411,7 +10413,7 @@ int Abc_CommandPutOnTop( Abc_Frame_t * pAbc, int argc, char ** argv ) { extern Abc_Ntk_t * Abc_NtkPutOnTop( Abc_Ntk_t * pNtk, Abc_Ntk_t * pNtk2 ); - Abc_Ntk_t * pNtk, * pNtk2, * pNtkRes; + Abc_Ntk_t * pNtk, * pNtk2, * pNtkRes = NULL; char * FileName; int fComb = 0; int c; @@ -10431,6 +10433,39 @@ int Abc_CommandPutOnTop( Abc_Frame_t * pAbc, int argc, char ** argv ) } } + if ( argc > globalUtilOptind + 1 ) + { + Abc_Ntk_t * pStrash; + for ( c = 1; c < argc; c++ ) + { + Abc_Ntk_t * pTemp, * pLogic = Io_Read( argv[c], Io_ReadFileType(argv[c]), 1, 0 ); + if ( pLogic == NULL ) + return 1; + if ( Abc_NtkIsStrash(pLogic) ) + { + pLogic = Abc_NtkToLogic( pTemp = pLogic ); + Abc_NtkDelete( pTemp ); + } + if ( pLogic == NULL ) + return 1; + if ( pNtkRes == NULL ) + pNtkRes = pLogic; + else + { + pNtkRes = Abc_NtkPutOnTop( pTemp = pNtkRes, pLogic ); + Abc_NtkDelete( pTemp ); + Abc_NtkDelete( pLogic ); + if ( pNtkRes == NULL ) + return 1; + } + } + assert( Abc_NtkIsLogic(pNtkRes) ); + pStrash = Abc_NtkStrash( pNtkRes, 1, 1, 0 ); + Abc_FrameReplaceCurrentNetwork( pAbc, pStrash ); + Abc_NtkDelete( pNtkRes ); + return 0; + } + // get the second network if ( argc != globalUtilOptind + 1 ) { @@ -10492,6 +10527,7 @@ usage: Abc_Print( -2, "\t connects PIs of network in to POs of current network\n" ); Abc_Print( -2, "\t-h : print the command usage\n"); Abc_Print( -2, "\t : file name with the second network\n"); + Abc_Print( -2, "\t : (given several files, all networks are stacked on top of each other)\n"); return 1; } @@ -14054,6 +14090,12 @@ int Abc_CommandTest( Abc_Frame_t * pAbc, int argc, char ** argv ) //Dau_NetworkEnumTest(); //Extra_SimulationTest( nDivMax, nNumOnes, fNewOrder ); //Mnist_ExperimentWithScaling( nDecMax ); + if ( Abc_FrameReadNtk(pAbc) ) + { + extern Abc_Ntk_t * Abc_NtkSpecialMapping( Abc_Ntk_t * pNtk, int fVerbose ); + Abc_Ntk_t * pNtkRes = Abc_NtkSpecialMapping( Abc_FrameReadNtk(pAbc), 0 ); + Abc_FrameReplaceCurrentNetwork( pAbc, pNtkRes ); + } return 0; usage: Abc_Print( -2, "usage: test [-CKDNM] [-aovwh] \n" ); @@ -40838,15 +40880,12 @@ usage: SeeAlso [] ***********************************************************************/ -int Abc_CommandAbc9MinLut( Abc_Frame_t * pAbc, int argc, char ** argv ) +int Abc_CommandAbc9LNetSim( Abc_Frame_t * pAbc, int argc, char ** argv ) { - extern Gia_Man_t * Gia_ManSimInfoSynth( Gia_Man_t * p, char * pFileName, int nIns, int nOuts, int LutSize, int Thresh, int fVerbose ); - //extern Gia_Man_t * Gia_ManPerformMinLut( Gia_Man_t * p, int GroupSize, int LutSize, int fVerbose ); - Gia_Man_t * pTemp; - char * pFileName = NULL; - int c, nIns = 6, nOuts = 2, LutSize = 6, Limit = -1, fVerbose = 0; + extern void Gia_ManSimInfoPassTest( Gia_Man_t * p, char * pFileName, char * pFileName2, int fCompare ); + int c, nIns = 6, nOuts = 2, fCompare = 0, fVerbose = 0; Extra_UtilGetoptReset(); - while ( ( c = Extra_UtilGetopt( argc, argv, "IOKLvh" ) ) != EOF ) + while ( ( c = Extra_UtilGetopt( argc, argv, "IOcvh" ) ) != EOF ) { switch ( c ) { @@ -40868,19 +40907,94 @@ int Abc_CommandAbc9MinLut( Abc_Frame_t * pAbc, int argc, char ** argv ) nOuts = atoi(argv[globalUtilOptind]); globalUtilOptind++; break; - case 'K': + case 'c': + fCompare ^= 1; + break; + case 'v': + fVerbose ^= 1; + break; + case 'h': + default: + goto usage; + } + } + if ( argc == globalUtilOptind + 3 ) + { + extern void Gia_ManSimInfoTransform( char * pFileName, char * pFileOut1, char * pFileOut2, int nIns, int nOuts ); + Gia_ManSimInfoTransform( argv[globalUtilOptind], argv[globalUtilOptind+1], argv[globalUtilOptind+2], nIns, nOuts ); + return 0; + } + if ( pAbc->pGia == NULL ) + { + Abc_Print( -1, "Empty GIA network.\n" ); + return 1; + } + if ( argc != globalUtilOptind + 2 ) + { + Abc_Print( -1, "Expecting two file names on the command line.\n" ); + return 1; + } + Gia_ManSimInfoPassTest( pAbc->pGia, argv[globalUtilOptind], argv[globalUtilOptind+1], fCompare ); + return 0; + +usage: + Abc_Print( -2, "usage: &lnetsim [-IO num] [-cvh] \n" ); + Abc_Print( -2, "\t performs specialized AIG simulation\n" ); + Abc_Print( -2, "\t-I num : the input support size [default = %d]\n", nIns ); + Abc_Print( -2, "\t-O num : the output group size [default = %d]\n", nOuts ); + Abc_Print( -2, "\t-c : toggles comparing simulation patterns [default = %s]\n", fCompare? "yes": "no" ); + Abc_Print( -2, "\t-v : toggles verbose output [default = %s]\n", fVerbose? "yes": "no" ); + Abc_Print( -2, "\t-h : prints the command usage\n"); + Abc_Print( -2, "\t : file name with simulation information\n"); + Abc_Print( -2, "\t : file name with simulation information\n"); + Abc_Print( -2, "\t : file name with simulation information (optional)\n"); + return 1; +} + +/**Function************************************************************* + + Synopsis [] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +int Abc_CommandAbc9LNetOpt( Abc_Frame_t * pAbc, int argc, char ** argv ) +{ + extern Gia_Man_t * Gia_ManPerformLNetOpt( Gia_Man_t * p, char * pFileName, int nIns, int nOuts, int Thresh, int fVerbose ); + Gia_Man_t * pTemp; + char * pFileName = NULL; + int c, nIns = 6, nOuts = 2, Limit = 0, fVerbose = 0; + Extra_UtilGetoptReset(); + while ( ( c = Extra_UtilGetopt( argc, argv, "IORvh" ) ) != EOF ) + { + switch ( c ) + { + case 'I': if ( globalUtilOptind >= argc ) { - Abc_Print( -1, "Command line switch \"-K\" should be followed by a positive integer.\n" ); + Abc_Print( -1, "Command line switch \"-I\" should be followed by a positive integer.\n" ); goto usage; } - LutSize = atoi(argv[globalUtilOptind]); + nIns = atoi(argv[globalUtilOptind]); globalUtilOptind++; break; - case 'L': + case 'O': if ( globalUtilOptind >= argc ) { - Abc_Print( -1, "Command line switch \"-L\" should be followed by a positive integer.\n" ); + Abc_Print( -1, "Command line switch \"-O\" should be followed by a positive integer.\n" ); + goto usage; + } + nOuts = atoi(argv[globalUtilOptind]); + globalUtilOptind++; + break; + case 'R': + if ( globalUtilOptind >= argc ) + { + Abc_Print( -1, "Command line switch \"-R\" should be followed by a positive integer.\n" ); goto usage; } Limit = atoi(argv[globalUtilOptind]); @@ -40894,6 +41008,10 @@ int Abc_CommandAbc9MinLut( Abc_Frame_t * pAbc, int argc, char ** argv ) goto usage; } } + if ( argc > globalUtilOptind + 1 ) + { + return 0; + } if ( pAbc->pGia == NULL ) { Abc_Print( -1, "Empty GIA network.\n" ); @@ -40910,20 +41028,17 @@ int Abc_CommandAbc9MinLut( Abc_Frame_t * pAbc, int argc, char ** argv ) fclose( pFile ); pFileName = argv[globalUtilOptind]; } - //pTemp = Gia_ManPerformMinLut( pAbc->pGia, GroupSize, LutSize, fVerbose ); - //Abc_FrameUpdateGia( pAbc, pTemp ); - pTemp = Gia_ManSimInfoSynth( pAbc->pGia, pFileName, nIns, nOuts, LutSize, Limit, fVerbose ); + pTemp = Gia_ManPerformLNetOpt( pAbc->pGia, pFileName, nIns, nOuts, Limit, fVerbose ); Abc_FrameUpdateGia( pAbc, pTemp ); return 0; usage: - Abc_Print( -2, "usage: &minlut [-IOKL num] [-vh] \n" ); - Abc_Print( -2, "\t performs specialized LUT mapping\n" ); - Abc_Print( -2, "\t-I num : the input support size [default = %d]\n", nIns ); - Abc_Print( -2, "\t-O num : the output group size [default = %d]\n", nOuts ); - Abc_Print( -2, "\t-K num : the LUT size for mapping [default = %d]\n", LutSize ); - Abc_Print( -2, "\t-L num : patterns count after this limit [default = %d]\n", Limit ); - Abc_Print( -2, "\t-v : toggles verbose output [default = %s]\n", fVerbose? "yes": "no" ); + Abc_Print( -2, "usage: &lnetopt [-IOR num] [-vh] \n" ); + Abc_Print( -2, "\t performs specialized AIG optimization\n" ); + Abc_Print( -2, "\t-I num : the input support size [default = %d]\n", nIns ); + Abc_Print( -2, "\t-O num : the output group size [default = %d]\n", nOuts ); + Abc_Print( -2, "\t-R num : patterns are cares starting this value [default = %d]\n", Limit ); + Abc_Print( -2, "\t-v : toggles verbose output [default = %s]\n", fVerbose? "yes": "no" ); Abc_Print( -2, "\t-h : prints the command usage\n"); Abc_Print( -2, "\t : file name with simulation information\n"); return 1; @@ -40940,17 +41055,37 @@ usage: SeeAlso [] ***********************************************************************/ -int Abc_CommandAbc9MinSim( Abc_Frame_t * pAbc, int argc, char ** argv ) +int Abc_CommandAbc9LNetMap( Abc_Frame_t * pAbc, int argc, char ** argv ) { - extern void Gia_ManSimInfoPassTest( Gia_Man_t * p, char * pFileName, char * pFileName2, int fCompare ); - int c, fCompare = 0, fVerbose = 0; + extern Abc_Ntk_t * Gia_ManPerformLNetMap( Gia_Man_t * p, int GroupSize, int fUseFixed, int fVerbose ); + Abc_Ntk_t * pTemp; + char * pFileName = NULL; + int c, nIns = 6, nOuts = 2, fUseFixed = 0, fVerbose = 0; Extra_UtilGetoptReset(); - while ( ( c = Extra_UtilGetopt( argc, argv, "cvh" ) ) != EOF ) + while ( ( c = Extra_UtilGetopt( argc, argv, "IOfvh" ) ) != EOF ) { switch ( c ) { - case 'c': - fCompare ^= 1; + case 'I': + if ( globalUtilOptind >= argc ) + { + Abc_Print( -1, "Command line switch \"-I\" should be followed by a positive integer.\n" ); + goto usage; + } + nIns = atoi(argv[globalUtilOptind]); + globalUtilOptind++; + break; + case 'O': + if ( globalUtilOptind >= argc ) + { + Abc_Print( -1, "Command line switch \"-O\" should be followed by a positive integer.\n" ); + goto usage; + } + nOuts = atoi(argv[globalUtilOptind]); + globalUtilOptind++; + break; + case 'f': + fUseFixed ^= 1; break; case 'v': fVerbose ^= 1; @@ -40965,22 +41100,30 @@ int Abc_CommandAbc9MinSim( Abc_Frame_t * pAbc, int argc, char ** argv ) Abc_Print( -1, "Empty GIA network.\n" ); return 1; } - if ( argc != globalUtilOptind + 2 ) + if ( argc == globalUtilOptind + 1 ) { - Abc_Print( -1, "Expecting two file names on the command line.\n" ); - return 1; + FILE * pFile = fopen( argv[globalUtilOptind], "rb" ); + if ( pFile == NULL ) + { + Abc_Print( -1, "Abc_CommandAbc9BCore(): Cannot open file \"%s\" for writing the proof.\n", argv[globalUtilOptind] ); + return 0; + } + fclose( pFile ); + pFileName = argv[globalUtilOptind]; } - Gia_ManSimInfoPassTest( pAbc->pGia, argv[globalUtilOptind], argv[globalUtilOptind+1], fCompare ); + pTemp = Gia_ManPerformLNetMap( pAbc->pGia, nOuts, fUseFixed, fVerbose ); + Abc_FrameReplaceCurrentNetwork( pAbc, pTemp ); return 0; usage: - Abc_Print( -2, "usage: &minsim [-cvh] \n" ); - Abc_Print( -2, "\t performs specialized AIG simulation\n" ); - Abc_Print( -2, "\t-c : toggles comparing simulation patterns [default = %s]\n", fCompare? "yes": "no" ); - Abc_Print( -2, "\t-v : toggles verbose output [default = %s]\n", fVerbose? "yes": "no" ); + Abc_Print( -2, "usage: &lnetmap [-IO num] [-fvh] \n" ); + Abc_Print( -2, "\t performs specialized LUT mapping\n" ); + Abc_Print( -2, "\t-I num : the input support size [default = %d]\n", nIns ); + Abc_Print( -2, "\t-O num : the output group size [default = %d]\n", nOuts ); + Abc_Print( -2, "\t-f : toggles using fixed primitives [default = %s]\n", fUseFixed? "yes": "no" ); + Abc_Print( -2, "\t-v : toggles verbose output [default = %s]\n", fVerbose? "yes": "no" ); Abc_Print( -2, "\t-h : prints the command usage\n"); Abc_Print( -2, "\t : file name with simulation information\n"); - Abc_Print( -2, "\t : file name with simulation information\n"); return 1; } @@ -48562,7 +48705,6 @@ usage: ***********************************************************************/ int Abc_CommandAbc9Test( Abc_Frame_t * pAbc, int argc, char ** argv ) { - extern void Gia_ManSimInfoTryTest( Gia_Man_t * p, int fSmall ); extern void Gia_RsbEnumerateWindows( Gia_Man_t * p, int nInputsMax, int nLevelsMax ); extern int Gia_ManSumTotalOfSupportSizes( Gia_Man_t * p ); int c, fVerbose = 0; @@ -48626,7 +48768,6 @@ int Abc_CommandAbc9Test( Abc_Frame_t * pAbc, int argc, char ** argv ) // return 1; // } // Abc_FrameUpdateGia( pAbc, Abc_Procedure(pAbc->pGia) ); - Gia_ManSimInfoTryTest( pAbc->pGia, fSwitch ); // printf( "AIG in \"%s\" has the sum of output support sizes equal to %d.\n", pAbc->pGia->pSpec, Gia_ManSumTotalOfSupportSizes(pAbc->pGia) ); return 0; usage: diff --git a/src/base/abci/abcLut.c b/src/base/abci/abcLut.c index edc2b7de..8dc84ba0 100644 --- a/src/base/abci/abcLut.c +++ b/src/base/abci/abcLut.c @@ -783,6 +783,164 @@ int Abc_NodeDecomposeStep( Abc_ManScl_t * p ) return 1; } +/**Function************************************************************* + + Synopsis [Performs specialized mapping.] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +static word s__Truths6[6] = { + ABC_CONST(0xAAAAAAAAAAAAAAAA), + ABC_CONST(0xCCCCCCCCCCCCCCCC), + ABC_CONST(0xF0F0F0F0F0F0F0F0), + ABC_CONST(0xFF00FF00FF00FF00), + ABC_CONST(0xFFFF0000FFFF0000), + ABC_CONST(0xFFFFFFFF00000000) +}; +word Abc_ObjComputeTruth( Abc_Obj_t * pObj, Vec_Int_t * vSupp ) +{ + int Index; word t0, t1, tc; + assert( Vec_IntSize(vSupp) <= 6 ); + if ( (Index = Vec_IntFind(vSupp, Abc_ObjId(pObj))) >= 0 ) + return s__Truths6[Index]; + assert( Abc_ObjIsNode(pObj) ); + if ( Abc_ObjFaninNum(pObj) == 0 ) + return Abc_NodeIsConst0(pObj) ? (word)0 : ~(word)0; + assert( Abc_ObjFaninNum(pObj) == 3 ); + t0 = Abc_ObjComputeTruth( Abc_ObjFanin(pObj, 2), vSupp ); + t1 = Abc_ObjComputeTruth( Abc_ObjFanin(pObj, 1), vSupp ); + tc = Abc_ObjComputeTruth( Abc_ObjFanin(pObj, 0), vSupp ); + return (tc & t1) | (~tc & t0); +} +Abc_Obj_t * Abc_NtkSpecialMap_rec( Abc_Ntk_t * pNew, Abc_Obj_t * pObj, Vec_Wec_t * vSupps, Vec_Int_t * vCover ) +{ + if ( pObj->pCopy ) + return pObj->pCopy; + if ( Abc_ObjFaninNum(pObj) == 0 ) + return NULL; + assert( Abc_ObjFaninNum(pObj) == 3 ); + if ( pObj->fMarkA || pObj->fMarkB ) + { + Abc_Obj_t * pFan0 = Abc_NtkSpecialMap_rec( pNew, Abc_ObjFanin(pObj, 2), vSupps, vCover ); + Abc_Obj_t * pFan1 = Abc_NtkSpecialMap_rec( pNew, Abc_ObjFanin(pObj, 1), vSupps, vCover ); + Abc_Obj_t * pFanC = Abc_NtkSpecialMap_rec( pNew, Abc_ObjFanin(pObj, 0), vSupps, vCover ); + if ( pFan0 == NULL ) + pFan0 = Abc_NodeIsConst0(Abc_ObjFanin(pObj, 2)) ? Abc_NtkCreateNodeConst0(pNew) : Abc_NtkCreateNodeConst1(pNew); + if ( pFan1 == NULL ) + pFan1 = Abc_NodeIsConst0(Abc_ObjFanin(pObj, 1)) ? Abc_NtkCreateNodeConst0(pNew) : Abc_NtkCreateNodeConst1(pNew); + pObj->pCopy = Abc_NtkCreateNodeMux( pNew, pFanC, pFan1, pFan0 ); + pObj->pCopy->fMarkA = pObj->fMarkA; + pObj->pCopy->fMarkB = pObj->fMarkB; + } + else + { + Abc_Obj_t * pTemp; int i; word Truth; + Vec_Int_t * vSupp = Vec_WecEntry( vSupps, Abc_ObjId(pObj) ); + Abc_NtkForEachObjVec( vSupp, pObj->pNtk, pTemp, i ) + Abc_NtkSpecialMap_rec( pNew, pTemp, vSupps, vCover ); + pObj->pCopy = Abc_NtkCreateNode( pNew ); + Abc_NtkForEachObjVec( vSupp, pObj->pNtk, pTemp, i ) + Abc_ObjAddFanin( pObj->pCopy, pTemp->pCopy ); + Truth = Abc_ObjComputeTruth( pObj, vSupp ); + pObj->pCopy->pData = Abc_SopCreateFromTruthIsop( (Mem_Flex_t *)pNew->pManFunc, Vec_IntSize(vSupp), &Truth, vCover ); + assert( Abc_SopGetVarNum((char *)pObj->pCopy->pData) == Vec_IntSize(vSupp) ); + } + return pObj->pCopy; +} +Abc_Ntk_t * Abc_NtkSpecialMapping( Abc_Ntk_t * pNtk, int fVerbose ) +{ + Abc_Ntk_t * pNtkNew; + Vec_Int_t * vCover = Vec_IntAlloc( 1 << 16 ); + Vec_Wec_t * vSupps = Vec_WecStart( Abc_NtkObjNumMax(pNtk) ); + Abc_Obj_t * pObj, * pFan0, * pFan1, * pFanC; int i, Count[2] = {0}; + Abc_NtkForEachCi( pNtk, pObj, i ) + Vec_IntPush( Vec_WecEntry(vSupps, i), i ); + Abc_NtkForEachNode( pNtk, pObj, i ) + { + Vec_Int_t * vSupp = Vec_WecEntry(vSupps, i); + if ( Abc_ObjFaninNum(pObj) == 0 ) + continue; + assert( Abc_ObjFaninNum(pObj) == 3 ); + pFan0 = Abc_ObjFanin( pObj, 2 ); + pFan1 = Abc_ObjFanin( pObj, 1 ); + pFanC = Abc_ObjFanin0( pObj ); + assert( Abc_ObjIsCi(pFanC) ); + if ( pFan0->fMarkA && pFan1->fMarkA ) + { + pObj->fMarkB = 1; + Vec_IntPush( vSupp, Abc_ObjId(pObj) ); + continue; + } + Vec_IntTwoMerge2( Vec_WecEntry(vSupps, Abc_ObjId(pFan0)), Vec_WecEntry(vSupps, Abc_ObjId(pFan1)), vSupp ); + assert( Vec_IntFind(vSupp, Abc_ObjId(pFanC)) == -1 ); + Vec_IntPushOrder( vSupp, Abc_ObjId(pFanC) ); + if ( Vec_IntSize(vSupp) <= 6 ) + continue; + Vec_IntClear( vSupp ); + if ( !pFan0->fMarkA && !pFan1->fMarkA ) + { + pObj->fMarkA = 1; + Vec_IntPush( vSupp, Abc_ObjId(pObj) ); + } + else + { + Vec_IntPushOrder( vSupp, Abc_ObjId(pFan0) ); + Vec_IntPushOrder( vSupp, Abc_ObjId(pFan1) ); + Vec_IntPushOrder( vSupp, Abc_ObjId(pFanC) ); + } + } + + if ( fVerbose ) + Abc_NtkForEachNode( pNtk, pObj, i ) + { + printf( "Node %4d : ", i ); + if ( pObj->fMarkA ) + printf( " MarkA " ); + else + printf( " " ); + if ( pObj->fMarkB ) + printf( " MarkB " ); + else + printf( " " ); + Vec_IntPrint( Vec_WecEntry(vSupps, i) ); + } + + Abc_NtkCleanCopy( pNtk ); + pNtkNew = Abc_NtkStartFrom( pNtk, ABC_NTK_LOGIC, ABC_FUNC_SOP ); + Abc_NtkForEachCo( pNtk, pObj, i ) + if ( Abc_ObjFaninNum(Abc_ObjFanin0(pObj)) == 0 ) + Abc_ObjFanin0(pObj)->pCopy = Abc_NodeIsConst0(Abc_ObjFanin0(pObj)) ? Abc_NtkCreateNodeConst0(pNtkNew) : Abc_NtkCreateNodeConst1(pNtkNew); + else + Abc_NtkSpecialMap_rec( pNtkNew, Abc_ObjFanin0(pObj), vSupps, vCover ); + Abc_NtkFinalize( pNtk, pNtkNew ); + Abc_NtkCleanMarkAB( pNtk ); + Vec_WecFree( vSupps ); + Vec_IntFree( vCover ); + + Abc_NtkForEachNode( pNtkNew, pObj, i ) + { + Count[0] += pObj->fMarkA, + Count[1] += pObj->fMarkB; + pObj->fPersist = pObj->fMarkA | pObj->fMarkB; + pObj->fMarkA = pObj->fMarkB = 0; + } + //printf( "Total = %3d. Nodes = %3d. MarkA = %3d. MarkB = %3d.\n", Abc_NtkNodeNum(pNtkNew), + // Abc_NtkNodeNum(pNtkNew) - Count[0] - Count[1], Count[0], Count[1] ); + + if ( !Abc_NtkCheck( pNtkNew ) ) + { + printf( "Abc_NtkSpecialMapping: The network check has failed.\n" ); + Abc_NtkDelete( pNtkNew ); + return NULL; + } + return pNtkNew; +} + //////////////////////////////////////////////////////////////////////// /// END OF FILE /// //////////////////////////////////////////////////////////////////////// diff --git a/src/base/abci/abcNtbdd.c b/src/base/abci/abcNtbdd.c index 3c28ce4f..cbf4bbb8 100644 --- a/src/base/abci/abcNtbdd.c +++ b/src/base/abci/abcNtbdd.c @@ -274,7 +274,7 @@ int Abc_NtkBddToMuxesPerformGlo( Abc_Ntk_t * pNtk, Abc_Ntk_t * pNtkNew, int Limi Abc_Obj_t * pObj, * pObjNew; int i; st__table * tBdd2Node; assert( Abc_NtkIsStrash(pNtk) ); - dd = (DdManager *)Abc_NtkBuildGlobalBdds( pNtk, Limit, 1, 1, fReorder, 0 ); + dd = (DdManager *)Abc_NtkBuildGlobalBdds( pNtk, Limit, 1, fReorder, 0, 0 ); if ( dd == NULL ) { printf( "Construction of global BDDs has failed.\n" ); diff --git a/src/base/io/io.c b/src/base/io/io.c index dec5ee45..5cf74ef9 100644 --- a/src/base/io/io.c +++ b/src/base/io/io.c @@ -2982,13 +2982,13 @@ usage: ***********************************************************************/ int IoCommandWriteVerilog( Abc_Frame_t * pAbc, int argc, char **argv ) { - extern void Io_WriteVerilogLut( Abc_Ntk_t * pNtk, char * pFileName, int nLutSize ); + extern void Io_WriteVerilogLut( Abc_Ntk_t * pNtk, char * pFileName, int nLutSize, int fFixed, int fNoModules ); char * pFileName; - int c, fOnlyAnds = 0; + int c, fFixed = 0, fOnlyAnds = 0, fNoModules = 0; int nLutSize = -1; Extra_UtilGetoptReset(); - while ( ( c = Extra_UtilGetopt( argc, argv, "Kah" ) ) != EOF ) + while ( ( c = Extra_UtilGetopt( argc, argv, "Kfamh" ) ) != EOF ) { switch ( c ) { @@ -3003,9 +3003,15 @@ int IoCommandWriteVerilog( Abc_Frame_t * pAbc, int argc, char **argv ) if ( nLutSize < 2 || nLutSize > 6 ) goto usage; break; + case 'f': + fFixed ^= 1; + break; case 'a': fOnlyAnds ^= 1; break; + case 'm': + fNoModules ^= 1; + break; case 'h': goto usage; default: @@ -3019,6 +3025,8 @@ int IoCommandWriteVerilog( Abc_Frame_t * pAbc, int argc, char **argv ) } if ( argc != globalUtilOptind + 1 ) goto usage; + if ( fFixed ) + nLutSize = 6; // get the output file name pFileName = argv[globalUtilOptind]; // call the corresponding file writer @@ -3031,16 +3039,18 @@ int IoCommandWriteVerilog( Abc_Frame_t * pAbc, int argc, char **argv ) Abc_NtkDelete( pNtkTemp ); } else if ( nLutSize >= 2 && nLutSize <= 6 ) - Io_WriteVerilogLut( pAbc->pNtkCur, pFileName, nLutSize ); + Io_WriteVerilogLut( pAbc->pNtkCur, pFileName, nLutSize, fFixed, fNoModules ); else Io_Write( pAbc->pNtkCur, pFileName, IO_FILE_VERILOG ); return 0; usage: - fprintf( pAbc->Err, "usage: write_verilog [-K num] [-ah] \n" ); + fprintf( pAbc->Err, "usage: write_verilog [-K num] [-famh] \n" ); fprintf( pAbc->Err, "\t writes the current network in Verilog format\n" ); fprintf( pAbc->Err, "\t-K num : write the network using instances of K-LUTs (2 <= K <= 6) [default = not used]\n" ); + fprintf( pAbc->Err, "\t-f : toggle using fixed format [default = %s]\n", fFixed? "yes":"no" ); fprintf( pAbc->Err, "\t-a : toggle writing expressions with only ANDs (without XORs and MUXes) [default = %s]\n", fOnlyAnds? "yes":"no" ); + fprintf( pAbc->Err, "\t-m : toggle writing additional modules [default = %s]\n", !fNoModules? "yes":"no" ); fprintf( pAbc->Err, "\t-h : print the help massage\n" ); fprintf( pAbc->Err, "\tfile : the name of the file to write\n" ); return 1; diff --git a/src/base/io/ioWriteVerilog.c b/src/base/io/ioWriteVerilog.c index 4c55b599..e05aed2e 100644 --- a/src/base/io/ioWriteVerilog.c +++ b/src/base/io/ioWriteVerilog.c @@ -639,10 +639,8 @@ int Io_WriteVerilogWiresCount( Abc_Ntk_t * pNtk ) char * Io_WriteVerilogGetName( char * pName ) { static char Buffer[500]; - int Length, i; - Length = strlen(pName); - // consider the case of a signal having name "0" or "1" - if ( !(Length == 1 && (pName[0] == '0' || pName[0] == '1')) ) + int i, Length = strlen(pName); + if ( pName[0] < '0' || pName[0] > '9' ) { for ( i = 0; i < Length; i++ ) if ( !((pName[i] >= 'a' && pName[i] <= 'z') || @@ -679,7 +677,39 @@ void Io_WriteLutModule( FILE * pFile, int nLutSize ) fprintf( pFile, " assign out = TT[in];\n" ); fprintf( pFile, "endmodule\n\n" ); } -void Io_WriteVerilogObjectsLut( FILE * pFile, Abc_Ntk_t * pNtk, int nLutSize ) +void Io_WriteFixedModules( FILE * pFile ) +{ + fprintf( pFile, "module LUT6 #( parameter INIT = 64\'h0000000000000000 ) (\n" ); + fprintf( pFile, " output O,\n" ); + fprintf( pFile, " input I0,\n" ); + fprintf( pFile, " input I1,\n" ); + fprintf( pFile, " input I2,\n" ); + fprintf( pFile, " input I3,\n" ); + fprintf( pFile, " input I4,\n" ); + fprintf( pFile, " input I5\n" ); + fprintf( pFile, ");\n" ); + fprintf( pFile, " assign O = INIT[ {I5, I4, I3, I2, I1, I0} ];\n" ); + fprintf( pFile, "endmodule\n\n" ); + + fprintf( pFile, "module MUXF7 (\n" ); + fprintf( pFile, " output O,\n" ); + fprintf( pFile, " input I0,\n" ); + fprintf( pFile, " input I1,\n" ); + fprintf( pFile, " input S\n" ); + fprintf( pFile, ");\n" ); + fprintf( pFile, " assign O = S ? I1 : I0;\n" ); + fprintf( pFile, "endmodule\n\n" ); + + fprintf( pFile, "module MUXF8 (\n" ); + fprintf( pFile, " output O,\n" ); + fprintf( pFile, " input I0,\n" ); + fprintf( pFile, " input I1,\n" ); + fprintf( pFile, " input S\n" ); + fprintf( pFile, ");\n" ); + fprintf( pFile, " assign O = S ? I1 : I0;\n" ); + fprintf( pFile, "endmodule\n\n" ); +} +void Io_WriteVerilogObjectsLut( FILE * pFile, Abc_Ntk_t * pNtk, int nLutSize, int fFixed ) { Abc_Ntk_t * pNtkBox; Abc_Obj_t * pObj, * pTerm; @@ -719,6 +749,34 @@ void Io_WriteVerilogObjectsLut( FILE * pFile, Abc_Ntk_t * pNtk, int nLutSize ) // write LUT instances nDigits = Abc_Base10Log( Abc_NtkNodeNum(pNtk) ); Counter = 0; + if ( fFixed ) + Abc_NtkForEachNode( pNtk, pObj, i ) + { + if ( pObj->fPersist ) + { + int One = Abc_ObjFanin0(Abc_ObjFanin(pObj, 1))->fPersist && Abc_ObjFanin0(Abc_ObjFanin(pObj, 2))->fPersist; + fprintf( pFile, " MUXF%d ", 7+One ); + fprintf( pFile, " mux_%0*d (", nDigits, Counter++ ); + fprintf( pFile, " %*s", Length, Io_WriteVerilogGetName(Abc_ObjName(Abc_ObjFanout0(pObj))) ); + for ( k = Abc_ObjFaninNum(pObj) - 1; k >= 0; k-- ) + fprintf( pFile, ", %*s", Length, Io_WriteVerilogGetName(Abc_ObjName(Abc_ObjFanin(pObj, k))) ); + fprintf( pFile, " );\n" ); + } + else + { + word Truth = Abc_SopToTruth( (char *)pObj->pData, Abc_ObjFaninNum(pObj) ); + fprintf( pFile, " LUT6 #(64\'h" ); + fprintf( pFile, "%08x%08x", (unsigned)(Truth >> 32), (unsigned)Truth ); + fprintf( pFile, ") lut_%0*d (", nDigits, Counter++ ); + fprintf( pFile, " %*s", Length, Io_WriteVerilogGetName(Abc_ObjName(Abc_ObjFanout0(pObj))) ); + for ( k = 0; k < Abc_ObjFaninNum(pObj); k++ ) + fprintf( pFile, ", %*s", Length, Io_WriteVerilogGetName(Abc_ObjName(Abc_ObjFanin(pObj, k))) ); + for ( ; k < 6; k++ ) + fprintf( pFile, ", %*s", Length, "1\'b0" ); + fprintf( pFile, " );\n" ); + } + } + else Abc_NtkForEachNode( pNtk, pObj, i ) { word Truth = Abc_SopToTruth( (char *)pObj->pData, Abc_ObjFaninNum(pObj) ); @@ -735,7 +793,7 @@ void Io_WriteVerilogObjectsLut( FILE * pFile, Abc_Ntk_t * pNtk, int nLutSize ) fprintf( pFile, "}, %*s );\n", Length, Io_WriteVerilogGetName(Abc_ObjName(Abc_ObjFanout0(pObj))) ); } } -void Io_WriteVerilogLutInt( FILE * pFile, Abc_Ntk_t * pNtk, int nLutSize ) +void Io_WriteVerilogLutInt( FILE * pFile, Abc_Ntk_t * pNtk, int nLutSize, int fFixed ) { // write inputs and outputs // fprintf( pFile, "module %s ( gclk,\n ", Abc_NtkName(pNtk) ); @@ -786,7 +844,7 @@ void Io_WriteVerilogLutInt( FILE * pFile, Abc_Ntk_t * pNtk, int nLutSize ) fprintf( pFile, ";\n\n" ); } // write nodes - Io_WriteVerilogObjectsLut( pFile, pNtk, nLutSize ); + Io_WriteVerilogObjectsLut( pFile, pNtk, nLutSize, fFixed ); // write registers if ( Abc_NtkLatchNum(pNtk) > 0 ) { @@ -797,7 +855,7 @@ void Io_WriteVerilogLutInt( FILE * pFile, Abc_Ntk_t * pNtk, int nLutSize ) // finalize the file fprintf( pFile, "\nendmodule\n\n" ); } -void Io_WriteVerilogLut( Abc_Ntk_t * pNtk, char * pFileName, int nLutSize ) +void Io_WriteVerilogLut( Abc_Ntk_t * pNtk, char * pFileName, int nLutSize, int fFixed, int fNoModules ) { FILE * pFile; Abc_Ntk_t * pNtkTemp; @@ -827,11 +885,16 @@ void Io_WriteVerilogLut( Abc_Ntk_t * pNtk, char * pFileName, int nLutSize ) // write the equations for the network fprintf( pFile, "// Benchmark \"%s\" written by ABC on %s\n", pNtk->pName, Extra_TimeStamp() ); fprintf( pFile, "\n" ); - Io_WriteLutModule( pFile, nLutSize ); - + if ( !fNoModules ) + { + if ( fFixed ) + Io_WriteFixedModules( pFile ); + else + Io_WriteLutModule( pFile, nLutSize ); + } pNtkTemp = Abc_NtkToNetlist( pNtk ); Abc_NtkToSop( pNtkTemp, -1, ABC_INFINITY ); - Io_WriteVerilogLutInt( pFile, pNtkTemp, nLutSize ); + Io_WriteVerilogLutInt( pFile, pNtkTemp, nLutSize, fFixed ); Abc_NtkDelete( pNtkTemp ); fprintf( pFile, "\n" ); -- cgit v1.2.3 From d35b05859c44015661d36aaaa2926e0dd5f3e4dc Mon Sep 17 00:00:00 2001 From: Alan Mishchenko Date: Tue, 18 May 2021 16:42:16 -0700 Subject: Adding command &extract. --- src/base/abci/abc.c | 68 ++++++++++++++++++++++++++++++++++++++++++++++ src/base/abci/abcExtract.c | 17 +++++++++++- 2 files changed, 84 insertions(+), 1 deletion(-) (limited to 'src/base') diff --git a/src/base/abci/abc.c b/src/base/abci/abc.c index ab80eef3..0ec00864 100644 --- a/src/base/abci/abc.c +++ b/src/base/abci/abc.c @@ -437,6 +437,7 @@ static int Abc_CommandAbc9Dsd ( Abc_Frame_t * pAbc, int argc, cha static int Abc_CommandAbc9Bidec ( Abc_Frame_t * pAbc, int argc, char ** argv ); static int Abc_CommandAbc9Shrink ( Abc_Frame_t * pAbc, int argc, char ** argv ); static int Abc_CommandAbc9Fx ( Abc_Frame_t * pAbc, int argc, char ** argv ); +static int Abc_CommandAbc9Extract ( Abc_Frame_t * pAbc, int argc, char ** argv ); static int Abc_CommandAbc9Balance ( Abc_Frame_t * pAbc, int argc, char ** argv ); static int Abc_CommandAbc9BalanceLut ( Abc_Frame_t * pAbc, int argc, char ** argv ); static int Abc_CommandAbc9Resub ( Abc_Frame_t * pAbc, int argc, char ** argv ); @@ -1163,6 +1164,7 @@ void Abc_Init( Abc_Frame_t * pAbc ) Cmd_CommandAdd( pAbc, "ABC9", "&bidec", Abc_CommandAbc9Bidec, 0 ); Cmd_CommandAdd( pAbc, "ABC9", "&shrink", Abc_CommandAbc9Shrink, 0 ); Cmd_CommandAdd( pAbc, "ABC9", "&fx", Abc_CommandAbc9Fx, 0 ); + Cmd_CommandAdd( pAbc, "ABC9", "&extract", Abc_CommandAbc9Extract, 0 ); Cmd_CommandAdd( pAbc, "ABC9", "&b", Abc_CommandAbc9Balance, 0 ); Cmd_CommandAdd( pAbc, "ABC9", "&blut", Abc_CommandAbc9BalanceLut, 0 ); Cmd_CommandAdd( pAbc, "ABC9", "&resub", Abc_CommandAbc9Resub, 0 ); @@ -34927,6 +34929,72 @@ usage: return 1; } +/**Function************************************************************* + + Synopsis [] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +int Abc_CommandAbc9Extract( Abc_Frame_t * pAbc, int argc, char ** argv ) +{ + extern Gia_Man_t * Abc_NtkShareXorGia( Gia_Man_t * p, int nMultiSize, int fAnd, int fVerbose ); + Gia_Man_t * pTemp; + int nMultiSize = 3; + int c, fAnds = 0; + int fVerbose = 0; + Extra_UtilGetoptReset(); + while ( (c = Extra_UtilGetopt(argc, argv, "Kavh")) != EOF ) + { + switch (c) + { + case 'K': + if ( globalUtilOptind >= argc ) + { + Abc_Print( -1, "Command line switch \"-K\" should be followed by an integer.\n" ); + goto usage; + } + nMultiSize = atoi(argv[globalUtilOptind]); + globalUtilOptind++; + if ( nMultiSize < 0 ) + goto usage; + break; + case 'a': + fAnds ^= 1; + break; + case 'v': + fVerbose ^= 1; + break; + case 'h': + goto usage; + break; + default: + goto usage; + } + } + if ( pAbc->pGia == NULL ) + { + Abc_Print( -1, "Abc_CommandAbc9Shrink(): There is no AIG.\n" ); + return 1; + } + pTemp = Abc_NtkShareXorGia( pAbc->pGia, nMultiSize, fAnds, fVerbose ); + Abc_FrameUpdateGia( pAbc, pTemp ); + return 0; + +usage: + Abc_Print( -2, "usage: &extract [-K ] [-vh]\n"); + Abc_Print( -2, "\t extract shared logic for XOR-rich circuits\n"); + Abc_Print( -2, "\t-K : the minimum gate size to consider for extraction [default = %d]\n", nMultiSize ); + Abc_Print( -2, "\t-a : toogle extracting ANDs instead of XORs [default = %s]\n", fAnds? "yes": "no" ); + Abc_Print( -2, "\t-v : print 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/abcExtract.c b/src/base/abci/abcExtract.c index 1b247841..870bc7dc 100644 --- a/src/base/abci/abcExtract.c +++ b/src/base/abci/abcExtract.c @@ -19,6 +19,7 @@ ***********************************************************************/ #include "base/abc/abc.h" +#include "aig/gia/giaAig.h" ABC_NAMESPACE_IMPL_START @@ -741,7 +742,21 @@ Abc_Ntk_t * Abc_NtkShareXor( Abc_Ntk_t * pNtk, int nMultiSize, int fAnd, int fVe Abc_ShaManStop( p ); return pNtkNew; } - +Gia_Man_t * Abc_NtkShareXorGia( Gia_Man_t * p, int nMultiSize, int fAnd, int fVerbose ) +{ + extern Aig_Man_t * Abc_NtkToDar( Abc_Ntk_t * pNtk, int fExors, int fRegisters ); + extern Abc_Ntk_t * Abc_NtkFromAigPhase( Aig_Man_t * pMan ); + Aig_Man_t * pMan = Gia_ManToAig( p, 0 ); + Abc_Ntk_t * pNtk = Abc_NtkFromAigPhase( pMan ); + Abc_Ntk_t * pNtkNew = Abc_NtkShareXor( pNtk, nMultiSize, fAnd, fVerbose ); + Aig_Man_t * pAig = Abc_NtkToDar( pNtkNew, 0, 0 ); + Gia_Man_t * pNew = Gia_ManFromAig( pAig ); + Abc_NtkDelete( pNtkNew ); + Abc_NtkDelete( pNtk ); + Aig_ManStop( pAig ); + Aig_ManStop( pMan ); + return pNew; +} //////////////////////////////////////////////////////////////////////// /// END OF FILE /// -- cgit v1.2.3 From 49078ffebf4d87165c625a0dad249e039adeb952 Mon Sep 17 00:00:00 2001 From: Alan Mishchenko Date: Tue, 25 May 2021 23:12:30 -0700 Subject: Updating LUT synthesis code. --- src/base/abci/abc.c | 146 +++++++++++++++++++++++++++++++++++------------ src/base/abci/abcPrint.c | 9 +++ 2 files changed, 120 insertions(+), 35 deletions(-) (limited to 'src/base') diff --git a/src/base/abci/abc.c b/src/base/abci/abc.c index 0ec00864..45755ad2 100644 --- a/src/base/abci/abc.c +++ b/src/base/abci/abc.c @@ -486,9 +486,11 @@ static int Abc_CommandAbc9Of ( Abc_Frame_t * pAbc, int argc, cha static int Abc_CommandAbc9Pack ( Abc_Frame_t * pAbc, int argc, char ** argv ); static int Abc_CommandAbc9Edge ( Abc_Frame_t * pAbc, int argc, char ** argv ); static int Abc_CommandAbc9SatLut ( Abc_Frame_t * pAbc, int argc, char ** argv ); -static int Abc_CommandAbc9LNetSim ( Abc_Frame_t * pAbc, int argc, char ** argv ); -static int Abc_CommandAbc9LNetOpt ( Abc_Frame_t * pAbc, int argc, char ** argv ); -static int Abc_CommandAbc9LNetMap ( Abc_Frame_t * pAbc, int argc, char ** argv ); +static int Abc_CommandAbc9LNetRead ( Abc_Frame_t * pAbc, int argc, char ** argv ); +static int Abc_CommandAbc9LNetSim ( Abc_Frame_t * pAbc, int argc, char ** argv ); +static int Abc_CommandAbc9LNetEval ( Abc_Frame_t * pAbc, int argc, char ** argv ); +static int Abc_CommandAbc9LNetOpt ( Abc_Frame_t * pAbc, int argc, char ** argv ); +static int Abc_CommandAbc9LNetMap ( Abc_Frame_t * pAbc, int argc, char ** argv ); static int Abc_CommandAbc9Unmap ( Abc_Frame_t * pAbc, int argc, char ** argv ); static int Abc_CommandAbc9Struct ( Abc_Frame_t * pAbc, int argc, char ** argv ); static int Abc_CommandAbc9Trace ( Abc_Frame_t * pAbc, int argc, char ** argv ); @@ -1213,7 +1215,9 @@ void Abc_Init( Abc_Frame_t * pAbc ) Cmd_CommandAdd( pAbc, "ABC9", "&pack", Abc_CommandAbc9Pack, 0 ); Cmd_CommandAdd( pAbc, "ABC9", "&edge", Abc_CommandAbc9Edge, 0 ); Cmd_CommandAdd( pAbc, "ABC9", "&satlut", Abc_CommandAbc9SatLut, 0 ); + Cmd_CommandAdd( pAbc, "ABC9", "&lnetread", Abc_CommandAbc9LNetRead, 0 ); Cmd_CommandAdd( pAbc, "ABC9", "&lnetsim", Abc_CommandAbc9LNetSim, 0 ); + Cmd_CommandAdd( pAbc, "ABC9", "&lneteval", Abc_CommandAbc9LNetEval, 0 ); Cmd_CommandAdd( pAbc, "ABC9", "&lnetopt", Abc_CommandAbc9LNetOpt, 0 ); Cmd_CommandAdd( pAbc, "ABC9", "&lnetmap", Abc_CommandAbc9LNetMap, 0 ); Cmd_CommandAdd( pAbc, "ABC9", "&unmap", Abc_CommandAbc9Unmap, 0 ); @@ -10437,7 +10441,6 @@ int Abc_CommandPutOnTop( Abc_Frame_t * pAbc, int argc, char ** argv ) if ( argc > globalUtilOptind + 1 ) { - Abc_Ntk_t * pStrash; for ( c = 1; c < argc; c++ ) { Abc_Ntk_t * pTemp, * pLogic = Io_Read( argv[c], Io_ReadFileType(argv[c]), 1, 0 ); @@ -10462,9 +10465,7 @@ int Abc_CommandPutOnTop( Abc_Frame_t * pAbc, int argc, char ** argv ) } } assert( Abc_NtkIsLogic(pNtkRes) ); - pStrash = Abc_NtkStrash( pNtkRes, 1, 1, 0 ); - Abc_FrameReplaceCurrentNetwork( pAbc, pStrash ); - Abc_NtkDelete( pNtkRes ); + Abc_FrameReplaceCurrentNetwork( pAbc, pNtkRes ); return 0; } @@ -40937,6 +40938,51 @@ usage: return 1; } +/**Function************************************************************* + + Synopsis [] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +int Abc_CommandAbc9LNetRead( Abc_Frame_t * pAbc, int argc, char ** argv ) +{ + extern void Gia_ManReadSimInfoInputs( char * pFileName, char * pFileOut1, int fVerbose ); + int c, fVerbose = 0; + Extra_UtilGetoptReset(); + while ( ( c = Extra_UtilGetopt( argc, argv, "vh" ) ) != EOF ) + { + switch ( c ) + { + case 'v': + fVerbose ^= 1; + break; + case 'h': + default: + goto usage; + } + } + if ( argc == globalUtilOptind + 2 ) // read 1 file, write 1 file + { + Gia_ManReadSimInfoInputs( argv[globalUtilOptind], argv[globalUtilOptind+1], fVerbose ); + return 0; + } + return 0; + +usage: + Abc_Print( -2, "usage: &lnetread [-vh] \n" ); + Abc_Print( -2, "\t reads and converts the simulation data\n" ); + Abc_Print( -2, "\t-v : toggles verbose output [default = %s]\n", fVerbose? "yes": "no" ); + Abc_Print( -2, "\t-h : prints the command usage\n"); + Abc_Print( -2, "\t : input file name with simulation information\n"); + Abc_Print( -2, "\t : output file name with simulation information\n"); + return 1; +} + /**Function************************************************************* Synopsis [] @@ -40950,22 +40996,64 @@ usage: ***********************************************************************/ int Abc_CommandAbc9LNetSim( Abc_Frame_t * pAbc, int argc, char ** argv ) { - extern void Gia_ManSimInfoPassTest( Gia_Man_t * p, char * pFileName, char * pFileName2, int fCompare ); - int c, nIns = 6, nOuts = 2, fCompare = 0, fVerbose = 0; + extern void Gia_ManSimInfoPassTest( Gia_Man_t * p, char * pFileName, char * pFileName2, int fVerbose ); + int c, fVerbose = 0; Extra_UtilGetoptReset(); - while ( ( c = Extra_UtilGetopt( argc, argv, "IOcvh" ) ) != EOF ) + while ( ( c = Extra_UtilGetopt( argc, argv, "vh" ) ) != EOF ) { switch ( c ) { - case 'I': - if ( globalUtilOptind >= argc ) - { - Abc_Print( -1, "Command line switch \"-I\" should be followed by a positive integer.\n" ); - goto usage; - } - nIns = atoi(argv[globalUtilOptind]); - globalUtilOptind++; + case 'v': + fVerbose ^= 1; break; + case 'h': + default: + goto usage; + } + } + if ( pAbc->pGia == NULL ) + { + Abc_Print( -1, "Empty GIA network.\n" ); + return 1; + } + if ( argc != globalUtilOptind + 2 ) + { + Abc_Print( -1, "Expecting two file names on the command line.\n" ); + return 1; + } + Gia_ManSimInfoPassTest( pAbc->pGia, argv[globalUtilOptind], argv[globalUtilOptind+1], fVerbose ); + return 0; + +usage: + Abc_Print( -2, "usage: &lnetsim [-vh] \n" ); + Abc_Print( -2, "\t performs specialized AIG simulation\n" ); + Abc_Print( -2, "\t-v : toggles verbose output [default = %s]\n", fVerbose? "yes": "no" ); + Abc_Print( -2, "\t-h : prints the command usage\n"); + Abc_Print( -2, "\t : input file name with simulation information\n"); + Abc_Print( -2, "\t : output file name with simulation information\n"); + return 1; +} + +/**Function************************************************************* + + Synopsis [] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +int Abc_CommandAbc9LNetEval( Abc_Frame_t * pAbc, int argc, char ** argv ) +{ + extern void Gia_ManSimInfoEval( Gia_Man_t * p, char * pFileName, char * pFileName2, int nOuts, int fVerbose ); + int c, nOuts = -1, fVerbose = 0; + Extra_UtilGetoptReset(); + while ( ( c = Extra_UtilGetopt( argc, argv, "Ovh" ) ) != EOF ) + { + switch ( c ) + { case 'O': if ( globalUtilOptind >= argc ) { @@ -40975,9 +41063,6 @@ int Abc_CommandAbc9LNetSim( Abc_Frame_t * pAbc, int argc, char ** argv ) nOuts = atoi(argv[globalUtilOptind]); globalUtilOptind++; break; - case 'c': - fCompare ^= 1; - break; case 'v': fVerbose ^= 1; break; @@ -40986,12 +41071,6 @@ int Abc_CommandAbc9LNetSim( Abc_Frame_t * pAbc, int argc, char ** argv ) goto usage; } } - if ( argc == globalUtilOptind + 3 ) - { - extern void Gia_ManSimInfoTransform( char * pFileName, char * pFileOut1, char * pFileOut2, int nIns, int nOuts ); - Gia_ManSimInfoTransform( argv[globalUtilOptind], argv[globalUtilOptind+1], argv[globalUtilOptind+2], nIns, nOuts ); - return 0; - } if ( pAbc->pGia == NULL ) { Abc_Print( -1, "Empty GIA network.\n" ); @@ -41002,20 +41081,17 @@ int Abc_CommandAbc9LNetSim( Abc_Frame_t * pAbc, int argc, char ** argv ) Abc_Print( -1, "Expecting two file names on the command line.\n" ); return 1; } - Gia_ManSimInfoPassTest( pAbc->pGia, argv[globalUtilOptind], argv[globalUtilOptind+1], fCompare ); + Gia_ManSimInfoEval( pAbc->pGia, argv[globalUtilOptind], argv[globalUtilOptind+1], nOuts, fVerbose ); return 0; usage: - Abc_Print( -2, "usage: &lnetsim [-IO num] [-cvh] \n" ); - Abc_Print( -2, "\t performs specialized AIG simulation\n" ); - Abc_Print( -2, "\t-I num : the input support size [default = %d]\n", nIns ); - Abc_Print( -2, "\t-O num : the output group size [default = %d]\n", nOuts ); - Abc_Print( -2, "\t-c : toggles comparing simulation patterns [default = %s]\n", fCompare? "yes": "no" ); - Abc_Print( -2, "\t-v : toggles verbose output [default = %s]\n", fVerbose? "yes": "no" ); + Abc_Print( -2, "usage: &lneteval [-O num] [-vh] \n" ); + Abc_Print( -2, "\t performs testing of the AIG on the simulation data\n" ); + Abc_Print( -2, "\t-O num : the output group size [default = %d]\n", nOuts ); + Abc_Print( -2, "\t-v : toggles verbose output [default = %s]\n", fVerbose? "yes": "no" ); Abc_Print( -2, "\t-h : prints the command usage\n"); Abc_Print( -2, "\t : file name with simulation information\n"); Abc_Print( -2, "\t : file name with simulation information\n"); - Abc_Print( -2, "\t : file name with simulation information (optional)\n"); return 1; } diff --git a/src/base/abci/abcPrint.c b/src/base/abci/abcPrint.c index 4ffb18a9..44d5c2c3 100644 --- a/src/base/abci/abcPrint.c +++ b/src/base/abci/abcPrint.c @@ -453,6 +453,15 @@ void Abc_NtkPrintStats( Abc_Ntk_t * pNtk, int fFactored, int fSaveBest, int fDum // if ( Abc_NtkHasSop(pNtk) ) // printf( "The total number of cube pairs = %d.\n", Abc_NtkGetCubePairNum(pNtk) ); + if ( 0 ) + { + FILE * pTable = fopen( "stats.txt", "a+" ); + if ( Abc_NtkIsStrash(pNtk) ) + fprintf( pTable, "%s ", pNtk->pName ); + fprintf( pTable, "%d ", Abc_NtkNodeNum(pNtk) ); + fclose( pTable ); + } + fflush( stdout ); if ( pNtk->pExdc ) Abc_NtkPrintStats( pNtk->pExdc, fFactored, fSaveBest, fDumpResult, fUseLutLib, fPrintMuxes, fPower, fGlitch, fSkipBuf, fSkipSmall, fPrintMem ); -- cgit v1.2.3 From 84ec53fbf9f7ede950c7c3f1ccabf8987982ae7e Mon Sep 17 00:00:00 2001 From: Alan Mishchenko Date: Thu, 3 Jun 2021 08:39:30 -0700 Subject: Disabled special handling of 2-input LUTs. --- src/base/abci/abcDar.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/base') diff --git a/src/base/abci/abcDar.c b/src/base/abci/abcDar.c index 8911780d..ae2d9835 100644 --- a/src/base/abci/abcDar.c +++ b/src/base/abci/abcDar.c @@ -858,7 +858,7 @@ Abc_Ntk_t * Abc_NtkFromMappedGia( Gia_Man_t * p, int fFindEnables, int fUseBuffs Gia_LutForEachFanin( p, i, iFan, k ) Abc_ObjAddFanin( pObjNew, Abc_NtkObj(pNtkNew, Gia_ObjValue(Gia_ManObj(p, iFan))) ); pObjNew->pData = Abc_ObjHopFromGia( (Hop_Man_t *)pNtkNew->pManFunc, p, i, vReflect ); - pObjNew->fPersist = Gia_ObjLutIsMux(p, i); + pObjNew->fPersist = Gia_ObjLutIsMux(p, i) && Gia_ObjLutSize(p, i) == 3; pObj->Value = Abc_ObjId( pObjNew ); } Vec_PtrFree( vReflect ); -- cgit v1.2.3 From 7d18d6b7aad526ba73b761f3c2f9292f7546b611 Mon Sep 17 00:00:00 2001 From: Alan Mishchenko Date: Sat, 5 Jun 2021 17:48:12 -0700 Subject: Experiments with cut computation. --- src/base/abci/abc.c | 1 + 1 file changed, 1 insertion(+) (limited to 'src/base') diff --git a/src/base/abci/abc.c b/src/base/abci/abc.c index 45755ad2..c3af777d 100644 --- a/src/base/abci/abc.c +++ b/src/base/abci/abc.c @@ -48913,6 +48913,7 @@ int Abc_CommandAbc9Test( Abc_Frame_t * pAbc, int argc, char ** argv ) // } // Abc_FrameUpdateGia( pAbc, Abc_Procedure(pAbc->pGia) ); // printf( "AIG in \"%s\" has the sum of output support sizes equal to %d.\n", pAbc->pGia->pSpec, Gia_ManSumTotalOfSupportSizes(pAbc->pGia) ); + Gia_ManExtractTest( pAbc->pGia ); return 0; usage: Abc_Print( -2, "usage: &test [-FW num] [-svh]\n" ); -- cgit v1.2.3 From b4f099c511f66dfe6624ac26194abb90e9615cfd Mon Sep 17 00:00:00 2001 From: Alan Mishchenko Date: Sat, 19 Jun 2021 19:26:41 -0700 Subject: Experiments with LUT mapping for small functions. --- src/base/abc/abcShow.c | 6 ++--- src/base/abci/abc.c | 69 ++++++++++++++++++++++++++++++++------------------ 2 files changed, 47 insertions(+), 28 deletions(-) (limited to 'src/base') diff --git a/src/base/abc/abcShow.c b/src/base/abc/abcShow.c index f91397df..ff43dbe6 100644 --- a/src/base/abc/abcShow.c +++ b/src/base/abc/abcShow.c @@ -121,7 +121,7 @@ void Abc_NodeShowBdd( Abc_Obj_t * pNode, int fCompl ) // visualize the file Abc_ShowFile( FileNameDot ); } -void Abc_NtkShowBdd( Abc_Ntk_t * pNtk, int fCompl ) +void Abc_NtkShowBdd( Abc_Ntk_t * pNtk, int fCompl, int fReorder ) { char FileNameDot[200]; char ** ppNamesIn, ** ppNamesOut; @@ -131,7 +131,7 @@ void Abc_NtkShowBdd( Abc_Ntk_t * pNtk, int fCompl ) FILE * pFile; assert( Abc_NtkIsStrash(pNtk) ); - dd = (DdManager *)Abc_NtkBuildGlobalBdds( pNtk, 10000000, 1, 1, 0, 0 ); + dd = (DdManager *)Abc_NtkBuildGlobalBdds( pNtk, 10000000, 1, fReorder, 0, 0 ); if ( dd == NULL ) { printf( "Construction of global BDDs has failed.\n" ); @@ -186,7 +186,7 @@ void Abc_NtkShowBdd( Abc_Ntk_t * pNtk, int fCompl ) #else void Abc_NodeShowBdd( Abc_Obj_t * pNode, int fCompl ) {} -void Abc_NtkShowBdd( Abc_Ntk_t * pNtk, int fCompl ) {} +void Abc_NtkShowBdd( Abc_Ntk_t * pNtk, int fCompl, int fReorder ) {} #endif /**Function************************************************************* diff --git a/src/base/abci/abc.c b/src/base/abci/abc.c index c3af777d..96cd2188 100644 --- a/src/base/abci/abc.c +++ b/src/base/abci/abc.c @@ -3172,13 +3172,13 @@ int Abc_CommandShowBdd( Abc_Frame_t * pAbc, int argc, char ** argv ) { Abc_Ntk_t * pNtk = Abc_FrameReadNtk(pAbc); Abc_Obj_t * pNode; - int c, fCompl = 0, fGlobal = 0; + int c, fCompl = 0, fGlobal = 0, fReorder = 1; extern void Abc_NodeShowBdd( Abc_Obj_t * pNode, int fCompl ); - extern void Abc_NtkShowBdd( Abc_Ntk_t * pNtk, int fCompl ); + extern void Abc_NtkShowBdd( Abc_Ntk_t * pNtk, int fCompl, int fReorder ); // set defaults Extra_UtilGetoptReset(); - while ( ( c = Extra_UtilGetopt( argc, argv, "cgh" ) ) != EOF ) + while ( ( c = Extra_UtilGetopt( argc, argv, "cgrh" ) ) != EOF ) { switch ( c ) { @@ -3188,6 +3188,9 @@ int Abc_CommandShowBdd( Abc_Frame_t * pAbc, int argc, char ** argv ) case 'g': fGlobal ^= 1; break; + case 'r': + fReorder ^= 1; + break; case 'h': goto usage; default: @@ -3204,7 +3207,7 @@ int Abc_CommandShowBdd( Abc_Frame_t * pAbc, int argc, char ** argv ) if ( fGlobal ) { Abc_Ntk_t * pTemp = Abc_NtkIsStrash(pNtk) ? pNtk : Abc_NtkStrash(pNtk, 0, 0, 0); - Abc_NtkShowBdd( pTemp, fCompl ); + Abc_NtkShowBdd( pTemp, fCompl, fReorder ); if ( pTemp != pNtk ) Abc_NtkDelete( pTemp ); return 0; @@ -3242,7 +3245,7 @@ int Abc_CommandShowBdd( Abc_Frame_t * pAbc, int argc, char ** argv ) return 0; usage: - Abc_Print( -2, "usage: show_bdd [-cgh] \n" ); + Abc_Print( -2, "usage: show_bdd [-cgrh] \n" ); Abc_Print( -2, " uses DOT and GSVIEW to visualize the global BDDs of primary outputs\n" ); Abc_Print( -2, " in terms of primary inputs or the local BDD of a node in terms of its fanins\n" ); #ifdef WIN32 @@ -3252,6 +3255,7 @@ usage: Abc_Print( -2, "\t: (optional) the node to consider [default = the driver of the first PO]\n"); Abc_Print( -2, "\t-c : toggle visualizing BDD with complemented edges [default = %s].\n", fCompl? "yes": "no" ); Abc_Print( -2, "\t-g : toggle visualizing the global BDDs of primary outputs [default = %s].\n", fGlobal? "yes": "no" ); + Abc_Print( -2, "\t-r : toggles dynamic variable reordering [default = %s]\n", fReorder? "yes": "no" ); Abc_Print( -2, "\t-h : print the command usage\n"); return 1; } @@ -14093,12 +14097,6 @@ int Abc_CommandTest( Abc_Frame_t * pAbc, int argc, char ** argv ) //Dau_NetworkEnumTest(); //Extra_SimulationTest( nDivMax, nNumOnes, fNewOrder ); //Mnist_ExperimentWithScaling( nDecMax ); - if ( Abc_FrameReadNtk(pAbc) ) - { - extern Abc_Ntk_t * Abc_NtkSpecialMapping( Abc_Ntk_t * pNtk, int fVerbose ); - Abc_Ntk_t * pNtkRes = Abc_NtkSpecialMapping( Abc_FrameReadNtk(pAbc), 0 ); - Abc_FrameReplaceCurrentNetwork( pAbc, pNtkRes ); - } return 0; usage: Abc_Print( -2, "usage: test [-CKDNM] [-aovwh] \n" ); @@ -41108,12 +41106,12 @@ usage: ***********************************************************************/ int Abc_CommandAbc9LNetOpt( Abc_Frame_t * pAbc, int argc, char ** argv ) { - extern Gia_Man_t * Gia_ManPerformLNetOpt( Gia_Man_t * p, char * pFileName, int nIns, int nOuts, int Thresh, int fVerbose ); + extern Gia_Man_t * Gia_ManPerformLNetOpt( Gia_Man_t * p, int fTryNew, char * pFileName, int nIns, int nOuts, int Thresh, int nRounds, int fVerbose ); Gia_Man_t * pTemp; char * pFileName = NULL; - int c, nIns = 6, nOuts = 2, Limit = 0, fVerbose = 0; + int c, fTryNew = 1, nIns = 6, nOuts = 2, Limit = 0, nRounds = 100, fVerbose = 0; Extra_UtilGetoptReset(); - while ( ( c = Extra_UtilGetopt( argc, argv, "IORvh" ) ) != EOF ) + while ( ( c = Extra_UtilGetopt( argc, argv, "IORXxvh" ) ) != EOF ) { switch ( c ) { @@ -41144,6 +41142,18 @@ int Abc_CommandAbc9LNetOpt( Abc_Frame_t * pAbc, int argc, char ** argv ) Limit = atoi(argv[globalUtilOptind]); globalUtilOptind++; break; + case 'X': + if ( globalUtilOptind >= argc ) + { + Abc_Print( -1, "Command line switch \"-X\" should be followed by a positive integer.\n" ); + goto usage; + } + nRounds = atoi(argv[globalUtilOptind]); + globalUtilOptind++; + break; + case 'x': + fTryNew ^= 1; + break; case 'v': fVerbose ^= 1; break; @@ -41172,17 +41182,19 @@ int Abc_CommandAbc9LNetOpt( Abc_Frame_t * pAbc, int argc, char ** argv ) fclose( pFile ); pFileName = argv[globalUtilOptind]; } - pTemp = Gia_ManPerformLNetOpt( pAbc->pGia, pFileName, nIns, nOuts, Limit, fVerbose ); + pTemp = Gia_ManPerformLNetOpt( pAbc->pGia, fTryNew, pFileName, nIns, nOuts, Limit, nRounds, fVerbose ); Abc_FrameUpdateGia( pAbc, pTemp ); return 0; usage: - Abc_Print( -2, "usage: &lnetopt [-IOR num] [-vh] \n" ); + Abc_Print( -2, "usage: &lnetopt [-IORX num] [-xvh] \n" ); Abc_Print( -2, "\t performs specialized AIG optimization\n" ); - Abc_Print( -2, "\t-I num : the input support size [default = %d]\n", nIns ); - Abc_Print( -2, "\t-O num : the output group size [default = %d]\n", nOuts ); + Abc_Print( -2, "\t-I num : the input support size [default = %d]\n", nIns ); + Abc_Print( -2, "\t-O num : the output group size [default = %d]\n", nOuts ); Abc_Print( -2, "\t-R num : patterns are cares starting this value [default = %d]\n", Limit ); - Abc_Print( -2, "\t-v : toggles verbose output [default = %s]\n", fVerbose? "yes": "no" ); + Abc_Print( -2, "\t-X num : the number of optimization rounds [default = %d]\n", nRounds ); + Abc_Print( -2, "\t-x : toggles using another computation [default = %s]\n", fTryNew? "yes": "no" ); + Abc_Print( -2, "\t-v : toggles verbose output [default = %s]\n", fVerbose? "yes": "no" ); Abc_Print( -2, "\t-h : prints the command usage\n"); Abc_Print( -2, "\t : file name with simulation information\n"); return 1; @@ -41201,12 +41213,12 @@ usage: ***********************************************************************/ int Abc_CommandAbc9LNetMap( Abc_Frame_t * pAbc, int argc, char ** argv ) { - extern Abc_Ntk_t * Gia_ManPerformLNetMap( Gia_Man_t * p, int GroupSize, int fUseFixed, int fVerbose ); + extern Abc_Ntk_t * Gia_ManPerformLNetMap( Gia_Man_t * p, int GroupSize, int fUseFixed, int fTryNew, int fVerbose ); Abc_Ntk_t * pTemp; char * pFileName = NULL; - int c, nIns = 6, nOuts = 2, fUseFixed = 0, fVerbose = 0; + int c, fTryNew = 1, nIns = 6, nOuts = 2, fUseFixed = 0, fVerbose = 0; Extra_UtilGetoptReset(); - while ( ( c = Extra_UtilGetopt( argc, argv, "IOfvh" ) ) != EOF ) + while ( ( c = Extra_UtilGetopt( argc, argv, "IOfxvh" ) ) != EOF ) { switch ( c ) { @@ -41231,6 +41243,9 @@ int Abc_CommandAbc9LNetMap( Abc_Frame_t * pAbc, int argc, char ** argv ) case 'f': fUseFixed ^= 1; break; + case 'x': + fTryNew ^= 1; + break; case 'v': fVerbose ^= 1; break; @@ -41255,16 +41270,17 @@ int Abc_CommandAbc9LNetMap( Abc_Frame_t * pAbc, int argc, char ** argv ) fclose( pFile ); pFileName = argv[globalUtilOptind]; } - pTemp = Gia_ManPerformLNetMap( pAbc->pGia, nOuts, fUseFixed, fVerbose ); + pTemp = Gia_ManPerformLNetMap( pAbc->pGia, nOuts, fUseFixed, fTryNew, fVerbose ); Abc_FrameReplaceCurrentNetwork( pAbc, pTemp ); return 0; usage: - Abc_Print( -2, "usage: &lnetmap [-IO num] [-fvh] \n" ); + Abc_Print( -2, "usage: &lnetmap [-IO num] [-fxvh] \n" ); Abc_Print( -2, "\t performs specialized LUT mapping\n" ); Abc_Print( -2, "\t-I num : the input support size [default = %d]\n", nIns ); Abc_Print( -2, "\t-O num : the output group size [default = %d]\n", nOuts ); Abc_Print( -2, "\t-f : toggles using fixed primitives [default = %s]\n", fUseFixed? "yes": "no" ); + Abc_Print( -2, "\t-x : toggles using another computation [default = %s]\n", fTryNew? "yes": "no" ); Abc_Print( -2, "\t-v : toggles verbose output [default = %s]\n", fVerbose? "yes": "no" ); Abc_Print( -2, "\t-h : prints the command usage\n"); Abc_Print( -2, "\t : file name with simulation information\n"); @@ -45447,6 +45463,7 @@ int Abc_CommandAbc9SatClp( Abc_Frame_t * pAbc, int argc, char ** argv ) return 0; } vSop = Bmc_CollapseOne( pAbc->pGia, nCubeLim, nBTLimit, fCanon, 0, fVerbose ); + printf( "%s\n", Vec_StrArray(vSop) ); Vec_StrFree( vSop ); return 0; @@ -48851,6 +48868,7 @@ int Abc_CommandAbc9Test( Abc_Frame_t * pAbc, int argc, char ** argv ) { extern void Gia_RsbEnumerateWindows( Gia_Man_t * p, int nInputsMax, int nLevelsMax ); extern int Gia_ManSumTotalOfSupportSizes( Gia_Man_t * p ); + extern void Abc_Tt6MinTest2( Gia_Man_t * p ); int c, fVerbose = 0; int nFrames = 5; int fSwitch = 0; @@ -48913,7 +48931,8 @@ int Abc_CommandAbc9Test( Abc_Frame_t * pAbc, int argc, char ** argv ) // } // Abc_FrameUpdateGia( pAbc, Abc_Procedure(pAbc->pGia) ); // printf( "AIG in \"%s\" has the sum of output support sizes equal to %d.\n", pAbc->pGia->pSpec, Gia_ManSumTotalOfSupportSizes(pAbc->pGia) ); - Gia_ManExtractTest( pAbc->pGia ); + //Gia_ManExtractTest( pAbc->pGia ); + //Abc_Tt6MinTest2( pAbc->pGia ); return 0; usage: Abc_Print( -2, "usage: &test [-FW num] [-svh]\n" ); -- cgit v1.2.3 From 28ba2c52137883b4acc46b2d31edf717822e543f Mon Sep 17 00:00:00 2001 From: Alan Mishchenko Date: Thu, 24 Jun 2021 19:18:28 -0700 Subject: Adding place holder file for resub experiments. --- src/base/abci/abc.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'src/base') diff --git a/src/base/abci/abc.c b/src/base/abci/abc.c index 96cd2188..913a8981 100644 --- a/src/base/abci/abc.c +++ b/src/base/abci/abc.c @@ -48866,6 +48866,7 @@ usage: ***********************************************************************/ int Abc_CommandAbc9Test( Abc_Frame_t * pAbc, int argc, char ** argv ) { + extern Gia_Man_t * Gia_ManPerformNewResub( Gia_Man_t * p, int nWinCount, int nCutSize, int nProcs, int fVerbose ); extern void Gia_RsbEnumerateWindows( Gia_Man_t * p, int nInputsMax, int nLevelsMax ); extern int Gia_ManSumTotalOfSupportSizes( Gia_Man_t * p ); extern void Abc_Tt6MinTest2( Gia_Man_t * p ); @@ -48924,12 +48925,12 @@ int Abc_CommandAbc9Test( Abc_Frame_t * pAbc, int argc, char ** argv ) goto usage; } } -// if ( pAbc->pGia == NULL ) -// { -// Abc_Print( -1, "Abc_CommandAbc9Test(): There is no AIG.\n" ); -// return 1; -// } -// Abc_FrameUpdateGia( pAbc, Abc_Procedure(pAbc->pGia) ); + if ( pAbc->pGia == NULL ) + { + Abc_Print( -1, "Abc_CommandAbc9Test(): There is no AIG.\n" ); + return 1; + } + Abc_FrameUpdateGia( pAbc, Gia_ManPerformNewResub(pAbc->pGia, 10, 8, 1, 1) ); // printf( "AIG in \"%s\" has the sum of output support sizes equal to %d.\n", pAbc->pGia->pSpec, Gia_ManSumTotalOfSupportSizes(pAbc->pGia) ); //Gia_ManExtractTest( pAbc->pGia ); //Abc_Tt6MinTest2( pAbc->pGia ); -- cgit v1.2.3 From 5a135c8799d439ad85ac9a0d105721ed80f355be Mon Sep 17 00:00:00 2001 From: Alan Mishchenko Date: Thu, 8 Jul 2021 21:42:15 -0700 Subject: Experiments with MUX decomposition. --- src/base/abci/abc.c | 56 ++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 55 insertions(+), 1 deletion(-) (limited to 'src/base') diff --git a/src/base/abci/abc.c b/src/base/abci/abc.c index 913a8981..9e24d2c0 100644 --- a/src/base/abci/abc.c +++ b/src/base/abci/abc.c @@ -400,6 +400,7 @@ static int Abc_CommandAbc9Status ( Abc_Frame_t * pAbc, int argc, cha static int Abc_CommandAbc9MuxProfile ( Abc_Frame_t * pAbc, int argc, char ** argv ); static int Abc_CommandAbc9MuxPos ( Abc_Frame_t * pAbc, int argc, char ** argv ); static int Abc_CommandAbc9MuxStr ( Abc_Frame_t * pAbc, int argc, char ** argv ); +static int Abc_CommandAbc9MuxDec ( Abc_Frame_t * pAbc, int argc, char ** argv ); static int Abc_CommandAbc9PrintTruth ( Abc_Frame_t * pAbc, int argc, char ** argv ); static int Abc_CommandAbc9Unate ( Abc_Frame_t * pAbc, int argc, char ** argv ); static int Abc_CommandAbc9Rex2Gia ( Abc_Frame_t * pAbc, int argc, char ** argv ); @@ -1129,6 +1130,7 @@ void Abc_Init( Abc_Frame_t * pAbc ) Cmd_CommandAdd( pAbc, "ABC9", "&profile", Abc_CommandAbc9MuxProfile, 0 ); Cmd_CommandAdd( pAbc, "ABC9", "&muxpos", Abc_CommandAbc9MuxPos, 0 ); Cmd_CommandAdd( pAbc, "ABC9", "&muxstr", Abc_CommandAbc9MuxStr, 0 ); + Cmd_CommandAdd( pAbc, "ABC9", "&muxdec", Abc_CommandAbc9MuxDec, 0 ); Cmd_CommandAdd( pAbc, "ABC9", "&print_truth", Abc_CommandAbc9PrintTruth, 0 ); Cmd_CommandAdd( pAbc, "ABC9", "&unate", Abc_CommandAbc9Unate, 0 ); Cmd_CommandAdd( pAbc, "ABC9", "&rex2gia", Abc_CommandAbc9Rex2Gia, 0 ); @@ -31717,6 +31719,58 @@ usage: } +/**Function************************************************************* + + Synopsis [] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +int Abc_CommandAbc9MuxDec( Abc_Frame_t * pAbc, int argc, char ** argv ) +{ + extern Gia_Man_t * Gia_ManPerformMuxDec( Gia_Man_t * p ); + Gia_Man_t * pGia; + int c, fVerbose = 0; + Extra_UtilGetoptReset(); + while ( ( c = Extra_UtilGetopt( argc, argv, "vh" ) ) != EOF ) + { + switch ( c ) + { + case 'v': + fVerbose ^= 1; + break; + case 'h': + goto usage; + default: + goto usage; + } + } + if ( pAbc->pGia == NULL ) + { + Abc_Print( -1, "Abc_CommandAbc9MuxDec(): There is no AIG.\n" ); + return 1; + } + if ( Gia_ManCiNum(pAbc->pGia) <= 6 || Gia_ManCiNum(pAbc->pGia) > 26 ) + { + Abc_Print( -1, "Abc_CommandAbc9MuxDec(): The number of inputs is wrong.\n" ); + return 1; + } + pGia = Gia_ManPerformMuxDec( pAbc->pGia ); + Abc_FrameUpdateGia( pAbc, pGia ); + return 0; + +usage: + Abc_Print( -2, "usage: &muxdec [-vh]\n" ); + Abc_Print( -2, "\t performs restructuring\n" ); + Abc_Print( -2, "\t-v : toggle verbose output [default = %s]\n", fVerbose? "yes": "no" ); + Abc_Print( -2, "\t-h : print the command usage\n"); + return 1; +} + /**Function************************************************************* Synopsis [] @@ -48930,7 +48984,7 @@ int Abc_CommandAbc9Test( Abc_Frame_t * pAbc, int argc, char ** argv ) Abc_Print( -1, "Abc_CommandAbc9Test(): There is no AIG.\n" ); return 1; } - Abc_FrameUpdateGia( pAbc, Gia_ManPerformNewResub(pAbc->pGia, 10, 8, 1, 1) ); + Abc_FrameUpdateGia( pAbc, Gia_ManPerformNewResub(pAbc->pGia, 100, 8, 1, 1) ); // printf( "AIG in \"%s\" has the sum of output support sizes equal to %d.\n", pAbc->pGia->pSpec, Gia_ManSumTotalOfSupportSizes(pAbc->pGia) ); //Gia_ManExtractTest( pAbc->pGia ); //Abc_Tt6MinTest2( pAbc->pGia ); -- cgit v1.2.3 From 9fac6c7a8b150792b67c3daabf672137942103ee Mon Sep 17 00:00:00 2001 From: Alan Mishchenko Date: Sat, 10 Jul 2021 10:50:33 -0700 Subject: Experiments with CEC. --- src/base/abci/abc.c | 30 ++++++++++++++++++++++++++---- 1 file changed, 26 insertions(+), 4 deletions(-) (limited to 'src/base') diff --git a/src/base/abci/abc.c b/src/base/abci/abc.c index 9e24d2c0..0350b671 100644 --- a/src/base/abci/abc.c +++ b/src/base/abci/abc.c @@ -37407,10 +37407,10 @@ int Abc_CommandAbc9Cec( Abc_Frame_t * pAbc, int argc, char ** argv ) FILE * pFile; Gia_Man_t * pGias[2] = {NULL, NULL}, * pMiter; char ** pArgvNew; - int c, nArgcNew, fUseNew = 0, fMiter = 0, fDualOutput = 0, fDumpMiter = 0; + int c, nArgcNew, fUseSim = 0, fUseNew = 0, fMiter = 0, fDualOutput = 0, fDumpMiter = 0; Cec_ManCecSetDefaultParams( pPars ); Extra_UtilGetoptReset(); - while ( ( c = Extra_UtilGetopt( argc, argv, "CTnmdasxvwh" ) ) != EOF ) + while ( ( c = Extra_UtilGetopt( argc, argv, "CTnmdasxtvwh" ) ) != EOF ) { switch ( c ) { @@ -37454,6 +37454,9 @@ int Abc_CommandAbc9Cec( Abc_Frame_t * pAbc, int argc, char ** argv ) case 'x': fUseNew ^= 1; break; + case 't': + fUseSim ^= 1; + break; case 'v': pPars->fVerbose ^= 1; break; @@ -37605,7 +37608,25 @@ int Abc_CommandAbc9Cec( Abc_Frame_t * pAbc, int argc, char ** argv ) pMiter->vSimsPi = Vec_WrdDup(pGias[0]->vSimsPi); pMiter->nSimWords = pGias[0]->nSimWords; } - if ( fUseNew ) + if ( fUseSim && Gia_ManCiNum(pMiter) > 40 ) + { + Abc_Print( -1, "This type of CEC can only be applied to AIGs with no more than 40 inputs.\n" ); + return 0; + } + if ( fUseSim ) + { + abctime clk = Abc_Clock(); + extern int Gia_ManCheckSimEquiv( Gia_Man_t * p, int fVerbose ); + int Status = Gia_ManCheckSimEquiv( pMiter, pPars->fVerbose ); + if ( Status == 1 ) + Abc_Print( 1, "Networks are equivalent. " ); + else if ( Status == 0 ) + Abc_Print( 1, "Networks are NOT equivalent. " ); + else + Abc_Print( 1, "Networks are UNDECIDED. " ); + Abc_PrintTime( 1, "Time", Abc_Clock() - clk ); + } + else if ( fUseNew ) { abctime clk = Abc_Clock(); extern Gia_Man_t * Cec4_ManSimulateTest3( Gia_Man_t * p, int nBTLimit, int fVerbose ); @@ -37630,7 +37651,7 @@ int Abc_CommandAbc9Cec( Abc_Frame_t * pAbc, int argc, char ** argv ) return 0; usage: - Abc_Print( -2, "usage: &cec [-CT num] [-nmdasxvwh]\n" ); + Abc_Print( -2, "usage: &cec [-CT num] [-nmdasxtvwh]\n" ); Abc_Print( -2, "\t new combinational equivalence checker\n" ); Abc_Print( -2, "\t-C num : the max number of conflicts at a node [default = %d]\n", pPars->nBTLimit ); Abc_Print( -2, "\t-T num : approximate runtime limit in seconds [default = %d]\n", pPars->TimeLimit ); @@ -37640,6 +37661,7 @@ usage: Abc_Print( -2, "\t-a : toggle writing dual-output miter [default = %s]\n", fDumpMiter? "yes":"no"); Abc_Print( -2, "\t-s : toggle silent operation [default = %s]\n", pPars->fSilent ? "yes":"no"); Abc_Print( -2, "\t-x : toggle using new solver [default = %s]\n", fUseNew? "yes":"no"); + Abc_Print( -2, "\t-t : toggle using simulation [default = %s]\n", fUseSim? "yes":"no"); Abc_Print( -2, "\t-v : toggle verbose output [default = %s]\n", pPars->fVerbose? "yes":"no"); Abc_Print( -2, "\t-w : toggle printing SAT solver statistics [default = %s]\n", pPars->fVeryVerbose? "yes":"no"); Abc_Print( -2, "\t-h : print the command usage\n"); -- cgit v1.2.3 From 3e67d167f5c07315f3d1bb7d8ae6c079cb451ded Mon Sep 17 00:00:00 2001 From: Alan Mishchenko Date: Tue, 13 Jul 2021 19:05:02 -0700 Subject: Experiments with LUT mapping for small functions. --- src/base/abci/abc.c | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) (limited to 'src/base') diff --git a/src/base/abci/abc.c b/src/base/abci/abc.c index 0350b671..af8608b1 100644 --- a/src/base/abci/abc.c +++ b/src/base/abci/abc.c @@ -41025,6 +41025,7 @@ usage: ***********************************************************************/ int Abc_CommandAbc9LNetRead( Abc_Frame_t * pAbc, int argc, char ** argv ) { + extern Gia_Man_t * Vec_WrdReadTest( char * pFileName ); extern void Gia_ManReadSimInfoInputs( char * pFileName, char * pFileOut1, int fVerbose ); int c, fVerbose = 0; Extra_UtilGetoptReset(); @@ -41045,11 +41046,21 @@ int Abc_CommandAbc9LNetRead( Abc_Frame_t * pAbc, int argc, char ** argv ) Gia_ManReadSimInfoInputs( argv[globalUtilOptind], argv[globalUtilOptind+1], fVerbose ); return 0; } + if ( strstr(argv[globalUtilOptind], ".v") ) + { + Gia_Man_t * pNew = Vec_WrdReadTest( argv[globalUtilOptind] ); + if ( pNew == NULL ) + { + printf( "Cannot read network from file \"%s\".\n", argv[globalUtilOptind] ); + return 0; + } + Abc_FrameUpdateGia( pAbc, pNew ); + } return 0; usage: Abc_Print( -2, "usage: &lnetread [-vh] \n" ); - Abc_Print( -2, "\t reads and converts the simulation data\n" ); + Abc_Print( -2, "\t reads and converts the network or the simulation data\n" ); Abc_Print( -2, "\t-v : toggles verbose output [default = %s]\n", fVerbose? "yes": "no" ); Abc_Print( -2, "\t-h : prints the command usage\n"); Abc_Print( -2, "\t : input file name with simulation information\n"); @@ -41252,7 +41263,7 @@ int Abc_CommandAbc9LNetOpt( Abc_Frame_t * pAbc, int argc, char ** argv ) FILE * pFile = fopen( argv[globalUtilOptind], "rb" ); if ( pFile == NULL ) { - Abc_Print( -1, "Abc_CommandAbc9BCore(): Cannot open file \"%s\" for writing the proof.\n", argv[globalUtilOptind] ); + Abc_Print( -1, "Abc_CommandAbc9BCore(): Cannot open file \"%s\" for reading the simulation information.\n", argv[globalUtilOptind] ); return 0; } fclose( pFile ); @@ -41340,7 +41351,7 @@ int Abc_CommandAbc9LNetMap( Abc_Frame_t * pAbc, int argc, char ** argv ) FILE * pFile = fopen( argv[globalUtilOptind], "rb" ); if ( pFile == NULL ) { - Abc_Print( -1, "Abc_CommandAbc9BCore(): Cannot open file \"%s\" for writing the proof.\n", argv[globalUtilOptind] ); + Abc_Print( -1, "Abc_CommandAbc9BCore(): Cannot open file \"%s\" for reading the simulation information.\n", argv[globalUtilOptind] ); return 0; } fclose( pFile ); -- cgit v1.2.3 From d9aeaade3b29360c65b54f6df734359b3fb452f0 Mon Sep 17 00:00:00 2001 From: Alan Mishchenko Date: Thu, 15 Jul 2021 18:23:04 -0700 Subject: Several unrelated changes. --- src/base/wlc/wlc.c | 67 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 67 insertions(+) (limited to 'src/base') diff --git a/src/base/wlc/wlc.c b/src/base/wlc/wlc.c index 6f0890e2..33308fd0 100644 --- a/src/base/wlc/wlc.c +++ b/src/base/wlc/wlc.c @@ -265,6 +265,73 @@ void Wlc_BlastMultiplierCnfTest( int nBits ) sat_solver_delete( pSat ); } +/**Function************************************************************* + + Synopsis [] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +Vec_Int_t * Wlc_ManGenAdderN( Gia_Man_t * p, int nLits, int * pLitsA, int * pLitsB, int Carry ) +{ + extern void Wlc_BlastFullAdder( Gia_Man_t * pNew, int a, int b, int c, int * pc, int * ps ); + Vec_Int_t * vRes = Vec_IntStart( nLits + 1 ); + int i, * pRes = Vec_IntArray(vRes); + for ( i = 0; i < nLits; i++ ) + Wlc_BlastFullAdder( p, pLitsA[i], pLitsB[i], Carry, &Carry, &pRes[i] ); + pRes[nLits] = Carry; + return vRes; +} +Vec_Int_t * Wlc_ManGenAdder_rec( Gia_Man_t * p, int nLits, int * pLitsA, int * pLitsB, int Carry, int Size ) +{ + Vec_Int_t * vRes, * vRes0, * vRes1, * vRes2; int i, iCtrl; + if ( nLits == Size ) + return Wlc_ManGenAdderN( p, nLits, pLitsA, pLitsB, Carry ); + vRes0 = Wlc_ManGenAdder_rec( p, nLits/2, pLitsA, pLitsB, Carry, Size ); + vRes1 = Wlc_ManGenAdder_rec( p, nLits/2, pLitsA + nLits/2, pLitsB + nLits/2, 0, Size ); + vRes2 = Wlc_ManGenAdder_rec( p, nLits/2, pLitsA + nLits/2, pLitsB + nLits/2, 1, Size ); + vRes = Vec_IntAlloc( nLits + 1 ); + Vec_IntAppend( vRes, vRes0 ); + iCtrl = Vec_IntPop( vRes ); + for ( i = 0; i <= nLits/2; i++ ) + Vec_IntPush( vRes, Gia_ManHashMux(p, iCtrl, Vec_IntEntry(vRes2, i), Vec_IntEntry(vRes1, i)) ); + assert( Vec_IntSize(vRes) == nLits + 1 ); + Vec_IntFree( vRes0 ); + Vec_IntFree( vRes1 ); + Vec_IntFree( vRes2 ); + return vRes; +} +Gia_Man_t * Wlc_ManGenAdder( int nBits, int Size, int fSigned ) +{ + Gia_Man_t * pTemp, * pNew; int n, i, iLit, nBitsAll; + Vec_Int_t * vOuts, * vLits = Vec_IntAlloc( 1000 ); + pNew = Gia_ManStart( 1000 ); + pNew->pName = Abc_UtilStrsav( "adder" ); + for ( nBitsAll = Size; nBitsAll < nBits; nBitsAll *= 2 ) + ; + for ( n = 0; n < 2; n++ ) + { + for ( i = 0; i < nBits; i++ ) + Vec_IntPush( vLits, Gia_ManAppendCi(pNew) ); + for ( ; i < nBitsAll; i++ ) + Vec_IntPush( vLits, fSigned ? Vec_IntEntry(vLits, nBits-1) : 0 ); + } + Gia_ManHashAlloc( pNew ); + vOuts = Wlc_ManGenAdder_rec( pNew, nBitsAll, Vec_IntEntryP(vLits, 0), Vec_IntEntryP(vLits, Vec_IntSize(vLits)/2), 0, Size ); + Gia_ManHashStop( pNew ); + Vec_IntForEachEntry( vOuts, iLit, i ) + Gia_ManAppendCo( pNew, iLit ); + Vec_IntFree( vLits ); + Vec_IntFree( vOuts ); + pNew = Gia_ManCleanup( pTemp = pNew ); + Gia_ManStop( pTemp ); + return pNew; +} + //////////////////////////////////////////////////////////////////////// /// END OF FILE /// //////////////////////////////////////////////////////////////////////// -- cgit v1.2.3 From 6e5a797a6d7551af06c0a0ebf721161ba2b6f44d Mon Sep 17 00:00:00 2001 From: Alan Mishchenko Date: Fri, 16 Jul 2021 13:44:38 -0700 Subject: Command to move CI/CO names. --- src/base/abci/abc.c | 63 +++++++++++++++++++ src/base/wlc/wlc.c | 178 ++++++++++++++++++++++++++++++++++++++++++++++++++-- 2 files changed, 235 insertions(+), 6 deletions(-) (limited to 'src/base') diff --git a/src/base/abci/abc.c b/src/base/abci/abc.c index af8608b1..13813c61 100644 --- a/src/base/abci/abc.c +++ b/src/base/abci/abc.c @@ -379,6 +379,7 @@ static int Abc_CommandAbcLoad ( Abc_Frame_t * pAbc, int argc, cha static int Abc_CommandAbc9Get ( Abc_Frame_t * pAbc, int argc, char ** argv ); static int Abc_CommandAbc9Put ( Abc_Frame_t * pAbc, int argc, char ** argv ); +static int Abc_CommandAbc9MoveNames ( Abc_Frame_t * pAbc, int argc, char ** argv ); static int Abc_CommandAbc9Save ( Abc_Frame_t * pAbc, int argc, char ** argv ); static int Abc_CommandAbc9Save2 ( Abc_Frame_t * pAbc, int argc, char ** argv ); static int Abc_CommandAbc9SaveAig ( Abc_Frame_t * pAbc, int argc, char ** argv ); @@ -1107,6 +1108,7 @@ void Abc_Init( Abc_Frame_t * pAbc ) Cmd_CommandAdd( pAbc, "ABC9", "&get", Abc_CommandAbc9Get, 0 ); Cmd_CommandAdd( pAbc, "ABC9", "&put", Abc_CommandAbc9Put, 0 ); + Cmd_CommandAdd( pAbc, "ABC9", "&move_names", Abc_CommandAbc9MoveNames, 0 ); Cmd_CommandAdd( pAbc, "ABC9", "&save", Abc_CommandAbc9Save, 0 ); Cmd_CommandAdd( pAbc, "ABC9", "&save2", Abc_CommandAbc9Save2, 0 ); Cmd_CommandAdd( pAbc, "ABC9", "&saveaig", Abc_CommandAbc9SaveAig, 0 ); @@ -30731,6 +30733,67 @@ usage: } +/**Function************************************************************* + + Synopsis [] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +int Abc_CommandAbc9MoveNames( Abc_Frame_t * pAbc, int argc, char ** argv ) +{ + int c, fVerbose = 0; + Extra_UtilGetoptReset(); + while ( ( c = Extra_UtilGetopt( argc, argv, "nvh" ) ) != EOF ) + { + switch ( c ) + { + case 'v': + fVerbose ^= 1; + break; + default: + goto usage; + } + } + if ( pAbc->pNtkCur == NULL ) + { + Abc_Print( -1, "There is no current network\n" ); + return 1; + } + if ( pAbc->pGia == NULL ) + { + Abc_Print( -1, "There is no current AIG.\n" ); + return 1; + } + if ( Gia_ManCiNum(pAbc->pGia) != Abc_NtkCiNum(pAbc->pNtkCur) ) + { + Abc_Print( -1, "The number of CIs does not match.\n" ); + return 1; + } + if ( Gia_ManCoNum(pAbc->pGia) != Abc_NtkCoNum(pAbc->pNtkCur) ) + { + Abc_Print( -1, "The number of COs does not match.\n" ); + return 1; + } + if ( pAbc->pGia->vNamesIn ) Vec_PtrFreeFree( pAbc->pGia->vNamesIn ); + if ( pAbc->pGia->vNamesOut ) Vec_PtrFreeFree( pAbc->pGia->vNamesOut ); + pAbc->pGia->vNamesIn = Abc_NtkCollectCiNames( pAbc->pNtkCur ); + pAbc->pGia->vNamesOut = Abc_NtkCollectCoNames( pAbc->pNtkCur ); + return 0; + +usage: + Abc_Print( -2, "usage: &move_names [-vh]\n" ); + Abc_Print( -2, "\t move CI/CO names\n" ); + Abc_Print( -2, "\t-v : toggles additional verbose output [default = %s]\n", fVerbose? "yes": "no" ); + Abc_Print( -2, "\t-h : print the command usage\n"); + Abc_Print( -2, "\t : the file name\n"); + return 1; +} + /**Function************************************************************* Synopsis [Compares to versions of the design and finds the best.] diff --git a/src/base/wlc/wlc.c b/src/base/wlc/wlc.c index 33308fd0..03c3f54c 100644 --- a/src/base/wlc/wlc.c +++ b/src/base/wlc/wlc.c @@ -286,14 +286,14 @@ Vec_Int_t * Wlc_ManGenAdderN( Gia_Man_t * p, int nLits, int * pLitsA, int * pLit pRes[nLits] = Carry; return vRes; } -Vec_Int_t * Wlc_ManGenAdder_rec( Gia_Man_t * p, int nLits, int * pLitsA, int * pLitsB, int Carry, int Size ) +Vec_Int_t * Wlc_ManGenAdder2_rec( Gia_Man_t * p, int nLits, int * pLitsA, int * pLitsB, int Carry, int Size ) { Vec_Int_t * vRes, * vRes0, * vRes1, * vRes2; int i, iCtrl; if ( nLits == Size ) return Wlc_ManGenAdderN( p, nLits, pLitsA, pLitsB, Carry ); - vRes0 = Wlc_ManGenAdder_rec( p, nLits/2, pLitsA, pLitsB, Carry, Size ); - vRes1 = Wlc_ManGenAdder_rec( p, nLits/2, pLitsA + nLits/2, pLitsB + nLits/2, 0, Size ); - vRes2 = Wlc_ManGenAdder_rec( p, nLits/2, pLitsA + nLits/2, pLitsB + nLits/2, 1, Size ); + vRes0 = Wlc_ManGenAdder2_rec( p, nLits/2, pLitsA, pLitsB, Carry, Size ); + vRes1 = Wlc_ManGenAdder2_rec( p, nLits/2, pLitsA + nLits/2, pLitsB + nLits/2, 0, Size ); + vRes2 = Wlc_ManGenAdder2_rec( p, nLits/2, pLitsA + nLits/2, pLitsB + nLits/2, 1, Size ); vRes = Vec_IntAlloc( nLits + 1 ); Vec_IntAppend( vRes, vRes0 ); iCtrl = Vec_IntPop( vRes ); @@ -305,7 +305,7 @@ Vec_Int_t * Wlc_ManGenAdder_rec( Gia_Man_t * p, int nLits, int * pLitsA, int * p Vec_IntFree( vRes2 ); return vRes; } -Gia_Man_t * Wlc_ManGenAdder( int nBits, int Size, int fSigned ) +Gia_Man_t * Wlc_ManGenAdder2( int nBits, int Size, int fSigned ) { Gia_Man_t * pTemp, * pNew; int n, i, iLit, nBitsAll; Vec_Int_t * vOuts, * vLits = Vec_IntAlloc( 1000 ); @@ -321,7 +321,7 @@ Gia_Man_t * Wlc_ManGenAdder( int nBits, int Size, int fSigned ) Vec_IntPush( vLits, fSigned ? Vec_IntEntry(vLits, nBits-1) : 0 ); } Gia_ManHashAlloc( pNew ); - vOuts = Wlc_ManGenAdder_rec( pNew, nBitsAll, Vec_IntEntryP(vLits, 0), Vec_IntEntryP(vLits, Vec_IntSize(vLits)/2), 0, Size ); + vOuts = Wlc_ManGenAdder2_rec( pNew, nBitsAll, Vec_IntEntryP(vLits, 0), Vec_IntEntryP(vLits, Vec_IntSize(vLits)/2), 0, Size ); Gia_ManHashStop( pNew ); Vec_IntForEachEntry( vOuts, iLit, i ) Gia_ManAppendCo( pNew, iLit ); @@ -332,6 +332,172 @@ Gia_Man_t * Wlc_ManGenAdder( int nBits, int Size, int fSigned ) return pNew; } +Vec_Int_t * Wlc_ManGenAdder_rec( Gia_Man_t * p, int nLits, int * pLitsA, int * pLitsB, int Carry, int Size ) +{ + Vec_Int_t * vRes, * vRes0, * vRes1, * vRes2, * vRes3, * vRes4; int i, iCtrl; + if ( nLits == Size ) + return Wlc_ManGenAdderN( p, nLits, pLitsA, pLitsB, Carry ); + assert( nLits % 3 == 0 ); + vRes0 = Wlc_ManGenAdder_rec( p, nLits/3, pLitsA + 0*nLits/3, pLitsB + 0*nLits/3, Carry, Size ); + vRes1 = Wlc_ManGenAdder_rec( p, nLits/3, pLitsA + 1*nLits/3, pLitsB + 1*nLits/3, 0, Size ); + vRes2 = Wlc_ManGenAdder_rec( p, nLits/3, pLitsA + 1*nLits/3, pLitsB + 1*nLits/3, 1, Size ); + vRes3 = Wlc_ManGenAdder_rec( p, nLits/3, pLitsA + 2*nLits/3, pLitsB + 2*nLits/3, 0, Size ); + vRes4 = Wlc_ManGenAdder_rec( p, nLits/3, pLitsA + 2*nLits/3, pLitsB + 2*nLits/3, 1, Size ); + vRes = Vec_IntAlloc( nLits + 1 ); + Vec_IntAppend( vRes, vRes0 ); + iCtrl = Vec_IntPop( vRes ); + for ( i = 0; i <= nLits/3; i++ ) + Vec_IntPush( vRes, Gia_ManHashMux(p, iCtrl, Vec_IntEntry(vRes2, i), Vec_IntEntry(vRes1, i)) ); + iCtrl = Vec_IntPop( vRes ); + for ( i = 0; i <= nLits/3; i++ ) + Vec_IntPush( vRes, Gia_ManHashMux(p, iCtrl, Vec_IntEntry(vRes4, i), Vec_IntEntry(vRes3, i)) ); + assert( Vec_IntSize(vRes) == nLits + 1 ); + Vec_IntFree( vRes0 ); + Vec_IntFree( vRes1 ); + Vec_IntFree( vRes2 ); + Vec_IntFree( vRes3 ); + Vec_IntFree( vRes4 ); + return vRes; +} +Gia_Man_t * Wlc_ManGenAdder( int nBits ) +{ + Gia_Man_t * pTemp, * pNew; int n, i, iLit, nBitsAll; + Vec_Int_t * vOuts, * vLits = Vec_IntAlloc( 1000 ); + pNew = Gia_ManStart( 1000 ); + pNew->pName = Abc_UtilStrsav( "adder" ); + for ( nBitsAll = 3; nBitsAll < nBits; nBitsAll *= 3 ) + ; + for ( n = 0; n < 2; n++ ) + { + for ( i = 0; i < nBits; i++ ) + Vec_IntPush( vLits, Gia_ManAppendCi(pNew) ); + for ( ; i < nBitsAll; i++ ) + Vec_IntPush( vLits, 0 ); + } + Gia_ManHashAlloc( pNew ); + vOuts = Wlc_ManGenAdder_rec( pNew, nBitsAll, Vec_IntEntryP(vLits, 0), Vec_IntEntryP(vLits, Vec_IntSize(vLits)/2), 0, 3 ); + Gia_ManHashStop( pNew ); + Vec_IntForEachEntryStop( vOuts, iLit, i, nBits+1 ) + Gia_ManAppendCo( pNew, iLit ); + Vec_IntFree( vLits ); + Vec_IntFree( vOuts ); + pNew = Gia_ManCleanup( pTemp = pNew ); + Gia_ManStop( pTemp ); + return pNew; +} + +/**Function************************************************************* + + Synopsis [] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +Vec_Wec_t * Wlc_ManGenTree_iter( Gia_Man_t * p, Vec_Wec_t * vBits, int * pCounter ) +{ + Vec_Wec_t * vBitsNew = Vec_WecStart( Vec_WecSize(vBits) ); int i, k, Count = 0; + for ( i = 0; i < Vec_WecSize(vBits)-1; i++ ) + { + Vec_Int_t * vBits0 = Vec_WecEntry(vBits, i); + Vec_Int_t * vBits1 = Vec_WecEntry(vBits, i+1); + if ( i == 0 ) + { + int s = 0; + } + while ( Vec_IntSize(vBits0) >= 6 ) + { + for ( k = 0; k < 6; k++ ) + Vec_IntPop( vBits0 ); + Vec_WecPush( vBitsNew, i+0, 0 ); + Vec_WecPush( vBitsNew, i+1, 0 ); + Vec_WecPush( vBitsNew, i+2, 0 ); + Count += 3; + } + if ( Vec_IntSize(vBits0) == 4 || Vec_IntSize(vBits0) == 5 ) + { + Vec_IntClear( vBits0 ); + if ( Vec_IntSize(vBits1) > 0 ) + Vec_IntPop( vBits1 ); + Vec_WecPush( vBitsNew, i+0, 0 ); + Vec_WecPush( vBitsNew, i+1, 0 ); + Vec_WecPush( vBitsNew, i+2, 0 ); + Count += 3; + } + //if ( (Vec_IntSize(vBits0) == 2 && Vec_IntSize(vBits1) > 1) || (Vec_IntSize(vBits0) == 3 && Vec_IntSize(vBits1) > 0) ) + if ( Vec_IntSize(vBits0) == 3 && Vec_IntSize(vBits1) > 0 ) + { + Vec_IntClear( vBits0 ); + Vec_IntPop( vBits1 ); + if ( Vec_IntSize(vBits1) > 0 ) + Vec_IntPop( vBits1 ); + if ( Vec_IntSize(vBits1) > 0 ) + Vec_IntPop( vBits1 ); + Vec_WecPush( vBitsNew, i+0, 0 ); + Vec_WecPush( vBitsNew, i+1, 0 ); + Vec_WecPush( vBitsNew, i+2, 0 ); + Count += 3; + } + if ( Vec_IntSize(vBits0) == 3 && Vec_IntSize(vBits1) == 0 ) + { + Vec_IntClear( vBits0 ); + Vec_WecPush( vBitsNew, i+0, 0 ); + Vec_WecPush( vBitsNew, i+1, 0 ); + Count += 2; + } +/* + if ( Vec_IntSize(vBits0) == 1 && Vec_IntSize(vBits1) > 2 ) + { + Vec_IntClear( vBits0 ); + Vec_IntPop( vBits1 ); + Vec_IntPop( vBits1 ); + Vec_IntPop( vBits1 ); + Vec_WecPush( vBitsNew, i+0, 0 ); + Vec_WecPush( vBitsNew, i+1, 0 ); + Vec_WecPush( vBitsNew, i+2, 0 ); + } +*/ + for ( k = 0; k < Vec_IntSize(vBits0); k++ ) + Vec_WecPush( vBitsNew, i, 0 ); + Vec_IntClear( vBits0 ); + } + if ( pCounter ) + *pCounter += Count; + return vBitsNew; +} +Gia_Man_t * Wlc_ManGenTree( int nBits ) +{ + Gia_Man_t * pTemp, * pNew; int i, iLit, Counter = 0; + Vec_Int_t * vOuts = Vec_IntAlloc( 1000 ), * vLits = Vec_IntAlloc( 1000 ); + Vec_Wec_t * vTemp, * vBits = Vec_WecStart( 14 ); // Abc_Base2Log(nBits)+3 ); + pNew = Gia_ManStart( 1000 ); + pNew->pName = Abc_UtilStrsav( "tree" ); + for ( i = 0; i < nBits; i++ ) +// Vec_WecPush( vBits, 0, Gia_ManAppendCi(pNew) ); + Vec_WecPush( vBits, 0, 0 ); + Vec_WecPrint( vBits, 0 ); + Gia_ManHashAlloc( pNew ); + for ( i = 0; i < 10; i++ ) + { + vBits = Wlc_ManGenTree_iter( pNew, vTemp = vBits, &Counter ); + Vec_WecFree( vTemp ); + printf( "LEVEL %d\n", i+1 ); + Vec_WecPrint( vBits, 0 ); + } + printf( "Counter = %d.\n", Counter ); + Gia_ManHashStop( pNew ); + Vec_IntForEachEntry( vOuts, iLit, i ) + Gia_ManAppendCo( pNew, iLit ); + Vec_IntFree( vLits ); + Vec_WecFree( vBits ); + pNew = Gia_ManCleanup( pTemp = pNew ); + Gia_ManStop( pTemp ); + return pNew; +} + //////////////////////////////////////////////////////////////////////// /// END OF FILE /// //////////////////////////////////////////////////////////////////////// -- cgit v1.2.3 From 62180f357678df2be0b678bec33ac8e8b36945b8 Mon Sep 17 00:00:00 2001 From: Alan Mishchenko Date: Fri, 16 Jul 2021 13:46:41 -0700 Subject: Command to move CI/CO names. --- src/base/abci/abc.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'src/base') diff --git a/src/base/abci/abc.c b/src/base/abci/abc.c index 13813c61..02264b16 100644 --- a/src/base/abci/abc.c +++ b/src/base/abci/abc.c @@ -584,6 +584,9 @@ extern int Abc_CommandNChooseK ( Abc_Frame_t * pAbc, int argc, cha extern Aig_Man_t * Abc_NtkToDar( Abc_Ntk_t * pNtk, int fExors, int fRegisters ); extern Abc_Ntk_t * Abc_NtkFromAigPhase( Aig_Man_t * pMan ); +extern Vec_Ptr_t * Abc_NtkCollectCiNames( Abc_Ntk_t * pNtk ); +extern Vec_Ptr_t * Abc_NtkCollectCoNames( Abc_Ntk_t * pNtk ); + //////////////////////////////////////////////////////////////////////// /// FUNCTION DEFINITIONS /// //////////////////////////////////////////////////////////////////////// @@ -30482,8 +30485,6 @@ usage: int Abc_CommandAbc9Get( Abc_Frame_t * pAbc, int argc, char ** argv ) { extern Aig_Man_t * Abc_NtkToDarChoices( Abc_Ntk_t * pNtk ); - extern Vec_Ptr_t * Abc_NtkCollectCiNames( Abc_Ntk_t * pNtk ); - extern Vec_Ptr_t * Abc_NtkCollectCoNames( Abc_Ntk_t * pNtk ); Abc_Ntk_t * pStrash; Aig_Man_t * pAig; Gia_Man_t * pGia, * pTemp; -- cgit v1.2.3 From a162b1f47aa4d3c38439d779c7ad943102c63bc5 Mon Sep 17 00:00:00 2001 From: Alan Mishchenko Date: Sun, 25 Jul 2021 14:11:34 -0700 Subject: Experimental simulation commands. --- src/base/abci/abc.c | 180 +++++++++++++++++++++++++++ src/base/wlc/wlc.c | 319 +++++++++++++++++++++++++++++++++++++++--------- src/base/wlc/wlcBlast.c | 24 ++-- 3 files changed, 458 insertions(+), 65 deletions(-) (limited to 'src/base') diff --git a/src/base/abci/abc.c b/src/base/abci/abc.c index 02264b16..8668a1f2 100644 --- a/src/base/abci/abc.c +++ b/src/base/abci/abc.c @@ -415,6 +415,7 @@ static int Abc_CommandAbc9Cof ( Abc_Frame_t * pAbc, int argc, cha static int Abc_CommandAbc9Trim ( Abc_Frame_t * pAbc, int argc, char ** argv ); static int Abc_CommandAbc9Dfs ( Abc_Frame_t * pAbc, int argc, char ** argv ); static int Abc_CommandAbc9Sim ( Abc_Frame_t * pAbc, int argc, char ** argv ); +static int Abc_CommandAbc9Sim2 ( Abc_Frame_t * pAbc, int argc, char ** argv ); static int Abc_CommandAbc9Sim3 ( Abc_Frame_t * pAbc, int argc, char ** argv ); static int Abc_CommandAbc9MLGen ( Abc_Frame_t * pAbc, int argc, char ** argv ); static int Abc_CommandAbc9MLTest ( Abc_Frame_t * pAbc, int argc, char ** argv ); @@ -1149,6 +1150,7 @@ void Abc_Init( Abc_Frame_t * pAbc ) Cmd_CommandAdd( pAbc, "ABC9", "&trim", Abc_CommandAbc9Trim, 0 ); Cmd_CommandAdd( pAbc, "ABC9", "&dfs", Abc_CommandAbc9Dfs, 0 ); Cmd_CommandAdd( pAbc, "ABC9", "&sim", Abc_CommandAbc9Sim, 0 ); + Cmd_CommandAdd( pAbc, "ABC9", "&sim2", Abc_CommandAbc9Sim2, 0 ); Cmd_CommandAdd( pAbc, "ABC9", "&sim3", Abc_CommandAbc9Sim3, 0 ); Cmd_CommandAdd( pAbc, "ABC9", "&mlgen", Abc_CommandAbc9MLGen, 0 ); Cmd_CommandAdd( pAbc, "ABC9", "&mltest", Abc_CommandAbc9MLTest, 0 ); @@ -32869,6 +32871,184 @@ usage: return 1; } +/**Function************************************************************* + + Synopsis [] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +int Abc_CommandAbc9Sim2( Abc_Frame_t * pAbc, int argc, char ** argv ) +{ + extern int Gia_ManSimTwo( Gia_Man_t * p0, Gia_Man_t * p1, int nWords, int nRounds, int fVerbose ); + Gia_Man_t * pGias[2]; FILE * pFile; + char ** pArgvNew; int nArgcNew; + int c, RetValue = 0, fVerbose = 0, nWords = 16, nRounds = 10, RandSeed = 1, TimeLimit = 0; + Extra_UtilGetoptReset(); + while ( ( c = Extra_UtilGetopt( argc, argv, "WRNTvh" ) ) != EOF ) + { + switch ( c ) + { + case 'W': + if ( globalUtilOptind >= argc ) + { + Abc_Print( -1, "Command line switch \"-W\" should be followed by an integer.\n" ); + goto usage; + } + nWords = atoi(argv[globalUtilOptind]); + globalUtilOptind++; + if ( nWords < 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; + } + nRounds = atoi(argv[globalUtilOptind]); + globalUtilOptind++; + if ( nRounds < 0 ) + goto usage; + break; + case 'N': + if ( globalUtilOptind >= argc ) + { + Abc_Print( -1, "Command line switch \"-N\" should be followed by an integer.\n" ); + goto usage; + } + RandSeed = atoi(argv[globalUtilOptind]); + globalUtilOptind++; + if ( RandSeed < 0 ) + goto usage; + break; + case 'T': + if ( globalUtilOptind >= argc ) + { + Abc_Print( -1, "Command line switch \"-T\" should be followed by an integer.\n" ); + goto usage; + } + TimeLimit = atoi(argv[globalUtilOptind]); + globalUtilOptind++; + if ( TimeLimit < 0 ) + goto usage; + break; + case 'v': + fVerbose ^= 1; + break; + case 'h': + goto usage; + default: + goto usage; + } + } + pArgvNew = argv + globalUtilOptind; + nArgcNew = argc - globalUtilOptind; + if ( nArgcNew > 2 ) + { + Abc_Print( -1, "Abc_CommandAbc9Cec(): Wrong number of command-line arguments.\n" ); + return 1; + } + if ( nArgcNew == 2 ) + { + char * pFileNames[2] = { pArgvNew[0], pArgvNew[1] }, * pTemp; + int n; + for ( n = 0; n < 2; n++ ) + { + // fix the wrong symbol + for ( pTemp = pFileNames[n]; *pTemp; pTemp++ ) + if ( *pTemp == '>' ) + *pTemp = '\\'; + if ( (pFile = fopen( pFileNames[n], "r" )) == NULL ) + { + Abc_Print( -1, "Cannot open input file \"%s\". ", pFileNames[n] ); + if ( (pFileNames[n] = Extra_FileGetSimilarName( pFileNames[n], ".aig", NULL, NULL, NULL, NULL )) ) + Abc_Print( 1, "Did you mean \"%s\"?", pFileNames[n] ); + Abc_Print( 1, "\n" ); + return 1; + } + fclose( pFile ); + pGias[n] = Gia_AigerRead( pFileNames[n], 0, 0, 0 ); + if ( pGias[n] == NULL ) + { + Abc_Print( -1, "Reading AIGER from file \"%s\" has failed.\n", pFileNames[n] ); + return 0; + } + } + } + else + { + char * FileName, * pTemp; + if ( pAbc->pGia == NULL ) + { + Abc_Print( -1, "Abc_CommandAbc9Cec(): There is no current AIG.\n" ); + return 1; + } + pGias[0] = pAbc->pGia; + if ( nArgcNew == 1 ) + FileName = pArgvNew[0]; + else + { + assert( nArgcNew == 0 ); + if ( pAbc->pGia->pSpec == NULL ) + { + Abc_Print( -1, "File name is not given on the command line.\n" ); + return 1; + } + FileName = pAbc->pGia->pSpec; + } + // fix the wrong symbol + for ( pTemp = FileName; *pTemp; pTemp++ ) + if ( *pTemp == '>' ) + *pTemp = '\\'; + if ( (pFile = fopen( FileName, "r" )) == NULL ) + { + Abc_Print( -1, "Cannot open input file \"%s\". ", FileName ); + if ( (FileName = Extra_FileGetSimilarName( FileName, ".aig", NULL, NULL, NULL, NULL )) ) + Abc_Print( 1, "Did you mean \"%s\"?", FileName ); + Abc_Print( 1, "\n" ); + return 1; + } + fclose( pFile ); + pGias[1] = Gia_AigerRead( FileName, 0, 0, 0 ); + if ( pGias[1] == NULL ) + { + Abc_Print( -1, "Reading AIGER has failed.\n" ); + return 0; + } + } + if ( Gia_ManCiNum(pGias[0]) != Gia_ManCiNum(pGias[1]) ) + { + Abc_Print( -1, "The number of CIs does not match.\n" ); + return 1; + } + if ( Gia_ManCoNum(pGias[0]) != Gia_ManCoNum(pGias[1]) ) + { + Abc_Print( -1, "The number of COs does not match.\n" ); + return 1; + } + RetValue = Gia_ManSimTwo( pGias[0], pGias[1], nWords, nRounds, fVerbose ); + if ( pGias[0] != pAbc->pGia ) + Gia_ManStopP( &pGias[0] ); + Gia_ManStopP( &pGias[1] ); + return 0; + +usage: + Abc_Print( -2, "usage: &sim2 [-WRNT num] [-vh] \n" ); + Abc_Print( -2, "\t performs random of two circuits\n" ); + Abc_Print( -2, "\t-W num : the number of words to simulate [default = %d]\n", nWords ); + Abc_Print( -2, "\t-R num : the number of simulation rounds [default = %d]\n", nRounds ); + Abc_Print( -2, "\t-N num : random number seed (1 <= num <= 1000) [default = %d]\n", RandSeed ); + Abc_Print( -2, "\t-T num : approximate runtime limit in seconds [default = %d]\n", TimeLimit ); + 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/wlc/wlc.c b/src/base/wlc/wlc.c index 03c3f54c..261ec96b 100644 --- a/src/base/wlc/wlc.c +++ b/src/base/wlc/wlc.c @@ -397,107 +397,314 @@ Gia_Man_t * Wlc_ManGenAdder( int nBits ) SeeAlso [] ***********************************************************************/ +void Wlc_BuildOne32( Gia_Man_t * p, int * pLitIn, int * pLitOut ) +{ + Wlc_BlastFullAdder( p, pLitIn[0], pLitIn[1], pLitIn[2], &pLitIn[5], &pLitOut[0] ); + Wlc_BlastFullAdder( p, pLitIn[3], pLitIn[4], pLitIn[5], &pLitOut[2], &pLitOut[1] ); +} +void Wlc_BuildOne51( Gia_Man_t * p, int * pLitIn, int * pLitOut ) +{ + int Lit00, Lit01, Lit11; + Wlc_BlastFullAdder( p, pLitIn[0], pLitIn[1], pLitIn[2], &Lit01, &Lit00 ); + Wlc_BlastFullAdder( p, pLitIn[3], pLitIn[4], Lit00, &Lit11, &pLitOut[0] ); + Wlc_BlastFullAdder( p, pLitIn[5], Lit01, Lit11, &pLitOut[2], &pLitOut[1] ); +} +void Wlc_BuildOne6( Gia_Man_t * p, int * pLitIn, int Const1, int * pLitOut ) +{ + int Lit00, Lit01, Lit10, Lit11, Lit12; + Wlc_BlastFullAdder( p, pLitIn[0], pLitIn[1], pLitIn[2], &Lit01, &Lit00 ); + Wlc_BlastFullAdder( p, pLitIn[3], pLitIn[4], pLitIn[5], &Lit11, &Lit10 ); + Wlc_BlastFullAdder( p, Lit00, Lit10, Const1, &Lit12, &pLitOut[0] ); + Wlc_BlastFullAdder( p, Lit01, Lit11, Lit12, &pLitOut[2],&pLitOut[1] ); +} Vec_Wec_t * Wlc_ManGenTree_iter( Gia_Man_t * p, Vec_Wec_t * vBits, int * pCounter ) { - Vec_Wec_t * vBitsNew = Vec_WecStart( Vec_WecSize(vBits) ); int i, k, Count = 0; + Vec_Wec_t * vBitsNew = Vec_WecStart( Vec_WecSize(vBits) ); + int i, k, pLitsIn[16], pLitsOut[16], Count = 0, fSimple = Vec_WecMaxLevelSize(vBits) <= 3; for ( i = 0; i < Vec_WecSize(vBits)-1; i++ ) { Vec_Int_t * vBits0 = Vec_WecEntry(vBits, i); Vec_Int_t * vBits1 = Vec_WecEntry(vBits, i+1); - if ( i == 0 ) + if ( fSimple ) { - int s = 0; + assert( Vec_IntSize(vBits0) <= 3 ); + for ( k = 0; Vec_IntSize(vBits0) > 0; k++ ) + pLitsIn[k] = Vec_IntPop( vBits0 ); + for ( ; k < 3; k++ ) + pLitsIn[k] = 0; + assert( k == 3 ); + Wlc_BlastFullAdder( p, pLitsIn[0], pLitsIn[1], pLitsIn[2], &pLitsOut[1], &pLitsOut[0] ); + Vec_WecPush( vBitsNew, i+0, pLitsOut[0] ); + Vec_WecPush( vBitsNew, i+1, pLitsOut[1] ); + Count += 2; + continue; } while ( Vec_IntSize(vBits0) >= 6 ) { for ( k = 0; k < 6; k++ ) - Vec_IntPop( vBits0 ); - Vec_WecPush( vBitsNew, i+0, 0 ); - Vec_WecPush( vBitsNew, i+1, 0 ); - Vec_WecPush( vBitsNew, i+2, 0 ); + pLitsIn[k] = Vec_IntPop( vBits0 ); + assert( k == 6 ); + Wlc_BuildOne6( p, pLitsIn, 0, pLitsOut ); + Vec_WecPush( vBitsNew, i+0, pLitsOut[0] ); + Vec_WecPush( vBitsNew, i+1, pLitsOut[1] ); + Vec_WecPush( vBitsNew, i+2, pLitsOut[2] ); Count += 3; } - if ( Vec_IntSize(vBits0) == 4 || Vec_IntSize(vBits0) == 5 ) + if ( Vec_IntSize(vBits0) == 5 && Vec_IntSize(vBits1) > 0 ) { - Vec_IntClear( vBits0 ); - if ( Vec_IntSize(vBits1) > 0 ) - Vec_IntPop( vBits1 ); - Vec_WecPush( vBitsNew, i+0, 0 ); - Vec_WecPush( vBitsNew, i+1, 0 ); - Vec_WecPush( vBitsNew, i+2, 0 ); + for ( k = 0; Vec_IntSize(vBits0) > 0; k++ ) + pLitsIn[k] = Vec_IntPop( vBits0 ); + pLitsIn[k++] = Vec_IntPop( vBits1 ); + assert( k == 6 ); + Wlc_BuildOne51( p, pLitsIn, pLitsOut ); + Vec_WecPush( vBitsNew, i+0, pLitsOut[0] ); + Vec_WecPush( vBitsNew, i+1, pLitsOut[1] ); + Vec_WecPush( vBitsNew, i+2, pLitsOut[2] ); Count += 3; } - //if ( (Vec_IntSize(vBits0) == 2 && Vec_IntSize(vBits1) > 1) || (Vec_IntSize(vBits0) == 3 && Vec_IntSize(vBits1) > 0) ) - if ( Vec_IntSize(vBits0) == 3 && Vec_IntSize(vBits1) > 0 ) + if ( Vec_IntSize(vBits0) == 5 && Vec_IntSize(vBits1) == 0 ) { - Vec_IntClear( vBits0 ); - Vec_IntPop( vBits1 ); - if ( Vec_IntSize(vBits1) > 0 ) - Vec_IntPop( vBits1 ); - if ( Vec_IntSize(vBits1) > 0 ) - Vec_IntPop( vBits1 ); - Vec_WecPush( vBitsNew, i+0, 0 ); - Vec_WecPush( vBitsNew, i+1, 0 ); - Vec_WecPush( vBitsNew, i+2, 0 ); + for ( k = 0; Vec_IntSize(vBits0) > 0; k++ ) + pLitsIn[k] = Vec_IntPop( vBits0 ); + pLitsIn[k++] = 0; + assert( k == 6 ); + Wlc_BuildOne6( p, pLitsIn, 0, pLitsOut ); + Vec_WecPush( vBitsNew, i+0, pLitsOut[0] ); + Vec_WecPush( vBitsNew, i+1, pLitsOut[1] ); + Vec_WecPush( vBitsNew, i+2, pLitsOut[2] ); Count += 3; } - if ( Vec_IntSize(vBits0) == 3 && Vec_IntSize(vBits1) == 0 ) + if ( Vec_IntSize(vBits0) == 4 && Vec_IntSize(vBits1) > 0 ) { - Vec_IntClear( vBits0 ); - Vec_WecPush( vBitsNew, i+0, 0 ); - Vec_WecPush( vBitsNew, i+1, 0 ); + for ( k = 0; Vec_IntSize(vBits0) > 0; k++ ) + pLitsIn[k] = Vec_IntPop( vBits0 ); + pLitsIn[k++] = 0; + pLitsIn[k++] = Vec_IntPop( vBits1 ); + assert( k == 6 ); + Wlc_BuildOne51( p, pLitsIn, pLitsOut ); + Vec_WecPush( vBitsNew, i+0, pLitsOut[0] ); + Vec_WecPush( vBitsNew, i+1, pLitsOut[1] ); + Vec_WecPush( vBitsNew, i+2, pLitsOut[2] ); + Count += 3; + } + if ( Vec_IntSize(vBits0) == 3 && Vec_IntSize(vBits1) >= 2 ) + { + for ( k = 0; Vec_IntSize(vBits0) > 0; k++ ) + pLitsIn[k] = Vec_IntPop( vBits0 ); + pLitsIn[k++] = Vec_IntPop( vBits1 ); + pLitsIn[k++] = Vec_IntPop( vBits1 ); + assert( k == 5 ); + Wlc_BuildOne32( p, pLitsIn, pLitsOut ); + Vec_WecPush( vBitsNew, i+0, pLitsOut[0] ); + Vec_WecPush( vBitsNew, i+1, pLitsOut[1] ); + Vec_WecPush( vBitsNew, i+2, pLitsOut[2] ); + Count += 3; + } + if ( Vec_IntSize(vBits0) >= 3 ) + { + for ( k = 0; k < 3; k++ ) + pLitsIn[k] = Vec_IntPop( vBits0 ); + assert( k == 3 ); + Wlc_BlastFullAdder( p, pLitsIn[0], pLitsIn[1], pLitsIn[2], &pLitsOut[1], &pLitsOut[0] ); + Vec_WecPush( vBitsNew, i+0, pLitsOut[0] ); + Vec_WecPush( vBitsNew, i+1, pLitsOut[1] ); Count += 2; } /* - if ( Vec_IntSize(vBits0) == 1 && Vec_IntSize(vBits1) > 2 ) + if ( Vec_IntSize(vBits0) == 2 ) { Vec_IntClear( vBits0 ); - Vec_IntPop( vBits1 ); - Vec_IntPop( vBits1 ); - Vec_IntPop( vBits1 ); Vec_WecPush( vBitsNew, i+0, 0 ); Vec_WecPush( vBitsNew, i+1, 0 ); - Vec_WecPush( vBitsNew, i+2, 0 ); + Count += 2; } */ - for ( k = 0; k < Vec_IntSize(vBits0); k++ ) - Vec_WecPush( vBitsNew, i, 0 ); - Vec_IntClear( vBits0 ); + for ( k = 0; Vec_IntSize(vBits0) > 0; k++ ) + Vec_WecPush( vBitsNew, i, Vec_IntPop(vBits0) ); } if ( pCounter ) - *pCounter += Count; + *pCounter = Count; return vBitsNew; } -Gia_Man_t * Wlc_ManGenTree( int nBits ) +void Wlc_ManGenTreeOne( Gia_Man_t * pNew, Vec_Wec_t * vBits0, int fMult, int fVerbose ) { - Gia_Man_t * pTemp, * pNew; int i, iLit, Counter = 0; - Vec_Int_t * vOuts = Vec_IntAlloc( 1000 ), * vLits = Vec_IntAlloc( 1000 ); - Vec_Wec_t * vTemp, * vBits = Vec_WecStart( 14 ); // Abc_Base2Log(nBits)+3 ); - pNew = Gia_ManStart( 1000 ); - pNew->pName = Abc_UtilStrsav( "tree" ); - for ( i = 0; i < nBits; i++ ) -// Vec_WecPush( vBits, 0, Gia_ManAppendCi(pNew) ); - Vec_WecPush( vBits, 0, 0 ); - Vec_WecPrint( vBits, 0 ); - Gia_ManHashAlloc( pNew ); - for ( i = 0; i < 10; i++ ) + extern int Wlc_BlastAdder( Gia_Man_t * pNew, int * pAdd0, int * pAdd1, int nBits, int Carry ); // result is in pAdd0 + + Vec_Wec_t * vTemp, * vBits = Vec_WecDup( vBits0 ); + Vec_Int_t * vOuts = Vec_IntAlloc( 1000 ), * vOuts2; + Vec_Int_t * vLits0 = Vec_IntAlloc( 1000 ); + Vec_Int_t * vLits1 = Vec_IntAlloc( 1000 ); + int i, iLit, nBitsAll = 0, CounterAll = 0, Counter = 1; + for ( i = 0; Counter && i < 1000; i++ ) { + if ( fVerbose ) printf( "LEVEL %d\n", i ); + if ( fVerbose ) Vec_WecPrint( vBits, 0 ); + if ( Vec_WecMaxLevelSize(vBits) <= 2 ) + break; vBits = Wlc_ManGenTree_iter( pNew, vTemp = vBits, &Counter ); Vec_WecFree( vTemp ); - printf( "LEVEL %d\n", i+1 ); - Vec_WecPrint( vBits, 0 ); + CounterAll += Counter; + } + printf( "Total count = %d.\n", CounterAll ); + if ( !fMult ) + { + int Carry; +/* + Vec_WecForEachLevel( vBits, vOuts2, i ) + { + if ( i == 10 ) + break; + if ( i == 0 ) + { + assert( Vec_IntSize(vOuts2) == 1 ); + Vec_IntPush( vOuts, Vec_IntPop(vOuts2) ); + continue; + } + assert( Vec_IntSize(vOuts2) == 1 || Vec_IntSize(vOuts2) == 2 ); + Vec_IntPush( vLits0, Vec_IntPop(vOuts2) ); + if ( Vec_IntSize(vOuts2) == 1 ) + Vec_IntPush( vLits1, Vec_IntPop(vOuts2) ); + else + { + Vec_IntPush( vLits1, 0 ); + } + } + assert( Vec_IntSize(vLits0) == 9 ); + assert( Vec_IntSize(vLits1) == 9 ); +*/ + Vec_WecForEachLevel( vBits, vOuts2, i ) + { + if ( Vec_IntSize(vOuts2) == 0 ) + break; + assert( Vec_IntSize(vOuts2) == 1 || Vec_IntSize(vOuts2) == 2 ); + Vec_IntPush( vLits0, Vec_IntPop(vOuts2) ); + if ( Vec_IntSize(vOuts2) == 1 ) + Vec_IntPush( vLits1, Vec_IntPop(vOuts2) ); + else + Vec_IntPush( vLits1, 0 ); + } + printf( "The adder size is %d.\n", Vec_IntSize(vLits0) ); + Vec_IntShrink( vLits0, 11 ); + Vec_IntShrink( vLits1, 11 ); + +// vOuts2 = Wlc_ManGenAdder_rec( pNew, 9, Vec_IntArray(vLits0), Vec_IntArray(vLits1), 0, 3 ); +// Vec_IntAppend( vOuts, vOuts2 ); +// Vec_IntFree( vOuts2 ); + + Carry = Wlc_BlastAdder( pNew, Vec_IntArray(vLits0), Vec_IntArray(vLits1), 11, 0 ); + Vec_IntAppend( vOuts, vLits0 ); + Vec_IntPush( vOuts, Carry ); + + + Gia_ManAppendCo( pNew, Vec_IntEntry(vOuts, 11) ); + } + else + { + Vec_WecForEachLevel( vBits, vOuts2, i ) + { + if ( Vec_IntSize(vOuts2) == 0 ) + break; + assert( Vec_IntSize(vOuts2) == 1 || Vec_IntSize(vOuts2) == 2 ); + Vec_IntPush( vLits0, Vec_IntPop(vOuts2) ); + if ( Vec_IntSize(vOuts2) == 1 ) + Vec_IntPush( vLits1, Vec_IntPop(vOuts2) ); + else + Vec_IntPush( vLits1, 0 ); + } + printf( "The adder size is %d.\n", Vec_IntSize(vLits0) ); + Vec_IntShrink( vLits0, Gia_ManCiNum(pNew)+1 ); // mult + Vec_IntShrink( vLits1, Gia_ManCiNum(pNew)+1 ); // mult + + for ( nBitsAll = 3; nBitsAll < Vec_IntSize(vLits0); nBitsAll *= 3 ) + ; + for ( i = Vec_IntSize(vLits0); i < nBitsAll; i++ ) + { + Vec_IntPush( vLits0, 0 ); + Vec_IntPush( vLits1, 0 ); + } + assert( Vec_IntSize(vLits0) == nBitsAll ); + assert( Vec_IntSize(vLits1) == nBitsAll ); + + vOuts2 = Wlc_ManGenAdder_rec( pNew, nBitsAll, Vec_IntArray(vLits0), Vec_IntArray(vLits1), 0, 3 ); + Vec_IntAppend( vOuts, vOuts2 ); + Vec_IntFree( vOuts2 ); + //Carry = Wlc_BlastAdder( pNew, Vec_IntArray(vLits0), Vec_IntArray(vLits1), nBitsAll, 0 ); + //Vec_IntAppend( vOuts, vLits0 ); + //Vec_IntPush( vOuts, Carry ); + + Vec_IntShrink( vOuts, Gia_ManCiNum(pNew) ); // mult + //Vec_IntShrink( vOuts, Gia_ManCiNum(pNew)/2 ); + + Vec_IntForEachEntry( vOuts, iLit, i ) + Gia_ManAppendCo( pNew, iLit ); } - printf( "Counter = %d.\n", Counter ); + + Vec_IntFree( vOuts ); + Vec_IntFree( vLits0 ); + Vec_IntFree( vLits1 ); + Vec_WecFree( vBits ); +} +Gia_Man_t * Wlc_ManGenTree( int nInputs, int Value, int nBits, int fVerbose ) +{ + Gia_Man_t * pTemp, * pNew; int i, Counter = 0; + Vec_Wec_t * vBits = Vec_WecStart( nBits+2 ); + for ( i = 0; i < nBits+2; i++ ) + Vec_WecPush( vBits, i, (Value >> i) & 1 ); + pNew = Gia_ManStart( 1000 ); + pNew->pName = Abc_UtilStrsav( "tree" ); + for ( i = 0; i < nInputs; i++ ) + Vec_WecPush( vBits, 0, Gia_ManAppendCi(pNew) ); + Gia_ManHashAlloc( pNew ); + Wlc_ManGenTreeOne( pNew, vBits, 0, fVerbose ); Gia_ManHashStop( pNew ); - Vec_IntForEachEntry( vOuts, iLit, i ) - Gia_ManAppendCo( pNew, iLit ); - Vec_IntFree( vLits ); Vec_WecFree( vBits ); pNew = Gia_ManCleanup( pTemp = pNew ); Gia_ManStop( pTemp ); return pNew; } + +/**Function************************************************************* + + Synopsis [] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +Gia_Man_t * Wlc_ManGenProd( int nInputs, int fVerbose ) +{ + extern void Wlc_BlastBooth( Gia_Man_t * pNew, int * pArgA, int * pArgB, int nArgA, int nArgB, Vec_Int_t * vRes, int fSigned, int fCla, Vec_Wec_t ** pvProds ); + extern void Wlc_BlastMultiplier3( Gia_Man_t * pNew, int * pArgA, int * pArgB, int nArgA, int nArgB, Vec_Int_t * vRes, int fSigned, int fCla, Vec_Wec_t ** pvProds ); + Vec_Int_t * vIns = Vec_IntAlloc( 2*nInputs ); + Gia_Man_t * pTemp, * pNew; + Vec_Wec_t * vProds; int i; + pNew = Gia_ManStart( 1000 ); + pNew->pName = Abc_UtilStrsav( "tree" ); + + for ( i = 0; i < 2*nInputs; i++ ) + Vec_IntPush( vIns, Gia_ManAppendCi(pNew) ); + //for ( i = 0; i < nInputs; i++ ) + // Vec_IntPush( vIns, Gia_ManAppendCi(pNew) ); + //for ( i = 0; i < nInputs; i++ ) + // Vec_IntPush( vIns, Vec_IntEntry(vIns, i) ); + + Gia_ManHashAlloc( pNew ); + Wlc_BlastBooth( pNew, Vec_IntArray(vIns), Vec_IntArray(vIns)+nInputs, nInputs, nInputs, NULL, 0, 0, &vProds ); + //Wlc_BlastMultiplier3( pNew, Vec_IntArray(vIns), Vec_IntArray(vIns)+nInputs, nInputs, nInputs, NULL, 0, 0, &vProds ); + //Vec_WecPrint( vProds, 0 ); + Wlc_ManGenTreeOne( pNew, vProds, 1, fVerbose ); + Gia_ManHashStop( pNew ); + Vec_WecFree( vProds ); + Vec_IntFree( vIns ); + pNew = Gia_ManCleanup( pTemp = pNew ); + Gia_ManStop( pTemp ); + return pNew; +} + //////////////////////////////////////////////////////////////////////// /// END OF FILE /// //////////////////////////////////////////////////////////////////////// diff --git a/src/base/wlc/wlcBlast.c b/src/base/wlc/wlcBlast.c index 8ff8d287..4ec8d7ff 100644 --- a/src/base/wlc/wlcBlast.c +++ b/src/base/wlc/wlcBlast.c @@ -345,11 +345,12 @@ void Wlc_BlastFullAdder( Gia_Man_t * pNew, int a, int b, int c, int * pc, int * if ( fCompl ) *ps = Abc_LitNot(*ps), *pc = Abc_LitNot(*pc); } -void Wlc_BlastAdder( Gia_Man_t * pNew, int * pAdd0, int * pAdd1, int nBits, int Carry ) // result is in pAdd0 +int Wlc_BlastAdder( Gia_Man_t * pNew, int * pAdd0, int * pAdd1, int nBits, int Carry ) // result is in pAdd0 { int b; for ( b = 0; b < nBits; b++ ) Wlc_BlastFullAdder( pNew, pAdd0[b], pAdd1[b], Carry, &Carry, &pAdd0[b] ); + return Carry; } void Wlc_BlastSubtract( Gia_Man_t * pNew, int * pAdd0, int * pAdd1, int nBits, int Carry ) // result is in pAdd0 { @@ -1022,7 +1023,7 @@ void Wlc_BlastReduceMatrix2( Gia_Man_t * pNew, Vec_Wec_t * vProds, Vec_Int_t * v } -void Wlc_BlastMultiplier3( Gia_Man_t * pNew, int * pArgA, int * pArgB, int nArgA, int nArgB, Vec_Int_t * vRes, int fSigned, int fCla ) +void Wlc_BlastMultiplier3( Gia_Man_t * pNew, int * pArgA, int * pArgB, int nArgA, int nArgB, Vec_Int_t * vRes, int fSigned, int fCla, Vec_Wec_t ** pvProds ) { Vec_Wec_t * vProds = Vec_WecStart( nArgA + nArgB ); Vec_Wec_t * vLevels = Vec_WecStart( nArgA + nArgB ); @@ -1043,7 +1044,10 @@ void Wlc_BlastMultiplier3( Gia_Man_t * pNew, int * pArgA, int * pArgB, int nArgA Vec_WecPush( vLevels, nArgA+nArgB-1, 0 ); } - Wlc_BlastReduceMatrix( pNew, vProds, vLevels, vRes, fSigned, fCla ); + if ( pvProds ) + *pvProds = Vec_WecDup(vProds); + else + Wlc_BlastReduceMatrix( pNew, vProds, vLevels, vRes, fSigned, fCla ); // Wlc_BlastReduceMatrix2( pNew, vProds, vRes, fSigned, fCla ); Vec_WecFree( vProds ); @@ -1086,7 +1090,7 @@ void Wlc_BlastDecoder( Gia_Man_t * pNew, int * pNum, int nNum, Vec_Int_t * vTmp, Vec_IntPush( vRes, iMint ); } } -void Wlc_BlastBooth( Gia_Man_t * pNew, int * pArgA, int * pArgB, int nArgA, int nArgB, Vec_Int_t * vRes, int fSigned, int fCla ) +void Wlc_BlastBooth( Gia_Man_t * pNew, int * pArgA, int * pArgB, int nArgA, int nArgB, Vec_Int_t * vRes, int fSigned, int fCla, Vec_Wec_t ** pvProds ) { Vec_Wec_t * vProds = Vec_WecStart( nArgA + nArgB + 3 ); Vec_Wec_t * vLevels = Vec_WecStart( nArgA + nArgB + 3 ); @@ -1159,9 +1163,11 @@ void Wlc_BlastBooth( Gia_Man_t * pNew, int * pArgA, int * pArgB, int nArgA, int //Vec_WecPrint( vProds, 0 ); //Wlc_BlastPrintMatrix( pNew, vProds, 1 ); //printf( "Cutoff ID for partial products = %d.\n", Gia_ManObjNum(pNew) ); - Wlc_BlastReduceMatrix( pNew, vProds, vLevels, vRes, fSigned, fCla ); -// Wlc_BlastReduceMatrix2( pNew, vProds, vRes, fSigned, fCla ); - + if ( pvProds ) + *pvProds = Vec_WecDup(vProds); + else + Wlc_BlastReduceMatrix( pNew, vProds, vLevels, vRes, fSigned, fCla ); + // Wlc_BlastReduceMatrix2( pNew, vProds, vRes, fSigned, fCla ); Vec_WecFree( vProds ); Vec_WecFree( vLevels ); Vec_IntFree( vArgB ); @@ -1792,9 +1798,9 @@ Gia_Man_t * Wlc_NtkBitBlast( Wlc_Ntk_t * p, Wlc_BstPar_t * pParIn ) if ( Wlc_NtkCountConstBits(pArg0, nRangeMax) < Wlc_NtkCountConstBits(pArg1, nRangeMax) ) ABC_SWAP( int *, pArg0, pArg1 ); if ( pPar->fBooth ) - Wlc_BlastBooth( pNew, pArg0, pArg1, nRange0, nRange1, vRes, fSigned, pPar->fCla ); + Wlc_BlastBooth( pNew, pArg0, pArg1, nRange0, nRange1, vRes, fSigned, pPar->fCla, NULL ); else if ( pPar->fCla ) - Wlc_BlastMultiplier3( pNew, pArg0, pArg1, nRange0, nRange1, vRes, Wlc_ObjIsSignedFanin01(p, pObj), pPar->fCla ); + Wlc_BlastMultiplier3( pNew, pArg0, pArg1, nRange0, nRange1, vRes, Wlc_ObjIsSignedFanin01(p, pObj), pPar->fCla, NULL ); else Wlc_BlastMultiplier( pNew, pArg0, pArg1, nRangeMax, nRangeMax, vTemp2, vRes, fSigned ); if ( nRange > Vec_IntSize(vRes) ) -- cgit v1.2.3 From d925e4802cdbd89b1c7cee4fa1041b08cf0d32f7 Mon Sep 17 00:00:00 2001 From: Alan Mishchenko Date: Sat, 31 Jul 2021 11:30:19 -0700 Subject: Experiments with cofactoring. --- src/base/abci/abc.c | 29 +++++++++++++++++++++++------ 1 file changed, 23 insertions(+), 6 deletions(-) (limited to 'src/base') diff --git a/src/base/abci/abc.c b/src/base/abci/abc.c index 8668a1f2..83c98e10 100644 --- a/src/base/abci/abc.c +++ b/src/base/abci/abc.c @@ -32507,11 +32507,12 @@ usage: ***********************************************************************/ int Abc_CommandAbc9Cof( Abc_Frame_t * pAbc, int argc, char ** argv ) { + extern Gia_Man_t * Gia_ManComputeCofs( Gia_Man_t * p, int nVars ); Gia_Man_t * pTemp; int c, fVerbose = 0; - int iVar = 0, nLimFan = 0; + int iVar = 0, nLimFan = 0, nVars = 0; Extra_UtilGetoptReset(); - while ( ( c = Extra_UtilGetopt( argc, argv, "VLvh" ) ) != EOF ) + while ( ( c = Extra_UtilGetopt( argc, argv, "VLNvh" ) ) != EOF ) { switch ( c ) { @@ -32537,6 +32538,17 @@ int Abc_CommandAbc9Cof( Abc_Frame_t * pAbc, int argc, char ** argv ) if ( nLimFan < 0 ) goto usage; break; + case 'N': + if ( globalUtilOptind >= argc ) + { + Abc_Print( -1, "Command line switch \"-N\" should be followed by an integer.\n" ); + goto usage; + } + nVars = atoi(argv[globalUtilOptind]); + globalUtilOptind++; + if ( nVars < 0 ) + goto usage; + break; case 'v': fVerbose ^= 1; break; @@ -32551,7 +32563,13 @@ int Abc_CommandAbc9Cof( Abc_Frame_t * pAbc, int argc, char ** argv ) Abc_Print( -1, "Abc_CommandAbc9Cof(): There is no AIG.\n" ); return 1; } - if ( nLimFan ) + if ( nVars ) + { + Abc_Print( -1, "Cofactoring the last %d inputs.\n", nVars ); + pTemp = Gia_ManComputeCofs( pAbc->pGia, nVars ); + Abc_FrameUpdateGia( pAbc, pTemp ); + } + else if ( nLimFan ) { Abc_Print( -1, "Cofactoring all variables whose fanout count is higher than %d.\n", nLimFan ); pTemp = Gia_ManDupCofAll( pAbc->pGia, nLimFan, fVerbose ); @@ -32571,10 +32589,11 @@ int Abc_CommandAbc9Cof( Abc_Frame_t * pAbc, int argc, char ** argv ) return 0; usage: - Abc_Print( -2, "usage: &cof [-VL num] [-vh]\n" ); + Abc_Print( -2, "usage: &cof [-VLN num] [-vh]\n" ); Abc_Print( -2, "\t performs cofactoring w.r.t. variable(s)\n" ); Abc_Print( -2, "\t-V num : the zero-based ID of one variable to cofactor [default = %d]\n", iVar ); Abc_Print( -2, "\t-L num : cofactor vars with fanout count higher than this [default = %d]\n", nLimFan ); + Abc_Print( -2, "\t-N num : cofactoring the given number of last input variables [default = %d]\n", nVars ); 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; @@ -49263,8 +49282,6 @@ int Abc_CommandAbc9Test( Abc_Frame_t * pAbc, int argc, char ** argv ) } Abc_FrameUpdateGia( pAbc, Gia_ManPerformNewResub(pAbc->pGia, 100, 8, 1, 1) ); // printf( "AIG in \"%s\" has the sum of output support sizes equal to %d.\n", pAbc->pGia->pSpec, Gia_ManSumTotalOfSupportSizes(pAbc->pGia) ); - //Gia_ManExtractTest( pAbc->pGia ); - //Abc_Tt6MinTest2( pAbc->pGia ); return 0; usage: Abc_Print( -2, "usage: &test [-FW num] [-svh]\n" ); -- cgit v1.2.3 From 692dd763190d2e2682c0eeabdcd81f16aaaabe94 Mon Sep 17 00:00:00 2001 From: Alan Mishchenko Date: Sat, 31 Jul 2021 15:34:46 -0700 Subject: Upgrading choice computation. --- src/base/abci/abc.c | 16 ++++++++++------ src/base/abci/abcDar.c | 36 +++++++++++++++++++++--------------- 2 files changed, 31 insertions(+), 21 deletions(-) (limited to 'src/base') diff --git a/src/base/abci/abc.c b/src/base/abci/abc.c index 83c98e10..06a7c877 100644 --- a/src/base/abci/abc.c +++ b/src/base/abci/abc.c @@ -15125,7 +15125,7 @@ int Abc_CommandDch( Abc_Frame_t * pAbc, int argc, char ** argv ) // set defaults Dch_ManSetDefaultParams( pPars ); Extra_UtilGetoptReset(); - while ( ( c = Extra_UtilGetopt( argc, argv, "WCSsptgcfrvh" ) ) != EOF ) + while ( ( c = Extra_UtilGetopt( argc, argv, "WCSsptgcfrxvh" ) ) != EOF ) { switch ( c ) { @@ -15183,6 +15183,9 @@ int Abc_CommandDch( Abc_Frame_t * pAbc, int argc, char ** argv ) case 'r': pPars->fSkipRedSupp ^= 1; break; + case 'x': + pPars->fUseNew ^= 1; + break; case 'v': pPars->fVerbose ^= 1; break; @@ -15213,7 +15216,7 @@ int Abc_CommandDch( Abc_Frame_t * pAbc, int argc, char ** argv ) return 0; usage: - Abc_Print( -2, "usage: dch [-WCS num] [-sptgcfrvh]\n" ); + Abc_Print( -2, "usage: dch [-WCS num] [-sptgcfrxvh]\n" ); Abc_Print( -2, "\t computes structural choices using a new approach\n" ); Abc_Print( -2, "\t-W num : the max number of simulation words [default = %d]\n", pPars->nWords ); Abc_Print( -2, "\t-C num : the max number of conflicts at a node [default = %d]\n", pPars->nBTLimit ); @@ -15225,6 +15228,7 @@ usage: Abc_Print( -2, "\t-c : toggle using circuit-based SAT vs. MiniSat [default = %s]\n", pPars->fUseCSat? "yes": "no" ); Abc_Print( -2, "\t-f : toggle using faster logic synthesis [default = %s]\n", pPars->fLightSynth? "yes": "no" ); Abc_Print( -2, "\t-r : toggle skipping choices with redundant support [default = %s]\n", pPars->fSkipRedSupp? "yes": "no" ); + Abc_Print( -2, "\t-x : toggle using new choice computation [default = %s]\n", pPars->fUseNew? "yes": "no" ); Abc_Print( -2, "\t-v : toggle verbose printout [default = %s]\n", pPars->fVerbose? "yes": "no" ); Abc_Print( -2, "\t-h : print the command usage\n"); return 1; @@ -30654,7 +30658,7 @@ int Abc_CommandAbc9Put( Abc_Frame_t * pAbc, int argc, char ** argv ) else { Abc_Ntk_t * pNtkNoCh; -// Abc_Print( -1, "Transforming AIG with %d choice nodes.\n", Gia_ManEquivCountClasses(pAbc->pGia) ); + Abc_Print( -1, "Transforming AIG with %d choice nodes.\n", Gia_ManEquivCountClasses(pAbc->pGia) ); // create network without choices pMan = Gia_ManToAig( pAbc->pGia, 0 ); pNtkNoCh = Abc_NtkFromAigPhase( pMan ); @@ -32565,19 +32569,19 @@ int Abc_CommandAbc9Cof( Abc_Frame_t * pAbc, int argc, char ** argv ) } if ( nVars ) { - Abc_Print( -1, "Cofactoring the last %d inputs.\n", nVars ); + Abc_Print( 0, "Cofactoring the last %d inputs.\n", nVars ); pTemp = Gia_ManComputeCofs( pAbc->pGia, nVars ); Abc_FrameUpdateGia( pAbc, pTemp ); } else if ( nLimFan ) { - Abc_Print( -1, "Cofactoring all variables whose fanout count is higher than %d.\n", nLimFan ); + Abc_Print( 0, "Cofactoring all variables whose fanout count is higher than %d.\n", nLimFan ); pTemp = Gia_ManDupCofAll( pAbc->pGia, nLimFan, fVerbose ); Abc_FrameUpdateGia( pAbc, pTemp ); } else if ( iVar ) { - Abc_Print( -1, "Cofactoring one variable with object ID %d.\n", iVar ); + Abc_Print( 0, "Cofactoring one variable with object ID %d.\n", iVar ); pTemp = Gia_ManDupCof( pAbc->pGia, iVar ); Abc_FrameUpdateGia( pAbc, pTemp ); } diff --git a/src/base/abci/abcDar.c b/src/base/abci/abcDar.c index ae2d9835..95c9200d 100644 --- a/src/base/abci/abcDar.c +++ b/src/base/abci/abcDar.c @@ -1651,6 +1651,7 @@ Abc_Ntk_t * Abc_NtkDChoice( Abc_Ntk_t * pNtk, int fBalance, int fUpdateLevel, in ***********************************************************************/ Abc_Ntk_t * Abc_NtkDch( Abc_Ntk_t * pNtk, Dch_Pars_t * pPars ) { + extern Aig_Man_t * Dar_ManChoiceNew( Aig_Man_t * pAig, Dch_Pars_t * pPars ); extern Gia_Man_t * Dar_NewChoiceSynthesis( Aig_Man_t * pAig, int fBalance, int fUpdateLevel, int fPower, int fLightSynth, int fVerbose ); extern Aig_Man_t * Cec_ComputeChoices( Gia_Man_t * pGia, Dch_Pars_t * pPars ); @@ -1662,23 +1663,28 @@ Abc_Ntk_t * Abc_NtkDch( Abc_Ntk_t * pNtk, Dch_Pars_t * pPars ) pMan = Abc_NtkToDar( pNtk, 0, 0 ); if ( pMan == NULL ) return NULL; -clk = Abc_Clock(); - if ( pPars->fSynthesis ) - pGia = Dar_NewChoiceSynthesis( pMan, 1, 1, pPars->fPower, pPars->fLightSynth, pPars->fVerbose ); - else + if ( pPars->fUseNew ) + pMan = Dar_ManChoiceNew( pMan, pPars ); + else { - pGia = Gia_ManFromAig( pMan ); - Aig_ManStop( pMan ); - } +clk = Abc_Clock(); + if ( pPars->fSynthesis ) + pGia = Dar_NewChoiceSynthesis( pMan, 1, 1, pPars->fPower, pPars->fLightSynth, pPars->fVerbose ); + else + { + pGia = Gia_ManFromAig( pMan ); + Aig_ManStop( pMan ); + } pPars->timeSynth = Abc_Clock() - clk; - if ( pPars->fUseGia ) - pMan = Cec_ComputeChoices( pGia, pPars ); - else - { - pMan = Gia_ManToAigSkip( pGia, 3 ); - Gia_ManStop( pGia ); - pMan = Dch_ComputeChoices( pTemp = pMan, pPars ); - Aig_ManStop( pTemp ); + if ( pPars->fUseGia ) + pMan = Cec_ComputeChoices( pGia, pPars ); + else + { + pMan = Gia_ManToAigSkip( pGia, 3 ); + Gia_ManStop( pGia ); + pMan = Dch_ComputeChoices( pTemp = pMan, pPars ); + Aig_ManStop( pTemp ); + } } pNtkAig = Abc_NtkFromDarChoices( pNtk, pMan ); Aig_ManStop( pMan ); -- cgit v1.2.3 From e162a26197b194e6b9adfcf455edb4312285c644 Mon Sep 17 00:00:00 2001 From: Alan Mishchenko Date: Sat, 31 Jul 2021 22:46:47 -0700 Subject: Allow retiming to skip some logic. --- src/base/wlc/wlcCom.c | 15 ++++++++----- src/base/wln/wln.h | 2 +- src/base/wln/wlnNdr.c | 4 ++-- src/base/wln/wlnRetime.c | 57 +++++++++++++++++++++++++++++++++++++++++++++++- 4 files changed, 69 insertions(+), 9 deletions(-) (limited to 'src/base') diff --git a/src/base/wlc/wlcCom.c b/src/base/wlc/wlcCom.c index e6294f41..666a8776 100644 --- a/src/base/wlc/wlcCom.c +++ b/src/base/wlc/wlcCom.c @@ -1331,16 +1331,20 @@ usage: ******************************************************************************/ int Abc_CommandRetime( Abc_Frame_t * pAbc, int argc, char ** argv ) { - extern void Wln_NtkRetimeTest( char * pFileName, int fSkipSimple, int fDump, int fVerbose ); + extern void Wln_NtkRetimeTest( char * pFileName, int fIgnoreIO, int fSkipSimple, int fDump, int fVerbose ); FILE * pFile; char * pFileName = NULL; + int fIgnoreIO = 0; int fSkipSimple = 0; int c, fDump = 0, fVerbose = 0; Extra_UtilGetoptReset(); - while ( ( c = Extra_UtilGetopt( argc, argv, "sdvh" ) ) != EOF ) + while ( ( c = Extra_UtilGetopt( argc, argv, "isdvh" ) ) != EOF ) { switch ( c ) { + case 'i': + fIgnoreIO ^= 1; + break; case 's': fSkipSimple ^= 1; break; @@ -1366,7 +1370,7 @@ int Abc_CommandRetime( Abc_Frame_t * pAbc, int argc, char ** argv ) printf( "Transforming NDR into internal represnetation has failed.\n" ); return 0; } - vMoves = Wln_NtkRetime( pNtk, fSkipSimple, fVerbose ); + vMoves = Wln_NtkRetime( pNtk, fIgnoreIO, fSkipSimple, fVerbose ); Wln_NtkFree( pNtk ); ABC_FREE( pAbc->pNdrArray ); if ( vMoves ) pAbc->pNdrArray = Vec_IntReleaseNewArray( vMoves ); @@ -1389,11 +1393,12 @@ int Abc_CommandRetime( Abc_Frame_t * pAbc, int argc, char ** argv ) return 0; } fclose( pFile ); - Wln_NtkRetimeTest( pFileName, fSkipSimple, fDump, fVerbose ); + Wln_NtkRetimeTest( pFileName, fIgnoreIO, fSkipSimple, fDump, fVerbose ); return 0; usage: - Abc_Print( -2, "usage: %%retime [-sdvh]\n" ); + Abc_Print( -2, "usage: %%retime [-isdvh]\n" ); Abc_Print( -2, "\t performs retiming for the NDR design\n" ); + Abc_Print( -2, "\t-i : toggle ignoring delays of IO paths [default = %s]\n", fIgnoreIO? "yes": "no" ); Abc_Print( -2, "\t-s : toggle printing simple nodes [default = %s]\n", !fSkipSimple? "yes": "no" ); Abc_Print( -2, "\t-d : toggle dumping the network in Verilog [default = %s]\n", fDump? "yes": "no" ); Abc_Print( -2, "\t-v : toggle printing verbose information [default = %s]\n", fVerbose? "yes": "no" ); diff --git a/src/base/wln/wln.h b/src/base/wln/wln.h index 510d74c1..93a1a92a 100644 --- a/src/base/wln/wln.h +++ b/src/base/wln/wln.h @@ -246,7 +246,7 @@ extern int Wln_ObjClone( Wln_Ntk_t * pNew, Wln_Ntk_t * p, int iObj ); extern int Wln_ObjCreateCo( Wln_Ntk_t * p, int iFanin ); extern void Wln_ObjPrint( Wln_Ntk_t * p, int iObj ); /*=== wlcRetime.c ========================================================*/ -extern Vec_Int_t * Wln_NtkRetime( Wln_Ntk_t * p, int fSkipSimple, int fVerbose ); +extern Vec_Int_t * Wln_NtkRetime( Wln_Ntk_t * p, int fIgnoreIO, int fSkipSimple, int fVerbose ); extern void Wln_NtkRetimeCreateDelayInfo( Wln_Ntk_t * pNtk ); /*=== wlcWriteVer.c ========================================================*/ extern void Wln_WriteVer( Wln_Ntk_t * p, char * pFileName ); diff --git a/src/base/wln/wlnNdr.c b/src/base/wln/wlnNdr.c index eb685463..d16840c6 100644 --- a/src/base/wln/wlnNdr.c +++ b/src/base/wln/wlnNdr.c @@ -314,7 +314,7 @@ void Wln_ReadNdrTest() Wln_NtkStaticFanoutTest( pNtk ); Wln_NtkFree( pNtk ); } -void Wln_NtkRetimeTest( char * pFileName, int fSkipSimple, int fDump, int fVerbose ) +void Wln_NtkRetimeTest( char * pFileName, int fIgnoreIO, int fSkipSimple, int fDump, int fVerbose ) { Vec_Int_t * vMoves; void * pData = Ndr_Read( pFileName ); @@ -326,7 +326,7 @@ void Wln_NtkRetimeTest( char * pFileName, int fSkipSimple, int fDump, int fVerbo return; } Wln_NtkRetimeCreateDelayInfo( pNtk ); - vMoves = Wln_NtkRetime( pNtk, fSkipSimple, fVerbose ); + vMoves = Wln_NtkRetime( pNtk, fIgnoreIO, fSkipSimple, fVerbose ); //Vec_IntPrint( vMoves ); Vec_IntFree( vMoves ); Wln_NtkFree( pNtk ); diff --git a/src/base/wln/wlnRetime.c b/src/base/wln/wlnRetime.c index 734ac194..5ccc1dd0 100644 --- a/src/base/wln/wlnRetime.c +++ b/src/base/wln/wlnRetime.c @@ -333,6 +333,55 @@ void Wln_RetFindSources( Wln_Ret_t * p ) // Vec_IntPrint( &p->vSources ); } +/**Function************************************************************* + + Synopsis [Mark paths from PIs to POs.] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +int Wln_RetMarkPaths_rec( Wln_Ntk_t * p, int iObj, int fVerbose ) +{ + int k, iFanin, fPrev = 1; + if ( Wln_ObjIsTravIdPrevious(p, iObj) ) + return 1; + if ( Wln_ObjIsTravIdCurrent(p, iObj) ) + return 0; + if ( Wln_ObjIsCio(p, iObj) || Wln_ObjIsFf(p, iObj) ) + return 0; + Wln_ObjForEachFanin( p, iObj, iFanin, k ) + fPrev &= Wln_RetMarkPaths_rec( p, iFanin, fVerbose ); + if ( fPrev ) + { + Wln_ObjSetTravIdPrevious( p, iObj ); + if ( Vec_IntEntry(&p->vInstIds, iObj) > 0 ) + { + if ( fVerbose ) + printf( "Updating delay %5d -> %5d : ", Vec_IntEntry(&p->vInstIds, iObj), 1 ); + if ( fVerbose ) + Wln_ObjPrint( p, iObj ); + Vec_IntWriteEntry( &p->vInstIds, iObj, 1 ); + } + return 1; + } + Wln_ObjSetTravIdCurrent( p, iObj ); + return 0; +} +void Wln_RetMarkPaths( Wln_Ntk_t * p, int fVerbose ) +{ + int i, iObj; + Wln_NtkIncrementTravId( p ); + Wln_NtkIncrementTravId( p ); + Wln_NtkForEachPi( p, iObj, i ) + Wln_ObjSetTravIdPrevious( p, iObj ); + Wln_NtkForEachPo( p, iObj, i ) + Wln_RetMarkPaths_rec( p, Wln_ObjFanin0(p, iObj), fVerbose ); +} + /**Function************************************************************* Synopsis [Retimability check.] @@ -571,7 +620,7 @@ void Wln_NtkRetimeCreateDelayInfo( Wln_Ntk_t * pNtk ) printf( "Assuming default delays: 10 units for most nodes and 1 unit for bit-slice, concat, and buffers driving COs.\n" ); } } -Vec_Int_t * Wln_NtkRetime( Wln_Ntk_t * pNtk, int fSkipSimple, int fVerbose ) +Vec_Int_t * Wln_NtkRetime_int( Wln_Ntk_t * pNtk, int fSkipSimple, int fVerbose ) { Wln_Ret_t * p = Wln_RetAlloc( pNtk ); Vec_Int_t * vSources = &p->vSources; @@ -666,6 +715,12 @@ Vec_Int_t * Wln_NtkRetime( Wln_Ntk_t * pNtk, int fSkipSimple, int fVerbose ) } return vMoves; } +Vec_Int_t * Wln_NtkRetime( Wln_Ntk_t * pNtk, int fIgnoreIO, int fSkipSimple, int fVerbose ) +{ + if ( fIgnoreIO ) + Wln_RetMarkPaths( pNtk, fVerbose ); + return Wln_NtkRetime_int( pNtk, fSkipSimple, fVerbose ); +} //////////////////////////////////////////////////////////////////////// /// END OF FILE /// -- cgit v1.2.3 From 4cf906d2fc64f5f27fd1f01580b89a60c4ee7e61 Mon Sep 17 00:00:00 2001 From: Alan Mishchenko Date: Sun, 1 Aug 2021 12:13:27 -0700 Subject: Experiments with LUT mapping for small functions. --- src/base/abci/abc.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/base') diff --git a/src/base/abci/abc.c b/src/base/abci/abc.c index 06a7c877..8fd38473 100644 --- a/src/base/abci/abc.c +++ b/src/base/abci/abc.c @@ -41461,6 +41461,7 @@ usage: int Abc_CommandAbc9LNetOpt( Abc_Frame_t * pAbc, int argc, char ** argv ) { extern Gia_Man_t * Gia_ManPerformLNetOpt( Gia_Man_t * p, int fTryNew, char * pFileName, int nIns, int nOuts, int Thresh, int nRounds, int fVerbose ); + extern Gia_Man_t * Gia_ManPerformLNetOptNew( Gia_Man_t * p, char * pFileName, int nIns, int nOuts, int Thresh, int nRounds, int fVerbose ); Gia_Man_t * pTemp; char * pFileName = NULL; int c, fTryNew = 1, nIns = 6, nOuts = 2, Limit = 0, nRounds = 100, fVerbose = 0; @@ -41536,7 +41537,7 @@ int Abc_CommandAbc9LNetOpt( Abc_Frame_t * pAbc, int argc, char ** argv ) fclose( pFile ); pFileName = argv[globalUtilOptind]; } - pTemp = Gia_ManPerformLNetOpt( pAbc->pGia, fTryNew, pFileName, nIns, nOuts, Limit, nRounds, fVerbose ); + pTemp = Gia_ManPerformLNetOptNew( pAbc->pGia, pFileName, nIns, nOuts, Limit, nRounds, fVerbose ); Abc_FrameUpdateGia( pAbc, pTemp ); return 0; -- cgit v1.2.3 From 5f8d4e72d1d99539d100ca5c190c56c5901976e6 Mon Sep 17 00:00:00 2001 From: Alan Mishchenko Date: Mon, 2 Aug 2021 16:46:56 -0700 Subject: Experiments with LUT mapping for small functions. --- src/base/abci/abc.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) (limited to 'src/base') diff --git a/src/base/abci/abc.c b/src/base/abci/abc.c index 8fd38473..9ab01a90 100644 --- a/src/base/abci/abc.c +++ b/src/base/abci/abc.c @@ -41464,9 +41464,9 @@ int Abc_CommandAbc9LNetOpt( Abc_Frame_t * pAbc, int argc, char ** argv ) extern Gia_Man_t * Gia_ManPerformLNetOptNew( Gia_Man_t * p, char * pFileName, int nIns, int nOuts, int Thresh, int nRounds, int fVerbose ); Gia_Man_t * pTemp; char * pFileName = NULL; - int c, fTryNew = 1, nIns = 6, nOuts = 2, Limit = 0, nRounds = 100, fVerbose = 0; + int c, nIns = 6, nOuts = 2, Limit = 0, nRounds = 20, fVerbose = 0; Extra_UtilGetoptReset(); - while ( ( c = Extra_UtilGetopt( argc, argv, "IORXxvh" ) ) != EOF ) + while ( ( c = Extra_UtilGetopt( argc, argv, "IORXvh" ) ) != EOF ) { switch ( c ) { @@ -41506,9 +41506,6 @@ int Abc_CommandAbc9LNetOpt( Abc_Frame_t * pAbc, int argc, char ** argv ) nRounds = atoi(argv[globalUtilOptind]); globalUtilOptind++; break; - case 'x': - fTryNew ^= 1; - break; case 'v': fVerbose ^= 1; break; @@ -41542,13 +41539,12 @@ int Abc_CommandAbc9LNetOpt( Abc_Frame_t * pAbc, int argc, char ** argv ) return 0; usage: - Abc_Print( -2, "usage: &lnetopt [-IORX num] [-xvh] \n" ); + Abc_Print( -2, "usage: &lnetopt [-IORX num] [-vh] \n" ); Abc_Print( -2, "\t performs specialized AIG optimization\n" ); Abc_Print( -2, "\t-I num : the input support size [default = %d]\n", nIns ); Abc_Print( -2, "\t-O num : the output group size [default = %d]\n", nOuts ); Abc_Print( -2, "\t-R num : patterns are cares starting this value [default = %d]\n", Limit ); Abc_Print( -2, "\t-X num : the number of optimization rounds [default = %d]\n", nRounds ); - Abc_Print( -2, "\t-x : toggles using another computation [default = %s]\n", fTryNew? "yes": "no" ); Abc_Print( -2, "\t-v : toggles verbose output [default = %s]\n", fVerbose? "yes": "no" ); Abc_Print( -2, "\t-h : prints the command usage\n"); Abc_Print( -2, "\t : file name with simulation information\n"); -- cgit v1.2.3 From ab29dad7f4cfc1163e9004bc5b71320f50130acc Mon Sep 17 00:00:00 2001 From: Alan Mishchenko Date: Thu, 5 Aug 2021 11:07:16 -0700 Subject: Adding node ordering options to command &dfs. --- src/base/abci/abc.c | 35 +++++++++++++---------------------- 1 file changed, 13 insertions(+), 22 deletions(-) (limited to 'src/base') diff --git a/src/base/abci/abc.c b/src/base/abci/abc.c index 9ab01a90..b59bdf4c 100644 --- a/src/base/abci/abc.c +++ b/src/base/abci/abc.c @@ -32700,18 +32700,22 @@ int Abc_CommandAbc9Dfs( Abc_Frame_t * pAbc, int argc, char ** argv ) Gia_Man_t * pTemp; int c; int fNormal = 0; - int fReverse = 0; + int fRevFans = 0; + int fRevOuts = 0; int fVerbose = 0; Extra_UtilGetoptReset(); - while ( ( c = Extra_UtilGetopt( argc, argv, "nrvh" ) ) != EOF ) + while ( ( c = Extra_UtilGetopt( argc, argv, "nfovh" ) ) != EOF ) { switch ( c ) { case 'n': fNormal ^= 1; break; - case 'r': - fReverse ^= 1; + case 'f': + fRevFans ^= 1; + break; + case 'o': + fRevOuts ^= 1; break; case 'v': fVerbose ^= 1; @@ -32728,31 +32732,18 @@ int Abc_CommandAbc9Dfs( Abc_Frame_t * pAbc, int argc, char ** argv ) return 1; } if ( fNormal ) - { pTemp = Gia_ManDupOrderAiger( pAbc->pGia ); - if ( fVerbose ) - Abc_Print( -1, "AIG objects are reordered as follows: CIs, ANDs, COs.\n" ); - } - else if ( fReverse ) - { - pTemp = Gia_ManDupOrderDfsReverse( pAbc->pGia ); - if ( fVerbose ) - Abc_Print( -1, "AIG objects are reordered in the reserve DFS order.\n" ); - } - else - { - pTemp = Gia_ManDupOrderDfs( pAbc->pGia ); - if ( fVerbose ) - Abc_Print( -1, "AIG objects are reordered in the DFS order.\n" ); - } + else + pTemp = Gia_ManDupOrderDfsReverse( pAbc->pGia, fRevFans, fRevOuts ); Abc_FrameUpdateGia( pAbc, pTemp ); return 0; usage: - Abc_Print( -2, "usage: &dfs [-nrvh]\n" ); + Abc_Print( -2, "usage: &dfs [-nfovh]\n" ); Abc_Print( -2, "\t orders objects in the DFS order\n" ); Abc_Print( -2, "\t-n : toggle using normalized ordering [default = %s]\n", fNormal? "yes": "no" ); - Abc_Print( -2, "\t-r : toggle using reverse DFS ordering [default = %s]\n", fReverse? "yes": "no" ); + Abc_Print( -2, "\t-f : toggle using reverse fanin traversal order [default = %s]\n", fRevFans? "yes": "no" ); + Abc_Print( -2, "\t-o : toggle using reverse output traversal order [default = %s]\n", fRevOuts? "yes": "no" ); 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; -- cgit v1.2.3 From ddc574a95406d2f86b82d4fcdfd2e66b216eaf0a Mon Sep 17 00:00:00 2001 From: Alan Mishchenko Date: Thu, 5 Aug 2021 14:01:55 -0700 Subject: Supporting simple operators in NDR. --- src/base/wlc/wlcNdr.c | 4 ++-- src/base/wln/wlnNdr.c | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) (limited to 'src/base') diff --git a/src/base/wlc/wlcNdr.c b/src/base/wlc/wlcNdr.c index 3212500f..7325692b 100644 --- a/src/base/wlc/wlcNdr.c +++ b/src/base/wlc/wlcNdr.c @@ -263,7 +263,7 @@ void Wlc_NtkToNdrTest( Wlc_Ntk_t * pNtk ) ppNames[i] = Wlc_ObjName(pNtk, i); // verify by writing Verilog - Ndr_WriteVerilog( NULL, pDesign, ppNames ); + Ndr_WriteVerilog( NULL, pDesign, ppNames, 0 ); Ndr_Write( "test.ndr", pDesign ); // cleanup @@ -535,7 +535,7 @@ Wlc_Ntk_t * Wlc_ReadNdr( char * pFileName ) void * pData = Ndr_Read( pFileName ); Wlc_Ntk_t * pNtk = Wlc_NtkFromNdr( pData ); //char * ppNames[10] = { NULL, "a", "b", "c", "d", "e", "f", "g", "h", "i" }; - //Ndr_WriteVerilog( NULL, pData, ppNames ); + //Ndr_WriteVerilog( NULL, pData, ppNames, 0 ); //Ndr_Delete( pData ); Abc_FrameInputNdr( Abc_FrameGetGlobalFrame(), pData ); return pNtk; diff --git a/src/base/wln/wlnNdr.c b/src/base/wln/wlnNdr.c index d16840c6..37dd6eb8 100644 --- a/src/base/wln/wlnNdr.c +++ b/src/base/wln/wlnNdr.c @@ -96,7 +96,7 @@ void Wln_NtkToNdrTest( Wln_Ntk_t * p ) ppNames[i] = Abc_UtilStrsav(Wln_ObjName(p, i)); // verify by writing Verilog - Ndr_WriteVerilog( NULL, pDesign, ppNames ); + Ndr_WriteVerilog( NULL, pDesign, ppNames, 0 ); Ndr_Write( "test.ndr", pDesign ); // cleanup @@ -301,7 +301,7 @@ Wln_Ntk_t * Wln_ReadNdr( char * pFileName ) Wln_Ntk_t * pNtk = pData ? Wln_NtkFromNdr( pData, 0 ) : NULL; if ( pNtk ) return NULL; //char * ppNames[10] = { NULL, "a", "b", "c", "d", "e", "f", "g", "h", "i" }; - //Ndr_WriteVerilog( NULL, pData, ppNames ); + //Ndr_WriteVerilog( NULL, pData, ppNames, 0 ); Ndr_Delete( pData ); return pNtk; } -- cgit v1.2.3 From 99ab99bfa6d1c2cc11d59af16aa26b273f611674 Mon Sep 17 00:00:00 2001 From: Alan Mishchenko Date: Thu, 5 Aug 2021 15:05:59 -0700 Subject: Making &cec support the miter circuit. --- src/base/abci/abc.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'src/base') diff --git a/src/base/abci/abc.c b/src/base/abci/abc.c index b59bdf4c..d6871a3c 100644 --- a/src/base/abci/abc.c +++ b/src/base/abci/abc.c @@ -37753,6 +37753,20 @@ int Abc_CommandAbc9Cec( Abc_Frame_t * pAbc, int argc, char ** argv ) Gia_Obj_t * pObj; int i; if ( !pPars->fSilent ) Abc_Print( 1, "Assuming the current network is a single-output miter.\n" ); + if ( fUseSim ) + { + abctime clk = Abc_Clock(); + extern int Gia_ManCheckSimEquiv( Gia_Man_t * p, int fVerbose ); + int Status = Gia_ManCheckSimEquiv( pAbc->pGia, pPars->fVerbose ); + if ( Status == 1 ) + Abc_Print( 1, "Networks are equivalent. " ); + else if ( Status == 0 ) + Abc_Print( 1, "Networks are NOT equivalent. " ); + else + Abc_Print( 1, "Networks are UNDECIDED. " ); + Abc_PrintTime( 1, "Time", Abc_Clock() - clk ); + return 0; + } // handle the case when the output is disproved by an all-0 primary input pattern ABC_FREE( pAbc->pGia->pCexComb ); Gia_ManSetPhase( pAbc->pGia ); -- cgit v1.2.3 From e8ac47641fa410edc5de016478066d104f0beb9c Mon Sep 17 00:00:00 2001 From: Alan Mishchenko Date: Thu, 12 Aug 2021 18:25:00 -0700 Subject: Suggested changes to collect and pass timing information. --- src/base/abci/abcTiming.c | 58 ++++++++++++++++++++++++++++++++++++++++------- src/base/io/ioReadBlif.c | 19 ++++++++++++---- 2 files changed, 64 insertions(+), 13 deletions(-) (limited to 'src/base') diff --git a/src/base/abci/abcTiming.c b/src/base/abci/abcTiming.c index ae0e7f45..65feb2e8 100644 --- a/src/base/abci/abcTiming.c +++ b/src/base/abci/abcTiming.c @@ -24,9 +24,11 @@ #include "base/main/main.h" #include "map/mio/mio.h" + ABC_NAMESPACE_IMPL_START + //////////////////////////////////////////////////////////////////////// /// DECLARATIONS /// //////////////////////////////////////////////////////////////////////// @@ -187,8 +189,11 @@ void Abc_NtkTimeSetDefaultRequired( Abc_Ntk_t * pNtk, float Rise, float Fall ) pNtk->pManTime->tReqDef.Rise = Rise; pNtk->pManTime->tReqDef.Fall = Fall; // set the required times for each output - Abc_NtkForEachCo( pNtk, pObj, i ) - Abc_NtkTimeSetRequired( pNtk, Abc_ObjId(pObj), Rise, Fall ); + Abc_NtkForEachCo( pNtk, pObj, i ){ + Abc_NtkTimeSetRequired( pNtk, Abc_ObjId(pObj), Rise, Fall ); + // printf("Debug: Setting *default* required time on object %d to R %f F %f\n", + // Abc_ObjId(pObj),Rise,Fall); + } } /**Function************************************************************* @@ -204,6 +209,8 @@ void Abc_NtkTimeSetDefaultRequired( Abc_Ntk_t * pNtk, float Rise, float Fall ) ***********************************************************************/ void Abc_NtkTimeSetArrival( Abc_Ntk_t * pNtk, int ObjId, float Rise, float Fall ) { + static int debug; + debug++; Vec_Ptr_t * vTimes; Abc_Time_t * pTime; if ( pNtk->pManTime == NULL ) @@ -214,9 +221,13 @@ void Abc_NtkTimeSetArrival( Abc_Ntk_t * pNtk, int ObjId, float Rise, float Fall pTime = (Abc_Time_t *)vTimes->pArray[ObjId]; pTime->Rise = Rise; pTime->Fall = Fall; + // printf("Debug:%d Setting arrival time on object %d to R %f and F %f\n",debug, + // ObjId, Rise, Fall); + } void Abc_NtkTimeSetRequired( Abc_Ntk_t * pNtk, int ObjId, float Rise, float Fall ) { + Vec_Ptr_t * vTimes; Abc_Time_t * pTime; if ( pNtk->pManTime == NULL ) @@ -227,6 +238,10 @@ void Abc_NtkTimeSetRequired( Abc_Ntk_t * pNtk, int ObjId, float Rise, float Fall pTime = (Abc_Time_t *)vTimes->pArray[ObjId]; pTime->Rise = Rise; pTime->Fall = Fall; + static int debug; + debug++; + // printf("Debug:%d Setting required time on object %d to R %f and F %f\n",debug, + // ObjId, Rise, Fall); } /**Function************************************************************* @@ -480,16 +495,40 @@ Abc_ManTime_t * Abc_ManTimeStart( Abc_Ntk_t * pNtk ) p->vReqs = Vec_PtrAlloc( 0 ); // set default default input=arrivals (assumed to be 0) // set default default output-requireds (can be either 0 or +infinity, based on the flag) - p->tReqDef.Rise = fUseZeroDefaultOutputRequired ? 0 : ABC_INFINITY; - p->tReqDef.Fall = fUseZeroDefaultOutputRequired ? 0 : ABC_INFINITY; + + //AF: hack support the values read in. Not defaults ! + + // p->tReqDef.Rise = fUseZeroDefaultOutputRequired ? 0 : ABC_INFINITY; + // p->tReqDef.Fall = fUseZeroDefaultOutputRequired ? 0 : ABC_INFINITY; + + + Abc_Time_t* pTime; // extend manager Abc_ManTimeExpand( p, Abc_NtkObjNumMax(pNtk) + 1, 0 ); // set the default timing for CIs - Abc_NtkForEachCi( pNtk, pObj, i ) - Abc_NtkTimeSetArrival( pNtk, Abc_ObjId(pObj), p->tArrDef.Rise, p->tArrDef.Rise ); + Abc_NtkForEachCi( pNtk, pObj, i ){ + Vec_Ptr_t * vTimes; + vTimes = pNtk->pManTime->vArrs; + pTime = (Abc_Time_t *)vTimes->pArray[Abc_ObjId(pObj)]; + if (pTime){ + p->tArrDef.Fall = pTime -> Fall; + p->tArrDef.Rise = pTime -> Rise; + } + + Abc_NtkTimeSetArrival( pNtk, Abc_ObjId(pObj), p->tArrDef.Rise, p->tArrDef.Rise ); + } + // set the default timing for COs - Abc_NtkForEachCo( pNtk, pObj, i ) - Abc_NtkTimeSetRequired( pNtk, Abc_ObjId(pObj), p->tReqDef.Rise, p->tReqDef.Rise ); + Abc_NtkForEachCo( pNtk, pObj, i ){ + Vec_Ptr_t * vTimes; + vTimes = pNtk->pManTime->vArrs; + pTime = (Abc_Time_t *)vTimes->pArray[Abc_ObjId(pObj)]; + if (pTime){ + p->tReqDef.Fall = pTime -> Fall; + p->tReqDef.Rise = pTime -> Rise; + } + Abc_NtkTimeSetRequired( pNtk, Abc_ObjId(pObj), p->tReqDef.Rise, p->tReqDef.Rise ); + } return p; } @@ -571,6 +610,9 @@ void Abc_ManTimeDup( Abc_Ntk_t * pNtkOld, Abc_Ntk_t * pNtkNew ) pNtkNew->pManTime->tOutLoad = ABC_ALLOC( Abc_Time_t, Abc_NtkCiNum(pNtkOld) ); memcpy( pNtkNew->pManTime->tOutLoad, pNtkOld->pManTime->tOutLoad, sizeof(Abc_Time_t) * Abc_NtkCoNum(pNtkOld) ); } + + printf("State of abc timing manager\n"); + Abc_NtkTimePrint(pNtkNew); } /**Function************************************************************* diff --git a/src/base/io/ioReadBlif.c b/src/base/io/ioReadBlif.c index 405b44d6..e8979c9b 100644 --- a/src/base/io/ioReadBlif.c +++ b/src/base/io/ioReadBlif.c @@ -22,6 +22,9 @@ #include "base/main/main.h" #include "map/mio/mio.h" + + + ABC_NAMESPACE_IMPL_START @@ -877,10 +880,13 @@ int Io_ReadBlifNetworkInputArrival( Io_ReadBlif_t * p, Vec_Ptr_t * vTokens ) return 1; } // set timing info - //Abc_NtkTimeSetArrival( p->pNtkCur, Abc_ObjFanin0(pNet)->Id, (float)TimeRise, (float)TimeFall ); - Vec_IntPush( p->vInArrs, Abc_ObjFanin0(pNet)->Id ); - Vec_IntPush( p->vInArrs, Abc_Float2Int((float)TimeRise) ); - Vec_IntPush( p->vInArrs, Abc_Float2Int((float)TimeFall) ); + // printf("Debug: Forcing setting of arrival times\n"); + if (Abc_ObjFaninNum(pNet) >0){ + Abc_NtkTimeSetArrival( p->pNtkCur, Abc_ObjFanin0(pNet)->Id, (float)TimeRise, (float)TimeFall ); + Vec_IntPush( p->vInArrs, Abc_ObjFanin0(pNet)->Id ); + Vec_IntPush( p->vInArrs, Abc_Float2Int((float)TimeRise) ); + Vec_IntPush( p->vInArrs, Abc_Float2Int((float)TimeFall) ); + } return 0; } @@ -928,7 +934,10 @@ int Io_ReadBlifNetworkOutputRequired( Io_ReadBlif_t * p, Vec_Ptr_t * vTokens ) return 1; } // set timing info -// Abc_NtkTimeSetRequired( p->pNtkCur, Abc_ObjFanout0(pNet)->Id, (float)TimeRise, (float)TimeFall ); + // printf("Setting required time for object %d to R %f F %f\n", + // Abc_ObjFanout0(pNet)->Id, (float)TimeRise, (float)TimeFall ); + + Abc_NtkTimeSetRequired( p->pNtkCur, Abc_ObjFanout0(pNet)->Id, (float)TimeRise, (float)TimeFall ); Vec_IntPush( p->vOutReqs, Abc_ObjFanout0(pNet)->Id ); Vec_IntPush( p->vOutReqs, Abc_Float2Int((float)TimeRise) ); Vec_IntPush( p->vOutReqs, Abc_Float2Int((float)TimeFall) ); -- cgit v1.2.3 From 0deb8bf632e1700451ce4d69c99f9820e2fe0339 Mon Sep 17 00:00:00 2001 From: Alan Mishchenko Date: Thu, 12 Aug 2021 18:26:37 -0700 Subject: Suggested changes to collect and pass timing information (compiler issues). --- src/base/abci/abcTiming.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) (limited to 'src/base') diff --git a/src/base/abci/abcTiming.c b/src/base/abci/abcTiming.c index 65feb2e8..9aaf8b9f 100644 --- a/src/base/abci/abcTiming.c +++ b/src/base/abci/abcTiming.c @@ -209,10 +209,10 @@ void Abc_NtkTimeSetDefaultRequired( Abc_Ntk_t * pNtk, float Rise, float Fall ) ***********************************************************************/ void Abc_NtkTimeSetArrival( Abc_Ntk_t * pNtk, int ObjId, float Rise, float Fall ) { - static int debug; - debug++; Vec_Ptr_t * vTimes; Abc_Time_t * pTime; + static int debug; + debug++; if ( pNtk->pManTime == NULL ) pNtk->pManTime = Abc_ManTimeStart(pNtk); Abc_ManTimeExpand( pNtk->pManTime, ObjId + 1, 1 ); @@ -227,9 +227,10 @@ void Abc_NtkTimeSetArrival( Abc_Ntk_t * pNtk, int ObjId, float Rise, float Fall } void Abc_NtkTimeSetRequired( Abc_Ntk_t * pNtk, int ObjId, float Rise, float Fall ) { - Vec_Ptr_t * vTimes; Abc_Time_t * pTime; + static int debug; + debug++; if ( pNtk->pManTime == NULL ) pNtk->pManTime = Abc_ManTimeStart(pNtk); Abc_ManTimeExpand( pNtk->pManTime, ObjId + 1, 1 ); @@ -238,8 +239,6 @@ void Abc_NtkTimeSetRequired( Abc_Ntk_t * pNtk, int ObjId, float Rise, float Fall pTime = (Abc_Time_t *)vTimes->pArray[ObjId]; pTime->Rise = Rise; pTime->Fall = Fall; - static int debug; - debug++; // printf("Debug:%d Setting required time on object %d to R %f and F %f\n",debug, // ObjId, Rise, Fall); } @@ -488,6 +487,7 @@ Abc_ManTime_t * Abc_ManTimeStart( Abc_Ntk_t * pNtk ) { int fUseZeroDefaultOutputRequired = 1; Abc_ManTime_t * p; + Abc_Time_t* pTime; Abc_Obj_t * pObj; int i; p = pNtk->pManTime = ABC_ALLOC( Abc_ManTime_t, 1 ); memset( p, 0, sizeof(Abc_ManTime_t) ); @@ -501,8 +501,6 @@ Abc_ManTime_t * Abc_ManTimeStart( Abc_Ntk_t * pNtk ) // p->tReqDef.Rise = fUseZeroDefaultOutputRequired ? 0 : ABC_INFINITY; // p->tReqDef.Fall = fUseZeroDefaultOutputRequired ? 0 : ABC_INFINITY; - - Abc_Time_t* pTime; // extend manager Abc_ManTimeExpand( p, Abc_NtkObjNumMax(pNtk) + 1, 0 ); // set the default timing for CIs -- cgit v1.2.3 From e9b487666d7cab3cc8a02faa34160d2ed4cb6178 Mon Sep 17 00:00:00 2001 From: Alan Mishchenko Date: Thu, 12 Aug 2021 18:27:40 -0700 Subject: Suggested changes to collect and pass timing information (unused variable). --- src/base/abci/abcTiming.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/base') diff --git a/src/base/abci/abcTiming.c b/src/base/abci/abcTiming.c index 9aaf8b9f..2777c9f8 100644 --- a/src/base/abci/abcTiming.c +++ b/src/base/abci/abcTiming.c @@ -485,7 +485,7 @@ void Abc_NtkTimePrepare( Abc_Ntk_t * pNtk ) ***********************************************************************/ Abc_ManTime_t * Abc_ManTimeStart( Abc_Ntk_t * pNtk ) { - int fUseZeroDefaultOutputRequired = 1; + //int fUseZeroDefaultOutputRequired = 1; Abc_ManTime_t * p; Abc_Time_t* pTime; Abc_Obj_t * pObj; int i; -- cgit v1.2.3 From 4da6cc890433e8d782f8a1805fa9ec617955464d Mon Sep 17 00:00:00 2001 From: Alan Mishchenko Date: Tue, 17 Aug 2021 16:52:29 -0700 Subject: Improving AIG to Verilog converter. --- src/base/abci/abc.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'src/base') diff --git a/src/base/abci/abc.c b/src/base/abci/abc.c index d6871a3c..259f4686 100644 --- a/src/base/abci/abc.c +++ b/src/base/abci/abc.c @@ -31219,12 +31219,13 @@ int Abc_CommandAbc9Write( Abc_Frame_t * pAbc, int argc, char ** argv ) int c, nArgcNew; int fUnique = 0; int fVerilog = 0; + int fVerBufs = 0; int fMiniAig = 0; int fMiniLut = 0; int fWriteNewLine = 0; int fVerbose = 0; Extra_UtilGetoptReset(); - while ( ( c = Extra_UtilGetopt( argc, argv, "upmlnvh" ) ) != EOF ) + while ( ( c = Extra_UtilGetopt( argc, argv, "upbmlnvh" ) ) != EOF ) { switch ( c ) { @@ -31234,6 +31235,9 @@ int Abc_CommandAbc9Write( Abc_Frame_t * pAbc, int argc, char ** argv ) case 'p': fVerilog ^= 1; break; + case 'b': + fVerBufs ^= 1; + break; case 'm': fMiniAig ^= 1; break; @@ -31272,7 +31276,7 @@ int Abc_CommandAbc9Write( Abc_Frame_t * pAbc, int argc, char ** argv ) Gia_ManStop( pGia ); } else if ( fVerilog ) - Gia_ManDumpVerilog( pAbc->pGia, pFileName, NULL ); + Gia_ManDumpVerilog( pAbc->pGia, pFileName, NULL, fVerBufs ); else if ( fMiniAig ) Gia_ManWriteMiniAig( pAbc->pGia, pFileName ); else if ( fMiniLut ) @@ -31282,10 +31286,11 @@ int Abc_CommandAbc9Write( Abc_Frame_t * pAbc, int argc, char ** argv ) return 0; usage: - Abc_Print( -2, "usage: &w [-upmlnvh] \n" ); + Abc_Print( -2, "usage: &w [-upbmlnvh] \n" ); Abc_Print( -2, "\t writes the current AIG into the AIGER file\n" ); Abc_Print( -2, "\t-u : toggle writing canonical AIG structure [default = %s]\n", fUnique? "yes" : "no" ); Abc_Print( -2, "\t-p : toggle writing Verilog with 'and' and 'not' [default = %s]\n", fVerilog? "yes" : "no" ); + Abc_Print( -2, "\t-b : toggle writing additional buffers in Verilog [default = %s]\n", fVerBufs? "yes" : "no" ); Abc_Print( -2, "\t-m : toggle writing MiniAIG rather than AIGER [default = %s]\n", fMiniAig? "yes" : "no" ); Abc_Print( -2, "\t-l : toggle writing MiniLUT rather than AIGER [default = %s]\n", fMiniLut? "yes" : "no" ); Abc_Print( -2, "\t-n : toggle writing \'\\n\' after \'c\' in the AIGER file [default = %s]\n", fWriteNewLine? "yes": "no" ); -- cgit v1.2.3 From ca710b3dda0848e552b4b13d72bb261b5089819c Mon Sep 17 00:00:00 2001 From: Tobias Wiersema Date: Thu, 19 Aug 2021 17:23:03 +0200 Subject: Add inv_get -f to read flop names from GIA --- src/base/wlc/wlcAbc.c | 12 +++++++++--- src/base/wlc/wlcCom.c | 36 +++++++++++++++++++++++++++++++----- 2 files changed, 40 insertions(+), 8 deletions(-) (limited to 'src/base') diff --git a/src/base/wlc/wlcAbc.c b/src/base/wlc/wlcAbc.c index e1b06ffd..be254bb2 100644 --- a/src/base/wlc/wlcAbc.c +++ b/src/base/wlc/wlcAbc.c @@ -140,7 +140,7 @@ void Wlc_NtkPrintInvStats( Wlc_Ntk_t * pNtk, Vec_Int_t * vCounts, int fVerbose ) SeeAlso [] ***********************************************************************/ -Abc_Ntk_t * Wlc_NtkGetInv( Wlc_Ntk_t * pNtk, Vec_Int_t * vInv ) +Abc_Ntk_t * Wlc_NtkGetInv( Wlc_Ntk_t * pNtk, Vec_Int_t * vInv, Vec_Ptr_t * vNamesIn ) { extern Vec_Int_t * Pdr_InvCounts( Vec_Int_t * vInv ); extern Vec_Str_t * Pdr_InvPrintStr( Vec_Int_t * vInv, Vec_Int_t * vCounts ); @@ -166,8 +166,14 @@ Abc_Ntk_t * Wlc_NtkGetInv( Wlc_Ntk_t * pNtk, Vec_Int_t * vInv ) if ( Entry == 0 ) continue; pMainObj = Abc_NtkCreatePi( pMainNtk ); - sprintf( Buffer, "pi%d", i ); - Abc_ObjAssignName( pMainObj, Buffer, NULL ); + if (vNamesIn != NULL && i < Vec_PtrSize(vNamesIn)) { + Abc_ObjAssignName( pMainObj, (char *)Vec_PtrEntry(vNamesIn, i), NULL ); + } + else + { + sprintf( Buffer, "pi%d", i ); + Abc_ObjAssignName( pMainObj, Buffer, NULL ); + } } if ( Abc_NtkPiNum(pMainNtk) != nInputs ) { diff --git a/src/base/wlc/wlcCom.c b/src/base/wlc/wlcCom.c index 666a8776..cf9805c5 100644 --- a/src/base/wlc/wlcCom.c +++ b/src/base/wlc/wlcCom.c @@ -1727,15 +1727,19 @@ usage: ******************************************************************************/ int Abc_CommandInvGet( Abc_Frame_t * pAbc, int argc, char ** argv ) { - extern Abc_Ntk_t * Wlc_NtkGetInv( Wlc_Ntk_t * pNtk, Vec_Int_t * vInv ); + extern Abc_Ntk_t * Wlc_NtkGetInv( Wlc_Ntk_t * pNtk, Vec_Int_t * vInv, Vec_Ptr_t * vNamesIn ); Abc_Ntk_t * pMainNtk; Wlc_Ntk_t * pNtk = Wlc_AbcGetNtk(pAbc); - int c, fVerbose = 0; + int c, i, fVerbose = 0, fFlopNamesFromGia = 0; + Vec_Ptr_t * vNamesIn = NULL; Extra_UtilGetoptReset(); - while ( ( c = Extra_UtilGetopt( argc, argv, "vh" ) ) != EOF ) + while ( ( c = Extra_UtilGetopt( argc, argv, "fvh" ) ) != EOF ) { switch ( c ) { + case 'f': + fFlopNamesFromGia ^= 1; + break; case 'v': fVerbose ^= 1; break; @@ -1750,16 +1754,38 @@ int Abc_CommandInvGet( Abc_Frame_t * pAbc, int argc, char ** argv ) Abc_Print( 1, "Abc_CommandInvGet(): Invariant is not available.\n" ); return 0; } + // See if we shall and can copy the PI names from the current GIA + if ( fFlopNamesFromGia ) + { + if ( pAbc->pGia == NULL ) + { + Abc_Print( 1, "Abc_CommandInvGet(): No network in &-space, cannot copy names.\n" ); + fFlopNamesFromGia = 0; + } + else + { + vNamesIn = Vec_PtrStart( Gia_ManRegNum(pAbc->pGia) ); + for ( i = 0; i < Gia_ManRegNum(pAbc->pGia); ++i ) + { + // Only the registers + Vec_PtrSetEntry( vNamesIn, i, Extra_UtilStrsav( (const char*)Vec_PtrEntry( pAbc->pGia->vNamesIn, Gia_ManPiNum(pAbc->pGia)+i ) ) ); + } + } + } // derive the network - pMainNtk = Wlc_NtkGetInv( pNtk, Wlc_AbcGetInv(pAbc) ); + pMainNtk = Wlc_NtkGetInv( pNtk, Wlc_AbcGetInv(pAbc), vNamesIn ); + // Delete names + if (vNamesIn) + Vec_PtrFree( vNamesIn ); // replace the current network if ( pMainNtk ) Abc_FrameReplaceCurrentNetwork( pAbc, pMainNtk ); return 0; usage: - Abc_Print( -2, "usage: inv_get [-vh]\n" ); + Abc_Print( -2, "usage: inv_get [-fvh]\n" ); Abc_Print( -2, "\t places invariant found by PDR as the current network in the main-space\n" ); Abc_Print( -2, "\t (in the case of \'sat\' or \'undecided\', inifity clauses are used)\n" ); + Abc_Print( -2, "\t-f : toggle reading flop names from the &-space [default = %s]\n", fFlopNamesFromGia? "yes": "no" ); 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; -- cgit v1.2.3 From d55e8fab82fa3d3e05725c27eb799e7669ee0d69 Mon Sep 17 00:00:00 2001 From: Tobias Wiersema Date: Thu, 19 Aug 2021 17:57:54 +0200 Subject: Fix typo inifity -> infinity in inv_get help --- src/base/wlc/wlcCom.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/base') diff --git a/src/base/wlc/wlcCom.c b/src/base/wlc/wlcCom.c index cf9805c5..39f1bebd 100644 --- a/src/base/wlc/wlcCom.c +++ b/src/base/wlc/wlcCom.c @@ -1784,7 +1784,7 @@ int Abc_CommandInvGet( Abc_Frame_t * pAbc, int argc, char ** argv ) usage: Abc_Print( -2, "usage: inv_get [-fvh]\n" ); Abc_Print( -2, "\t places invariant found by PDR as the current network in the main-space\n" ); - Abc_Print( -2, "\t (in the case of \'sat\' or \'undecided\', inifity clauses are used)\n" ); + Abc_Print( -2, "\t (in the case of \'sat\' or \'undecided\', infinity clauses are used)\n" ); Abc_Print( -2, "\t-f : toggle reading flop names from the &-space [default = %s]\n", fFlopNamesFromGia? "yes": "no" ); 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"); -- cgit v1.2.3 From b82a7f46777e73c89b9e8db3a391d3a93aa5b562 Mon Sep 17 00:00:00 2001 From: Tobias Wiersema Date: Thu, 19 Aug 2021 18:01:38 +0200 Subject: Add comment to Wlc_NtkGetInv about vNamesIn's role --- src/base/wlc/wlcAbc.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src/base') diff --git a/src/base/wlc/wlcAbc.c b/src/base/wlc/wlcAbc.c index be254bb2..8b7dbfa7 100644 --- a/src/base/wlc/wlcAbc.c +++ b/src/base/wlc/wlcAbc.c @@ -166,6 +166,8 @@ Abc_Ntk_t * Wlc_NtkGetInv( Wlc_Ntk_t * pNtk, Vec_Int_t * vInv, Vec_Ptr_t * vName if ( Entry == 0 ) continue; pMainObj = Abc_NtkCreatePi( pMainNtk ); + // If vNamesIn is given, take names from there for as many entries as possible + // otherwise generate names from counter if (vNamesIn != NULL && i < Vec_PtrSize(vNamesIn)) { Abc_ObjAssignName( pMainObj, (char *)Vec_PtrEntry(vNamesIn, i), NULL ); } -- cgit v1.2.3 From 77760dd8ac0d9ed1c0c909f28415204074074e78 Mon Sep 17 00:00:00 2001 From: Alan Mishchenko Date: Thu, 19 Aug 2021 09:48:46 -0700 Subject: Extending &trim to trim structurally equivalent primary outputs. --- src/base/abci/abc.c | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) (limited to 'src/base') diff --git a/src/base/abci/abc.c b/src/base/abci/abc.c index 259f4686..6e322b9b 100644 --- a/src/base/abci/abc.c +++ b/src/base/abci/abc.c @@ -32628,8 +32628,9 @@ int Abc_CommandAbc9Trim( Abc_Frame_t * pAbc, int argc, char ** argv ) int fTrimCos = 1; int fDualOut = 0; int fPoFedByPi = 0; + int fPoFedByPo = 0; Extra_UtilGetoptReset(); - while ( ( c = Extra_UtilGetopt( argc, argv, "Viocdh" ) ) != EOF ) + while ( ( c = Extra_UtilGetopt( argc, argv, "Viocpdh" ) ) != EOF ) { switch ( c ) { @@ -32653,6 +32654,9 @@ int Abc_CommandAbc9Trim( Abc_Frame_t * pAbc, int argc, char ** argv ) case 'c': fPoFedByPi ^= 1; break; + case 'p': + fPoFedByPo ^= 1; + break; case 'd': fDualOut ^= 1; break; @@ -32674,16 +32678,23 @@ int Abc_CommandAbc9Trim( Abc_Frame_t * pAbc, int argc, char ** argv ) pTemp = Gia_ManDupTrimmed2( pTemp2 = pTemp ); Gia_ManStop( pTemp2 ); } + if ( fPoFedByPo ) + { + extern Gia_Man_t * Gia_ManDupTrimmed3( Gia_Man_t * p ); + pTemp = Gia_ManDupTrimmed3( pTemp2 = pTemp ); + Gia_ManStop( pTemp2 ); + } Abc_FrameUpdateGia( pAbc, pTemp ); return 0; usage: - Abc_Print( -2, "usage: &trim [-V num] [-iocdh]\n" ); + Abc_Print( -2, "usage: &trim [-V num] [-iocpdh]\n" ); Abc_Print( -2, "\t removes PIs without fanout and PO driven by constants\n" ); Abc_Print( -2, "\t-V num : the value (0 or 1) of POs to remove [default = both]\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-p : toggle additionally removing duplicated POs [default = %s]\n", fPoFedByPo? "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; @@ -49291,7 +49302,7 @@ int Abc_CommandAbc9Test( Abc_Frame_t * pAbc, int argc, char ** argv ) Abc_Print( -1, "Abc_CommandAbc9Test(): There is no AIG.\n" ); return 1; } - Abc_FrameUpdateGia( pAbc, Gia_ManPerformNewResub(pAbc->pGia, 100, 8, 1, 1) ); + Abc_FrameUpdateGia( pAbc, Gia_ManPerformNewResub(pAbc->pGia, 100, 6, 1, 1) ); // printf( "AIG in \"%s\" has the sum of output support sizes equal to %d.\n", pAbc->pGia->pSpec, Gia_ManSumTotalOfSupportSizes(pAbc->pGia) ); return 0; usage: -- cgit v1.2.3 From 625ccde611da6eecf3bfdefc7632cd7a801767df Mon Sep 17 00:00:00 2001 From: Alan Mishchenko Date: Sun, 22 Aug 2021 13:05:28 -0700 Subject: Support of pair-wise miter and other changes. --- src/base/abc/abcDfs.c | 4 ++-- src/base/abci/abc.c | 21 +++++++++++++++++++-- 2 files changed, 21 insertions(+), 4 deletions(-) (limited to 'src/base') diff --git a/src/base/abc/abcDfs.c b/src/base/abc/abcDfs.c index 731d35f5..a1345db8 100644 --- a/src/base/abc/abcDfs.c +++ b/src/base/abc/abcDfs.c @@ -897,9 +897,9 @@ Vec_Ptr_t * Abc_NtkNodeSupport( Abc_Ntk_t * pNtk, Abc_Obj_t ** ppNodes, int nNod vNodes = Vec_PtrAlloc( 100 ); // go through the PO nodes and call for each of them for ( i = 0; i < nNodes; i++ ) - if ( Abc_ObjIsCo(ppNodes[i]) ) + if ( Abc_ObjIsCo(ppNodes[i]) && Abc_ObjFaninNum(Abc_ObjFanin0(ppNodes[i])) != 0 ) Abc_NtkNodeSupport_rec( Abc_ObjFanin0(ppNodes[i]), vNodes ); - else + else if ( !Abc_ObjIsCo(ppNodes[i]) && Abc_ObjFaninNum(ppNodes[i]) != 0 ) Abc_NtkNodeSupport_rec( ppNodes[i], vNodes ); return vNodes; } diff --git a/src/base/abci/abc.c b/src/base/abci/abc.c index 6e322b9b..b5881b91 100644 --- a/src/base/abci/abc.c +++ b/src/base/abci/abc.c @@ -36013,6 +36013,7 @@ usage: ***********************************************************************/ int Abc_CommandAbc9Miter( Abc_Frame_t * pAbc, int argc, char ** argv ) { + extern Gia_Man_t * Gia_ManPairWiseMiter( Gia_Man_t * p ); FILE * pFile; Gia_Man_t * pAux; Gia_Man_t * pSecond; @@ -36023,13 +36024,14 @@ int Abc_CommandAbc9Miter( Abc_Frame_t * pAbc, int argc, char ** argv ) int nInsDup = 0; int fDualOut = 0; int fSeq = 0; + int fPairWise= 0; int fTrans = 0; int fTransX = 0; int fConvert = 0; int fTransZ = 0; int fVerbose = 0; Extra_UtilGetoptReset(); - while ( ( c = Extra_UtilGetopt( argc, argv, "Idstxyzvh" ) ) != EOF ) + while ( ( c = Extra_UtilGetopt( argc, argv, "Idsptxyzvh" ) ) != EOF ) { switch ( c ) { @@ -36050,6 +36052,9 @@ int Abc_CommandAbc9Miter( Abc_Frame_t * pAbc, int argc, char ** argv ) case 's': fSeq ^= 1; break; + case 'p': + fPairWise ^= 1; + break; case 't': fTrans ^= 1; break; @@ -36071,6 +36076,17 @@ int Abc_CommandAbc9Miter( Abc_Frame_t * pAbc, int argc, char ** argv ) goto usage; } } + if ( fPairWise ) + { + if ( pAbc->pGia == NULL ) + { + Abc_Print( -1, "Abc_CommandAbc9Miter(): There is no AIG.\n" ); + return 1; + } + pAux = Gia_ManPairWiseMiter( pAbc->pGia ); + Abc_FrameUpdateGia( pAbc, pAux ); + return 0; + } if ( fTrans || fTransX || fTransZ || fConvert ) { if ( pAbc->pGia == NULL ) @@ -36144,11 +36160,12 @@ int Abc_CommandAbc9Miter( Abc_Frame_t * pAbc, int argc, char ** argv ) return 0; usage: - Abc_Print( -2, "usage: &miter [-I num] [-dstxyzvh] \n" ); + Abc_Print( -2, "usage: &miter [-I num] [-dsptxyzvh] \n" ); Abc_Print( -2, "\t creates miter of two designs (current AIG vs. )\n" ); Abc_Print( -2, "\t-I num : the number of last PIs to replicate [default = %d]\n", nInsDup ); Abc_Print( -2, "\t-d : toggle creating dual-output miter [default = %s]\n", fDualOut? "yes": "no" ); Abc_Print( -2, "\t-s : toggle creating sequential miter [default = %s]\n", fSeq? "yes": "no" ); + Abc_Print( -2, "\t-p : toggle creating pair-wise miter [default = %s]\n", fPairWise? "yes": "no" ); Abc_Print( -2, "\t-t : toggle XORing POs of dual-output miter [default = %s]\n", fTrans? "yes": "no" ); Abc_Print( -2, "\t-x : toggle XORing POs of two-word miter [default = %s]\n", fTransX? "yes": "no" ); Abc_Print( -2, "\t-y : toggle convering two-word miter into dual-output miter [default = %s]\n", fConvert? "yes": "no" ); -- cgit v1.2.3 From 67c47fa44aaa566d10abb154b3f89a9d427f5581 Mon Sep 17 00:00:00 2001 From: Alan Mishchenko Date: Sun, 22 Aug 2021 20:05:15 -0700 Subject: Adding input/output/flop name reading in command &r. --- src/base/acb/acbFunc.c | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) (limited to 'src/base') diff --git a/src/base/acb/acbFunc.c b/src/base/acb/acbFunc.c index 55918f49..a8cae33d 100644 --- a/src/base/acb/acbFunc.c +++ b/src/base/acb/acbFunc.c @@ -776,6 +776,31 @@ Gia_Man_t * Acb_NtkToGia( Acb_Ntk_t * p, Vec_Int_t * vSupp, Vec_Int_t * vNodes, Gia_ManStop( pOne ); return pNew; } +int Acb_NtkSaveNames( Acb_Ntk_t * p, Vec_Int_t * vSupp, Vec_Int_t * vNodes, Vec_Int_t * vRoots, Vec_Int_t * vDivs, Vec_Int_t * vTargets, Gia_Man_t * pNew ) +{ + int i, iObj; + assert( pNew->vNamesIn == NULL ); + + pNew->vNamesIn = Vec_PtrAlloc( Gia_ManCiNum(pNew) ); + Acb_NtkForEachCiVec( vSupp, p, iObj, i ) + Vec_PtrPush( pNew->vNamesIn, Abc_UtilStrsav(Acb_ObjNameStr(p, iObj)) ); + if ( vTargets ) + Vec_IntForEachEntry( vTargets, iObj, i ) + Vec_PtrPush( pNew->vNamesIn, Abc_UtilStrsav(Acb_ObjNameStr(p, iObj)) ); + + pNew->vNamesOut = Vec_PtrAlloc( Gia_ManCoNum(pNew) ); + Acb_NtkForEachCoDriverVec( vRoots, p, iObj, i ) + Vec_PtrPush( pNew->vNamesOut, Abc_UtilStrsav(Acb_ObjNameStr(p, iObj)) ); + if ( vDivs ) + Vec_IntForEachEntry( vDivs, iObj, i ) + { + char Buffer[100]; + assert( strlen(Acb_ObjNameStr(p, iObj)) < 90 ); + sprintf( Buffer, "%s_%d", Acb_ObjNameStr(p, iObj), Acb_ObjWeight(p, iObj) ); + Vec_PtrPush( pNew->vNamesOut, Abc_UtilStrsav(Buffer) ); + } + return 1; +} /**Function************************************************************* @@ -2622,6 +2647,10 @@ int Acb_NtkEcoPerform( Acb_Ntk_t * pNtkF, Acb_Ntk_t * pNtkG, char * pFileName[4] char * pSop = NULL; int i; +// int Value = Acb_NtkSaveNames( pNtkF, vSupp, vNodesF, vRoots, vDivs, &pNtkF->vTargets, pGiaF ); +// Gia_AigerWrite( pGiaF, pFileBase, 0, 0, 0 ); +// return 0; + if ( fVerbose ) { printf( "The number of targets = %d.\n", nTargets ); @@ -2770,6 +2799,16 @@ int Acb_NtkEcoPerform( Acb_Ntk_t * pNtkF, Acb_Ntk_t * pNtkG, char * pFileName[4] if ( pFileName[3] == NULL ) Acb_GenerateFilePatch( vPatch, "patch.v" ); Acb_GenerateFileOut( vInst, pFileName[0], pFileName[3] ? pFileName[3] : (char *)"out.v", vPatch ); printf( "Finished dumping resulting file \"%s\".\n\n", pFileName[3] ? pFileName[3] : "out.v" ); +/* + { + char * pFileBase = Extra_FileNameGenericAppend( pFileName[0], "_patch.v" ); + Acb_GenerateFilePatch( vPatch, pFileBase ); + pFileBase = Extra_FileNameGenericAppend( pFileName[0], "_out.v" ); + Acb_GenerateFileOut( vInst, pFileName[0], pFileName[3] ? pFileName[3] : pFileBase, vPatch ); + Acb_GenerateFileOut( vInst, pFileName[0], pFileName[3] ? pFileName[3] : "out.v", vPatch ); + printf( "Finished dumping resulting file \"%s\".\n\n", pFileName[3] ? pFileName[3] : pFileBase ); + } +*/ //Gia_AigerWrite( pGiaG, "test.aig", 0, 0, 0 ); cleanup: // cleanup -- cgit v1.2.3 From 85a94766a6b4e1870279110a8620cba92832367f Mon Sep 17 00:00:00 2001 From: Alan Mishchenko Date: Mon, 23 Aug 2021 19:56:26 -0700 Subject: Compiler warnings. --- src/base/abci/abcLut.c | 2 ++ src/base/abci/abcMiter.c | 4 ++-- src/base/io/ioReadBlifMv.c | 2 +- src/base/wlc/wlcNdr.c | 2 +- src/base/wln/wlnNdr.c | 2 +- 5 files changed, 7 insertions(+), 5 deletions(-) (limited to 'src/base') diff --git a/src/base/abci/abcLut.c b/src/base/abci/abcLut.c index 8dc84ba0..49c74e6b 100644 --- a/src/base/abci/abcLut.c +++ b/src/base/abci/abcLut.c @@ -896,6 +896,7 @@ Abc_Ntk_t * Abc_NtkSpecialMapping( Abc_Ntk_t * pNtk, int fVerbose ) } if ( fVerbose ) + { Abc_NtkForEachNode( pNtk, pObj, i ) { printf( "Node %4d : ", i ); @@ -909,6 +910,7 @@ Abc_Ntk_t * Abc_NtkSpecialMapping( Abc_Ntk_t * pNtk, int fVerbose ) printf( " " ); Vec_IntPrint( Vec_WecEntry(vSupps, i) ); } + } Abc_NtkCleanCopy( pNtk ); pNtkNew = Abc_NtkStartFrom( pNtk, ABC_NTK_LOGIC, ABC_FUNC_SOP ); diff --git a/src/base/abci/abcMiter.c b/src/base/abci/abcMiter.c index 81b032d4..6086fc61 100644 --- a/src/base/abci/abcMiter.c +++ b/src/base/abci/abcMiter.c @@ -863,7 +863,7 @@ void Abc_NtkAddFrame( Abc_Ntk_t * pNtkFrames, Abc_Ntk_t * pNtk, int iFrame ) { int fVerbose = 0; int NodeBef = Abc_NtkNodeNum(pNtkFrames); - char Buffer[10]; + char Buffer[16]; Abc_Obj_t * pNode, * pLatch; int i; // create the prefix to be added to the node names @@ -1008,7 +1008,7 @@ Abc_Ntk_t * Abc_NtkFrames2( Abc_Ntk_t * pNtk, int nFrames, int fInitial, AddFram void Abc_NtkAddFrame2( Abc_Ntk_t * pNtkFrames, Abc_Ntk_t * pNtk, int iFrame, Vec_Ptr_t * vNodes, AddFrameMapping addFrameMapping, void* arg ) { /* - char Buffer[10]; + char Buffer[16]; Abc_Obj_t * pNode, * pNodeNew, * pLatch; Abc_Obj_t * pConst1, * pConst1New; int i; diff --git a/src/base/io/ioReadBlifMv.c b/src/base/io/ioReadBlifMv.c index 098f94a1..e5c6fe49 100644 --- a/src/base/io/ioReadBlifMv.c +++ b/src/base/io/ioReadBlifMv.c @@ -1657,7 +1657,7 @@ static int Io_MvWriteValues( Abc_Obj_t * pNode, Vec_Str_t * vFunc ) ***********************************************************************/ static int Io_MvParseLiteralMv( Io_MvMod_t * p, Abc_Obj_t * pNode, char * pToken, Vec_Str_t * vFunc, int iLit ) { - char Buffer[10]; + char Buffer[16]; Io_MvVar_t * pVar; Abc_Obj_t * pFanin, * pNet; char * pCur, * pNext; diff --git a/src/base/wlc/wlcNdr.c b/src/base/wlc/wlcNdr.c index 7325692b..b06d9357 100644 --- a/src/base/wlc/wlcNdr.c +++ b/src/base/wlc/wlcNdr.c @@ -487,7 +487,7 @@ Wlc_Ntk_t * Wlc_NtkFromNdr( void * pData ) pNtk->pManName = Abc_NamStart( NameIdMax+1, 10 ); for ( i = 1; i <= NameIdMax; i++ ) { - char pName[20]; sprintf( pName, "s%0*d", nDigits, i ); + char pName[100]; sprintf( pName, "s%0*d", nDigits, i ); NameId = Abc_NamStrFindOrAdd( pNtk->pManName, pName, &fFound ); assert( !fFound && i == NameId ); } diff --git a/src/base/wln/wlnNdr.c b/src/base/wln/wlnNdr.c index 37dd6eb8..9eaf71ed 100644 --- a/src/base/wln/wlnNdr.c +++ b/src/base/wln/wlnNdr.c @@ -256,7 +256,7 @@ Wln_Ntk_t * Wln_NtkFromNdr( void * pData, int fDump ) pNtk->pManName = Abc_NamStart( NameIdMax+1, 10 ); for ( i = 1; i <= NameIdMax; i++ ) { - char pName[20]; sprintf( pName, "s%0*d", nDigits, i ); + char pName[100]; sprintf( pName, "s%0*d", nDigits, i ); NameId = Abc_NamStrFindOrAdd( pNtk->pManName, pName, &fFound ); assert( !fFound && i == NameId ); } -- cgit v1.2.3 From 388255e557cf973616c84c32307366f79822295a Mon Sep 17 00:00:00 2001 From: Alan Mishchenko Date: Tue, 24 Aug 2021 14:51:24 -0700 Subject: Allow &mfs to work on sequential AIGs. --- src/base/abci/abc.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'src/base') diff --git a/src/base/abci/abc.c b/src/base/abci/abc.c index b5881b91..4e986360 100644 --- a/src/base/abci/abc.c +++ b/src/base/abci/abc.c @@ -47282,7 +47282,16 @@ int Abc_CommandAbc9Mfs( Abc_Frame_t * pAbc, int argc, char ** argv ) return 0; } */ - pTemp = Gia_ManPerformMfs( pAbc->pGia, pPars ); + if ( Gia_ManRegNum(pAbc->pGia) == 0 ) + pTemp = Gia_ManPerformMfs( pAbc->pGia, pPars ); + else + { + int nRegs = Gia_ManRegNum(pAbc->pGia); + pAbc->pGia->nRegs = 0; + pTemp = Gia_ManPerformMfs( pAbc->pGia, pPars ); + Gia_ManSetRegNum( pAbc->pGia, nRegs ); + Gia_ManSetRegNum( pTemp, nRegs ); + } Abc_FrameUpdateGia( pAbc, pTemp ); return 0; -- cgit v1.2.3 From a718318740a3a50f6058b3d64330dbe8ca1e6303 Mon Sep 17 00:00:00 2001 From: Alan Mishchenko Date: Thu, 2 Sep 2021 22:54:19 -0700 Subject: Various changes. --- src/base/abci/abc.c | 18 +++- src/base/acb/acbFunc.c | 258 +++++++++++++++++++++++++++++++++++++++++++++- src/base/io/ioReadAiger.c | 9 ++ 3 files changed, 278 insertions(+), 7 deletions(-) (limited to 'src/base') diff --git a/src/base/abci/abc.c b/src/base/abci/abc.c index 4e986360..d4155ca6 100644 --- a/src/base/abci/abc.c +++ b/src/base/abci/abc.c @@ -770,6 +770,11 @@ void Abc_FrameUpdateGia( Abc_Frame_t * pAbc, Gia_Man_t * pNew ) pNew->vNamesOut = pAbc->pGia->vNamesOut; pAbc->pGia->vNamesOut = NULL; } + if (!pNew->vNamesNode && pAbc->pGia && pAbc->pGia->vNamesNode && Gia_ManObjNum(pNew) == Vec_PtrSize(pAbc->pGia->vNamesNode)) + { + pNew->vNamesNode = pAbc->pGia->vNamesNode; + pAbc->pGia->vNamesNode = NULL; + } // update if ( pAbc->pGia2 ) Gia_ManStop( pAbc->pGia2 ); @@ -30088,6 +30093,7 @@ int Abc_CommandAbc9Read( Abc_Frame_t * pAbc, int argc, char ** argv ) { extern void Abc3_ReadShowHie( char * pFileName, int fFlat ); extern Gia_Man_t * Gia_MiniAigSuperDerive( char * pFileName, int fVerbose ); + extern Gia_Man_t * Gia_FileSimpleRead( char * pFileName, int fNames, char * pFileW ); Gia_Man_t * pAig = NULL; FILE * pFile; char ** pArgvNew; @@ -30099,8 +30105,9 @@ int Abc_CommandAbc9Read( Abc_Frame_t * pAbc, int argc, char ** argv ) int fVerbose = 0; int fGiaSimple = 0; int fSkipStrash = 0; + int fNewReader = 0; Extra_UtilGetoptReset(); - while ( ( c = Extra_UtilGetopt( argc, argv, "csmnlvh" ) ) != EOF ) + while ( ( c = Extra_UtilGetopt( argc, argv, "csmnlpvh" ) ) != EOF ) { switch ( c ) { @@ -30119,6 +30126,9 @@ int Abc_CommandAbc9Read( Abc_Frame_t * pAbc, int argc, char ** argv ) case 'l': fMiniLut ^= 1; break; + case 'p': + fNewReader ^= 1; + break; case 'v': fVerbose ^= 1; break; @@ -30150,7 +30160,9 @@ int Abc_CommandAbc9Read( Abc_Frame_t * pAbc, int argc, char ** argv ) } fclose( pFile ); - if ( fMiniAig ) + if ( fNewReader ) + pAig = Gia_FileSimpleRead( FileName, fGiaSimple, NULL ); + else if ( fMiniAig ) pAig = Gia_ManReadMiniAig( FileName ); else if ( fMiniAig2 ) pAig = Gia_MiniAigSuperDerive( FileName, fVerbose ); @@ -30702,6 +30714,8 @@ int Abc_CommandAbc9Put( Abc_Frame_t * pAbc, int argc, char ** argv ) } } } + if ( pAbc->pGia->vNamesNode ) + Abc_Print( 0, "Internal nodes names are not transferred.\n" ); // decouple CI/CO with the same name if ( pAbc->pGia->vNamesIn || pAbc->pGia->vNamesOut ) diff --git a/src/base/acb/acbFunc.c b/src/base/acb/acbFunc.c index a8cae33d..5105f463 100644 --- a/src/base/acb/acbFunc.c +++ b/src/base/acb/acbFunc.c @@ -210,17 +210,78 @@ Vec_Int_t * Acb_VerilogSimpleLex( char * pFileName, Abc_Nam_t * pNames ) Vec_Int_t * vBuffer = Vec_IntAlloc( 1000 ); char * pBuffer = Extra_FileReadContents( pFileName ); char * pToken, * pStart, * pLimit = pBuffer + strlen(pBuffer); + int i, iToken, RLeft = -1, RRight = -1; if ( pBuffer == NULL ) return NULL; Acb_VerilogRemoveComments( pBuffer ); pToken = strtok( pBuffer, " \n\r\t(),;=" ); while ( pToken ) { - int iToken = Abc_NamStrFindOrAdd( pNames, pToken, NULL ); + if ( 0 ) + { + if ( !strcmp(pToken, "assign") ) + { + int fBuffer = 0; + int nToks = 0, pToks[4]; + while ( 1 ) + { + pToken = strtok( NULL, " \n\r\t(),=~&" ); + if ( pToken[0] == ';' ) + break; + if ( pToken[strlen(pToken)-1] == ';' ) + { + pToken[strlen(pToken)-1] = 0; + assert( nToks < 3 ); + pToks[nToks++] = Abc_NamStrFindOrAdd( pNames, pToken, NULL ); + fBuffer = 1; + break; + } + else + { + assert( nToks < 3 ); + pToks[nToks++] = Abc_NamStrFindOrAdd( pNames, pToken, NULL ); + } + } + assert( nToks == 2 || nToks == 3 ); + Vec_IntPush( vBuffer, fBuffer ? ACB_AND : ACB_NAND ); + Vec_IntPush( vBuffer, pToks[0] ); + Vec_IntPush( vBuffer, pToks[1] ); + Vec_IntPush( vBuffer, nToks == 3 ? pToks[2] : pToks[1] ); + pToken = strtok( NULL, " \n\r\t(),;=" ); + continue; + } + } + + if ( pToken[0] == '[' ) + { + assert( RLeft == -1 ); + RLeft = atoi(pToken+1); + RRight = atoi(strstr(pToken,":")+1); + pToken = strtok( NULL, " \n\r\t(),;=" ); + continue; + } + if ( pToken[0] == '\\' ) + pToken++; if ( !strcmp(pToken, "assign") ) - Vec_IntPush( vBuffer, ACB_BUF ); + iToken = ACB_BUF; else - Vec_IntPush( vBuffer, iToken ); + iToken = Abc_NamStrFindOrAdd( pNames, pToken, NULL ); + if ( iToken < ACB_UNUSED ) + RLeft = RRight = -1; + else if ( RLeft != -1 ) + { + char Buffer[1000]; + assert( strlen(pToken) < 990 ); + for ( i = RRight; i <= RLeft; i++ ) + { + sprintf( Buffer, "%s[%d]", pToken, i ); + iToken = Abc_NamStrFindOrAdd( pNames, Buffer, NULL ); + Vec_IntPush( vBuffer, iToken ); + } + pToken = strtok( NULL, " \n\r\t(),;=" ); + continue; + } + Vec_IntPush( vBuffer, iToken ); if ( iToken >= ACB_BUF && iToken < ACB_UNUSED ) { for ( pStart = pToken; pStart < pLimit && *pStart != '\n'; pStart++ ) @@ -326,6 +387,178 @@ void * Acb_VerilogSimpleParse( Vec_Int_t * vBuffer, Abc_Nam_t * pNames ) return pDesign; } +/**Function************************************************************* + + Synopsis [] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +int Gia_FileSimpleParse_rec( Gia_Man_t * pNew, int Token, Vec_Int_t * vMapType, Vec_Int_t * vTypes, Vec_Int_t * vFanins, Vec_Int_t * vMap ) +{ + int nFanins, * pFanins, pLits[16]; + int i, Type, Size, Place = Vec_IntEntry( vMapType, Token ); + int iLit = Vec_IntEntry( vMap, Token ); + if ( iLit >= 0 ) + return iLit; + Place = Vec_IntEntry( vMapType, Token ); + assert( Place >= 0 ); + Type = Vec_IntEntry( vTypes, Place ); + Size = Vec_IntEntry( vTypes, Place+1 ); + nFanins = Vec_IntEntry(vTypes, Place+3) - Size - 1; + pFanins = Vec_IntEntryP(vFanins, Size+1); + assert( nFanins > 0 && nFanins < 16 ); + for ( i = 0; i < nFanins; i++ ) + Gia_FileSimpleParse_rec( pNew, pFanins[i], vMapType, vTypes, vFanins, vMap ); + for ( i = 0; i < nFanins; i++ ) + pLits[i] = Vec_IntEntry( vMap, pFanins[i] ); + if ( nFanins == 1 ) + { + assert( Type == ACB_BUF || Type == ACB_NOT ); + iLit = Abc_LitNotCond( pLits[0], Type == ACB_NOT ); + iLit = Gia_ManAppendAnd2( pNew, iLit, iLit ); + } + else + { + iLit = pLits[0]; + if ( Type == ACB_AND || Type == ACB_NAND ) + for ( i = 1; i < nFanins; i++ ) + iLit = Gia_ManAppendAnd2( pNew, iLit, pLits[i] ); + else if ( Type == ACB_OR || Type == ACB_NOR ) + for ( i = 1; i < nFanins; i++ ) + iLit = Gia_ManAppendOr2( pNew, iLit, pLits[i] ); + else if ( Type == ACB_XOR || Type == ACB_XNOR ) + for ( i = 1; i < nFanins; i++ ) + iLit = Gia_ManAppendXor2( pNew, iLit, pLits[i] ); + else assert( 0 ); + iLit = Abc_LitNotCond( iLit, (Type == ACB_NAND || Type == ACB_NOR || Type == ACB_XNOR) ); + } + Vec_IntWriteEntry( vMap, Token, iLit ); + return iLit; +} +Gia_Man_t * Gia_FileSimpleParse( Vec_Int_t * vBuffer, Abc_Nam_t * pNames, int fNames, char * pFileW ) +{ + Gia_Man_t * pNew = NULL; + Vec_Int_t * vInputs = Vec_IntAlloc(100); + Vec_Int_t * vOutputs = Vec_IntAlloc(100); + Vec_Int_t * vWires = Vec_IntAlloc(100); + Vec_Int_t * vTypes = Vec_IntAlloc(100); + Vec_Int_t * vFanins = Vec_IntAlloc(100); + Vec_Int_t * vCur = NULL; + Vec_Int_t * vMap = Vec_IntStartFull( Abc_NamObjNumMax(pNames) ); + Vec_Int_t * vMapType = Vec_IntStartFull( Abc_NamObjNumMax(pNames) ); + int i, iLit, Token, Size; + char Buffer[1000]; + assert( Vec_IntEntry(vBuffer, 0) == ACB_MODULE ); + Vec_IntForEachEntryStart( vBuffer, Token, i, 2 ) + { + if ( vCur == NULL && Token >= ACB_UNUSED ) + continue; + if ( Token == ACB_ENDMODULE ) + break; + if ( Token == ACB_INPUT ) + vCur = vInputs; + else if ( Token == ACB_OUTPUT ) + vCur = vOutputs; + else if ( Token == ACB_WIRE ) + vCur = vWires; + else if ( Token >= ACB_BUF && Token < ACB_UNUSED ) + { + Vec_IntPush( vTypes, Token ); + Vec_IntPush( vTypes, Vec_IntSize(vFanins) ); + vCur = vFanins; + } + else + Vec_IntPush( vCur, Token ); + } + Vec_IntPush( vTypes, -1 ); + Vec_IntPush( vTypes, Vec_IntSize(vFanins) ); + // map types + Vec_IntForEachEntryDouble( vTypes, Token, Size, i ) + if ( Token > 0 ) + Vec_IntWriteEntry( vMapType, Vec_IntEntry(vFanins, Size), i ); + // create design + pNew = Gia_ManStart( 10000 ); + pNew->pName = Abc_UtilStrsav( Abc_NamStr(pNames, Vec_IntEntry(vBuffer, 1)) ); + pNew->fGiaSimple = 1; + if ( (Token = Abc_NamStrFind(pNames, "1\'b0")) ) + Vec_IntWriteEntry( vMap, Token, 0 ); + if ( (Token = Abc_NamStrFind(pNames, "1\'b1")) ) + Vec_IntWriteEntry( vMap, Token, 1 ); + if ( (Token = Abc_NamStrFind(pNames, "1\'bx")) ) + Vec_IntWriteEntry( vMap, Token, 0 ); + if ( (Token = Abc_NamStrFind(pNames, "1\'bz")) ) + Vec_IntWriteEntry( vMap, Token, 0 ); + Vec_IntForEachEntry( vInputs, Token, i ) + Gia_ManAppendCi(pNew); + Vec_IntForEachEntry( vInputs, Token, i ) + Vec_IntWriteEntry( vMap, Token, Gia_ManAppendAnd2(pNew, Gia_ManCiLit(pNew, i), Gia_ManCiLit(pNew, i)) ); + Vec_IntForEachEntry( vOutputs, Token, i ) + Gia_FileSimpleParse_rec( pNew, Token, vMapType, vTypes, vFanins, vMap ); + Vec_IntForEachEntry( vOutputs, Token, i ) + Gia_ManAppendCo( pNew, Vec_IntEntry(vMap, Token) ); + // create names + if ( fNames ) + { + pNew->vNamesNode = Vec_PtrStart( Gia_ManObjNum(pNew) ); + Vec_IntForEachEntry( vMap, iLit, Token ) + { + if ( iLit == -1 || !Gia_ObjIsAnd(Gia_ManObj(pNew, Abc_Lit2Var(iLit))) ) + continue; + sprintf( Buffer, "%c_%s", Abc_LitIsCompl(iLit) ? 'c' : 'd', Abc_NamStr(pNames, Token) ); + assert( Vec_PtrEntry(pNew->vNamesNode, Abc_Lit2Var(iLit)) == NULL ); + Vec_PtrWriteEntry( pNew->vNamesNode, Abc_Lit2Var(iLit), Abc_UtilStrsav(Buffer) ); + } + } + else + { + Gia_Man_t * pTemp; + pNew = Gia_ManDupDfsRehash( pTemp = pNew ); + Gia_ManStop( pTemp ); + } + pNew->vNamesIn = Vec_PtrAlloc( Vec_IntSize(vInputs) ); + Vec_IntForEachEntry( vInputs, Token, i ) + Vec_PtrPush( pNew->vNamesIn, Abc_UtilStrsav(Abc_NamStr(pNames, Token)) ); + pNew->vNamesOut = Vec_PtrAlloc( Vec_IntSize(vOutputs) ); + Vec_IntForEachEntry( vOutputs, Token, i ) + Vec_PtrPush( pNew->vNamesOut, Abc_UtilStrsav(Abc_NamStr(pNames, Token)) ); + if ( pFileW ) + { + extern Vec_Int_t * Acb_ReadWeightMap( char * pFileName, Abc_Nam_t * pNames ); + Vec_Int_t * vT2W = Acb_ReadWeightMap( pFileW, pNames ); + assert( pNew->vWeights == NULL ); + pNew->vWeights = Vec_IntStartFull( Gia_ManObjNum(pNew) ); + Vec_IntForEachEntry( vMap, iLit, Token ) + if ( iLit != -1 && Vec_IntEntry(vT2W, Token) != -1 ) + Vec_IntWriteEntry( pNew->vWeights, Abc_Lit2Var(iLit), Vec_IntEntry(vT2W, Token) ); + Vec_IntFree( vT2W ); + } + // cleanup + Vec_IntFree( vInputs ); + Vec_IntFree( vOutputs ); + Vec_IntFree( vWires ); + Vec_IntFree( vTypes ); + Vec_IntFree( vFanins ); + Vec_IntFree( vMap ); + Vec_IntFree( vMapType ); + return pNew; +} +Gia_Man_t * Gia_FileSimpleRead( char * pFileName, int fNames, char * pFileW ) +{ + Abc_Nam_t * pNames = Acb_VerilogStartNames(); + Vec_Int_t * vBuffer = Acb_VerilogSimpleLex( pFileName, pNames ); + Gia_Man_t * pNew = vBuffer ? Gia_FileSimpleParse( vBuffer, pNames, fNames, pFileW ) : NULL; + assert( pNew->pSpec == NULL ); + pNew->pSpec = Abc_UtilStrsav( pFileName ); + Abc_NamDeref( pNames ); + Vec_IntFree( vBuffer ); + return pNew; +} + /**Function************************************************************* Synopsis [Read weights of nodes from the weight file.] @@ -374,10 +607,18 @@ Vec_Int_t * Acb_ReadWeightMap( char * pFileName, Abc_Nam_t * pNames ) SeeAlso [] ***********************************************************************/ +char ** Acb_PrepareNames( Abc_Nam_t * p ) +{ + char ** ppRes = ABC_CALLOC( char *, Abc_NamObjNumMax(p) ); + int i; + for ( i = 0; i < Abc_NamObjNumMax(p); i++ ) + ppRes[i] = Abc_NamStr( p, i ); + return ppRes; +} Acb_Ntk_t * Acb_VerilogSimpleRead( char * pFileName, char * pFileNameW ) { extern Acb_Ntk_t * Acb_NtkFromNdr( char * pFileName, void * pModule, Abc_Nam_t * pNames, Vec_Int_t * vWeights, int nNameIdMax ); - Acb_Ntk_t * pNtk; + Acb_Ntk_t * pNtk; //char ** ppNames; Abc_Nam_t * pNames = Acb_VerilogStartNames(); Vec_Int_t * vBuffer = Acb_VerilogSimpleLex( pFileName, pNames ); void * pModule = vBuffer ? Acb_VerilogSimpleParse( vBuffer, pNames ) : NULL; @@ -392,7 +633,9 @@ Acb_Ntk_t * Acb_VerilogSimpleRead( char * pFileName, char * pFileNameW ) printf( "Cannot read weight file \"%s\".\n", pFileNameW ); return NULL; } -// Ndr_ModuleWriteVerilog( "iccad17/unit1/test.v", pModule, pNameStrs ); + //ppNames = Acb_PrepareNames(pNames); + //Ndr_WriteVerilog( Extra_FileNameGenericAppend(pFileName, "_ndr.v"), pModule, ppNames, 1 ); + //ABC_FREE( ppNames ); pNtk = Acb_NtkFromNdr( pFileName, pModule, pNames, vWeights, Abc_NamObjNumMax(pNames) ); Ndr_Delete( pModule ); Vec_IntFree( vBuffer ); @@ -400,6 +643,11 @@ Acb_Ntk_t * Acb_VerilogSimpleRead( char * pFileName, char * pFileNameW ) Abc_NamDeref( pNames ); return pNtk; } +void Acb_VerilogSimpleReadTest( char * pFileName ) +{ + Acb_Ntk_t * p = Acb_VerilogSimpleRead( pFileName, NULL ); + Acb_NtkFree( p ); +} /**Function************************************************************* diff --git a/src/base/io/ioReadAiger.c b/src/base/io/ioReadAiger.c index f87d971f..9cf41413 100644 --- a/src/base/io/ioReadAiger.c +++ b/src/base/io/ioReadAiger.c @@ -480,6 +480,7 @@ Abc_Ntk_t * Io_ReadAiger( char * pFileName, int fCheck ) if ( pCur < pContents + nFileSize && *pCur != 'c' ) { int Counter = 0; + int fNodeNames = 0; while ( pCur < pContents + nFileSize && *pCur != 'c' ) { // get the terminal type @@ -490,6 +491,12 @@ Abc_Ntk_t * Io_ReadAiger( char * pFileName, int fCheck ) vTerms = pNtkNew->vBoxes; else if ( *pCur == 'o' || *pCur == 'b' || *pCur == 'c' || *pCur == 'j' || *pCur == 'f' ) vTerms = pNtkNew->vPos; + else if ( *pCur == 'n' ) + { + fNodeNames++; + while ( *pCur++ != '\n' ); + continue; + } else { // fprintf( stdout, "Wrong terminal type.\n" ); @@ -543,6 +550,8 @@ Abc_Ntk_t * Io_ReadAiger( char * pFileName, int fCheck ) } // if ( Counter ) // printf( "Io_ReadAiger(): Added %d default names for nameless I/O/register objects.\n", Counter ); + if ( fNodeNames ) + printf( "Io_ReadAiger(): The names of internal nodes are not supported. Ignoring %d node names.\n", fNodeNames ); } else { -- cgit v1.2.3 From ed9c16d4f5e1484bb287c30a6af50832a62d35ec Mon Sep 17 00:00:00 2001 From: Alan Mishchenko Date: Fri, 3 Sep 2021 18:14:10 -0700 Subject: Additional MiniLUT API. --- src/base/main/abcapis.h | 1 + 1 file changed, 1 insertion(+) (limited to 'src/base') diff --git a/src/base/main/abcapis.h b/src/base/main/abcapis.h index e384896d..1523baad 100644 --- a/src/base/main/abcapis.h +++ b/src/base/main/abcapis.h @@ -80,6 +80,7 @@ extern ABC_DLL void Abc_NtkSetFlopNum( Abc_Frame_t * pAbc, int nFlops ); extern ABC_DLL void Abc_FrameGiaInputMiniLut( Abc_Frame_t * pAbc, void * pMiniLut ); extern ABC_DLL void * Abc_FrameGiaOutputMiniLut( Abc_Frame_t * pAbc ); extern ABC_DLL char * Abc_FrameGiaOutputMiniLutAttr( Abc_Frame_t * pAbc, void * pMiniLut ); +extern ABC_DLL int * Abc_FrameReadMiniLutSwitching( Abc_Frame_t * pAbc ); // procedures to input/output NDR data-structure extern ABC_DLL void Abc_FrameInputNdr( Abc_Frame_t * pAbc, void * pData ); -- cgit v1.2.3 From e7a029d73fbce3145063f0e65b952b356014cf63 Mon Sep 17 00:00:00 2001 From: Alan Mishchenko Date: Sat, 4 Sep 2021 19:21:59 -0700 Subject: Various changes. --- src/base/abc/abcUtil.c | 2 +- src/base/abci/abcFx.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'src/base') diff --git a/src/base/abc/abcUtil.c b/src/base/abc/abcUtil.c index 51d31527..29753210 100644 --- a/src/base/abc/abcUtil.c +++ b/src/base/abc/abcUtil.c @@ -3153,7 +3153,7 @@ Vec_Wec_t * Abc_GiaSynthesize( Vec_Ptr_t * vGias, Gia_Man_t * pMulti ) int i, k, iNode = 0; Abc_FrameReplaceCurrentNetwork( Abc_FrameReadGlobalFrame(), pNtk ); Abc_FrameSetBatchMode( 1 ); - Cmd_CommandExecute( Abc_FrameGetGlobalFrame(), "compress2rs; dch; map -a; strash; compress2rs; dch; map -a; strash; compress2rs; dch; map -a" ); + Cmd_CommandExecute( Abc_FrameGetGlobalFrame(), "clp; sop; fx; strash; compress2rs; dch; map -a; strash; compress2rs; dch; map -a" ); Abc_FrameSetBatchMode( 0 ); pNtkNew = Abc_FrameReadNtk( Abc_FrameReadGlobalFrame() ); vRes = Vec_WecStart( Abc_NtkPiNum(pNtkNew) + Abc_NtkNodeNum(pNtkNew) + Abc_NtkPoNum(pNtkNew) ); diff --git a/src/base/abci/abcFx.c b/src/base/abci/abcFx.c index 60461a4a..487aee3c 100644 --- a/src/base/abci/abcFx.c +++ b/src/base/abci/abcFx.c @@ -201,7 +201,7 @@ void Abc_NtkFxInsert( Abc_Ntk_t * pNtk, Vec_Wec_t * vCubes ) // quit if nothing changes if ( iNodeMax < Abc_NtkObjNumMax(pNtk) ) { - printf( "The network is unchanged by fast extract.\n" ); + //printf( "The network is unchanged by fast extract.\n" ); return; } // create new nodes -- cgit v1.2.3 From 14dc389e625ded1afebf2ea3b9b46e5aaff2c483 Mon Sep 17 00:00:00 2001 From: Alan Mishchenko Date: Mon, 6 Sep 2021 09:53:49 -0700 Subject: Bug fix in the timing manager. --- src/base/abci/abcTiming.c | 58 ++++++++++++++++++++++++----------------------- 1 file changed, 30 insertions(+), 28 deletions(-) (limited to 'src/base') diff --git a/src/base/abci/abcTiming.c b/src/base/abci/abcTiming.c index 2777c9f8..84cda931 100644 --- a/src/base/abci/abcTiming.c +++ b/src/base/abci/abcTiming.c @@ -189,10 +189,8 @@ void Abc_NtkTimeSetDefaultRequired( Abc_Ntk_t * pNtk, float Rise, float Fall ) pNtk->pManTime->tReqDef.Rise = Rise; pNtk->pManTime->tReqDef.Fall = Fall; // set the required times for each output - Abc_NtkForEachCo( pNtk, pObj, i ){ - Abc_NtkTimeSetRequired( pNtk, Abc_ObjId(pObj), Rise, Fall ); - // printf("Debug: Setting *default* required time on object %d to R %f F %f\n", - // Abc_ObjId(pObj),Rise,Fall); + Abc_NtkForEachCo( pNtk, pObj, i ){ + Abc_NtkTimeSetRequired( pNtk, Abc_ObjId(pObj), Rise, Fall ); } } @@ -211,8 +209,7 @@ void Abc_NtkTimeSetArrival( Abc_Ntk_t * pNtk, int ObjId, float Rise, float Fall { Vec_Ptr_t * vTimes; Abc_Time_t * pTime; - static int debug; - debug++; + if ( pNtk->pManTime == NULL ) pNtk->pManTime = Abc_ManTimeStart(pNtk); Abc_ManTimeExpand( pNtk->pManTime, ObjId + 1, 1 ); @@ -221,16 +218,13 @@ void Abc_NtkTimeSetArrival( Abc_Ntk_t * pNtk, int ObjId, float Rise, float Fall pTime = (Abc_Time_t *)vTimes->pArray[ObjId]; pTime->Rise = Rise; pTime->Fall = Fall; - // printf("Debug:%d Setting arrival time on object %d to R %f and F %f\n",debug, - // ObjId, Rise, Fall); + } void Abc_NtkTimeSetRequired( Abc_Ntk_t * pNtk, int ObjId, float Rise, float Fall ) { Vec_Ptr_t * vTimes; Abc_Time_t * pTime; - static int debug; - debug++; if ( pNtk->pManTime == NULL ) pNtk->pManTime = Abc_ManTimeStart(pNtk); Abc_ManTimeExpand( pNtk->pManTime, ObjId + 1, 1 ); @@ -239,8 +233,6 @@ void Abc_NtkTimeSetRequired( Abc_Ntk_t * pNtk, int ObjId, float Rise, float Fall pTime = (Abc_Time_t *)vTimes->pArray[ObjId]; pTime->Rise = Rise; pTime->Fall = Fall; - // printf("Debug:%d Setting required time on object %d to R %f and F %f\n",debug, - // ObjId, Rise, Fall); } /**Function************************************************************* @@ -485,7 +477,7 @@ void Abc_NtkTimePrepare( Abc_Ntk_t * pNtk ) ***********************************************************************/ Abc_ManTime_t * Abc_ManTimeStart( Abc_Ntk_t * pNtk ) { - //int fUseZeroDefaultOutputRequired = 1; + int fUseZeroDefaultOutputRequired = 1; Abc_ManTime_t * p; Abc_Time_t* pTime; Abc_Obj_t * pObj; int i; @@ -496,34 +488,45 @@ Abc_ManTime_t * Abc_ManTimeStart( Abc_Ntk_t * pNtk ) // set default default input=arrivals (assumed to be 0) // set default default output-requireds (can be either 0 or +infinity, based on the flag) - //AF: hack support the values read in. Not defaults ! - - // p->tReqDef.Rise = fUseZeroDefaultOutputRequired ? 0 : ABC_INFINITY; - // p->tReqDef.Fall = fUseZeroDefaultOutputRequired ? 0 : ABC_INFINITY; - // extend manager Abc_ManTimeExpand( p, Abc_NtkObjNumMax(pNtk) + 1, 0 ); // set the default timing for CIs Abc_NtkForEachCi( pNtk, pObj, i ){ + + //get the constrained value, if there is one Vec_Ptr_t * vTimes; vTimes = pNtk->pManTime->vArrs; pTime = (Abc_Time_t *)vTimes->pArray[Abc_ObjId(pObj)]; - if (pTime){ - p->tArrDef.Fall = pTime -> Fall; - p->tArrDef.Rise = pTime -> Rise; + //unconstrained arrival defaults. Note that + //unconstrained value in vTimes set to -ABC_INFINITY. + if (pTime && + (!(p-> tArrDef.Fall == -ABC_INFINITY || + p-> tArrDef.Rise != -ABC_INFINITY )) + ){ + p->tArrDef.Fall = pTime -> Fall; + p->tArrDef.Rise = pTime -> Rise; + } + else { + //use the default arrival time 0 (implicit in memset 0, above). + p->tArrDef.Rise = 0; + p->tArrDef.Fall = 0; } - Abc_NtkTimeSetArrival( pNtk, Abc_ObjId(pObj), p->tArrDef.Rise, p->tArrDef.Rise ); } - - // set the default timing for COs + + Abc_NtkForEachCo( pNtk, pObj, i ){ Vec_Ptr_t * vTimes; vTimes = pNtk->pManTime->vArrs; pTime = (Abc_Time_t *)vTimes->pArray[Abc_ObjId(pObj)]; if (pTime){ - p->tReqDef.Fall = pTime -> Fall; - p->tReqDef.Rise = pTime -> Rise; + p->tReqDef.Fall = pTime -> Fall; + p->tReqDef.Rise = pTime -> Rise; + } + else{ + //use the default + p->tReqDef.Rise = fUseZeroDefaultOutputRequired ? 0 : ABC_INFINITY; + p->tReqDef.Fall = fUseZeroDefaultOutputRequired ? 0 : ABC_INFINITY; } Abc_NtkTimeSetRequired( pNtk, Abc_ObjId(pObj), p->tReqDef.Rise, p->tReqDef.Rise ); } @@ -609,8 +612,7 @@ void Abc_ManTimeDup( Abc_Ntk_t * pNtkOld, Abc_Ntk_t * pNtkNew ) memcpy( pNtkNew->pManTime->tOutLoad, pNtkOld->pManTime->tOutLoad, sizeof(Abc_Time_t) * Abc_NtkCoNum(pNtkOld) ); } - printf("State of abc timing manager\n"); - Abc_NtkTimePrint(pNtkNew); + } /**Function************************************************************* -- cgit v1.2.3 From bafd2a7820553438e919e3c0c4c683e72bb0366e Mon Sep 17 00:00:00 2001 From: Alan Mishchenko Date: Tue, 7 Sep 2021 19:40:57 -0700 Subject: Disabling command print_mint when CUDD is not used. --- src/base/abci/abc.c | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'src/base') diff --git a/src/base/abci/abc.c b/src/base/abci/abc.c index d4155ca6..0fb6fc65 100644 --- a/src/base/abci/abc.c +++ b/src/base/abci/abc.c @@ -86,7 +86,9 @@ static int Abc_CommandPrintMffc ( Abc_Frame_t * pAbc, int argc, cha static int Abc_CommandPrintFactor ( Abc_Frame_t * pAbc, int argc, char ** argv ); static int Abc_CommandPrintLevel ( Abc_Frame_t * pAbc, int argc, char ** argv ); static int Abc_CommandPrintSupport ( Abc_Frame_t * pAbc, int argc, char ** argv ); +#ifdef ABC_USE_CUDD static int Abc_CommandPrintMint ( Abc_Frame_t * pAbc, int argc, char ** argv ); +#endif static int Abc_CommandPrintSymms ( Abc_Frame_t * pAbc, int argc, char ** argv ); static int Abc_CommandPrintUnate ( Abc_Frame_t * pAbc, int argc, char ** argv ); static int Abc_CommandPrintAuto ( Abc_Frame_t * pAbc, int argc, char ** argv ); @@ -827,7 +829,9 @@ void Abc_Init( Abc_Frame_t * pAbc ) Cmd_CommandAdd( pAbc, "Printing", "print_factor", Abc_CommandPrintFactor, 0 ); Cmd_CommandAdd( pAbc, "Printing", "print_level", Abc_CommandPrintLevel, 0 ); Cmd_CommandAdd( pAbc, "Printing", "print_supp", Abc_CommandPrintSupport, 0 ); +#ifdef ABC_USE_CUDD Cmd_CommandAdd( pAbc, "Printing", "print_mint", Abc_CommandPrintMint, 0 ); +#endif Cmd_CommandAdd( pAbc, "Printing", "print_symm", Abc_CommandPrintSymms, 0 ); Cmd_CommandAdd( pAbc, "Printing", "print_unate", Abc_CommandPrintUnate, 0 ); Cmd_CommandAdd( pAbc, "Printing", "print_auto", Abc_CommandPrintAuto, 0 ); @@ -2109,6 +2113,7 @@ usage: SeeAlso [] ***********************************************************************/ +#ifdef ABC_USE_CUDD int Abc_CommandPrintMint( Abc_Frame_t * pAbc, int argc, char ** argv ) { Abc_Ntk_t * pNtk = Abc_FrameReadNtk(pAbc); @@ -2147,6 +2152,7 @@ int Abc_CommandPrintMint( Abc_Frame_t * pAbc, int argc, char ** argv ) Abc_Print( -1, "This command works only for logic networks with local functions represented by BDDs.\n" ); return 1; } + Abc_NtkForEachNode( pNtk, pObj, c ) printf( "ObjId %3d : SuppSize = %5d MintCount = %32.0f\n", c, Abc_ObjFaninNum(pObj), Cudd_CountMinterm((DdManager *)pNtk->pManFunc, (DdNode *)pObj->pData, Abc_ObjFaninNum(pObj)) ); @@ -2159,6 +2165,7 @@ usage: Abc_Print( -2, "\t-h : print the command usage\n"); return 1; } +#endif /**Function************************************************************* -- cgit v1.2.3 From c557272241645ab98d2bb6fa0941a32802e0c765 Mon Sep 17 00:00:00 2001 From: Alan Mishchenko Date: Mon, 13 Sep 2021 09:44:28 -0700 Subject: Enable command 'pipe' for pipelining. --- src/base/abc/abcLatch.c | 15 +++------------ src/base/abci/abc.c | 12 +++++++++--- src/base/abci/abcVerify.c | 3 +++ 3 files changed, 15 insertions(+), 15 deletions(-) (limited to 'src/base') diff --git a/src/base/abc/abcLatch.c b/src/base/abc/abcLatch.c index fcace105..d8432382 100644 --- a/src/base/abc/abcLatch.c +++ b/src/base/abc/abcLatch.c @@ -148,7 +148,7 @@ int Abc_NtkRemoveSelfFeedLatches( Abc_Ntk_t * pNtk ) void Abc_NtkLatchPipe( Abc_Ntk_t * pNtk, int nLatches ) { Vec_Ptr_t * vNodes; - Abc_Obj_t * pObj, * pLatch, * pFanin, * pFanout; + Abc_Obj_t * pObj, * pFanin, * pFanout; int i, k, nTotal, nDigits; if ( nLatches < 1 ) return; @@ -157,18 +157,9 @@ void Abc_NtkLatchPipe( Abc_Ntk_t * pNtk, int nLatches ) vNodes = Vec_PtrAlloc( 100 ); Abc_NtkForEachPi( pNtk, pObj, i ) { - // remember current fanins of the PI Abc_NodeCollectFanouts( pObj, vNodes ); - // create the latches - for ( pFanin = pObj, k = 0; k < nLatches; k++, pFanin = pLatch ) - { - pLatch = Abc_NtkCreateLatch( pNtk ); - Abc_ObjAddFanin( pLatch, pFanin ); - Abc_LatchSetInitDc( pLatch ); - // create the name of the new latch - Abc_ObjAssignName( pLatch, Abc_ObjNameDummy("LL", i*nLatches + k, nDigits), NULL ); - } - // patch the PI fanouts + for ( pFanin = pObj, k = 0; k < nLatches; k++ ) + pFanin = Abc_NtkAddLatch( pNtk, pFanin, ABC_INIT_ZERO ); Vec_PtrForEachEntry( Abc_Obj_t *, vNodes, pFanout, k ) Abc_ObjPatchFanin( pFanout, pObj, pFanin ); } diff --git a/src/base/abci/abc.c b/src/base/abci/abc.c index 0fb6fc65..9853dced 100644 --- a/src/base/abci/abc.c +++ b/src/base/abci/abc.c @@ -1039,7 +1039,7 @@ void Abc_Init( Abc_Frame_t * pAbc ) Cmd_CommandAdd( pAbc, "Sequential", "zero", Abc_CommandZero, 1 ); Cmd_CommandAdd( pAbc, "Sequential", "undc", Abc_CommandUndc, 1 ); Cmd_CommandAdd( pAbc, "Sequential", "onehot", Abc_CommandOneHot, 1 ); -// Cmd_CommandAdd( pAbc, "Sequential", "pipe", Abc_CommandPipe, 1 ); + Cmd_CommandAdd( pAbc, "Sequential", "pipe", Abc_CommandPipe, 1 ); Cmd_CommandAdd( pAbc, "Sequential", "retime", Abc_CommandRetime, 1 ); Cmd_CommandAdd( pAbc, "Sequential", "dretime", Abc_CommandDRetime, 1 ); Cmd_CommandAdd( pAbc, "Sequential", "fretime", Abc_CommandFlowRetime, 1 ); @@ -20530,9 +20530,15 @@ int Abc_CommandPipe( Abc_Frame_t * pAbc, int argc, char ** argv ) return 1; } - if ( Abc_NtkIsComb(pNtk) ) + if ( !Abc_NtkIsLogic(pNtk) ) { - Abc_Print( 0, "The current network is combinational.\n" ); + Abc_Print( 0, "Abc_CommandPipe(): Expecting a logic network (run command \"logic\").\n" ); + return 0; + } + + if ( !Abc_NtkIsComb(pNtk) ) + { + Abc_Print( 0, "Abc_CommandPipe(): Expecting a combinational network.\n" ); return 0; } diff --git a/src/base/abci/abcVerify.c b/src/base/abci/abcVerify.c index 7199c529..f3e86746 100644 --- a/src/base/abci/abcVerify.c +++ b/src/base/abci/abcVerify.c @@ -781,6 +781,8 @@ void Abc_NtkVerifyReportError( Abc_Ntk_t * pNtk1, Abc_Ntk_t * pNtk2, int * pMode Abc_NtkForEachCi( pNtk1, pNode, i ) pNode->pCopy = (Abc_Obj_t *)(ABC_PTRINT_T)i; // print the model + if ( Vec_PtrSize(vNodes) ) + { pNode = (Abc_Obj_t *)Vec_PtrEntry( vNodes, 0 ); if ( Abc_ObjIsCi(pNode) ) { @@ -790,6 +792,7 @@ void Abc_NtkVerifyReportError( Abc_Ntk_t * pNtk1, Abc_Ntk_t * pNtk2, int * pMode printf( " %s=%d", Abc_ObjName(pNode), pModel[(int)(ABC_PTRINT_T)pNode->pCopy] ); } } + } printf( "\n" ); Vec_PtrFree( vNodes ); } -- cgit v1.2.3 From ecda331a2a921bcac30bf3210f56adf9152ca22f Mon Sep 17 00:00:00 2001 From: Alan Mishchenko Date: Tue, 14 Sep 2021 22:01:41 -0700 Subject: Various changes. --- src/base/acb/acbFunc.c | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) (limited to 'src/base') diff --git a/src/base/acb/acbFunc.c b/src/base/acb/acbFunc.c index 5105f463..ee468e88 100644 --- a/src/base/acb/acbFunc.c +++ b/src/base/acb/acbFunc.c @@ -472,6 +472,8 @@ Gia_Man_t * Gia_FileSimpleParse( Vec_Int_t * vBuffer, Abc_Nam_t * pNames, int fN Vec_IntPush( vTypes, Vec_IntSize(vFanins) ); vCur = vFanins; } + else if ( pFileW && vCur == vWires && Abc_NamStr(pNames, Token)[0] == 't' ) + Vec_IntPush( vInputs, Token ); else Vec_IntPush( vCur, Token ); } @@ -526,7 +528,7 @@ Gia_Man_t * Gia_FileSimpleParse( Vec_Int_t * vBuffer, Abc_Nam_t * pNames, int fN pNew->vNamesOut = Vec_PtrAlloc( Vec_IntSize(vOutputs) ); Vec_IntForEachEntry( vOutputs, Token, i ) Vec_PtrPush( pNew->vNamesOut, Abc_UtilStrsav(Abc_NamStr(pNames, Token)) ); - if ( pFileW ) + if ( pFileW && fNames ) { extern Vec_Int_t * Acb_ReadWeightMap( char * pFileName, Abc_Nam_t * pNames ); Vec_Int_t * vT2W = Acb_ReadWeightMap( pFileW, pNames ); @@ -618,7 +620,7 @@ char ** Acb_PrepareNames( Abc_Nam_t * p ) Acb_Ntk_t * Acb_VerilogSimpleRead( char * pFileName, char * pFileNameW ) { extern Acb_Ntk_t * Acb_NtkFromNdr( char * pFileName, void * pModule, Abc_Nam_t * pNames, Vec_Int_t * vWeights, int nNameIdMax ); - Acb_Ntk_t * pNtk; //char ** ppNames; + Acb_Ntk_t * pNtk; Abc_Nam_t * pNames = Acb_VerilogStartNames(); Vec_Int_t * vBuffer = Acb_VerilogSimpleLex( pFileName, pNames ); void * pModule = vBuffer ? Acb_VerilogSimpleParse( vBuffer, pNames ) : NULL; @@ -633,9 +635,12 @@ Acb_Ntk_t * Acb_VerilogSimpleRead( char * pFileName, char * pFileNameW ) printf( "Cannot read weight file \"%s\".\n", pFileNameW ); return NULL; } - //ppNames = Acb_PrepareNames(pNames); - //Ndr_WriteVerilog( Extra_FileNameGenericAppend(pFileName, "_ndr.v"), pModule, ppNames, 1 ); - //ABC_FREE( ppNames ); + if ( 0 ) + { + char ** ppNames = Acb_PrepareNames(pNames); + Ndr_WriteVerilog( Extra_FileNameGenericAppend(pFileName, "_ndr.v"), pModule, ppNames, 1 ); + ABC_FREE( ppNames ); + } pNtk = Acb_NtkFromNdr( pFileName, pModule, pNames, vWeights, Abc_NamObjNumMax(pNames) ); Ndr_Delete( pModule ); Vec_IntFree( vBuffer ); @@ -2391,7 +2396,7 @@ Vec_Str_t * Acb_GeneratePatch2( Gia_Man_t * pGia, Vec_Ptr_t * vIns, Vec_Ptr_t * extern Vec_Wec_t * Abc_GiaSynthesize( Vec_Ptr_t * vGias, Gia_Man_t * pMulti ); Vec_Wec_t * vGates = Abc_GiaSynthesize( NULL, pGia ); Vec_Int_t * vGate; int nIns = Vec_PtrSize(vIns), nOuts = Vec_PtrSize(vOuts); char * pName; - int i, k, iObj, nWires = Vec_WecSize(vGates) - nIns - nOuts, fFirst = 1; + int i, k, iObj, nWires = Vec_WecSize(vGates) - nIns - nOuts, nTwoIns = 0, fFirst = 1; Vec_Ptr_t * vNames = Acb_GenerateSignalNames2( vGates, vIns, vOuts ); Vec_Str_t * vStr = Vec_StrAlloc( 100 ); @@ -2400,7 +2405,7 @@ Vec_Str_t * Acb_GeneratePatch2( Gia_Man_t * pGia, Vec_Ptr_t * vIns, Vec_Ptr_t * Vec_PtrForEachEntry( char *, vOuts, pName, i ) Vec_StrPrintF( vStr, "%s %s", i ? ",":"", pName ); Vec_PtrForEachEntry( char *, vIns, pName, i ) - Vec_StrPrintF( vStr, ", %s", pName ); + Vec_StrPrintF( vStr, ", %s%s", i ? "":" ", pName ); Vec_StrAppend( vStr, " );\n\n" ); Vec_StrAppend( vStr, " output" ); @@ -2422,8 +2427,9 @@ Vec_Str_t * Acb_GeneratePatch2( Gia_Man_t * pGia, Vec_Ptr_t * vIns, Vec_Ptr_t * if ( !strncmp(pName, "ww", 2) ) Vec_StrPrintF( vStr, "%s %s", fFirst ? "":",", pName ), fFirst = 0; } - Vec_StrAppend( vStr, ";\n\n" ); + Vec_StrAppend( vStr, ";\n" ); } + Vec_StrAppend( vStr, "\n" ); // create internal nodes Vec_WecForEachLevelStartStop( vGates, vGate, i, nIns, nIns+nWires ) @@ -2434,6 +2440,7 @@ Vec_Str_t * Acb_GeneratePatch2( Gia_Man_t * pGia, Vec_Ptr_t * vIns, Vec_Ptr_t * Vec_IntForEachEntryStart( vGate, iObj, k, 1 ) Vec_StrPrintF( vStr, "%s %s", k > 1 ? ",":"", (char *)Vec_PtrEntry(vNames, iObj) ); Vec_StrAppend( vStr, " );\n" ); + nTwoIns += Vec_IntSize(vGate) - 3; } else { @@ -2449,7 +2456,7 @@ Vec_Str_t * Acb_GeneratePatch2( Gia_Man_t * pGia, Vec_Ptr_t * vIns, Vec_Ptr_t * Vec_PtrFreeFree( vNames ); Vec_WecFree( vGates ); - printf( "Synthesized patch with %d inputs, %d outputs and %d gates.\n", nIns, nOuts, nWires ); + printf( "Synthesized patch with %d inputs, %d outputs and %d gates (including %d two-input gates).\n", nIns, nOuts, nWires, nTwoIns ); return vStr; } void Acb_GenerateFile2( Gia_Man_t * pGia, Vec_Ptr_t * vIns, Vec_Ptr_t * vOuts, char * pFileName, char * pFileNameOut, int fSkipMffc ) -- cgit v1.2.3 From 997e1a2ddceacf8eaeb32ab1d28143da095b63ce Mon Sep 17 00:00:00 2001 From: Alan Mishchenko Date: Thu, 16 Sep 2021 17:48:57 -0700 Subject: Further debugging of MiniLUT APIs. --- src/base/main/abcapis.h | 1 + 1 file changed, 1 insertion(+) (limited to 'src/base') diff --git a/src/base/main/abcapis.h b/src/base/main/abcapis.h index 1523baad..1bf52a89 100644 --- a/src/base/main/abcapis.h +++ b/src/base/main/abcapis.h @@ -78,6 +78,7 @@ extern ABC_DLL void Abc_NtkSetFlopNum( Abc_Frame_t * pAbc, int nFlops ); // procedures to input/output 'mini LUT' extern ABC_DLL void Abc_FrameGiaInputMiniLut( Abc_Frame_t * pAbc, void * pMiniLut ); +extern ABC_DLL void Abc_FrameGiaInputMiniLut2( Abc_Frame_t * pAbc, void * pMiniLut ); extern ABC_DLL void * Abc_FrameGiaOutputMiniLut( Abc_Frame_t * pAbc ); extern ABC_DLL char * Abc_FrameGiaOutputMiniLutAttr( Abc_Frame_t * pAbc, void * pMiniLut ); extern ABC_DLL int * Abc_FrameReadMiniLutSwitching( Abc_Frame_t * pAbc ); -- cgit v1.2.3 From 6ca31c475f7ae1605be34a0629559db2beef49d1 Mon Sep 17 00:00:00 2001 From: Alan Mishchenko Date: Thu, 16 Sep 2021 21:51:10 -0700 Subject: Improving MiniAIG and name manager. --- src/base/abci/abc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/base') diff --git a/src/base/abci/abc.c b/src/base/abci/abc.c index 9853dced..009843ff 100644 --- a/src/base/abci/abc.c +++ b/src/base/abci/abc.c @@ -30176,7 +30176,7 @@ int Abc_CommandAbc9Read( Abc_Frame_t * pAbc, int argc, char ** argv ) if ( fNewReader ) pAig = Gia_FileSimpleRead( FileName, fGiaSimple, NULL ); else if ( fMiniAig ) - pAig = Gia_ManReadMiniAig( FileName ); + pAig = Gia_ManReadMiniAig( FileName, fGiaSimple || fSkipStrash ); else if ( fMiniAig2 ) pAig = Gia_MiniAigSuperDerive( FileName, fVerbose ); else if ( fMiniLut ) -- cgit v1.2.3 From e2f15482175a06a9aa9056a3a54b2bb05de2721a Mon Sep 17 00:00:00 2001 From: Alan Mishchenko Date: Tue, 21 Sep 2021 10:00:46 -0700 Subject: Various changes. --- src/base/abci/abc.c | 14 +++++++++----- src/base/acb/acbFunc.c | 18 ++++++++++++------ src/base/acb/acbUtil.c | 4 ++-- 3 files changed, 23 insertions(+), 13 deletions(-) (limited to 'src/base') diff --git a/src/base/abci/abc.c b/src/base/abci/abc.c index 009843ff..eb7e50f6 100644 --- a/src/base/abci/abc.c +++ b/src/base/abci/abc.c @@ -7106,11 +7106,11 @@ usage: ***********************************************************************/ int Abc_CommandRunEco( Abc_Frame_t * pAbc, int argc, char ** argv ) { - extern void Acb_NtkRunEco( char * pFileNames[4], int nTimeout, int fCheck, int fRandom, int fInputs, int fVerbose, int fVeryVerbose ); + extern void Acb_NtkRunEco( char * pFileNames[4], int nTimeout, int fCheck, int fRandom, int fInputs, int fUnitW, int fVerbose, int fVeryVerbose ); char * pFileNames[4] = {NULL}; - int c, nTimeout = 0, fCheck = 0, fRandom = 0, fInputs = 0, fVerbose = 0, fVeryVerbose = 0; + int c, nTimeout = 0, fCheck = 0, fRandom = 0, fInputs = 0, fUnitW = 0, fVerbose = 0, fVeryVerbose = 0; Extra_UtilGetoptReset(); - while ( ( c = Extra_UtilGetopt( argc, argv, "Tcrivwh" ) ) != EOF ) + while ( ( c = Extra_UtilGetopt( argc, argv, "Tcriuvwh" ) ) != EOF ) { switch ( c ) { @@ -7134,6 +7134,9 @@ int Abc_CommandRunEco( Abc_Frame_t * pAbc, int argc, char ** argv ) case 'i': fInputs ^= 1; break; + case 'u': + fUnitW ^= 1; + break; case 'v': fVerbose ^= 1; break; @@ -7165,11 +7168,11 @@ int Abc_CommandRunEco( Abc_Frame_t * pAbc, int argc, char ** argv ) fclose( pFile ); pFileNames[c] = argv[globalUtilOptind+c]; } - Acb_NtkRunEco( pFileNames, nTimeout, fCheck, fRandom, fInputs, fVerbose, fVeryVerbose ); + Acb_NtkRunEco( pFileNames, nTimeout, fCheck, fRandom, fInputs, fUnitW, fVerbose, fVeryVerbose ); return 0; usage: - Abc_Print( -2, "usage: runeco [-T num] [-crivwh] \n" ); + Abc_Print( -2, "usage: runeco [-T num] [-criuvwh] \n" ); Abc_Print( -2, "\t performs computation of patch functions during ECO,\n" ); Abc_Print( -2, "\t as described in the following paper: A. Q. Dao et al\n" ); Abc_Print( -2, "\t \"Efficient computation of ECO patch functions\", Proc. DAC\'18\n" ); @@ -7181,6 +7184,7 @@ usage: Abc_Print( -2, "\t-c : toggle checking that the problem has a solution [default = %s]\n", fCheck? "yes": "no" ); Abc_Print( -2, "\t-r : toggle using random permutation of support variables [default = %s]\n", fRandom? "yes": "no" ); Abc_Print( -2, "\t-i : toggle using primary inputs as support variables [default = %s]\n", fInputs? "yes": "no" ); + Abc_Print( -2, "\t-u : toggle using unit weights [default = %s]\n", fUnitW? "yes": "no" ); Abc_Print( -2, "\t-v : toggle printing verbose information [default = %s]\n", fVerbose? "yes": "no" ); Abc_Print( -2, "\t-w : toggle printing more verbose information [default = %s]\n", fVeryVerbose? "yes": "no" ); Abc_Print( -2, "\t-h : print the command usage\n"); diff --git a/src/base/acb/acbFunc.c b/src/base/acb/acbFunc.c index ee468e88..a1d6568c 100644 --- a/src/base/acb/acbFunc.c +++ b/src/base/acb/acbFunc.c @@ -854,12 +854,18 @@ Vec_Int_t * Acb_NtkFindDivsCis( Acb_Ntk_t * p, Vec_Int_t * vSupp ) printf( "Divisors are %d support variables (CIs in the TFO of the targets).\n", Vec_IntSize(vSupp) ); return vDivs; } -Vec_Int_t * Acb_NtkFindDivs( Acb_Ntk_t * p, Vec_Int_t * vSupp, Vec_Bit_t * vBlock, int fVerbose ) +Vec_Int_t * Acb_NtkFindDivs( Acb_Ntk_t * p, Vec_Int_t * vSupp, Vec_Bit_t * vBlock, int fUnitW, int fVerbose ) { int fPrintWeights = 0; int nDivLimit = 5000; int i, iObj; Vec_Int_t * vDivs = Vec_IntAlloc( 1000 ); + if ( fUnitW ) + { + Acb_NtkForEachNode( p, iObj ) + if ( Acb_ObjWeight(p, iObj) > 0 ) + Vec_IntWriteEntry( &p->vObjWeight, iObj, 1 ); + } // mark inputs Acb_NtkIncTravId( p ); Acb_NtkForEachCiVec( vSupp, p, iObj, i ) @@ -2863,7 +2869,7 @@ Vec_Ptr_t * Acb_TransformPatchFunctions( Vec_Ptr_t * vSops, Vec_Wec_t * vSupps, SeeAlso [] ***********************************************************************/ -int Acb_NtkEcoPerform( Acb_Ntk_t * pNtkF, Acb_Ntk_t * pNtkG, char * pFileName[4], int nTimeout, int fCisOnly, int fInputs, int fCheck, int fVerbose, int fVeryVerbose ) +int Acb_NtkEcoPerform( Acb_Ntk_t * pNtkF, Acb_Ntk_t * pNtkG, char * pFileName[4], int nTimeout, int fCisOnly, int fInputs, int fCheck, int fUnitW, int fVerbose, int fVeryVerbose ) { extern Gia_Man_t * Abc_SopSynthesizeOne( char * pSop, int fClp ); @@ -2879,7 +2885,7 @@ int Acb_NtkEcoPerform( Acb_Ntk_t * pNtkF, Acb_Ntk_t * pNtkG, char * pFileName[4] Vec_Int_t * vSuppF = Acb_NtkFindSupp( pNtkF, vRoots ); Vec_Int_t * vSuppG = Acb_NtkFindSupp( pNtkG, vRoots ); Vec_Int_t * vSupp = Vec_IntTwoMerge( vSuppF, vSuppG ); - Vec_Int_t * vDivs = (fCisOnly || fInputs) ? Acb_NtkFindDivsCis( pNtkF, vSupp ) : Acb_NtkFindDivs( pNtkF, vSupp, vBlock, fVerbose ); + Vec_Int_t * vDivs = (fCisOnly || fInputs) ? Acb_NtkFindDivsCis( pNtkF, vSupp ) : Acb_NtkFindDivs( pNtkF, vSupp, vBlock, fUnitW, fVerbose ); Vec_Int_t * vNodesF = Acb_NtkFindNodes( pNtkF, vRoots, vDivs ); Vec_Int_t * vNodesG = Acb_NtkFindNodes( pNtkG, vRoots, NULL ); @@ -3129,7 +3135,7 @@ void Acb_NtkTestRun2( char * pFileNames[3], int fVerbose ) SeeAlso [] ***********************************************************************/ -void Acb_NtkRunEco( char * pFileNames[4], int nTimeout, int fCheck, int fRandom, int fInputs, int fVerbose, int fVeryVerbose ) +void Acb_NtkRunEco( char * pFileNames[4], int nTimeout, int fCheck, int fRandom, int fInputs, int fUnitW, int fVerbose, int fVeryVerbose ) { char Command[1000]; int Result = 1; Acb_Ntk_t * pNtkF = Acb_VerilogSimpleRead( pFileNames[0], pFileNames[2] ); @@ -3151,10 +3157,10 @@ void Acb_NtkRunEco( char * pFileNames[4], int nTimeout, int fCheck, int fRandom, Acb_IntallLibrary( Abc_FrameReadSignalNames() != NULL ); - if ( !Acb_NtkEcoPerform( pNtkF, pNtkG, pFileNames, nTimeout, 0, fInputs, fCheck, fVerbose, fVeryVerbose ) ) + if ( !Acb_NtkEcoPerform( pNtkF, pNtkG, pFileNames, nTimeout, 0, fInputs, fCheck, fUnitW, fVerbose, fVeryVerbose ) ) { // printf( "General computation timed out. Trying inputs only.\n\n" ); -// if ( !Acb_NtkEcoPerform( pNtkF, pNtkG, pFileNames, nTimeout, 1, fInputs, fCheck, fVerbose, fVeryVerbose ) ) +// if ( !Acb_NtkEcoPerform( pNtkF, pNtkG, pFileNames, nTimeout, 1, fInputs, fCheck, fUnitW, fVerbose, fVeryVerbose ) ) // printf( "Input-only computation also timed out.\n\n" ); printf( "Computation did not succeed.\n" ); Result = 0; diff --git a/src/base/acb/acbUtil.c b/src/base/acb/acbUtil.c index d0d53e18..b6adb6b3 100644 --- a/src/base/acb/acbUtil.c +++ b/src/base/acb/acbUtil.c @@ -1273,10 +1273,10 @@ void Acb_Ntk4DumpWeights( char * pFileNameIn, Vec_Ptr_t * vObjNames, char * pFil void Acb_NtkRunSim( char * pFileName[4], int nTimeout, int nWords, int nBeam, int LevL, int LevU, int fOrder, int fFancy, int fUseBuf, int fRandom, int fUseWeights, int fInputs, int fSkipMffc, int fVerbose, int fVeryVerbose ) { extern int Gia_Sim4Try( char * pFileName0, char * pFileName1, char * pFileName2, int nTimeout, int nWords, int nBeam, int LevL, int LevU, int fOrder, int fFancy, int fUseBuf, int fSkipMffc, int fVerbose ); - extern void Acb_NtkRunEco( char * pFileNames[4], int nTimeout, int fCheck, int fRandom, int fInputs, int fVerbose, int fVeryVerbose ); + extern void Acb_NtkRunEco( char * pFileNames[4], int nTimeout, int fCheck, int fRandom, int fInputs, int fUnitW, int fVerbose, int fVeryVerbose ); char * pFileNames[4] = { pFileName[2], pFileName[1], fUseWeights ? (char *)"weights.txt" : NULL, pFileName[2] }; if ( Gia_Sim4Try( pFileName[0], pFileName[1], pFileName[2], nTimeout, nWords, nBeam, LevL, LevU, fOrder, fFancy, fUseBuf, fSkipMffc, fVerbose ) ) - Acb_NtkRunEco( pFileNames, nTimeout, 1, fRandom, fInputs, fVerbose, fVeryVerbose ); + Acb_NtkRunEco( pFileNames, nTimeout, 1, fRandom, fInputs, 0, fVerbose, fVeryVerbose ); } -- cgit v1.2.3 From a36325609845c7114541dd23ccb7dae3137f3fd4 Mon Sep 17 00:00:00 2001 From: Alan Mishchenko Date: Tue, 21 Sep 2021 10:08:04 -0700 Subject: Removing unused command. --- src/base/abci/abc.c | 155 ----------------------------------------------- src/base/main/mainInit.c | 2 - 2 files changed, 157 deletions(-) (limited to 'src/base') diff --git a/src/base/abci/abc.c b/src/base/abci/abc.c index eb7e50f6..50edfcbf 100644 --- a/src/base/abci/abc.c +++ b/src/base/abci/abc.c @@ -140,7 +140,6 @@ static int Abc_CommandTestRPO ( Abc_Frame_t * pAbc, int argc, cha static int Abc_CommandTestTruth ( 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_CommandRunSim ( 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 ); @@ -883,7 +882,6 @@ void Abc_Init( Abc_Frame_t * pAbc ) Cmd_CommandAdd( pAbc, "Synthesis", "testtruth", Abc_CommandTestTruth, 0 ); Cmd_CommandAdd( pAbc, "Synthesis", "runeco", Abc_CommandRunEco, 0 ); Cmd_CommandAdd( pAbc, "Synthesis", "rungen", Abc_CommandRunGen, 0 ); - Cmd_CommandAdd( pAbc, "Synthesis", "runsim", Abc_CommandRunSim, 0 ); Cmd_CommandAdd( pAbc, "Synthesis", "xec", Abc_CommandRunTest, 0 ); Cmd_CommandAdd( pAbc, "Synthesis", "rewrite", Abc_CommandRewrite, 1 ); @@ -7240,159 +7238,6 @@ usage: return 1; } -/**Function************************************************************* - - Synopsis [] - - Description [] - - SideEffects [] - - SeeAlso [] - -***********************************************************************/ -int Abc_CommandRunSim( Abc_Frame_t * pAbc, int argc, char ** argv ) -{ - extern void Acb_NtkRunSim( char * pFileName[4], int nTimeout, int nWords, int nBeam, int LevL, int LevU, int fOrder, int fFancy, int fUseBuf, int fRandom, int fUseWeights, int fInputs, int fSkipMffc, int fVerbose, int fVeryVerbose ); - char * pFileNames[4] = {NULL, NULL, "out.v", NULL}; - int c, nTimeout = 0, nWords = 8, nBeam = 4, LevL = -1, LevU = -1, fOrder = 0, fFancy = 0, fUseBuf = 0, fRandom = 0, fUseWeights = 0, fInputs = 0, fSkipMffc = 0, fVerbose = 0, fVeryVerbose = 0; - Extra_UtilGetoptReset(); - while ( ( c = Extra_UtilGetopt( argc, argv, "TWBLUofbruimvwh" ) ) != EOF ) - { - switch ( c ) - { - case 'T': - if ( globalUtilOptind >= argc ) - { - Abc_Print( -1, "Command line switch \"-T\" should be followed by an integer.\n" ); - goto usage; - } - nTimeout = atoi(argv[globalUtilOptind]); - globalUtilOptind++; - if ( nTimeout < 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; - } - nWords = atoi(argv[globalUtilOptind]); - globalUtilOptind++; - if ( nWords < 0 ) - goto usage; - break; - case 'B': - if ( globalUtilOptind >= argc ) - { - Abc_Print( -1, "Command line switch \"-B\" should be followed by an integer.\n" ); - goto usage; - } - nBeam = atoi(argv[globalUtilOptind]); - globalUtilOptind++; - if ( nBeam < 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; - } - LevL = atoi(argv[globalUtilOptind]); - globalUtilOptind++; - if ( LevL < 0 ) - goto usage; - break; - case 'U': - if ( globalUtilOptind >= argc ) - { - Abc_Print( -1, "Command line switch \"-U\" should be followed by an integer.\n" ); - goto usage; - } - LevU = atoi(argv[globalUtilOptind]); - globalUtilOptind++; - if ( LevU < 0 ) - goto usage; - break; - case 'o': - fOrder ^= 1; - break; - case 'f': - fFancy ^= 1; - break; - case 'b': - fUseBuf ^= 1; - break; - case 'r': - fRandom ^= 1; - break; - case 'u': - fUseWeights ^= 1; - break; - case 'i': - fInputs ^= 1; - break; - case 'm': - fSkipMffc ^= 1; - break; - case 'v': - fVerbose ^= 1; - break; - case 'w': - fVeryVerbose ^= 1; - break; - case 'h': - goto usage; - default: - goto usage; - } - } - if ( argc - globalUtilOptind < 2 || argc - globalUtilOptind > 4 ) - { - Abc_Print( 1, "Expecting two or three file names on the command line.\n" ); - goto usage; - } - Gia_ManRandom(1); - for ( c = 0; c < argc - globalUtilOptind; c++ ) - pFileNames[c] = argv[globalUtilOptind+c]; - for ( c = 0; c < argc - globalUtilOptind - 1; c++ ) - { - FILE * pFile = fopen( pFileNames[c], "rb" ); - if ( pFile == NULL ) - { - printf( "Cannot open input file \"%s\".\n", pFileNames[c] ); - return 0; - } - else - fclose( pFile ); - } - Acb_NtkRunSim( pFileNames, nTimeout, nWords, nBeam, LevL, LevU, fOrder, fFancy, fUseBuf, fRandom, fUseWeights, fInputs, fSkipMffc, fVerbose, fVeryVerbose ); - return 0; - -usage: - Abc_Print( -2, "usage: runsim [-TWBLU] [-ofbruimvwh] [-N ] \n" ); - Abc_Print( -2, "\t experimental simulation command\n" ); - Abc_Print( -2, "\t-T : the timeout in seconds [default = %d]\n", nTimeout ); - Abc_Print( -2, "\t-W : the number of words of simulation info [default = %d]\n", nWords ); - Abc_Print( -2, "\t-B : the beam width parameter [default = %d]\n", nBeam ); - Abc_Print( -2, "\t-L : the lower bound on level [default = %d]\n", LevL ); - Abc_Print( -2, "\t-U : the upper bound on level [default = %d]\n", LevU ); - Abc_Print( -2, "\t-o : toggle using a different node ordering [default = %s]\n", fOrder? "yes": "no" ); - Abc_Print( -2, "\t-f : toggle using experimental feature [default = %s]\n", fFancy? "yes": "no" ); - Abc_Print( -2, "\t-b : toggle using buffers [default = %s]\n", fUseBuf? "yes": "no" ); - Abc_Print( -2, "\t-r : toggle using random permutation of support variables [default = %s]\n", fRandom? "yes": "no" ); - Abc_Print( -2, "\t-u : toggle using topological info to select support variables [default = %s]\n", fUseWeights? "yes": "no" ); - Abc_Print( -2, "\t-i : toggle using primary inputs as support variables [default = %s]\n", fInputs? "yes": "no" ); - Abc_Print( -2, "\t-m : toggle MFFC nodes as candidate divisors [default = %s]\n", fSkipMffc? "yes": "no" ); - Abc_Print( -2, "\t-v : toggle printing verbose information [default = %s]\n", fVerbose? "yes": "no" ); - Abc_Print( -2, "\t-w : toggle printing more verbose information [default = %s]\n", fVeryVerbose? "yes": "no" ); - Abc_Print( -2, "\t-h : print the command usage\n"); - return 1; -} - - /**Function************************************************************* Synopsis [] diff --git a/src/base/main/mainInit.c b/src/base/main/mainInit.c index d7ab7ae2..693cea90 100644 --- a/src/base/main/mainInit.c +++ b/src/base/main/mainInit.c @@ -119,7 +119,6 @@ void Abc_FrameInit( Abc_Frame_t * pAbc ) Bac_Init( pAbc ); Cba_Init( pAbc ); Pla_Init( pAbc ); - Sim_Init( pAbc ); Test_Init( pAbc ); Glucose_Init( pAbc ); Glucose2_Init( pAbc ); @@ -160,7 +159,6 @@ void Abc_FrameEnd( Abc_Frame_t * pAbc ) Bac_End( pAbc ); Cba_End( pAbc ); Pla_End( pAbc ); - Sim_End( pAbc ); Test_End( pAbc ); Glucose_End( pAbc ); } -- cgit v1.2.3 From 1e69e7e7d101cca19dcdca6b61d7ca9a1237283c Mon Sep 17 00:00:00 2001 From: Alan Mishchenko Date: Tue, 21 Sep 2021 10:22:40 -0700 Subject: Adding command &reshape. --- src/base/abci/abc.c | 63 ++++++++++++++++++++++++++++++++++++++++++++++++++ src/base/acb/acbUtil.c | 21 ----------------- 2 files changed, 63 insertions(+), 21 deletions(-) (limited to 'src/base') diff --git a/src/base/abci/abc.c b/src/base/abci/abc.c index 50edfcbf..8ff96d99 100644 --- a/src/base/abci/abc.c +++ b/src/base/abci/abc.c @@ -445,6 +445,7 @@ static int Abc_CommandAbc9Extract ( Abc_Frame_t * pAbc, int argc, cha static int Abc_CommandAbc9Balance ( Abc_Frame_t * pAbc, int argc, char ** argv ); static int Abc_CommandAbc9BalanceLut ( Abc_Frame_t * pAbc, int argc, char ** argv ); static int Abc_CommandAbc9Resub ( Abc_Frame_t * pAbc, int argc, char ** argv ); +static int Abc_CommandAbc9Reshape ( Abc_Frame_t * pAbc, int argc, char ** argv ); static int Abc_CommandAbc9Syn2 ( Abc_Frame_t * pAbc, int argc, char ** argv ); static int Abc_CommandAbc9Syn3 ( Abc_Frame_t * pAbc, int argc, char ** argv ); static int Abc_CommandAbc9Syn4 ( Abc_Frame_t * pAbc, int argc, char ** argv ); @@ -1186,6 +1187,7 @@ void Abc_Init( Abc_Frame_t * pAbc ) Cmd_CommandAdd( pAbc, "ABC9", "&b", Abc_CommandAbc9Balance, 0 ); Cmd_CommandAdd( pAbc, "ABC9", "&blut", Abc_CommandAbc9BalanceLut, 0 ); Cmd_CommandAdd( pAbc, "ABC9", "&resub", Abc_CommandAbc9Resub, 0 ); + Cmd_CommandAdd( pAbc, "ABC9", "&reshape", Abc_CommandAbc9Reshape, 0 ); Cmd_CommandAdd( pAbc, "ABC9", "&syn2", Abc_CommandAbc9Syn2, 0 ); Cmd_CommandAdd( pAbc, "ABC9", "&syn3", Abc_CommandAbc9Syn3, 0 ); Cmd_CommandAdd( pAbc, "ABC9", "&syn4", Abc_CommandAbc9Syn4, 0 ); @@ -35483,6 +35485,67 @@ usage: return 1; } +/**Function************************************************************* + + Synopsis [] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +int Abc_CommandAbc9Reshape( Abc_Frame_t * pAbc, int argc, char ** argv ) +{ + extern Gia_Man_t * Gia_ManReshape1( Gia_Man_t * pGia, int fVerbose, int fVeryVerbose ); + extern Gia_Man_t * Gia_ManReshape2( Gia_Man_t * pGia, int fVerbose, int fVeryVerbose ); + Gia_Man_t * pTemp; + int fUseReshape1 = 0; + int c, fVerbose = 0; + int fVeryVerbose = 0; + Extra_UtilGetoptReset(); + while ( ( c = Extra_UtilGetopt( argc, argv, "avwh" ) ) != EOF ) + { + switch ( c ) + { + case 'a': + fUseReshape1 ^= 1; + break; + case 'v': + fVerbose ^= 1; + break; + case 'w': + fVeryVerbose ^= 1; + break; + case 'h': + goto usage; + default: + goto usage; + } + } + if ( pAbc->pGia == NULL ) + { + Abc_Print( -1, "Abc_CommandAbc9Resub(): There is no AIG.\n" ); + return 1; + } + if ( fUseReshape1 ) + pTemp = Gia_ManReshape1( pAbc->pGia, fVerbose, fVeryVerbose ); + else + pTemp = Gia_ManReshape2( pAbc->pGia, fVerbose, fVeryVerbose ); + Abc_FrameUpdateGia( pAbc, pTemp ); + return 0; + +usage: + Abc_Print( -2, "usage: &reshape [-avwh]\n" ); + Abc_Print( -2, "\t performs AIG resubstitution\n" ); + Abc_Print( -2, "\t-a : toggles selecting the algorithm [default = %s]\n", fUseReshape1? "yes": "no" ); + Abc_Print( -2, "\t-v : toggles printing verbose information [default = %s]\n", fVerbose? "yes": "no" ); + Abc_Print( -2, "\t-w : toggles printing additional information [default = %s]\n", fVeryVerbose? "yes": "no" ); + Abc_Print( -2, "\t-h : print the command usage\n"); + return 1; +} + /**Function************************************************************* Synopsis [] diff --git a/src/base/acb/acbUtil.c b/src/base/acb/acbUtil.c index b6adb6b3..ef106e86 100644 --- a/src/base/acb/acbUtil.c +++ b/src/base/acb/acbUtil.c @@ -1259,27 +1259,6 @@ void Acb_Ntk4DumpWeights( char * pFileNameIn, Vec_Ptr_t * vObjNames, char * pFil Vec_IntFree( vObjs ); } -/**Function************************************************************* - - Synopsis [] - - Description [] - - SideEffects [] - - SeeAlso [] - -***********************************************************************/ -void Acb_NtkRunSim( char * pFileName[4], int nTimeout, int nWords, int nBeam, int LevL, int LevU, int fOrder, int fFancy, int fUseBuf, int fRandom, int fUseWeights, int fInputs, int fSkipMffc, int fVerbose, int fVeryVerbose ) -{ - extern int Gia_Sim4Try( char * pFileName0, char * pFileName1, char * pFileName2, int nTimeout, int nWords, int nBeam, int LevL, int LevU, int fOrder, int fFancy, int fUseBuf, int fSkipMffc, int fVerbose ); - extern void Acb_NtkRunEco( char * pFileNames[4], int nTimeout, int fCheck, int fRandom, int fInputs, int fUnitW, int fVerbose, int fVeryVerbose ); - char * pFileNames[4] = { pFileName[2], pFileName[1], fUseWeights ? (char *)"weights.txt" : NULL, pFileName[2] }; - if ( Gia_Sim4Try( pFileName[0], pFileName[1], pFileName[2], nTimeout, nWords, nBeam, LevL, LevU, fOrder, fFancy, fUseBuf, fSkipMffc, fVerbose ) ) - Acb_NtkRunEco( pFileNames, nTimeout, 1, fRandom, fInputs, 0, fVerbose, fVeryVerbose ); -} - - //////////////////////////////////////////////////////////////////////// /// END OF FILE /// //////////////////////////////////////////////////////////////////////// -- cgit v1.2.3 From cc13d1fb472957d7798165774c6df386433a3d2b Mon Sep 17 00:00:00 2001 From: Alan Mishchenko Date: Tue, 21 Sep 2021 10:50:10 -0700 Subject: Adding command &reshape. --- src/base/abci/abc.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) (limited to 'src/base') diff --git a/src/base/abci/abc.c b/src/base/abci/abc.c index 8ff96d99..43d91cfd 100644 --- a/src/base/abci/abc.c +++ b/src/base/abci/abc.c @@ -35498,20 +35498,24 @@ usage: ***********************************************************************/ int Abc_CommandAbc9Reshape( Abc_Frame_t * pAbc, int argc, char ** argv ) { - extern Gia_Man_t * Gia_ManReshape1( Gia_Man_t * pGia, int fVerbose, int fVeryVerbose ); - extern Gia_Man_t * Gia_ManReshape2( Gia_Man_t * pGia, int fVerbose, int fVeryVerbose ); + extern Gia_Man_t * Gia_ManReshape1( Gia_Man_t * pGia, int fUseSimple, int fVerbose, int fVeryVerbose ); + extern Gia_Man_t * Gia_ManReshape2( Gia_Man_t * pGia, int fUseSimple, int fVerbose, int fVeryVerbose ); Gia_Man_t * pTemp; int fUseReshape1 = 0; + int fUseSimple = 0; int c, fVerbose = 0; int fVeryVerbose = 0; Extra_UtilGetoptReset(); - while ( ( c = Extra_UtilGetopt( argc, argv, "avwh" ) ) != EOF ) + while ( ( c = Extra_UtilGetopt( argc, argv, "asvwh" ) ) != EOF ) { switch ( c ) { case 'a': fUseReshape1 ^= 1; break; + case 's': + fUseSimple ^= 1; + break; case 'v': fVerbose ^= 1; break; @@ -35530,16 +35534,17 @@ int Abc_CommandAbc9Reshape( Abc_Frame_t * pAbc, int argc, char ** argv ) return 1; } if ( fUseReshape1 ) - pTemp = Gia_ManReshape1( pAbc->pGia, fVerbose, fVeryVerbose ); + pTemp = Gia_ManReshape1( pAbc->pGia, fUseSimple, fVerbose, fVeryVerbose ); else - pTemp = Gia_ManReshape2( pAbc->pGia, fVerbose, fVeryVerbose ); + pTemp = Gia_ManReshape2( pAbc->pGia, fUseSimple, fVerbose, fVeryVerbose ); Abc_FrameUpdateGia( pAbc, pTemp ); return 0; usage: - Abc_Print( -2, "usage: &reshape [-avwh]\n" ); + Abc_Print( -2, "usage: &reshape [-asvwh]\n" ); Abc_Print( -2, "\t performs AIG resubstitution\n" ); Abc_Print( -2, "\t-a : toggles selecting the algorithm [default = %s]\n", fUseReshape1? "yes": "no" ); + Abc_Print( -2, "\t-s : toggles using simple method [default = %s]\n", fUseSimple? "yes": "no" ); Abc_Print( -2, "\t-v : toggles printing verbose information [default = %s]\n", fVerbose? "yes": "no" ); Abc_Print( -2, "\t-w : toggles printing additional information [default = %s]\n", fVeryVerbose? "yes": "no" ); Abc_Print( -2, "\t-h : print the command usage\n"); -- cgit v1.2.3 From 787dbb9433e2757d087db55217194bad4773c0de Mon Sep 17 00:00:00 2001 From: Alan Mishchenko Date: Sun, 26 Sep 2021 11:05:48 -0700 Subject: Two rare corner-case bugs in &if mapper. --- src/base/abci/abcIf.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'src/base') diff --git a/src/base/abci/abcIf.c b/src/base/abci/abcIf.c index ab88c5e2..491e2c14 100644 --- a/src/base/abci/abcIf.c +++ b/src/base/abci/abcIf.c @@ -230,9 +230,13 @@ If_Man_t * Abc_NtkToIf( Abc_Ntk_t * pNtk, If_Par_t * pPars ) Abc_AigConst1(pNtk)->pCopy = (Abc_Obj_t *)If_ManConst1( pIfMan ); Abc_NtkForEachCi( pNtk, pNode, i ) { - pNode->pCopy = (Abc_Obj_t *)If_ManCreateCi( pIfMan ); + If_Obj_t * pIfObj = If_ManCreateCi( pIfMan ); + pNode->pCopy = (Abc_Obj_t *)pIfObj; // transfer logic level information Abc_ObjIfCopy(pNode)->Level = pNode->Level; + // mark the largest level + if ( pIfMan->nLevelMax < (int)pIfObj->Level ) + pIfMan->nLevelMax = (int)pIfObj->Level; } // load the AIG into the mapper -- cgit v1.2.3 From ba64e78608064612db61d6515f19dd2cabe69cee Mon Sep 17 00:00:00 2001 From: Alan Mishchenko Date: Sun, 26 Sep 2021 11:30:54 -0700 Subject: Changing declaration of Vec_Ptr_t sorting function to satisfy some compilers. --- src/base/abc/abcCheck.c | 4 ++-- src/base/abc/abcFanOrder.c | 4 ++-- src/base/abc/abcHie.c | 2 +- src/base/abc/abcHieNew.c | 4 ++-- src/base/abc/abcMinBase.c | 2 +- src/base/abci/abcBalance.c | 2 +- src/base/abci/abcDar.c | 2 +- src/base/abci/abcLutmin.c | 2 +- src/base/abci/abcMffc.c | 2 +- src/base/abci/abcNpnSave.c | 2 +- src/base/abci/abcStrash.c | 2 +- src/base/abci/abcSweep.c | 2 +- src/base/cba/cbaNtk.c | 2 +- src/base/wlc/wlcAbs.c | 8 ++++---- 14 files changed, 20 insertions(+), 20 deletions(-) (limited to 'src/base') diff --git a/src/base/abc/abcCheck.c b/src/base/abc/abcCheck.c index 3e978bf0..a7448530 100644 --- a/src/base/abc/abcCheck.c +++ b/src/base/abc/abcCheck.c @@ -865,7 +865,7 @@ int Abc_NtkCheckUniqueCiNames( Abc_Ntk_t * pNtk ) vNames = Vec_PtrAlloc( Abc_NtkCiNum(pNtk) ); Abc_NtkForEachCi( pNtk, pObj, i ) Vec_PtrPush( vNames, Abc_ObjName(pObj) ); - Vec_PtrSort( vNames, (int (*)())Abc_NtkNamesCompare ); + Vec_PtrSort( vNames, (int (*)(const void *, const void *))Abc_NtkNamesCompare ); for ( i = 1; i < Abc_NtkCiNum(pNtk); i++ ) if ( !strcmp( (const char *)Vec_PtrEntry(vNames,i-1), (const char *)Vec_PtrEntry(vNames,i) ) ) { @@ -896,7 +896,7 @@ int Abc_NtkCheckUniqueCoNames( Abc_Ntk_t * pNtk ) vNames = Vec_PtrAlloc( Abc_NtkCoNum(pNtk) ); Abc_NtkForEachCo( pNtk, pObj, i ) Vec_PtrPush( vNames, Abc_ObjName(pObj) ); - Vec_PtrSort( vNames, (int (*)())Abc_NtkNamesCompare ); + Vec_PtrSort( vNames, (int (*)(const void *, const void *))Abc_NtkNamesCompare ); for ( i = 1; i < Abc_NtkCoNum(pNtk); i++ ) { // printf( "%s\n", Vec_PtrEntry(vNames,i) ); diff --git a/src/base/abc/abcFanOrder.c b/src/base/abc/abcFanOrder.c index 12df7d85..949170aa 100644 --- a/src/base/abc/abcFanOrder.c +++ b/src/base/abc/abcFanOrder.c @@ -476,9 +476,9 @@ void Abc_NodeSortCubes( Abc_Obj_t * pNode, Vec_Ptr_t * vCubes, Vec_Str_t * vStor Vec_PtrPush( vCubes, pCube ); } if ( fWeight ) - Vec_PtrSort( vCubes, (int (*)())Abc_NodeCompareCubes2 ); + Vec_PtrSort( vCubes, (int (*)(const void *, const void *))Abc_NodeCompareCubes2 ); else - Vec_PtrSort( vCubes, (int (*)())Abc_NodeCompareCubes1 ); + Vec_PtrSort( vCubes, (int (*)(const void *, const void *))Abc_NodeCompareCubes1 ); Vec_StrGrow( vStore, Vec_PtrSize(vCubes) * (nVars + 3) ); pPivot = Vec_StrArray( vStore ); Vec_PtrForEachEntry( char *, vCubes, pCube, i ) diff --git a/src/base/abc/abcHie.c b/src/base/abc/abcHie.c index 8397301f..bd08c35d 100644 --- a/src/base/abc/abcHie.c +++ b/src/base/abc/abcHie.c @@ -442,7 +442,7 @@ void Abc_NtkPrintBoxInfo( Abc_Ntk_t * pNtk ) } // sort models by name vMods = pNtk->pDesign->vModules; - Vec_PtrSort( vMods, (int(*)())Abc_NtkCompareNames ); + Vec_PtrSort( vMods, (int(*)(const void *, const void *))Abc_NtkCompareNames ); // Vec_PtrForEachEntry( Abc_Ntk_t *, vMods, pModel, i ) // printf( "%s\n", Abc_NtkName(pModel) ); diff --git a/src/base/abc/abcHieNew.c b/src/base/abc/abcHieNew.c index 0f191707..54a61609 100644 --- a/src/base/abc/abcHieNew.c +++ b/src/base/abc/abcHieNew.c @@ -558,7 +558,7 @@ void Au_ManPrintBoxInfo( Au_Ntk_t * pNtk ) vMods->nSize--; vMods->pArray++; // sort models by name - Vec_PtrSort( vMods, (int(*)())Au_NtkCompareNames ); + Vec_PtrSort( vMods, (int(*)(const void *, const void *))Au_NtkCompareNames ); // swap the first model Num = Vec_PtrFind( vMods, pNtk ); assert( Num >= 0 && Num < Vec_PtrSize(vMods) ); @@ -643,7 +643,7 @@ void Au_ManPrintBoxInfoSorted( Au_Ntk_t * pNtk ) vMods->pArray--; vMods->nSize++; - Vec_PtrSort( vModsNew, (int(*)())Au_NtkCompareSign ); + Vec_PtrSort( vModsNew, (int(*)(const void *, const void *))Au_NtkCompareSign ); Vec_PtrForEachEntryStart( Au_Ntk_t *, vModsNew, pModel, i, 1 ) { printf( "MODULE " ); diff --git a/src/base/abc/abcMinBase.c b/src/base/abc/abcMinBase.c index 22d1e285..fe3435ac 100644 --- a/src/base/abc/abcMinBase.c +++ b/src/base/abc/abcMinBase.c @@ -703,7 +703,7 @@ void Abc_ObjSortInReverseOrder( Abc_Ntk_t * pNtk, Vec_Ptr_t * vNodes ) vOrder = Abc_NtkDfsReverse( pNtk ); Vec_PtrForEachEntry( Abc_Obj_t *, vOrder, pNode, i ) pNode->iTemp = i; - Vec_PtrSort( vNodes, (int (*)())Abc_ObjCompareByNumber ); + Vec_PtrSort( vNodes, (int (*)(const void *, const void *))Abc_ObjCompareByNumber ); Vec_PtrForEachEntry( Abc_Obj_t *, vOrder, pNode, i ) pNode->iTemp = 0; Vec_PtrFree( vOrder ); diff --git a/src/base/abci/abcBalance.c b/src/base/abci/abcBalance.c index 552cba7f..185ef9c1 100644 --- a/src/base/abci/abcBalance.c +++ b/src/base/abci/abcBalance.c @@ -266,7 +266,7 @@ Abc_Obj_t * Abc_NodeBalance_rec( Abc_Ntk_t * pNtkNew, Abc_Obj_t * pNodeOld, Vec_ if ( vSuper->nSize < 2 ) printf( "BUG!\n" ); // sort the new nodes by level in the decreasing order - Vec_PtrSort( vSuper, (int (*)(void))Abc_NodeCompareLevelsDecrease ); + Vec_PtrSort( vSuper, (int (*)(const void *, const void *))Abc_NodeCompareLevelsDecrease ); // balance the nodes assert( vSuper->nSize > 1 ); while ( vSuper->nSize > 1 ) diff --git a/src/base/abci/abcDar.c b/src/base/abci/abcDar.c index 95c9200d..483f65b9 100644 --- a/src/base/abci/abcDar.c +++ b/src/base/abci/abcDar.c @@ -91,7 +91,7 @@ void Abc_CollectTopOr( Abc_Obj_t * pObj, Vec_Ptr_t * vSuper ) if ( Abc_ObjIsComplement(pObj) ) { Abc_CollectTopOr_rec( Abc_ObjNot(pObj), vSuper ); - Vec_PtrUniqify( vSuper, (int (*)())Abc_ObjCompareById ); + Vec_PtrUniqify( vSuper, (int (*)(const void *, const void *))Abc_ObjCompareById ); } else Vec_PtrPush( vSuper, Abc_ObjNot(pObj) ); diff --git a/src/base/abci/abcLutmin.c b/src/base/abci/abcLutmin.c index be01beb6..7bac74bf 100644 --- a/src/base/abci/abcLutmin.c +++ b/src/base/abci/abcLutmin.c @@ -610,7 +610,7 @@ Abc_Obj_t * Abc_NtkBddDecompose( Abc_Ntk_t * pNtkNew, Abc_Obj_t * pNode, int nLu // cofactor w.r.t. the bound set variables vCofs = Abc_NtkBddCofactors( dd, (DdNode *)pNode->pData, nLutSize ); vUniq = Vec_PtrDup( vCofs ); - Vec_PtrUniqify( vUniq, (int (*)())Vec_PtrSortCompare ); + Vec_PtrUniqify( vUniq, (int (*)(const void *, const void *))Vec_PtrSortCompare ); // only perform decomposition with it is support reduring with two less vars if( Vec_PtrSize(vUniq) > (1 << (nLutSize-2)) ) { diff --git a/src/base/abci/abcMffc.c b/src/base/abci/abcMffc.c index 1d64df5c..55f39252 100644 --- a/src/base/abci/abcMffc.c +++ b/src/base/abci/abcMffc.c @@ -1141,7 +1141,7 @@ Vec_Ptr_t * Abc_NktMffcServer( Abc_Ntk_t * pNtk, int nInMax, int nOutMax ) // sort by their MFFC size Vec_PtrForEachEntry( Abc_Obj_t *, vPivots, pObj, i ) pObj->iTemp = Vec_IntSize((Vec_Int_t *)Vec_PtrEntry(vVolumes, Abc_ObjId(pObj))); - Vec_PtrSort( vPivots, (int (*)(void))Abc_NodeCompareVolumeDecrease ); + Vec_PtrSort( vPivots, (int (*)(const void *, const void *))Abc_NodeCompareVolumeDecrease ); // create marks vMarks = Vec_IntStart( Abc_NtkObjNumMax(pNtk) ); Vec_PtrForEachEntry( Abc_Obj_t *, vPivots, pObj, i ) diff --git a/src/base/abci/abcNpnSave.c b/src/base/abci/abcNpnSave.c index 0e2d13d5..3dd97432 100644 --- a/src/base/abci/abcNpnSave.c +++ b/src/base/abci/abcNpnSave.c @@ -564,7 +564,7 @@ void Npn_ManWrite( Npn_Man_t * p, char * pFileName ) for ( i = 0; i < p->nBins; i++ ) for ( pEntry = Npn_ManObj(p, p->pBins[i]); pEntry; pEntry = Npn_ManObj(p, pEntry->iNext) ) Vec_PtrPush( vEntries, pEntry ); - Vec_PtrSort( vEntries, (int (*)())Npn_ManCompareEntries ); + Vec_PtrSort( vEntries, (int (*)(const void *, const void *))Npn_ManCompareEntries ); Vec_PtrForEachEntry( Npn_Obj_t *, vEntries, pEntry, i ) { Extra_PrintHexadecimal( pFile, (unsigned *)&pEntry->uTruth, 6 ); diff --git a/src/base/abci/abcStrash.c b/src/base/abci/abcStrash.c index 050f3647..d54957a6 100644 --- a/src/base/abci/abcStrash.c +++ b/src/base/abci/abcStrash.c @@ -712,7 +712,7 @@ Vec_Ptr_t * Abc_NodeGetSuper( Abc_Obj_t * pNode ) Vec_PtrFree( vSuper ); vSuper = vFront; // uniquify and return the frontier - Vec_PtrUniqify( vSuper, (int (*)())Vec_CompareNodeIds ); + Vec_PtrUniqify( vSuper, (int (*)(const void *, const void *))Vec_CompareNodeIds ); return vSuper; } diff --git a/src/base/abci/abcSweep.c b/src/base/abci/abcSweep.c index e970ac38..2f2f1ac1 100644 --- a/src/base/abci/abcSweep.c +++ b/src/base/abci/abcSweep.c @@ -888,7 +888,7 @@ int Abc_NtkReplaceAutonomousLogic( Abc_Ntk_t * pNtk ) Vec_PtrPush( vNodes, pFanin ); } } - Vec_PtrUniqify( vNodes, (int (*)(void))Abc_ObjPointerCompare ); + Vec_PtrUniqify( vNodes, (int (*)(const void *, const void *))Abc_ObjPointerCompare ); // replace these nodes by the PIs Vec_PtrForEachEntry( Abc_Obj_t *, vNodes, pNode, i ) { diff --git a/src/base/cba/cbaNtk.c b/src/base/cba/cbaNtk.c index 5be0aa6c..c3f8fae9 100644 --- a/src/base/cba/cbaNtk.c +++ b/src/base/cba/cbaNtk.c @@ -445,7 +445,7 @@ void Cba_NtkObjOrder( Cba_Ntk_t * p, Vec_Int_t * vObjs, Vec_Int_t * vNameIds ) // printf( "%s \n", pName ); // printf( "\n" ); // do the sorting - Vec_PtrSort( vNames, (int (*)(void))Cba_StrCmp ); + Vec_PtrSort( vNames, (int (*)(const void *, const void *))Cba_StrCmp ); // print after // Vec_PtrForEachEntry( char *, vNames, pName, i ) // printf( "%s \n", pName ); diff --git a/src/base/wlc/wlcAbs.c b/src/base/wlc/wlcAbs.c index 402ce21b..c297c54f 100644 --- a/src/base/wlc/wlcAbs.c +++ b/src/base/wlc/wlcAbs.c @@ -867,10 +867,10 @@ static Vec_Bit_t * Wlc_NtkMarkLimit( Wlc_Ntk_t * p, Wlc_Par_t * pPars ) } } - Vec_PtrSort( vAdds, (int (*)(void))IntPairPtrCompare ) ; - Vec_PtrSort( vMults, (int (*)(void))IntPairPtrCompare ) ; - Vec_PtrSort( vMuxes, (int (*)(void))IntPairPtrCompare ) ; - Vec_PtrSort( vFlops, (int (*)(void))IntPairPtrCompare ) ; + Vec_PtrSort( vAdds, (int (*)(const void *, const void *))IntPairPtrCompare ) ; + Vec_PtrSort( vMults, (int (*)(const void *, const void *))IntPairPtrCompare ) ; + Vec_PtrSort( vMuxes, (int (*)(const void *, const void *))IntPairPtrCompare ) ; + Vec_PtrSort( vFlops, (int (*)(const void *, const void *))IntPairPtrCompare ) ; Vec_PtrForEachEntry( Int_Pair_t *, vAdds, pPair, i ) { -- cgit v1.2.3 From a8b5da820df6c008fd02f514a8c93a48ecfe3620 Mon Sep 17 00:00:00 2001 From: Alan Mishchenko Date: Sun, 26 Sep 2021 11:58:42 -0700 Subject: Other compiler changes. --- src/base/main/mainUtils.c | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'src/base') diff --git a/src/base/main/mainUtils.c b/src/base/main/mainUtils.c index d1fe1d20..377299fd 100644 --- a/src/base/main/mainUtils.c +++ b/src/base/main/mainUtils.c @@ -52,7 +52,14 @@ static char * DateReadFromDateString( char * datestr ); char * Abc_UtilsGetVersion( Abc_Frame_t * pAbc ) { static char Version[1000]; +#if __GNUC__ + #pragma GCC diagnostic push + #pragma GCC diagnostic ignored "-Wdate-time" +#endif sprintf(Version, "%s (compiled %s %s)", ABC_VERSION, __DATE__, __TIME__); +#if __GNUC__ + #pragma GCC diagnostic pop +#endif return Version; } -- cgit v1.2.3 From 227b0c775b0d61aee54423cc22a3f6644b2c2bb7 Mon Sep 17 00:00:00 2001 From: Alan Mishchenko Date: Wed, 6 Oct 2021 20:33:41 -0700 Subject: New command &stochsyn for stochastic synthesis. --- src/base/abci/abc.c | 103 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 103 insertions(+) (limited to 'src/base') diff --git a/src/base/abci/abc.c b/src/base/abci/abc.c index 43d91cfd..fd7b572c 100644 --- a/src/base/abci/abc.c +++ b/src/base/abci/abc.c @@ -555,6 +555,7 @@ static int Abc_CommandAbc9Exorcism ( Abc_Frame_t * pAbc, int argc, cha static int Abc_CommandAbc9Mfs ( Abc_Frame_t * pAbc, int argc, char ** argv ); static int Abc_CommandAbc9Mfsd ( Abc_Frame_t * pAbc, int argc, char ** argv ); static int Abc_CommandAbc9DeepSyn ( Abc_Frame_t * pAbc, int argc, char ** argv ); +static int Abc_CommandAbc9StochSyn ( Abc_Frame_t * pAbc, int argc, char ** argv ); //static int Abc_CommandAbc9PoPart2 ( Abc_Frame_t * pAbc, int argc, char ** argv ); //static int Abc_CommandAbc9CexCut ( Abc_Frame_t * pAbc, int argc, char ** argv ); //static int Abc_CommandAbc9CexMerge ( Abc_Frame_t * pAbc, int argc, char ** argv ); @@ -1297,6 +1298,7 @@ void Abc_Init( Abc_Frame_t * pAbc ) Cmd_CommandAdd( pAbc, "ABC9", "&mfs", Abc_CommandAbc9Mfs, 0 ); Cmd_CommandAdd( pAbc, "ABC9", "&mfsd", Abc_CommandAbc9Mfsd, 0 ); Cmd_CommandAdd( pAbc, "ABC9", "&deepsyn", Abc_CommandAbc9DeepSyn, 0 ); + Cmd_CommandAdd( pAbc, "ABC9", "&stochsyn", Abc_CommandAbc9StochSyn, 0 ); // Cmd_CommandAdd( pAbc, "ABC9", "&popart2", Abc_CommandAbc9PoPart2, 0 ); // Cmd_CommandAdd( pAbc, "ABC9", "&cexcut", Abc_CommandAbc9CexCut, 0 ); // Cmd_CommandAdd( pAbc, "ABC9", "&cexmerge", Abc_CommandAbc9CexMerge, 0 ); @@ -47541,6 +47543,107 @@ usage: return 1; } +/**Function************************************************************* + + Synopsis [] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +int Abc_CommandAbc9StochSyn( Abc_Frame_t * pAbc, int argc, char ** argv ) +{ + extern void Gia_ManStochSyn( int nMaxSize, int nIters, int TimeOut, int Seed, int fVerbose, char * pScript ); + int c, nMaxSize = 1000, nIters = 10, TimeOut = 0, Seed = 0, fVerbose = 0; char * pScript; + Extra_UtilGetoptReset(); + while ( ( c = Extra_UtilGetopt( argc, argv, "NITSvh" ) ) != EOF ) + { + switch ( c ) + { + case 'N': + if ( globalUtilOptind >= argc ) + { + Abc_Print( -1, "Command line switch \"-N\" should be followed by an integer.\n" ); + goto usage; + } + nMaxSize = atoi(argv[globalUtilOptind]); + globalUtilOptind++; + if ( nMaxSize < 0 ) + goto usage; + break; + 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++; + if ( nIters < 0 ) + goto usage; + break; + case 'T': + if ( globalUtilOptind >= argc ) + { + Abc_Print( -1, "Command line switch \"-T\" should be followed by an integer.\n" ); + goto usage; + } + TimeOut = atoi(argv[globalUtilOptind]); + globalUtilOptind++; + if ( TimeOut < 0 ) + goto usage; + break; + case 'S': + if ( globalUtilOptind >= argc ) + { + Abc_Print( -1, "Command line switch \"-S\" should be followed by an integer.\n" ); + goto usage; + } + Seed = atoi(argv[globalUtilOptind]); + globalUtilOptind++; + if ( Seed < 0 ) + goto usage; + break; + case 'v': + fVerbose ^= 1; + break; + case 'h': + goto usage; + default: + goto usage; + } + } + if ( pAbc->pGia == NULL ) + { + Abc_Print( -1, "Abc_CommandAbc9StochSyn(): There is no AIG.\n" ); + return 0; + } + if ( argc != globalUtilOptind + 1 ) + { + printf( "Expecting a synthesis script in quotes on the command line (for example: \"&st; &dch; &if\").\n" ); + goto usage; + } + pScript = Abc_UtilStrsav( argv[globalUtilOptind] ); + Gia_ManStochSyn( nMaxSize, nIters, TimeOut, Seed, fVerbose, pScript ); + ABC_FREE( pScript ); + return 0; + +usage: + Abc_Print( -2, "usage: &stochsyn [-NITS ] [-tvh]