abc-master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
sscCore.c File Reference
#include "sscInt.h"
#include "proof/cec/cec.h"

Go to the source code of this file.

Functions

ABC_NAMESPACE_IMPL_START void Ssc_ManSetDefaultParams (Ssc_Pars_t *p)
 DECLARATIONS ///. More...
 
void Ssc_ManStop (Ssc_Man_t *p)
 
Ssc_Man_tSsc_ManStart (Gia_Man_t *pAig, Gia_Man_t *pCare, Ssc_Pars_t *pPars)
 
void Ssc_ManPrintStats (Ssc_Man_t *p)
 
int Ssc_GiaSimulatePatternFraig_rec (Ssc_Man_t *p, int iFraigObj)
 
int Ssc_GiaSimulatePattern_rec (Ssc_Man_t *p, Gia_Obj_t *pObj)
 
int Ssc_GiaResimulateOneClass (Ssc_Man_t *p, int iRepr, int iObj)
 
int Ssc_PerformVerification (Gia_Man_t *p0, Gia_Man_t *p1, Gia_Man_t *pC)
 
Gia_Man_tSsc_PerformSweepingInt (Gia_Man_t *pAig, Gia_Man_t *pCare, Ssc_Pars_t *pPars)
 
Gia_Man_tSsc_PerformSweeping (Gia_Man_t *pAig, Gia_Man_t *pCare, Ssc_Pars_t *pPars)
 
Gia_Man_tSsc_PerformSweepingConstr (Gia_Man_t *p, Ssc_Pars_t *pPars)
 

Function Documentation

int Ssc_GiaResimulateOneClass ( Ssc_Man_t p,
int  iRepr,
int  iObj 
)

Definition at line 196 of file sscCore.c.

197 {
198  int Ent, RetValue;
199  assert( iRepr == Gia_ObjRepr(p->pAig, iObj) );
200  assert( Gia_ObjIsHead( p->pAig, iRepr ) );
201  // set bit-values at the nodes according to the counter-example
203  Gia_ClassForEachObj( p->pAig, iRepr, Ent )
204  Ssc_GiaSimulatePattern_rec( p, Gia_ManObj(p->pAig, Ent) );
205  // refine one class using these bit-values
206  RetValue = Ssc_GiaSimClassRefineOneBit( p->pAig, iRepr );
207  // check that the candidate equivalence is indeed refined
208  assert( iRepr != Gia_ObjRepr(p->pAig, iObj) );
209  return RetValue;
210 }
Aig_Man_t * pAig
Definition: llb3Image.c:49
static Llb_Mgr_t * p
Definition: llb3Image.c:950
int Ssc_GiaSimClassRefineOneBit(Gia_Man_t *p, int i)
Definition: sscClass.c:162
static int Gia_ObjIsHead(Gia_Man_t *p, int Id)
Definition: gia.h:916
static Gia_Obj_t * Gia_ManObj(Gia_Man_t *p, int v)
Definition: gia.h:402
int Ssc_GiaSimulatePattern_rec(Ssc_Man_t *p, Gia_Obj_t *pObj)
Definition: sscCore.c:177
#define Gia_ClassForEachObj(p, i, iObj)
Definition: gia.h:931
#define assert(ex)
Definition: util_old.h:213
void Gia_ManIncrementTravId(Gia_Man_t *p)
Definition: giaUtil.c:149
static int Gia_ObjRepr(Gia_Man_t *p, int Id)
Definition: gia.h:887
int Ssc_GiaSimulatePattern_rec ( Ssc_Man_t p,
Gia_Obj_t pObj 
)

Definition at line 177 of file sscCore.c.

178 {
179  int Res0, Res1;
180  if ( Gia_ObjIsTravIdCurrent(p->pAig, pObj) )
181  return pObj->fMark0;
183  if ( ~pObj->Value ) // mapping into FRAIG exists - simulate FRAIG
184  {
186  pObj->fMark0 = Res0 ^ Abc_LitIsCompl(pObj->Value);
187  }
188  else // mapping into FRAIG does not exist - simulate AIG
189  {
190  Res0 = Ssc_GiaSimulatePattern_rec( p, Gia_ObjFanin0(pObj) );
191  Res1 = Ssc_GiaSimulatePattern_rec( p, Gia_ObjFanin1(pObj) );
192  pObj->fMark0 = (Res0 ^ Gia_ObjFaninC0(pObj)) & (Res1 ^ Gia_ObjFaninC1(pObj));
193  }
194  return pObj->fMark0;
195 }
int Ssc_GiaSimulatePatternFraig_rec(Ssc_Man_t *p, int iFraigObj)
Definition: sscCore.c:164
Aig_Man_t * pAig
Definition: llb3Image.c:49
static int Gia_ObjFaninC1(Gia_Obj_t *pObj)
Definition: gia.h:452
static Llb_Mgr_t * p
Definition: llb3Image.c:950
static int Gia_ObjIsTravIdCurrent(Gia_Man_t *p, Gia_Obj_t *pObj)
Definition: gia.h:533
static int Abc_LitIsCompl(int Lit)
Definition: abc_global.h:265
static Gia_Obj_t * Gia_ObjFanin0(Gia_Obj_t *pObj)
Definition: gia.h:454
static void Gia_ObjSetTravIdCurrent(Gia_Man_t *p, Gia_Obj_t *pObj)
Definition: gia.h:531
int Ssc_GiaSimulatePattern_rec(Ssc_Man_t *p, Gia_Obj_t *pObj)
Definition: sscCore.c:177
unsigned fMark0
Definition: gia.h:79
static int Abc_Lit2Var(int Lit)
Definition: abc_global.h:264
static Gia_Obj_t * Gia_ObjFanin1(Gia_Obj_t *pObj)
Definition: gia.h:455
unsigned Value
Definition: gia.h:87
static int Gia_ObjFaninC0(Gia_Obj_t *pObj)
Definition: gia.h:451
int Ssc_GiaSimulatePatternFraig_rec ( Ssc_Man_t p,
int  iFraigObj 
)

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

Synopsis [Refine one class by resimulating one pattern.]

Description []

SideEffects []

SeeAlso []

Definition at line 164 of file sscCore.c.

165 {
166  Gia_Obj_t * pObj;
167  int Res0, Res1;
168  if ( Ssc_ObjSatVar(p, iFraigObj) )
169  return sat_solver_var_value( p->pSat, Ssc_ObjSatVar(p, iFraigObj) );
170  pObj = Gia_ManObj( p->pFraig, iFraigObj );
171  assert( Gia_ObjIsAnd(pObj) );
172  Res0 = Ssc_GiaSimulatePatternFraig_rec( p, Gia_ObjFaninId0(pObj, iFraigObj) );
173  Res1 = Ssc_GiaSimulatePatternFraig_rec( p, Gia_ObjFaninId1(pObj, iFraigObj) );
174  pObj->fMark0 = (Res0 ^ Gia_ObjFaninC0(pObj)) & (Res1 ^ Gia_ObjFaninC1(pObj));
175  return pObj->fMark0;
176 }
int Ssc_GiaSimulatePatternFraig_rec(Ssc_Man_t *p, int iFraigObj)
Definition: sscCore.c:164
static int Ssc_ObjSatVar(Ssc_Man_t *p, int iObj)
MACRO DEFINITIONS ///.
Definition: sscInt.h:90
static int Gia_ObjFaninC1(Gia_Obj_t *pObj)
Definition: gia.h:452
static Llb_Mgr_t * p
Definition: llb3Image.c:950
static Gia_Obj_t * Gia_ManObj(Gia_Man_t *p, int v)
Definition: gia.h:402
Definition: gia.h:75
static int sat_solver_var_value(sat_solver *s, int v)
Definition: satSolver.h:200
unsigned fMark0
Definition: gia.h:79
static int Gia_ObjIsAnd(Gia_Obj_t *pObj)
Definition: gia.h:422
#define assert(ex)
Definition: util_old.h:213
static int Gia_ObjFaninC0(Gia_Obj_t *pObj)
Definition: gia.h:451
static int Gia_ObjFaninId1(Gia_Obj_t *pObj, int ObjId)
Definition: gia.h:461
static int Gia_ObjFaninId0(Gia_Obj_t *pObj, int ObjId)
Definition: gia.h:460
void Ssc_ManPrintStats ( Ssc_Man_t p)

Definition at line 132 of file sscCore.c.

133 {
134  Abc_Print( 1, "Parameters: SimWords = %d. SatConfs = %d. SatVarMax = %d. CallsRec = %d. Verbose = %d.\n",
135  p->pPars->nWords, p->pPars->nBTLimit, p->pPars->nSatVarMax, p->pPars->nCallsRecycle, p->pPars->fVerbose );
136  Abc_Print( 1, "SAT calls : Total = %d. Proof = %d. Cex = %d. Undec = %d.\n",
137  p->nSatCalls, p->nSatCallsUnsat, p->nSatCallsSat, p->nSatCallsUndec );
138  Abc_Print( 1, "SAT solver: Vars = %d. Clauses = %d. Recycles = %d. Sim rounds = %d.\n",
139  sat_solver_nvars(p->pSat), sat_solver_nclauses(p->pSat), p->nRecycles, p->nSimRounds );
140 
141  p->timeOther = p->timeTotal - p->timeSimInit - p->timeSimSat - p->timeCnfGen - p->timeSatSat - p->timeSatUnsat - p->timeSatUndec;
142  ABC_PRTP( "Initialization ", p->timeSimInit, p->timeTotal );
143  ABC_PRTP( "SAT simulation ", p->timeSimSat, p->timeTotal );
144  ABC_PRTP( "CNF generation ", p->timeSimSat, p->timeTotal );
145  ABC_PRTP( "SAT solving ", p->timeSat-p->timeCnfGen, p->timeTotal );
146  ABC_PRTP( " unsat ", p->timeSatUnsat, p->timeTotal );
147  ABC_PRTP( " sat ", p->timeSatSat, p->timeTotal );
148  ABC_PRTP( " undecided ", p->timeSatUndec, p->timeTotal );
149  ABC_PRTP( "Other ", p->timeOther, p->timeTotal );
150  ABC_PRTP( "TOTAL ", p->timeTotal, p->timeTotal );
151 }
static Llb_Mgr_t * p
Definition: llb3Image.c:950
#define ABC_PRTP(a, t, T)
Definition: abc_global.h:223
int sat_solver_nvars(sat_solver *s)
Definition: satSolver.c:1896
static void Abc_Print(int level, const char *format,...)
Definition: abc_global.h:313
int sat_solver_nclauses(sat_solver *s)
Definition: satSolver.c:1902
ABC_NAMESPACE_IMPL_START void Ssc_ManSetDefaultParams ( Ssc_Pars_t p)

DECLARATIONS ///.

MACRO DEFINITIONS ///.

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

FileName [sscCore.c]

SystemName [ABC: Logic synthesis and verification system.]

PackageName [SAT sweeping under constraints.]

Synopsis [The core procedures.]

Author [Alan Mishchenko]

Affiliation [UC Berkeley]

Date [Ver. 1.0. Started - June 29, 2008.]

Revision [

Id:
sscCore.c,v 1.00 2008/07/29 00:00:00 alanmi Exp

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

Synopsis [This procedure sets default parameters.]

Description []

SideEffects []

SeeAlso []

Definition at line 46 of file sscCore.c.

47 {
48  memset( p, 0, sizeof(Ssc_Pars_t) );
49  p->nWords = 1; // the number of simulation words
50  p->nBTLimit = 1000; // conflict limit at a node
51  p->nSatVarMax = 5000; // the max number of SAT variables
52  p->nCallsRecycle = 100; // calls to perform before recycling SAT solver
53  p->fVerbose = 0; // verbose stats
54 }
char * memset()
static Llb_Mgr_t * p
Definition: llb3Image.c:950
typedefABC_NAMESPACE_HEADER_START struct Ssc_Pars_t_ Ssc_Pars_t
INCLUDES ///.
Definition: ssc.h:43
Ssc_Man_t* Ssc_ManStart ( Gia_Man_t pAig,
Gia_Man_t pCare,
Ssc_Pars_t pPars 
)

Definition at line 80 of file sscCore.c.

81 {
82  Ssc_Man_t * p;
83  p = ABC_CALLOC( Ssc_Man_t, 1 );
84  p->pPars = pPars;
85  p->pAig = pAig;
86  p->pCare = pCare;
87  p->pFraig = Gia_ManDupDfs( p->pCare );
88  assert( p->pFraig->pHTable == NULL );
89  assert( !Gia_ManHasDangling(p->pFraig) );
90  Gia_ManInvertPos( p->pFraig );
91  Ssc_ManStartSolver( p );
92  if ( p->pSat == NULL )
93  {
94  printf( "Constraints are UNSAT after propagation.\n" );
95  Ssc_ManStop( p );
96  return (Ssc_Man_t *)(ABC_PTRINT_T)1;
97  }
98 // p->vPivot = Ssc_GiaFindPivotSim( p->pFraig );
99 // Vec_IntFreeP( &p->vPivot );
100  p->vPivot = Ssc_ManFindPivotSat( p );
101  if ( p->vPivot == (Vec_Int_t *)(ABC_PTRINT_T)1 )
102  {
103  printf( "Constraints are UNSAT.\n" );
104  Ssc_ManStop( p );
105  return (Ssc_Man_t *)(ABC_PTRINT_T)1;
106  }
107  if ( p->vPivot == NULL )
108  {
109  printf( "Conflict limit is reached while trying to find one SAT assignment.\n" );
110  Ssc_ManStop( p );
111  return NULL;
112  }
113  sat_solver_bookmark( p->pSat );
114 // Vec_IntPrint( p->vPivot );
115  Gia_ManSetPhasePattern( p->pAig, p->vPivot );
116  Gia_ManSetPhasePattern( p->pCare, p->vPivot );
117  if ( Gia_ManCheckCoPhase(p->pCare) )
118  {
119  printf( "Computed reference pattern violates %d constraints (this is a bug!).\n", Gia_ManCheckCoPhase(p->pCare) );
120  Ssc_ManStop( p );
121  return NULL;
122  }
123  // other things
124  p->vDisPairs = Vec_IntAlloc( 100 );
125  p->vPattern = Vec_IntAlloc( 100 );
126  p->vFanins = Vec_IntAlloc( 100 );
127  p->vFront = Vec_IntAlloc( 100 );
128  Ssc_GiaClassesInit( pAig );
129  // now it is ready for refinement using simulation
130  return p;
131 }
static Llb_Mgr_t * p
Definition: llb3Image.c:950
typedefABC_NAMESPACE_IMPL_START struct Vec_Int_t_ Vec_Int_t
DECLARATIONS ///.
Definition: bblif.c:37
static void sat_solver_bookmark(sat_solver *s)
Definition: satSolver.h:247
typedefABC_NAMESPACE_HEADER_START struct Ssc_Man_t_ Ssc_Man_t
INCLUDES ///.
Definition: sscInt.h:46
void Gia_ManInvertPos(Gia_Man_t *pAig)
Definition: giaUtil.c:1425
int Gia_ManHasDangling(Gia_Man_t *p)
Definition: giaUtil.c:1155
void Ssc_GiaClassesInit(Gia_Man_t *p)
FUNCTION DECLARATIONS ///.
Definition: sscClass.c:265
static Vec_Int_t * Vec_IntAlloc(int nCap)
FUNCTION DEFINITIONS ///.
Definition: bblif.c:149
void Ssc_ManStartSolver(Ssc_Man_t *p)
Definition: sscSat.c:261
Vec_Int_t * Ssc_ManFindPivotSat(Ssc_Man_t *p)
Definition: sscSat.c:323
Gia_Man_t * Gia_ManDupDfs(Gia_Man_t *p)
Definition: giaDup.c:1238
int Gia_ManCheckCoPhase(Gia_Man_t *p)
Definition: giaUtil.c:450
#define ABC_CALLOC(type, num)
Definition: abc_global.h:230
#define assert(ex)
Definition: util_old.h:213
void Ssc_ManStop(Ssc_Man_t *p)
Definition: sscCore.c:67
void Gia_ManSetPhasePattern(Gia_Man_t *p, Vec_Int_t *vCiValues)
Definition: giaUtil.c:386
void Ssc_ManStop ( Ssc_Man_t p)

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 67 of file sscCore.c.

68 {
69  Vec_IntFreeP( &p->vFront );
70  Vec_IntFreeP( &p->vFanins );
71  Vec_IntFreeP( &p->vPattern );
72  Vec_IntFreeP( &p->vDisPairs );
73  Vec_IntFreeP( &p->vPivot );
74  Vec_IntFreeP( &p->vId2Var );
75  Vec_IntFreeP( &p->vVar2Id );
76  if ( p->pSat ) sat_solver_delete( p->pSat );
77  Gia_ManStopP( &p->pFraig );
78  ABC_FREE( p );
79 }
static Llb_Mgr_t * p
Definition: llb3Image.c:950
void sat_solver_delete(sat_solver *s)
Definition: satSolver.c:1141
void Gia_ManStopP(Gia_Man_t **p)
Definition: giaMan.c:177
static void Vec_IntFreeP(Vec_Int_t **p)
Definition: vecInt.h:289
#define ABC_FREE(obj)
Definition: abc_global.h:232
Gia_Man_t* Ssc_PerformSweeping ( Gia_Man_t pAig,
Gia_Man_t pCare,
Ssc_Pars_t pPars 
)

Definition at line 413 of file sscCore.c.

414 {
415  Gia_Man_t * pResult = Ssc_PerformSweepingInt( pAig, pCare, pPars );
416  if ( pPars->fVerify )
417  Ssc_PerformVerification( pAig, pResult, pCare );
418  return pResult;
419 }
Gia_Man_t * Ssc_PerformSweepingInt(Gia_Man_t *pAig, Gia_Man_t *pCare, Ssc_Pars_t *pPars)
Definition: sscCore.c:264
int Ssc_PerformVerification(Gia_Man_t *p0, Gia_Man_t *p1, Gia_Man_t *pC)
Definition: sscCore.c:223
Definition: gia.h:95
Gia_Man_t* Ssc_PerformSweepingConstr ( Gia_Man_t p,
Ssc_Pars_t pPars 
)

Definition at line 420 of file sscCore.c.

421 {
422  Gia_Man_t * pAig, * pCare, * pResult;
423  int i;
424  if ( pPars->fVerbose )
425  Abc_Print( 0, "SAT sweeping AIG with %d constraints.\n", p->nConstrs );
426  if ( p->nConstrs == 0 )
427  {
428  pAig = Gia_ManDup( p );
429  pCare = Gia_ManStart( Gia_ManCiNum(p) + 2 );
430  pCare->pName = Abc_UtilStrsav( "care" );
431  for ( i = 0; i < Gia_ManCiNum(p); i++ )
432  Gia_ManAppendCi( pCare );
433  Gia_ManAppendCo( pCare, 0 );
434  }
435  else
436  {
438  pAig = Gia_ManDupCones( p, Vec_IntArray(vOuts), Gia_ManPoNum(p) - p->nConstrs, 0 );
439  pCare = Gia_ManDupCones( p, Vec_IntArray(vOuts) + Gia_ManPoNum(p) - p->nConstrs, p->nConstrs, 0 );
440  Vec_IntFree( vOuts );
441  }
442  if ( pPars->fVerbose )
443  {
444  printf( "User AIG: " );
445  Gia_ManPrintStats( pAig, NULL );
446  printf( "Care AIG: " );
447  Gia_ManPrintStats( pCare, NULL );
448  }
449 
450  pAig = Gia_ManDupLevelized( pResult = pAig );
451  Gia_ManStop( pResult );
452  pResult = Ssc_PerformSweeping( pAig, pCare, pPars );
453  if ( pPars->fAppend )
454  {
455  Gia_ManDupAppendShare( pResult, pCare );
456  pResult->nConstrs = Gia_ManPoNum(pCare);
457  }
458  Gia_ManStop( pAig );
459  Gia_ManStop( pCare );
460  return pResult;
461 }
static int * Vec_IntArray(Vec_Int_t *p)
Definition: vecInt.h:328
Gia_Man_t * Gia_ManDupCones(Gia_Man_t *p, int *pPos, int nPos, int fTrimPis)
Definition: giaDup.c:2691
Gia_Man_t * Gia_ManDup(Gia_Man_t *p)
Definition: giaDup.c:552
void Gia_ManStop(Gia_Man_t *p)
Definition: giaMan.c:77
void Gia_ManPrintStats(Gia_Man_t *p, Gps_Par_t *pPars)
Definition: giaMan.c:389
static int Gia_ManPoNum(Gia_Man_t *p)
Definition: gia.h:386
static int Gia_ManAppendCo(Gia_Man_t *p, int iLit0)
Definition: gia.h:703
typedefABC_NAMESPACE_IMPL_START struct Vec_Int_t_ Vec_Int_t
DECLARATIONS ///.
Definition: bblif.c:37
static int Gia_ManAppendCi(Gia_Man_t *p)
Definition: gia.h:583
static Vec_Int_t * Vec_IntStartNatural(int nSize)
Definition: bblif.c:192
int nConstrs
Definition: gia.h:117
char * pName
Definition: gia.h:97
Gia_Man_t * Ssc_PerformSweeping(Gia_Man_t *pAig, Gia_Man_t *pCare, Ssc_Pars_t *pPars)
Definition: sscCore.c:413
Gia_Man_t * Gia_ManStart(int nObjsMax)
DECLARATIONS ///.
Definition: giaMan.c:52
static void Abc_Print(int level, const char *format,...)
Definition: abc_global.h:313
void Gia_ManDupAppendShare(Gia_Man_t *p, Gia_Man_t *pTwo)
Definition: giaDup.c:765
static int Gia_ManCiNum(Gia_Man_t *p)
Definition: gia.h:383
Definition: gia.h:95
Gia_Man_t * Gia_ManDupLevelized(Gia_Man_t *p)
Definition: giaDup.c:2812
static void Vec_IntFree(Vec_Int_t *p)
Definition: bblif.c:235
char * Abc_UtilStrsav(char *s)
Definition: starter.c:47
Gia_Man_t* Ssc_PerformSweepingInt ( Gia_Man_t pAig,
Gia_Man_t pCare,
Ssc_Pars_t pPars 
)

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 264 of file sscCore.c.

265 {
266  Ssc_Man_t * p;
267  Gia_Man_t * pResult, * pTemp;
268  Gia_Obj_t * pObj, * pRepr;
269  abctime clk, clkTotal = Abc_Clock();
270  int i, fCompl, nRefined, status;
271 clk = Abc_Clock();
272  assert( Gia_ManRegNum(pCare) == 0 );
273  assert( Gia_ManCiNum(pAig) == Gia_ManCiNum(pCare) );
274  assert( Gia_ManIsNormalized(pAig) );
275  assert( Gia_ManIsNormalized(pCare) );
276  // reset random numbers
277  Gia_ManRandom( 1 );
278  // sweeping manager
279  p = Ssc_ManStart( pAig, pCare, pPars );
280  if ( p == (Ssc_Man_t *)(ABC_PTRINT_T)1 ) // UNSAT
281  return Gia_ManDupZero( pAig );
282  if ( p == NULL ) // timeout
283  return Gia_ManDup( pAig );
284  if ( p->pPars->fVerbose )
285  printf( "Care set produced %d hits out of %d.\n", Ssc_GiaEstimateCare(p->pFraig, 5), 640 );
286  // perform simulation
287  while ( 1 )
288  {
289  // simulate care set
290  Ssc_GiaRandomPiPattern( p->pFraig, 5, NULL );
291  Ssc_GiaSimRound( p->pFraig );
292  // transfer care patterns to user's AIG
293  if ( !Ssc_GiaTransferPiPattern( pAig, p->pFraig, p->vPivot ) )
294  break;
295  // simulate the main AIG
296  Ssc_GiaSimRound( pAig );
297  nRefined = Ssc_GiaClassesRefine( pAig );
298  if ( pPars->fVerbose )
299  Gia_ManEquivPrintClasses( pAig, 0, 0 );
300  if ( nRefined <= Gia_ManCandNum(pAig) / 100 )
301  break;
302  }
303 p->timeSimInit += Abc_Clock() - clk;
304 
305  // prepare user's AIG
306  Gia_ManFillValue(pAig);
307  Gia_ManConst0(pAig)->Value = 0;
308  Gia_ManForEachCi( pAig, pObj, i )
309  pObj->Value = Gia_Obj2Lit( p->pFraig, Gia_ManCi(p->pFraig, i) );
310 // Gia_ManLevelNum(pAig);
311  // prepare swept AIG (should be done after starting SAT solver in Ssc_ManStart)
312  Gia_ManHashStart( p->pFraig );
313  // perform sweeping
314  Ssc_GiaResetPiPattern( pAig, pPars->nWords );
315  Ssc_GiaSavePiPattern( pAig, p->vPivot );
316  Gia_ManForEachCand( pAig, pObj, i )
317  {
318  if ( pAig->iPatsPi == 64 * pPars->nWords )
319  {
320 clk = Abc_Clock();
321  Ssc_GiaSimRound( pAig );
322  Ssc_GiaClassesRefine( pAig );
323  if ( pPars->fVerbose )
324  Gia_ManEquivPrintClasses( pAig, 0, 0 );
325  Ssc_GiaClassesCheckPairs( pAig, p->vDisPairs );
326  Vec_IntClear( p->vDisPairs );
327  // prepare next patterns
328  Ssc_GiaResetPiPattern( pAig, pPars->nWords );
329  Ssc_GiaSavePiPattern( pAig, p->vPivot );
330 p->timeSimSat += Abc_Clock() - clk;
331 //printf( "\n" );
332  }
333  if ( Gia_ObjIsAnd(pObj) )
334  pObj->Value = Gia_ManHashAnd( p->pFraig, Gia_ObjFanin0Copy(pObj), Gia_ObjFanin1Copy(pObj) );
335  if ( !Gia_ObjHasRepr(pAig, i) )
336  continue;
337  pRepr = Gia_ObjReprObj(pAig, i);
338  if ( (int)pObj->Value == Abc_LitNotCond( pRepr->Value, pRepr->fPhase ^ pObj->fPhase ) )
339  {
340  Gia_ObjSetProved( pAig, i );
341  continue;
342  }
343  assert( Abc_Lit2Var(pRepr->Value) != Abc_Lit2Var(pObj->Value) );
344  fCompl = pRepr->fPhase ^ pObj->fPhase ^ Abc_LitIsCompl(pRepr->Value) ^ Abc_LitIsCompl(pObj->Value);
345 
346  // perform SAT call
347 clk = Abc_Clock();
348  p->nSatCalls++;
349  status = Ssc_ManCheckEquivalence( p, Abc_Lit2Var(pRepr->Value), Abc_Lit2Var(pObj->Value), fCompl );
350  if ( status == l_False )
351  {
352  p->nSatCallsUnsat++;
353  pObj->Value = Abc_LitNotCond( pRepr->Value, pRepr->fPhase ^ pObj->fPhase );
354  Gia_ObjSetProved( pAig, i );
355  }
356  else if ( status == l_True )
357  {
358  p->nSatCallsSat++;
359  Ssc_GiaSavePiPattern( pAig, p->vPattern );
360  Vec_IntPush( p->vDisPairs, Gia_ObjRepr(p->pAig, i) );
361  Vec_IntPush( p->vDisPairs, i );
362 // printf( "Try %2d and %2d: ", Gia_ObjRepr(p->pAig, i), i );
363 // Vec_IntPrint( p->vPattern );
364  if ( Gia_ObjRepr(p->pAig, i) > 0 )
365  Ssc_GiaResimulateOneClass( p, Gia_ObjRepr(p->pAig, i), i );
366  }
367  else if ( status == l_Undef )
368  p->nSatCallsUndec++;
369  else assert( 0 );
370 p->timeSat += Abc_Clock() - clk;
371  }
372  if ( pAig->iPatsPi > 1 )
373  {
374 clk = Abc_Clock();
375  while ( pAig->iPatsPi < 64 * pPars->nWords )
376  Ssc_GiaSavePiPattern( pAig, p->vPivot );
377  Ssc_GiaSimRound( pAig );
378  Ssc_GiaClassesRefine( pAig );
379  if ( pPars->fVerbose )
380  Gia_ManEquivPrintClasses( pAig, 0, 0 );
381  Ssc_GiaClassesCheckPairs( pAig, p->vDisPairs );
382  Vec_IntClear( p->vDisPairs );
383 p->timeSimSat += Abc_Clock() - clk;
384  }
385 // Gia_ManEquivPrintClasses( pAig, 1, 0 );
386 // Gia_ManPrint( pAig );
387 
388  // generate the resulting AIG
389  pResult = Gia_ManEquivReduce( pAig, 0, 0, 1, 0 );
390  if ( pResult == NULL )
391  {
392  printf( "There is no equivalences.\n" );
393  ABC_FREE( pAig->pReprs );
394  ABC_FREE( pAig->pNexts );
395  pResult = Gia_ManDup( pAig );
396  }
397  pResult = Gia_ManCleanup( pTemp = pResult );
398  Gia_ManStop( pTemp );
399  p->timeTotal = Abc_Clock() - clkTotal;
400  if ( pPars->fVerbose )
401  Ssc_ManPrintStats( p );
402  Ssc_ManStop( p );
403  // count the number of representatives
404  if ( pPars->fVerbose )
405  {
406  Abc_Print( 1, "Reduction in AIG nodes:%8d ->%8d (%6.2f %%). ",
407  Gia_ManAndNum(pAig), Gia_ManAndNum(pResult),
408  100.0 - 100.0 * Gia_ManAndNum(pResult) / Gia_ManAndNum(pAig) );
409  Abc_PrintTime( 1, "Time", Abc_Clock() - clkTotal );
410  }
411  return pResult;
412 }
Gia_Man_t * Gia_ManDup(Gia_Man_t *p)
Definition: giaDup.c:552
void Gia_ManStop(Gia_Man_t *p)
Definition: giaMan.c:77
static Gia_Obj_t * Gia_ManCi(Gia_Man_t *p, int v)
Definition: gia.h:403
static Llb_Mgr_t * p
Definition: llb3Image.c:950
void Ssc_GiaResetPiPattern(Gia_Man_t *p, int nWords)
Definition: sscSim.c:141
Ssc_Man_t * Ssc_ManStart(Gia_Man_t *pAig, Gia_Man_t *pCare, Ssc_Pars_t *pPars)
Definition: sscCore.c:80
#define l_Undef
Definition: SolverTypes.h:86
typedefABC_NAMESPACE_HEADER_START struct Ssc_Man_t_ Ssc_Man_t
INCLUDES ///.
Definition: sscInt.h:46
void Ssc_ManPrintStats(Ssc_Man_t *p)
Definition: sscCore.c:132
#define l_True
Definition: SolverTypes.h:84
Gia_Man_t * Gia_ManDupZero(Gia_Man_t *p)
Definition: giaDup.c:608
static abctime Abc_Clock()
Definition: abc_global.h:279
int nWords
Definition: abcNpn.c:127
static int Abc_LitNotCond(int Lit, int c)
Definition: abc_global.h:267
Definition: gia.h:75
void Gia_ManEquivPrintClasses(Gia_Man_t *p, int fVerbose, float Mem)
Definition: giaEquiv.c:304
unsigned Gia_ManRandom(int fReset)
FUNCTION DEFINITIONS ///.
Definition: giaUtil.c:49
#define Gia_ManForEachCi(p, pObj, i)
Definition: gia.h:1016
Gia_Man_t * Gia_ManEquivReduce(Gia_Man_t *p, int fUseAll, int fDualOut, int fSkipPhase, int fVerbose)
Definition: giaEquiv.c:417
static void Abc_PrintTime(int level, const char *pStr, abctime time)
Definition: abc_global.h:367
void Ssc_GiaSavePiPattern(Gia_Man_t *p, Vec_Int_t *vPat)
Definition: sscSim.c:149
int Ssc_GiaClassesRefine(Gia_Man_t *p)
Definition: sscClass.c:279
static int Gia_ManAndNum(Gia_Man_t *p)
Definition: gia.h:389
static int Abc_LitIsCompl(int Lit)
Definition: abc_global.h:265
int Ssc_GiaTransferPiPattern(Gia_Man_t *pAig, Gia_Man_t *pCare, Vec_Int_t *vPivot)
Definition: sscSim.c:201
static void Gia_ObjSetProved(Gia_Man_t *p, int Id)
Definition: gia.h:897
static int Gia_ObjFanin1Copy(Gia_Obj_t *pObj)
Definition: gia.h:482
int Ssc_GiaResimulateOneClass(Ssc_Man_t *p, int iRepr, int iObj)
Definition: sscCore.c:196
void Gia_ManHashStart(Gia_Man_t *p)
Definition: giaHash.c:117
static void Vec_IntPush(Vec_Int_t *p, int Entry)
Definition: bblif.c:468
void Gia_ManFillValue(Gia_Man_t *p)
Definition: giaUtil.c:328
static int Gia_ManCandNum(Gia_Man_t *p)
Definition: gia.h:394
static void Abc_Print(int level, const char *format,...)
Definition: abc_global.h:313
static int Gia_ObjFanin0Copy(Gia_Obj_t *pObj)
Definition: gia.h:481
#define Gia_ManForEachCand(p, pObj, i)
Definition: gia.h:1008
static Gia_Obj_t * Gia_ObjReprObj(Gia_Man_t *p, int Id)
Definition: gia.h:886
static int Gia_ManCiNum(Gia_Man_t *p)
Definition: gia.h:383
unsigned fPhase
Definition: gia.h:85
int Ssc_GiaEstimateCare(Gia_Man_t *p, int nWords)
Definition: sscSim.c:351
#define ABC_FREE(obj)
Definition: abc_global.h:232
Definition: gia.h:95
int Gia_ManIsNormalized(Gia_Man_t *p)
Definition: giaTim.c:109
static int Gia_ObjIsAnd(Gia_Obj_t *pObj)
Definition: gia.h:422
static Gia_Obj_t * Gia_ManConst0(Gia_Man_t *p)
Definition: gia.h:400
static int Abc_Lit2Var(int Lit)
Definition: abc_global.h:264
#define l_False
Definition: SolverTypes.h:85
int Ssc_ManCheckEquivalence(Ssc_Man_t *p, int iRepr, int iObj, int fCompl)
Definition: sscSat.c:348
void Ssc_GiaRandomPiPattern(Gia_Man_t *p, int nWords, Vec_Int_t *vPivot)
Definition: sscSim.c:163
void Ssc_GiaSimRound(Gia_Man_t *p)
Definition: sscSim.c:247
#define assert(ex)
Definition: util_old.h:213
unsigned Value
Definition: gia.h:87
void Ssc_ManStop(Ssc_Man_t *p)
Definition: sscCore.c:67
static void Vec_IntClear(Vec_Int_t *p)
Definition: bblif.c:452
ABC_INT64_T abctime
Definition: abc_global.h:278
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:572
static int Gia_Obj2Lit(Gia_Man_t *p, Gia_Obj_t *pObj)
Definition: gia.h:433
static int Gia_ObjRepr(Gia_Man_t *p, int Id)
Definition: gia.h:887
void Ssc_GiaClassesCheckPairs(Gia_Man_t *p, Vec_Int_t *vDisPairs)
Definition: sscClass.c:309
static int Gia_ObjHasRepr(Gia_Man_t *p, int Id)
Definition: gia.h:891
static int Gia_ManRegNum(Gia_Man_t *p)
Definition: gia.h:387
int Ssc_PerformVerification ( Gia_Man_t p0,
Gia_Man_t p1,
Gia_Man_t pC 
)

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

Synopsis [Perform verification of conditional sweeping.]

Description []

SideEffects []

SeeAlso []

Definition at line 223 of file sscCore.c.

224 {
225  int Status;
226  Cec_ParCec_t ParsCec, * pPars = &ParsCec;
227  // derive the OR of constraint outputs
228  Gia_Man_t * pCond = Gia_ManDupAndOr( pC, Gia_ManPoNum(p0), 1, 0 );
229  // derive F = F & !OR(c0, c1, c2, ...)
230  Gia_Man_t * p0c = Gia_ManMiter( p0, pCond, 0, 0, 0, 1, 0 );
231  // derive F = F & !OR(c0, c1, c2, ...)
232  Gia_Man_t * p1c = Gia_ManMiter( p1, pCond, 0, 0, 0, 1, 0 );
233  // derive dual-output miter
234  Gia_Man_t * pMiter = Gia_ManMiter( p0c, p1c, 0, 1, 0, 0, 0 );
235  Gia_ManStop( p0c );
236  Gia_ManStop( p1c );
237  Gia_ManStop( pCond );
238  // run equivalence checking
240  Status = Cec_ManVerify( pMiter, pPars );
241  Gia_ManStop( pMiter );
242  // report the results
243  if ( Status == 1 )
244  printf( "Verification succeeded.\n" );
245  else if ( Status == 0 )
246  printf( "Verification failed.\n" );
247  else if ( Status == -1 )
248  printf( "Verification undecided.\n" );
249  else assert( 0 );
250  return Status;
251 }
void Gia_ManStop(Gia_Man_t *p)
Definition: giaMan.c:77
static int Gia_ManPoNum(Gia_Man_t *p)
Definition: gia.h:386
Gia_Man_t * Gia_ManDupAndOr(Gia_Man_t *p, int nOuts, int fUseOr, int fCompl)
Definition: giaDup.c:2275
void Cec_ManCecSetDefaultParams(Cec_ParCec_t *p)
Definition: cecCore.c:157
Definition: gia.h:95
int Cec_ManVerify(Gia_Man_t *p, Cec_ParCec_t *pPars)
MACRO DEFINITIONS ///.
Definition: cecCec.c:308
#define assert(ex)
Definition: util_old.h:213
Gia_Man_t * Gia_ManMiter(Gia_Man_t *pAig0, Gia_Man_t *pAig1, int nInsDup, int fDualOut, int fSeq, int fImplic, int fVerbose)
Definition: giaDup.c:2128