84 word * pTruth0, * pTruth1, * pTruth = NULL;
85 int i, k,
nWords = Abc_Truth6WordNum( Vec_PtrSize(vLeaves) );
92 for ( i = Vec_PtrSize(vFuncs); i < Vec_PtrSize(vVisited); i++ )
97 assert( !Abc_ObjIsPi(pNode) );
98 pTruth0 = (
word *)Abc_ObjFanin0(pNode)->pCopy;
99 pTruth1 = (
word *)Abc_ObjFanin1(pNode)->pCopy;
100 pTruth = (
word *)Vec_PtrEntry( vFuncs, i );
101 if ( Abc_ObjFaninC0(pNode) )
103 if ( Abc_ObjFaninC1(pNode) )
104 for ( k = 0; k <
nWords; k++ )
105 pTruth[k] = ~pTruth0[k] & ~pTruth1[k];
107 for ( k = 0; k <
nWords; k++ )
108 pTruth[k] = ~pTruth0[k] & pTruth1[k];
112 if ( Abc_ObjFaninC1(pNode) )
113 for ( k = 0; k <
nWords; k++ )
114 pTruth[k] = pTruth0[k] & ~pTruth1[k];
116 for ( k = 0; k <
nWords; k++ )
117 pTruth[k] = pTruth0[k] & pTruth1[k];
125 int k,
nWords = Abc_Truth6WordNum( nVars );
126 for ( k = 0; k <
nWords; k++ )
133 int k,
nWords = Abc_Truth6WordNum( nVars );
134 for ( k = 0; k <
nWords; k++ )
155 int fVeryVerbose = 0;
156 int nVars = Vec_PtrSize(vFanins);
157 int nWordsMax = Abc_Truth6WordNum(
p->nNodeSizeMax);
162 int i, nNodesSaved, nNodesAdded, Required;
166 p->nNodesConsidered++;
173p->timeTru += Abc_Clock() - clk;
174 if ( pTruth == NULL )
181 p->nNodesGained +=
p->nLastGain;
182 p->nNodesRefactored++;
189p->timeFact += Abc_Clock() - clk;
196 Abc_NtkIncrementTravId( pNode->
pNtk );
202 Dec_GraphNode(pFForm, i)->pFunc = pFanin;
208p->timeEval += Abc_Clock() - clk;
211 if ( nNodesAdded == -1 || nNodesSaved - nNodesAdded < nMinSaved )
213 Dec_GraphFree( pFForm );
218 p->nLastGain = nNodesSaved - nNodesAdded;
219 p->nNodesGained +=
p->nLastGain;
220 p->nNodesRefactored++;
226 printf(
"Cone = %2d. ", vFanins->nSize );
227 printf(
"FF = %2d. ", 1 + Dec_GraphNodeNum(pFForm) );
228 printf(
"MFFC = %2d. ", nNodesSaved );
229 printf(
"Add = %2d. ", nNodesAdded );
230 printf(
"GAIN = %2d. ",
p->nLastGain );
253 p->vCube = Vec_StrAlloc( 100 );
254 p->vVisited = Vec_PtrAlloc( 100 );
255 p->nNodeSizeMax = nNodeSizeMax;
256 p->nConeSizeMax = nConeSizeMax;
257 p->fVerbose = fVerbose;
258 p->vVars = Vec_PtrAllocTruthTables( Abc_MaxInt(nNodeSizeMax, 6) );
259 p->vFuncs = Vec_PtrAlloc( 100 );
260 p->vMemory = Vec_IntAlloc( 1 << 16 );
277 Vec_PtrFreeFree(
p->vFuncs );
278 Vec_PtrFree(
p->vVars );
279 Vec_IntFree(
p->vMemory );
280 Vec_PtrFree(
p->vVisited );
281 Vec_StrFree(
p->vCube );
298 printf(
"Refactoring statistics:\n" );
299 printf(
"Nodes considered = %8d.\n",
p->nNodesConsidered );
300 printf(
"Nodes refactored = %8d.\n",
p->nNodesRefactored );
301 printf(
"Gain = %8d. (%6.2f %%).\n",
p->nNodesBeg-
p->nNodesEnd, 100.0*(
p->nNodesBeg-
p->nNodesEnd)/
p->nNodesBeg );
303 ABC_PRT(
"Resynthesis",
p->timeRes );
309 ABC_PRT(
"AIG update ",
p->timeNtk );
329int Abc_NtkRefactor(
Abc_Ntk_t * pNtk,
int nNodeSizeMax,
int nMinSaved,
int nConeSizeMax,
int fUpdateLevel,
int fUseZeros,
int fUseDcs,
int fVerbose )
338 abctime clk, clkStart = Abc_Clock();
339 int i, nNodes, RetValue = 1;
341 assert( Abc_NtkIsStrash(pNtk) );
353 pManRef->
nNodesBeg = Abc_NtkNodeNum(pNtk);
354 nNodes = Abc_NtkObjNumMax(pNtk);
358 Extra_ProgressBarUpdate( pProgress, i, NULL );
363 if ( Abc_NodeIsPersistant(pNode) )
366 if ( Abc_ObjFanoutNum(pNode) > 1000 )
374pManRef->
timeCut += Abc_Clock() - clk;
377 pFForm =
Abc_NodeRefactor( pManRef, pNode, vFanins, nMinSaved, fUpdateLevel, fUseZeros, fUseDcs, fVerbose );
378pManRef->
timeRes += Abc_Clock() - clk;
379 if ( pFForm == NULL )
385 Dec_GraphFree( pFForm );
389pManRef->
timeNtk += Abc_Clock() - clk;
390 Dec_GraphFree( pFForm );
393pManRef->
timeTotal = Abc_Clock() - clkStart;
394 pManRef->
nNodesEnd = Abc_NtkNodeNum(pNtk);
405 if ( RetValue != -1 )
415 printf(
"Abc_NtkRefactor: The network check has failed.\n" );
int Dec_GraphUpdateNetwork(Abc_Obj_t *pRoot, Dec_Graph_t *pGraph, int fUpdateLevel, int nGain)
struct Abc_ManRef_t_ Abc_ManRef_t
Dec_Graph_t * Abc_NodeRefactor(Abc_ManRef_t *p, Abc_Obj_t *pNode, Vec_Ptr_t *vFanins, int nMinSaved, int fUpdateLevel, int fUseZeros, int fUseDcs, int fVerbose)
void Abc_NtkManRefStop(Abc_ManRef_t *p)
Abc_ManRef_t * Abc_NtkManRefStart(int nNodeSizeMax, int nConeSizeMax, int fUseDcs, int fVerbose)
int Abc_NodeConeIsConst0(word *pTruth, int nVars)
void Abc_NtkManRefPrintStats(Abc_ManRef_t *p)
word * Abc_NodeConeTruth(Vec_Ptr_t *vVars, Vec_Ptr_t *vFuncs, int nWordsMax, Abc_Obj_t *pRoot, Vec_Ptr_t *vLeaves, Vec_Ptr_t *vVisited)
FUNCTION DEFINITIONS ///.
int Abc_NodeConeIsConst1(word *pTruth, int nVars)
int Abc_NtkRefactor(Abc_Ntk_t *pNtk, int nNodeSizeMax, int nMinSaved, int nConeSizeMax, int fUpdateLevel, int fUseZeros, int fUseDcs, int fVerbose)
DECLARATIONS ///.
struct Abc_Obj_t_ Abc_Obj_t
ABC_DLL int Abc_NodeMffcSize(Abc_Obj_t *pNode)
FUNCTION DEFINITIONS ///.
ABC_DLL int Abc_ObjRequiredLevel(Abc_Obj_t *pObj)
ABC_DLL int Abc_NtkCheck(Abc_Ntk_t *pNtk)
FUNCTION DEFINITIONS ///.
ABC_DLL int Abc_NodeMffcLabelAig(Abc_Obj_t *pNode)
struct Abc_ManCut_t_ Abc_ManCut_t
ABC_DLL void Abc_NodeConeCollect(Abc_Obj_t **ppRoots, int nRoots, Vec_Ptr_t *vFanins, Vec_Ptr_t *vVisited, int fIncludeFanins)
struct Abc_Aig_t_ Abc_Aig_t
ABC_DLL void Abc_NtkManCutStop(Abc_ManCut_t *p)
ABC_DLL char * Abc_ObjName(Abc_Obj_t *pNode)
DECLARATIONS ///.
struct Abc_Ntk_t_ Abc_Ntk_t
ABC_DLL void Abc_NtkStopReverseLevels(Abc_Ntk_t *pNtk)
ABC_DLL int Abc_NtkLevel(Abc_Ntk_t *pNtk)
ABC_DLL Vec_Ptr_t * Abc_NodeFindCut(Abc_ManCut_t *p, Abc_Obj_t *pRoot, int fContain)
ABC_DLL int Abc_AigCleanup(Abc_Aig_t *pMan)
ABC_DLL void Abc_NtkStartReverseLevels(Abc_Ntk_t *pNtk, int nMaxLevelIncrease)
ABC_DLL Vec_Ptr_t * Abc_NtkManCutReadCutLarge(Abc_ManCut_t *p)
ABC_DLL void Abc_NtkReassignIds(Abc_Ntk_t *pNtk)
ABC_DLL Abc_ManCut_t * Abc_NtkManCutStart(int nNodeSizeMax, int nConeSizeMax, int nNodeFanStop, int nConeFanStop)
#define Abc_NtkForEachNode(pNtk, pNode, i)
#define ABC_ALLOC(type, num)
#define ABC_INFINITY
MACRO DEFINITIONS ///.
#define ABC_NAMESPACE_IMPL_START
#define ABC_NAMESPACE_IMPL_END
typedefABC_NAMESPACE_IMPL_START struct Vec_Int_t_ Vec_Int_t
DECLARATIONS ///.
struct Vec_Str_t_ Vec_Str_t
ABC_NAMESPACE_IMPL_START typedef char ProgressBar
int Dec_GraphToNetworkCount(Abc_Obj_t *pRoot, Dec_Graph_t *pGraph, int NodeMax, int LevelMax)
struct Dec_Graph_t_ Dec_Graph_t
unsigned __int64 word
DECLARATIONS ///.
Kit_Graph_t * Kit_TruthToGraph(unsigned *pTruth, int nVars, Vec_Int_t *vMemory)
typedefABC_NAMESPACE_HEADER_START struct Vec_Ptr_t_ Vec_Ptr_t
INCLUDES ///.
#define Vec_PtrForEachEntry(Type, vVec, pEntry, i)
MACRO DEFINITIONS ///.