48 FILE * pFile = fopen( pFileName,
"wb" );
50 printf(
"Cannot open file \"%s\" for writing.\n", pFileName );
58 fprintf( pFile,
"# PLA file written via PLA package in ABC on " );
60 fprintf( pFile,
"\n\n" );
62 fprintf( pFile,
".i %d\n", Pla_ManInNum(
p) );
63 fprintf( pFile,
".o %d\n", 1 );
64 fprintf( pFile,
".p %d\n", Vec_WecSize(&
p->vCubeLits) );
66 vStr = Vec_StrStart( Pla_ManInNum(
p) + 1 );
69 if ( !Vec_IntSize(vCube) )
71 for ( k = 0; k < Pla_ManInNum(
p); k++ )
72 Vec_StrWriteEntry( vStr, k,
'-' );
74 Vec_StrWriteEntry( vStr, Abc_Lit2Var(Lit), (
char)(Abc_LitIsCompl(Lit) ?
'0' :
'1') );
75 fprintf( pFile,
"%s 1\n", Vec_StrArray(vStr) );
78 fprintf( pFile,
".e\n\n" );
80 printf(
"Written file \"%s\".\n", pFileName );
86 int nVarsInit = Pla_ManDivNum(
p) ? Vec_IntCountZero(&
p->vDivs) : Pla_ManInNum(
p);
87 FILE * pFile = fopen( pFileName,
"wb" );
89 printf(
"Cannot open file \"%s\" for writing.\n", pFileName );
97 fprintf( pFile,
"# BLIF file written via PLA package in ABC on " );
99 fprintf( pFile,
"\n\n" );
101 fprintf( pFile,
".model %s\n", Pla_ManName(
p) );
102 fprintf( pFile,
".inputs" );
103 for ( i = 0; i < nVarsInit; i++ )
104 fprintf( pFile,
" i%d", i );
105 fprintf( pFile,
"\n" );
106 fprintf( pFile,
".outputs o" );
107 fprintf( pFile,
"\n" );
109 fprintf( pFile,
".names" );
110 for ( i = 0; i < Pla_ManInNum(
p); i++ )
111 fprintf( pFile,
" i%d", i );
112 fprintf( pFile,
" o\n" );
113 vStr = Vec_StrStart( Pla_ManInNum(
p) + 1 );
116 for ( k = 0; k < Pla_ManInNum(
p); k++ )
117 Vec_StrWriteEntry( vStr, k,
'-' );
119 Vec_StrWriteEntry( vStr, Abc_Lit2Var(Lit), (
char)(Abc_LitIsCompl(Lit) ?
'0' :
'1') );
120 fprintf( pFile,
"%s 1\n", Vec_StrArray(vStr) );
126 int pLits[3] = { (Div >> 2) & 0x3FF, (Div >> 12) & 0x3FF, (Div >> 22) & 0x3FF };
127 fprintf( pFile,
".names" );
128 fprintf( pFile,
" i%d", Abc_Lit2Var(pLits[0]) );
129 fprintf( pFile,
" i%d", Abc_Lit2Var(pLits[1]) );
130 if ( (Div & 3) == 3 )
131 fprintf( pFile,
" i%d", Abc_Lit2Var(pLits[2]) );
132 fprintf( pFile,
" i%d\n", i );
133 if ( (Div & 3) == 1 )
134 fprintf( pFile,
"%d%d 1\n", !Abc_LitIsCompl(pLits[0]), !Abc_LitIsCompl(pLits[1]) );
135 else if ( (Div & 3) == 2 )
137 assert( !Abc_LitIsCompl(pLits[0]) );
138 assert( !Abc_LitIsCompl(pLits[1]) );
139 fprintf( pFile,
"10 1\n01 1\n" );
141 else if ( (Div & 3) == 3 )
143 assert( !Abc_LitIsCompl(pLits[1]) );
144 assert( !Abc_LitIsCompl(pLits[2]) );
145 fprintf( pFile,
"%d-0 1\n-11 1\n", !Abc_LitIsCompl(pLits[0]) );
149 fprintf( pFile,
".end\n\n" );
151 printf(
"Written file \"%s\".\n", pFileName );
183 int i, v, iMint, iVar, nMints = (1 << nVars);
184 int nWords = Abc_Bit6WordNum( nMints );
185 Vec_Wrd_t * vCubes = Vec_WrdAlloc( 1000 );
189 Vec_Int_t * vStore = Vec_IntAlloc( 1000 );
192 for ( i = 0; i < nMints; i++ )
193 if ( Pla_TtGetBit(pOn, i) && !Pla_TtGetBit(pDc, i) )
199 Pla_TtSetBit(pDc, i);
202 Vec_IntPushTwo( vStore, i, -1 );
210 Pla_TtSetBit(pDc, i);
211 Pla_TtSetBit(pDc, i ^ (1 << pDirs[0]));
214 Vec_IntPushTwo( vStore, i, pDirs[0] );
217 if ( nDirs == 2 && Pla_TtGetBit(pOn, i ^ (1 << pDirs[0]) ^ (1 << pDirs[1])) )
220 Pla_TtSetBit(pDc, i);
221 Pla_TtSetBit(pDc, i ^ (1 << pDirs[0]));
222 Pla_TtSetBit(pDc, i ^ (1 << pDirs[1]));
223 Pla_TtSetBit(pDc, i ^ (1 << pDirs[0]) ^ (1 << pDirs[1]));
230 for ( i = 0; i < nMints; i++ )
231 if ( Pla_TtGetBit(pOn, i) && !Pla_TtGetBit(pDc, i) )
235 for ( v = 0; v < nDirs; v++ )
236 if ( Pla_TtGetBit(pOn, i ^ (1 << pDirs[v])) && !Pla_TtGetBit(pDc, i ^ (1 << pDirs[v])) )
242 Pla_TtSetBit(pDc, i);
243 Pla_TtSetBit(pDc, i ^ (1 << pDirs[v]));
246 Vec_IntPushTwo( vStore, i, pDirs[v] );
251 printf(
"Truth = %d. ", Pla_TtCountOnes(pOn,
nWords) );
252 printf(
"Cover = %d. ", Pla_TtCountOnes(pDc,
nWords) );
256 for ( i = 0; i < 16; i++ )
258 printf(
"%d=%d ", i, Count[i] );
262 for ( i = 0; i < 16; i++ )
264 printf(
"%d=%d ", i, Cubes[i] );
284 for ( v = 0; v < nVars; v++ )
288 if ( (iMint >> v) & 1 )
293 Vec_WrdPush( vCubes,
Cube );
295 Vec_IntFree( vStore );
307 sprintf( Buffer,
"primes%02d", nVars );
308 p = Pla_ManAlloc( Buffer, nVars, 1, Vec_WrdSize(vSop) );
309 Vec_WecInit( &
p->vCubeLits, Pla_ManCubeNum(
p) );
310 Vec_WecInit( &
p->vOccurs, 2*Pla_ManInNum(
p) );
316 Vec_WecPush( &
p->vCubeLits, i, Lit );
317 Vec_WecPush( &
p->vOccurs, Lit, i );
319 Vec_BitFree( vFunc );