120 Gia_Obj_t * pObj = Gia_ManObj( pNew, iIdNew );
121 int iLitPart0, iLitPart1, iRes;
122 if ( Vec_IntEntry(vCopies, iIdNew) )
123 return Vec_IntEntry(vCopies, iIdNew);
124 if ( Vec_IntEntry(vSatMap, iIdNew) >= 0 || Gia_ObjIsCi(pObj) )
126 Vec_IntPush( vPartMap, iIdNew );
127 iRes = Gia_ManAppendCi(pPart);
128 Vec_IntWriteEntry( vCopies, iIdNew, iRes );
131 assert( Gia_ObjIsAnd(pObj) );
132 iLitPart0 =
Bmc_BmciPart_rec( pNew, vSatMap, Gia_ObjFaninId0(pObj, iIdNew), pPart, vPartMap, vCopies );
133 iLitPart1 =
Bmc_BmciPart_rec( pNew, vSatMap, Gia_ObjFaninId1(pObj, iIdNew), pPart, vPartMap, vCopies );
134 iLitPart0 = Abc_LitNotCond( iLitPart0, Gia_ObjFaninC0(pObj) );
135 iLitPart1 = Abc_LitNotCond( iLitPart1, Gia_ObjFaninC1(pObj) );
136 Vec_IntPush( vPartMap, iIdNew );
137 iRes = Gia_ManAppendAnd( pPart, iLitPart0, iLitPart1 );
138 Vec_IntWriteEntry( vCopies, iIdNew, iRes );
144 int i, iLit, iLitPart;
145 Vec_IntFill( vCopies, Gia_ManObjNum(pNew), 0 );
146 Vec_IntFillExtra( vSatMap, Gia_ManObjNum(pNew), -1 );
149 Vec_IntClear( vPartMap );
150 Vec_IntPush( vPartMap, 0 );
156 iLitPart =
Bmc_BmciPart_rec( pNew, vSatMap, Abc_Lit2Var(iLit), pPart, vPartMap, vCopies );
157 Gia_ManAppendCo( pPart, Abc_LitNotCond(iLitPart, Abc_LitIsCompl(iLit)) );
158 Vec_IntPush( vPartMap, -1 );
160 assert( Gia_ManPoNum(pPart) > 0 );
161 assert( Vec_IntSize(vPartMap) == Gia_ManObjNum(pPart) );
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) );
191 sat_solver_set_runtime_limit( pSat, nTimeOut ? nTimeOut * CLOCKS_PER_SEC + Abc_Clock(): 0 );
194 pNew->
pName = Abc_UtilStrsav(
p->pName );
196 Gia_ManConst0(
p)->Value = 0;
198 vLits0 = Vec_IntAlloc( Gia_ManRegNum(
p) );
200 Vec_IntPush( vLits0, iLit < 2 ? iLit : Gia_ManAppendCi(pNew) );
202 vLits1 = Vec_IntAlloc( Gia_ManRegNum(
p) );
204 Vec_IntPush( vLits1, iLit < 2 ? iLit : Gia_ManAppendCi(pNew) );
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++ )
215 assert( Vec_IntSize(vLits0) == Vec_IntSize(vLits1) );
217 Vec_IntClear( vMiters );
219 if ( (iLit0 >= 2 || iLit1 >= 2) && iLit0 != iLit1 )
220 Vec_IntPush( vMiters,
Gia_ManHashXor(pNew, iLit0, iLit1) ), nMiters++;
222 Vec_IntPush( vMiters, -1 );
223 assert( Vec_IntSize(vMiters) == Gia_ManRegNum(
p) );
224 if ( Vec_IntSum(vMiters) + Vec_IntSize(vLits1) == 0 )
227 printf(
"Reached a fixed point after %d frames. \n", f+1 );
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++ )
242 iVar0 = pCnf->
pVarNums[Gia_ObjId(pPart, pObj)];
243 iVar1 = Vec_IntEntry( vSatMap, Vec_IntEntry(vPartMap, Gia_ObjId(pPart, pObj)) );
246 sat_solver_add_buffer( pSat, iVar0, iVar1, 0 );
252 assert( Gia_ObjIsCi(pObj) || Vec_IntEntry( vSatMap, Vec_IntEntry(vPartMap, i) ) == -1 );
253 Vec_IntWriteEntry( vSatMap, Vec_IntEntry(vPartMap, i), pCnf->
pVarNums[i] );
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 );
273 printf(
"Timeout reached after %d seconds. \n", nTimeOut );
278 iLit0 = Vec_IntEntry( vLits0, i );
279 iLit1 = Vec_IntEntry( vLits1, i );
280 assert( (iLit0 >= 2 || iLit1 >= 2) && iLit0 != iLit1 );
282 Vec_IntWriteEntry( vLits1, i, iLit0 );
284 Vec_IntWriteEntry( vLits0, i, iLit1 );
285 iLit0 = Vec_IntEntry( vLits0, i );
286 iLit1 = Vec_IntEntry( vLits1, i );
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 );
302 printf(
"Reached a fixed point after %d frames. \n", f+1 );
310 Vec_IntFree( vLits0 );
311 Vec_IntFree( vLits1 );
312 Vec_IntFree( vMiters );
313 Vec_IntFree( vSatMap );
314 Vec_IntFree( vPartMap );
315 Vec_IntFree( vCopies );