45static inline int Fra_SmlCountOnesOne(
Fra_Sml_t *
p,
int Node )
49 pSim = Fra_ObjSim(
p, Node );
50 for ( k =
p->nWordsPref; k < p->nWordsTotal; k++ )
51 Counter += Aig_WordCountOnes( pSim[k] );
66static inline int * Fra_SmlCountOnes(
Fra_Sml_t *
p )
70 pnBits =
ABC_ALLOC(
int, Aig_ManObjNumMax(
p->pAig) );
71 memset( pnBits, 0,
sizeof(
int) * Aig_ManObjNumMax(
p->pAig) );
73 pnBits[i] = Fra_SmlCountOnesOne(
p, i );
88static inline int Sml_NodeCheckImp(
Fra_Sml_t *
p,
int Left,
int Right )
90 unsigned * pSimL, * pSimR;
92 pSimL = Fra_ObjSim(
p, Left );
93 pSimR = Fra_ObjSim(
p, Right );
94 for ( k =
p->nWordsPref; k < p->nWordsTotal; k++ )
95 if ( pSimL[k] & ~pSimR[k] )
111static inline int Sml_NodeNotImpWeight(
Fra_Sml_t *
p,
int Left,
int Right )
113 unsigned * pSimL, * pSimR;
115 pSimL = Fra_ObjSim(
p, Left );
116 pSimR = Fra_ObjSim(
p, Right );
117 for ( k =
p->nWordsPref; k < p->nWordsTotal; k++ )
118 Counter += Aig_WordCountOnes( pSimL[k] & ~pSimR[k] );
133static inline void Sml_NodeSaveNotImpPatterns(
Fra_Sml_t *
p,
int Left,
int Right,
unsigned * pResult )
135 unsigned * pSimL, * pSimR;
137 pSimL = Fra_ObjSim(
p, Left );
138 pSimR = Fra_ObjSim(
p, Right );
139 for ( k =
p->nWordsPref; k < p->nWordsTotal; k++ )
140 pResult[k] |= pSimL[k] & ~pSimR[k];
158 int i, nNodes,
nTotal, nBits, * pnNodes, * pnBits, * pMemory;
161 pnBits = Fra_SmlCountOnes(
p );
164 nBits =
p->nWordsTotal * 32;
166 memset( pnNodes, 0,
sizeof(
int) * (nBits + 1) );
169 if ( i == 0 )
continue;
173 if ( !Aig_ObjIsCi(pObj) )
178 if ( !Aig_ObjIsNode(pObj) && !Aig_ObjIsCi(pObj) )
184 assert( pnBits[i] <= nBits );
185 pnNodes[pnBits[i]]++;
189 pMemory =
ABC_ALLOC(
int, nNodes + nBits + 1 );
191 vNodes = Vec_PtrAlloc( nBits + 1 );
192 Vec_PtrPush( vNodes, pMemory );
193 for ( i = 1; i <= nBits; i++ )
195 pMemory += pnNodes[i-1] + 1;
196 Vec_PtrPush( vNodes, pMemory );
199 memset( pnNodes, 0,
sizeof(
int) * (nBits + 1) );
202 if ( i == 0 )
continue;
206 if ( !Aig_ObjIsCi(pObj) )
211 if ( !Aig_ObjIsNode(pObj) && !Aig_ObjIsCi(pObj) )
217 pMemory = (
int *)Vec_PtrEntry( vNodes, pnBits[i] );
218 pMemory[ pnNodes[pnBits[i]]++ ] = i;
224 pMemory[ pnNodes[i]++ ] = 0;
247 int * pCostCount, nImpCount, Imp, i, c;
248 assert( Vec_IntSize(vImps) >= nImpLimit );
250 pCostCount =
ABC_ALLOC(
int, nCostMax + 1 );
251 memset( pCostCount, 0,
sizeof(
int) * (nCostMax + 1) );
252 for ( i = 0; i < Vec_IntSize(vImps); i++ )
254 assert( pCosts[i] <= nCostMax );
255 pCostCount[ pCosts[i] ]++;
257 assert( pCostCount[0] == 0 );
260 for ( c = nCostMax; c > 0; c-- )
262 nImpCount += pCostCount[c];
263 if ( nImpCount >= nImpLimit )
268 vImpsNew = Vec_IntAlloc( nImpLimit );
273 Vec_IntPush( vImpsNew, Imp );
274 if ( Vec_IntSize( vImpsNew ) == nImpLimit )
296 int Max1 = Abc_MaxInt( pImp1[0], pImp1[1] );
297 int Max2 = Abc_MaxInt( pImp2[0], pImp2[1] );
327 int * pImpCosts, * pNodesI, * pNodesK;
328 int nImpsTotal = 0, nImpsTried = 0, nImpsNonSeq = 0, nImpsComb = 0, nImpsCollected = 0;
330 int i, k, Imp, CostRange;
332 assert( Aig_ManObjNumMax(
p->pManAig) < (1 << 15) );
333 assert( nImpMaxLimit > 0 && nImpUseLimit > 0 && nImpUseLimit <= nImpMaxLimit );
340 for ( k = nSimWords * 32; k > 0; k-- )
341 for ( i = k - 1; i > 0; i-- )
342 for ( pNodesI = (
int *)Vec_PtrEntry( vNodes, i ); *pNodesI; pNodesI++ )
343 for ( pNodesK = (
int *)Vec_PtrEntry( vNodes, k ); *pNodesK; pNodesK++ )
347 pImpCosts =
ABC_ALLOC(
int, nImpMaxLimit );
348 vImps = Vec_IntAlloc( nImpMaxLimit );
350 for ( i = k - 1; i > 0; i-- )
354 for ( pNodesI = (
int *)Vec_PtrEntry( vNodes, i ); *pNodesI; pNodesI++ )
355 for ( pNodesK = (
int *)Vec_PtrEntry( vNodes, k ); *pNodesK; pNodesK++ )
358 if ( !Sml_NodeCheckImp(pSeq, *pNodesI, *pNodesK) )
363 if ( Sml_NodeCheckImp(pComb, *pNodesI, *pNodesK) )
369 Imp = Fra_ImpCreate( *pNodesI, *pNodesK );
370 pImpCosts[ Vec_IntSize(vImps) ] = Sml_NodeNotImpWeight(pComb, *pNodesI, *pNodesK);
371 CostMin = Abc_MinInt( CostMin, pImpCosts[ Vec_IntSize(vImps) ] );
372 CostMax = Abc_MaxInt( CostMax, pImpCosts[ Vec_IntSize(vImps) ] );
373 Vec_IntPush( vImps, Imp );
374 if ( Vec_IntSize(vImps) == nImpMaxLimit )
384 if ( Vec_IntSize(vImps) > nImpUseLimit )
386 vImps =
Fra_SmlSelectMaxCost( vTemp = vImps, pImpCosts, nSimWords * 32, nImpUseLimit, &CostRange );
387 Vec_IntFree( vTemp );
393 void * pTemp = Vec_PtrEntry(vNodes, 0);
396 Vec_PtrFree( vNodes );
398 qsort( (
void *)Vec_IntArray(vImps), (
size_t)Vec_IntSize(vImps),
sizeof(
int),
400if (
p->pPars->fVerbose )
402printf(
"Implications: All = %d. Try = %d. NonSeq = %d. Comb = %d. Res = %d.\n",
403 nImpsTotal, nImpsTried, nImpsNonSeq, nImpsComb, nImpsCollected );
404printf(
"Implication weight: Min = %d. Pivot = %d. Max = %d. ",
405 CostMin, CostRange, CostMax );
406ABC_PRT(
"Time", Abc_Clock() - clk );
433 int pLits[2], Imp, Left, Right, i, f, status;
434 int fComplL, fComplR;
438 pLeft = Aig_ManObj(
p->pManAig, Fra_ImpLeft(Imp) );
439 pRight = Aig_ManObj(
p->pManAig, Fra_ImpRight(Imp) );
441 for ( f = 0; f <
p->pPars->nFramesK; f++ )
444 pLeftF = Fra_ObjFraig( pLeft, f );
445 pRightF = Fra_ObjFraig( pRight, f );
446 if ( Aig_ObjIsNone(Aig_Regular(pLeftF)) || Aig_ObjIsNone(Aig_Regular(pRightF)) )
448 Vec_IntWriteEntry( vImps, i, 0 );
452 if ( f < p->pPars->nFramesK )
455 for ( f = 0; f <
p->pPars->nFramesK; f++ )
458 pLeftF = Fra_ObjFraig( pLeft, f );
459 pRightF = Fra_ObjFraig( pRight, f );
461 Left = pSatVarNums[ Aig_Regular(pLeftF)->Id ];
462 Right = pSatVarNums[ Aig_Regular(pRightF)->Id ];
463 assert( Left > 0 && Left < p->nSatVars );
464 assert( Right > 0 && Right < p->nSatVars );
466 fComplL = pLeft->
fPhase ^ Aig_IsComplement(pLeftF);
467 fComplR = pRight->
fPhase ^ Aig_IsComplement(pRightF);
470 pLits[0] = 2 * Left + !fComplL;
471 pLits[1] = 2 * Right + fComplR;
507 int i, Imp, Left, Right, Max, RetValue;
508 int fComplL, fComplR;
513 Left = Fra_ImpLeft(Imp);
514 Right = Fra_ImpRight(Imp);
515 Max = Abc_MaxInt( Left, Right );
517 if ( Max > pNode->
Id )
520 pLeft = Aig_ManObj(
p->pManAig, Left );
521 pRight = Aig_ManObj(
p->pManAig, Right );
523 pLeftF = Fra_ObjFraig( pLeft,
p->pPars->nFramesK );
524 pRightF = Fra_ObjFraig( pRight,
p->pPars->nFramesK );
526 fComplL = pLeft->
fPhase ^ Aig_IsComplement(pLeftF);
527 fComplR = pRight->
fPhase ^ Aig_IsComplement(pRightF);
529 if ( Aig_Regular(pLeftF) == Aig_Regular(pRightF) )
531 if ( fComplL == fComplR )
533 assert( fComplL != fComplR );
539 if ( Aig_ObjIsConst1(Aig_Regular(pLeftF)) && fComplL )
542 p->pCla->fRefinement = 1;
543 Vec_IntWriteEntry( vImps, i, 0 );
550 RetValue =
Fra_NodesAreImp(
p, Aig_Regular(pLeftF), Aig_Regular(pRightF), fComplL, fComplR );
553 p->pCla->fRefinement = 1;
556 if ( Vec_IntEntry(vImps, i) != 0 )
557 printf(
"Fra_ImpCheckForNode(): Implication is not refined!\n" );
558 assert( Vec_IntEntry(vImps, i) == 0 );
578 int Imp, i, RetValue = 0;
584 pLeft = Aig_ManObj(
p->pManAig, Fra_ImpLeft(Imp) );
585 pRight = Aig_ManObj(
p->pManAig, Fra_ImpRight(Imp) );
587 if ( !Sml_NodeCheckImp(
p->pSml, pLeft->
Id, pRight->
Id) )
589 Vec_IntWriteEntry( vImps, i, 0 );
613 Vec_IntWriteEntry( vImps, k++, Imp );
614 Vec_IntShrink( vImps, k );
634 int Left, Right, Imp, i;
635 if (
p->pCla->vImps == NULL || Vec_IntSize(
p->pCla->vImps) == 0 )
640 pResult = Fra_ObjSim( pComb, 0 );
641 assert( pResult[0] == 0 );
644 Left = Fra_ImpLeft(Imp);
645 Right = Fra_ImpRight(Imp);
646 Sml_NodeSaveNotImpPatterns( pComb, Left, Right, pResult );
671 int Left, Right, Imp, i, Counter;
672 if (
p->pCla->vImps == NULL || Vec_IntSize(
p->pCla->vImps) == 0 )
677 pfFails =
ABC_ALLOC(
char, Vec_IntSize(
p->pCla->vImps) );
678 memset( pfFails, 0,
sizeof(
char) * Vec_IntSize(
p->pCla->vImps) );
681 Left = Fra_ImpLeft(Imp);
682 Right = Fra_ImpRight(Imp);
683 pfFails[i] = !Sml_NodeCheckImp( pSeq, Left, Right );
687 for ( i = 0; i < Vec_IntSize(
p->pCla->vImps); i++ )
688 Counter += pfFails[i];
709 if (
p->pCla->vImps == NULL || Vec_IntSize(
p->pCla->vImps) == 0 )
712 nPosOld = Aig_ManCoNum(pNew);
715 pLeft = Aig_ManObj(
p->pManAig, Fra_ImpLeft(Imp) );
716 pRight = Aig_ManObj(
p->pManAig, Fra_ImpRight(Imp) );
723 pNew->nAsserts = Aig_ManCoNum(pNew) - nPosOld;
#define ABC_ALLOC(type, num)
#define ABC_INFINITY
MACRO DEFINITIONS ///.
#define ABC_NAMESPACE_IMPL_START
#define ABC_NAMESPACE_IMPL_END
#define Aig_ManForEachObj(p, pObj, i)
Aig_Obj_t * Aig_ObjCreateCo(Aig_Man_t *p, Aig_Obj_t *pDriver)
struct Aig_Obj_t_ Aig_Obj_t
typedefABC_NAMESPACE_HEADER_START struct Aig_Man_t_ Aig_Man_t
INCLUDES ///.
Aig_Obj_t * Aig_Or(Aig_Man_t *p, Aig_Obj_t *p0, Aig_Obj_t *p1)
int nTotal
DECLARATIONS ///.
typedefABC_NAMESPACE_IMPL_START struct Vec_Int_t_ Vec_Int_t
DECLARATIONS ///.
#define sat_solver_addclause
int Fra_ImpCheckForNode(Fra_Man_t *p, Vec_Int_t *vImps, Aig_Obj_t *pNode, int Pos)
int Fra_ImpVerifyUsingSimulation(Fra_Man_t *p)
int Sml_CompareMaxId(unsigned short *pImp1, unsigned short *pImp2)
Vec_Ptr_t * Fra_SmlSortUsingOnes(Fra_Sml_t *p, int fLatchCorr)
void Fra_ImpCompactArray(Vec_Int_t *vImps)
void Fra_ImpRecordInManager(Fra_Man_t *p, Aig_Man_t *pNew)
Vec_Int_t * Fra_ImpDerive(Fra_Man_t *p, int nImpMaxLimit, int nImpUseLimit, int fLatchCorr)
void Fra_ImpAddToSolver(Fra_Man_t *p, Vec_Int_t *vImps, int *pSatVarNums)
Vec_Int_t * Fra_SmlSelectMaxCost(Vec_Int_t *vImps, int *pCosts, int nCostMax, int nImpLimit, int *pCostRange)
int Fra_ImpRefineUsingCex(Fra_Man_t *p, Vec_Int_t *vImps)
double Fra_ImpComputeStateSpaceRatio(Fra_Man_t *p)
void Fra_SmlStop(Fra_Sml_t *p)
struct Fra_Man_t_ Fra_Man_t
struct Fra_Sml_t_ Fra_Sml_t
Fra_Sml_t * Fra_SmlSimulateComb(Aig_Man_t *pAig, int nWords, int fCheckMiter)
int Fra_NodesAreImp(Fra_Man_t *p, Aig_Obj_t *pOld, Aig_Obj_t *pNew, int fComplL, int fComplR)
void Fra_SmlResimulate(Fra_Man_t *p)
Fra_Sml_t * Fra_SmlSimulateSeq(Aig_Man_t *pAig, int nPref, int nFrames, int nWords, int fCheckMiter)
int sat_solver_simplify(sat_solver *s)
void sat_solver_delete(sat_solver *s)
#define Vec_IntForEachEntry(vVec, Entry, i)
MACRO DEFINITIONS ///.
#define Vec_IntForEachEntryStart(vVec, Entry, i, Start)
typedefABC_NAMESPACE_HEADER_START struct Vec_Ptr_t_ Vec_Ptr_t
INCLUDES ///.
#define Vec_PtrForEachEntry(Type, vVec, pEntry, i)
MACRO DEFINITIONS ///.