21#ifndef ABC__base__wlc__wlc_h
22#define ABC__base__wlc__wlc_h
39#define MASK55 ABC_CONST(0x5555555555555555)
82static inline char * Pla_ManName(
Pla_Man_t *
p ) {
return p->pName; }
83static inline int Pla_ManInNum(
Pla_Man_t *
p ) {
return p->nIns; }
84static inline int Pla_ManOutNum(
Pla_Man_t *
p ) {
return p->nOuts; }
85static inline int Pla_ManCubeNum(
Pla_Man_t *
p ) {
return Vec_IntSize( &
p->vCubes ); }
86static inline int Pla_ManDivNum(
Pla_Man_t *
p ) {
return Vec_IntSize( &
p->vDivs ); }
88static inline word * Pla_CubeIn(
Pla_Man_t *
p,
int i ) {
return Vec_WrdEntryP(&
p->vInBits, i *
p->nInWords); }
89static inline word * Pla_CubeOut(
Pla_Man_t *
p,
int i ) {
return Vec_WrdEntryP(&
p->vOutBits, i *
p->nOutWords); }
91static inline int Pla_CubeNum(
int hCube ) {
return hCube >> 8; }
92static inline int Pla_CubeLit(
int hCube ) {
return hCube & 0xFF; }
93static inline int Pla_CubeHandle(
int iCube,
int iLit ) {
assert( !(iCube >> 24) && !(iLit >> 8) );
return iCube << 8 | iLit; }
96static inline int Pla_TtGetBit(
word *
p,
int i ) {
return (
int)(
p[i>>6] >> (i & 63)) & 1; }
97static inline void Pla_TtSetBit(
word *
p,
int i ) {
p[i>>6] |= (((
word)1)<<(i & 63)); }
98static inline void Pla_TtXorBit(
word *
p,
int i ) {
p[i>>6] ^= (((
word)1)<<(i & 63)); }
101static inline int Pla_CubeGetLit(
word *
p,
int i ) {
return (
int)(
p[i>>5] >> ((i<<1) & 63)) & 3; }
102static inline void Pla_CubeSetLit(
word *
p,
int i,
Pla_Lit_t d ) {
p[i>>5] |= (((
word)d)<<((i<<1) & 63)); }
103static inline void Pla_CubeXorLit(
word *
p,
int i,
Pla_Lit_t d ) {
p[i>>5] ^= (((
word)d)<<((i<<1) & 63)); }
114#define Pla_ForEachCubeIn( p, pCube, i ) \
115 for ( i = 0; (i < Pla_ManCubeNum(p)) && (((pCube) = Pla_CubeIn(p, i)), 1); i++ )
116#define Pla_ForEachCubeInStart( p, pCube, i, Start ) \
117 for ( i = Start; (i < Pla_ManCubeNum(p)) && (((pCube) = Pla_CubeIn(p, i)), 1); i++ )
119#define Pla_ForEachCubeOut( p, pCube, i ) \
120 for ( i = 0; (i < Pla_ManCubeNum(p)) && (((pCube) = Pla_CubeOut(p, i)), 1); i++ )
121#define Pla_ForEachCubeInOut( p, pCubeIn, pCubeOut, i ) \
122 for ( i = 0; (i < Pla_ManCubeNum(p)) && (((pCubeIn) = Pla_CubeIn(p, i)), 1) && (((pCubeOut) = Pla_CubeOut(p, i)), 1); i++ )
124#define Pla_CubeForEachLit( nVars, pCube, Lit, i ) \
125 for ( i = 0; (i < nVars) && (((Lit) = Pla_CubeGetLit(pCube, i)), 1); i++ )
126#define Pla_CubeForEachLitIn( p, pCube, Lit, i ) \
127 Pla_CubeForEachLit( Pla_ManInNum(p), pCube, Lit, i )
128#define Pla_CubeForEachLitOut( p, pCube, Lit, i ) \
129 Pla_CubeForEachLit( Pla_ManOutNum(p), pCube, Lit, i )
147static inline int Pla_OnlyOneOne(
word t )
149 return t ? ((t & (t-1)) == 0) : 0;
151static inline int Pla_CubesAreDistance1(
word *
p,
word * q,
int nWords )
153 word Test;
int c, fFound = 0;
154 for ( c = 0; c <
nWords; c++ )
161 Test = ((
p[c] ^ q[c]) | ((
p[c] ^ q[c]) >> 1)) &
MASK55;
162 if ( !Pla_OnlyOneOne(Test) )
168static inline int Pla_CubesAreConsensus(
word *
p,
word * q,
int nWords,
int * piVar )
170 word Test;
int c, fFound = 0;
171 for ( c = 0; c <
nWords; c++ )
178 Test = ((
p[c] ^ q[c]) & ((
p[c] ^ q[c]) >> 1)) &
MASK55;
179 if ( !Pla_OnlyOneOne(Test) )
182 if ( piVar ) *piVar = c * 32 + Abc_Tt6FirstBit(Test)/2;
186static inline int Pla_TtCountOnesOne(
word x )
188 x = x - ((x >> 1) &
ABC_CONST(0x5555555555555555));
190 x = (x + (x >> 4)) &
ABC_CONST(0x0F0F0F0F0F0F0F0F);
194 return (
int)(x & 0xFF);
196static inline int Pla_TtCountOnes(
word *
p,
int nWords )
199 for ( i = 0; i <
nWords; i++ )
200 Count += Pla_TtCountOnesOne(
p[i] );
215static inline Pla_Man_t * Pla_ManAlloc(
char * pFileName,
int nIns,
int nOuts,
int nCubes )
219 p->pSpec = Abc_UtilStrsav( pFileName );
222 p->nInWords = Abc_Bit6WordNum( 2*nIns );
223 p->nOutWords = Abc_Bit6WordNum( 2*nOuts );
224 Vec_IntFillNatural( &
p->vCubes, nCubes );
225 Vec_WrdFill( &
p->vInBits, Pla_ManCubeNum(
p) *
p->nInWords, 0 );
226 Vec_WrdFill( &
p->vOutBits, Pla_ManCubeNum(
p) *
p->nOutWords, 0 );
229static inline void Pla_ManFree(
Pla_Man_t *
p )
231 Vec_IntErase( &
p->vCubes );
232 Vec_IntErase( &
p->vHashes );
233 Vec_WrdErase( &
p->vInBits );
234 Vec_WrdErase( &
p->vOutBits );
235 Vec_WecErase( &
p->vCubeLits );
236 Vec_WecErase( &
p->vOccurs );
237 Vec_IntErase( &
p->vDivs );
242static inline int Pla_ManLitInNum(
Pla_Man_t *
p )
244 word * pCube;
int i, k, Lit, Count = 0;
250static inline int Pla_ManLitOutNum(
Pla_Man_t *
p )
252 word * pCube;
int i, k, Lit, Count = 0;
258static inline void Pla_ManPrintStats(
Pla_Man_t *
p,
int fVerbose )
260 printf(
"%-16s : ", Pla_ManName(
p) );
261 printf(
"In =%4d ", Pla_ManInNum(
p) );
262 printf(
"Out =%4d ", Pla_ManOutNum(
p) );
263 printf(
"Cube =%8d ", Pla_ManCubeNum(
p) );
264 printf(
"LitIn =%8d ", Pla_ManLitInNum(
p) );
265 printf(
"LitOut =%8d ", Pla_ManLitOutNum(
p) );
266 printf(
"Div =%6d ", Pla_ManDivNum(
p) );
#define ABC_CALLOC(type, num)
#define ABC_CONST(number)
PARAMETERS ///.
#define ABC_NAMESPACE_HEADER_END
#define ABC_NAMESPACE_HEADER_START
NAMESPACES ///.
typedefABC_NAMESPACE_IMPL_START struct Vec_Int_t_ Vec_Int_t
DECLARATIONS ///.
unsigned __int64 word
DECLARATIONS ///.
int Pla_ManDist1Merge(Pla_Man_t *p)
DECLARATIONS ///.
#define Pla_ForEachCubeIn(p, pCube, i)
MACRO DEFINITIONS ///.
#define MASK55
INCLUDES ///.
Pla_File_t
BASIC TYPES ///.
void Pla_ManComputeDist1Test(Pla_Man_t *p)
#define Pla_CubeForEachLitIn(p, pCube, Lit, i)
#define Pla_CubeForEachLitOut(p, pCube, Lit, i)
void Pla_ManConvertToBits(Pla_Man_t *p)
void Pla_ManConvertFromBits(Pla_Man_t *p)
#define Pla_ForEachCubeOut(p, pCube, i)
int Pla_ManFxPerformSimple(int nVars)
Pla_Man_t * Pla_ReadPla(char *pFileName)
struct Pla_Man_t_ Pla_Man_t
void Pla_WritePla(Pla_Man_t *p, char *pFileName)
Pla_Man_t * Pla_ManGenerate(int nIns, int nOuts, int nCubes, int fVerbose)
Pla_Man_t * Pla_ManPrimesDetector(int nVars)
Vec_Bit_t * Pla_ManPrimesTable(int nVars)
int Pla_ManDist1NumTest(Pla_Man_t *p)
int Pla_ManHashDist1NumTest(Pla_Man_t *p)
typedefABC_NAMESPACE_HEADER_START struct Vec_Bit_t_ Vec_Bit_t
INCLUDES ///.
typedefABC_NAMESPACE_HEADER_START struct Vec_Wec_t_ Vec_Wec_t
INCLUDES ///.
typedefABC_NAMESPACE_HEADER_START struct Vec_Wrd_t_ Vec_Wrd_t
INCLUDES ///.