177{
178 int nSatVars = 1;
179 Vec_Int_t * vLits0, * vLits1, * vMiters, * vSatMap, * vPartMap, * vCopies;
184 int iVar0, iVar1, iLit, iLit0, iLit1;
185 int i, f, status, nChanges, nMiters, RetValue = 1;
186 assert( Vec_IntSize(vInit0) == Gia_ManRegNum(
p) );
187 assert( Vec_IntSize(vInit1) == Gia_ManRegNum(
p) );
188
189
191 sat_solver_set_runtime_limit( pSat, nTimeOut ? nTimeOut * CLOCKS_PER_SEC + Abc_Clock(): 0 );
192
194 pNew->
pName = Abc_UtilStrsav(
p->pName );
196 Gia_ManConst0(
p)->Value = 0;
197
198 vLits0 = Vec_IntAlloc( Gia_ManRegNum(
p) );
200 Vec_IntPush( vLits0, iLit < 2 ? iLit : Gia_ManAppendCi(pNew) );
201
202 vLits1 = Vec_IntAlloc( Gia_ManRegNum(
p) );
204 Vec_IntPush( vLits1, iLit < 2 ? iLit : Gia_ManAppendCi(pNew) );
205
206 vMiters = Vec_IntAlloc( 1000 );
207 vSatMap = Vec_IntAlloc( 1000 );
208 vPartMap = Vec_IntAlloc( 1000 );
209 vCopies = Vec_IntAlloc( 1000 );
210 for ( f = 0; f < nFrames; f++ )
211 {
215 assert( Vec_IntSize(vLits0) == Vec_IntSize(vLits1) );
216 nMiters = 0;
217 Vec_IntClear( vMiters );
219 if ( (iLit0 >= 2 || iLit1 >= 2) && iLit0 != iLit1 )
220 Vec_IntPush( vMiters,
Gia_ManHashXor(pNew, iLit0, iLit1) ), nMiters++;
221 else
222 Vec_IntPush( vMiters, -1 );
223 assert( Vec_IntSize(vMiters) == Gia_ManRegNum(
p) );
224 if ( Vec_IntSum(vMiters) + Vec_IntSize(vLits1) == 0 )
225 {
226 if ( fVerbose )
227 printf( "Reached a fixed point after %d frames. \n", f+1 );
228 break;
229 }
230
231 pPart =
Bmc_BmciPart( pNew, vSatMap, vMiters, vPartMap, vCopies );
232 pCnf = Cnf_DeriveGiaRemapped( pPart );
233 Cnf_DataLiftGia( pCnf, pPart, nSatVars );
234 nSatVars += pCnf->
nVars;
236 for ( i = 0; i < pCnf->
nClauses; i++ )
239
241 {
242 iVar0 = pCnf->
pVarNums[Gia_ObjId(pPart, pObj)];
243 iVar1 = Vec_IntEntry( vSatMap, Vec_IntEntry(vPartMap, Gia_ObjId(pPart, pObj)) );
244 if ( iVar1 == -1 )
245 continue;
246 sat_solver_add_buffer( pSat, iVar0, iVar1, 0 );
247 }
248
251 {
252 assert( Gia_ObjIsCi(pObj) || Vec_IntEntry( vSatMap, Vec_IntEntry(vPartMap, i) ) == -1 );
253 Vec_IntWriteEntry( vSatMap, Vec_IntEntry(vPartMap, i), pCnf->
pVarNums[i] );
254 }
257
258 nChanges = 0;
260 {
261 if ( iLit == -1 )
262 continue;
263 assert( Vec_IntEntry(vSatMap, Abc_Lit2Var(iLit)) > 0 );
264 iLit = Abc_Lit2LitV( Vec_IntArray(vSatMap), iLit );
265 status =
sat_solver_solve( pSat, &iLit, &iLit + 1, (ABC_INT64_T)0, (ABC_INT64_T)0, (ABC_INT64_T)0, (ABC_INT64_T)0 );
267 {
268 nChanges++;
269 continue;
270 }
272 {
273 printf( "Timeout reached after %d seconds. \n", nTimeOut );
274 RetValue = 0;
275 goto cleanup;
276 }
278 iLit0 = Vec_IntEntry( vLits0, i );
279 iLit1 = Vec_IntEntry( vLits1, i );
280 assert( (iLit0 >= 2 || iLit1 >= 2) && iLit0 != iLit1 );
281 if ( iLit1 >= 2 )
282 Vec_IntWriteEntry( vLits1, i, iLit0 );
283 else
284 Vec_IntWriteEntry( vLits0, i, iLit1 );
285 iLit0 = Vec_IntEntry( vLits0, i );
286 iLit1 = Vec_IntEntry( vLits1, i );
288 }
289 if ( fVerbose )
290 {
291 printf( "Frame %4d : ", f+1 );
292 printf( "Vars =%7d ", nSatVars );
295 printf( "AIG =%7d ", Gia_ManAndNum(pNew) );
296 printf( "Miters =%5d ", nMiters );
297 printf( "SAT =%5d ", nChanges );
298 Abc_PrintTime( 1, "Time", Abc_Clock() - clk );
299 }
300 if ( nChanges == 0 )
301 {
302 printf( "Reached a fixed point after %d frames. \n", f+1 );
303 break;
304 }
305 }
306cleanup:
307
310 Vec_IntFree( vLits0 );
311 Vec_IntFree( vLits1 );
312 Vec_IntFree( vMiters );
313 Vec_IntFree( vSatMap );
314 Vec_IntFree( vPartMap );
315 Vec_IntFree( vCopies );
316 return RetValue;
317}
typedefABC_NAMESPACE_IMPL_START struct Vec_Int_t_ Vec_Int_t
DECLARATIONS ///.
void Bmc_BmciUnfold(Gia_Man_t *pNew, Gia_Man_t *p, Vec_Int_t *vFFLits, int fPiReuse)
Gia_Man_t * Bmc_BmciPart(Gia_Man_t *pNew, Vec_Int_t *vSatMap, Vec_Int_t *vMiters, Vec_Int_t *vPartMap, Vec_Int_t *vCopies)
#define sat_solver_addclause
struct Cnf_Dat_t_ Cnf_Dat_t
void Cnf_DataFree(Cnf_Dat_t *p)
void Gia_ManStop(Gia_Man_t *p)
#define Gia_ManForEachCand(p, pObj, i)
void Gia_ManStopP(Gia_Man_t **p)
void Gia_ManHashAlloc(Gia_Man_t *p)
#define Gia_ManForEachPi(p, pObj, i)
int Gia_ManHashXor(Gia_Man_t *p, int iLit0, int iLit1)
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)
void sat_solver_delete(sat_solver *s)
#define Vec_IntForEachEntryTwo(vVec1, vVec2, Entry1, Entry2, i)