ABC: A System for Sequential Synthesis and Verification
 
Loading...
Searching...
No Matches
bmcBmcS.c File Reference
#include "bmc.h"
#include "sat/cnf/cnf.h"
#include "sat/satoko/satoko.h"
Include dependency graph for bmcBmcS.c:

Go to the source code of this file.

Classes

struct  Bmcs_Man_t_
 

Macros

#define l_Undef   0
 
#define l_True   1
 
#define l_False   -1
 
#define bmc_sat_solver   satoko_t
 
#define bmc_sat_solver_start(type)
 
#define bmc_sat_solver_stop   satoko_destroy
 
#define bmc_sat_solver_addclause   satoko_add_clause
 
#define bmc_sat_solver_addvar(s)
 
#define bmc_sat_solver_solve   satoko_solve_assumptions
 
#define bmc_sat_solver_read_cex_varvalue   satoko_read_cex_varvalue
 
#define bmc_sat_solver_setstop   satoko_set_stop
 
#define PAR_THR_MAX   100
 DECLARATIONS ///.
 

Typedefs

typedef struct Bmcs_Man_t_ Bmcs_Man_t
 

Functions

void Bmc_SuperBuildTents_rec (Gia_Man_t *p, int iObj, Vec_Int_t *vIns, Vec_Int_t *vCuts, Vec_Int_t *vFlops, Vec_Int_t *vObjs, Vec_Int_t *vRankIns, Vec_Int_t *vRankCuts, int Rank)
 FUNCTION DEFINITIONS ///.
 
Gia_Man_tBmc_SuperBuildTents (Gia_Man_t *p, Vec_Int_t **pvMap)
 
void Gia_ManCountTents_rec (Gia_Man_t *p, int iObj, Vec_Int_t *vRoots)
 
int Gia_ManCountTents (Gia_Man_t *p)
 
void Gia_ManCountRanks_rec (Gia_Man_t *p, int iObj, Vec_Int_t *vRoots, Vec_Int_t *vRanks, Vec_Int_t *vCands, int Rank)
 
int Gia_ManCountRanks (Gia_Man_t *p)
 
Bmcs_Man_tBmcs_ManStart (Gia_Man_t *pGia, Bmc_AndPar_t *pPars)
 
void Bmcs_ManStop (Bmcs_Man_t *p)
 
int Bmcs_ManUnfold_rec (Bmcs_Man_t *p, int iObj, int f)
 
int Bmcs_ManCollect_rec (Bmcs_Man_t *p, int iObj)
 
Gia_Man_tBmcs_ManUnfold (Bmcs_Man_t *p, int f, int nFramesAdd)
 
Cnf_Dat_tBmcs_ManAddNewCnf (Bmcs_Man_t *p, int f, int nFramesAdd)
 
void Bmcs_ManPrintFrame (Bmcs_Man_t *p, int f, int nClauses, int Solver, abctime clkStart)
 
void Bmcs_ManPrintTime (Bmcs_Man_t *p)
 
Abc_Cex_tBmcs_ManGenerateCex (Bmcs_Man_t *p, int i, int f, int s)
 
void Bmcs_ManAddCnf (Bmcs_Man_t *p, bmc_sat_solver *pSat, Cnf_Dat_t *pCnf)
 
int Bmcs_ManPerformOne (Gia_Man_t *pGia, Bmc_AndPar_t *pPars)
 
int Bmcs_ManPerformMulti (Gia_Man_t *pGia, Bmc_AndPar_t *pPars)
 
int Bmcs_ManPerform (Gia_Man_t *pGia, Bmc_AndPar_t *pPars)
 

Macro Definition Documentation

◆ bmc_sat_solver

#define bmc_sat_solver   satoko_t

Definition at line 37 of file bmcBmcS.c.

◆ bmc_sat_solver_addclause

#define bmc_sat_solver_addclause   satoko_add_clause

Definition at line 40 of file bmcBmcS.c.

◆ bmc_sat_solver_addvar

#define bmc_sat_solver_addvar ( s)
Value:
int satoko_add_variable(satoko_t *, char)
Definition solver_api.c:237

Definition at line 41 of file bmcBmcS.c.

◆ bmc_sat_solver_read_cex_varvalue

#define bmc_sat_solver_read_cex_varvalue   satoko_read_cex_varvalue

Definition at line 43 of file bmcBmcS.c.

◆ bmc_sat_solver_setstop

#define bmc_sat_solver_setstop   satoko_set_stop

Definition at line 44 of file bmcBmcS.c.

◆ bmc_sat_solver_solve

#define bmc_sat_solver_solve   satoko_solve_assumptions

Definition at line 42 of file bmcBmcS.c.

◆ bmc_sat_solver_start

#define bmc_sat_solver_start ( type)
Value:
satoko_t * satoko_create(void)
Definition solver_api.c:88

Definition at line 38 of file bmcBmcS.c.

◆ bmc_sat_solver_stop

#define bmc_sat_solver_stop   satoko_destroy

Definition at line 39 of file bmcBmcS.c.

◆ l_False

#define l_False   -1

Definition at line 36 of file bmcBmcS.c.

◆ l_True

#define l_True   1

Definition at line 35 of file bmcBmcS.c.

◆ l_Undef

#define l_Undef   0

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

FileName [bmcBmcS.c]

SystemName [ABC: Logic synthesis and verification system.]

PackageName [SAT-based bounded model checking.]

Synopsis [New BMC package.]

Author [Alan Mishchenko]

Affiliation [UC Berkeley]

Date [Ver. 1.0. Started - July 20, 2017.]

Revision [

Id
bmcBmcS.c,v 1.00 2017/07/20 00:00:00 alanmi Exp

]

Definition at line 34 of file bmcBmcS.c.

◆ PAR_THR_MAX

#define PAR_THR_MAX   100

DECLARATIONS ///.

Definition at line 67 of file bmcBmcS.c.

Typedef Documentation

◆ Bmcs_Man_t

typedef struct Bmcs_Man_t_ Bmcs_Man_t

Definition at line 69 of file bmcBmcS.c.

Function Documentation

◆ Bmc_SuperBuildTents()

Gia_Man_t * Bmc_SuperBuildTents ( Gia_Man_t * p,
Vec_Int_t ** pvMap )

Definition at line 143 of file bmcBmcS.c.

144{
145 Vec_Int_t * vIns = Vec_IntAlloc( 1000 );
146 Vec_Int_t * vCuts = Vec_IntAlloc( 1000 );
147 Vec_Int_t * vFlops = Vec_IntAlloc( 1000 );
148 Vec_Int_t * vObjs = Vec_IntAlloc( 1000 );
149 Vec_Int_t * vLimIns = Vec_IntAlloc( 1000 );
150 Vec_Int_t * vLimCuts = Vec_IntAlloc( 1000 );
151 Vec_Int_t * vLimFlops = Vec_IntAlloc( 1000 );
152 Vec_Int_t * vLimObjs = Vec_IntAlloc( 1000 );
153 Vec_Int_t * vRankIns = Vec_IntAlloc( 1000 );
154 Vec_Int_t * vRankCuts = Vec_IntAlloc( 1000 );
155 Vec_Int_t * vMap = Vec_IntAlloc( 1000 );
156 Gia_Man_t * pNew, * pTemp;
157 Gia_Obj_t * pObj;
158 int i, r, Entry, Rank, iPrev, iThis = 0;
159 // collect internal nodes
160 Gia_ManForEachPo( p, pObj, i )
161 Vec_IntPush( vFlops, Gia_ObjId(p, pObj) );
163 for ( Rank = 0; iThis < Vec_IntEntryLast(vFlops); Rank++ )
164 {
165 Vec_IntPush( vLimIns, Vec_IntSize(vIns) );
166 Vec_IntPush( vLimCuts, Vec_IntSize(vCuts) );
167 Vec_IntPush( vLimFlops, Vec_IntSize(vFlops) );
168 Vec_IntPush( vLimObjs, Vec_IntSize(vObjs) );
169 iPrev = iThis;
170 iThis = Vec_IntEntryLast(vFlops);
171 Vec_IntForEachEntryStartStop( vFlops, Entry, i, iPrev, iThis )
172 {
174 Bmc_SuperBuildTents_rec( p, Gia_ObjFaninId0(Gia_ManObj(p, iPrev), iPrev), vIns, vCuts, vFlops, vObjs, vRankIns, vRankCuts, Rank );
175 }
176 }
178 Vec_IntPush( vLimIns, Vec_IntSize(vIns) );
179 Vec_IntPush( vLimCuts, Vec_IntSize(vCuts) );
180 Vec_IntPush( vLimFlops, Vec_IntSize(vFlops) );
181 Vec_IntPush( vLimObjs, Vec_IntSize(vObjs) );
182 // create new GIA
183 pNew = Gia_ManStart( Gia_ManObjNum(p) );
184 pNew->pName = Abc_UtilStrsav( p->pName );
185 pNew->pSpec = Abc_UtilStrsav( p->pSpec );
187 Gia_ManConst0(p)->Value = 0;
188 Gia_ManForEachObjVec( vIns, p, pObj, i )
189 pObj->Value = Gia_ManAppendCi(pNew);
190 Gia_ManForEachObjVec( vCuts, p, pObj, i )
191 pObj->Value = Gia_ManAppendCi(pNew);
192 for ( r = Rank; r >= 0; r-- )
193 {
194 Vec_IntForEachEntryStartStop( vFlops, Entry, i, Vec_IntEntry(vLimFlops, r), Vec_IntEntry(vLimFlops, r+1) )
195 {
196 pObj = Gia_ManObj(p, Entry);
197 pObj->Value = Gia_ObjFanin0Copy(pObj);
198 }
199 Vec_IntForEachEntryStartStop( vObjs, Entry, i, Vec_IntEntry(vLimObjs, r), Vec_IntEntry(vLimObjs, r+1) )
200 {
201 pObj = Gia_ManObj(p, Entry);
202 pObj->Value = Gia_ObjFanin0Copy(pObj);
203 }
204 }
205 Gia_ManForEachPo( p, pObj, i )
206 Gia_ManAppendCo( pNew, Gia_ObjFanin0Copy(pObj) );
207 Gia_ManForEachObjVec( vCuts, p, pObj, i )
208 Gia_ManAppendCo( pNew, Gia_ObjFanin0Copy(pObj) );
209 Gia_ManSetRegNum( pNew, Vec_IntSize(vCuts) );
210
211 // create map
212 Vec_IntForEachEntryTwo( vIns, vRankIns, Entry, Rank, i )
213 Vec_IntPushTwo( vMap, Entry, Rank );
214 Vec_IntForEachEntryTwo( vCuts, vRankCuts, Entry, Rank, i )
215 Vec_IntPushTwo( vMap, Entry, Rank );
216
217 Vec_IntFree( vIns );
218 Vec_IntFree( vCuts );
219 Vec_IntFree( vFlops );
220 Vec_IntFree( vObjs );
221
222 Vec_IntFree( vLimIns );
223 Vec_IntFree( vLimCuts );
224 Vec_IntFree( vLimFlops );
225 Vec_IntFree( vLimObjs );
226
227 Vec_IntFree( vRankIns );
228 Vec_IntFree( vRankCuts );
229
230 if ( pvMap )
231 *pvMap = vMap;
232 else
233 Vec_IntFree( vMap );
234
235 pNew = Gia_ManCleanup( pTemp = pNew );
236 Gia_ManStop( pTemp );
237 return pNew;
238}
typedefABC_NAMESPACE_IMPL_START struct Vec_Int_t_ Vec_Int_t
DECLARATIONS ///.
Definition bblif.c:37
void Bmc_SuperBuildTents_rec(Gia_Man_t *p, int iObj, Vec_Int_t *vIns, Vec_Int_t *vCuts, Vec_Int_t *vFlops, Vec_Int_t *vObjs, Vec_Int_t *vRankIns, Vec_Int_t *vRankCuts, int Rank)
FUNCTION DEFINITIONS ///.
Definition bmcBmcS.c:107
Cube * p
Definition exorList.c:222
void Gia_ManStop(Gia_Man_t *p)
Definition giaMan.c:82
#define Gia_ManForEachPo(p, pObj, i)
Definition gia.h:1250
void Gia_ManSetRegNum(Gia_Man_t *p, int nRegs)
Definition giaMan.c:764
Gia_Man_t * Gia_ManStart(int nObjsMax)
FUNCTION DEFINITIONS ///.
Definition giaMan.c:57
struct Gia_Obj_t_ Gia_Obj_t
Definition gia.h:76
void Gia_ManFillValue(Gia_Man_t *p)
Definition giaUtil.c:369
struct Gia_Man_t_ Gia_Man_t
Definition gia.h:96
#define Gia_ManForEachObjVec(vVec, p, pObj, i)
Definition gia.h:1194
Gia_Man_t * Gia_ManCleanup(Gia_Man_t *p)
Definition giaScl.c:84
void Gia_ManIncrementTravId(Gia_Man_t *p)
Definition giaUtil.c:190
void Gia_ManCleanMark01(Gia_Man_t *p)
Definition giaUtil.c:218
char * pSpec
Definition gia.h:100
char * pName
Definition gia.h:99
unsigned Value
Definition gia.h:89
#define Vec_IntForEachEntryTwo(vVec1, vVec2, Entry1, Entry2, i)
Definition vecInt.h:66
#define Vec_IntForEachEntryStartStop(vVec, Entry, i, Start, Stop)
Definition vecInt.h:60
Here is the call graph for this function:

◆ Bmc_SuperBuildTents_rec()

void Bmc_SuperBuildTents_rec ( Gia_Man_t * p,
int iObj,
Vec_Int_t * vIns,
Vec_Int_t * vCuts,
Vec_Int_t * vFlops,
Vec_Int_t * vObjs,
Vec_Int_t * vRankIns,
Vec_Int_t * vRankCuts,
int Rank )

FUNCTION DEFINITIONS ///.

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

Synopsis [Incremental unfolding.]

Description []

SideEffects []

SeeAlso []

Definition at line 107 of file bmcBmcS.c.

108{
109 Gia_Obj_t * pObj;
110 if ( iObj == 0 )
111 return;
112 if ( Gia_ObjIsTravIdCurrentId(p, iObj) )
113 return;
114 Gia_ObjSetTravIdCurrentId(p, iObj);
115 pObj = Gia_ManObj( p, iObj );
116 if ( pObj->fMark0 )
117 {
118 if ( !pObj->fMark1 )
119 return;
120 Vec_IntPush( vCuts, iObj );
121 Vec_IntPush( vRankCuts, Rank );
122 pObj->fMark1 = 1;
123 return;
124 }
125 pObj->fMark0 = 1;
126 if ( Gia_ObjIsPi(p, pObj) )
127 {
128 Vec_IntPush( vIns, iObj );
129 Vec_IntPush( vRankIns, Rank );
130 pObj->fMark1 = 1;
131 return;
132 }
133 if ( Gia_ObjIsCi(pObj) )
134 {
135 Vec_IntPush( vFlops, iObj );
136 return;
137 }
138 assert( Gia_ObjIsAnd(pObj) );
139 Bmc_SuperBuildTents_rec( p, Gia_ObjFaninId0(pObj, iObj), vIns, vCuts, vFlops, vObjs, vRankIns, vRankCuts, Rank );
140 Bmc_SuperBuildTents_rec( p, Gia_ObjFaninId1(pObj, iObj), vIns, vCuts, vFlops, vObjs, vRankIns, vRankCuts, Rank );
141 Vec_IntPush( vObjs, iObj );
142}
unsigned fMark1
Definition gia.h:86
unsigned fMark0
Definition gia.h:81
#define assert(ex)
Definition util_old.h:213
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Bmcs_ManAddCnf()

void Bmcs_ManAddCnf ( Bmcs_Man_t * p,
bmc_sat_solver * pSat,
Cnf_Dat_t * pCnf )

Definition at line 628 of file bmcBmcS.c.

629{
630 int i;
631 for ( i = p->nSatVarsOld; i < p->nSatVars; i++ )
632 bmc_sat_solver_addvar( pSat );
633 for ( i = 0; i < pCnf->nClauses; i++ )
634 if ( !bmc_sat_solver_addclause( pSat, pCnf->pClauses[i], pCnf->pClauses[i+1]-pCnf->pClauses[i] ) )
635 assert( 0 );
636}
#define bmc_sat_solver_addclause
Definition bmcBmcS.c:40
#define bmc_sat_solver_addvar(s)
Definition bmcBmcS.c:41
int ** pClauses
Definition cnf.h:62
int nClauses
Definition cnf.h:61
Here is the caller graph for this function:

◆ Bmcs_ManAddNewCnf()

Cnf_Dat_t * Bmcs_ManAddNewCnf ( Bmcs_Man_t * p,
int f,
int nFramesAdd )

Definition at line 537 of file bmcBmcS.c.

538{
539 abctime clk = Abc_Clock();
540 Gia_Man_t * pNew = Bmcs_ManUnfold( p, f, nFramesAdd );
541 Cnf_Dat_t * pCnf;
542 Gia_Obj_t * pObj;
543 int i, iVar, * pMap;
544 p->timeUnf += Abc_Clock() - clk;
545 if ( pNew == NULL )
546 return NULL;
547 clk = Abc_Clock();
548 pCnf = (Cnf_Dat_t *) Mf_ManGenerateCnf( pNew, 8, 1, 0, 0, 0 );
549 pMap = ABC_FALLOC( int, Gia_ManObjNum(pNew) );
550 pMap[0] = 0;
551 Gia_ManForEachObj1( pNew, pObj, i )
552 {
553 if ( pCnf->pObj2Count[i] <= 0 && !Gia_ObjIsCi(pObj) )
554 continue;
555 iVar = Vec_IntEntry( &p->vFr2Sat, pObj->Value );
556 if ( iVar == -1 )
557 Vec_IntWriteEntry( &p->vFr2Sat, pObj->Value, (iVar = p->nSatVars++) );
558 pMap[i] = iVar;
559 }
560 Gia_ManStop( pNew );
561 for ( i = 0; i < pCnf->nLiterals; i++ )
562 pCnf->pClauses[0][i] = Abc_Lit2LitV( pMap, pCnf->pClauses[0][i] );
563 ABC_FREE( pMap );
564 p->timeCnf += Abc_Clock() - clk;
565 return pCnf;
566}
ABC_INT64_T abctime
Definition abc_global.h:332
#define ABC_FALLOC(type, num)
Definition abc_global.h:266
#define ABC_FREE(obj)
Definition abc_global.h:267
Gia_Man_t * Bmcs_ManUnfold(Bmcs_Man_t *p, int f, int nFramesAdd)
Definition bmcBmcS.c:491
struct Cnf_Dat_t_ Cnf_Dat_t
Definition cnf.h:52
#define Gia_ManForEachObj1(p, pObj, i)
Definition gia.h:1192
void * Mf_ManGenerateCnf(Gia_Man_t *pGia, int nLutSize, int fCnfObjIds, int fAddOrCla, int fMapping, int fVerbose)
Definition giaMf.c:1877
int * pObj2Count
Definition cnf.h:65
int nLiterals
Definition cnf.h:60
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Bmcs_ManCollect_rec()

int Bmcs_ManCollect_rec ( Bmcs_Man_t * p,
int iObj )

Definition at line 467 of file bmcBmcS.c.

468{
469 Gia_Obj_t * pObj;
470 int iSatVar, iLitClean = Gia_ObjCopyArray( p->pFrames, iObj );
471 if ( iLitClean >= 0 )
472 return iLitClean;
473 pObj = Gia_ManObj( p->pFrames, iObj );
474 iSatVar = Vec_IntEntry( &p->vFr2Sat, iObj );
475 if ( iSatVar > 0 || Gia_ObjIsCi(pObj) )
476 iLitClean = Gia_ManAppendCi( p->pClean );
477 else if ( Gia_ObjIsAnd(pObj) )
478 {
479 int iLit0 = Bmcs_ManCollect_rec( p, Gia_ObjFaninId0(pObj, iObj) );
480 int iLit1 = Bmcs_ManCollect_rec( p, Gia_ObjFaninId1(pObj, iObj) );
481 iLit0 = Abc_LitNotCond( iLit0, Gia_ObjFaninC0(pObj) );
482 iLit1 = Abc_LitNotCond( iLit1, Gia_ObjFaninC1(pObj) );
483 iLitClean = Gia_ManAppendAnd( p->pClean, iLit0, iLit1 );
484 }
485 else assert( 0 );
486 assert( !Abc_LitIsCompl(iLitClean) );
487 Gia_ManObj( p->pClean, Abc_Lit2Var(iLitClean) )->Value = iObj;
488 Gia_ObjSetCopyArray( p->pFrames, iObj, iLitClean );
489 return iLitClean;
490}
int Bmcs_ManCollect_rec(Bmcs_Man_t *p, int iObj)
Definition bmcBmcS.c:467
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Bmcs_ManGenerateCex()

Abc_Cex_t * Bmcs_ManGenerateCex ( Bmcs_Man_t * p,
int i,
int f,
int s )

Definition at line 612 of file bmcBmcS.c.

613{
614 Abc_Cex_t * pCex = Abc_CexMakeTriv( Gia_ManRegNum(p->pGia), Gia_ManPiNum(p->pGia), Gia_ManPoNum(p->pGia), f*Gia_ManPoNum(p->pGia)+i );
615 Gia_Obj_t * pObj; int k;
616 Gia_ManForEachPi( p->pFrames, pObj, k )
617 {
618 int iSatVar = Vec_IntEntry( &p->vFr2Sat, Gia_ObjId(p->pFrames, pObj) );
619 if ( iSatVar > 0 && bmc_sat_solver_read_cex_varvalue(p->pSats[s], iSatVar) ) // 1 bit
620 {
621 int iCiId = Vec_IntEntry( &p->vCiMap, 2*k+0 );
622 int iFrame = Vec_IntEntry( &p->vCiMap, 2*k+1 );
623 Abc_InfoSetBit( pCex->pData, Gia_ManRegNum(p->pGia) + iFrame * Gia_ManPiNum(p->pGia) + iCiId );
624 }
625 }
626 return pCex;
627}
#define bmc_sat_solver_read_cex_varvalue
Definition bmcBmcS.c:43
#define Gia_ManForEachPi(p, pObj, i)
Definition gia.h:1248
Abc_Cex_t * Abc_CexMakeTriv(int nRegs, int nTruePis, int nTruePos, int iFrameOut)
Definition utilCex.c:85
typedefABC_NAMESPACE_HEADER_START struct Abc_Cex_t_ Abc_Cex_t
INCLUDES ///.
Definition utilCex.h:39
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Bmcs_ManPerform()

int Bmcs_ManPerform ( Gia_Man_t * pGia,
Bmc_AndPar_t * pPars )

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 925 of file bmcBmcS.c.

926{
927 assert( pPars->nProcs < PAR_THR_MAX );
928 if ( pPars->nProcs == 1 )
929 return Bmcs_ManPerformOne( pGia, pPars );
930 else
931 return Bmcs_ManPerformMulti( pGia, pPars );
932}
#define PAR_THR_MAX
DECLARATIONS ///.
Definition bmcBmcG.c:31
int Bmcs_ManPerformOne(Gia_Man_t *pGia, Bmc_AndPar_t *pPars)
Definition bmcBmcS.c:637
int Bmcs_ManPerformMulti(Gia_Man_t *pGia, Bmc_AndPar_t *pPars)
Definition bmcBmcS.c:728
int nProcs
Definition bmc.h:152
Here is the call graph for this function:

◆ Bmcs_ManPerformMulti()

int Bmcs_ManPerformMulti ( Gia_Man_t * pGia,
Bmc_AndPar_t * pPars )

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 728 of file bmcBmcS.c.

728{ return Bmcs_ManPerformOne(pGia, pPars); }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Bmcs_ManPerformOne()

int Bmcs_ManPerformOne ( Gia_Man_t * pGia,
Bmc_AndPar_t * pPars )

Definition at line 637 of file bmcBmcS.c.

638{
639 abctime clkStart = Abc_Clock();
640 Bmcs_Man_t * p = Bmcs_ManStart( pGia, pPars );
641 int f, k = 0, i = Gia_ManPoNum(pGia), status, RetValue = -1, nClauses = 0;
642 Abc_CexFreeP( &pGia->pCexSeq );
643 for ( f = 0; !pPars->nFramesMax || f < pPars->nFramesMax; f += pPars->nFramesAdd )
644 {
645 Cnf_Dat_t * pCnf = Bmcs_ManAddNewCnf( p, f, pPars->nFramesAdd );
646 if ( pCnf == NULL )
647 {
648 Bmcs_ManPrintFrame( p, f, nClauses, -1, clkStart );
649 if( pPars->pFuncOnFrameDone)
650 for ( k = 0; k < pPars->nFramesAdd; k++ )
651 for ( i = 0; i < Gia_ManPoNum(pGia); i++ )
652 pPars->pFuncOnFrameDone(f+k, i, 0);
653 continue;
654 }
655 nClauses += pCnf->nClauses;
656 Bmcs_ManAddCnf( p, p->pSats[0], pCnf );
657 p->nSatVarsOld = p->nSatVars;
658 Cnf_DataFree( pCnf );
659 assert( Gia_ManPoNum(p->pFrames) == (f + pPars->nFramesAdd) * Gia_ManPoNum(pGia) );
660 for ( k = 0; k < pPars->nFramesAdd; k++ )
661 {
662 for ( i = 0; i < Gia_ManPoNum(pGia); i++ )
663 {
664 abctime clk = Abc_Clock();
665 int iObj = Gia_ObjId( p->pFrames, Gia_ManCo(p->pFrames, (f+k) * Gia_ManPoNum(pGia) + i) );
666 int iLit = Abc_Var2Lit( Vec_IntEntry(&p->vFr2Sat, iObj), 0 );
667 if ( pPars->nTimeOut && (Abc_Clock() - clkStart)/CLOCKS_PER_SEC >= pPars->nTimeOut )
668 break;
669 status = bmc_sat_solver_solve( p->pSats[0], &iLit, 1 );
670 p->timeSat += Abc_Clock() - clk;
671 if ( status == l_False ) // unsat
672 {
673 if ( i == Gia_ManPoNum(pGia)-1 )
674 Bmcs_ManPrintFrame( p, f+k, nClauses, -1, clkStart );
675 if( pPars->pFuncOnFrameDone)
676 pPars->pFuncOnFrameDone(f+k, i, 0);
677 continue;
678 }
679 if ( status == l_True ) // sat
680 {
681 RetValue = 0;
682 pPars->iFrame = f+k;
683 pGia->pCexSeq = Bmcs_ManGenerateCex( p, i, f+k, 0 );
684 pPars->nFailOuts++;
685 Bmcs_ManPrintFrame( p, f+k, nClauses, -1, clkStart );
686 if ( !pPars->fNotVerbose )
687 {
688 int nOutDigits = Abc_Base10Log( Gia_ManPoNum(pGia) );
689 Abc_Print( 1, "Output %*d was asserted in frame %2d (solved %*d out of %*d outputs). ",
690 nOutDigits, i, f+k, nOutDigits, pPars->nFailOuts, nOutDigits, Gia_ManPoNum(pGia) );
691 fflush( stdout );
692 }
693 if( pPars->pFuncOnFrameDone)
694 pPars->pFuncOnFrameDone(f+k, i, 1);
695 }
696 break;
697 }
698 if ( i < Gia_ManPoNum(pGia) || f+k == pPars->nFramesMax-1 )
699 break;
700 }
701 if ( k < pPars->nFramesAdd )
702 break;
703 }
704 p->timeOth = Abc_Clock() - clkStart - p->timeUnf - p->timeCnf - p->timeSat;
705 if ( RetValue == -1 && !pPars->fNotVerbose )
706 printf( "No output failed in %d frames. ", f + (k < pPars->nFramesAdd ? k+1 : 0) );
707 Abc_PrintTime( 1, "Time", Abc_Clock() - clkStart );
709 Bmcs_ManStop( p );
710 return RetValue;
711}
#define bmc_sat_solver_solve
Definition bmcBmcS.c:42
Cnf_Dat_t * Bmcs_ManAddNewCnf(Bmcs_Man_t *p, int f, int nFramesAdd)
Definition bmcBmcS.c:537
Bmcs_Man_t * Bmcs_ManStart(Gia_Man_t *pGia, Bmc_AndPar_t *pPars)
Definition bmcBmcS.c:365
Abc_Cex_t * Bmcs_ManGenerateCex(Bmcs_Man_t *p, int i, int f, int s)
Definition bmcBmcS.c:612
struct Bmcs_Man_t_ Bmcs_Man_t
Definition bmcBmcS.c:69
void Bmcs_ManPrintFrame(Bmcs_Man_t *p, int f, int nClauses, int Solver, abctime clkStart)
Definition bmcBmcS.c:579
void Bmcs_ManPrintTime(Bmcs_Man_t *p)
Definition bmcBmcS.c:601
void Bmcs_ManStop(Bmcs_Man_t *p)
Definition bmcBmcS.c:404
#define l_True
Definition bmcBmcS.c:35
#define l_False
Definition bmcBmcS.c:36
void Bmcs_ManAddCnf(Bmcs_Man_t *p, bmc_sat_solver *pSat, Cnf_Dat_t *pCnf)
Definition bmcBmcS.c:628
void Cnf_DataFree(Cnf_Dat_t *p)
Definition cnfMan.c:207
int nFramesAdd
Definition bmc.h:148
int nFramesMax
Definition bmc.h:147
int fNotVerbose
Definition bmc.h:161
int nTimeOut
Definition bmc.h:150
int iFrame
Definition bmc.h:162
int nFailOuts
Definition bmc.h:163
void(* pFuncOnFrameDone)(int, int, int)
Definition bmc.h:166
Abc_Cex_t * pCexSeq
Definition gia.h:150
void Abc_CexFreeP(Abc_Cex_t **p)
Definition utilCex.c:361
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Bmcs_ManPrintFrame()

void Bmcs_ManPrintFrame ( Bmcs_Man_t * p,
int f,
int nClauses,
int Solver,
abctime clkStart )

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 579 of file bmcBmcS.c.

580{
581 int fUnfinished = 0;
582 if ( !p->pPars->fVerbose )
583 return;
584 Abc_Print( 1, "%4d %s : ", f, fUnfinished ? "-" : "+" );
585#ifndef ABC_USE_EXT_SOLVERS
586 Abc_Print( 1, "Var =%8.0f. ", (double)satoko_varnum(p->pSats[0]) );
587 Abc_Print( 1, "Cla =%9.0f. ", (double)satoko_clausenum(p->pSats[0]) );
588 Abc_Print( 1, "Learn =%9.0f. ",(double)satoko_learntnum(p->pSats[0]) );
589 Abc_Print( 1, "Conf =%9.0f. ", (double)satoko_conflictnum(p->pSats[0]) );
590#else
591 Abc_Print( 1, "Var =%8.0f. ", (double)p->nSatVars );
592 Abc_Print( 1, "Cla =%9.0f. ", (double)nClauses );
593#endif
594 if ( p->pPars->nProcs > 1 )
595 Abc_Print( 1, "S = %3d. ", Solver );
596 Abc_Print( 1, "%4.0f MB", 1.0*((int)Gia_ManMemory(p->pFrames) + Vec_IntMemory(&p->vFr2Sat))/(1<<20) );
597 Abc_Print( 1, "%9.2f sec ", (float)(Abc_Clock() - clkStart)/(float)(CLOCKS_PER_SEC) );
598 printf( "\n" );
599 fflush( stdout );
600}
double Gia_ManMemory(Gia_Man_t *p)
Definition giaMan.c:194
int satoko_varnum(satoko_t *)
Definition solver_api.c:625
int satoko_conflictnum(satoko_t *)
Definition solver_api.c:640
int satoko_clausenum(satoko_t *)
Definition solver_api.c:630
int satoko_learntnum(satoko_t *)
Definition solver_api.c:635
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Bmcs_ManPrintTime()

void Bmcs_ManPrintTime ( Bmcs_Man_t * p)

Definition at line 601 of file bmcBmcS.c.

602{
603 abctime clkTotal = p->timeUnf + p->timeCnf + p->timeSat + p->timeOth;
604 if ( !p->pPars->fVerbose )
605 return;
606 ABC_PRTP( "Unfolding ", p->timeUnf, clkTotal );
607 ABC_PRTP( "CNF generation", p->timeCnf, clkTotal );
608 ABC_PRTP( "SAT solving ", p->timeSat, clkTotal );
609 ABC_PRTP( "Other ", p->timeOth, clkTotal );
610 ABC_PRTP( "TOTAL ", clkTotal , clkTotal );
611}
#define ABC_PRTP(a, t, T)
Definition abc_global.h:258
Here is the caller graph for this function:

◆ Bmcs_ManStart()

Bmcs_Man_t * Bmcs_ManStart ( Gia_Man_t * pGia,
Bmc_AndPar_t * pPars )

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 365 of file bmcBmcS.c.

366{
368 int i, Lit = Abc_Var2Lit( 0, 1 );
369 satoko_opts_t opts;
370 satoko_default_opts(&opts);
371 opts.conf_limit = pPars->nConfLimit;
372 assert( Gia_ManRegNum(pGia) > 0 );
373 p->pPars = pPars;
374 p->pGia = pGia;
375 p->pFrames = Gia_ManStart( 3*Gia_ManObjNum(pGia) ); Gia_ManHashStart(p->pFrames);
376 p->pClean = NULL;
377// Vec_PtrFill( &p->vGia2Fr, Gia_ManCountTents(pGia)+1, NULL );
378// for ( i = 0; i < Vec_PtrSize(&p->vGia2Fr); i++ )
379// Vec_PtrWriteEntry( &p->vGia2Fr, i, ABC_FALLOC(int, Gia_ManObjNum(pGia)) );
380 Vec_PtrGrow( &p->vGia2Fr, 1000 );
381 Vec_IntGrow( &p->vFr2Sat, 3*Gia_ManCiNum(pGia) );
382 Vec_IntPush( &p->vFr2Sat, 0 );
383 Vec_IntGrow( &p->vCiMap, 3*Gia_ManCiNum(pGia) );
384 for ( i = 0; i < pPars->nProcs; i++ )
385 {
386 // modify parameters to get different SAT solvers
387 opts.f_rst = 0.8 - i * 0.05;
388 opts.b_rst = 1.4 - i * 0.05;
389 opts.garbage_max_ratio = (float) 0.3 + i * 0.05;
390 // create SAT solvers
391 p->pSats[i] = bmc_sat_solver_start( i );
392#ifdef ABC_USE_EXT_SOLVERS
393 p->pSats[i]->SolverType = i;
394#else
395 satoko_configure(p->pSats[i], &opts);
396#endif
397 bmc_sat_solver_addvar( p->pSats[i] );
398 bmc_sat_solver_addclause( p->pSats[i], &Lit, 1 );
399 bmc_sat_solver_setstop( p->pSats[i], &p->fStopNow );
400 }
401 p->nSatVars = 1;
402 return p;
403}
#define ABC_CALLOC(type, num)
Definition abc_global.h:265
#define bmc_sat_solver_setstop
Definition bmcBmcS.c:44
#define bmc_sat_solver_start(type)
Definition bmcBmcS.c:38
void Gia_ManHashStart(Gia_Man_t *p)
Definition giaHash.c:125
struct satoko_opts satoko_opts_t
Definition satoko.h:37
void satoko_default_opts(satoko_opts_t *)
Definition solver_api.c:161
void satoko_configure(satoko_t *, satoko_opts_t *)
Definition solver_api.c:196
int nConfLimit
Definition bmc.h:149
double f_rst
Definition satoko.h:44
float garbage_max_ratio
Definition satoko.h:67
double b_rst
Definition satoko.h:45
long conf_limit
Definition satoko.h:40
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Bmcs_ManStop()

void Bmcs_ManStop ( Bmcs_Man_t * p)

Definition at line 404 of file bmcBmcS.c.

405{
406 int i;
407 Gia_ManStopP( &p->pFrames );
408 Gia_ManStopP( &p->pClean );
409 Vec_PtrFreeData( &p->vGia2Fr );
410 Vec_PtrErase( &p->vGia2Fr );
411 Vec_IntErase( &p->vFr2Sat );
412 Vec_IntErase( &p->vCiMap );
413 for ( i = 0; i < p->pPars->nProcs; i++ )
414 if ( p->pSats[i] )
415 bmc_sat_solver_stop( p->pSats[i] );
416 ABC_FREE( p );
417}
#define bmc_sat_solver_stop
Definition bmcBmcS.c:39
void Gia_ManStopP(Gia_Man_t **p)
Definition giaMan.c:224
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Bmcs_ManUnfold()

Gia_Man_t * Bmcs_ManUnfold ( Bmcs_Man_t * p,
int f,
int nFramesAdd )

Definition at line 491 of file bmcBmcS.c.

492{
493 Gia_Man_t * pNew = NULL; Gia_Obj_t * pObj;
494 int i, k, iLitFrame, iLitClean, fTrivial = 1;
495 int * pCopies, nFrameObjs = Gia_ManObjNum(p->pFrames);
496 assert( Gia_ManPoNum(p->pFrames) == f * Gia_ManPoNum(p->pGia) );
497 for ( k = 0; k < nFramesAdd; k++ )
498 {
499 // unfold this timeframe
500 Vec_PtrPush( &p->vGia2Fr, ABC_FALLOC(int, Gia_ManObjNum(p->pGia)) );
501 assert( Vec_PtrSize(&p->vGia2Fr) == f+k+1 );
502 pCopies = Bmcs_ManCopies( p, f+k );
503 //memset( pCopies, 0xFF, sizeof(int)*Gia_ManObjNum(p->pGia) );
504 pCopies[0] = 0;
505 Gia_ManForEachPo( p->pGia, pObj, i )
506 {
507 iLitFrame = Bmcs_ManUnfold_rec( p, Gia_ObjFaninId0p(p->pGia, pObj), f+k );
508 iLitFrame = Abc_LitNotCond( iLitFrame, Gia_ObjFaninC0(pObj) );
509 pCopies[Gia_ObjId(p->pGia, pObj)] = Gia_ManAppendCo( p->pFrames, iLitFrame );
510 fTrivial &= (iLitFrame == 0);
511 }
512 }
513 if ( fTrivial )
514 return NULL;
515 // create a clean copy of the new nodes of this timeframe
516 Vec_IntFillExtra( &p->vFr2Sat, Gia_ManObjNum(p->pFrames), -1 );
517 Vec_IntFillExtra( &p->pFrames->vCopies, Gia_ManObjNum(p->pFrames), -1 );
518 //assert( Vec_IntCountEntry(&p->pFrames->vCopies, -1) == Vec_IntSize(&p->pFrames->vCopies) );
519 Gia_ManStopP( &p->pClean );
520 p->pClean = Gia_ManStart( Gia_ManObjNum(p->pFrames) - nFrameObjs + 1000 );
521 Gia_ObjSetCopyArray( p->pFrames, 0, 0 );
522 for ( k = 0; k < nFramesAdd; k++ )
523 for ( i = 0; i < Gia_ManPoNum(p->pGia); i++ )
524 {
525 pObj = Gia_ManCo( p->pFrames, (f+k) * Gia_ManPoNum(p->pGia) + i );
526 iLitClean = Bmcs_ManCollect_rec( p, Gia_ObjFaninId0p(p->pFrames, pObj) );
527 iLitClean = Abc_LitNotCond( iLitClean, Gia_ObjFaninC0(pObj) );
528 iLitClean = Gia_ManAppendCo( p->pClean, iLitClean );
529 Gia_ManObj( p->pClean, Abc_Lit2Var(iLitClean) )->Value = Gia_ObjId(p->pFrames, pObj);
530 Gia_ObjSetCopyArray( p->pFrames, Gia_ObjId(p->pFrames, pObj), iLitClean );
531 }
532 pNew = p->pClean; p->pClean = NULL;
533 Gia_ManForEachObj( pNew, pObj, i )
534 Gia_ObjSetCopyArray( p->pFrames, pObj->Value, -1 );
535 return pNew;
536}
int Bmcs_ManUnfold_rec(Bmcs_Man_t *p, int iObj, int f)
Definition bmcBmcS.c:431
#define Gia_ManForEachObj(p, pObj, i)
MACRO DEFINITIONS ///.
Definition gia.h:1190
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Bmcs_ManUnfold_rec()

int Bmcs_ManUnfold_rec ( Bmcs_Man_t * p,
int iObj,
int f )

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

Synopsis [Incremental unfolding.]

Description []

SideEffects []

SeeAlso []

Definition at line 431 of file bmcBmcS.c.

432{
433 Gia_Obj_t * pObj;
434 int iLit = 0, * pCopies = Bmcs_ManCopies( p, f );
435 if ( pCopies[iObj] >= 0 )
436 return pCopies[iObj];
437 pObj = Gia_ManObj( p->pGia, iObj );
438 if ( Gia_ObjIsCi(pObj) )
439 {
440 if ( Gia_ObjIsPi(p->pGia, pObj) )
441 {
442 Vec_IntPushTwo( &p->vCiMap, Gia_ObjCioId(pObj), f );
443 iLit = Gia_ManAppendCi( p->pFrames );
444 }
445 else if ( f > 0 )
446 {
447 pObj = Gia_ObjRoToRi( p->pGia, pObj );
448 iLit = Bmcs_ManUnfold_rec( p, Gia_ObjFaninId0p(p->pGia, pObj), f-1 );
449 iLit = Abc_LitNotCond( iLit, Gia_ObjFaninC0(pObj) );
450 }
451 }
452 else if ( Gia_ObjIsAnd(pObj) )
453 {
454 iLit = Bmcs_ManUnfold_rec( p, Gia_ObjFaninId0(pObj, iObj), f );
455 iLit = Abc_LitNotCond( iLit, Gia_ObjFaninC0(pObj) );
456 if ( iLit > 0 )
457 {
458 int iNew;
459 iNew = Bmcs_ManUnfold_rec( p, Gia_ObjFaninId1(pObj, iObj), f );
460 iNew = Abc_LitNotCond( iNew, Gia_ObjFaninC1(pObj) );
461 iLit = Gia_ManHashAnd( p->pFrames, iLit, iNew );
462 }
463 }
464 else assert( 0 );
465 return (pCopies[iObj] = iLit);
466}
int Gia_ManHashAnd(Gia_Man_t *p, int iLit0, int iLit1)
Definition giaHash.c:576
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Gia_ManCountRanks()

int Gia_ManCountRanks ( Gia_Man_t * p)

Definition at line 325 of file bmcBmcS.c.

326{
327 Vec_Int_t * vRoots;
328 Vec_Int_t * vRanks = Vec_IntStartFull( Gia_ManObjNum(p) );
329 Vec_Int_t * vCands = Vec_IntStart( Gia_ManObjNum(p) );
330 Gia_Obj_t * pObj;
331 int t, i, iObj, nSizeCurr = 0;
332 assert( Gia_ManPoNum(p) > 0 );
334 Gia_ObjSetTravIdCurrentId( p, 0 );
335 vRoots = Vec_IntAlloc( 100 );
336 Gia_ManForEachPo( p, pObj, i )
337 Vec_IntPush( vRoots, Gia_ObjFaninId0p(p, pObj) );
338 for ( t = 0; nSizeCurr < Vec_IntSize(vRoots); t++ )
339 {
340 int nSizePrev = nSizeCurr;
341 nSizeCurr = Vec_IntSize(vRoots);
342 Vec_IntForEachEntryStartStop( vRoots, iObj, i, nSizePrev, nSizeCurr )
343 Gia_ManCountRanks_rec( p, iObj, vRoots, vRanks, vCands, t );
344 }
345 Vec_IntWriteEntry( vCands, 0, 0 );
346 printf( "Tents = %6d. Cands = %6d. %10.2f %%\n", t, Vec_IntSum(vCands), 100.0*Vec_IntSum(vCands)/Gia_ManCandNum(p) );
347 Vec_IntFree( vRoots );
348 Vec_IntFree( vRanks );
349 Vec_IntFree( vCands );
350 return t;
351}
void Gia_ManCountRanks_rec(Gia_Man_t *p, int iObj, Vec_Int_t *vRoots, Vec_Int_t *vRanks, Vec_Int_t *vCands, int Rank)
Definition bmcBmcS.c:303
Here is the call graph for this function:

◆ Gia_ManCountRanks_rec()

void Gia_ManCountRanks_rec ( Gia_Man_t * p,
int iObj,
Vec_Int_t * vRoots,
Vec_Int_t * vRanks,
Vec_Int_t * vCands,
int Rank )

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

Synopsis [Count tents.]

Description []

SideEffects []

SeeAlso []

Definition at line 303 of file bmcBmcS.c.

304{
305 Gia_Obj_t * pObj;
306 if ( Gia_ObjIsTravIdCurrentId(p, iObj) )
307 {
308 if ( Vec_IntEntry(vRanks, iObj) < Rank )
309 Vec_IntWriteEntry( vCands, iObj, 1 );
310 return;
311 }
312 Gia_ObjSetTravIdCurrentId(p, iObj);
313 Vec_IntWriteEntry( vRanks, iObj, Rank );
314 pObj = Gia_ManObj( p, iObj );
315 if ( Gia_ObjIsAnd(pObj) )
316 {
317 Gia_ManCountRanks_rec( p, Gia_ObjFaninId0(pObj, iObj), vRoots, vRanks, vCands, Rank );
318 Gia_ManCountRanks_rec( p, Gia_ObjFaninId1(pObj, iObj), vRoots, vRanks, vCands, Rank );
319 }
320 else if ( Gia_ObjIsRo(p, pObj) )
321 Vec_IntPush( vRoots, Gia_ObjFaninId0p(p, Gia_ObjRoToRi(p, pObj)) );
322 else if ( !Gia_ObjIsPi(p, pObj) )
323 assert( 0 );
324}
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Gia_ManCountTents()

int Gia_ManCountTents ( Gia_Man_t * p)

Definition at line 270 of file bmcBmcS.c.

271{
272 Vec_Int_t * vRoots;
273 Gia_Obj_t * pObj;
274 int t, i, iObj, nSizeCurr = 0;
275 assert( Gia_ManPoNum(p) > 0 );
277 Gia_ObjSetTravIdCurrentId( p, 0 );
278 vRoots = Vec_IntAlloc( 100 );
279 Gia_ManForEachPo( p, pObj, i )
280 Vec_IntPush( vRoots, Gia_ObjFaninId0p(p, pObj) );
281 for ( t = 0; nSizeCurr < Vec_IntSize(vRoots); t++ )
282 {
283 int nSizePrev = nSizeCurr;
284 nSizeCurr = Vec_IntSize(vRoots);
285 Vec_IntForEachEntryStartStop( vRoots, iObj, i, nSizePrev, nSizeCurr )
286 Gia_ManCountTents_rec( p, iObj, vRoots );
287 }
288 Vec_IntFree( vRoots );
289 return t;
290}
void Gia_ManCountTents_rec(Gia_Man_t *p, int iObj, Vec_Int_t *vRoots)
Definition bmcBmcS.c:253
Here is the call graph for this function:

◆ Gia_ManCountTents_rec()

void Gia_ManCountTents_rec ( Gia_Man_t * p,
int iObj,
Vec_Int_t * vRoots )

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

Synopsis [Count tents.]

Description []

SideEffects []

SeeAlso []

Definition at line 253 of file bmcBmcS.c.

254{
255 Gia_Obj_t * pObj;
256 if ( Gia_ObjIsTravIdCurrentId(p, iObj) )
257 return;
258 Gia_ObjSetTravIdCurrentId(p, iObj);
259 pObj = Gia_ManObj( p, iObj );
260 if ( Gia_ObjIsAnd(pObj) )
261 {
262 Gia_ManCountTents_rec( p, Gia_ObjFaninId0(pObj, iObj), vRoots );
263 Gia_ManCountTents_rec( p, Gia_ObjFaninId1(pObj, iObj), vRoots );
264 }
265 else if ( Gia_ObjIsRo(p, pObj) )
266 Vec_IntPush( vRoots, Gia_ObjFaninId0p(p, Gia_ObjRoToRi(p, pObj)) );
267 else if ( !Gia_ObjIsPi(p, pObj) )
268 assert( 0 );
269}
Here is the call graph for this function:
Here is the caller graph for this function: