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

Go to the source code of this file.

Classes

struct  Ccf_Man_t_
 

Typedefs

typedef typedefABC_NAMESPACE_IMPL_START struct Ccf_Man_t_ Ccf_Man_t
 DECLARATIONS ///.
 

Functions

Ccf_Man_tCcf_ManStart (Gia_Man_t *pGia, int nFrameMax, int nConfMax, int nTimeMax, int fVerbose)
 FUNCTION DEFINITIONS ///.
 
void Ccf_ManStop (Ccf_Man_t *p)
 
void Gia_ManCofExtendSolver (Ccf_Man_t *p)
 
void Gia_ManCofOneDerive_rec (Ccf_Man_t *p, int Id)
 
int Gia_ManCofOneDerive (Ccf_Man_t *p, int LitProp)
 
int Gia_ManCofGetReachable (Ccf_Man_t *p, int Lit)
 
Gia_Man_tGia_ManCofTest (Gia_Man_t *pGia, int nFrameMax, int nConfMax, int nTimeMax, int fVerbose)
 

Typedef Documentation

◆ Ccf_Man_t

typedef typedefABC_NAMESPACE_IMPL_START struct Ccf_Man_t_ Ccf_Man_t

DECLARATIONS ///.

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

FileName [giaCCof.c]

SystemName [ABC: Logic synthesis and verification system.]

PackageName [Scalable AIG package.]

Synopsis [Backward reachability using circuit cofactoring.]

Author [Alan Mishchenko]

Affiliation [UC Berkeley]

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

Revision [

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

]

Definition at line 31 of file giaCCof.c.

Function Documentation

◆ Ccf_ManStart()

Ccf_Man_t * Ccf_ManStart ( Gia_Man_t * pGia,
int nFrameMax,
int nConfMax,
int nTimeMax,
int fVerbose )

FUNCTION DEFINITIONS ///.

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

Synopsis [Create manager.]

Description []

SideEffects []

SeeAlso []

Definition at line 62 of file giaCCof.c.

63{
64 static Gia_ParFra_t Pars, * pPars = &Pars;
65 Ccf_Man_t * p;
66 assert( nFrameMax > 0 );
67 p = ABC_CALLOC( Ccf_Man_t, 1 );
68 p->pGia = pGia;
69 p->nFrameMax = nFrameMax;
70 p->nConfMax = nConfMax;
71 p->nTimeMax = nTimeMax;
72 p->fVerbose = fVerbose;
73 // create unrolling manager
74 memset( pPars, 0, sizeof(Gia_ParFra_t) );
75 pPars->fVerbose = fVerbose;
76 pPars->nFrames = nFrameMax;
77 pPars->fSaveLastLit = 1;
78 p->pUnr = Gia_ManUnrollStart( pGia, pPars );
79 p->vCopies = Vec_IntAlloc( 1000 );
80 // internal data
81 p->pSat = sat_solver_new();
82// sat_solver_setnvars( p->pSat, 10000 );
83 return p;
84}
#define ABC_CALLOC(type, num)
Definition abc_global.h:265
Cube * p
Definition exorList.c:222
typedefABC_NAMESPACE_IMPL_START struct Ccf_Man_t_ Ccf_Man_t
DECLARATIONS ///.
Definition giaCCof.c:31
struct Gia_ParFra_t_ Gia_ParFra_t
Definition gia.h:293
void * Gia_ManUnrollStart(Gia_Man_t *pAig, Gia_ParFra_t *pPars)
Definition giaFrames.c:402
sat_solver * sat_solver_new(void)
Definition satSolver.c:1137
int fSaveLastLit
Definition gia.h:298
int nFrames
Definition gia.h:296
int fVerbose
Definition gia.h:301
#define assert(ex)
Definition util_old.h:213
char * memset()
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Ccf_ManStop()

void Ccf_ManStop ( Ccf_Man_t * p)

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

Synopsis [Delete manager.]

Description []

SideEffects []

SeeAlso []

Definition at line 97 of file giaCCof.c.

98{
99 Vec_IntFree( p->vCopies );
100 Gia_ManUnrollStop( p->pUnr );
101 sat_solver_delete( p->pSat );
102 Gia_ManStopP( &p->pFrames );
103 ABC_FREE( p );
104}
#define ABC_FREE(obj)
Definition abc_global.h:267
void Gia_ManUnrollStop(void *pMan)
Definition giaFrames.c:310
void Gia_ManStopP(Gia_Man_t **p)
Definition giaMan.c:224
void sat_solver_delete(sat_solver *s)
Definition satSolver.c:1341
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Gia_ManCofExtendSolver()

void Gia_ManCofExtendSolver ( Ccf_Man_t * p)

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

Synopsis [Extends the solver.]

Description []

SideEffects []

SeeAlso []

Definition at line 118 of file giaCCof.c.

119{
120 Gia_Obj_t * pObj;
121 int i;
122 // add SAT clauses
123 for ( i = sat_solver_nvars(p->pSat); i < Gia_ManObjNum(p->pFrames); i++ )
124 {
125 pObj = Gia_ManObj( p->pFrames, i );
126 if ( Gia_ObjIsAnd(pObj) )
127 sat_solver_add_and( p->pSat, i,
128 Gia_ObjFaninId0(pObj, i),
129 Gia_ObjFaninId1(pObj, i),
130 Gia_ObjFaninC0(pObj),
131 Gia_ObjFaninC1(pObj), 0 );
132 }
133 sat_solver_setnvars( p->pSat, Gia_ManObjNum(p->pFrames) );
134}
#define sat_solver_add_and
Definition cecSatG2.c:38
struct Gia_Obj_t_ Gia_Obj_t
Definition gia.h:76
void sat_solver_setnvars(sat_solver *s, int n)
Definition satSolver.c:1272
int sat_solver_nvars(sat_solver *s)
Definition satSolver.c:2369
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Gia_ManCofGetReachable()

int Gia_ManCofGetReachable ( Ccf_Man_t * p,
int Lit )

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

Synopsis [Enumerates backward reachable states.]

Description [Return -1 if resource limit is reached. Returns 1 if computation converged (there is no more reachable states). Returns 0 if no more states to enumerate.]

SideEffects []

SeeAlso []

Definition at line 220 of file giaCCof.c.

221{
222 int ObjPrev = 0, ConfPrev = 0;
223 int Count = 0, LitOut, RetValue;
224 abctime clk;
225 // try solving for the first time and quit if converged
226 RetValue = sat_solver_solve( p->pSat, &Lit, &Lit + 1, p->nConfMax, 0, 0, 0 );
227 if ( RetValue == l_False )
228 return 1;
229 // iterate circuit cofactoring
230 while ( RetValue == l_True )
231 {
232 clk = Abc_Clock();
233 // derive cofactor
234 LitOut = Gia_ManCofOneDerive( p, Lit );
235 // add the blocking clause
236 RetValue = sat_solver_addclause( p->pSat, &LitOut, &LitOut + 1 );
237 assert( RetValue );
238 // try solving again
239 RetValue = sat_solver_solve( p->pSat, &Lit, &Lit + 1, p->nConfMax, 0, 0, 0 );
240 // derive cofactors
241 if ( p->fVerbose )
242 {
243 printf( "%3d : AIG =%7d Conf =%7d. ", Count++,
244 Gia_ManObjNum(p->pFrames) - ObjPrev, sat_solver_nconflicts(p->pSat) - ConfPrev );
245 Abc_PrintTime( 1, "Time", Abc_Clock() - clk );
246 ObjPrev = Gia_ManObjNum(p->pFrames);
247 ConfPrev = sat_solver_nconflicts(p->pSat);
248 }
249 }
250 if ( RetValue == l_Undef )
251 return -1;
252 return 0;
253}
ABC_INT64_T abctime
Definition abc_global.h:332
#define l_True
Definition bmcBmcS.c:35
#define l_Undef
Definition bmcBmcS.c:34
#define l_False
Definition bmcBmcS.c:36
#define sat_solver_addclause
Definition cecSatG2.c:37
#define sat_solver_solve
Definition cecSatG2.c:45
int Gia_ManCofOneDerive(Ccf_Man_t *p, int LitProp)
Definition giaCCof.c:191
int sat_solver_nconflicts(sat_solver *s)
Definition satSolver.c:2381
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Gia_ManCofOneDerive()

int Gia_ManCofOneDerive ( Ccf_Man_t * p,
int LitProp )

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

Synopsis [Cofactor the circuit w.r.t. the given assignment.]

Description [Assumes that the solver has just returned SAT.]

SideEffects []

SeeAlso []

Definition at line 191 of file giaCCof.c.

192{
193 int LitOut;
194 // derive the cofactor of the property node
195 Vec_IntFill( p->vCopies, Gia_ManObjNum(p->pFrames), -1 );
196 Gia_ManCofOneDerive_rec( p, Abc_Lit2Var(LitProp) );
197 LitOut = Vec_IntEntry( p->vCopies, Abc_Lit2Var(LitProp) );
198 LitOut = Abc_LitNotCond( LitOut, Abc_LitIsCompl(LitProp) );
199 // add new PO for the cofactor
200 Gia_ManAppendCo( p->pFrames, LitOut );
201 // add SAT clauses
203 // return negative literal of the cofactor
204 return Abc_LitNot(LitOut);
205}
void Gia_ManCofExtendSolver(Ccf_Man_t *p)
Definition giaCCof.c:118
void Gia_ManCofOneDerive_rec(Ccf_Man_t *p, int Id)
Definition giaCCof.c:153
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Gia_ManCofOneDerive_rec()

void Gia_ManCofOneDerive_rec ( Ccf_Man_t * p,
int Id )

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

Synopsis [Cofactor the circuit w.r.t. the given assignment.]

Description [Assumes that the solver has just returned SAT.]

SideEffects []

SeeAlso []

Definition at line 153 of file giaCCof.c.

154{
155 Gia_Obj_t * pObj;
156 int Res;
157 if ( Vec_IntEntry(p->vCopies, Id) != -1 )
158 return;
159 pObj = Gia_ManObj(p->pFrames, Id);
160 assert( Gia_ObjIsCi(pObj) || Gia_ObjIsAnd(pObj) );
161 if ( Gia_ObjIsAnd(pObj) )
162 {
163 int fCompl0 = Gia_ObjFaninC0(pObj);
164 int fCompl1 = Gia_ObjFaninC1(pObj);
165 int Fan0 = Gia_ObjFaninId0p(p->pFrames, pObj);
166 int Fan1 = Gia_ObjFaninId1p(p->pFrames, pObj);
167 Gia_ManCofOneDerive_rec( p, Fan0 );
168 Gia_ManCofOneDerive_rec( p, Fan1 );
169 Res = Gia_ManHashAnd( p->pFrames,
170 Gia_Obj0Copy(p->vCopies, Fan0, fCompl0),
171 Gia_Obj1Copy(p->vCopies, Fan1, fCompl1) );
172 }
173 else if ( Gia_ObjCioId(pObj) >= Gia_ManRegNum(p->pGia) ) // PI
174 Res = sat_solver_var_value( p->pSat, Id );
175 else
176 Res = Abc_Var2Lit( Id, 0 );
177 Vec_IntWriteEntry( p->vCopies, Id, Res );
178}
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_ManCofTest()

Gia_Man_t * Gia_ManCofTest ( Gia_Man_t * pGia,
int nFrameMax,
int nConfMax,
int nTimeMax,
int fVerbose )

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 266 of file giaCCof.c.

267{
268 Gia_Man_t * pNew;
269 Ccf_Man_t * p;
270 Gia_Obj_t * pObj;
271 int f, i, Lit, RetValue = -1, fFailed = 0;
272 abctime nTimeToStop = Abc_Clock() + nTimeMax * CLOCKS_PER_SEC;
273 abctime clk = Abc_Clock();
274 assert( Gia_ManPoNum(pGia) == 1 );
275
276 // create reachability manager
277 p = Ccf_ManStart( pGia, nFrameMax, nConfMax, nTimeMax, fVerbose );
278
279 // set runtime limit
280 if ( nTimeMax )
281 sat_solver_set_runtime_limit( p->pSat, nTimeToStop );
282
283 // perform backward image computation
284 for ( f = 0; f < nFrameMax; f++ )
285 {
286 if ( fVerbose )
287 printf( "ITER %3d :\n", f );
288 // add to the mapping of nodes
289 p->pFrames = (Gia_Man_t *)Gia_ManUnrollAdd( p->pUnr, f+1 );
290 // add SAT clauses
292 // return output literal
293 Lit = Gia_ManUnrollLastLit( p->pUnr );
294 // derives cofactors of the property literal till all states are blocked
295 RetValue = Gia_ManCofGetReachable( p, Lit );
296 if ( RetValue )
297 break;
298
299 // check the property output
300 Gia_ManSetPhase( p->pFrames );
301 Gia_ManForEachPo( p->pFrames, pObj, i )
302 if ( pObj->fPhase )
303 {
304 printf( "Property failed in frame %d.\n", f );
305 fFailed = 1;
306 break;
307 }
308 if ( i < Gia_ManPoNum(p->pFrames) )
309 break;
310 }
311
312 // report the result
313 if ( nTimeToStop && Abc_Clock() > nTimeToStop )
314 printf( "Runtime limit (%d sec) is reached after %d frames. ", nTimeMax, f );
315 else if ( f == nFrameMax )
316 printf( "Completed %d frames without converging. ", f );
317 else if ( RetValue == 1 )
318 printf( "Backward reachability converged after %d iterations. ", f-1 );
319 else if ( RetValue == -1 )
320 printf( "Conflict limit or timeout is reached after %d frames. ", f-1 );
321 Abc_PrintTime( 1, "Runtime", Abc_Clock() - clk );
322
323 if ( !fFailed && RetValue == 1 )
324 printf( "Property holds.\n" );
325 else if ( !fFailed )
326 printf( "Property is undecided.\n" );
327
328 // get the resulting AIG manager
329 Gia_ManHashStop( p->pFrames );
330 pNew = p->pFrames; p->pFrames = NULL;
331 Ccf_ManStop( p );
332
333 // cleanup
334// if ( fVerbose )
335// Gia_ManPrintStats( pNew, 0 );
336 pNew = Gia_ManCleanup( pGia = pNew );
337 Gia_ManStop( pGia );
338// if ( fVerbose )
339// Gia_ManPrintStats( pNew, 0 );
340 return pNew;
341}
Ccf_Man_t * Ccf_ManStart(Gia_Man_t *pGia, int nFrameMax, int nConfMax, int nTimeMax, int fVerbose)
FUNCTION DEFINITIONS ///.
Definition giaCCof.c:62
void Ccf_ManStop(Ccf_Man_t *p)
Definition giaCCof.c:97
int Gia_ManCofGetReachable(Ccf_Man_t *p, int Lit)
Definition giaCCof.c:220
void Gia_ManStop(Gia_Man_t *p)
Definition giaMan.c:82
#define Gia_ManForEachPo(p, pObj, i)
Definition gia.h:1250
void * Gia_ManUnrollAdd(void *pMan, int fMax)
Definition giaFrames.c:437
struct Gia_Man_t_ Gia_Man_t
Definition gia.h:96
Gia_Man_t * Gia_ManCleanup(Gia_Man_t *p)
Definition giaScl.c:84
int Gia_ManUnrollLastLit(void *pMan)
Definition giaFrames.c:490
void Gia_ManSetPhase(Gia_Man_t *p)
Definition giaUtil.c:420
void Gia_ManHashStop(Gia_Man_t *p)
Definition giaHash.c:149
unsigned fPhase
Definition gia.h:87
Here is the call graph for this function: