From c42aeb81a491c2276c997c909453d44c83c08cba Mon Sep 17 00:00:00 2001 From: Alan Mishchenko Date: Fri, 5 Aug 2016 20:43:45 -0700 Subject: Handling constant and buffer cut in exact synthesis. --- src/base/abc/abc.h | 2 +- src/base/abci/abcExact.c | 28 ++++++++++++++++++++++------ src/base/abci/abcIf.c | 2 +- 3 files changed, 24 insertions(+), 8 deletions(-) (limited to 'src') diff --git a/src/base/abc/abc.h b/src/base/abc/abc.h index fcb2d989..35b20dbe 100644 --- a/src/base/abc/abc.h +++ b/src/base/abc/abc.h @@ -645,7 +645,7 @@ extern ABC_DLL Vec_Ptr_t * Abc_AigGetLevelizedOrder( Abc_Ntk_t * pNtk, in /*=== abcExact.c ==========================================================*/ extern ABC_DLL int Abc_ExactInputNum(); extern ABC_DLL int Abc_ExactIsRunning(); -extern ABC_DLL Abc_Obj_t * Abc_ExactBuildNode( word * pTruth, int nVars, int * pArrTimeProfile, Abc_Obj_t ** pFanins ); +extern ABC_DLL Abc_Obj_t * Abc_ExactBuildNode( word * pTruth, int nVars, int * pArrTimeProfile, Abc_Obj_t ** pFanins, Abc_Ntk_t * pNtk ); extern ABC_DLL Abc_Ntk_t * Abc_NtkFindExact( word * pTruth, int nVars, int nFunc, int nMaxDepth, int * pArrivalTimes, int fVerbose ); /*=== abcFanio.c ==========================================================*/ extern ABC_DLL void Abc_ObjAddFanin( Abc_Obj_t * pObj, Abc_Obj_t * pFanin ); diff --git a/src/base/abci/abcExact.c b/src/base/abci/abcExact.c index d739118a..50052b91 100644 --- a/src/base/abci/abcExact.c +++ b/src/base/abci/abcExact.c @@ -1500,12 +1500,25 @@ int Abc_ExactDelayCost( word * pTruth, int nVars, int * pArrTimeProfile, char * abctime timeStart; /* some checks */ - if ( nVars < 2 || nVars > 8 ) + if ( nVars < 0 || nVars > 8 ) { printf( "invalid truth table size %d\n", nVars ); assert( 0 ); } + if ( nVars == 0 ) + { + *Cost = 0; + return 0; + } + + if ( nVars == 1 ) + { + *Cost = 0; + pPerm[0] = (char)0; + return pArrTimeProfile[0]; + } + /* statistics */ s_pSesStore->nCutCount++; s_pSesStore->pCutCount[nVars]++; @@ -1566,7 +1579,7 @@ int Abc_ExactDelayCost( word * pTruth, int nVars, int * pArrTimeProfile, char * } // this procedure returns a new node whose output in terms of the given fanins // has the smallest possible arrival time (in agreement with the above Abc_ExactDelayCost) -Abc_Obj_t * Abc_ExactBuildNode( word * pTruth, int nVars, int * pArrTimeProfile, Abc_Obj_t ** pFanins ) +Abc_Obj_t * Abc_ExactBuildNode( word * pTruth, int nVars, int * pArrTimeProfile, Abc_Obj_t ** pFanins, Abc_Ntk_t * pNtk ) { char * pSol; int i, j; @@ -1576,7 +1589,10 @@ Abc_Obj_t * Abc_ExactBuildNode( word * pTruth, int nVars, int * pArrTimeProfile, char pGateTruth[5]; char * pSopCover; - Abc_Ntk_t * pNtk = Abc_ObjNtk( pFanins[0] ); + if ( nVars == 0 ) + return (pTruth[0] & 1) ? Abc_NtkCreateNodeConst1(pNtk) : Abc_NtkCreateNodeConst0(pNtk); + if ( nVars == 1 ) + return (pTruth[0] & 1) ? Abc_NtkCreateNodeInv(pNtk, pFanins[0]) : Abc_NtkCreateNodeBuf(pNtk, pFanins[0]); pSol = Ses_StoreGetEntry( s_pSesStore, pTruth, nVars, pArrTimeProfile ); if ( !pSol ) @@ -1656,14 +1672,14 @@ void Abc_ExactStoreTest( int fVerbose ) Abc_ExactStart( 10000, 1, fVerbose, NULL ); - assert( !Abc_ExactBuildNode( pTruth, 4, pArrTimeProfile, pFanins ) ); + assert( !Abc_ExactBuildNode( pTruth, 4, pArrTimeProfile, pFanins, pNtk ) ); assert( Abc_ExactDelayCost( pTruth, 4, pArrTimeProfile, pPerm, &Cost, 12 ) == 1 ); - assert( Abc_ExactBuildNode( pTruth, 4, pArrTimeProfile, pFanins ) ); + assert( Abc_ExactBuildNode( pTruth, 4, pArrTimeProfile, pFanins, pNtk ) ); (*pArrTimeProfile)++; - assert( !Abc_ExactBuildNode( pTruth, 4, pArrTimeProfile, pFanins ) ); + assert( !Abc_ExactBuildNode( pTruth, 4, pArrTimeProfile, pFanins, pNtk ) ); (*pArrTimeProfile)--; Abc_ExactStop( NULL ); diff --git a/src/base/abci/abcIf.c b/src/base/abci/abcIf.c index 6b760de2..08e2a560 100644 --- a/src/base/abci/abcIf.c +++ b/src/base/abci/abcIf.c @@ -452,7 +452,7 @@ Abc_Obj_t * Abc_NodeFromIf_rec( Abc_Ntk_t * pNtkNew, If_Man_t * pIfMan, If_Obj_t Abc_Obj_t * pFanins[IF_MAX_FUNC_LUTSIZE]; If_CutForEachLeaf( pIfMan, pCutBest, pIfLeaf, i ) pFanins[i] = Abc_NodeFromIf_rec(pNtkNew, pIfMan, pIfLeaf, vCover); - pNodeNew = Abc_ExactBuildNode( If_CutTruthW(pIfMan, pCutBest), If_CutLeaveNum(pCutBest), If_CutArrTimeProfile(pIfMan, pCutBest), pFanins ); + pNodeNew = Abc_ExactBuildNode( If_CutTruthW(pIfMan, pCutBest), If_CutLeaveNum(pCutBest), If_CutArrTimeProfile(pIfMan, pCutBest), pFanins, pNtkNew ); If_ObjSetCopy( pIfObj, pNodeNew ); return pNodeNew; } -- cgit v1.2.3