74 if (
p->pVarNums[Gia_ObjId(pGia, pObj)] >= 0 )
75 p->pVarNums[Gia_ObjId(pGia, pObj)] += nVarsPlus;
76 for ( v = 0; v <
p->nLiterals; v++ )
77 p->pClauses[0][v] += 2*nVarsPlus;
96 int i, k, iVar0, iVar1, iVarOut;
102 sat_solver_set_runtime_limit( pSat, nTimeOut ? nTimeOut * CLOCKS_PER_SEC + Abc_Clock(): 0 );
105 vLits = Vec_IntAlloc( Gia_ManCoNum(
p) );
107 Vec_IntPush( vLits, Abc_Var2Lit(Gia_ManRegNum(
p) + i, 0) );
111 Cnf_DataLiftGia( pCnf, pMiter, Gia_ManRegNum(
p) + Gia_ManCoNum(
p) );
112 VarShift += Gia_ManRegNum(
p) + Gia_ManCoNum(
p);
117 pObj0 = Gia_ManPo( pMiter, 2*i+0 );
118 pObj1 = Gia_ManPo( pMiter, 2*i+1 );
119 iVar0 = pCnf->
pVarNums[Gia_ObjId(pMiter, pObj0)];
120 iVar1 = pCnf->
pVarNums[Gia_ObjId(pMiter, pObj1)];
121 iVarOut = Gia_ManRegNum(
p) + i;
126 pObj0 = Gia_ManRi( pMiter, i );
127 pObj1 = Gia_ManRi( pMiter, i + Gia_ManRegNum(
p) );
128 iVar0 = pCnf->
pVarNums[Gia_ObjId(pMiter, pObj0)];
129 iVar1 = pCnf->
pVarNums[Gia_ObjId(pMiter, pObj1)];
130 iVarOut = Gia_ManRegNum(
p) + Gia_ManPoNum(
p) + i;
131 sat_solver_add_xor_and( pSat, iVarOut, iVar0, iVar1, i );
134 for ( i = 0; i < pCnf->
nClauses; i++ )
139 for ( k = 0; k < nFramesMax; k++ )
142 Vec_IntClear( vLits );
144 Vec_IntPush( vLits, pCnf->
pVarNums[Gia_ObjId(pMiter, pObj)] );
146 Cnf_DataLiftGia( pCnf, pMiter, pCnf->
nVars );
147 VarShift += pCnf->
nVars;
151 iVar0 = pCnf->
pVarNums[Gia_ObjId(pMiter, pObj)];
152 iVar1 = Vec_IntEntry( vLits, i );
155 sat_solver_add_buffer( pSat, iVar0, iVar1, 0 );
160 pObj0 = Gia_ManPo( pMiter, 2*i+0 );
161 pObj1 = Gia_ManPo( pMiter, 2*i+1 );
162 iVar0 = pCnf->
pVarNums[Gia_ObjId(pMiter, pObj0)];
163 iVar1 = pCnf->
pVarNums[Gia_ObjId(pMiter, pObj1)];
164 sat_solver_add_buffer( pSat, iVar0, iVar1, 0 );
168 pObj0 = Gia_ManRi( pMiter, i );
169 pObj1 = Gia_ManRi( pMiter, i + Gia_ManRegNum(
p) );
170 iVar0 = pCnf->
pVarNums[Gia_ObjId(pMiter, pObj0)];
171 iVar1 = pCnf->
pVarNums[Gia_ObjId(pMiter, pObj1)];
172 sat_solver_add_buffer_enable( pSat, iVar0, iVar1, i, 0 );
175 for ( i = 0; i < pCnf->
nClauses; i++ )
180 Cnf_DataLiftGia( pCnf, pMiter, -VarShift );
181 Vec_IntFree( vLits );
204 int nLitsUsed, nLits, * pLits;
205 abctime clkStart = Abc_Clock();
207 assert( Gia_ManRegNum(
p) > 0 );
210 printf(
"Solving M-inductiveness for design %s with %d AND nodes and %d flip-flops:\n",
211 Gia_ManName(
p), Gia_ManAndNum(
p), Gia_ManRegNum(
p) );
217 assert( Gia_ManPoNum(pMiter) == 2 * Gia_ManPoNum(
p) );
218 assert( Gia_ManRegNum(pMiter) == 2 * Gia_ManRegNum(
p) );
221 pCnf = Cnf_DeriveGiaRemapped( pMiter );
230 vLits = Vec_IntAlloc( Gia_ManCoNum(
p) );
231 for ( i = 0; i < Gia_ManRegNum(
p); i++ )
232 Vec_IntPush( vLits, Abc_Var2Lit(i, fEmpty) );
235 nLitsUsed = fEmpty ? 0 : Vec_IntSize(vLits);
236 vUsed = Vec_IntAlloc( Vec_IntSize(vLits) );
243 status =
sat_solver_solve( pSat, Vec_IntArray(vLits), Vec_IntArray(vLits) + Vec_IntSize(vLits), (ABC_INT64_T)0, (ABC_INT64_T)0, (ABC_INT64_T)0, (ABC_INT64_T)0 );
246 printf(
"Timeout reached after %d seconds.\n", nTimeOut );
251 printf(
"The problem is satisfiable (the current set is not M-inductive).\n" );
256 nLits = sat_solver_final( pSat, &pLits );
258 Vec_IntFill( vUsed, Vec_IntSize(vLits), 0 );
259 for ( i = 0; i < nLits; i++ )
260 Vec_IntWriteEntry( vUsed, Abc_Lit2Var(pLits[i]), 1 );
265 assert( i == Abc_Lit2Var(Lit) );
266 if ( Abc_LitIsCompl(Lit) )
268 if ( Vec_IntEntry(vUsed, i) )
271 Vec_IntWriteEntry( vLits, i, Abc_LitNot(Lit) );
277 printf(
"M =%4d : AIG =%8d. SAT vars =%8d. SAT conf =%8d. S =%6d. (%6.2f %%) ",
278 nFramesMax, (nFramesMax+1) * Gia_ManAndNum(pMiter),
282 Abc_PrintTime( 1,
"Time", Abc_Clock() - clkStart );
285 if ( !fChanges || fEmpty )
292 Vec_IntFree( vLits );
293 Vec_IntFree( vUsed );
309 if ( Gia_ObjIsTravIdCurrent(
p, pObj) )
311 Gia_ObjSetTravIdCurrent(
p, pObj);
312 if ( Gia_ObjIsCi(pObj) )
314 if ( Gia_ObjIsRo(
p, pObj) )
315 Vec_IntPush( vRegs, Gia_ObjId(
p, pObj) );
318 assert( Gia_ObjIsAnd(pObj) );
327 Vec_IntClear( vRegs );
329 Vec_IntPush( vRegs, Gia_ObjId(
p, pObj) );
332 Gia_ObjSetTravIdCurrent(
p, Gia_ManConst0(
p) );
335 assert( Gia_ObjIsPo(
p, pObj) || Gia_ObjIsRo(
p, pObj) );
336 if ( Gia_ObjIsRo(
p, pObj) )
337 pObj = Gia_ObjRoToRi(
p, pObj );
342 if ( !Gia_ObjIsTravIdCurrent(
p, pObj) )
343 Vec_IntPush( vRegs, Gia_ObjId(
p, pObj) );
345 assert( Vec_IntSize(vRegs) == Gia_ManCoNum(
p) );
348 if ( i < Gia_ManPoNum(
p) )
350 iReg = Gia_ObjCioId(pObj) - Gia_ManPiNum(
p);
351 assert( iReg >= 0 && iReg < Gia_ManRegNum(
p) );
352 Vec_IntWriteEntry( vRegs, k++, iReg );
354 Vec_IntShrink( vRegs, k );
355 assert( Vec_IntSize(vRegs) == Gia_ManRegNum(
p) );
379 int nLitsUsed, RetValue = 0;
380 abctime clkStart = Abc_Clock();
382 assert( Gia_ManRegNum(
p) > 0 );
388 assert( Gia_ManPoNum(pMiter) == 2 * Gia_ManPoNum(
p) );
389 assert( Gia_ManRegNum(pMiter) == 2 * Gia_ManRegNum(
p) );
392 pCnf = Cnf_DeriveGiaRemapped( pMiter );
408 status =
sat_solver_solve( pSat, Vec_IntArray(vLits), Vec_IntArray(vLits) + Vec_IntSize(vLits), (ABC_INT64_T)0, (ABC_INT64_T)0, (ABC_INT64_T)0, (ABC_INT64_T)0 );
411 printf(
"I = %4d : ", nFramesMax );
412 printf(
"Problem is satisfiable.\n" );
420 printf(
"ICheck: Timeout reached after %d seconds. \n", nTimeOut );
428 for ( i = 0; i < Gia_ManRegNum(
p); i++ )
429 if ( !Abc_LitIsCompl(Vec_IntEntry(vLits, i)) )
433 vRegs = Vec_IntStartNatural( Gia_ManRegNum(
p) );
437 Vec_IntReverseOrder( vRegs );
442 if ( Abc_LitIsCompl(Vec_IntEntry(vLits, i)) )
444 Vec_IntWriteEntry( vLits, i, Abc_LitNot(Vec_IntEntry(vLits, i)) );
445 status =
sat_solver_solve( pSat, Vec_IntArray(vLits), Vec_IntArray(vLits) + Vec_IntSize(vLits), (ABC_INT64_T)0, (ABC_INT64_T)0, (ABC_INT64_T)0, (ABC_INT64_T)0 );
448 printf(
"ICheck: Timeout reached after %d seconds. \n", nTimeOut );
453 Vec_IntWriteEntry( vLits, i, Abc_LitNot(Vec_IntEntry(vLits, i)) );
461 printf(
"I = %4d : AIG =%8d. SAT vars =%8d. SAT conf =%8d. S =%6d. (%6.2f %%) ",
462 i, (nFramesMax+1) * Gia_ManAndNum(pMiter),
465 ABC_PRTr(
"Time", Abc_Clock() - clkStart );
473 printf(
"M = %4d : AIG =%8d. SAT vars =%8d. SAT conf =%8d. S =%6d. (%6.2f %%) ",
474 nFramesMax, (nFramesMax+1) * Gia_ManAndNum(pMiter),
477 Abc_PrintTime( 1,
"Time", Abc_Clock() - clkStart );
485 Vec_IntFree( vRegs );
494 printf(
"Solving M-inductiveness for design %s with %d AND nodes and %d flip-flops with %s %s flop order:\n",
495 Gia_ManName(
p), Gia_ManAndNum(
p), Gia_ManRegNum(
p), fReverse ?
"reverse":
"direct", fBackTopo ?
"backward":
"natural" );
499 vLits = Vec_IntAlloc( Gia_ManCoNum(
p) );
500 for ( i = 0; i < Gia_ManRegNum(
p); i++ )
501 Vec_IntPush( vLits, Abc_Var2Lit(i, 0) );
503 for ( f = 1; f <= nFramesMax; f++ )
506 Vec_IntFree( vLits );
514 for ( i = 0; i < Gia_ManRegNum(
p); i++ )
515 if ( !Abc_LitIsCompl(Vec_IntEntry(vLits, i)) )
517 printf(
"The set contains %d (out of %d) next-state functions with 0-based numbers:\n", nLitsUsed, Gia_ManRegNum(
p) );
518 for ( i = 0; i < Gia_ManRegNum(
p); i++ )
519 if ( !Abc_LitIsCompl(Vec_IntEntry(vLits, i)) )
524 vFlops = Vec_IntAlloc( Gia_ManRegNum(
p) );
525 for ( i = 0; i < Gia_ManRegNum(
p); i++ )
526 if ( !Abc_LitIsCompl(Vec_IntEntry(vLits, i)) )
527 Vec_IntPush( vFlops, 1 );
529 Vec_IntPush( vFlops, 0 );
530 Vec_IntFree( vLits );
#define ABC_NAMESPACE_IMPL_START
#define ABC_NAMESPACE_IMPL_END
void Aig_ManStop(Aig_Man_t *p)
typedefABC_NAMESPACE_HEADER_START struct Aig_Man_t_ Aig_Man_t
INCLUDES ///.
typedefABC_NAMESPACE_IMPL_START struct Vec_Int_t_ Vec_Int_t
DECLARATIONS ///.
Vec_Int_t * Bmc_PerformISearch(Gia_Man_t *p, int nFramesMax, int nTimeOut, int fReverse, int fBackTopo, int fDump, int fVerbose)
void Bmc_PerformICheck(Gia_Man_t *p, int nFramesMax, int nTimeOut, int fEmpty, int fVerbose)
int Bmc_PerformISearchOne(Gia_Man_t *p, int nFramesMax, int nTimeOut, int fReverse, int fBackTopo, int fVerbose, Vec_Int_t *vLits)
void Bmc_PerformFindFlopOrder(Gia_Man_t *p, Vec_Int_t *vRegs)
sat_solver * Bmc_DeriveSolver(Gia_Man_t *p, Gia_Man_t *pMiter, Cnf_Dat_t *pCnf, int nFramesMax, int nTimeOut, int fVerbose)
void Bmc_PerformFindFlopOrder_rec(Gia_Man_t *p, Gia_Obj_t *pObj, Vec_Int_t *vRegs)
#define sat_solver_addclause
#define sat_solver_add_xor
Cnf_Dat_t * Cnf_Derive(Aig_Man_t *pAig, int nOutputs)
struct Cnf_Dat_t_ Cnf_Dat_t
void Cnf_DataFree(Cnf_Dat_t *p)
Aig_Man_t * Gia_ManToAigSimple(Gia_Man_t *p)
void Gia_ManStop(Gia_Man_t *p)
Gia_Man_t * Gia_ManDup(Gia_Man_t *p)
#define Gia_ManForEachRo(p, pObj, i)
#define Gia_ManForEachPo(p, pObj, i)
struct Gia_Obj_t_ Gia_Obj_t
struct Gia_Man_t_ Gia_Man_t
#define Gia_ManForEachObjVec(vVec, p, pObj, i)
void Gia_ManIncrementTravId(Gia_Man_t *p)
Gia_Man_t * Gia_ManMiter(Gia_Man_t *pAig0, Gia_Man_t *pAig1, int nInsDup, int fDualOut, int fSeq, int fImplic, int fVerbose)
#define Gia_ManForEachObj(p, pObj, i)
MACRO DEFINITIONS ///.
#define Gia_ManForEachCo(p, pObj, i)
#define Gia_ManForEachRi(p, pObj, i)
Gia_Man_t * Jf_ManDeriveCnf(Gia_Man_t *p, int fCnfObjIds)
void * Mf_ManGenerateCnf(Gia_Man_t *pGia, int nLutSize, int fCnfObjIds, int fAddOrCla, int fMapping, int fVerbose)
sat_solver * sat_solver_new(void)
int sat_solver_nconflicts(sat_solver *s)
void sat_solver_setnvars(sat_solver *s, int n)
int sat_solver_nvars(sat_solver *s)
void sat_solver_delete(sat_solver *s)
#define Vec_IntForEachEntry(vVec, Entry, i)
MACRO DEFINITIONS ///.