ABC: A System for Sequential Synthesis and Verification
 
Loading...
Searching...
No Matches
giaCSat2.c File Reference
#include "gia.h"
Include dependency graph for giaCSat2.c:

Go to the source code of this file.

Classes

struct  Cbs2_Par_t_
 
struct  Cbs2_Que_t_
 
struct  Cbs2_Man_t_
 

Macros

#define Cbs2_QueForEachEntry(Que, iObj, i)
 
#define Cbs2_ClauseForEachEntry(p, hClause, iObj, i)
 
#define Cbs2_ClauseForEachEntry1(p, hClause, iObj, i)
 
#define Cbs2_ObjForEachFanout(p, iObj, iFanLit)
 

Typedefs

typedef typedefABC_NAMESPACE_IMPL_START struct Cbs2_Par_t_ Cbs2_Par_t
 DECLARATIONS ///.
 
typedef struct Cbs2_Que_t_ Cbs2_Que_t
 
typedef struct Cbs2_Man_t_ Cbs2_Man_t
 

Functions

void Cbs2_SetDefaultParams (Cbs2_Par_t *pPars)
 FUNCTION DEFINITIONS ///.
 
void Cbs2_ManSetConflictNum (Cbs2_Man_t *p, int Num)
 
Cbs2_Man_tCbs2_ManAlloc (Gia_Man_t *pGia)
 
void Cbs2_ManStop (Cbs2_Man_t *p)
 
Vec_Int_tCbs2_ReadModel (Cbs2_Man_t *p)
 
int Cbs2_ManPropagate (Cbs2_Man_t *p, int Level)
 
int Cbs2_ManPropagate2 (Cbs2_Man_t *p, int Level)
 
int Cbs2_ManUpdateFrontier (Cbs2_Man_t *p, int iPropHeadOld, int *piDecLit)
 
int Cbs2_ManSolve1_rec (Cbs2_Man_t *p, int Level)
 
int Cbs2_ManSolve2_rec (Cbs2_Man_t *p, int Level)
 
int Cbs2_ManSolve_rec (Cbs2_Man_t *p, int Level)
 
int Cbs2_ManSolve (Cbs2_Man_t *p, int iLit)
 
int Cbs2_ManSolve2 (Cbs2_Man_t *p, int iLit, int iLit2)
 
void Cbs2_ManSatPrintStats (Cbs2_Man_t *p)
 
void Cbs2_ObjPrintFanouts (Cbs2_Man_t *p, int iObj)
 
void Cbs2_ManPrintFanouts (Cbs2_Man_t *p)
 
void Cbs2_ObjCreateFanout (Cbs2_Man_t *p, int iObj, int iFan0, int iFan1)
 
void Cbs2_ObjDeleteFanout (Cbs2_Man_t *p, int iObj)
 
void Cbs2_ManCreateFanout_rec (Cbs2_Man_t *p, int iObj)
 
void Cbs2_ManDeleteFanout_rec (Cbs2_Man_t *p, int iObj)
 
void Cbs2_ManCheckFanouts (Cbs2_Man_t *p)
 
Vec_Int_tCbs2_ManSolveMiterNc (Gia_Man_t *pAig, int nConfs, Vec_Str_t **pvStatus, int fVerbose)
 

Macro Definition Documentation

◆ Cbs2_ClauseForEachEntry

#define Cbs2_ClauseForEachEntry ( p,
hClause,
iObj,
i )
Value:
for ( i = 1; i <= Cbs2_ClauseSize(p, hClause) && (iObj = (p)->pClauses.pData[hClause+i]); i++ )
Cube * p
Definition exorList.c:222

Definition at line 162 of file giaCSat2.c.

162#define Cbs2_ClauseForEachEntry( p, hClause, iObj, i ) \
163 for ( i = 1; i <= Cbs2_ClauseSize(p, hClause) && (iObj = (p)->pClauses.pData[hClause+i]); i++ )

◆ Cbs2_ClauseForEachEntry1

#define Cbs2_ClauseForEachEntry1 ( p,
hClause,
iObj,
i )
Value:
for ( i = 2; i <= Cbs2_ClauseSize(p, hClause) && (iObj = (p)->pClauses.pData[hClause+i]); i++ )

Definition at line 164 of file giaCSat2.c.

164#define Cbs2_ClauseForEachEntry1( p, hClause, iObj, i ) \
165 for ( i = 2; i <= Cbs2_ClauseSize(p, hClause) && (iObj = (p)->pClauses.pData[hClause+i]); i++ )

◆ Cbs2_ObjForEachFanout

#define Cbs2_ObjForEachFanout ( p,
iObj,
iFanLit )
Value:
for ( iFanLit = Vec_IntEntry(&p->vFanout0, iObj); iFanLit; iFanLit = Vec_IntEntry(&p->vFanoutN, iFanLit) )

Definition at line 167 of file giaCSat2.c.

167#define Cbs2_ObjForEachFanout( p, iObj, iFanLit ) \
168 for ( iFanLit = Vec_IntEntry(&p->vFanout0, iObj); iFanLit; iFanLit = Vec_IntEntry(&p->vFanoutN, iFanLit) )

◆ Cbs2_QueForEachEntry

#define Cbs2_QueForEachEntry ( Que,
iObj,
i )
Value:
for ( i = (Que).iHead; (i < (Que).iTail) && ((iObj) = (Que).pData[i]); i++ )

Definition at line 159 of file giaCSat2.c.

159#define Cbs2_QueForEachEntry( Que, iObj, i ) \
160 for ( i = (Que).iHead; (i < (Que).iTail) && ((iObj) = (Que).pData[i]); i++ )

Typedef Documentation

◆ Cbs2_Man_t

typedef struct Cbs2_Man_t_ Cbs2_Man_t

Definition at line 63 of file giaCSat2.c.

◆ Cbs2_Par_t

typedef typedefABC_NAMESPACE_IMPL_START struct Cbs2_Par_t_ Cbs2_Par_t

DECLARATIONS ///.

CFile****************************************************************

FileName [giaCSat.c]

SystemName [ABC: Logic synthesis and verification system.]

PackageName [Scalable AIG package.]

Synopsis [A simple circuit-based solver.]

Author [Alan Mishchenko]

Affiliation [UC Berkeley]

Date [Ver. 1.0. Started - June 20, 2005.]

Revision [

Id
giaCSat.c,v 1.00 2005/06/20 00:00:00 alanmi Exp

]

Definition at line 33 of file giaCSat2.c.

◆ Cbs2_Que_t

typedef struct Cbs2_Que_t_ Cbs2_Que_t

Definition at line 54 of file giaCSat2.c.

Function Documentation

◆ Cbs2_ManAlloc()

Cbs2_Man_t * Cbs2_ManAlloc ( Gia_Man_t * pGia)

Function*************************************************************

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 212 of file giaCSat2.c.

213{
214 Cbs2_Man_t * p;
215 p = ABC_CALLOC( Cbs2_Man_t, 1 );
216 p->pProp.nSize = p->pJust.nSize = p->pClauses.nSize = 10000;
217 p->pProp.pData = ABC_ALLOC( int, p->pProp.nSize );
218 p->pJust.pData = ABC_ALLOC( int, p->pJust.nSize );
219 p->pClauses.pData = ABC_ALLOC( int, p->pClauses.nSize );
220 p->pClauses.iHead = p->pClauses.iTail = 1;
221 p->vModel = Vec_IntAlloc( 1000 );
222 p->vTemp = Vec_IntAlloc( 1000 );
223 p->pAig = pGia;
224 Cbs2_SetDefaultParams( &p->Pars );
225 Vec_StrFill( &p->vAssign, Gia_ManObjNum(pGia), 2 );
226 Vec_StrFill( &p->vMark, Gia_ManObjNum(pGia), 0 );
227 Vec_IntFill( &p->vLevReason, 3*Gia_ManObjNum(pGia), -1 );
228 Vec_IntFill( &p->vWatches, 2*Gia_ManObjNum(pGia), 0 );
229 Vec_IntFill( &p->vFanout0, Gia_ManObjNum(pGia), 0 );
230 Vec_IntFill( &p->vFanoutN, 2*Gia_ManObjNum(pGia), 0 );
231 Vec_IntFill( &p->vActivity, Gia_ManObjNum(pGia), 0 );
232 Vec_IntGrow( &p->vActStore, 1000 );
233 Vec_IntGrow( &p->vJStore, 1000 );
234 Vec_IntGrow( &p->vWatchUpds, 1000 );
235 return p;
236}
#define ABC_ALLOC(type, num)
Definition abc_global.h:264
#define ABC_CALLOC(type, num)
Definition abc_global.h:265
struct Cbs2_Man_t_ Cbs2_Man_t
Definition giaCSat2.c:63
void Cbs2_SetDefaultParams(Cbs2_Par_t *pPars)
FUNCTION DEFINITIONS ///.
Definition giaCSat2.c:185
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Cbs2_ManCheckFanouts()

void Cbs2_ManCheckFanouts ( Cbs2_Man_t * p)

Definition at line 1536 of file giaCSat2.c.

1537{
1538 Gia_Obj_t * pObj;
1539 int iObj;
1540 Gia_ManForEachObj( p->pAig, pObj, iObj )
1541 {
1542 assert( Vec_IntEntry(&p->vFanout0, iObj) == 0 );
1543 assert( Vec_IntEntry(&p->vFanoutN, Abc_Var2Lit(iObj, 0)) == 0 );
1544 assert( Vec_IntEntry(&p->vFanoutN, Abc_Var2Lit(iObj, 1)) == 0 );
1545 }
1546}
struct Gia_Obj_t_ Gia_Obj_t
Definition gia.h:76
#define Gia_ManForEachObj(p, pObj, i)
MACRO DEFINITIONS ///.
Definition gia.h:1190
#define assert(ex)
Definition util_old.h:213

◆ Cbs2_ManCreateFanout_rec()

void Cbs2_ManCreateFanout_rec ( Cbs2_Man_t * p,
int iObj )

Definition at line 1508 of file giaCSat2.c.

1509{
1510 Gia_Obj_t * pObj; int iFan0, iFan1;
1511 if ( !iObj || Gia_ObjIsTravIdCurrentId(p->pAig, iObj) )
1512 return;
1513 Gia_ObjSetTravIdCurrentId(p->pAig, iObj);
1514 pObj = Gia_ManObj(p->pAig, iObj);
1515 if ( Gia_ObjIsCi(pObj) )
1516 return;
1517 assert( Gia_ObjIsAnd(pObj) );
1518 iFan0 = Gia_ObjFaninId0(pObj, iObj);
1519 iFan1 = Gia_ObjFaninId1(pObj, iObj);
1520 Cbs2_ManCreateFanout_rec( p, iFan0 );
1521 Cbs2_ManCreateFanout_rec( p, iFan1 );
1522 Cbs2_ObjCreateFanout( p, iObj, iFan0, iFan1 );
1523}
void Cbs2_ObjCreateFanout(Cbs2_Man_t *p, int iObj, int iFan0, int iFan1)
Definition giaCSat2.c:1495
void Cbs2_ManCreateFanout_rec(Cbs2_Man_t *p, int iObj)
Definition giaCSat2.c:1508
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Cbs2_ManDeleteFanout_rec()

void Cbs2_ManDeleteFanout_rec ( Cbs2_Man_t * p,
int iObj )

Definition at line 1524 of file giaCSat2.c.

1525{
1526 Gia_Obj_t * pObj = Gia_ManObj(p->pAig, iObj); int iFan0, iFan1;
1527 Cbs2_ObjDeleteFanout( p, iObj );
1528 if ( Gia_ObjIsCi(pObj) )
1529 return;
1530 assert( Gia_ObjIsAnd(pObj) );
1531 iFan0 = Gia_ObjFaninId0(pObj, iObj);
1532 iFan1 = Gia_ObjFaninId1(pObj, iObj);
1533 if ( Vec_IntEntry(&p->vFanout0, iFan0) ) Cbs2_ManDeleteFanout_rec( p, iFan0 );
1534 if ( Vec_IntEntry(&p->vFanout0, iFan1) ) Cbs2_ManDeleteFanout_rec( p, iFan1 );
1535}
void Cbs2_ObjDeleteFanout(Cbs2_Man_t *p, int iObj)
Definition giaCSat2.c:1502
void Cbs2_ManDeleteFanout_rec(Cbs2_Man_t *p, int iObj)
Definition giaCSat2.c:1524
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Cbs2_ManPrintFanouts()

void Cbs2_ManPrintFanouts ( Cbs2_Man_t * p)

Definition at line 1488 of file giaCSat2.c.

1489{
1490 Gia_Obj_t * pObj; int iObj;
1491 Gia_ManForEachObj( p->pAig, pObj, iObj )
1492 if ( Vec_IntEntry(&p->vFanout0, iObj) )
1493 Cbs2_ObjPrintFanouts( p, iObj );
1494}
void Cbs2_ObjPrintFanouts(Cbs2_Man_t *p, int iObj)
Definition giaCSat2.c:1479
Here is the call graph for this function:

◆ Cbs2_ManPropagate()

int Cbs2_ManPropagate ( Cbs2_Man_t * p,
int Level )

Function*************************************************************

Synopsis [Propagates all variables.]

Description [Returns 1 if conflict; 0 if no conflict.]

SideEffects []

SeeAlso []

Definition at line 1103 of file giaCSat2.c.

1104{
1105 while ( 1 )
1106 {
1107 int i, k, iVar, iLit, hClause;
1108 Cbs2_QueForEachEntry( p->pProp, iLit, i )
1109 {
1110 if ( (hClause = Cbs2_ManPropagateOne( p, Abc_Lit2Var(iLit), Level )) )
1111 return hClause;
1112 }
1113 p->pProp.iHead = p->pProp.iTail;
1114 k = p->pJust.iHead;
1115 Cbs2_QueForEachEntry( p->pJust, iVar, i )
1116 {
1117 if ( Cbs2_VarIsJust(p, Gia_ManObj(p->pAig, iVar), iVar) )
1118 p->pJust.pData[k++] = iVar;
1119 else if ( (hClause = Cbs2_ManPropagateTwo( p, iVar, Level )) )
1120 return hClause;
1121 }
1122 if ( k == p->pJust.iTail )
1123 break;
1124 p->pJust.iTail = k;
1125 }
1126 return 0;
1127}
#define Cbs2_QueForEachEntry(Que, iObj, i)
Definition giaCSat2.c:159
Here is the caller graph for this function:

◆ Cbs2_ManPropagate2()

int Cbs2_ManPropagate2 ( Cbs2_Man_t * p,
int Level )

Definition at line 1130 of file giaCSat2.c.

1131{
1132 int i, iLit, iFan, hClause;
1133 Cbs2_QueForEachEntry( p->pProp, iLit, i )
1134 {
1135 if ( (hClause = Cbs2_ManPropagateClauses(p, Level, iLit)) )
1136 return hClause;
1137 Cbs2_ObjForEachFanout( p, Abc_Lit2Var(iLit), iFan )
1138 {
1139 int iFanout = Abc_Lit2Var(iFan);
1140 if ( !Cbs2_VarIsAssigned(p, iFanout) )
1141 Cbs2_ManPropagateUnassigned( p, iFanout, Level );
1142 else if ( (hClause = Cbs2_ManPropagateOne(p, iFanout, Level)) )
1143 return hClause;
1144 }
1145 if ( (hClause = Cbs2_ManPropagateOne( p, Abc_Lit2Var(iLit), Level )) )
1146 return hClause;
1147 }
1148 p->pProp.iHead = p->pProp.iTail;
1149 return 0;
1150}
#define Cbs2_ObjForEachFanout(p, iObj, iFanLit)
Definition giaCSat2.c:167
Here is the caller graph for this function:

◆ Cbs2_ManSatPrintStats()

void Cbs2_ManSatPrintStats ( Cbs2_Man_t * p)

Function*************************************************************

Synopsis [Prints statistics of the manager.]

Description []

SideEffects []

SeeAlso []

Definition at line 1449 of file giaCSat2.c.

1450{
1451 printf( "CO = %8d ", Gia_ManCoNum(p->pAig) );
1452 printf( "AND = %8d ", Gia_ManAndNum(p->pAig) );
1453 printf( "Conf = %6d ", p->Pars.nBTLimit );
1454 printf( "JustMax = %5d ", p->Pars.nJustLimit );
1455 printf( "\n" );
1456 printf( "Unsat calls %6d (%6.2f %%) Ave conf = %8.1f ",
1457 p->nSatUnsat, p->nSatTotal? 100.0*p->nSatUnsat/p->nSatTotal :0.0, p->nSatUnsat? 1.0*p->nConfUnsat/p->nSatUnsat :0.0 );
1458 ABC_PRTP( "Time", p->timeSatUnsat, p->timeTotal );
1459 printf( "Sat calls %6d (%6.2f %%) Ave conf = %8.1f ",
1460 p->nSatSat, p->nSatTotal? 100.0*p->nSatSat/p->nSatTotal :0.0, p->nSatSat? 1.0*p->nConfSat/p->nSatSat : 0.0 );
1461 ABC_PRTP( "Time", p->timeSatSat, p->timeTotal );
1462 printf( "Undef calls %6d (%6.2f %%) Ave conf = %8.1f ",
1463 p->nSatUndec, p->nSatTotal? 100.0*p->nSatUndec/p->nSatTotal :0.0, p->nSatUndec? 1.0*p->nConfUndec/p->nSatUndec : 0.0 );
1464 ABC_PRTP( "Time", p->timeSatUndec, p->timeTotal );
1465 ABC_PRT( "Total time", p->timeTotal );
1466}
#define ABC_PRT(a, t)
Definition abc_global.h:255
#define ABC_PRTP(a, t, T)
Definition abc_global.h:258
Here is the caller graph for this function:

◆ Cbs2_ManSetConflictNum()

void Cbs2_ManSetConflictNum ( Cbs2_Man_t * p,
int Num )

Definition at line 196 of file giaCSat2.c.

197{
198 p->Pars.nBTLimit = Num;
199}

◆ Cbs2_ManSolve()

int Cbs2_ManSolve ( Cbs2_Man_t * p,
int iLit )

Function*************************************************************

Synopsis [Looking for a satisfying assignment of the node.]

Description [Assumes that each node has flag pObj->fMark0 set to 0. Returns 1 if unsatisfiable, 0 if satisfiable, and -1 if undecided. The node may be complemented. ]

SideEffects [The two procedures differ in the CEX format.]

SeeAlso []

Definition at line 1389 of file giaCSat2.c.

1390{
1391 int RetValue = 0;
1392 assert( !p->pProp.iHead && !p->pProp.iTail );
1393 assert( !p->pJust.iHead && !p->pJust.iTail );
1394 assert( p->pClauses.iHead == 1 && p->pClauses.iTail == 1 );
1395 p->Pars.nBTThis = p->Pars.nJustThis = p->Pars.nBTThisNc = 0;
1396 Cbs2_ManAssign( p, iLit, 0, 0, 0 );
1397 if ( !Cbs2_ManSolve_rec(p, 0) && !Cbs2_ManCheckLimits(p) )
1398 Cbs2_ManSaveModel( p, p->vModel );
1399 else
1400 RetValue = 1;
1401 Cbs2_ManCancelUntil( p, 0 );
1402 Cbs2_ManCleanWatch( p );
1403 Cbs2_ManBumpClean( p );
1404 p->pJust.iHead = p->pJust.iTail = 0;
1405 p->pClauses.iHead = p->pClauses.iTail = 1;
1406 p->Pars.nBTTotal += p->Pars.nBTThis;
1407 p->Pars.nJustTotal = Abc_MaxInt( p->Pars.nJustTotal, p->Pars.nJustThis );
1408 if ( Cbs2_ManCheckLimits( p ) )
1409 RetValue = -1;
1410 return RetValue;
1411}
int Cbs2_ManSolve_rec(Cbs2_Man_t *p, int Level)
Definition giaCSat2.c:1371
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Cbs2_ManSolve1_rec()

int Cbs2_ManSolve1_rec ( Cbs2_Man_t * p,
int Level )

Function*************************************************************

Synopsis [Solve the problem recursively.]

Description [Returns learnt clause if unsat, NULL if sat or undecided.]

SideEffects []

SeeAlso []

Definition at line 1253 of file giaCSat2.c.

1254{
1255 Gia_Obj_t * pVar;
1256 Cbs2_Que_t * pQue = &(p->pClauses);
1257 int iPropHead, iJustHead, iJustTail;
1258 int hClause, hLearn0, hLearn1, iVar, iDecLit;
1259 // propagate assignments
1260 assert( !Cbs2_QueIsEmpty(&p->pProp) );
1261 if ( (hClause = Cbs2_ManPropagate( p, Level )) )
1262 return hClause;
1263 // check for satisfying assignment
1264 assert( Cbs2_QueIsEmpty(&p->pProp) );
1265 if ( Cbs2_QueIsEmpty(&p->pJust) )
1266 return 0;
1267 // quit using resource limits
1268 p->Pars.nJustThis = Abc_MaxInt( p->Pars.nJustThis, p->pJust.iTail - p->pJust.iHead );
1269 if ( Cbs2_ManCheckLimits( p ) )
1270 return 0;
1271 // remember the state before branching
1272 iPropHead = p->pProp.iHead;
1273 Cbs2_QueStore( &p->pJust, &iJustHead, &iJustTail );
1274 // find the decision variable
1275 assert( p->Pars.fUseHighest );
1276 iVar = Cbs2_ManDecideHighest( p );
1277 pVar = Gia_ManObj( p->pAig, iVar );
1278 assert( Cbs2_VarIsJust(p, pVar, iVar) );
1279 // chose decision variable using fanout count
1280 if ( Gia_ObjRefNum(p->pAig, Gia_ObjFanin0(pVar)) > Gia_ObjRefNum(p->pAig, Gia_ObjFanin1(pVar)) )
1281 iDecLit = Abc_LitNot(Gia_ObjFaninLit0(pVar, iVar));
1282 else
1283 iDecLit = Abc_LitNot(Gia_ObjFaninLit1(pVar, iVar));
1284 // decide on first fanin
1285 Cbs2_ManAssign( p, iDecLit, Level+1, 0, 0 );
1286 if ( !(hLearn0 = Cbs2_ManSolve1_rec( p, Level+1 )) )
1287 return 0;
1288 if ( pQue->pData[hLearn0+1] != Abc_Lit2Var(iDecLit) )
1289 return hLearn0;
1290 Cbs2_ManCancelUntil( p, iPropHead );
1291 Cbs2_QueRestore( &p->pJust, iJustHead, iJustTail );
1292 // decide on second fanin
1293 Cbs2_ManAssign( p, Abc_LitNot(iDecLit), Level+1, 0, 0 );
1294 if ( !(hLearn1 = Cbs2_ManSolve1_rec( p, Level+1 )) )
1295 return 0;
1296 if ( pQue->pData[hLearn1+1] != Abc_Lit2Var(iDecLit) )
1297 return hLearn1;
1298 hClause = Cbs2_ManResolve( p, Level, hLearn0, hLearn1 );
1299 Cbs2_ManBumpClause( p, hClause );
1300// Cbs2_ManPrintCube( p, Level, hClause );
1301// if ( Level > Cbs2_ClauseDecLevel(p, hClause) )
1302// p->Pars.nBTThisNc++;
1303 p->Pars.nBTThis++;
1304 return hClause;
1305}
int Cbs2_ManSolve1_rec(Cbs2_Man_t *p, int Level)
Definition giaCSat2.c:1253
int Cbs2_ManPropagate(Cbs2_Man_t *p, int Level)
Definition giaCSat2.c:1103
struct Cbs2_Que_t_ Cbs2_Que_t
Definition giaCSat2.c:54
int * pData
Definition giaCSat2.c:60
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Cbs2_ManSolve2()

int Cbs2_ManSolve2 ( Cbs2_Man_t * p,
int iLit,
int iLit2 )

Definition at line 1412 of file giaCSat2.c.

1413{
1414 int RetValue = 0;
1415 assert( !p->pProp.iHead && !p->pProp.iTail );
1416 assert( !p->pJust.iHead && !p->pJust.iTail );
1417 assert( p->pClauses.iHead == 1 && p->pClauses.iTail == 1 );
1418 p->Pars.nBTThis = p->Pars.nJustThis = p->Pars.nBTThisNc = 0;
1419 Cbs2_ManAssign( p, iLit, 0, 0, 0 );
1420 if ( iLit2 )
1421 Cbs2_ManAssign( p, iLit2, 0, 0, 0 );
1422 if ( !Cbs2_ManSolve_rec(p, 0) && !Cbs2_ManCheckLimits(p) )
1423 Cbs2_ManSaveModelAll( p, p->vModel );
1424 else
1425 RetValue = 1;
1426 Cbs2_ManCancelUntil( p, 0 );
1427 Cbs2_ManCleanWatch( p );
1428 Cbs2_ManBumpClean( p );
1429 p->pJust.iHead = p->pJust.iTail = 0;
1430 p->pClauses.iHead = p->pClauses.iTail = 1;
1431 p->Pars.nBTTotal += p->Pars.nBTThis;
1432 p->Pars.nJustTotal = Abc_MaxInt( p->Pars.nJustTotal, p->Pars.nJustThis );
1433 if ( Cbs2_ManCheckLimits( p ) )
1434 RetValue = -1;
1435 return RetValue;
1436}
Here is the call graph for this function:

◆ Cbs2_ManSolve2_rec()

int Cbs2_ManSolve2_rec ( Cbs2_Man_t * p,
int Level )

Definition at line 1307 of file giaCSat2.c.

1308{
1309 Gia_Obj_t * pVar;
1310 Cbs2_Que_t * pQue = &(p->pClauses);
1311 int iPropHead, iJustHead, iJustTail;
1312 int hClause, hLearn0, hLearn1, iVar, iDecLit, iDecLit2;
1313 int iPropHeadOld = p->pProp.iHead;
1314 // propagate assignments
1315 assert( !Cbs2_QueIsEmpty(&p->pProp) );
1316 if ( (hClause = Cbs2_ManPropagate2( p, Level )) )
1317 return hClause;
1318 // check for satisfying assignment
1319 assert( Cbs2_QueIsEmpty(&p->pProp) );
1320// if ( Cbs2_QueIsEmpty(&p->pJust) )
1321// return 0;
1322 if ( Cbs2_ManUpdateFrontier(p, iPropHeadOld, &iDecLit2) )
1323 return 0;
1324 // quit using resource limits
1325 p->Pars.nJustThis = Abc_MaxInt( p->Pars.nJustThis, p->pJust.iTail - p->pJust.iHead );
1326 if ( Cbs2_ManCheckLimits( p ) )
1327 return 0;
1328 // remember the state before branching
1329 iPropHead = p->pProp.iHead;
1330// Cbs2_QueStore( &p->pJust, &iJustHead, &iJustTail );
1331 iJustHead = p->pJust.iHead;
1332 iJustTail = p->pJust.iTail;
1333 // find the decision variable
1334
1335 assert( p->Pars.fUseHighest );
1336 iVar = Cbs2_ManDecideHighest( p );
1337 pVar = Gia_ManObj( p->pAig, iVar );
1338 assert( Cbs2_VarIsJust(p, pVar, iVar) );
1339 // chose decision variable using fanout count
1340 if ( Gia_ObjRefNum(p->pAig, Gia_ObjFanin0(pVar)) > Gia_ObjRefNum(p->pAig, Gia_ObjFanin1(pVar)) )
1341// if ( Vec_IntEntry(&p->vActivity, Gia_ObjFaninId0(pVar, iVar)) > Vec_IntEntry(&p->vActivity, Gia_ObjFaninId1(pVar, iVar)) )
1342 iDecLit = Abc_LitNot(Gia_ObjFaninLit0(pVar, iVar));
1343 else
1344 iDecLit = Abc_LitNot(Gia_ObjFaninLit1(pVar, iVar));
1345
1346 //iDecLit = iDecLit2;
1347
1348 // decide on first fanin
1349 Cbs2_ManAssign( p, iDecLit, Level+1, 0, 0 );
1350 if ( !(hLearn0 = Cbs2_ManSolve2_rec( p, Level+1 )) )
1351 return 0;
1352 if ( pQue->pData[hLearn0+1] != Abc_Lit2Var(iDecLit) )
1353 return hLearn0;
1354 Cbs2_ManCancelUntil( p, iPropHead );
1355 Cbs2_QueRestore( &p->pJust, iJustHead, iJustTail );
1356 // decide on second fanin
1357 Cbs2_ManAssign( p, Abc_LitNot(iDecLit), Level+1, 0, 0 );
1358 if ( !(hLearn1 = Cbs2_ManSolve2_rec( p, Level+1 )) )
1359 return 0;
1360 if ( pQue->pData[hLearn1+1] != Abc_Lit2Var(iDecLit) )
1361 return hLearn1;
1362 hClause = Cbs2_ManResolve( p, Level, hLearn0, hLearn1 );
1363 Cbs2_ManBumpClause( p, hClause );
1364 //Cbs2_ManPrintCube( p, Level, hClause );
1365// if ( Level > Cbs2_ClauseDecLevel(p, hClause) )
1366// p->Pars.nBTThisNc++;
1367 p->Pars.nBTThis++;
1368 return hClause;
1369}
int Cbs2_ManSolve2_rec(Cbs2_Man_t *p, int Level)
Definition giaCSat2.c:1307
int Cbs2_ManUpdateFrontier(Cbs2_Man_t *p, int iPropHeadOld, int *piDecLit)
Definition giaCSat2.c:1206
int Cbs2_ManPropagate2(Cbs2_Man_t *p, int Level)
Definition giaCSat2.c:1130
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Cbs2_ManSolve_rec()

int Cbs2_ManSolve_rec ( Cbs2_Man_t * p,
int Level )

Definition at line 1371 of file giaCSat2.c.

1372{
1373 return p->Pars.fUseFanout ? Cbs2_ManSolve2_rec(p, Level) : Cbs2_ManSolve1_rec(p, Level);
1374}
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Cbs2_ManSolveMiterNc()

Vec_Int_t * Cbs2_ManSolveMiterNc ( Gia_Man_t * pAig,
int nConfs,
Vec_Str_t ** pvStatus,
int fVerbose )

Function*************************************************************

Synopsis [Procedure to test the new SAT solver.]

Description []

SideEffects []

SeeAlso []

Definition at line 1559 of file giaCSat2.c.

1560{
1561 extern void Gia_ManCollectTest( Gia_Man_t * pAig );
1562 extern void Cec_ManSatAddToStore( Vec_Int_t * vCexStore, Vec_Int_t * vCex, int Out );
1563 Cbs2_Man_t * p;
1564 Vec_Int_t * vCex, * vVisit, * vCexStore;
1565 Vec_Str_t * vStatus;
1566 Gia_Obj_t * pRoot;
1567 int i, status;
1568 abctime clk, clkTotal = Abc_Clock();
1569 assert( Gia_ManRegNum(pAig) == 0 );
1570// Gia_ManCollectTest( pAig );
1571 // prepare AIG
1572 Gia_ManCreateRefs( pAig );
1573 //Gia_ManLevelNum( pAig );
1574 //Gia_ManCleanMark0( pAig );
1575 //Gia_ManCleanMark1( pAig );
1576 //Gia_ManFillValue( pAig ); // maps nodes into trail ids
1577 //Gia_ManSetPhase( pAig ); // maps nodes into trail ids
1578 // create logic network
1579 p = Cbs2_ManAlloc( pAig );
1580 p->Pars.nBTLimit = nConfs;
1581 // create resulting data-structures
1582 vStatus = Vec_StrAlloc( Gia_ManPoNum(pAig) );
1583 vCexStore = Vec_IntAlloc( 10000 );
1584 vVisit = Vec_IntAlloc( 100 );
1585 vCex = Cbs2_ReadModel( p );
1586 // solve for each output
1587 Gia_ManForEachCo( pAig, pRoot, i )
1588 {
1589 //printf( "\nOutput %d\n", i );
1590
1591 Vec_IntClear( vCex );
1592 if ( Gia_ObjIsConst0(Gia_ObjFanin0(pRoot)) )
1593 {
1594 if ( Gia_ObjFaninC0(pRoot) )
1595 {
1596// printf( "Constant 1 output of SRM!!!\n" );
1597 Cec_ManSatAddToStore( vCexStore, vCex, i ); // trivial counter-example
1598 Vec_StrPush( vStatus, 0 );
1599 }
1600 else
1601 {
1602// printf( "Constant 0 output of SRM!!!\n" );
1603 Vec_StrPush( vStatus, 1 );
1604 }
1605 continue;
1606 }
1607 clk = Abc_Clock();
1608 p->Pars.fUseHighest = 1;
1609 p->Pars.fUseLowest = 0;
1610
1611 Gia_ManIncrementTravId( pAig );
1612 Cbs2_ManCreateFanout_rec( p, Gia_ObjFaninId0p(pAig, pRoot) );
1613 //Cbs2_ManPrintFanouts( p );
1614
1615 status = Cbs2_ManSolve( p, Gia_ObjFaninLit0p(pAig, pRoot) );
1616 //printf( "\n" );
1617
1618 Cbs2_ManDeleteFanout_rec( p, Gia_ObjFaninId0p(pAig, pRoot) );
1619 //Cbs2_ManCheckFanouts( p );
1620
1621/*
1622 if ( status == -1 )
1623 {
1624 p->Pars.fUseHighest = 0;
1625 p->Pars.fUseLowest = 1;
1626 status = Cbs2_ManSolve( p, Gia_ObjChild0(pRoot) );
1627 }
1628*/
1629 Vec_StrPush( vStatus, (char)status );
1630 if ( status == -1 )
1631 {
1632 p->nSatUndec++;
1633 p->nConfUndec += p->Pars.nBTThis;
1634 Cec_ManSatAddToStore( vCexStore, NULL, i ); // timeout
1635 p->timeSatUndec += Abc_Clock() - clk;
1636 continue;
1637 }
1638 if ( status == 1 )
1639 {
1640 p->nSatUnsat++;
1641 p->nConfUnsat += p->Pars.nBTThis;
1642 p->timeSatUnsat += Abc_Clock() - clk;
1643 continue;
1644 }
1645 p->nSatSat++;
1646 p->nConfSat += p->Pars.nBTThis;
1647// Gia_SatVerifyPattern( pAig, pRoot, vCex, vVisit );
1648 Cec_ManSatAddToStore( vCexStore, vCex, i );
1649 p->timeSatSat += Abc_Clock() - clk;
1650 }
1651 Vec_IntFree( vVisit );
1652 p->nSatTotal = Gia_ManPoNum(pAig);
1653 p->timeTotal = Abc_Clock() - clkTotal;
1654 if ( fVerbose )
1656 if ( fVerbose )
1657 {
1658// printf( "RecCalls = %8d. RecClause = %8d. RecNonChro = %8d.\n", p->nRecCall, p->nRecClause, p->nRecNonChro );
1659 printf( "Prop1 = %d. Prop2 = %d. Prop3 = %d. ClaConf = %d. FailJ = %d. FailC = %d. ", p->nPropCalls[0], p->nPropCalls[1], p->nPropCalls[2], p->nClauseConf, p->nFails[0], p->nFails[1] );
1660 Abc_PrintTime( 1, "JFront", p->timeJFront );
1661 }
1662
1663 Cbs2_ManStop( p );
1664 *pvStatus = vStatus;
1665
1666// printf( "Total number of cex literals = %d. (Ave = %d)\n",
1667// Vec_IntSize(vCexStore)-2*p->nSatUndec-2*p->nSatSat,
1668// (Vec_IntSize(vCexStore)-2*p->nSatUndec-2*p->nSatSat)/p->nSatSat );
1669 return vCexStore;
1670}
ABC_INT64_T abctime
Definition abc_global.h:332
typedefABC_NAMESPACE_IMPL_START struct Vec_Int_t_ Vec_Int_t
DECLARATIONS ///.
Definition bblif.c:37
struct Vec_Str_t_ Vec_Str_t
Definition bblif.c:46
void Cec_ManSatAddToStore(Vec_Int_t *vCexStore, Vec_Int_t *vCex, int Out)
Definition cecSolve.c:996
void Cbs2_ManSatPrintStats(Cbs2_Man_t *p)
Definition giaCSat2.c:1449
Vec_Int_t * Cbs2_ReadModel(Cbs2_Man_t *p)
Definition giaCSat2.c:280
int Cbs2_ManSolve(Cbs2_Man_t *p, int iLit)
Definition giaCSat2.c:1389
void Cbs2_ManStop(Cbs2_Man_t *p)
Definition giaCSat2.c:249
Cbs2_Man_t * Cbs2_ManAlloc(Gia_Man_t *pGia)
Definition giaCSat2.c:212
void Gia_ManCollectTest(Gia_Man_t *p)
Definition giaDfs.c:232
struct Gia_Man_t_ Gia_Man_t
Definition gia.h:96
void Gia_ManCreateRefs(Gia_Man_t *p)
Definition giaUtil.c:779
void Gia_ManIncrementTravId(Gia_Man_t *p)
Definition giaUtil.c:190
#define Gia_ManForEachCo(p, pObj, i)
Definition gia.h:1236
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Cbs2_ManStop()

void Cbs2_ManStop ( Cbs2_Man_t * p)

Function*************************************************************

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 249 of file giaCSat2.c.

250{
251 Vec_StrErase( &p->vAssign );
252 Vec_StrErase( &p->vMark );
253 Vec_IntErase( &p->vLevReason );
254 Vec_IntErase( &p->vWatches );
255 Vec_IntErase( &p->vFanout0 );
256 Vec_IntErase( &p->vFanoutN );
257 Vec_IntErase( &p->vActivity );
258 Vec_IntErase( &p->vActStore );
259 Vec_IntErase( &p->vJStore );
260 Vec_IntErase( &p->vWatchUpds );
261 Vec_IntFree( p->vModel );
262 Vec_IntFree( p->vTemp );
263 ABC_FREE( p->pClauses.pData );
264 ABC_FREE( p->pProp.pData );
265 ABC_FREE( p->pJust.pData );
266 ABC_FREE( p );
267}
#define ABC_FREE(obj)
Definition abc_global.h:267
Here is the caller graph for this function:

◆ Cbs2_ManUpdateFrontier()

int Cbs2_ManUpdateFrontier ( Cbs2_Man_t * p,
int iPropHeadOld,
int * piDecLit )

Definition at line 1206 of file giaCSat2.c.

1207{
1208 abctime clk = Abc_Clock();
1209 int i, iVar, iLit, iJustTailOld = p->pJust.iTail;
1210 *piDecLit = -1;
1211 assert( Cbs2_QueIsEmpty(&p->pProp) );
1212 // visit old frontier nodes
1213 Cbs2_QueForEachEntry( p->pJust, iVar, i )
1214 if ( i == iJustTailOld )
1215 break;
1216 else if ( Cbs2_VarIsJust(p, Gia_ManObj(p->pAig, iVar), iVar) )
1217 {
1218 Cbs2_QuePush( &p->pJust, iVar );
1219 //*piDecLit = Cbs2_ManUpdateDecVar( p, iVar, *piDecLit );
1220 }
1221 // append new nodes
1222 p->pProp.iHead = iPropHeadOld;
1223 Cbs2_QueForEachEntry( p->pProp, iLit, i )
1224 {
1225 iVar = Abc_Lit2Var(iLit);
1226 if ( Cbs2_VarIsJust(p, Gia_ManObj(p->pAig, iVar), iVar) )
1227 {
1228 Cbs2_QuePush( &p->pJust, iVar );
1229 //*piDecLit = Cbs2_ManUpdateDecVar( p, iVar, *piDecLit );
1230 }
1231 }
1232 p->pProp.iHead = p->pProp.iTail;
1233 // update the head of the frontier
1234 p->pJust.iHead = iJustTailOld;
1235 // return 1 if the queue is empty
1236 p->timeJFront += Abc_Clock() - clk;
1237//printf( "%d ", p->pJust.iTail - p->pJust.iHead );
1238 return Cbs2_QueIsEmpty(&p->pJust);
1239}
Here is the caller graph for this function:

◆ Cbs2_ObjCreateFanout()

void Cbs2_ObjCreateFanout ( Cbs2_Man_t * p,
int iObj,
int iFan0,
int iFan1 )

Definition at line 1495 of file giaCSat2.c.

1496{
1497 Vec_IntWriteEntry( &p->vFanoutN, Abc_Var2Lit(iObj, 0), Vec_IntEntry(&p->vFanout0, iFan0) );
1498 Vec_IntWriteEntry( &p->vFanoutN, Abc_Var2Lit(iObj, 1), Vec_IntEntry(&p->vFanout0, iFan1) );
1499 Vec_IntWriteEntry( &p->vFanout0, iFan0, Abc_Var2Lit(iObj, 0) );
1500 Vec_IntWriteEntry( &p->vFanout0, iFan1, Abc_Var2Lit(iObj, 1) );
1501}
Here is the caller graph for this function:

◆ Cbs2_ObjDeleteFanout()

void Cbs2_ObjDeleteFanout ( Cbs2_Man_t * p,
int iObj )

Definition at line 1502 of file giaCSat2.c.

1503{
1504 Vec_IntWriteEntry( &p->vFanoutN, Abc_Var2Lit(iObj, 0), 0 );
1505 Vec_IntWriteEntry( &p->vFanoutN, Abc_Var2Lit(iObj, 1), 0 );
1506 Vec_IntWriteEntry( &p->vFanout0, iObj, 0 );
1507}
Here is the caller graph for this function:

◆ Cbs2_ObjPrintFanouts()

void Cbs2_ObjPrintFanouts ( Cbs2_Man_t * p,
int iObj )

Function*************************************************************

Synopsis [Create fanout.]

Description []

SideEffects []

SeeAlso []

Definition at line 1479 of file giaCSat2.c.

1480{
1481 int iFanLit;
1482 printf( "Fanouts of node %d: ", iObj );
1483 Cbs2_ObjForEachFanout( p, iObj, iFanLit )
1484 printf( "%d ", Abc_Lit2Var(iFanLit) );
1485 printf( "\n" );
1486}
Here is the caller graph for this function:

◆ Cbs2_ReadModel()

Vec_Int_t * Cbs2_ReadModel ( Cbs2_Man_t * p)

Function*************************************************************

Synopsis [Returns satisfying assignment.]

Description []

SideEffects []

SeeAlso []

Definition at line 280 of file giaCSat2.c.

281{
282 return p->vModel;
283}
Here is the caller graph for this function:

◆ Cbs2_SetDefaultParams()

void Cbs2_SetDefaultParams ( Cbs2_Par_t * pPars)

FUNCTION DEFINITIONS ///.

Function*************************************************************

Synopsis [Sets default values of the parameters.]

Description []

SideEffects []

SeeAlso []

Definition at line 185 of file giaCSat2.c.

186{
187 memset( pPars, 0, sizeof(Cbs2_Par_t) );
188 pPars->nBTLimit = 1000; // limit on the number of conflicts
189 pPars->nJustLimit = 500; // limit on the size of justification queue
190 pPars->fUseHighest = 1; // use node with the highest ID
191 pPars->fUseLowest = 0; // use node with the highest ID
192 pPars->fUseMaxFF = 0; // use node with the largest fanin fanout
193 pPars->fUseFanout = 1;
194 pPars->fVerbose = 1; // print detailed statistics
195}
typedefABC_NAMESPACE_IMPL_START struct Cbs2_Par_t_ Cbs2_Par_t
DECLARATIONS ///.
Definition giaCSat2.c:33
char * memset()
Here is the call graph for this function:
Here is the caller graph for this function: