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

Go to the source code of this file.

Functions

ABC_NAMESPACE_IMPL_START int Gia_ManVerifyCex (Gia_Man_t *pAig, Abc_Cex_t *p, int fDualOut)
 DECLARATIONS ///.
 
int Gia_ManFindFailedPoCex (Gia_Man_t *pAig, Abc_Cex_t *p, int nOutputs)
 
int Gia_ManSetFailedPoCex (Gia_Man_t *pAig, Abc_Cex_t *p)
 
void Gia_ManCounterExampleValueStart (Gia_Man_t *pGia, Abc_Cex_t *pCex)
 
void Gia_ManCounterExampleValueStop (Gia_Man_t *pGia)
 
int Gia_ManCounterExampleValueLookup (Gia_Man_t *pGia, int Id, int iFrame)
 
void Gia_ManCounterExampleValueTest (Gia_Man_t *pGia, Abc_Cex_t *pCex)
 
Abc_Cex_tGia_ManCexExtendToIncludeCurrentStates (Gia_Man_t *p, Abc_Cex_t *pCex)
 
Abc_Cex_tGia_ManCexExtendToIncludeAllObjects (Gia_Man_t *p, Abc_Cex_t *pCex)
 
Gia_Man_tGia_ManFramesForCexMin (Gia_Man_t *p, int nFrames)
 
void Gia_ManMinCex (Gia_Man_t *p, Abc_Cex_t *pCex)
 
Abc_Cex_tBmc_CexCareDeriveCex (Abc_Cex_t *pCex, int iFirstVar, int *pLits, int nLits)
 
Abc_Cex_tBmc_CexCareSatBasedMinimizeAig (Gia_Man_t *p, Abc_Cex_t *pCex, int fHighEffort, int fVerbose)
 

Function Documentation

◆ Bmc_CexCareDeriveCex()

Abc_Cex_t * Bmc_CexCareDeriveCex ( Abc_Cex_t * pCex,
int iFirstVar,
int * pLits,
int nLits )

Definition at line 503 of file giaCex.c.

504{
505 Abc_Cex_t * pCexMin; int i;
506 pCexMin = Abc_CexAlloc( pCex->nRegs, pCex->nPis, pCex->iFrame + 1 );
507 pCexMin->iPo = pCex->iPo;
508 pCexMin->iFrame = pCex->iFrame;
509 for ( i = 0; i < nLits; i++ )
510 {
511 int PiNum = Abc_Lit2Var(pLits[i]) - iFirstVar;
512 assert( PiNum >= 0 && PiNum < pCex->nBits - pCex->nRegs );
513 Abc_InfoSetBit( pCexMin->pData, pCexMin->nRegs + PiNum );
514 }
515 return pCexMin;
516}
ABC_NAMESPACE_IMPL_START Abc_Cex_t * Abc_CexAlloc(int nRegs, int nRealPis, int nFrames)
DECLARATIONS ///.
Definition utilCex.c:51
typedefABC_NAMESPACE_HEADER_START struct Abc_Cex_t_ Abc_Cex_t
INCLUDES ///.
Definition utilCex.h:39
#define assert(ex)
Definition util_old.h:213
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Bmc_CexCareSatBasedMinimizeAig()

Abc_Cex_t * Bmc_CexCareSatBasedMinimizeAig ( Gia_Man_t * p,
Abc_Cex_t * pCex,
int fHighEffort,
int fVerbose )

Definition at line 517 of file giaCex.c.

518{
519 abctime clk = Abc_Clock();
520 int n, i, iFirstVar, iLit, status;
521 Vec_Int_t * vLits = NULL, * vTemp;
522 sat_solver * pSat;
523 Cnf_Dat_t * pCnf;
524 int nFinal, * pFinal;
525 Abc_Cex_t * pCexBest = NULL;
526 int CountBest = 0;
527 Gia_Man_t * pFrames;
528
529 // CEX minimization
530 clk = Abc_Clock();
531 pCexBest = Bmc_CexCareMinimizeAig( p, Gia_ManPiNum(p), pCex, 1, 1, fVerbose );
532 for ( i = pCexBest->nRegs; i < pCexBest->nBits; i++ )
533 CountBest += Abc_InfoHasBit(pCexBest->pData, i);
534 if ( fVerbose )
535 {
536 printf( "Care bits = %d. ", CountBest );
537 Abc_PrintTime( 1, "Non-SAT-based CEX minimization", Abc_Clock() - clk );
538 }
539
540 // SAT instance
541 clk = Abc_Clock();
542 pFrames = Gia_ManFramesForCexMin( p, pCex->iFrame + 1 );
543 pCnf = (Cnf_Dat_t*)Mf_ManGenerateCnf( pFrames, 8, 0, 0, 0, 0 );
544 iFirstVar = pCnf->nVars - (pCex->iFrame+1) * pCex->nPis;
545 pSat = (sat_solver*)Cnf_DataWriteIntoSolver( pCnf, 1, 0 );
546 iLit = Abc_Var2Lit( 1, 1 );
547 status = sat_solver_addclause( pSat, &iLit, &iLit + 1 );
548 assert( status );
549 // create literals
550 vTemp = Vec_IntAlloc( 100 );
551 for ( i = pCex->nRegs; i < pCex->nBits; i++ )
552 Vec_IntPush( vTemp, Abc_Var2Lit(iFirstVar + i - pCex->nRegs, !Abc_InfoHasBit(pCex->pData, i)) );
553 if ( fVerbose )
554 Abc_PrintTime( 1, "Constructing SAT solver", Abc_Clock() - clk );
555
556 for ( n = 0; n < 2; n++ )
557 {
558 Vec_IntFreeP( &vLits );
559
560 vLits = Vec_IntDup( vTemp );
561 if ( n ) Vec_IntReverseOrder( vLits );
562
563 // SAT-based minimization
564 clk = Abc_Clock();
565 status = sat_solver_solve( pSat, Vec_IntArray(vLits), Vec_IntLimit(vLits), 0, 0, 0, 0 );
566 nFinal = sat_solver_final( pSat, &pFinal );
567 if ( fVerbose )
568 {
569 printf( "Status %s Selected %5d assumptions out of %5d. ", status == l_False ? "OK ":"BUG", nFinal, Vec_IntSize(vLits) );
570 Abc_PrintTime( 1, "Analyze_final", Abc_Clock() - clk );
571 }
572 if ( CountBest > nFinal )
573 {
574 CountBest = nFinal;
575 ABC_FREE( pCexBest );
576 pCexBest = Bmc_CexCareDeriveCex( pCex, iFirstVar, pFinal, nFinal );
577 }
578 if ( !fHighEffort )
579 continue;
580
581 // SAT-based minimization
582 clk = Abc_Clock();
583 nFinal = sat_solver_minimize_assumptions( pSat, Vec_IntArray(vLits), Vec_IntSize(vLits), 0 );
584 if ( fVerbose )
585 {
586 printf( "Status %s Selected %5d assumptions out of %5d. ", status == l_False ? "OK ":"BUG", nFinal, Vec_IntSize(vLits) );
587 Abc_PrintTime( 1, "LEXUNSAT ", Abc_Clock() - clk );
588 }
589 if ( CountBest > nFinal )
590 {
591 CountBest = nFinal;
592 ABC_FREE( pCexBest );
593 pCexBest = Bmc_CexCareDeriveCex( pCex, iFirstVar, Vec_IntArray(vLits), nFinal );
594 }
595 }
596 if ( fVerbose )
597 {
598 printf( "Final : " );
599 Bmc_CexPrint( pCexBest, pCexBest->nPis, 0 );
600 }
601 // cleanup
602 Vec_IntFreeP( &vLits );
603 Vec_IntFreeP( &vTemp );
604 sat_solver_delete( pSat );
605 Cnf_DataFree( pCnf );
606 Gia_ManStop( pFrames );
607 return pCexBest;
608}
ABC_INT64_T abctime
Definition abc_global.h:332
#define ABC_FREE(obj)
Definition abc_global.h:267
typedefABC_NAMESPACE_IMPL_START struct Vec_Int_t_ Vec_Int_t
DECLARATIONS ///.
Definition bblif.c:37
#define l_False
Definition bmcBmcS.c:36
void Bmc_CexPrint(Abc_Cex_t *pCex, int nRealPis, int fVerbose)
Abc_Cex_t * Bmc_CexCareMinimizeAig(Gia_Man_t *p, int nRealPis, Abc_Cex_t *pCex, int nTryCexes, int fCheck, int fVerbose)
Definition bmcCexCare.c:254
#define sat_solver_addclause
Definition cecSatG2.c:37
#define sat_solver
Definition cecSatG2.c:34
#define sat_solver_solve
Definition cecSatG2.c:45
struct Cnf_Dat_t_ Cnf_Dat_t
Definition cnf.h:52
void Cnf_DataFree(Cnf_Dat_t *p)
Definition cnfMan.c:207
Cube * p
Definition exorList.c:222
Gia_Man_t * Gia_ManFramesForCexMin(Gia_Man_t *p, int nFrames)
Definition giaCex.c:401
Abc_Cex_t * Bmc_CexCareDeriveCex(Abc_Cex_t *pCex, int iFirstVar, int *pLits, int nLits)
Definition giaCex.c:503
void Gia_ManStop(Gia_Man_t *p)
Definition giaMan.c:82
struct Gia_Man_t_ Gia_Man_t
Definition gia.h:96
void * Mf_ManGenerateCnf(Gia_Man_t *pGia, int nLutSize, int fCnfObjIds, int fAddOrCla, int fMapping, int fVerbose)
Definition giaMf.c:1877
void * Cnf_DataWriteIntoSolver(Cnf_Dat_t *p, int nFrames, int fInit)
Definition cnfMan.c:579
void sat_solver_delete(sat_solver *s)
Definition satSolver.c:1341
int sat_solver_minimize_assumptions(sat_solver *s, int *pLits, int nLits, int nConfLimit)
Definition satSolver.c:2209
int nVars
Definition cnf.h:59
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Gia_ManCexExtendToIncludeAllObjects()

Abc_Cex_t * Gia_ManCexExtendToIncludeAllObjects ( Gia_Man_t * p,
Abc_Cex_t * pCex )

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

Synopsis [Returns CEX containing all object valuess for each timeframe.]

Description []

SideEffects []

SeeAlso []

Definition at line 353 of file giaCex.c.

354{
355 Abc_Cex_t * pNew;
356 Gia_Obj_t * pObj, * pObjRo, * pObjRi;
357 int i, k, iBit = 0;
358 assert( pCex->nRegs > 0 );
359 // start the counter-example
360 pNew = Abc_CexAlloc( 0, Gia_ManObjNum(p), pCex->iFrame + 1 );
361 pNew->iFrame = pCex->iFrame;
362 pNew->iPo = pCex->iPo;
363 // set const0
364 Gia_ManConst0(p)->fMark0 = 0;
365 // set init state
366 Gia_ManForEachRi( p, pObjRi, k )
367 pObjRi->fMark0 = Abc_InfoHasBit(pCex->pData, iBit++);
368 assert( iBit == pCex->nRegs );
369 for ( i = 0; i <= pCex->iFrame; i++ )
370 {
371 Gia_ManForEachPi( p, pObj, k )
372 pObj->fMark0 = Abc_InfoHasBit(pCex->pData, iBit++);
373 Gia_ManForEachRiRo( p, pObjRi, pObjRo, k )
374 pObjRo->fMark0 = pObjRi->fMark0;
375 Gia_ManForEachObj( p, pObj, k )
376 if ( pObj->fMark0 )
377 Abc_InfoSetBit( pNew->pData, pNew->nPis * i + k );
378 Gia_ManForEachAnd( p, pObj, k )
379 pObj->fMark0 = (Gia_ObjFanin0(pObj)->fMark0 ^ Gia_ObjFaninC0(pObj)) & (Gia_ObjFanin1(pObj)->fMark0 ^ Gia_ObjFaninC1(pObj));
380 Gia_ManForEachCo( p, pObj, k )
381 pObj->fMark0 = Gia_ObjFanin0(pObj)->fMark0 ^ Gia_ObjFaninC0(pObj);
382 }
383 assert( iBit == pCex->nBits );
384 assert( Gia_ManPo(p, pCex->iPo)->fMark0 == 1 );
386 return pNew;
387}
#define Gia_ManForEachAnd(p, pObj, i)
Definition gia.h:1214
#define Gia_ManForEachPi(p, pObj, i)
Definition gia.h:1248
struct Gia_Obj_t_ Gia_Obj_t
Definition gia.h:76
void Gia_ManCleanMark0(Gia_Man_t *p)
Definition giaUtil.c:256
#define Gia_ManForEachObj(p, pObj, i)
MACRO DEFINITIONS ///.
Definition gia.h:1190
#define Gia_ManForEachCo(p, pObj, i)
Definition gia.h:1236
#define Gia_ManForEachRiRo(p, pObjRi, pObjRo, i)
Definition gia.h:1256
#define Gia_ManForEachRi(p, pObj, i)
Definition gia.h:1254
unsigned fMark0
Definition gia.h:81
Here is the call graph for this function:

◆ Gia_ManCexExtendToIncludeCurrentStates()

Abc_Cex_t * Gia_ManCexExtendToIncludeCurrentStates ( Gia_Man_t * p,
Abc_Cex_t * pCex )

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

Synopsis [Returns CEX containing PI+CS values for each timeframe.]

Description []

SideEffects []

SeeAlso []

Definition at line 306 of file giaCex.c.

307{
308 Abc_Cex_t * pNew;
309 Gia_Obj_t * pObj, * pObjRo, * pObjRi;
310 int i, k, iBit = 0;
311 assert( pCex->nRegs > 0 );
312 // start the counter-example
313 pNew = Abc_CexAlloc( 0, Gia_ManCiNum(p), pCex->iFrame + 1 );
314 pNew->iFrame = pCex->iFrame;
315 pNew->iPo = pCex->iPo;
316 // set const0
317 Gia_ManConst0(p)->fMark0 = 0;
318 // set init state
319 Gia_ManForEachRi( p, pObjRi, k )
320 pObjRi->fMark0 = Abc_InfoHasBit(pCex->pData, iBit++);
321 assert( iBit == pCex->nRegs );
322 for ( i = 0; i <= pCex->iFrame; i++ )
323 {
324 Gia_ManForEachPi( p, pObj, k )
325 pObj->fMark0 = Abc_InfoHasBit(pCex->pData, iBit++);
326 Gia_ManForEachRiRo( p, pObjRi, pObjRo, k )
327 pObjRo->fMark0 = pObjRi->fMark0;
328 Gia_ManForEachCi( p, pObj, k )
329 if ( pObj->fMark0 )
330 Abc_InfoSetBit( pNew->pData, pNew->nPis * i + k );
331 Gia_ManForEachAnd( p, pObj, k )
332 pObj->fMark0 = (Gia_ObjFanin0(pObj)->fMark0 ^ Gia_ObjFaninC0(pObj)) & (Gia_ObjFanin1(pObj)->fMark0 ^ Gia_ObjFaninC1(pObj));
333 Gia_ManForEachCo( p, pObj, k )
334 pObj->fMark0 = Gia_ObjFanin0(pObj)->fMark0 ^ Gia_ObjFaninC0(pObj);
335 }
336 assert( iBit == pCex->nBits );
337 assert( Gia_ManPo(p, pCex->iPo)->fMark0 == 1 );
339 return pNew;
340}
#define Gia_ManForEachCi(p, pObj, i)
Definition gia.h:1228
Here is the call graph for this function:

◆ Gia_ManCounterExampleValueLookup()

int Gia_ManCounterExampleValueLookup ( Gia_Man_t * pGia,
int Id,
int iFrame )

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

Synopsis [Returns the value of the given object in the given timeframe.]

Description [Should be called to probe the value of an object with the given ID (iFrame is a 0-based number of a time frame - should not exceed the number of timeframes in the original counter-example).]

SideEffects []

SeeAlso []

Definition at line 266 of file giaCex.c.

267{
268 assert( Id >= 0 && Id < Gia_ManObjNum(pGia) );
269 return Abc_InfoHasBit( (unsigned *)pGia->pData2, Gia_ManObjNum(pGia) * iFrame + Id );
270}
unsigned * pData2
Definition gia.h:199
Here is the caller graph for this function:

◆ Gia_ManCounterExampleValueStart()

void Gia_ManCounterExampleValueStart ( Gia_Man_t * pGia,
Abc_Cex_t * pCex )

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

Synopsis [Starts the process of returning values for internal nodes.]

Description [Should be called when pCex is available, before probing any object for its value using Gia_ManCounterExampleValueLookup().]

SideEffects []

SeeAlso []

Definition at line 188 of file giaCex.c.

189{
190 Gia_Obj_t * pObj, * pObjRi, * pObjRo;
191 int Val0, Val1, nObjs, i, k, iBit = 0;
192 assert( Gia_ManRegNum(pGia) > 0 ); // makes sense only for sequential AIGs
193 assert( pGia->pData2 == NULL ); // if this fail, there may be a memory leak
194 // allocate memory to store simulation bits for internal nodes
195 pGia->pData2 = ABC_CALLOC( unsigned, Abc_BitWordNum( (pCex->iFrame + 1) * Gia_ManObjNum(pGia) ) );
196 // the register values in the counter-example should be zero
197 Gia_ManForEachRo( pGia, pObj, k )
198 assert( Abc_InfoHasBit(pCex->pData, iBit) == 0 ), iBit++;
199 // iterate through the timeframes
200 nObjs = Gia_ManObjNum(pGia);
201 for ( i = 0; i <= pCex->iFrame; i++ )
202 {
203 // no need to set constant-0 node
204 // set primary inputs according to the counter-example
205 Gia_ManForEachPi( pGia, pObj, k )
206 if ( Abc_InfoHasBit(pCex->pData, iBit++) )
207 Abc_InfoSetBit( (unsigned *)pGia->pData2, nObjs * i + Gia_ObjId(pGia, pObj) );
208 // compute values for each node
209 Gia_ManForEachAnd( pGia, pObj, k )
210 {
211 Val0 = Abc_InfoHasBit( (unsigned *)pGia->pData2, nObjs * i + Gia_ObjFaninId0p(pGia, pObj) );
212 Val1 = Abc_InfoHasBit( (unsigned *)pGia->pData2, nObjs * i + Gia_ObjFaninId1p(pGia, pObj) );
213 if ( (Val0 ^ Gia_ObjFaninC0(pObj)) & (Val1 ^ Gia_ObjFaninC1(pObj)) )
214 Abc_InfoSetBit( (unsigned *)pGia->pData2, nObjs * i + Gia_ObjId(pGia, pObj) );
215 }
216 // derive values for combinational outputs
217 Gia_ManForEachCo( pGia, pObj, k )
218 {
219 Val0 = Abc_InfoHasBit( (unsigned *)pGia->pData2, nObjs * i + Gia_ObjFaninId0p(pGia, pObj) );
220 if ( Val0 ^ Gia_ObjFaninC0(pObj) )
221 Abc_InfoSetBit( (unsigned *)pGia->pData2, nObjs * i + Gia_ObjId(pGia, pObj) );
222 }
223 if ( i == pCex->iFrame )
224 continue;
225 // transfer values to the register output of the next frame
226 Gia_ManForEachRiRo( pGia, pObjRi, pObjRo, k )
227 if ( Abc_InfoHasBit( (unsigned *)pGia->pData2, nObjs * i + Gia_ObjId(pGia, pObjRi) ) )
228 Abc_InfoSetBit( (unsigned *)pGia->pData2, nObjs * (i+1) + Gia_ObjId(pGia, pObjRo) );
229 }
230 assert( iBit == pCex->nBits );
231 // check that the counter-example is correct, that is, the corresponding output is asserted
232 assert( Abc_InfoHasBit( (unsigned *)pGia->pData2, nObjs * pCex->iFrame + Gia_ObjId(pGia, Gia_ManCo(pGia, pCex->iPo)) ) );
233}
#define ABC_CALLOC(type, num)
Definition abc_global.h:265
#define Gia_ManForEachRo(p, pObj, i)
Definition gia.h:1252
Here is the caller graph for this function:

◆ Gia_ManCounterExampleValueStop()

void Gia_ManCounterExampleValueStop ( Gia_Man_t * pGia)

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

Synopsis [Stops the process of returning values for internal nodes.]

Description [Should be called when probing is no longer needed]

SideEffects []

SeeAlso []

Definition at line 246 of file giaCex.c.

247{
248 assert( pGia->pData2 != NULL ); // if this fail, we try to call this procedure more than once
249 ABC_FREE( pGia->pData2 );
250 pGia->pData2 = NULL;
251}
Here is the caller graph for this function:

◆ Gia_ManCounterExampleValueTest()

void Gia_ManCounterExampleValueTest ( Gia_Man_t * pGia,
Abc_Cex_t * pCex )

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

Synopsis [Procedure to test the above code.]

Description []

SideEffects []

SeeAlso []

Definition at line 283 of file giaCex.c.

284{
285 Gia_Obj_t * pObj = Gia_ManObj( pGia, Gia_ManObjNum(pGia)/2 );
286 int iFrame = Abc_MaxInt( 0, pCex->iFrame - 1 );
287 printf( "\nUsing counter-example, which asserts output %d in frame %d.\n", pCex->iPo, pCex->iFrame );
289 printf( "Value of object %d in frame %d is %d.\n", Gia_ObjId(pGia, pObj), iFrame,
290 Gia_ManCounterExampleValueLookup(pGia, Gia_ObjId(pGia, pObj), iFrame) );
292}
void Gia_ManCounterExampleValueStop(Gia_Man_t *pGia)
Definition giaCex.c:246
int Gia_ManCounterExampleValueLookup(Gia_Man_t *pGia, int Id, int iFrame)
Definition giaCex.c:266
void Gia_ManCounterExampleValueStart(Gia_Man_t *pGia, Abc_Cex_t *pCex)
Definition giaCex.c:188
Here is the call graph for this function:

◆ Gia_ManFindFailedPoCex()

int Gia_ManFindFailedPoCex ( Gia_Man_t * pAig,
Abc_Cex_t * p,
int nOutputs )

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

Synopsis [Resimulates the counter-example.]

Description []

SideEffects []

SeeAlso []

Definition at line 91 of file giaCex.c.

92{
93 Gia_Obj_t * pObj, * pObjRi, * pObjRo;
94 int RetValue, i, k, iBit = 0;
95 assert( Gia_ManPiNum(pAig) == p->nPis );
97 Gia_ManForEachRo( pAig, pObj, i )
98 pObj->fMark0 = Abc_InfoHasBit(p->pData, iBit++);
99 iBit = p->nRegs;
100 for ( i = 0; i <= p->iFrame; i++ )
101 {
102 Gia_ManForEachPi( pAig, pObj, k )
103 pObj->fMark0 = Abc_InfoHasBit(p->pData, iBit++);
104 Gia_ManForEachAnd( pAig, pObj, k )
105 pObj->fMark0 = (Gia_ObjFanin0(pObj)->fMark0 ^ Gia_ObjFaninC0(pObj)) &
106 (Gia_ObjFanin1(pObj)->fMark0 ^ Gia_ObjFaninC1(pObj));
107 Gia_ManForEachCo( pAig, pObj, k )
108 pObj->fMark0 = Gia_ObjFanin0(pObj)->fMark0 ^ Gia_ObjFaninC0(pObj);
109 Gia_ManForEachRiRo( pAig, pObjRi, pObjRo, k )
110 pObjRo->fMark0 = pObjRi->fMark0;
111 }
112 assert( iBit == p->nBits );
113 // figure out the number of failed output
114 RetValue = -1;
115// for ( i = Gia_ManPoNum(pAig) - 1; i >= nOutputs; i-- )
116 for ( i = nOutputs; i < Gia_ManPoNum(pAig); i++ )
117 {
118 if ( Gia_ManPo(pAig, i)->fMark0 )
119 {
120 RetValue = i;
121 break;
122 }
123 }
124 Gia_ManCleanMark0(pAig);
125 return RetValue;
126}
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Gia_ManFramesForCexMin()

Gia_Man_t * Gia_ManFramesForCexMin ( Gia_Man_t * p,
int nFrames )

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 401 of file giaCex.c.

402{
403 Gia_Man_t * pFrames, * pTemp;
404 Gia_Obj_t * pObj; int i, f;
405 assert( Gia_ManPoNum(p) == 1 );
406 pFrames = Gia_ManStart( Gia_ManObjNum(p) );
407 pFrames->pName = Abc_UtilStrsav( p->pName );
408 pFrames->pSpec = Abc_UtilStrsav( p->pSpec );
409 Gia_ManHashAlloc( pFrames );
410 Gia_ManConst0(p)->Value = 0;
411 for ( f = 0; f < nFrames; f++ )
412 {
413 Gia_ManForEachRo( p, pObj, i )
414 pObj->Value = f ? Gia_ObjRoToRi( p, pObj )->Value : 0;
415 Gia_ManForEachPi( p, pObj, i )
416 pObj->Value = Gia_ManAppendCi( pFrames );
417 Gia_ManForEachAnd( p, pObj, i )
418 pObj->Value = Gia_ManHashAnd( pFrames, Gia_ObjFanin0Copy(pObj), Gia_ObjFanin1Copy(pObj) );
419 Gia_ManForEachRi( p, pObj, i )
420 pObj->Value = Gia_ObjFanin0Copy(pObj);
421 }
422 Gia_ManForEachCo( p, pObj, i )
423 Gia_ManAppendCo( pFrames, Gia_ObjFanin0Copy(pObj) );
424 pFrames = Gia_ManCleanup( pTemp = pFrames );
425 //printf( "Before cleanup = %d nodes. After cleanup = %d nodes.\n",
426 // Gia_ManAndNum(pTemp), Gia_ManAndNum(pFrames) );
427 Gia_ManStop( pTemp );
428 return pFrames;
429}
void Gia_ManHashAlloc(Gia_Man_t *p)
Definition giaHash.c:105
Gia_Man_t * Gia_ManStart(int nObjsMax)
FUNCTION DEFINITIONS ///.
Definition giaMan.c:57
Gia_Man_t * Gia_ManCleanup(Gia_Man_t *p)
Definition giaScl.c:84
int Gia_ManHashAnd(Gia_Man_t *p, int iLit0, int iLit1)
Definition giaHash.c:576
char * pSpec
Definition gia.h:100
char * pName
Definition gia.h:99
unsigned Value
Definition gia.h:89
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Gia_ManMinCex()

void Gia_ManMinCex ( Gia_Man_t * p,
Abc_Cex_t * pCex )

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 442 of file giaCex.c.

443{
444 abctime clk = Abc_Clock();
445 int n, i, iFirstVar, iLit, status, Counter = 0;//, Id;
446 Vec_Int_t * vLits;
447 sat_solver * pSat;
448 Cnf_Dat_t * pCnf;
449 int nFinal, * pFinal;
450 Abc_Cex_t * pCexCare;
451 Gia_Man_t * pFrames;
452
453 // CEX minimization
454 clk = Abc_Clock();
455 pCexCare = Bmc_CexCareMinimizeAig( p, Gia_ManPiNum(p), pCex, 1, 1, 1 );
456 for ( i = pCexCare->nRegs; i < pCexCare->nBits; i++ )
457 Counter += Abc_InfoHasBit(pCexCare->pData, i);
458 Abc_CexFree( pCexCare );
459 printf( "Care bits = %d. ", Counter );
460 Abc_PrintTime( 1, "CEX minimization", Abc_Clock() - clk );
461
462 // SAT instance
463 clk = Abc_Clock();
464 pFrames = Gia_ManFramesForCexMin( p, pCex->iFrame + 1 );
465 pCnf = (Cnf_Dat_t*)Mf_ManGenerateCnf( pFrames, 8, 0, 0, 0, 0 );
466 iFirstVar = pCnf->nVars - (pCex->iFrame+1) * pCex->nPis;
467 pSat = (sat_solver*)Cnf_DataWriteIntoSolver( pCnf, 1, 0 );
468 iLit = Abc_Var2Lit( 1, 1 );
469 status = sat_solver_addclause( pSat, &iLit, &iLit + 1 );
470 assert( status );
471 // create literals
472 vLits = Vec_IntAlloc( 100 );
473 for ( i = pCex->nRegs; i < pCex->nBits; i++ )
474 Vec_IntPush( vLits, Abc_Var2Lit(iFirstVar + i - pCex->nRegs, !Abc_InfoHasBit(pCex->pData, i)) );
475 Abc_PrintTime( 1, "SAT solver", Abc_Clock() - clk );
476
477 for ( n = 0; n < 2; n++ )
478 {
479 if ( n ) Vec_IntReverseOrder( vLits );
480
481 // SAT-based minimization
482 clk = Abc_Clock();
483 status = sat_solver_solve( pSat, Vec_IntArray(vLits), Vec_IntLimit(vLits), 0, 0, 0, 0 );
484 nFinal = sat_solver_final( pSat, &pFinal );
485 printf( "Status %d. Selected %d assumptions out of %d. ", status, nFinal, Vec_IntSize(vLits) );
486 Abc_PrintTime( 1, "Analyze_final", Abc_Clock() - clk );
487
488 // SAT-based minimization
489 clk = Abc_Clock();
490 nFinal = sat_solver_minimize_assumptions( pSat, Vec_IntArray(vLits), Vec_IntSize(vLits), 0 );
491 printf( "Status %d. Selected %d assumptions out of %d. ", status, nFinal, Vec_IntSize(vLits) );
492 Abc_PrintTime( 1, "LEXUNSAT", Abc_Clock() - clk );
493 }
494
495 // cleanup
496 Vec_IntFree( vLits );
497 sat_solver_delete( pSat );
498 Cnf_DataFree( pCnf );
499 Gia_ManStop( pFrames );
500}
void Abc_CexFree(Abc_Cex_t *p)
Definition utilCex.c:382
Here is the call graph for this function:

◆ Gia_ManSetFailedPoCex()

int Gia_ManSetFailedPoCex ( Gia_Man_t * pAig,
Abc_Cex_t * p )

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

Synopsis [Determines the failed PO when its exact frame is not known.]

Description []

SideEffects []

SeeAlso []

Definition at line 139 of file giaCex.c.

140{
141 Gia_Obj_t * pObj, * pObjRi, * pObjRo;
142 int i, k, iBit = 0;
143 assert( Gia_ManPiNum(pAig) == p->nPis );
144 Gia_ManCleanMark0(pAig);
145 p->iPo = -1;
146// Gia_ManForEachRo( pAig, pObj, i )
147// pObj->fMark0 = Abc_InfoHasBit(p->pData, iBit++);
148 iBit = p->nRegs;
149 for ( i = 0; i <= p->iFrame; i++ )
150 {
151 Gia_ManForEachPi( pAig, pObj, k )
152 pObj->fMark0 = Abc_InfoHasBit(p->pData, iBit++);
153 Gia_ManForEachAnd( pAig, pObj, k )
154 pObj->fMark0 = (Gia_ObjFanin0(pObj)->fMark0 ^ Gia_ObjFaninC0(pObj)) &
155 (Gia_ObjFanin1(pObj)->fMark0 ^ Gia_ObjFaninC1(pObj));
156 Gia_ManForEachCo( pAig, pObj, k )
157 pObj->fMark0 = Gia_ObjFanin0(pObj)->fMark0 ^ Gia_ObjFaninC0(pObj);
158 Gia_ManForEachRiRo( pAig, pObjRi, pObjRo, k )
159 pObjRo->fMark0 = pObjRi->fMark0;
160 // check the POs
161 Gia_ManForEachPo( pAig, pObj, k )
162 {
163 if ( !pObj->fMark0 )
164 continue;
165 p->iPo = k;
166 p->iFrame = i;
167 p->nBits = iBit;
168 break;
169 }
170 }
171 Gia_ManCleanMark0(pAig);
172 return p->iPo;
173}
#define Gia_ManForEachPo(p, pObj, i)
Definition gia.h:1250
Here is the call graph for this function:

◆ Gia_ManVerifyCex()

ABC_NAMESPACE_IMPL_START int Gia_ManVerifyCex ( Gia_Man_t * pAig,
Abc_Cex_t * p,
int fDualOut )

DECLARATIONS ///.

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

FileName [giaAbs.c]

SystemName [ABC: Logic synthesis and verification system.]

PackageName [Scalable AIG package.]

Synopsis [Counter-example-guided abstraction refinement.]

Author [Alan Mishchenko]

Affiliation [UC Berkeley]

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

Revision [

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

] FUNCTION DEFINITIONS /// Function*************************************************************

Synopsis [Resimulates the counter-example.]

Description []

SideEffects []

SeeAlso []

Definition at line 48 of file giaCex.c.

49{
50 Gia_Obj_t * pObj, * pObjRi, * pObjRo;
51 int RetValue, i, k, iBit = 0;
53 Gia_ManForEachRo( pAig, pObj, i )
54 pObj->fMark0 = Abc_InfoHasBit(p->pData, iBit++);
55 for ( i = 0; i <= p->iFrame; i++ )
56 {
57 Gia_ManForEachPi( pAig, pObj, k )
58 pObj->fMark0 = Abc_InfoHasBit(p->pData, iBit++);
59 Gia_ManForEachAnd( pAig, pObj, k )
60 pObj->fMark0 = (Gia_ObjFanin0(pObj)->fMark0 ^ Gia_ObjFaninC0(pObj)) &
61 (Gia_ObjFanin1(pObj)->fMark0 ^ Gia_ObjFaninC1(pObj));
62 Gia_ManForEachCo( pAig, pObj, k )
63 pObj->fMark0 = Gia_ObjFanin0(pObj)->fMark0 ^ Gia_ObjFaninC0(pObj);
64 if ( i == p->iFrame )
65 break;
66 Gia_ManForEachRiRo( pAig, pObjRi, pObjRo, k )
67 {
68 pObjRo->fMark0 = pObjRi->fMark0;
69 }
70 }
71 assert( iBit == p->nBits );
72 if ( fDualOut )
73 RetValue = Gia_ManPo(pAig, 2*p->iPo)->fMark0 ^ Gia_ManPo(pAig, 2*p->iPo+1)->fMark0;
74 else
75 RetValue = Gia_ManPo(pAig, p->iPo)->fMark0;
77 return RetValue;
78}
Here is the call graph for this function:
Here is the caller graph for this function: