31#define PAR_THR_MAX 100
55static inline int * Bmcg_ManCopies(
Bmcg_Man_t *
p,
int f ) {
return (
int*)Vec_PtrEntry(&
p->vGia2Fr, f); }
75 int i, Lit = Abc_Var2Lit( 0, 1 );
77 assert( Gia_ManRegNum(pGia) > 0 );
85 Vec_PtrGrow( &
p->vGia2Fr, 1000 );
86 Vec_IntGrow( &
p->vFr2Sat, 3*Gia_ManCiNum(pGia) );
87 Vec_IntPush( &
p->vFr2Sat, 0 );
88 Vec_IntGrow( &
p->vCiMap, 3*Gia_ManCiNum(pGia) );
89 for ( i = 0; i <
p->pPars->nProcs; i++ )
105 Vec_PtrFreeData( &
p->vGia2Fr );
106 Vec_PtrErase( &
p->vGia2Fr );
107 Vec_IntErase( &
p->vFr2Sat );
108 Vec_IntErase( &
p->vCiMap );
109 for ( i = 0; i <
p->pPars->nProcs; i++ )
130 int iLit = 0, * pCopies = Bmcg_ManCopies(
p, f );
131 if ( pCopies[iObj] >= 0 )
132 return pCopies[iObj];
133 pObj = Gia_ManObj(
p->pGia, iObj );
134 if ( Gia_ObjIsCi(pObj) )
136 if ( Gia_ObjIsPi(
p->pGia, pObj) )
138 Vec_IntPushTwo( &
p->vCiMap, Gia_ObjCioId(pObj), f );
139 iLit = Gia_ManAppendCi(
p->pFrames );
143 pObj = Gia_ObjRoToRi(
p->pGia, pObj );
145 iLit = Abc_LitNotCond( iLit, Gia_ObjFaninC0(pObj) );
148 else if ( Gia_ObjIsAnd(pObj) )
151 iLit = Abc_LitNotCond( iLit, Gia_ObjFaninC0(pObj) );
156 iNew = Abc_LitNotCond( iNew, Gia_ObjFaninC1(pObj) );
161 return (pCopies[iObj] = iLit);
166 int iSatVar, iLitClean = Gia_ObjCopyArray(
p->pFrames, iObj );
167 if ( iLitClean >= 0 )
169 pObj = Gia_ManObj(
p->pFrames, iObj );
170 iSatVar = Vec_IntEntry( &
p->vFr2Sat, iObj );
171 if ( iSatVar > 0 || Gia_ObjIsCi(pObj) )
172 iLitClean = Gia_ManAppendCi(
p->pClean );
173 else if ( Gia_ObjIsAnd(pObj) )
177 iLit0 = Abc_LitNotCond( iLit0, Gia_ObjFaninC0(pObj) );
178 iLit1 = Abc_LitNotCond( iLit1, Gia_ObjFaninC1(pObj) );
179 iLitClean = Gia_ManAppendAnd(
p->pClean, iLit0, iLit1 );
182 assert( !Abc_LitIsCompl(iLitClean) );
183 Gia_ManObj(
p->pClean, Abc_Lit2Var(iLitClean) )->Value = iObj;
184 Gia_ObjSetCopyArray(
p->pFrames, iObj, iLitClean );
190 int i, k, iLitFrame, iLitClean, fTrivial = 1;
191 int * pCopies, nFrameObjs = Gia_ManObjNum(
p->pFrames);
192 assert( Gia_ManPoNum(
p->pFrames) == f * Gia_ManPoNum(
p->pGia) );
193 for ( k = 0; k < nFramesAdd; k++ )
196 Vec_PtrPush( &
p->vGia2Fr,
ABC_FALLOC(
int, Gia_ManObjNum(
p->pGia)) );
197 assert( Vec_PtrSize(&
p->vGia2Fr) == f+k+1 );
198 pCopies = Bmcg_ManCopies(
p, f+k );
204 iLitFrame = Abc_LitNotCond( iLitFrame, Gia_ObjFaninC0(pObj) );
205 pCopies[Gia_ObjId(
p->pGia, pObj)] = Gia_ManAppendCo(
p->pFrames, iLitFrame );
206 fTrivial &= (iLitFrame == 0);
212 Vec_IntFillExtra( &
p->vFr2Sat, Gia_ManObjNum(
p->pFrames), -1 );
213 Vec_IntFillExtra( &
p->pFrames->vCopies, Gia_ManObjNum(
p->pFrames), -1 );
216 p->pClean =
Gia_ManStart( Gia_ManObjNum(
p->pFrames) - nFrameObjs + 1000 );
217 Gia_ObjSetCopyArray(
p->pFrames, 0, 0 );
218 for ( k = 0; k < nFramesAdd; k++ )
219 for ( i = 0; i < Gia_ManPoNum(
p->pGia); i++ )
221 pObj = Gia_ManCo(
p->pFrames, (f+k) * Gia_ManPoNum(
p->pGia) + i );
223 iLitClean = Abc_LitNotCond( iLitClean, Gia_ObjFaninC0(pObj) );
224 iLitClean = Gia_ManAppendCo(
p->pClean, iLitClean );
225 Gia_ManObj(
p->pClean, Abc_Lit2Var(iLitClean) )->Value = Gia_ObjId(
p->pFrames, pObj);
226 Gia_ObjSetCopyArray(
p->pFrames, Gia_ObjId(
p->pFrames, pObj), iLitClean );
228 pNew =
p->pClean;
p->pClean = NULL;
230 Gia_ObjSetCopyArray(
p->pFrames, pObj->
Value, -1 );
240 p->timeUnf += Abc_Clock() - clk;
245 pMap =
ABC_FALLOC(
int, Gia_ManObjNum(pNew) );
249 if ( pCnf->
pObj2Count[i] <= 0 && !Gia_ObjIsCi(pObj) )
251 iVar = Vec_IntEntry( &
p->vFr2Sat, pObj->
Value );
253 Vec_IntWriteEntry( &
p->vFr2Sat, pObj->
Value, (iVar =
p->nSatVars++) );
260 p->timeCnf += Abc_Clock() - clk;
278 if ( !
p->pPars->fVerbose )
280 Abc_Print( 1,
"%4d %s : ", f, fUnfinished ?
"-" :
"+" );
287 if (
p->pPars->nProcs > 1 )
288 Abc_Print( 1,
"S = %3d. ", Solver );
289 Abc_Print( 1,
"%4.0f MB", 1.0*((
int)
Gia_ManMemory(
p->pFrames) + Vec_IntMemory(&
p->vFr2Sat))/(1<<20) );
290 Abc_Print( 1,
"%9.2f sec ", (
float)(Abc_Clock() - clkStart)/(
float)(CLOCKS_PER_SEC) );
296 abctime clkTotal =
p->timeUnf +
p->timeCnf +
p->timeSmp +
p->timeSat +
p->timeOth;
297 if ( !
p->pPars->fVerbose )
299 ABC_PRTP(
"Unfolding ",
p->timeUnf, clkTotal );
300 ABC_PRTP(
"CNF generation",
p->timeCnf, clkTotal );
301 ABC_PRTP(
"CNF simplify ",
p->timeSmp, clkTotal );
302 ABC_PRTP(
"SAT solving ",
p->timeSat, clkTotal );
303 ABC_PRTP(
"Other ",
p->timeOth, clkTotal );
304 ABC_PRTP(
"TOTAL ", clkTotal , clkTotal );
312 int iSatVar = Vec_IntEntry( &
p->vFr2Sat, Gia_ObjId(
p->pFrames, pObj) );
315 int iCiId = Vec_IntEntry( &
p->vCiMap, 2*k+0 );
316 int iFrame = Vec_IntEntry( &
p->vCiMap, 2*k+1 );
317 Abc_InfoSetBit( pCex->pData, Gia_ManRegNum(
p->pGia) + iFrame * Gia_ManPiNum(
p->pGia) + iCiId );
327 if (
p->pPars->fUseEliminate )
329 for ( i =
p->nOldFrPis; i < Gia_ManPiNum(
p->pFrames); i++ )
331 Gia_Obj_t * pObj = Gia_ManPi(
p->pFrames, i );
332 int iSatVar = Vec_IntEntry( &
p->vFr2Sat, Gia_ObjId(
p->pFrames, pObj) );
336 for ( i =
p->nOldFrPos; i < Gia_ManPoNum(
p->pFrames); i++ )
338 Gia_Obj_t * pObj = Gia_ManPo(
p->pFrames, i );
339 int iSatVar = Vec_IntEntry( &
p->vFr2Sat, Gia_ObjId(
p->pFrames, pObj) );
343 p->nOldFrPis = Gia_ManPiNum(
p->pFrames);
344 p->nOldFrPos = Gia_ManPoNum(
p->pFrames);
346 for ( i = 0; i < pCnf->
nClauses; i++ )
349 if ( !
p->pPars->fUseEliminate )
354 Vec_IntWriteEntry( &
p->vFr2Sat, i, -1 );
355 p->timeSmp += Abc_Clock() - clk;
359 abctime clkStart = Abc_Clock();
361 int f, k = 0, i = Gia_ManPoNum(pGia), status, RetValue = -1, nClauses = 0;
371 for ( i = 0; i < Gia_ManPoNum(pGia); i++ )
378 assert( Gia_ManPoNum(
p->pFrames) == (f + pPars->
nFramesAdd) * Gia_ManPoNum(pGia) );
381 for ( i = 0; i < Gia_ManPoNum(pGia); i++ )
384 int iObj = Gia_ObjId(
p->pFrames, Gia_ManCo(
p->pFrames, (f+k) * Gia_ManPoNum(pGia) + i) );
385 int iLit = Abc_Var2Lit( Vec_IntEntry(&
p->vFr2Sat, iObj), 0 );
386 if ( pPars->
nTimeOut && (Abc_Clock() - clkStart)/CLOCKS_PER_SEC >= pPars->
nTimeOut )
389 p->timeSat += Abc_Clock() - clk;
392 if ( i == Gia_ManPoNum(pGia)-1 )
407 int nOutDigits = Abc_Base10Log( Gia_ManPoNum(pGia) );
408 Abc_Print( 1,
"Output %*d was asserted in frame %2d (solved %*d out of %*d outputs). ",
409 nOutDigits, i, f+k, nOutDigits, pPars->
nFailOuts, nOutDigits, Gia_ManPoNum(pGia) );
417 if ( i < Gia_ManPoNum(pGia) || f+k == pPars->
nFramesMax-1 )
420 if ( k < pPars->nFramesAdd )
423 p->timeOth = Abc_Clock() - clkStart -
p->timeUnf -
p->timeCnf -
p->timeSmp -
p->timeSat;
426 printf(
"No output failed in %d frames. ", f + (k < pPars->nFramesAdd ? k+1 : 0) );
427 Abc_PrintTime( 1,
"Time", Abc_Clock() - clkStart );
int bmcg_sat_solver_conflictnum(bmcg_sat_solver *s)
void bmcg_sat_solver_set_stop(bmcg_sat_solver *s, int *pstop)
int bmcg_sat_solver_learntnum(bmcg_sat_solver *s)
int bmcg_sat_solver_varnum(bmcg_sat_solver *s)
int bmcg_sat_solver_addvar(bmcg_sat_solver *s)
bmcg_sat_solver * bmcg_sat_solver_start()
MACRO DEFINITIONS ///.
int bmcg_sat_solver_solve(bmcg_sat_solver *s, int *plits, int nlits)
int bmcg_sat_solver_addclause(bmcg_sat_solver *s, int *plits, int nlits)
void bmcg_sat_solver_var_set_frozen(bmcg_sat_solver *s, int v, int freeze)
int bmcg_sat_solver_read_cex_varvalue(bmcg_sat_solver *s, int ivar)
int bmcg_sat_solver_eliminate(bmcg_sat_solver *s, int turn_off_elim)
void bmcg_sat_solver_set_nvars(bmcg_sat_solver *s, int nvars)
int bmcg_sat_solver_elim_varnum(bmcg_sat_solver *s)
int bmcg_sat_solver_clausenum(bmcg_sat_solver *s)
void bmcg_sat_solver_stop(bmcg_sat_solver *s)
int bmcg_sat_solver_var_is_elim(bmcg_sat_solver *s, int v)
#define ABC_FALLOC(type, num)
#define ABC_PRTP(a, t, T)
#define ABC_CALLOC(type, num)
#define ABC_NAMESPACE_IMPL_START
#define ABC_NAMESPACE_IMPL_END
typedefABC_NAMESPACE_IMPL_START struct Vec_Int_t_ Vec_Int_t
DECLARATIONS ///.
void Bmcg_ManStop(Bmcg_Man_t *p)
void Bmcg_ManAddCnf(Bmcg_Man_t *p, bmcg_sat_solver *pSat, Cnf_Dat_t *pCnf)
int Bmcg_ManPerform(Gia_Man_t *pGia, Bmc_AndPar_t *pPars)
Abc_Cex_t * Bmcg_ManGenerateCex(Bmcg_Man_t *p, int i, int f, int s)
Cnf_Dat_t * Bmcg_ManAddNewCnf(Bmcg_Man_t *p, int f, int nFramesAdd)
int Bmcg_ManPerformOne(Gia_Man_t *pGia, Bmc_AndPar_t *pPars)
void Bmcg_ManPrintTime(Bmcg_Man_t *p)
#define PAR_THR_MAX
DECLARATIONS ///.
int Bmcg_ManUnfold_rec(Bmcg_Man_t *p, int iObj, int f)
Gia_Man_t * Bmcg_ManUnfold(Bmcg_Man_t *p, int f, int nFramesAdd)
Bmcg_Man_t * Bmcg_ManStart(Gia_Man_t *pGia, Bmc_AndPar_t *pPars)
FUNCTION DEFINITIONS ///.
void Bmcg_ManPrintFrame(Bmcg_Man_t *p, int f, int nClauses, int Solver, abctime clkStart)
struct Bmcg_Man_t_ Bmcg_Man_t
int Bmcg_ManCollect_rec(Bmcg_Man_t *p, int iObj)
struct Bmc_AndPar_t_ Bmc_AndPar_t
struct Cnf_Dat_t_ Cnf_Dat_t
void Cnf_DataFree(Cnf_Dat_t *p)
void Gia_ManStop(Gia_Man_t *p)
void Gia_ManHashStart(Gia_Man_t *p)
double Gia_ManMemory(Gia_Man_t *p)
#define Gia_ManForEachPo(p, pObj, i)
void Gia_ManStopP(Gia_Man_t **p)
#define Gia_ManForEachPi(p, pObj, i)
Gia_Man_t * Gia_ManStart(int nObjsMax)
FUNCTION DEFINITIONS ///.
struct Gia_Obj_t_ Gia_Obj_t
struct Gia_Man_t_ Gia_Man_t
#define Gia_ManForEachObj1(p, pObj, i)
int Gia_ManHashAnd(Gia_Man_t *p, int iLit0, int iLit1)
#define Gia_ManForEachObj(p, pObj, i)
MACRO DEFINITIONS ///.
void * Mf_ManGenerateCnf(Gia_Man_t *pGia, int nLutSize, int fCnfObjIds, int fAddOrCla, int fMapping, int fVerbose)
void(* pFuncOnFrameDone)(int, int, int)
bmcg_sat_solver * pSats[PAR_THR_MAX]
void Abc_CexFreeP(Abc_Cex_t **p)
Abc_Cex_t * Abc_CexMakeTriv(int nRegs, int nTruePis, int nTruePos, int iFrameOut)
typedefABC_NAMESPACE_HEADER_START struct Abc_Cex_t_ Abc_Cex_t
INCLUDES ///.
#define Vec_IntForEachEntry(vVec, Entry, i)
MACRO DEFINITIONS ///.
typedefABC_NAMESPACE_HEADER_START struct Vec_Ptr_t_ Vec_Ptr_t
INCLUDES ///.