30static inline int Fra_RegToLit(
int n,
int c ) {
return c? -n-1 : n+1; }
31static inline int Fra_LitReg(
int n ) {
return (n>0)? n-1 : -n-1; }
32static inline int Fra_LitSign(
int n ) {
return (n<0); }
53 pSims = Fra_ObjSim(pSeq, pObj->
Id);
54 for ( i = pSeq->
nWordsPref; i < pSeq->nWordsTotal; i++ )
73 unsigned * pSims0, * pSims1;
75 pSims0 = Fra_ObjSim(pSeq, pObj0->
Id);
76 pSims1 = Fra_ObjSim(pSeq, pObj1->
Id);
77 for ( i = pSeq->
nWordsPref; i < pSeq->nWordsTotal; i++ )
78 if ( pSims0[i] != pSims1[i] )
96 unsigned * pSim1, * pSim2;
98 pSim1 = Fra_ObjSim(pSeq, pObj1->
Id);
99 pSim2 = Fra_ObjSim(pSeq, pObj2->
Id);
100 if ( fCompl1 && fCompl2 )
102 for ( k = pSeq->
nWordsPref; k < pSeq->nWordsTotal; k++ )
103 if ( pSim1[k] & pSim2[k] )
108 for ( k = pSeq->
nWordsPref; k < pSeq->nWordsTotal; k++ )
109 if ( pSim1[k] & ~pSim2[k] )
114 for ( k = pSeq->
nWordsPref; k < pSeq->nWordsTotal; k++ )
115 if ( ~pSim1[k] & pSim2[k] )
136 int fSkipConstEqu = 1;
140 int nTruePis = Aig_ManCiNum(pSim->
pAig) - Aig_ManRegNum(pSim->
pAig);
142 vOneHots = Vec_IntAlloc( 100 );
147 assert( i-nTruePis >= 0 );
156 assert( k-nTruePis >= 0 );
159 Vec_IntPush( vOneHots, Fra_RegToLit(i-nTruePis, 1) );
160 Vec_IntPush( vOneHots, Fra_RegToLit(k-nTruePis, 1) );
165 Vec_IntPush( vOneHots, Fra_RegToLit(i-nTruePis, 0) );
166 Vec_IntPush( vOneHots, Fra_RegToLit(k-nTruePis, 1) );
171 Vec_IntPush( vOneHots, Fra_RegToLit(i-nTruePis, 1) );
172 Vec_IntPush( vOneHots, Fra_RegToLit(k-nTruePis, 0) );
194 int i, Out1, Out2, pLits[2];
195 int nPiNum = Aig_ManCiNum(
p->pManFraig) - Aig_ManRegNum(
p->pManFraig);
196 assert(
p->pPars->nFramesK == 1 );
197 for ( i = 0; i < Vec_IntSize(vOneHots); i += 2 )
199 Out1 = Vec_IntEntry( vOneHots, i );
200 Out2 = Vec_IntEntry( vOneHots, i+1 );
201 if ( Out1 == 0 && Out2 == 0 )
203 pObj1 = Aig_ManCi(
p->pManFraig, nPiNum + Fra_LitReg(Out1) );
204 pObj2 = Aig_ManCi(
p->pManFraig, nPiNum + Fra_LitReg(Out2) );
205 pLits[0] = toLitCond( Fra_ObjSatNum(pObj1), Fra_LitSign(Out1) );
206 pLits[1] = toLitCond( Fra_ObjSatNum(pObj2), Fra_LitSign(Out2) );
210 printf(
"Fra_OneHotAssume(): Adding clause makes SAT solver unsat.\n" );
232 int RetValue, i, Out1, Out2;
233 int nTruePos = Aig_ManCoNum(
p->pManFraig) - Aig_ManRegNum(
p->pManFraig);
234 for ( i = 0; i < Vec_IntSize(vOneHots); i += 2 )
236 Out1 = Vec_IntEntry( vOneHots, i );
237 Out2 = Vec_IntEntry( vOneHots, i+1 );
238 if ( Out1 == 0 && Out2 == 0 )
240 pObj1 = Aig_ManCo(
p->pManFraig, nTruePos + Fra_LitReg(Out1) );
241 pObj2 = Aig_ManCo(
p->pManFraig, nTruePos + Fra_LitReg(Out2) );
245 p->pCla->fRefinement = 1;
248 if ( Vec_IntEntry(vOneHots, i) != 0 )
249 printf(
"Fra_OneHotCheck(): Clause is not refined!\n" );
250 assert( Vec_IntEntry(vOneHots, i) == 0 );
269 int i, Out1, Out2, RetValue = 0;
270 int nPiNum = Aig_ManCiNum(
p->pManAig) - Aig_ManRegNum(
p->pManAig);
271 assert(
p->pSml->pAig ==
p->pManAig );
272 for ( i = 0; i < Vec_IntSize(vOneHots); i += 2 )
274 Out1 = Vec_IntEntry( vOneHots, i );
275 Out2 = Vec_IntEntry( vOneHots, i+1 );
276 if ( Out1 == 0 && Out2 == 0 )
279 pObj1 = Aig_ManCi(
p->pManAig, nPiNum + Fra_LitReg(Out1) );
280 pObj2 = Aig_ManCi(
p->pManAig, nPiNum + Fra_LitReg(Out2) );
284 Vec_IntWriteEntry( vOneHots, i, 0 );
285 Vec_IntWriteEntry( vOneHots, i+1, 0 );
305 int i, Out1, Out2, Counter = 0;
306 for ( i = 0; i < Vec_IntSize(vOneHots); i += 2 )
308 Out1 = Vec_IntEntry( vOneHots, i );
309 Out2 = Vec_IntEntry( vOneHots, i+1 );
310 if ( Out1 == 0 && Out2 == 0 )
330 int nSimWords = (1<<14);
331 int nRegs = Aig_ManRegNum(
p->pManAig);
333 unsigned * pSim1, * pSim2, * pSimTot;
334 int i, w, Out1, Out2, nCovered, Counter = 0;
338 vSimInfo = Vec_PtrAllocSimInfo( nRegs + 1, nSimWords );
341 for ( i = 0; i < nRegs; i++ )
343 pSim1 = (
unsigned *)Vec_PtrEntry( vSimInfo, i );
344 for ( w = 0; w < nSimWords; w++ )
345 pSim1[w] = Fra_ObjRandomSim();
347 pSimTot = (
unsigned *)Vec_PtrEntry( vSimInfo, nRegs );
350 memset( pSimTot, 0,
sizeof(
unsigned) * nSimWords );
351 for ( i = 0; i < Vec_IntSize(vOneHots); i += 2 )
353 Out1 = Vec_IntEntry( vOneHots, i );
354 Out2 = Vec_IntEntry( vOneHots, i+1 );
355 if ( Out1 == 0 && Out2 == 0 )
361 pSim1 = (
unsigned *)Vec_PtrEntry( vSimInfo, Fra_LitReg(Out1) );
362 pSim2 = (
unsigned *)Vec_PtrEntry( vSimInfo, Fra_LitReg(Out2) );
363 if ( Fra_LitSign(Out1) && Fra_LitSign(Out2) )
364 for ( w = 0; w < nSimWords; w++ )
365 pSimTot[w] |= pSim1[w] & pSim2[w];
366 else if ( Fra_LitSign(Out1) )
367 for ( w = 0; w < nSimWords; w++ )
368 pSimTot[w] |= pSim1[w] & ~pSim2[w];
369 else if ( Fra_LitSign(Out2) )
370 for ( w = 0; w < nSimWords; w++ )
371 pSimTot[w] |= ~pSim1[w] & pSim2[w];
378 for ( w = 0; w < nSimWords; w++ )
379 nCovered += Aig_WordCountOnes( pSimTot[w] );
380 Vec_PtrFree( vSimInfo );
382 printf(
"Care states ratio = %f. ", 1.0 * (nSimWords * 32 - nCovered) / (nSimWords * 32) );
383 printf(
"(%d out of %d patterns) ", nSimWords * 32 - nCovered, nSimWords * 32 );
384 ABC_PRT(
"Time", Abc_Clock() - clk );
402 int i, Out1, Out2, nTruePis;
408 nTruePis = Aig_ManCiNum(
p->pManAig) - Aig_ManRegNum(
p->pManAig);
409 for ( i = 0; i < Vec_IntSize(vOneHots); i += 2 )
411 Out1 = Vec_IntEntry( vOneHots, i );
412 Out2 = Vec_IntEntry( vOneHots, i+1 );
413 if ( Out1 == 0 && Out2 == 0 )
415 pObj1 = Aig_ManCi( pNew, nTruePis + Fra_LitReg(Out1) );
416 pObj2 = Aig_ManCi( pNew, nTruePis + Fra_LitReg(Out2) );
417 pObj1 = Aig_NotCond( pObj1, Fra_LitSign(Out1) );
418 pObj2 = Aig_NotCond( pObj2, Fra_LitSign(Out2) );
419 pObj =
Aig_Or( pNew, pObj1, pObj2 );
443 int k, i, j, Out1, Out2, pLits[2];
453 pObj1 = Aig_ManCi(
p->pManFraig, Out1 );
454 pObj2 = Aig_ManCi(
p->pManFraig, Out2 );
455 pLits[0] = toLitCond( Fra_ObjSatNum(pObj1), 1 );
456 pLits[1] = toLitCond( Fra_ObjSatNum(pObj2), 1 );
460 printf(
"Fra_OneHotAddKnownConstraint(): Adding clause makes SAT solver unsat.\n" );
#define ABC_NAMESPACE_IMPL_START
#define ABC_NAMESPACE_IMPL_END
#define Aig_ManForEachCi(p, pObj, i)
ITERATORS ///.
Aig_Obj_t * Aig_ObjCreateCo(Aig_Man_t *p, Aig_Obj_t *pDriver)
struct Aig_Obj_t_ Aig_Obj_t
Aig_Man_t * Aig_ManStart(int nNodesMax)
DECLARATIONS ///.
typedefABC_NAMESPACE_HEADER_START struct Aig_Man_t_ Aig_Man_t
INCLUDES ///.
int Aig_ManCleanup(Aig_Man_t *p)
Aig_Obj_t * Aig_ObjCreateCi(Aig_Man_t *p)
DECLARATIONS ///.
#define Aig_ManForEachLoSeq(p, pObj, i)
Aig_Obj_t * Aig_Or(Aig_Man_t *p, Aig_Obj_t *p0, Aig_Obj_t *p1)
unsigned Aig_ManRandom(int fReset)
typedefABC_NAMESPACE_IMPL_START struct Vec_Int_t_ Vec_Int_t
DECLARATIONS ///.
#define sat_solver_addclause
int Fra_OneHotNodesAreEqual(Fra_Sml_t *pSeq, Aig_Obj_t *pObj0, Aig_Obj_t *pObj1)
Vec_Int_t * Fra_OneHotCompute(Fra_Man_t *p, Fra_Sml_t *pSim)
void Fra_OneHotAssume(Fra_Man_t *p, Vec_Int_t *vOneHots)
void Fra_OneHotEstimateCoverage(Fra_Man_t *p, Vec_Int_t *vOneHots)
int Fra_OneHotNodesAreClause(Fra_Sml_t *pSeq, Aig_Obj_t *pObj1, Aig_Obj_t *pObj2, int fCompl1, int fCompl2)
Aig_Man_t * Fra_OneHotCreateExdc(Fra_Man_t *p, Vec_Int_t *vOneHots)
int Fra_OneHotRefineUsingCex(Fra_Man_t *p, Vec_Int_t *vOneHots)
void Fra_OneHotAddKnownConstraint(Fra_Man_t *p, Vec_Ptr_t *vOnehots)
void Fra_OneHotCheck(Fra_Man_t *p, Vec_Int_t *vOneHots)
int Fra_OneHotCount(Fra_Man_t *p, Vec_Int_t *vOneHots)
int Fra_OneHotNodeIsConst(Fra_Sml_t *pSeq, Aig_Obj_t *pObj)
FUNCTION DEFINITIONS ///.
int Fra_NodesAreClause(Fra_Man_t *p, Aig_Obj_t *pOld, Aig_Obj_t *pNew, int fComplL, int fComplR)
struct Fra_Man_t_ Fra_Man_t
struct Fra_Sml_t_ Fra_Sml_t
void Fra_SmlResimulate(Fra_Man_t *p)
void sat_solver_delete(sat_solver *s)
#define Vec_IntForEachEntry(vVec, Entry, i)
MACRO DEFINITIONS ///.
#define Vec_IntForEachEntryStart(vVec, Entry, i, Start)
#define Vec_PtrForEachEntryStart(Type, vVec, pEntry, i, Start)
typedefABC_NAMESPACE_HEADER_START struct Vec_Ptr_t_ Vec_Ptr_t
INCLUDES ///.
#define Vec_PtrForEachEntry(Type, vVec, pEntry, i)
MACRO DEFINITIONS ///.