66 unsigned uTruthBest = 0;
69 int Required, nNodesSaved;
70 int nNodesSaveCur = -1;
71 int i, GainCur = -1, GainBest = -1;
74 p->nNodesConsidered++;
82p->timeCut += Abc_Clock() - clk;
93 for ( pCut = pCut->
pNext; pCut; pCut = pCut->
pNext )
101 uTruth = 0xFFFF & *Cut_CutReadTruth(pCut);
102 pPerm =
p->pPerms4[ (int)
p->pPerms[uTruth] ];
103 uPhase =
p->pPhases[uTruth];
105 Vec_PtrClear(
p->vFaninsCur );
106 Vec_PtrFill(
p->vFaninsCur, (
int)pCut->
nLeaves, 0 );
107 for ( i = 0; i < (int)pCut->
nLeaves; i++ )
109 pFanin = Abc_NtkObj( pNode->
pNtk, pCut->
pLeaves[(
int)pPerm[i]] );
110 if ( pFanin == NULL )
112 pFanin = Abc_ObjNotCond(pFanin, ((uPhase & (1<<i)) > 0) );
113 Vec_PtrWriteEntry(
p->vFaninsCur, i, pFanin );
125 if ( Abc_ObjFanoutNum(Abc_ObjRegular(pFanin)) == 1 )
140 Abc_ObjRegular(pFanin)->vFanouts.nSize++;
143 Abc_NtkIncrementTravId( pNode->
pNtk );
147 Abc_ObjRegular(pFanin)->vFanouts.nSize--;
148p->timeMffc += Abc_Clock() - clk2;
152 pGraph = Rwr_CutEvaluate(
p, pNode, pCut,
p->vFaninsCur, nNodesSaved, Required, &GainCur, fPlaceEnable );
153p->timeEval += Abc_Clock() - clk2;
156 if ( pGraph != NULL && GainBest < GainCur )
159 nNodesSaveCur = nNodesSaved;
162 p->fCompl = ((uPhase & (1<<4)) > 0);
163 uTruthBest = 0xFFFF & *Cut_CutReadTruth(pCut);
165 Vec_PtrClear(
p->vFanins );
167 Vec_PtrPush(
p->vFanins, pFanin );
170p->timeRes += Abc_Clock() - clk;
172 if ( GainBest == -1 )
211 Dec_GraphNode((
Dec_Graph_t *)
p->pGraph, i)->pFunc = pFanin;
220 p->nScores[
p->pMap[uTruthBest]]++;
221 p->nNodesGained += GainBest;
222 if ( fUseZeros || GainBest > 0 )
224 p->nNodesRewritten++;
228 if ( fVeryVerbose && GainBest > 0 )
231 printf(
"Fanins = %d. ",
p->vFanins->nSize );
232 printf(
"Save = %d. ", nNodesSaveCur );
233 printf(
"Add = %d. ", nNodesSaveCur-GainBest );
234 printf(
"GAIN = %d. ", GainBest );
235 printf(
"Cone = %d. ",
p->pGraph? Dec_GraphNodeNum((
Dec_Graph_t *)
p->pGraph) : 0 );
236 printf(
"Class = %d. ",
p->pMap[uTruthBest] );
260 int nNodesAdded, GainBest, i, k;
264 uTruth = 0xFFFF & *Cut_CutReadTruth(pCut);
265 vSubgraphs = Vec_VecEntry(
p->vClasses,
p->pMap[uTruth] );
266 p->nSubgraphs += vSubgraphs->nSize;
276 Dec_GraphNode(pGraphCur, k)->pFunc = pFanin;
279 if ( nNodesAdded == -1 )
281 assert( nNodesSaved >= nNodesAdded );
321 if ( GainBest < nNodesSaved - nNodesAdded )
323 GainBest = nNodesSaved - nNodesAdded;
324 pGraphBest = pGraphCur;
327 if ( nNodesSaved - nNodesAdded > 0 )
330 pNode->
nGain += GainBest;
331 pNode->
nAdded += nNodesAdded;
336 if ( GainBest == -1 )
338 *pGainBest = GainBest;
355 if ( Vec_PtrFind(vLeaves, pObj) >= 0 || Vec_PtrFind(vLeaves, Abc_ObjNot(pObj)) >= 0 )
363 assert( !Abc_ObjIsCi(pObj) );
385 pTemp = Abc_ObjRegular(pTemp);
393 pTemp = Abc_ObjRegular(pTemp);
415 for ( i = 0; i < (int)pCut->
nLeaves; i++ )
422 Vec_PtrPush( vNodes, pObj );
426 assert( Abc_ObjIsNode(pObj) );
431 Vec_PtrPush( vNodes, pObj );
454 vNodes = Vec_PtrAlloc( 100 );
455 for ( pCut = pCut->
pNext; pCut; pCut = pCut->
pNext )
461 Counter = Vec_PtrSize(vNodes);
462 Vec_PtrFree( vNodes );
481 int i, Depth0, Depth1;
482 if ( Abc_ObjIsCi(pObj) )
485 if ( pObj == Abc_ObjRegular(pLeaf) )
487 Depth0 = Rwr_NodeGetDepth_rec( Abc_ObjFanin0(pObj), vLeaves );
488 Depth1 = Rwr_NodeGetDepth_rec( Abc_ObjFanin1(pObj), vLeaves );
489 return 1 + Abc_MaxInt( Depth0, Depth1 );
509 for ( i = 0; i <
p->vClasses->nSize; i++ )
511 vSubgraphs = Vec_VecEntry(
p->vClasses, i );
517static int Gains[222];
532 if ( Gains[*pNum1] > Gains[*pNum2] )
534 if ( Gains[*pNum1] < Gains[*pNum2] )
559 assert(
p->vClasses->nSize == 222 );
560 for ( i = 0; i <
p->vClasses->nSize; i++ )
564 vSubgraphs = Vec_VecEntry(
p->vClasses, i );
566 Gains[i] += pNode->
nGain;
569 qsort( Perm, (
size_t)222,
sizeof(
int), (
int (*)(
const void *,
const void *))
Rwr_ScoresCompare );
572 for ( i = 0; i <
p->vClasses->nSize; i++ )
575 if ( Gains[iNew] == 0 )
577 vSubgraphs = Vec_VecEntry(
p->vClasses, iNew );
578 printf(
"CLASS %3d: Subgr = %3d. Total gain = %6d. ", iNew, Vec_PtrSize(vSubgraphs), Gains[iNew] );
579 uTruth = (unsigned)
p->pMapInv[iNew];
587 printf(
" %2d: S=%5d. A=%5d. G=%6d. ", k, pNode->
nScore, pNode->
nAdded, pNode->
nGain );
struct Abc_Obj_t_ Abc_Obj_t
ABC_DLL int Abc_ObjRequiredLevel(Abc_Obj_t *pObj)
ABC_DLL int Abc_NodeMffcLabelAig(Abc_Obj_t *pNode)
ABC_DLL char * Abc_ObjName(Abc_Obj_t *pNode)
DECLARATIONS ///.
ABC_DLL void * Abc_NodeGetCutsRecursive(void *p, Abc_Obj_t *pObj, int fDag, int fTree)
#define ABC_INFINITY
MACRO DEFINITIONS ///.
#define ABC_NAMESPACE_IMPL_START
#define ABC_NAMESPACE_IMPL_END
struct Cut_ManStruct_t_ Cut_Man_t
BASIC TYPES ///.
struct Cut_CutStruct_t_ Cut_Cut_t
int Dec_GraphToNetworkCount(Abc_Obj_t *pRoot, Dec_Graph_t *pGraph, int NodeMax, int LevelMax)
void Dec_GraphPrint(FILE *pFile, Dec_Graph_t *pGraph, char *pNamesIn[], char *pNameOut)
FUNCTION DEFINITIONS ///.
struct Dec_Graph_t_ Dec_Graph_t
void Extra_PrintBinary(FILE *pFile, unsigned Sign[], int nBits)
void Ivy_TruthDsdComputePrint(unsigned uTruth)
void Rwr_ScoresClean(Rwr_Man_t *p)
void Rwr_ScoresReport(Rwr_Man_t *p)
void Rwr_CutIsBoolean_rec(Abc_Obj_t *pObj, Vec_Ptr_t *vLeaves, int fMarkA)
void Rwr_CutCountNumNodes_rec(Abc_Obj_t *pObj, Cut_Cut_t *pCut, Vec_Ptr_t *vNodes)
int Rwr_NodeRewrite(Rwr_Man_t *p, Cut_Man_t *pManCut, Abc_Obj_t *pNode, int fUpdateLevel, int fUseZeros, int fPlaceEnable)
FUNCTION DEFINITIONS ///.
int Rwr_ScoresCompare(int *pNum1, int *pNum2)
struct Rwr_Man_t_ Rwr_Man_t
struct Rwr_Node_t_ Rwr_Node_t
typedefABC_NAMESPACE_HEADER_START struct Vec_Ptr_t_ Vec_Ptr_t
INCLUDES ///.
#define Vec_PtrForEachEntry(Type, vVec, pEntry, i)
MACRO DEFINITIONS ///.