abc-master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
dchSimSat.c File Reference
#include "dchInt.h"

Go to the source code of this file.

Functions

ABC_NAMESPACE_IMPL_START void Dch_ManCollectTfoCands_rec (Dch_Man_t *p, Aig_Obj_t *pObj)
 DECLARATIONS ///. More...
 
void Dch_ManCollectTfoCands (Dch_Man_t *p, Aig_Obj_t *pObj1, Aig_Obj_t *pObj2)
 
void Dch_ManResimulateSolved_rec (Dch_Man_t *p, Aig_Obj_t *pObj)
 
void Dch_ManResimulateOther_rec (Dch_Man_t *p, Aig_Obj_t *pObj)
 
void Dch_ManResimulateCex (Dch_Man_t *p, Aig_Obj_t *pObj, Aig_Obj_t *pRepr)
 
void Dch_ManResimulateCex2 (Dch_Man_t *p, Aig_Obj_t *pObj, Aig_Obj_t *pRepr)
 

Function Documentation

void Dch_ManCollectTfoCands ( Dch_Man_t p,
Aig_Obj_t pObj1,
Aig_Obj_t pObj2 
)

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

Synopsis [Collect equivalence classes and const1 cands in the TFO.]

Description []

SideEffects []

SeeAlso []

Definition at line 84 of file dchSimSat.c.

85 {
86  Aig_Obj_t * pObj;
87  int i;
88  Vec_PtrClear( p->vSimRoots );
92  Dch_ManCollectTfoCands_rec( p, pObj1 );
93  Dch_ManCollectTfoCands_rec( p, pObj2 );
94  Vec_PtrSort( p->vSimRoots, (int (*)(void))Aig_ObjCompareIdIncrease );
95  Vec_PtrSort( p->vSimClasses, (int (*)(void))Aig_ObjCompareIdIncrease );
96  Vec_PtrForEachEntry( Aig_Obj_t *, p->vSimClasses, pObj, i )
97  pObj->fMarkA = 0;
98 }
int Aig_ObjCompareIdIncrease(Aig_Obj_t **pp1, Aig_Obj_t **pp2)
Definition: aigUtil.c:496
static void Vec_PtrSort(Vec_Ptr_t *p, int(*Vec_PtrSortCompare)()) ___unused
Definition: vecPtr.h:851
ABC_NAMESPACE_IMPL_START void Dch_ManCollectTfoCands_rec(Dch_Man_t *p, Aig_Obj_t *pObj)
DECLARATIONS ///.
Definition: dchSimSat.c:45
Vec_Ptr_t * vSimRoots
Definition: dchInt.h:70
static void Aig_ObjSetTravIdCurrent(Aig_Man_t *p, Aig_Obj_t *pObj)
Definition: aig.h:293
void Aig_ManIncrementTravId(Aig_Man_t *p)
DECLARATIONS ///.
Definition: aigUtil.c:44
Vec_Ptr_t * vSimClasses
Definition: dchInt.h:71
Definition: aig.h:69
static Aig_Obj_t * Aig_ManConst1(Aig_Man_t *p)
Definition: aig.h:264
Aig_Man_t * pAigTotal
Definition: dchInt.h:57
static void Vec_PtrClear(Vec_Ptr_t *p)
Definition: vecPtr.h:545
#define Vec_PtrForEachEntry(Type, vVec, pEntry, i)
MACRO DEFINITIONS ///.
Definition: vecPtr.h:55
ABC_NAMESPACE_IMPL_START void Dch_ManCollectTfoCands_rec ( Dch_Man_t p,
Aig_Obj_t pObj 
)

DECLARATIONS ///.

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

FileName [dchSimSat.c]

SystemName [ABC: Logic synthesis and verification system.]

PackageName [Choice computation for tech-mapping.]

Synopsis [Performs resimulation using counter-examples.]

Author [Alan Mishchenko]

Affiliation [UC Berkeley]

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

Revision [

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

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

Synopsis [Collects internal nodes in the reverse DFS order.]

Description []

SideEffects []

SeeAlso []

Definition at line 45 of file dchSimSat.c.

46 {
47  Aig_Obj_t * pFanout, * pRepr;
48  int iFanout = -1, i;
49  assert( !Aig_IsComplement(pObj) );
50  if ( Aig_ObjIsTravIdCurrent(p->pAigTotal, pObj) )
51  return;
53  // traverse the fanouts
54  Aig_ObjForEachFanout( p->pAigTotal, pObj, pFanout, iFanout, i )
55  Dch_ManCollectTfoCands_rec( p, pFanout );
56  // check if the given node has a representative
57  pRepr = Aig_ObjRepr( p->pAigTotal, pObj );
58  if ( pRepr == NULL )
59  return;
60  // pRepr is the constant 1 node
61  if ( pRepr == Aig_ManConst1(p->pAigTotal) )
62  {
63  Vec_PtrPush( p->vSimRoots, pObj );
64  return;
65  }
66  // pRepr is the representative of an equivalence class
67  if ( pRepr->fMarkA )
68  return;
69  pRepr->fMarkA = 1;
70  Vec_PtrPush( p->vSimClasses, pRepr );
71 }
#define Aig_ObjForEachFanout(p, pObj, pFanout, iFan, i)
Definition: aig.h:427
static Aig_Obj_t * Aig_ObjRepr(Aig_Man_t *p, Aig_Obj_t *pObj)
Definition: aig.h:330
static int Aig_ObjIsTravIdCurrent(Aig_Man_t *p, Aig_Obj_t *pObj)
Definition: aig.h:295
static int Aig_IsComplement(Aig_Obj_t *p)
Definition: aig.h:249
ABC_NAMESPACE_IMPL_START void Dch_ManCollectTfoCands_rec(Dch_Man_t *p, Aig_Obj_t *pObj)
DECLARATIONS ///.
Definition: dchSimSat.c:45
static void Vec_PtrPush(Vec_Ptr_t *p, void *Entry)
Definition: vecPtr.h:606
unsigned int fMarkA
Definition: aig.h:79
static void Aig_ObjSetTravIdCurrent(Aig_Man_t *p, Aig_Obj_t *pObj)
Definition: aig.h:293
Vec_Ptr_t * vSimClasses
Definition: dchInt.h:71
if(last==0)
Definition: sparse_int.h:34
Definition: aig.h:69
static Aig_Obj_t * Aig_ManConst1(Aig_Man_t *p)
Definition: aig.h:264
Aig_Man_t * pAigTotal
Definition: dchInt.h:57
#define assert(ex)
Definition: util_old.h:213
void Dch_ManResimulateCex ( Dch_Man_t p,
Aig_Obj_t pObj,
Aig_Obj_t pRepr 
)

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

Synopsis [Handle the counter-example.]

Description []

SideEffects []

SeeAlso []

Definition at line 177 of file dchSimSat.c.

178 {
179  Aig_Obj_t * pRoot, ** ppClass;
180  int i, k, nSize, RetValue1, RetValue2;
181  abctime clk = Abc_Clock();
182  // get the equivalence classes
183  Dch_ManCollectTfoCands( p, pObj, pRepr );
184  // resimulate the cone of influence of the solved nodes
185  p->nConeThis = 0;
188  Dch_ManResimulateSolved_rec( p, pObj );
189  Dch_ManResimulateSolved_rec( p, pRepr );
190  p->nConeMax = Abc_MaxInt( p->nConeMax, p->nConeThis );
191  // resimulate the cone of influence of the other nodes
192  Vec_PtrForEachEntry( Aig_Obj_t *, p->vSimRoots, pRoot, i )
193  Dch_ManResimulateOther_rec( p, pRoot );
194  // refine these nodes
195  RetValue1 = Dch_ClassesRefineConst1Group( p->ppClasses, p->vSimRoots, 0 );
196  // resimulate the cone of influence of the cand classes
197  RetValue2 = 0;
198  Vec_PtrForEachEntry( Aig_Obj_t *, p->vSimClasses, pRoot, i )
199  {
200  ppClass = Dch_ClassesReadClass( p->ppClasses, pRoot, &nSize );
201  for ( k = 0; k < nSize; k++ )
202  Dch_ManResimulateOther_rec( p, ppClass[k] );
203  // refine this class
204  RetValue2 += Dch_ClassesRefineOneClass( p->ppClasses, pRoot, 0 );
205  }
206  // make sure refinement happened
207  if ( Aig_ObjIsConst1(pRepr) )
208  assert( RetValue1 );
209  else
210  assert( RetValue2 );
211 p->timeSimSat += Abc_Clock() - clk;
212 }
void Dch_ManCollectTfoCands(Dch_Man_t *p, Aig_Obj_t *pObj1, Aig_Obj_t *pObj2)
Definition: dchSimSat.c:84
void Dch_ManResimulateSolved_rec(Dch_Man_t *p, Aig_Obj_t *pObj)
Definition: dchSimSat.c:111
Vec_Ptr_t * vSimRoots
Definition: dchInt.h:70
static abctime Abc_Clock()
Definition: abc_global.h:279
static int Abc_MaxInt(int a, int b)
Definition: abc_global.h:238
static void Aig_ObjSetTravIdCurrent(Aig_Man_t *p, Aig_Obj_t *pObj)
Definition: aig.h:293
int nConeThis
Definition: dchInt.h:73
void Aig_ManIncrementTravId(Aig_Man_t *p)
DECLARATIONS ///.
Definition: aigUtil.c:44
int Dch_ClassesRefineConst1Group(Dch_Cla_t *p, Vec_Ptr_t *vRoots, int fRecursive)
Definition: dchClass.c:570
int Dch_ClassesRefineOneClass(Dch_Cla_t *p, Aig_Obj_t *pReprOld, int fRecursive)
Definition: dchClass.c:443
int nConeMax
Definition: dchInt.h:74
void Dch_ManResimulateOther_rec(Dch_Man_t *p, Aig_Obj_t *pObj)
Definition: dchSimSat.c:149
static int Aig_ObjIsConst1(Aig_Obj_t *pObj)
Definition: aig.h:274
Definition: aig.h:69
static Aig_Obj_t * Aig_ManConst1(Aig_Man_t *p)
Definition: aig.h:264
Aig_Man_t * pAigTotal
Definition: dchInt.h:57
Aig_Obj_t ** Dch_ClassesReadClass(Dch_Cla_t *p, Aig_Obj_t *pRepr, int *pnSize)
Definition: dchClass.c:222
#define assert(ex)
Definition: util_old.h:213
#define Vec_PtrForEachEntry(Type, vVec, pEntry, i)
MACRO DEFINITIONS ///.
Definition: vecPtr.h:55
ABC_INT64_T abctime
Definition: abc_global.h:278
void Dch_ManResimulateCex2 ( Dch_Man_t p,
Aig_Obj_t pObj,
Aig_Obj_t pRepr 
)

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

Synopsis [Handle the counter-example.]

Description []

SideEffects []

SeeAlso []

Definition at line 225 of file dchSimSat.c.

226 {
227  Aig_Obj_t * pRoot;
228  int i, RetValue;
229  abctime clk = Abc_Clock();
230  // get the equivalence class
231  if ( Dch_ObjIsConst1Cand(p->pAigTotal, pObj) )
233  else
235  // resimulate the cone of influence of the solved nodes
236  p->nConeThis = 0;
239  Dch_ManResimulateSolved_rec( p, pObj );
240  Dch_ManResimulateSolved_rec( p, pRepr );
241  p->nConeMax = Abc_MaxInt( p->nConeMax, p->nConeThis );
242  // resimulate the cone of influence of the other nodes
243  Vec_PtrForEachEntry( Aig_Obj_t *, p->vSimRoots, pRoot, i )
244  Dch_ManResimulateOther_rec( p, pRoot );
245  // refine this class
246  if ( Dch_ObjIsConst1Cand(p->pAigTotal, pObj) )
247  RetValue = Dch_ClassesRefineConst1Group( p->ppClasses, p->vSimRoots, 0 );
248  else
249  RetValue = Dch_ClassesRefineOneClass( p->ppClasses, pRepr, 0 );
250  assert( RetValue );
251 p->timeSimSat += Abc_Clock() - clk;
252 }
static int Dch_ObjIsConst1Cand(Aig_Man_t *pAig, Aig_Obj_t *pObj)
Definition: dchInt.h:108
void Dch_ManResimulateSolved_rec(Dch_Man_t *p, Aig_Obj_t *pObj)
Definition: dchSimSat.c:111
Vec_Ptr_t * vSimRoots
Definition: dchInt.h:70
static abctime Abc_Clock()
Definition: abc_global.h:279
static int Abc_MaxInt(int a, int b)
Definition: abc_global.h:238
static void Aig_ObjSetTravIdCurrent(Aig_Man_t *p, Aig_Obj_t *pObj)
Definition: aig.h:293
int nConeThis
Definition: dchInt.h:73
void Aig_ManIncrementTravId(Aig_Man_t *p)
DECLARATIONS ///.
Definition: aigUtil.c:44
int Dch_ClassesRefineConst1Group(Dch_Cla_t *p, Vec_Ptr_t *vRoots, int fRecursive)
Definition: dchClass.c:570
int Dch_ClassesRefineOneClass(Dch_Cla_t *p, Aig_Obj_t *pReprOld, int fRecursive)
Definition: dchClass.c:443
void Dch_ClassesCollectConst1Group(Dch_Cla_t *p, Aig_Obj_t *pObj, int nNodes, Vec_Ptr_t *vRoots)
Definition: dchClass.c:546
int nConeMax
Definition: dchInt.h:74
Dch_Cla_t * ppClasses
Definition: dchInt.h:60
if(last==0)
Definition: sparse_int.h:34
void Dch_ManResimulateOther_rec(Dch_Man_t *p, Aig_Obj_t *pObj)
Definition: dchSimSat.c:149
else
Definition: sparse_int.h:55
Definition: aig.h:69
static Aig_Obj_t * Aig_ManConst1(Aig_Man_t *p)
Definition: aig.h:264
Aig_Man_t * pAigTotal
Definition: dchInt.h:57
#define assert(ex)
Definition: util_old.h:213
void Dch_ClassesCollectOneClass(Dch_Cla_t *p, Aig_Obj_t *pRepr, Vec_Ptr_t *vRoots)
Definition: dchClass.c:525
#define Vec_PtrForEachEntry(Type, vVec, pEntry, i)
MACRO DEFINITIONS ///.
Definition: vecPtr.h:55
ABC_INT64_T abctime
Definition: abc_global.h:278
void Dch_ManResimulateOther_rec ( Dch_Man_t p,
Aig_Obj_t pObj 
)

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

Synopsis [Resimulates the cone of influence of the other nodes.]

Description []

SideEffects []

SeeAlso []

Definition at line 149 of file dchSimSat.c.

150 {
151  if ( Aig_ObjIsTravIdCurrent(p->pAigTotal, pObj) )
152  return;
154  if ( Aig_ObjIsCi(pObj) )
155  {
156  // set random value
157  pObj->fMarkB = Aig_ManRandom(0) & 1;
158  return;
159  }
162  pObj->fMarkB = ( Aig_ObjFanin0(pObj)->fMarkB ^ Aig_ObjFaninC0(pObj) )
163  & ( Aig_ObjFanin1(pObj)->fMarkB ^ Aig_ObjFaninC1(pObj) );
164 }
static int Aig_ObjIsTravIdCurrent(Aig_Man_t *p, Aig_Obj_t *pObj)
Definition: aig.h:295
unsigned int fMarkB
Definition: aig.h:80
static Aig_Obj_t * Aig_ObjFanin0(Aig_Obj_t *pObj)
Definition: aig.h:308
unsigned Aig_ManRandom(int fReset)
Definition: aigUtil.c:1157
static Aig_Obj_t * Aig_ObjFanin1(Aig_Obj_t *pObj)
Definition: aig.h:309
static void Aig_ObjSetTravIdCurrent(Aig_Man_t *p, Aig_Obj_t *pObj)
Definition: aig.h:293
void Dch_ManResimulateOther_rec(Dch_Man_t *p, Aig_Obj_t *pObj)
Definition: dchSimSat.c:149
static int Aig_ObjFaninC0(Aig_Obj_t *pObj)
Definition: aig.h:306
static int Aig_ObjFaninC1(Aig_Obj_t *pObj)
Definition: aig.h:307
Aig_Man_t * pAigTotal
Definition: dchInt.h:57
static int Aig_ObjIsCi(Aig_Obj_t *pObj)
Definition: aig.h:275
void Dch_ManResimulateSolved_rec ( Dch_Man_t p,
Aig_Obj_t pObj 
)

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

Synopsis [Resimulates the cone of influence of the solved nodes.]

Description []

SideEffects []

SeeAlso []

Definition at line 111 of file dchSimSat.c.

112 {
113  if ( Aig_ObjIsTravIdCurrent(p->pAigTotal, pObj) )
114  return;
116  if ( Aig_ObjIsCi(pObj) )
117  {
118  Aig_Obj_t * pObjFraig;
119  int nVarNum;
120  pObjFraig = Dch_ObjFraig( pObj );
121  assert( !Aig_IsComplement(pObjFraig) );
122  nVarNum = Dch_ObjSatNum( p, pObjFraig );
123  // get the value from the SAT solver
124  // (account for the fact that some vars may be minimized away)
125  pObj->fMarkB = !nVarNum? 0 : sat_solver_var_value( p->pSat, nVarNum );
126 // pObj->fMarkB = !nVarNum? Aig_ManRandom(0) & 1 : sat_solver_var_value( p->pSat, nVarNum );
127  return;
128  }
131  pObj->fMarkB = ( Aig_ObjFanin0(pObj)->fMarkB ^ Aig_ObjFaninC0(pObj) )
132  & ( Aig_ObjFanin1(pObj)->fMarkB ^ Aig_ObjFaninC1(pObj) );
133  // count the cone size
134  if ( Dch_ObjSatNum( p, Aig_Regular(Dch_ObjFraig(pObj)) ) > 0 )
135  p->nConeThis++;
136 }
static int Aig_ObjIsTravIdCurrent(Aig_Man_t *p, Aig_Obj_t *pObj)
Definition: aig.h:295
unsigned int fMarkB
Definition: aig.h:80
static Aig_Obj_t * Aig_ObjFanin0(Aig_Obj_t *pObj)
Definition: aig.h:308
static int Aig_IsComplement(Aig_Obj_t *p)
Definition: aig.h:249
static Aig_Obj_t * Aig_Regular(Aig_Obj_t *p)
Definition: aig.h:246
void Dch_ManResimulateSolved_rec(Dch_Man_t *p, Aig_Obj_t *pObj)
Definition: dchSimSat.c:111
static Aig_Obj_t * Aig_ObjFanin1(Aig_Obj_t *pObj)
Definition: aig.h:309
static void Aig_ObjSetTravIdCurrent(Aig_Man_t *p, Aig_Obj_t *pObj)
Definition: aig.h:293
int nConeThis
Definition: dchInt.h:73
static int sat_solver_var_value(sat_solver *s, int v)
Definition: satSolver.h:200
static Aig_Obj_t * Dch_ObjFraig(Aig_Obj_t *pObj)
Definition: dchInt.h:105
Definition: aig.h:69
static int Aig_ObjFaninC0(Aig_Obj_t *pObj)
Definition: aig.h:306
sat_solver * pSat
Definition: dchInt.h:63
static int Aig_ObjFaninC1(Aig_Obj_t *pObj)
Definition: aig.h:307
Aig_Man_t * pAigTotal
Definition: dchInt.h:57
#define assert(ex)
Definition: util_old.h:213
static int Aig_ObjIsCi(Aig_Obj_t *pObj)
Definition: aig.h:275
static int Dch_ObjSatNum(Dch_Man_t *p, Aig_Obj_t *pObj)
MACRO DEFINITIONS ///.
Definition: dchInt.h:102