abc-master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
sscInt.h File Reference
#include "aig/gia/gia.h"
#include "sat/bsat/satSolver.h"
#include "ssc.h"

Go to the source code of this file.

Data Structures

struct  Ssc_Man_t_
 

Typedefs

typedef
typedefABC_NAMESPACE_HEADER_START
struct Ssc_Man_t_ 
Ssc_Man_t
 INCLUDES ///. More...
 

Functions

static int Ssc_ObjSatVar (Ssc_Man_t *p, int iObj)
 MACRO DEFINITIONS ///. More...
 
static void Ssc_ObjSetSatVar (Ssc_Man_t *p, int iObj, int Num)
 
static void Ssc_ObjCleanSatVar (Ssc_Man_t *p, int Num)
 
static int Ssc_ObjFraig (Ssc_Man_t *p, Gia_Obj_t *pObj)
 
static void Ssc_ObjSetFraig (Gia_Obj_t *pObj, int iNode)
 
void Ssc_GiaClassesInit (Gia_Man_t *p)
 FUNCTION DECLARATIONS ///. More...
 
int Ssc_GiaClassesRefine (Gia_Man_t *p)
 
void Ssc_GiaClassesCheckPairs (Gia_Man_t *p, Vec_Int_t *vDisPairs)
 
int Ssc_GiaSimClassRefineOneBit (Gia_Man_t *p, int i)
 
void Ssc_CnfNodeAddToSolver (Ssc_Man_t *p, Gia_Obj_t *pObj)
 
void Ssc_ManSatSolverRecycle (Ssc_Man_t *p)
 
void Ssc_ManStartSolver (Ssc_Man_t *p)
 
Vec_Int_tSsc_ManFindPivotSat (Ssc_Man_t *p)
 
int Ssc_ManCheckEquivalence (Ssc_Man_t *p, int iRepr, int iObj, int fCompl)
 
void Ssc_GiaResetPiPattern (Gia_Man_t *p, int nWords)
 
void Ssc_GiaRandomPiPattern (Gia_Man_t *p, int nWords, Vec_Int_t *vPivot)
 
int Ssc_GiaTransferPiPattern (Gia_Man_t *pAig, Gia_Man_t *pCare, Vec_Int_t *vPivot)
 
void Ssc_GiaSavePiPattern (Gia_Man_t *p, Vec_Int_t *vPat)
 
void Ssc_GiaSimRound (Gia_Man_t *p)
 
Vec_Int_tSsc_GiaFindPivotSim (Gia_Man_t *p)
 
int Ssc_GiaEstimateCare (Gia_Man_t *p, int nWords)
 
Gia_Man_tSsc_GenerateOneHot (int nVars)
 

Typedef Documentation

typedef typedefABC_NAMESPACE_HEADER_START struct Ssc_Man_t_ Ssc_Man_t

INCLUDES ///.

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

FileName [sscInt.h]

SystemName [ABC: Logic synthesis and verification system.]

PackageName [Choice computation for tech-mapping.]

Synopsis [Internal declarations.]

Author [Alan Mishchenko]

Affiliation [UC Berkeley]

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

Revision [

Id:
sscInt.h,v 1.00 2008/07/29 00:00:00 alanmi Exp

]PARAMETERS ///BASIC TYPES ///

Definition at line 46 of file sscInt.h.

Function Documentation

void Ssc_CnfNodeAddToSolver ( Ssc_Man_t p,
Gia_Obj_t pObj 
)
Gia_Man_t* Ssc_GenerateOneHot ( int  nVars)
void Ssc_GiaClassesCheckPairs ( Gia_Man_t p,
Vec_Int_t vDisPairs 
)

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

Synopsis [Check if the pairs have been disproved.]

Description []

SideEffects []

SeeAlso []

Definition at line 309 of file sscClass.c.

310 {
311  int i, iRepr, iObj, Result = 1;
312  Vec_IntForEachEntryDouble( vDisPairs, iRepr, iObj, i )
313  if ( iRepr == Gia_ObjRepr(p, iObj) )
314  printf( "Pair (%d, %d) are still equivalent.\n", iRepr, iObj ), Result = 0;
315 // if ( Result )
316 // printf( "Classes are refined correctly.\n" );
317 }
if(last==0)
Definition: sparse_int.h:34
#define Vec_IntForEachEntryDouble(vVec, Entry1, Entry2, i)
Definition: vecInt.h:66
static int Gia_ObjRepr(Gia_Man_t *p, int Id)
Definition: gia.h:887
void Ssc_GiaClassesInit ( Gia_Man_t p)

FUNCTION DECLARATIONS ///.

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

Synopsis [Refines equivalence classes.]

Description []

SideEffects []

SeeAlso []

Definition at line 265 of file sscClass.c.

266 {
267  Gia_Obj_t * pObj;
268  int i;
269  assert( p->pReprs == NULL );
271  p->pNexts = ABC_CALLOC( int, Gia_ManObjNum(p) );
272  Gia_ManForEachObj( p, pObj, i )
273  Gia_ObjSetRepr( p, i, Gia_ObjIsCand(pObj) ? 0 : GIA_VOID );
274  if ( p->vClassOld == NULL )
275  p->vClassOld = Vec_IntAlloc( 100 );
276  if ( p->vClassNew == NULL )
277  p->vClassNew = Vec_IntAlloc( 100 );
278 }
int * pNexts
Definition: gia.h:122
static int Gia_ObjIsCand(Gia_Obj_t *pObj)
Definition: gia.h:429
Definition: gia.h:75
static void Gia_ObjSetRepr(Gia_Man_t *p, int Id, int Num)
Definition: gia.h:888
static Vec_Int_t * Vec_IntAlloc(int nCap)
FUNCTION DEFINITIONS ///.
Definition: bblif.c:149
if(last==0)
Definition: sparse_int.h:34
#define GIA_VOID
Definition: gia.h:45
#define Gia_ManForEachObj(p, pObj, i)
MACRO DEFINITIONS ///.
Definition: gia.h:984
#define ABC_CALLOC(type, num)
Definition: abc_global.h:230
Gia_Rpr_t * pReprs
Definition: gia.h:121
#define assert(ex)
Definition: util_old.h:213
Definition: gia.h:56
static int Gia_ManObjNum(Gia_Man_t *p)
Definition: gia.h:388
int Ssc_GiaClassesRefine ( Gia_Man_t p)

Definition at line 279 of file sscClass.c.

280 {
281  Vec_Int_t * vRefinedC;
282  Gia_Obj_t * pObj;
283  int i, Counter = 0;
284  if ( p->pReprs != NULL );
285  vRefinedC = Vec_IntAlloc( 100 );
286  Gia_ManForEachCand( p, pObj, i )
287  if ( Gia_ObjIsTail(p, i) )
288  Counter += Ssc_GiaSimClassRefineOne( p, Gia_ObjRepr(p, i) );
289  else if ( Gia_ObjIsConst(p, i) && !Ssc_GiaSimIsConst0(p, i) )
290  Vec_IntPush( vRefinedC, i );
291  Ssc_GiaSimProcessRefined( p, vRefinedC );
292  Counter += Vec_IntSize( vRefinedC );
293  Vec_IntFree( vRefinedC );
294  return Counter;
295 }
typedefABC_NAMESPACE_IMPL_START struct Vec_Int_t_ Vec_Int_t
DECLARATIONS ///.
Definition: bblif.c:37
void Ssc_GiaSimProcessRefined(Gia_Man_t *p, Vec_Int_t *vRefined)
Definition: sscClass.c:221
Definition: gia.h:75
static Vec_Int_t * Vec_IntAlloc(int nCap)
FUNCTION DEFINITIONS ///.
Definition: bblif.c:149
static int Gia_ObjIsConst(Gia_Man_t *p, int Id)
Definition: gia.h:915
if(last==0)
Definition: sparse_int.h:34
else
Definition: sparse_int.h:55
static void Vec_IntPush(Vec_Int_t *p, int Entry)
Definition: bblif.c:468
static int Counter
int Ssc_GiaSimClassRefineOne(Gia_Man_t *p, int i)
Definition: sscClass.c:197
#define Gia_ManForEachCand(p, pObj, i)
Definition: gia.h:1008
static int Gia_ObjIsTail(Gia_Man_t *p, int Id)
Definition: gia.h:918
static int Vec_IntSize(Vec_Int_t *p)
Definition: bblif.c:252
Gia_Rpr_t * pReprs
Definition: gia.h:121
static void Vec_IntFree(Vec_Int_t *p)
Definition: bblif.c:235
static int Ssc_GiaSimIsConst0(Gia_Man_t *p, int iObj0)
Definition: sscClass.c:73
static int Gia_ObjRepr(Gia_Man_t *p, int Id)
Definition: gia.h:887
int Ssc_GiaEstimateCare ( Gia_Man_t p,
int  nWords 
)

Definition at line 351 of file sscSim.c.

352 {
353  Ssc_GiaRandomPiPattern( p, nWords, NULL );
354  Ssc_GiaSimRound( p );
355  return Ssc_GiaCountCaresSim( p );
356 }
int Ssc_GiaCountCaresSim(Gia_Man_t *p)
Definition: sscSim.c:343
void Ssc_GiaSimRound(Gia_Man_t *p)
Definition: sscSim.c:247
int nWords
Definition: abcNpn.c:127
void Ssc_GiaRandomPiPattern(Gia_Man_t *p, int nWords, Vec_Int_t *vPivot)
Definition: sscSim.c:163
Vec_Int_t* Ssc_GiaFindPivotSim ( Gia_Man_t p)

Definition at line 323 of file sscSim.c.

324 {
325  Vec_Int_t * vInit;
326  Ssc_GiaRandomPiPattern( p, 1, NULL );
327  Ssc_GiaSimRound( p );
328  vInit = Ssc_GiaGetOneSim( p );
329  return vInit;
330 }
typedefABC_NAMESPACE_IMPL_START struct Vec_Int_t_ Vec_Int_t
DECLARATIONS ///.
Definition: bblif.c:37
void Ssc_GiaSimRound(Gia_Man_t *p)
Definition: sscSim.c:247
Vec_Int_t * Ssc_GiaGetOneSim(Gia_Man_t *p)
Definition: sscSim.c:308
void Ssc_GiaRandomPiPattern(Gia_Man_t *p, int nWords, Vec_Int_t *vPivot)
Definition: sscSim.c:163
void Ssc_GiaRandomPiPattern ( Gia_Man_t p,
int  nWords,
Vec_Int_t vPivot 
)

Definition at line 163 of file sscSim.c.

164 {
165  word * pSimPi;
166  int i, w;
168  pSimPi = Gia_ObjSimPi( p, 0 );
169  for ( i = 0; i < Gia_ManPiNum(p); i++, pSimPi += nWords )
170  {
171  pSimPi[0] = vPivot ? Ssc_Random1(Vec_IntEntry(vPivot, i)) : Ssc_Random2();
172  for ( w = 1; w < nWords; w++ )
173  pSimPi[w] = Ssc_Random();
174 // if ( i < 10 )
175 // Extra_PrintBinary( stdout, (unsigned *)pSimPi, 64 ), printf( "\n" );
176  }
177 }
static word Ssc_Random1(int Bit)
Definition: sscSim.c:31
static word Ssc_Random2()
Definition: sscSim.c:32
void Ssc_GiaResetPiPattern(Gia_Man_t *p, int nWords)
Definition: sscSim.c:141
int nWords
Definition: abcNpn.c:127
static word * Gia_ObjSimPi(Gia_Man_t *p, int PiId)
Definition: gia.h:555
static ABC_NAMESPACE_IMPL_START word Ssc_Random()
DECLARATIONS ///.
Definition: sscSim.c:30
static int Vec_IntEntry(Vec_Int_t *p, int i)
Definition: bblif.c:268
unsigned __int64 word
DECLARATIONS ///.
Definition: kitPerm.c:36
static int Gia_ManPiNum(Gia_Man_t *p)
Definition: gia.h:385
void Ssc_GiaResetPiPattern ( Gia_Man_t p,
int  nWords 
)

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 141 of file sscSim.c.

142 {
143  p->iPatsPi = 0;
144  if ( p->vSimsPi == NULL )
145  p->vSimsPi = Vec_WrdStart(0);
146  Vec_WrdFill( p->vSimsPi, nWords * Gia_ManCiNum(p), 0 );
147  assert( nWords == Gia_ObjSimWords( p ) );
148 }
Vec_Wrd_t * vSimsPi
Definition: gia.h:178
int nWords
Definition: abcNpn.c:127
int iPatsPi
Definition: gia.h:176
static void Vec_WrdFill(Vec_Wrd_t *p, int nSize, word Fill)
Definition: vecWrd.h:489
static Vec_Wrd_t * Vec_WrdStart(int nSize)
Definition: vecWrd.h:103
static int Gia_ManCiNum(Gia_Man_t *p)
Definition: gia.h:383
#define assert(ex)
Definition: util_old.h:213
static int Gia_ObjSimWords(Gia_Man_t *p)
Definition: gia.h:554
void Ssc_GiaSavePiPattern ( Gia_Man_t p,
Vec_Int_t vPat 
)

Definition at line 149 of file sscSim.c.

150 {
151  word * pSimPi;
152  int i;
153  assert( Vec_IntSize(vPat) == Gia_ManCiNum(p) );
154  if ( p->iPatsPi == 64 * Gia_ObjSimWords(p) )
156  assert( p->iPatsPi < 64 * Gia_ObjSimWords(p) );
157  pSimPi = Gia_ObjSimPi( p, 0 );
158  for ( i = 0; i < Gia_ManCiNum(p); i++, pSimPi += Gia_ObjSimWords(p) )
159  if ( Vec_IntEntry(vPat, i) )
160  Abc_InfoSetBit( (unsigned *)pSimPi, p->iPatsPi );
161  p->iPatsPi++;
162 }
Vec_Wrd_t * vSimsPi
Definition: gia.h:178
static word * Gia_ObjSimPi(Gia_Man_t *p, int PiId)
Definition: gia.h:555
int iPatsPi
Definition: gia.h:176
void Vec_WrdDoubleSimInfo(Vec_Wrd_t *p, int nObjs)
FUNCTION DEFINITIONS ///.
Definition: sscSim.c:119
static int Vec_IntEntry(Vec_Int_t *p, int i)
Definition: bblif.c:268
unsigned __int64 word
DECLARATIONS ///.
Definition: kitPerm.c:36
static void Abc_InfoSetBit(unsigned *p, int i)
Definition: abc_global.h:259
static int Gia_ManCiNum(Gia_Man_t *p)
Definition: gia.h:383
static int Vec_IntSize(Vec_Int_t *p)
Definition: bblif.c:252
#define assert(ex)
Definition: util_old.h:213
static int Gia_ObjSimWords(Gia_Man_t *p)
Definition: gia.h:554
int Ssc_GiaSimClassRefineOneBit ( Gia_Man_t p,
int  i 
)

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

Synopsis [Refines one equivalence class using individual bit-pattern.]

Description []

SideEffects []

SeeAlso []

Definition at line 162 of file sscClass.c.

163 {
164  Gia_Obj_t * pObj;
165  int Ent;
166  assert( Gia_ObjIsHead( p, i ) );
167  Vec_IntClear( p->vClassOld );
168  Vec_IntClear( p->vClassNew );
169  Vec_IntPush( p->vClassOld, i );
170  pObj = Gia_ManObj(p, i);
171  Gia_ClassForEachObj1( p, i, Ent )
172  {
173  if ( Ssc_GiaSimAreEqualBit( p, i, Ent ) )
174  Vec_IntPush( p->vClassOld, Ent );
175  else
176  Vec_IntPush( p->vClassNew, Ent );
177  }
178  if ( Vec_IntSize( p->vClassNew ) == 0 )
179  return 0;
182  return 1;
183 }
Vec_Int_t * vClassOld
Definition: gia.h:179
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
Definition: gia.h:75
Vec_Int_t * vClassNew
Definition: gia.h:180
static int Ssc_GiaSimAreEqualBit(Gia_Man_t *p, int iObj0, int iObj1)
Definition: sscClass.c:110
#define Gia_ClassForEachObj1(p, i, iObj)
Definition: gia.h:933
static void Vec_IntPush(Vec_Int_t *p, int Entry)
Definition: bblif.c:468
static int Vec_IntSize(Vec_Int_t *p)
Definition: bblif.c:252
#define assert(ex)
Definition: util_old.h:213
static void Vec_IntClear(Vec_Int_t *p)
Definition: bblif.c:452
void Ssc_GiaSimClassCreate(Gia_Man_t *p, Vec_Int_t *vClass)
Definition: sscClass.c:128
void Ssc_GiaSimRound ( Gia_Man_t p)

Definition at line 247 of file sscSim.c.

248 {
249  Gia_Obj_t * pObj;
250  word * pSim, * pSim0, * pSim1;
251  int i, nWords = Gia_ObjSimWords(p);
252  Ssc_GiaResetSimInfo( p );
253  assert( nWords == Vec_WrdSize(p->vSims) / Gia_ManObjNum(p) );
254  // constant node
255  Ssc_SimConst( Gia_ObjSim(p, 0), nWords, 0 );
256  // primary inputs
257  pSim = Gia_ObjSim( p, 1 );
258  pSim0 = Gia_ObjSimPi( p, 0 );
259  Gia_ManForEachCi( p, pObj, i )
260  {
261  assert( pSim == Gia_ObjSimObj( p, pObj ) );
262  Ssc_SimDup( pSim, pSim0, nWords, 0 );
263  pSim += nWords;
264  pSim0 += nWords;
265  }
266  // intermediate nodes
267  pSim = Gia_ObjSim( p, 1+Gia_ManCiNum(p) );
268  Gia_ManForEachAnd( p, pObj, i )
269  {
270  assert( pSim == Gia_ObjSim( p, i ) );
271  pSim0 = pSim - pObj->iDiff0 * nWords;
272  pSim1 = pSim - pObj->iDiff1 * nWords;
273  Ssc_SimAnd( pSim, pSim0, pSim1, nWords, Gia_ObjFaninC0(pObj), Gia_ObjFaninC1(pObj) );
274  pSim += nWords;
275  }
276  // primary outputs
277  pSim = Gia_ObjSim( p, Gia_ManObjNum(p) - Gia_ManPoNum(p) );
278  Gia_ManForEachPo( p, pObj, i )
279  {
280  assert( pSim == Gia_ObjSimObj( p, pObj ) );
281  pSim0 = pSim - pObj->iDiff0 * nWords;
282  Ssc_SimDup( pSim, pSim0, nWords, Gia_ObjFaninC0(pObj) );
283 // Extra_PrintBinary( stdout, pSim, 64 ), printf( "\n" );
284  pSim += nWords;
285  }
286 }
unsigned iDiff0
Definition: gia.h:77
Vec_Wrd_t * vSims
Definition: gia.h:177
static int Gia_ManPoNum(Gia_Man_t *p)
Definition: gia.h:386
static int Gia_ObjFaninC1(Gia_Obj_t *pObj)
Definition: gia.h:452
static void Ssc_SimDup(word *pSim, word *pSim0, int nWords, int fComp0)
Definition: sscSim.c:43
static int Vec_WrdSize(Vec_Wrd_t *p)
Definition: vecWrd.h:336
int nWords
Definition: abcNpn.c:127
Definition: gia.h:75
static word * Gia_ObjSimPi(Gia_Man_t *p, int PiId)
Definition: gia.h:555
#define Gia_ManForEachCi(p, pObj, i)
Definition: gia.h:1016
static void Ssc_SimConst(word *pSim, int nWords, int fComp0)
Definition: sscSim.c:50
unsigned __int64 word
DECLARATIONS ///.
Definition: kitPerm.c:36
static void Ssc_SimAnd(word *pSim, word *pSim0, word *pSim1, int nWords, int fComp0, int fComp1)
Definition: sscSim.c:34
#define Gia_ManForEachAnd(p, pObj, i)
Definition: gia.h:1002
static int Gia_ManCiNum(Gia_Man_t *p)
Definition: gia.h:383
void Ssc_GiaResetSimInfo(Gia_Man_t *p)
Definition: sscSim.c:240
static word * Gia_ObjSimObj(Gia_Man_t *p, Gia_Obj_t *pObj)
Definition: gia.h:557
#define assert(ex)
Definition: util_old.h:213
static word * Gia_ObjSim(Gia_Man_t *p, int Id)
Definition: gia.h:556
unsigned iDiff1
Definition: gia.h:82
static int Gia_ObjFaninC0(Gia_Obj_t *pObj)
Definition: gia.h:451
#define Gia_ManForEachPo(p, pObj, i)
Definition: gia.h:1036
static int Gia_ObjSimWords(Gia_Man_t *p)
Definition: gia.h:554
static int Gia_ManObjNum(Gia_Man_t *p)
Definition: gia.h:388
int Ssc_GiaTransferPiPattern ( Gia_Man_t pAig,
Gia_Man_t pCare,
Vec_Int_t vPivot 
)

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

Synopsis [Transfer the simulation pattern from pCare to pAig.]

Description []

SideEffects []

SeeAlso []

Definition at line 201 of file sscSim.c.

202 {
203  extern word * Ssc_GiaGetCareMask( Gia_Man_t * p );
204  Gia_Obj_t * pObj;
205  int i, w, nWords = Gia_ObjSimWords( pCare );
206  word * pCareMask = Ssc_GiaGetCareMask( pCare );
207  int Count = Ssc_SimCountBits( pCareMask, nWords );
208  word * pSimPiCare, * pSimPiAig;
209  if ( Count == 0 )
210  {
211  ABC_FREE( pCareMask );
212  return 0;
213  }
214  Ssc_GiaResetPiPattern( pAig, nWords );
215  Gia_ManForEachCi( pCare, pObj, i )
216  {
217  pSimPiAig = Gia_ObjSimPi( pAig, i );
218  pSimPiCare = Gia_ObjSimObj( pCare, pObj );
219  for ( w = 0; w < nWords; w++ )
220  if ( Vec_IntEntry(vPivot, i) )
221  pSimPiAig[w] = pSimPiCare[w] | ~pCareMask[w];
222  else
223  pSimPiAig[w] = pSimPiCare[w] & pCareMask[w];
224  }
225  ABC_FREE( pCareMask );
226  return Count;
227 }
word * Ssc_GiaGetCareMask(Gia_Man_t *p)
Definition: sscSim.c:299
void Ssc_GiaResetPiPattern(Gia_Man_t *p, int nWords)
Definition: sscSim.c:141
static Llb_Mgr_t * p
Definition: llb3Image.c:950
int nWords
Definition: abcNpn.c:127
Definition: gia.h:75
static word * Gia_ObjSimPi(Gia_Man_t *p, int PiId)
Definition: gia.h:555
static int Ssc_SimCountBits(word *pSim, int nWords)
Definition: sscSim.c:95
#define Gia_ManForEachCi(p, pObj, i)
Definition: gia.h:1016
static int Vec_IntEntry(Vec_Int_t *p, int i)
Definition: bblif.c:268
unsigned __int64 word
DECLARATIONS ///.
Definition: kitPerm.c:36
static word * Gia_ObjSimObj(Gia_Man_t *p, Gia_Obj_t *pObj)
Definition: gia.h:557
#define ABC_FREE(obj)
Definition: abc_global.h:232
Definition: gia.h:95
static int Gia_ObjSimWords(Gia_Man_t *p)
Definition: gia.h:554
int Ssc_ManCheckEquivalence ( Ssc_Man_t p,
int  iRepr,
int  iNode,
int  fCompl 
)

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 348 of file sscSat.c.

349 {
350  int pLitsSat[2], RetValue;
351  abctime clk;
352  assert( iRepr != iNode );
353  if ( iRepr > iNode )
354  return l_Undef;
355  assert( iRepr < iNode );
356 // if ( p->nTimeOut )
357 // sat_solver_set_runtime_limit( p->pSat, p->nTimeOut * CLOCKS_PER_SEC + Abc_Clock() );
358 
359  // create CNF
360  if ( iRepr )
361  Ssc_ManCnfNodeAddToSolver( p, iRepr );
362  Ssc_ManCnfNodeAddToSolver( p, iNode );
363  sat_solver_compress( p->pSat );
364 
365  // order the literals
366  pLitsSat[0] = Abc_Var2Lit( Ssc_ObjSatVar(p, iRepr), 0 );
367  pLitsSat[1] = Abc_Var2Lit( Ssc_ObjSatVar(p, iNode), fCompl ^ (int)(iRepr > 0) );
368 
369  // solve under assumptions
370  // A = 1; B = 0
371  clk = Abc_Clock();
372  RetValue = sat_solver_solve( p->pSat, pLitsSat, pLitsSat + 2, (ABC_INT64_T)p->pPars->nBTLimit, (ABC_INT64_T)0, (ABC_INT64_T)0, (ABC_INT64_T)0 );
373  if ( RetValue == l_False )
374  {
375  pLitsSat[0] = Abc_LitNot( pLitsSat[0] ); // compl
376  pLitsSat[1] = Abc_LitNot( pLitsSat[1] ); // compl
377  RetValue = sat_solver_addclause( p->pSat, pLitsSat, pLitsSat + 2 );
378  assert( RetValue );
379  p->timeSatUnsat += Abc_Clock() - clk;
380  }
381  else if ( RetValue == l_True )
382  {
383  Ssc_ManCollectSatPattern( p, p->vPattern );
384  p->timeSatSat += Abc_Clock() - clk;
385  return l_True;
386  }
387  else // if ( RetValue1 == l_Undef )
388  {
389  p->timeSatUndec += Abc_Clock() - clk;
390  return l_Undef;
391  }
392 
393  // if the old node was constant 0, we already know the answer
394  if ( iRepr == 0 )
395  return l_False;
396 
397  // solve under assumptions
398  // A = 0; B = 1
399  clk = Abc_Clock();
400  RetValue = sat_solver_solve( p->pSat, pLitsSat, pLitsSat + 2, (ABC_INT64_T)p->pPars->nBTLimit, (ABC_INT64_T)0, (ABC_INT64_T)0, (ABC_INT64_T)0 );
401  if ( RetValue == l_False )
402  {
403  pLitsSat[0] = Abc_LitNot( pLitsSat[0] );
404  pLitsSat[1] = Abc_LitNot( pLitsSat[1] );
405  RetValue = sat_solver_addclause( p->pSat, pLitsSat, pLitsSat + 2 );
406  assert( RetValue );
407  p->timeSatUnsat += Abc_Clock() - clk;
408  }
409  else if ( RetValue == l_True )
410  {
411  Ssc_ManCollectSatPattern( p, p->vPattern );
412  p->timeSatSat += Abc_Clock() - clk;
413  return l_True;
414  }
415  else // if ( RetValue1 == l_Undef )
416  {
417  p->timeSatUndec += Abc_Clock() - clk;
418  return l_Undef;
419  }
420  return l_False;
421 }
static int Ssc_ObjSatVar(Ssc_Man_t *p, int iObj)
MACRO DEFINITIONS ///.
Definition: sscInt.h:90
static Llb_Mgr_t * p
Definition: llb3Image.c:950
int sat_solver_addclause(sat_solver *s, lit *begin, lit *end)
Definition: satSolver.c:1492
#define l_Undef
Definition: SolverTypes.h:86
int sat_solver_solve(sat_solver *s, lit *begin, lit *end, ABC_INT64_T nConfLimit, ABC_INT64_T nInsLimit, ABC_INT64_T nConfLimitGlobal, ABC_INT64_T nInsLimitGlobal)
Definition: satSolver.c:1700
static void sat_solver_compress(sat_solver *s)
Definition: satSolver.h:217
void Ssc_ManCollectSatPattern(Ssc_Man_t *p, Vec_Int_t *vPattern)
Definition: sscSat.c:315
static int Abc_Var2Lit(int Var, int fCompl)
Definition: abc_global.h:263
#define l_True
Definition: SolverTypes.h:84
static abctime Abc_Clock()
Definition: abc_global.h:279
static void Ssc_ManCnfNodeAddToSolver(Ssc_Man_t *p, int NodeId)
Definition: sscSat.c:208
static int Abc_LitNot(int Lit)
Definition: abc_global.h:266
#define l_False
Definition: SolverTypes.h:85
#define assert(ex)
Definition: util_old.h:213
ABC_INT64_T abctime
Definition: abc_global.h:278
Vec_Int_t* Ssc_ManFindPivotSat ( Ssc_Man_t p)

Definition at line 323 of file sscSat.c.

324 {
325  Vec_Int_t * vInit;
326  int status = sat_solver_solve( p->pSat, NULL, NULL, p->pPars->nBTLimit, 0, 0, 0 );
327  if ( status == l_False )
328  return (Vec_Int_t *)(ABC_PTRINT_T)1;
329  if ( status == l_Undef )
330  return NULL;
331  assert( status == l_True );
332  vInit = Vec_IntAlloc( Gia_ManCiNum(p->pFraig) );
333  Ssc_ManCollectSatPattern( p, vInit );
334  return vInit;
335 }
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
#define l_Undef
Definition: SolverTypes.h:86
int sat_solver_solve(sat_solver *s, lit *begin, lit *end, ABC_INT64_T nConfLimit, ABC_INT64_T nInsLimit, ABC_INT64_T nConfLimitGlobal, ABC_INT64_T nInsLimitGlobal)
Definition: satSolver.c:1700
void Ssc_ManCollectSatPattern(Ssc_Man_t *p, Vec_Int_t *vPattern)
Definition: sscSat.c:315
#define l_True
Definition: SolverTypes.h:84
static Vec_Int_t * Vec_IntAlloc(int nCap)
FUNCTION DEFINITIONS ///.
Definition: bblif.c:149
static int Gia_ManCiNum(Gia_Man_t *p)
Definition: gia.h:383
#define l_False
Definition: SolverTypes.h:85
#define assert(ex)
Definition: util_old.h:213
void Ssc_ManSatSolverRecycle ( Ssc_Man_t p)
void Ssc_ManStartSolver ( Ssc_Man_t p)

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

Synopsis [Starts the SAT solver for constraints.]

Description []

SideEffects []

SeeAlso []

Definition at line 261 of file sscSat.c.

262 {
263  Aig_Man_t * pMan = Gia_ManToAigSimple( p->pFraig );
264  Cnf_Dat_t * pDat = Cnf_Derive( pMan, 0 );
265  Gia_Obj_t * pObj;
266  sat_solver * pSat;
267  int i, status;
268  assert( p->pSat == NULL && p->vId2Var == NULL );
269  assert( Aig_ManObjNumMax(pMan) == Gia_ManObjNum(p->pFraig) );
270  Aig_ManStop( pMan );
271  // save variable mapping
272  p->nSatVarsPivot = p->nSatVars = pDat->nVars;
273  p->vId2Var = Vec_IntStart( Gia_ManCandNum(p->pAig) + Gia_ManCandNum(p->pCare) + 10 ); // mapping of each node into its SAT var
274  p->vVar2Id = Vec_IntStart( Gia_ManCandNum(p->pAig) + Gia_ManCandNum(p->pCare) + 10 ); // mapping of each SAT var into its node
275  Ssc_ObjSetSatVar( p, 0, pDat->pVarNums[0] );
276  Gia_ManForEachCi( p->pFraig, pObj, i )
277  {
278  int iObj = Gia_ObjId( p->pFraig, pObj );
279  Ssc_ObjSetSatVar( p, iObj, pDat->pVarNums[iObj] );
280  }
281 //Cnf_DataWriteIntoFile( pDat, "dump.cnf", 1, NULL, NULL );
282  // start the SAT solver
283  pSat = sat_solver_new();
284  sat_solver_setnvars( pSat, pDat->nVars + 1000 );
285  for ( i = 0; i < pDat->nClauses; i++ )
286  {
287  if ( !sat_solver_addclause( pSat, pDat->pClauses[i], pDat->pClauses[i+1] ) )
288  {
289  Cnf_DataFree( pDat );
290  sat_solver_delete( pSat );
291  return;
292  }
293  }
294  Cnf_DataFree( pDat );
295  status = sat_solver_simplify( pSat );
296  if ( status == 0 )
297  {
298  sat_solver_delete( pSat );
299  return;
300  }
301  p->pSat = pSat;
302 }
Aig_Man_t * pAig
Definition: llb3Image.c:49
Aig_Man_t * Gia_ManToAigSimple(Gia_Man_t *p)
Definition: giaAig.c:367
Cnf_Dat_t * Cnf_Derive(Aig_Man_t *pAig, int nOutputs)
Definition: cnfCore.c:165
typedefABC_NAMESPACE_HEADER_START struct Aig_Man_t_ Aig_Man_t
INCLUDES ///.
Definition: aig.h:50
static Llb_Mgr_t * p
Definition: llb3Image.c:950
int sat_solver_addclause(sat_solver *s, lit *begin, lit *end)
Definition: satSolver.c:1492
void Aig_ManStop(Aig_Man_t *p)
Definition: aigMan.c:187
int nClauses
Definition: cnf.h:61
int nVars
Definition: cnf.h:59
void sat_solver_delete(sat_solver *s)
Definition: satSolver.c:1141
int * pVarNums
Definition: cnf.h:63
Definition: cnf.h:56
Definition: gia.h:75
#define Gia_ManForEachCi(p, pObj, i)
Definition: gia.h:1016
static Vec_Int_t * Vec_IntStart(int nSize)
Definition: bblif.c:172
int ** pClauses
Definition: cnf.h:62
void sat_solver_setnvars(sat_solver *s, int n)
Definition: satSolver.c:1072
static int Gia_ObjId(Gia_Man_t *p, Gia_Obj_t *pObj)
Definition: gia.h:410
static void Ssc_ObjSetSatVar(Ssc_Man_t *p, int iObj, int Num)
Definition: sscInt.h:91
static int Gia_ManCandNum(Gia_Man_t *p)
Definition: gia.h:394
static int Aig_ManObjNumMax(Aig_Man_t *p)
Definition: aig.h:259
int sat_solver_simplify(sat_solver *s)
Definition: satSolver.c:1276
sat_solver * sat_solver_new(void)
Definition: satSolver.c:1001
void Cnf_DataFree(Cnf_Dat_t *p)
Definition: cnfMan.c:180
#define assert(ex)
Definition: util_old.h:213
static int Gia_ManObjNum(Gia_Man_t *p)
Definition: gia.h:388
static void Ssc_ObjCleanSatVar ( Ssc_Man_t p,
int  Num 
)
inlinestatic

Definition at line 92 of file sscInt.h.

92 { Vec_IntWriteEntry(p->vId2Var, Vec_IntEntry(p->vVar2Id, Num), Num); Vec_IntWriteEntry(p->vVar2Id, Num, 0); }
static Llb_Mgr_t * p
Definition: llb3Image.c:950
static void Vec_IntWriteEntry(Vec_Int_t *p, int i, int Entry)
Definition: bblif.c:285
static int Vec_IntEntry(Vec_Int_t *p, int i)
Definition: bblif.c:268
static int Ssc_ObjFraig ( Ssc_Man_t p,
Gia_Obj_t pObj 
)
inlinestatic

Definition at line 94 of file sscInt.h.

94 { return pObj->Value; }
unsigned Value
Definition: gia.h:87
static int Ssc_ObjSatVar ( Ssc_Man_t p,
int  iObj 
)
inlinestatic

MACRO DEFINITIONS ///.

Definition at line 90 of file sscInt.h.

90 { return Vec_IntEntry(p->vId2Var, iObj); }
static Llb_Mgr_t * p
Definition: llb3Image.c:950
static int Vec_IntEntry(Vec_Int_t *p, int i)
Definition: bblif.c:268
static void Ssc_ObjSetFraig ( Gia_Obj_t pObj,
int  iNode 
)
inlinestatic

Definition at line 95 of file sscInt.h.

95 { pObj->Value = iNode; }
unsigned Value
Definition: gia.h:87
static void Ssc_ObjSetSatVar ( Ssc_Man_t p,
int  iObj,
int  Num 
)
inlinestatic

Definition at line 91 of file sscInt.h.

91 { Vec_IntWriteEntry(p->vId2Var, iObj, Num); Vec_IntWriteEntry(p->vVar2Id, Num, iObj); }
static Llb_Mgr_t * p
Definition: llb3Image.c:950
static void Vec_IntWriteEntry(Vec_Int_t *p, int i, int Entry)
Definition: bblif.c:285