51 Gia_Obj_t * pRoot = Gia_ObjFanin0( Gia_ManPo(pOld, Gia_ManPoNum(pOld)-1) );
54 assert( Gia_ManCiNum(pGold) == Gia_ManCiNum(pOld) );
55 assert( Gia_ManCoNum(pGold) == Gia_ManCoNum(pOld) - 1 );
56 assert( Gia_ObjIsAnd(pRoot) );
62 Gia_ManConst0(pGold)->Value = 0;
64 pObj->
Value = Gia_ManAppendCi( pNew );
65 NewPi = Gia_ManAppendCi( pNew );
69 pObj->
Value = Gia_ObjFanin0Copy( pObj );
71 Gia_ManConst0(pOld)->Value = 0;
73 pObj->
Value = Gia_ManCi(pGold, i)->Value;
80 pObj->
Value = Gia_ObjFanin0Copy( pObj );
86 pObj->
Value = Abc_LitNot(NewPi);
90 pObj->
Value = Gia_ObjFanin0Copy( pObj );
94 Gia_ManAppendCo( pNew, Miter );
97 Gia_ManAppendCo( pNew, pObj->
Value );
101 assert( Gia_ManPiNum(pNew) == Gia_ManCiNum(pGold) + 1 );
102 assert( Gia_ManPoNum(pNew) == Gia_ManCoNum(pGold) + 1 + Vec_IntSize(vFans) );
122 pCnf =
Cnf_Derive( pAig, Aig_ManCoNum(pAig) );
140 int nBTLimit = 1000000;
141 Vec_Int_t * vLits = Vec_IntAlloc( Vec_IntSize(vVars) );
142 int status, i, Div, iVar, nFinal, * pFinal, nIter = 0, RetValue = 0;
145 pLits[0] = Abc_Var2Lit( Root, 0 );
146 pLits[1] = Abc_Var2Lit( nVars, 0 );
152 { RetValue = -1;
break; }
154 { RetValue = 1;
break; }
157 Vec_IntClear( vLits );
158 Vec_IntPush( vLits, Abc_LitNot(pLits[0]) );
160 Vec_IntPush( vLits, sat_solver_var_literal(pSat, Div) );
162 status =
sat_solver_solve( pSat, Vec_IntArray(vLits), Vec_IntArray(vLits) + Vec_IntSize(vLits), nBTLimit, 0, 0, 0 );
164 { RetValue = -1;
break; }
169 nFinal = sat_solver_final( pSat, &pFinal );
170 Vec_IntClear( vLits );
171 Vec_IntPush( vLits, Abc_LitNot(pLits[1]) );
172 printf(
"Cube %d : ", nIter );
173 for ( i = 0; i < nFinal; i++ )
175 if ( pFinal[i] == pLits[0] )
177 Vec_IntPush( vLits, pFinal[i] );
178 iVar = Vec_IntFind( vVars, Abc_Lit2Var(pFinal[i]) );
assert( iVar >= 0 );
179 printf(
"%s%d ", Abc_LitIsCompl(pFinal[i]) ?
"+":
"-", iVar );
182 status =
sat_solver_addclause( pSat, Vec_IntArray(vLits), Vec_IntArray(vLits) + Vec_IntSize(vLits) );
187 Vec_IntFree( vLits );
204 int i, Lit, RetValue, Root;
208 Cnf_Dat_t * pCnf = Cnf_DeriveGiaRemapped(
p );
212 for ( i = 0; i < pCnf->
nClauses; i++ )
216 assert( Gia_ManPoNum(
p) == nOuts + 1 + nIns );
221 Lit = Abc_Var2Lit( pCnf->
pVarNums[Gia_ObjId(
p, pObj)], 1 );
226 pObj = Gia_ManPo(
p, nOuts );
227 Lit = Abc_Var2Lit( pCnf->
pVarNums[Gia_ObjId(
p, pObj)], 0 );
234 vVars = Vec_IntAlloc( nIns );
236 if ( i >= nOuts + 1 )
237 Vec_IntPush( vVars, pCnf->
pVarNums[Gia_ObjId(
p, pObj)] );
238 assert( Vec_IntSize(vVars) == nIns );
240 pObj = Gia_ManPi(
p, Gia_ManPiNum(
p) - 1 );
241 Root = pCnf->
pVarNums[Gia_ObjId(
p, pObj)];
244 Vec_IntFree( vVars );
261 char * pFileGold =
"eco_gold.aig";
262 char * pFileOld =
"eco_old.aig";
271 pFile = fopen( pFileGold,
"r" );
274 printf(
"File \"%s\" does not exist.\n", pFileGold );
278 pFile = fopen( pFileOld,
"r" );
281 printf(
"File \"%s\" does not exist.\n", pFileOld );
289 vFans = Vec_IntAlloc( Gia_ManCiNum(pOld) );
291 Vec_IntPush( vFans, Gia_ObjId(pOld, pObj) );
293 Vec_IntFree( vFans );
296 RetValue =
Bmc_EcoPatch( pMiter, Gia_ManCiNum(pGold), Gia_ManCoNum(pGold) );
298 printf(
"Patch is computed.\n" );
300 printf(
"Cannot be patched.\n" );
301 if ( RetValue == -1 )
302 printf(
"Resource limit exceeded.\n" );
#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 ///.
int Bmc_EcoSolve(sat_solver *pSat, int Root, Vec_Int_t *vVars)
ABC_NAMESPACE_IMPL_START Gia_Man_t * Bmc_EcoMiter(Gia_Man_t *pGold, Gia_Man_t *pOld, Vec_Int_t *vFans)
DECLARATIONS ///.
int Bmc_EcoPatch(Gia_Man_t *p, int nIns, int nOuts)
#define sat_solver_addclause
Cnf_Dat_t * Cnf_Derive(Aig_Man_t *pAig, int nOutputs)
struct Cnf_Dat_t_ Cnf_Dat_t
Aig_Man_t * Gia_ManToAigSimple(Gia_Man_t *p)
void Gia_ManStop(Gia_Man_t *p)
#define Gia_ManForEachPo(p, pObj, i)
#define Gia_ManForEachAnd(p, pObj, i)
Gia_Man_t * Gia_AigerRead(char *pFileName, int fGiaSimple, int fSkipStrash, int fCheck)
void Gia_ManHashAlloc(Gia_Man_t *p)
Gia_Man_t * Gia_ManStart(int nObjsMax)
FUNCTION DEFINITIONS ///.
int Gia_ManHashOr(Gia_Man_t *p, int iLit0, int iLit1)
struct Gia_Obj_t_ Gia_Obj_t
int Gia_ManHashXor(Gia_Man_t *p, int iLit0, int iLit1)
struct Gia_Man_t_ Gia_Man_t
#define Gia_ManForEachObjVec(vVec, p, pObj, i)
Gia_Man_t * Gia_ManCleanup(Gia_Man_t *p)
int Gia_ManHashAnd(Gia_Man_t *p, int iLit0, int iLit1)
#define Gia_ManForEachCo(p, pObj, i)
#define Gia_ManForEachCi(p, pObj, i)
void Gia_AigerWrite(Gia_Man_t *p, char *pFileName, int fWriteSymbols, int fCompact, int fWriteNewLine)
sat_solver * sat_solver_new(void)
int sat_solver_simplify(sat_solver *s)
void sat_solver_setnvars(sat_solver *s, int n)
int sat_solver_nvars(sat_solver *s)
#define Vec_IntForEachEntry(vVec, Entry, i)
MACRO DEFINITIONS ///.