43static inline int Slv_ManObjNum (
Slv_Man_t *
p ) {
return Vec_IntSize(&
p->vFanins)/2; }
45static inline int Slv_ObjFaninLit (
Slv_Man_t *
p,
int iObj,
int f ) {
return Vec_IntEntry(&
p->vFanins, Abc_Var2Lit(iObj, f)); }
46static inline int Slv_ObjFanin (
Slv_Man_t *
p,
int iObj,
int f ) {
return Abc_Lit2Var(Slv_ObjFaninLit(
p, iObj, f)); }
47static inline int Slv_ObjFaninC (
Slv_Man_t *
p,
int iObj,
int f ) {
return Abc_LitIsCompl(Slv_ObjFaninLit(
p, iObj, f)); }
49static inline int Slv_ObjIsCi (
Slv_Man_t *
p,
int iObj ) {
return !Slv_ObjFaninLit(
p, iObj, 0) && Slv_ObjFaninLit(
p, iObj, 1); }
50static inline int Slv_ObjIsCo (
Slv_Man_t *
p,
int iObj ) {
return Slv_ObjFaninLit(
p, iObj, 0) && !Slv_ObjFaninLit(
p, iObj, 1); }
51static inline int Slv_ObjIsAnd (
Slv_Man_t *
p,
int iObj ) {
return Slv_ObjFaninLit(
p, iObj, 0) && Slv_ObjFaninLit(
p, iObj, 1); }
53static inline int Slv_ObjFanout0 (
Slv_Man_t *
p,
int iObj ) {
return Vec_IntEntry(&
p->vFanout0, iObj); }
54static inline void Slv_ObjSetFanout0 (
Slv_Man_t *
p,
int iObj,
int iLit ) { Vec_IntWriteEntry(&
p->vFanout0, iObj, iLit); }
56static inline int Slv_ObjNextFanout (
Slv_Man_t *
p,
int iLit ) {
return Vec_IntEntry(&
p->vFanoutN, iLit); }
57static inline void Slv_ObjSetNextFanout(
Slv_Man_t *
p,
int iLit,
int iLitF ) { Vec_IntWriteEntry(&
p->vFanoutN, iLit, iLitF); }
59static inline int Slv_ObjCopyLit (
Slv_Man_t *
p,
int iObj ) {
return Vec_IntEntry(&
p->vCopies, iObj); }
60static inline void Slv_ObjSetCopyLit (
Slv_Man_t *
p,
int iObj,
int iLit ) { Vec_IntWriteEntry(&
p->vCopies, iObj, iLit); }
62#define Slv_ManForEachObj( p, iObj ) \
63 for ( iObj = 1; iObj < Slv_ManObjNum(p); iObj++ )
65#define Slv_ObjForEachFanout( p, iObj, iFanLit ) \
66 for ( iFanLit = Slv_ObjFanout0(p, iObj); iFanLit; iFanLit = Slv_ObjNextFanout(p, iFanLit) )
86 Vec_IntGrow( &
p->vCis, 100 );
87 Vec_IntGrow( &
p->vCos, 100 );
88 Vec_IntGrow( &
p->vFanins, 2*nObjs );
89 Vec_IntGrow( &
p->vFanoutN, 2*nObjs );
90 Vec_IntGrow( &
p->vFanout0, nObjs );
91 Vec_StrGrow( &
p->vValues, nObjs );
93 Vec_IntFill( &
p->vFanins, 2, 0 );
94 Vec_IntFill( &
p->vFanoutN, 2, 0 );
95 Vec_IntFill( &
p->vFanout0, 1, 0 );
100 Vec_IntErase( &
p->vCis );
101 Vec_IntErase( &
p->vCos );
102 Vec_IntErase( &
p->vFanins );
103 Vec_IntErase( &
p->vFanoutN );
104 Vec_IntErase( &
p->vFanout0 );
105 Vec_StrErase( &
p->vValues );
106 Vec_IntErase( &
p->vCopies );
114 printf(
"Fanouts of node %d: ", iObj );
116 printf(
"%d ", Abc_Lit2Var(iFanLit) );
120static inline int Slv_ManAppendObj(
Slv_Man_t *
p,
int iLit0,
int iLit1 )
122 int iObj = Slv_ManObjNum(
p);
123 Vec_StrPush( &
p->vValues, 0 );
124 Vec_IntPush( &
p->vFanout0, 0 );
125 Vec_IntPushTwo( &
p->vFanoutN, 0, 0 );
127 assert(!iLit1), iLit1 = Vec_IntSize(&
p->vCis)+1, Vec_IntPush(&
p->vCis, iObj);
129 assert(iLit0), Vec_IntPush(&
p->vCos, iObj);
132 Slv_ObjSetNextFanout(
p, Abc_Var2Lit(iObj, 0), Slv_ObjFanout0(
p, Abc_Lit2Var(iLit0)) );
133 Slv_ObjSetNextFanout(
p, Abc_Var2Lit(iObj, 1), Slv_ObjFanout0(
p, Abc_Lit2Var(iLit1)) );
134 Slv_ObjSetFanout0(
p, Abc_Lit2Var(iLit0), Abc_Var2Lit(iObj, 0) );
135 Slv_ObjSetFanout0(
p, Abc_Lit2Var(iLit1), Abc_Var2Lit(iObj, 1) );
137 Vec_IntPushTwo( &
p->vFanins, iLit0, iLit1 );
138 return Abc_Var2Lit( iObj, 0 );
156 Gia_ManConst0(
p)->Value = 0;
159 if ( Gia_ObjIsAnd(pObj) )
160 pObj->
Value = Slv_ManAppendObj( pNew, Abc_LitNotCond(Gia_ObjFanin0(pObj)->Value, Gia_ObjFaninC0(pObj)), Abc_LitNotCond(Gia_ObjFanin1(pObj)->Value, Gia_ObjFaninC1(pObj)) );
161 else if ( Gia_ObjIsCo(pObj) )
162 pObj->
Value = Slv_ManAppendObj( pNew, Abc_LitNotCond(Gia_ObjFanin0(pObj)->Value, Gia_ObjFaninC0(pObj)), 0 );
163 else if ( Gia_ObjIsCi(pObj) )
164 pObj->
Value = Slv_ManAppendObj( pNew, 0, 0 );
168 assert( Gia_ManObjNum(
p) == Slv_ManObjNum(pNew) );
175 Vec_IntFill( &
p->vCopies, Slv_ManObjNum(
p), 0 );
177 if ( Slv_ObjIsCi(
p, iObj) )
178 Slv_ObjSetCopyLit(
p, iObj, Gia_ManAppendCi(pNew) );
179 else if ( Slv_ObjIsCo(
p, iObj) )
181 int iLit0 = Abc_LitNotCond( Slv_ObjCopyLit(
p, Slv_ObjFanin(
p, iObj, 0)), Slv_ObjFaninC(
p, iObj, 0) );
182 Slv_ObjSetCopyLit(
p, iObj, Gia_ManAppendCo(pNew, iLit0) );
184 else if ( Slv_ObjIsAnd(
p, iObj) )
186 int iLit0 = Abc_LitNotCond( Slv_ObjCopyLit(
p, Slv_ObjFanin(
p, iObj, 0)), Slv_ObjFaninC(
p, iObj, 0) );
187 int iLit1 = Abc_LitNotCond( Slv_ObjCopyLit(
p, Slv_ObjFanin(
p, iObj, 1)), Slv_ObjFaninC(
p, iObj, 1) );
188 Slv_ObjSetCopyLit(
p, iObj, Gia_ManAppendAnd(pNew, iLit0, iLit1) );
191 assert( Gia_ManObjNum(pNew) == Slv_ManObjNum(
p) );
224 pNew->
pName = Abc_UtilStrsav(
p->pName );
225 pNew->
pSpec = Abc_UtilStrsav(
p->pSpec );
227 Gia_ManAppendCi( pNew );
229 for ( m = 0; m < (1 << nVars); m++ )
232 Gia_ManConst0(
p)->Value = 0;
236 pObj->
Value = (m >> i) & 1;
238 pObj->
Value = Gia_ObjToLit(pNew, Gia_ManCi(pNew, i));
243 Gia_ManAppendCo( pNew, Gia_ObjFanin0Copy(pObj) );
272 int iFan0 = Gia_ObjFaninId0p(
p, pObj);
275 if ( Gia_ManCiNum(pTemp) == Gia_ManCiNum(pUsed) &&
Cec_ManVerifyTwo(pTemp, pUsed, 0) == 1 )
277 ABC_SWAP(
void *, Vec_PtrArray(vGias)[0], Vec_PtrArray(vGias)[k] );
283 printf(
"\nOut %6d : ", i );
284 if ( k == Vec_PtrSize(vGias) )
285 printf(
"Equiv to none " );
287 printf(
"Equiv to %6d ", k );
290 if ( k == Vec_PtrSize(vGias) )
291 Vec_PtrPush( vGias, pTemp );
295 printf(
"\nComputed %d classes.\n\n", Vec_PtrSize(vGias) );
298 Vec_PtrFree( vGias );
315 for ( i = 0; i < nVars; i++ )
320void Gia_EnumPerms_rec(
int * pUsed,
int nVars,
int * pPerm,
int nPerm,
int * pCount, FILE * pFile,
int nLogVars )
323 if ( nPerm == nVars )
327 for ( i = 0; i < nLogVars; i++ )
328 fprintf( pFile,
"%c",
'0' + ((*pCount) >> (nLogVars-1-i) & 1) );
329 fprintf( pFile,
" " );
330 for ( i = 0; i < nVars; i++ )
331 for ( k = 0; k < nVars; k++ )
332 fprintf( pFile,
"%c",
'0' + (pPerm[i] == k) );
333 fprintf( pFile,
"\n" );
339 printf(
"%5d : ", (*pCount) );
340 for ( i = 0; i < nVars; i += 2 )
341 printf(
"%d %d ", pPerm[i], pPerm[i+1] );
351 assert( pUsed[New] == 0 );
354 for ( i = 0; i < nVars; i++ )
365 assert( pUsed[New] == 1 );
370 int nLogVars = 0, Count = 0;
373 FILE * pFile = fopen(
"pairset.pla",
"wb" );
376 printf(
"Printing sets of pairs for %d objects:\n", nVars );
380 printf(
"Finished enumerating %d sets of pairs.\n", Count );
382 nLogVars = Abc_Base2Log( Count );
383 printf(
"Need %d variables to encode %d sets.\n", nLogVars, Count );
385 fprintf( pFile,
".i %d\n", nLogVars );
386 fprintf( pFile,
".o %d\n", nVars*nVars );
388 fprintf( pFile,
".e\n" );
390 printf(
"Finished dumping file \"%s\".\n",
"pairset.pla" );
#define ABC_SWAP(Type, a, b)
#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 Vec_Str_t_ Vec_Str_t
int Cec_ManVerifyTwo(Gia_Man_t *p0, Gia_Man_t *p1, int fVerbose)
void Slv_ManFree(Slv_Man_t *p)
void Gia_ManStructExperiment(Gia_Man_t *p)
Gia_Man_t * Slv_ManToAig(Gia_Man_t *pGia)
#define Slv_ObjForEachFanout(p, iObj, iFanLit)
void Gia_EnumPerms(int nVars)
typedefABC_NAMESPACE_IMPL_START struct Slv_Man_t_ Slv_Man_t
DECLARATIONS ///.
#define Slv_ManForEachObj(p, iObj)
void Gia_EnumPerms_rec(int *pUsed, int nVars, int *pPerm, int nPerm, int *pCount, FILE *pFile, int nLogVars)
Slv_Man_t * Slv_ManFromGia(Gia_Man_t *p)
Gia_Man_t * Slv_ManToGia(Slv_Man_t *p)
int Gia_EnumFirstUnused(int *pUsed, int nVars)
void Slv_ManPrintFanouts(Slv_Man_t *p)
Gia_Man_t * Gia_ManCofPisVars(Gia_Man_t *p, int nVars)
Slv_Man_t * Slv_ManAlloc(int nObjs)
FUNCTION DEFINITIONS ///.
void Gia_ManStop(Gia_Man_t *p)
void Gia_ManHashStart(Gia_Man_t *p)
#define Gia_ManForEachPo(p, pObj, i)
#define Gia_ManForEachAnd(p, pObj, i)
#define Gia_ManForEachPi(p, pObj, i)
Gia_Man_t * Gia_ManStart(int nObjsMax)
FUNCTION DEFINITIONS ///.
struct Gia_Obj_t_ Gia_Obj_t
void Gia_ManFillValue(Gia_Man_t *p)
struct Gia_Man_t_ Gia_Man_t
#define Gia_ManForEachObj1(p, pObj, i)
Gia_Man_t * Gia_ManCleanup(Gia_Man_t *p)
int Gia_ManHashAnd(Gia_Man_t *p, int iLit0, int iLit1)
#define Gia_ManForEachCo(p, pObj, i)
void Gia_ManHashStop(Gia_Man_t *p)
void Gia_ManPrintStats(Gia_Man_t *p, Gps_Par_t *pPars)
Gia_Man_t * Gia_ManDupAndCones(Gia_Man_t *p, int *pAnds, int nAnds, int fTrimPis)
typedefABC_NAMESPACE_HEADER_START struct Vec_Ptr_t_ Vec_Ptr_t
INCLUDES ///.
#define Vec_PtrForEachEntry(Type, vVec, pEntry, i)
MACRO DEFINITIONS ///.