74 pNew =
Gia_ManStart( fUseVars * 2 * Gia_ManRegNum(
p) + nFrames * Gia_ManObjNum(
p) );
75 pNew->
pName = Abc_UtilStrsav(
p->pName );
77 Gia_ManConst0(
p)->Value = 0;
80 Gia_ManAppendCi( pNew );
82 Gia_ManAppendCi( pNew );
84 assert( !vInit || Vec_IntSize(vInit) == Gia_ManRegNum(
p) );
87 int Value = Vec_IntEntry( vInit, i );
88 int iCtrl = Gia_ManCiLit( pNew, i );
89 int iData = Gia_ManCiLit( pNew, Gia_ManRegNum(
p)+i );
93 else if ( Value == 1 )
95 else if ( Value == 2 )
97 else if ( Value == 3 )
99 else if ( Value == 4 )
101 else if ( Value == 5 )
105 for ( f = 0; f < nFrames; f++ )
108 pObj->
Value = Gia_ManAppendCi( pNew );
112 pObj->
Value = Gia_ObjFanin0Copy(pObj);
114 pObj->
Value = Gia_ObjRoToRi(
p, pObj)->Value;
117 pObj->
Value = Gia_ManAppendCo( pNew, pObj->
Value );
120 assert( Gia_ManPiNum(pNew) == 2 * Gia_ManRegNum(
p) + nFrames * Gia_ManPiNum(
p) );
138 int nIterMax = 1000000;
139 int i, iLit, Iter, status;
141 abctime clkTotal = Abc_Clock();
149 Cnf_Dat_t * pCnf = Cnf_DeriveGiaRemapped( pM );
152 assert( Gia_ManRegNum(
p) > 0 );
154 printf(
"Running with %d frames and %sgiven init state.\n", nFrames, vInit ?
"":
"no " );
158 sat_solver_set_runtime_limit( pSat, nTimeOut ? nTimeOut * CLOCKS_PER_SEC + Abc_Clock(): 0 );
159 for ( i = 0; i < pCnf->
nClauses; i++ )
164 vLits = Vec_IntAlloc( Gia_ManCoNum(
p) );
166 Vec_IntPush( vLits, Abc_Var2Lit(pCnf->
pVarNums[Gia_ObjId(pM, pObj)], 0) );
170 Vec_IntClear( vLits );
172 if ( i == Gia_ManRegNum(
p) )
174 else if ( Vec_IntEntry(vInit, i) == 0 || Vec_IntEntry(vInit, i) == 1 )
175 Vec_IntPush( vLits, Abc_Var2Lit(pCnf->
pVarNums[Gia_ObjId(pM, pObj)], 1) );
179 printf(
"Iter%6d : ", 0 );
183 printf(
"Subset =%6d ", Vec_IntSize(vLits) );
184 Abc_PrintTime( 1,
"Time", clkSat );
187 for ( Iter = 0; Iter < nIterMax; Iter++ )
190 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 );
191 clkSat += Abc_Clock() - clk;
196 printf(
"Timeout reached after %d seconds and %d iterations. ", nTimeOut, Iter );
203 printf(
"The problem is SAT after %d iterations. ", Iter );
207 nLits = sat_solver_final( pSat, &pLits );
210 printf(
"Iter%6d : ", Iter+1 );
214 printf(
"Subset =%6d ", nLits );
215 Abc_PrintTime( 1,
"Time", clkSat );
218 if ( Vec_IntSize(vLits) == nLits )
222 printf(
"Reached fixed point with %d entries after %d iterations. ", Vec_IntSize(vLits), Iter+1 );
226 Vec_IntClear( vLits );
227 for ( i = 0; i < nLits; i++ )
228 Vec_IntPush( vLits, Abc_LitNot(pLits[i]) );
231 vMap = Vec_IntStart( pCnf->
nVars );
233 Vec_IntWriteEntry( vMap, Abc_Lit2Var(iLit), 1 );
236 Vec_IntFree( vLits );
237 vLits = Vec_IntDup(vInit);
239 if ( i == Gia_ManRegNum(
p) )
241 else if ( Vec_IntEntry(vLits, i) == 4 || Vec_IntEntry(vLits, i) == 5 )
242 Vec_IntWriteEntry( vLits, i, Vec_IntEntry(vLits, i) );
243 else if ( (Vec_IntEntry(vLits, i) == 0 || Vec_IntEntry(vLits, i) == 1) && !Vec_IntEntry(vMap, pCnf->
pVarNums[Gia_ObjId(pM, pObj)]) )
244 Vec_IntWriteEntry( vLits, i, Vec_IntEntry(vLits, i) | 2 );
251 Abc_PrintTime( 1,
"Total runtime", Abc_Clock() - clkTotal );
269 vInit = vInit0 ? vInit0 : Vec_IntStart( Gia_ManRegNum(
p) );
271 if ( vInit != vInit0 )
272 Vec_IntFree( vInit );
#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 * Gia_ManMaxiPerform(Gia_Man_t *p, Vec_Int_t *vInit, int nFrames, int nTimeOut, int fVerbose)
Gia_Man_t * Gia_ManMaxiUnfold(Gia_Man_t *p, int nFrames, int fUseVars, Vec_Int_t *vInit)
Vec_Int_t * Gia_ManMaxiTest(Gia_Man_t *p, Vec_Int_t *vInit0, int nFrames, int nWords, int nTimeOut, int fSim, int fVerbose)
#define sat_solver_addclause
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)
#define Gia_ManForEachRo(p, pObj, i)
#define Gia_ManForEachAnd(p, pObj, i)
void Gia_ManHashAlloc(Gia_Man_t *p)
#define Gia_ManForEachPi(p, pObj, i)
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
struct Gia_Man_t_ Gia_Man_t
Gia_Man_t * Gia_ManCleanup(Gia_Man_t *p)
int Gia_ManHashAnd(Gia_Man_t *p, int iLit0, int iLit1)
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_ManForEachCo(p, pObj, i)
#define Gia_ManForEachRi(p, pObj, i)
sat_solver * sat_solver_new(void)
int sat_solver_nconflicts(sat_solver *s)
int sat_solver_nclauses(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 ///.