46 int i, k, Count, nMints = ( 1 << nVars );
49 sprintf( Buffer,
"sorter%02d.pla", nVars );
50 pFile = fopen( Buffer,
"wb" );
51 fprintf( pFile,
"# This file was generated by ABC on %s.\n",
Extra_TimeStamp() );
52 fprintf( pFile,
".i %d\n", nVars );
53 fprintf( pFile,
".o %d\n", nVars );
54 fprintf( pFile,
".p %d\n", nMints-1 );
55 for ( i = 1; i < nMints; i++ )
58 for ( k = nVars-1; k >= 0; k-- )
60 Count += ((i >> k) & 1);
61 fprintf( pFile,
"%d", (i >> k) & 1 );
63 fprintf( pFile,
" " );
64 for ( k = 0; k < Count; k++ )
65 fprintf( pFile,
"1" );
66 for ( ; k < nVars; k++ )
67 fprintf( pFile,
"0" );
68 fprintf( pFile,
"\n" );
70 fprintf( pFile,
".end\n" );
87 int i, n, nBits = 1 << nVars;
88 Vec_Bit_t * vMap = Vec_BitStartFull( Abc_MaxInt(64, nBits) );
89 for ( i = nBits; i < 64; i++ )
90 Vec_BitWriteEntry( vMap, i, 0 );
91 Vec_BitShrink( vMap, nBits );
92 Vec_BitWriteEntry( vMap, 0, 0 );
93 Vec_BitWriteEntry( vMap, 1, 0 );
94 for ( n = 2; n < nBits; n++ )
95 if ( Vec_BitEntry(vMap, n) )
96 for ( i = 2*n; i < nBits; i += n )
97 Vec_BitWriteEntry( vMap, i, 0 );
102 int n, nBits = ( 1 << nVars );
103 Vec_Int_t * vPrimes = Vec_IntAlloc( 1000 );
105 for ( n = 2; n < nBits; n++ )
106 if ( Vec_BitEntry(vMap, n) )
107 Vec_IntPush( vPrimes, n );
108 printf(
"Primes up to 2^%d = %d\n", nVars, Vec_IntSize(vPrimes) );
115 Pla_Man_t *
p = Pla_ManAlloc( pName, nVars, 1, Vec_IntSize(vMints) );
120 Mint = Vec_IntEntry(vMints, i);
133 sprintf( pName,
"primes%02d", nVars );
135 Vec_IntFree( vMints );
153 Vec_Bit_t * vBits = Vec_BitStart( 1 << nVars );
154 assert( nVars > 0 && nVars <= 30 );
155 assert( nNums > 0 && nNums < (1 << (nVars - 1)) );
156 while ( Count < nNums )
159 if ( fNonZero && Mint == 0 )
161 if ( Vec_BitEntry(vBits, Mint) )
163 Vec_BitWriteEntry( vBits, Mint, 1 );
175 sprintf( Buffer,
"%s_%d_%d_%d",
"rand", nInputs, nOutputs, nCubes );
176 p = Pla_ManAlloc( Buffer, nInputs, nOutputs, nCubes );
179 for ( i = Count = 0; i < Vec_BitSize(vBits); i++ )
180 if ( Vec_BitEntry(vBits, i) )
182 pCube = Pla_CubeIn(
p, Count++ );
183 for ( k = 0; k < nInputs; k++ )
186 assert( Count == nCubes );
187 Vec_BitFree( vBits );
192 for ( i = Count = 0; i < Vec_BitSize(vBits); i++ )
193 if ( Vec_BitEntry(vBits, i) )
195 pCube = Pla_CubeOut(
p, Count++ );
196 for ( k = 0; k < nOutputs; k++ )
199 assert( Count == nCubes );
200 Vec_BitFree( vBits );
224 word * pCube;
int i, k, Lit, Count;
225 Vec_WecClear( &
p->vCubeLits );
226 Vec_WecClear( &
p->vOccurs );
227 Vec_WecInit( &
p->vCubeLits, Pla_ManCubeNum(
p) );
228 Vec_WecInit( &
p->vOccurs, 2*Pla_ManInNum(
p) );
231 vCube = Vec_WecEntry( &
p->vCubeLits, i );
237 Vec_IntGrow( vCube, Count );
244 Vec_WecPush( &
p->vCubeLits, i, Lit );
246 Vec_WecPush( &
p->vOccurs, Lit, i );
248 assert( Vec_IntSize(vCube) == Vec_IntCap(vCube) );
254 Vec_IntFillNatural( &
p->vCubes, Vec_WecSize(&
p->vCubeLits) );
255 Vec_WrdFill( &
p->vInBits, Pla_ManCubeNum(
p) *
p->nInWords, 0 );
274 word * pCube1, * pCube2;
275 int i, k,
Dist, Count = 0;
279 Dist = Pla_CubesAreDistance1( pCube1, pCube2,
p->nInWords );
281 Count += (
Dist == 1);
289 printf(
"Found %d pairs among %d cubes using cube pair enumeration. ", Count, Pla_ManCubeNum(
p) );
290 Abc_PrintTime( 1,
"Time", Abc_Clock() - clk );
#define ABC_NAMESPACE_IMPL_START
#define ABC_NAMESPACE_IMPL_END
typedefABC_NAMESPACE_IMPL_START struct Vec_Int_t_ Vec_Int_t
DECLARATIONS ///.
unsigned Gia_ManRandom(int fReset)
FUNCTION DEFINITIONS ///.
unsigned __int64 word
DECLARATIONS ///.
void Pla_ManConvertToBits(Pla_Man_t *p)
void Pla_ManConvertFromBits(Pla_Man_t *p)
Pla_Man_t * Pla_GenFromMinterms(char *pName, Vec_Int_t *vMints, int nVars)
ABC_NAMESPACE_IMPL_START void Pla_GenSorter(int nVars)
DECLARATIONS ///.
Vec_Bit_t * Pla_GenRandom(int nVars, int nNums, int fNonZero)
Pla_Man_t * Pla_ManGenerate(int nInputs, int nOutputs, int nCubes, int fVerbose)
int Pla_ManDist1Num(Pla_Man_t *p)
Vec_Int_t * Pla_GenPrimes(int nVars)
Pla_Man_t * Pla_ManPrimesDetector(int nVars)
Vec_Bit_t * Pla_ManPrimesTable(int nVars)
int Pla_ManDist1NumTest(Pla_Man_t *p)
#define Pla_ForEachCubeIn(p, pCube, i)
MACRO DEFINITIONS ///.
#define Pla_CubeForEachLitIn(p, pCube, Lit, i)
#define Pla_ForEachCubeOut(p, pCube, i)
#define Pla_ForEachCubeInStart(p, pCube, i, Start)
struct Pla_Man_t_ Pla_Man_t
typedefABC_NAMESPACE_HEADER_START struct Vec_Bit_t_ Vec_Bit_t
INCLUDES ///.
#define Vec_IntForEachEntry(vVec, Entry, i)
MACRO DEFINITIONS ///.
#define Vec_WecForEachLevel(vGlob, vVec, i)
MACRO DEFINITIONS ///.