45static inline int Ssc_GiaSimHashKey(
Gia_Man_t *
p,
int iObj,
int nTableSize )
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 );
52 int i,
nWords = Gia_ObjSimWords(
p);
54 for ( i = 0; i <
nWords; i++ )
55 uHash ^= ~pSim[i] * s_Primes[i & 0xf];
57 for ( i = 0; i <
nWords; i++ )
58 uHash ^= pSim[i] * s_Primes[i & 0xf];
59 return (
int)(uHash % nTableSize);
73static inline int Ssc_GiaSimIsConst0(
Gia_Man_t *
p,
int iObj0 )
75 int w,
nWords = Gia_ObjSimWords(
p);
76 word * pSim = Gia_ObjSim(
p, iObj0 );
79 for ( w = 0; w <
nWords; w++ )
85 for ( w = 0; w <
nWords; w++ )
91static inline int Ssc_GiaSimAreEqual(
Gia_Man_t *
p,
int iObj0,
int iObj1 )
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) )
98 for ( w = 0; w <
nWords; w++ )
99 if ( pSim0[w] != ~pSim1[w] )
104 for ( w = 0; w <
nWords; w++ )
105 if ( pSim0[w] != pSim1[w] )
110static inline int Ssc_GiaSimAreEqualBit(
Gia_Man_t *
p,
int iObj0,
int iObj1 )
130 int Repr =
GIA_VOID, EntPrev = -1, Ent, i;
131 assert( Vec_IntSize(vClass) > 0 );
143 Gia_ObjSetRepr(
p, Ent, Repr );
144 Gia_ObjSetNext(
p, EntPrev, Ent );
148 Gia_ObjSetNext(
p, EntPrev, 0 );
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);
173 if ( Ssc_GiaSimAreEqualBit(
p, i, Ent ) )
174 Vec_IntPush(
p->vClassOld, Ent );
176 Vec_IntPush(
p->vClassNew, Ent );
178 if ( Vec_IntSize(
p->vClassNew ) == 0 )
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);
208 if ( Ssc_GiaSimAreEqual(
p, i, Ent ) )
209 Vec_IntPush(
p->vClassOld, Ent );
211 Vec_IntPush(
p->vClassNew, Ent );
213 if ( Vec_IntSize(
p->vClassNew ) == 0 )
217 if ( Vec_IntSize(
p->vClassNew) > 1 )
223 int * pTable, nTableSize, i, k, Key;
224 if ( Vec_IntSize(vRefined) == 0 )
226 nTableSize = Abc_PrimeCudd( 100 + Vec_IntSize(vRefined) / 3 );
230 assert( !Ssc_GiaSimIsConst0(
p, i ) );
231 Key = Ssc_GiaSimHashKey(
p, i, nTableSize );
232 if ( pTable[Key] == 0 )
234 assert( Gia_ObjRepr(
p, i) == 0 );
235 assert( Gia_ObjNext(
p, i) == 0 );
240 Gia_ObjSetNext(
p, pTable[Key], i );
241 Gia_ObjSetRepr(
p, i, Gia_ObjRepr(
p, pTable[Key]) );
243 Gia_ObjSetRepr(
p, i, pTable[Key] );
244 assert( Gia_ObjRepr(
p, i) > 0 );
249 if ( Gia_ObjIsHead(
p, 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 );
285 vRefinedC = Vec_IntAlloc( 100 );
287 if ( Gia_ObjIsTail(
p, i) )
289 else if ( Gia_ObjIsConst(
p, i) && !Ssc_GiaSimIsConst0(
p, i) )
290 Vec_IntPush( vRefinedC, i );
292 Counter += Vec_IntSize( vRefinedC );
293 Vec_IntFree( vRefinedC );
311 int i, iRepr, iObj, Result = 1;
313 if ( iRepr == Gia_ObjRepr(
p, iObj) )
314 printf(
"Pair (%d, %d) are still equivalent.\n", iRepr, iObj ), Result = 0;
#define ABC_CALLOC(type, num)
#define ABC_NAMESPACE_IMPL_START
#define ABC_NAMESPACE_IMPL_END
typedefABC_NAMESPACE_IMPL_START struct Vec_Int_t_ Vec_Int_t
DECLARATIONS ///.
struct Gia_Rpr_t_ Gia_Rpr_t
#define Gia_ManForEachCand(p, pObj, i)
#define Gia_ClassForEachObj1(p, i, iObj)
struct Gia_Obj_t_ Gia_Obj_t
struct Gia_Man_t_ Gia_Man_t
#define Gia_ManForEachObj(p, pObj, i)
MACRO DEFINITIONS ///.
unsigned __int64 word
DECLARATIONS ///.
void Ssc_GiaSimProcessRefined(Gia_Man_t *p, Vec_Int_t *vRefined)
void Ssc_GiaClassesCheckPairs(Gia_Man_t *p, Vec_Int_t *vDisPairs)
int Ssc_GiaSimClassRefineOne(Gia_Man_t *p, int i)
void Ssc_GiaClassesInit(Gia_Man_t *p)
FUNCTION DECLARATIONS ///.
void Ssc_GiaSimClassCreate(Gia_Man_t *p, Vec_Int_t *vClass)
int Ssc_GiaSimClassRefineOneBit(Gia_Man_t *p, int i)
int Ssc_GiaClassesRefine(Gia_Man_t *p)
#define Vec_IntForEachEntryDouble(vVec, Entry1, Entry2, i)
#define Vec_IntForEachEntry(vVec, Entry, i)
MACRO DEFINITIONS ///.