82static inline int Cbs0_VarIsAssigned(
Gia_Obj_t * pVar ) {
return pVar->
fMark0; }
87static inline int Cbs0_VarIsJust(
Gia_Obj_t * pVar ) {
return Gia_ObjIsAnd(pVar) && !Cbs0_VarIsAssigned(Gia_ObjFanin0(pVar)) && !Cbs0_VarIsAssigned(Gia_ObjFanin1(pVar)); }
88static inline int Cbs0_VarFanin0Value(
Gia_Obj_t * pVar ) {
return !Cbs0_VarIsAssigned(Gia_ObjFanin0(pVar)) ? 2 : (Cbs0_VarValue(Gia_ObjFanin0(pVar)) ^ Gia_ObjFaninC0(pVar)); }
89static inline int Cbs0_VarFanin1Value(
Gia_Obj_t * pVar ) {
return !Cbs0_VarIsAssigned(Gia_ObjFanin1(pVar)) ? 2 : (Cbs0_VarValue(Gia_ObjFanin1(pVar)) ^ Gia_ObjFaninC1(pVar)); }
91#define Cbs0_QueForEachEntry( Que, pObj, i ) \
92 for ( i = (Que).iHead; (i < (Que).iTail) && ((pObj) = (Que).pData[i]); i++ )
112 pPars->nBTLimit = 1000;
113 pPars->nJustLimit = 100;
114 pPars->fUseHighest = 1;
115 pPars->fUseLowest = 0;
116 pPars->fUseMaxFF = 0;
135 p->pProp.nSize =
p->pJust.nSize = 10000;
138 p->vModel = Vec_IntAlloc( 1000 );
156 Vec_IntFree(
p->vModel );
192static inline int Cbs0_ManCheckLimits(
Cbs0_Man_t *
p )
194 return p->Pars.nJustThis >
p->Pars.nJustLimit ||
p->Pars.nBTThis >
p->Pars.nBTLimit;
212 Vec_IntClear( vCex );
215 if ( Gia_ObjIsCi(pVar) )
217 Vec_IntPush( vCex, Abc_Var2Lit(Gia_ObjCioId(pVar), !Cbs0_VarValue(pVar)) );
233 return p->iHead ==
p->iTail;
249 if (
p->iTail ==
p->nSize )
254 p->pData[
p->iTail++] = pObj;
289static inline void Cbs0_QueStore(
Cbs0_Que_t *
p,
int * piHeadOld,
int * piTailOld )
292 *piHeadOld =
p->iHead;
293 *piTailOld =
p->iTail;
294 for ( i = *piHeadOld; i < *piTailOld; i++ )
295 Cbs0_QuePush(
p,
p->pData[i] );
296 p->iHead = *piTailOld;
310static inline void Cbs0_QueRestore(
Cbs0_Que_t *
p,
int iHeadOld,
int iTailOld )
331 assert( !Gia_IsComplement(pObj) );
332 assert( Gia_ObjIsAnd(pObj) );
333 Count0 = Gia_ObjRefNum(
p->pAig, Gia_ObjFanin0(pObj) );
334 Count1 = Gia_ObjRefNum(
p->pAig, Gia_ObjFanin1(pObj) );
335 return Abc_MaxInt( Count0, Count1 );
354 if ( pObjMax == NULL || pObjMax < pObj )
375 if ( pObjMin == NULL || pObjMin > pObj )
394 int i, iMaxFF = 0, iCurFF;
395 assert(
p->pAig->pRefs != NULL );
398 iCurFF = Cbs0_VarFaninFanoutMax(
p, pObj );
400 if ( iMaxFF < iCurFF )
422static inline void Cbs0_ManCancelUntil(
Cbs0_Man_t *
p,
int iBound )
426 assert( iBound <= p->pProp.iTail );
427 p->pProp.iHead = iBound;
429 Cbs0_VarUnassign( pVar );
430 p->pProp.iTail = iBound;
447 assert( Gia_ObjIsCand(pObjR) );
448 assert( !Cbs0_VarIsAssigned(pObjR) );
449 Cbs0_VarAssign( pObjR );
450 Cbs0_VarSetValue( pObjR, !Gia_IsComplement(pObj) );
451 Cbs0_QuePush( &
p->pProp, pObjR );
468 assert( !Gia_IsComplement(pVar) );
469 assert( Cbs0_VarIsAssigned(pVar) );
470 if ( Gia_ObjIsCi(pVar) )
472 assert( Gia_ObjIsAnd(pVar) );
473 Value0 = Cbs0_VarFanin0Value(pVar);
474 Value1 = Cbs0_VarFanin1Value(pVar);
475 if ( Cbs0_VarValue(pVar) )
477 if ( Value0 == 0 || Value1 == 0 )
480 Cbs0_ManAssign(
p, Gia_ObjChild0(pVar) );
482 Cbs0_ManAssign(
p, Gia_ObjChild1(pVar) );
486 if ( Value0 == 0 || Value1 == 0 )
488 if ( Value0 == 1 && Value1 == 1 )
490 if ( Value0 == 1 || Value1 == 1 )
493 Cbs0_ManAssign(
p, Gia_Not(Gia_ObjChild0(pVar)) );
495 Cbs0_ManAssign(
p, Gia_Not(Gia_ObjChild1(pVar)) );
498 assert( Cbs0_VarIsJust(pVar) );
499 assert( !Cbs0_QueHasNode( &
p->pJust, pVar ) );
500 Cbs0_QuePush( &
p->pJust, pVar );
518 assert( !Gia_IsComplement(pVar) );
519 assert( Gia_ObjIsAnd(pVar) );
520 assert( Cbs0_VarIsAssigned(pVar) );
521 assert( !Cbs0_VarValue(pVar) );
522 Value0 = Cbs0_VarFanin0Value(pVar);
523 Value1 = Cbs0_VarFanin1Value(pVar);
525 if ( Value0 == 0 || Value1 == 0 )
527 if ( Value0 == 1 && Value1 == 1 )
529 assert( Value0 == 1 || Value1 == 1 );
531 Cbs0_ManAssign(
p, Gia_Not(Gia_ObjChild0(pVar)) );
533 Cbs0_ManAssign(
p, Gia_Not(Gia_ObjChild1(pVar)) );
556 if ( Cbs0_ManPropagateOne(
p, pVar ) )
559 p->pProp.iHead =
p->pProp.iTail;
563 if ( Cbs0_VarIsJust( pVar ) )
564 p->pJust.pData[k++] = pVar;
565 else if ( Cbs0_ManPropagateTwo(
p, pVar ) )
568 if ( k ==
p->pJust.iTail )
589 int iPropHead, iJustHead, iJustTail;
591 assert( !Cbs0_QueIsEmpty(&
p->pProp) );
595 assert( Cbs0_QueIsEmpty(&
p->pProp) );
596 if ( Cbs0_QueIsEmpty(&
p->pJust) )
599 p->Pars.nJustThis = Abc_MaxInt(
p->Pars.nJustThis,
p->pJust.iTail -
p->pJust.iHead );
600 if ( Cbs0_ManCheckLimits(
p ) )
603 iPropHead =
p->pProp.iHead;
604 Cbs0_QueStore( &
p->pJust, &iJustHead, &iJustTail );
606 if (
p->Pars.fUseHighest )
607 pVar = Cbs0_ManDecideHighest(
p );
608 else if (
p->Pars.fUseLowest )
609 pVar = Cbs0_ManDecideLowest(
p );
610 else if (
p->Pars.fUseMaxFF )
611 pVar = Cbs0_ManDecideMaxFF(
p );
613 assert( Cbs0_VarIsJust( pVar ) );
615 if ( Gia_ObjRefNum(
p->pAig, Gia_ObjFanin0(pVar)) > Gia_ObjRefNum(
p->pAig, Gia_ObjFanin1(pVar)) )
616 pDecVar = Gia_Not(Gia_ObjChild0(pVar));
618 pDecVar = Gia_Not(Gia_ObjChild1(pVar));
620 Cbs0_ManAssign(
p, pDecVar );
623 Cbs0_ManCancelUntil(
p, iPropHead );
624 Cbs0_QueRestore( &
p->pJust, iJustHead, iJustTail );
626 Cbs0_ManAssign(
p, Gia_Not(pDecVar) );
649 assert( !
p->pProp.iHead && !
p->pProp.iTail );
650 assert( !
p->pJust.iHead && !
p->pJust.iTail );
651 p->Pars.nBTThis =
p->Pars.nJustThis = 0;
652 Cbs0_ManAssign(
p, pObj );
654 if ( RetValue == 0 && !Cbs0_ManCheckLimits(
p) )
655 Cbs0_ManSaveModel(
p,
p->vModel );
656 Cbs0_ManCancelUntil(
p, 0 );
657 p->pJust.iHead =
p->pJust.iTail = 0;
658 p->Pars.nBTTotal +=
p->Pars.nBTThis;
659 p->Pars.nJustTotal = Abc_MaxInt(
p->Pars.nJustTotal,
p->Pars.nJustThis );
660 if ( Cbs0_ManCheckLimits(
p ) )
680 printf(
"CO = %8d ", Gia_ManCoNum(
p->pAig) );
681 printf(
"AND = %8d ", Gia_ManAndNum(
p->pAig) );
682 printf(
"Conf = %6d ",
p->Pars.nBTLimit );
683 printf(
"JustMax = %5d ",
p->Pars.nJustLimit );
685 printf(
"Unsat calls %6d (%6.2f %%) Ave conf = %8.1f ",
686 p->nSatUnsat,
p->nSatTotal? 100.0*
p->nSatUnsat/
p->nSatTotal :0.0,
p->nSatUnsat? 1.0*
p->nConfUnsat/
p->nSatUnsat :0.0 );
687 ABC_PRTP(
"Time",
p->timeSatUnsat,
p->timeTotal );
688 printf(
"Sat calls %6d (%6.2f %%) Ave conf = %8.1f ",
689 p->nSatSat,
p->nSatTotal? 100.0*
p->nSatSat/
p->nSatTotal :0.0,
p->nSatSat? 1.0*
p->nConfSat/
p->nSatSat : 0.0 );
690 ABC_PRTP(
"Time",
p->timeSatSat,
p->timeTotal );
691 printf(
"Undef calls %6d (%6.2f %%) Ave conf = %8.1f ",
692 p->nSatUndec,
p->nSatTotal? 100.0*
p->nSatUndec/
p->nSatTotal :0.0,
p->nSatUndec? 1.0*
p->nConfUndec/
p->nSatUndec : 0.0 );
693 ABC_PRTP(
"Time",
p->timeSatUndec,
p->timeTotal );
694 ABC_PRT(
"Total time",
p->timeTotal );
716 abctime clk, clkTotal = Abc_Clock();
717 assert( Gia_ManRegNum(pAig) == 0 );
724 p->Pars.nBTLimit = nConfs;
727 vStatus = Vec_StrAlloc( Gia_ManPoNum(pAig) );
728 vCexStore = Vec_IntAlloc( 10000 );
729 vVisit = Vec_IntAlloc( 100 );
734 Vec_IntClear( vCex );
735 if ( Gia_ObjIsConst0(Gia_ObjFanin0(pRoot)) )
737 if ( Gia_ObjFaninC0(pRoot) )
739 printf(
"Constant 1 output of SRM!!!\n" );
741 Vec_StrPush( vStatus, 0 );
746 Vec_StrPush( vStatus, 1 );
751 p->Pars.fUseHighest = 1;
752 p->Pars.fUseLowest = 0;
762 Vec_StrPush( vStatus, (
char)status );
766 p->nConfUndec +=
p->Pars.nBTThis;
768 p->timeSatUndec += Abc_Clock() - clk;
774 p->nConfUnsat +=
p->Pars.nBTThis;
775 p->timeSatUnsat += Abc_Clock() - clk;
779 p->nConfSat +=
p->Pars.nBTThis;
782 p->timeSatSat += Abc_Clock() - clk;
784 Vec_IntFree( vVisit );
785 p->nSatTotal = Gia_ManPoNum(pAig);
786 p->timeTotal = Abc_Clock() - clkTotal;
#define ABC_ALLOC(type, num)
#define ABC_PRTP(a, t, T)
#define ABC_REALLOC(type, obj, num)
#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 ///.
struct Vec_Str_t_ Vec_Str_t
void Cec_ManSatAddToStore(Vec_Int_t *vCexStore, Vec_Int_t *vCex, int Out)
int Cbs0_ManSolve_rec(Cbs0_Man_t *p)
int Cbs0_ManSolve(Cbs0_Man_t *p, Gia_Obj_t *pObj)
void Cbs0_SetDefaultParams(Cbs0_Par_t *pPars)
FUNCTION DEFINITIONS ///.
#define Cbs0_QueForEachEntry(Que, pObj, i)
int Cbs0_ManPropagate(Cbs0_Man_t *p)
void Cbs0_ManStop(Cbs0_Man_t *p)
struct Cbs0_Man_t_ Cbs0_Man_t
Vec_Int_t * Cbs_ManSolveMiter(Gia_Man_t *pAig, int nConfs, Vec_Str_t **pvStatus, int fVerbose)
struct Cbs0_Que_t_ Cbs0_Que_t
Vec_Int_t * Cbs0_ReadModel(Cbs0_Man_t *p)
typedefABC_NAMESPACE_IMPL_START struct Cbs0_Par_t_ Cbs0_Par_t
DECLARATIONS ///.
void Cbs0_ManSatPrintStats(Cbs0_Man_t *p)
Cbs0_Man_t * Cbs0_ManAlloc()
struct Gia_Obj_t_ Gia_Obj_t
struct Gia_Man_t_ Gia_Man_t
void Gia_ManCleanMark0(Gia_Man_t *p)
void Gia_ManCreateRefs(Gia_Man_t *p)
#define Gia_ManForEachCo(p, pObj, i)
void Gia_ManCleanMark1(Gia_Man_t *p)