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

Go to the source code of this file.

Functions

static ABC_NAMESPACE_IMPL_START int Ssc_GiaSimHashKey (Gia_Man_t *p, int iObj, int nTableSize)
 DECLARATIONS ///. More...
 
static int Ssc_GiaSimIsConst0 (Gia_Man_t *p, int iObj0)
 
static int Ssc_GiaSimAreEqual (Gia_Man_t *p, int iObj0, int iObj1)
 
static int Ssc_GiaSimAreEqualBit (Gia_Man_t *p, int iObj0, int iObj1)
 
void Ssc_GiaSimClassCreate (Gia_Man_t *p, Vec_Int_t *vClass)
 
int Ssc_GiaSimClassRefineOneBit (Gia_Man_t *p, int i)
 
int Ssc_GiaSimClassRefineOne (Gia_Man_t *p, int i)
 
void Ssc_GiaSimProcessRefined (Gia_Man_t *p, Vec_Int_t *vRefined)
 
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)
 

Function Documentation

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
static int Ssc_GiaSimAreEqual ( Gia_Man_t p,
int  iObj0,
int  iObj1 
)
inlinestatic

Definition at line 91 of file sscClass.c.

92 {
93  int w, nWords = Gia_ObjSimWords(p);
94  word * pSim0 = Gia_ObjSim( p, iObj0 );
95  word * pSim1 = Gia_ObjSim( p, iObj1 );
96  if ( (pSim0[0] & 1) != (pSim1[0] & 1) )
97  {
98  for ( w = 0; w < nWords; w++ )
99  if ( pSim0[w] != ~pSim1[w] )
100  return 0;
101  }
102  else
103  {
104  for ( w = 0; w < nWords; w++ )
105  if ( pSim0[w] != pSim1[w] )
106  return 0;
107  }
108  return 1;
109 }
int nWords
Definition: abcNpn.c:127
unsigned __int64 word
DECLARATIONS ///.
Definition: kitPerm.c:36
static word * Gia_ObjSim(Gia_Man_t *p, int Id)
Definition: gia.h:556
static int Gia_ObjSimWords(Gia_Man_t *p)
Definition: gia.h:554
static int Ssc_GiaSimAreEqualBit ( Gia_Man_t p,
int  iObj0,
int  iObj1 
)
inlinestatic

Definition at line 110 of file sscClass.c.

111 {
112  Gia_Obj_t * pObj0 = Gia_ManObj( p, iObj0 );
113  Gia_Obj_t * pObj1 = Gia_ManObj( p, iObj1 );
114  return (pObj0->fPhase ^ pObj0->fMark0) == (pObj1->fPhase ^ pObj1->fMark0);
115 }
static Gia_Obj_t * Gia_ManObj(Gia_Man_t *p, int v)
Definition: gia.h:402
Definition: gia.h:75
unsigned fPhase
Definition: gia.h:85
unsigned fMark0
Definition: gia.h:79
void Ssc_GiaSimClassCreate ( Gia_Man_t p,
Vec_Int_t vClass 
)

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

Synopsis [Refines one equivalence class.]

Description []

SideEffects []

SeeAlso []

Definition at line 128 of file sscClass.c.

129 {
130  int Repr = GIA_VOID, EntPrev = -1, Ent, i;
131  assert( Vec_IntSize(vClass) > 0 );
132  Vec_IntForEachEntry( vClass, Ent, i )
133  {
134  if ( i == 0 )
135  {
136  Repr = Ent;
137  Gia_ObjSetRepr( p, Ent, GIA_VOID );
138  EntPrev = Ent;
139  }
140  else
141  {
142  assert( Repr < Ent );
143  Gia_ObjSetRepr( p, Ent, Repr );
144  Gia_ObjSetNext( p, EntPrev, Ent );
145  EntPrev = Ent;
146  }
147  }
148  Gia_ObjSetNext( p, EntPrev, 0 );
149 }
static void Gia_ObjSetRepr(Gia_Man_t *p, int Id, int Num)
Definition: gia.h:888
static void Gia_ObjSetNext(Gia_Man_t *p, int Id, int Num)
Definition: gia.h:913
#define GIA_VOID
Definition: gia.h:45
static int Vec_IntSize(Vec_Int_t *p)
Definition: bblif.c:252
#define assert(ex)
Definition: util_old.h:213
#define Vec_IntForEachEntry(vVec, Entry, i)
MACRO DEFINITIONS ///.
Definition: vecInt.h:54
int Ssc_GiaSimClassRefineOne ( Gia_Man_t p,
int  i 
)

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

Synopsis [Refines one class using simulation patterns.]

Description []

SideEffects []

SeeAlso []

Definition at line 197 of file sscClass.c.

198 {
199  Gia_Obj_t * pObj;
200  int Ent;
201  assert( Gia_ObjIsHead( p, i ) );
202  Vec_IntClear( p->vClassOld );
203  Vec_IntClear( p->vClassNew );
204  Vec_IntPush( p->vClassOld, i );
205  pObj = Gia_ManObj(p, i);
206  Gia_ClassForEachObj1( p, i, Ent )
207  {
208  if ( Ssc_GiaSimAreEqual( p, i, Ent ) )
209  Vec_IntPush( p->vClassOld, Ent );
210  else
211  Vec_IntPush( p->vClassNew, Ent );
212  }
213  if ( Vec_IntSize( p->vClassNew ) == 0 )
214  return 0;
217  if ( Vec_IntSize(p->vClassNew) > 1 )
218  return 1 + Ssc_GiaSimClassRefineOne( p, Vec_IntEntry(p->vClassNew,0) );
219  return 1;
220 }
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_GiaSimAreEqual(Gia_Man_t *p, int iObj0, int iObj1)
Definition: sscClass.c:91
static int Vec_IntEntry(Vec_Int_t *p, int i)
Definition: bblif.c:268
#define Gia_ClassForEachObj1(p, i, iObj)
Definition: gia.h:933
static void Vec_IntPush(Vec_Int_t *p, int Entry)
Definition: bblif.c:468
int Ssc_GiaSimClassRefineOne(Gia_Man_t *p, int i)
Definition: sscClass.c:197
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
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
static ABC_NAMESPACE_IMPL_START int Ssc_GiaSimHashKey ( Gia_Man_t p,
int  iObj,
int  nTableSize 
)
inlinestatic

DECLARATIONS ///.

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

FileName [sscClass.c]

SystemName [ABC: Logic synthesis and verification system.]

PackageName [SAT sweeping under constraints.]

Synopsis [Equivalence classes.]

Author [Alan Mishchenko]

Affiliation [UC Berkeley]

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

Revision [

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

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

Synopsis [Computes hash key of the simuation info.]

Description []

SideEffects []

SeeAlso []

Definition at line 45 of file sscClass.c.

46 {
47  static int s_Primes[16] = {
48  1291, 1699, 1999, 2357, 2953, 3313, 3907, 4177,
49  4831, 5147, 5647, 6343, 6899, 7103, 7873, 8147 };
50  word * pSim = Gia_ObjSim( p, iObj );
51  unsigned uHash = 0;
52  int i, nWords = Gia_ObjSimWords(p);
53  if ( pSim[0] & 1 )
54  for ( i = 0; i < nWords; i++ )
55  uHash ^= ~pSim[i] * s_Primes[i & 0xf];
56  else
57  for ( i = 0; i < nWords; i++ )
58  uHash ^= pSim[i] * s_Primes[i & 0xf];
59  return (int)(uHash % nTableSize);
60 }
int nWords
Definition: abcNpn.c:127
static int s_Primes[MAX_PRIMES]
Definition: fxuPair.c:30
unsigned __int64 word
DECLARATIONS ///.
Definition: kitPerm.c:36
static word * Gia_ObjSim(Gia_Man_t *p, int Id)
Definition: gia.h:556
static int Gia_ObjSimWords(Gia_Man_t *p)
Definition: gia.h:554
static int Ssc_GiaSimIsConst0 ( Gia_Man_t p,
int  iObj0 
)
inlinestatic

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

Synopsis [Returns 1 if sim patterns are equal up to the complement.]

Description []

SideEffects []

SeeAlso []

Definition at line 73 of file sscClass.c.

74 {
75  int w, nWords = Gia_ObjSimWords(p);
76  word * pSim = Gia_ObjSim( p, iObj0 );
77  if ( pSim[0] & 1 )
78  {
79  for ( w = 0; w < nWords; w++ )
80  if ( ~pSim[w] )
81  return 0;
82  }
83  else
84  {
85  for ( w = 0; w < nWords; w++ )
86  if ( pSim[w] )
87  return 0;
88  }
89  return 1;
90 }
int nWords
Definition: abcNpn.c:127
unsigned __int64 word
DECLARATIONS ///.
Definition: kitPerm.c:36
static word * Gia_ObjSim(Gia_Man_t *p, int Id)
Definition: gia.h:556
static int Gia_ObjSimWords(Gia_Man_t *p)
Definition: gia.h:554
void Ssc_GiaSimProcessRefined ( Gia_Man_t p,
Vec_Int_t vRefined 
)

Definition at line 221 of file sscClass.c.

222 {
223  int * pTable, nTableSize, i, k, Key;
224  if ( Vec_IntSize(vRefined) == 0 )
225  return;
226  nTableSize = Abc_PrimeCudd( 100 + Vec_IntSize(vRefined) / 3 );
227  pTable = ABC_CALLOC( int, nTableSize );
228  Vec_IntForEachEntry( vRefined, i, k )
229  {
230  assert( !Ssc_GiaSimIsConst0( p, i ) );
231  Key = Ssc_GiaSimHashKey( p, i, nTableSize );
232  if ( pTable[Key] == 0 )
233  {
234  assert( Gia_ObjRepr(p, i) == 0 );
235  assert( Gia_ObjNext(p, i) == 0 );
236  Gia_ObjSetRepr( p, i, GIA_VOID );
237  }
238  else
239  {
240  Gia_ObjSetNext( p, pTable[Key], i );
241  Gia_ObjSetRepr( p, i, Gia_ObjRepr(p, pTable[Key]) );
242  if ( Gia_ObjRepr(p, i) == GIA_VOID )
243  Gia_ObjSetRepr( p, i, pTable[Key] );
244  assert( Gia_ObjRepr(p, i) > 0 );
245  }
246  pTable[Key] = i;
247  }
248  Vec_IntForEachEntry( vRefined, i, k )
249  if ( Gia_ObjIsHead( p, i ) )
250  Ssc_GiaSimClassRefineOne( p, i );
251  ABC_FREE( pTable );
252 }
static int Abc_PrimeCudd(unsigned int p)
Definition: abc_global.h:383
static ABC_NAMESPACE_IMPL_START int Ssc_GiaSimHashKey(Gia_Man_t *p, int iObj, int nTableSize)
DECLARATIONS ///.
Definition: sscClass.c:45
static int Gia_ObjIsHead(Gia_Man_t *p, int Id)
Definition: gia.h:916
static void Gia_ObjSetRepr(Gia_Man_t *p, int Id, int Num)
Definition: gia.h:888
if(last==0)
Definition: sparse_int.h:34
int Ssc_GiaSimClassRefineOne(Gia_Man_t *p, int i)
Definition: sscClass.c:197
static int Gia_ObjNext(Gia_Man_t *p, int Id)
Definition: gia.h:912
static void Gia_ObjSetNext(Gia_Man_t *p, int Id, int Num)
Definition: gia.h:913
#define GIA_VOID
Definition: gia.h:45
static int Vec_IntSize(Vec_Int_t *p)
Definition: bblif.c:252
#define ABC_FREE(obj)
Definition: abc_global.h:232
#define ABC_CALLOC(type, num)
Definition: abc_global.h:230
#define assert(ex)
Definition: util_old.h:213
#define Vec_IntForEachEntry(vVec, Entry, i)
MACRO DEFINITIONS ///.
Definition: vecInt.h:54
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