31 #define KIT_ISOP_MEM_LIMIT (1<<20)
61 assert( nVars >= 0 && nVars <= 16 );
70 if ( pcRes->nCubes == -1 )
76 if ( pcRes->nCubes == 0 || (pcRes->nCubes == 1 && pcRes->pCubes[0] == 0) )
78 vMemory->pArray[0] = 0;
87 if ( pcRes2->nCubes >= 0 )
90 if ( pcRes->nCubes > pcRes2->nCubes || (pcRes->nCubes == pcRes2->nCubes && pcRes->nLits > pcRes2->nLits) )
100 memmove( vMemory->pArray, pcRes->pCubes, pcRes->nCubes *
sizeof(
unsigned) );
106 int i, k, Entry, Literal;
114 for ( k = 0; k < nVars; k++ )
116 Literal = 3 & (Entry >> (k << 1));
119 else if ( Literal == 2 )
121 else if ( Literal == 0 )
125 printf(
" %d\n", !fCompl );
130 int fCompl =
Kit_TruthIsop( puTruth, nVars, vCover, fTryBoth );
148 Kit_Sop_t * pcRes0 = &cRes0, * pcRes1 = &cRes1, * pcRes2 = &cRes2;
149 unsigned * puRes0, * puRes1, * puRes2;
150 unsigned * puOn0, * puOn1, * puOnDc0, * puOnDc1, * pTemp, * pTemp0, * pTemp1;
166 pcRes->pCubes = NULL;
175 if ( pcRes->pCubes == NULL )
180 pcRes->pCubes[0] = 0;
186 for ( Var = nVars-1; Var >= 0; Var-- )
195 for ( i = 0; i < nWordsAll; i++ )
202 puOn0 = puOn; puOn1 = puOn +
nWords;
203 puOnDc0 = puOnDc; puOnDc1 = puOnDc +
nWords;
204 pTemp0 = pTemp; pTemp1 = pTemp +
nWords;
208 if ( pcRes0->nCubes == -1 )
215 if ( pcRes1->nCubes == -1 )
225 if ( pcRes2->nCubes == -1 )
231 pcRes->nLits = pcRes0->nLits + pcRes1->nLits + pcRes2->nLits + pcRes0->nCubes + pcRes1->nCubes;
232 pcRes->nCubes = pcRes0->nCubes + pcRes1->nCubes + pcRes2->nCubes;
234 if ( pcRes->pCubes == NULL )
240 for ( i = 0; i < pcRes0->nCubes; i++ )
241 pcRes->pCubes[k++] = pcRes0->pCubes[i] | (1 << ((Var<<1)+0));
242 for ( i = 0; i < pcRes1->nCubes; i++ )
243 pcRes->pCubes[k++] = pcRes1->pCubes[i] | (1 << ((Var<<1)+1));
244 for ( i = 0; i < pcRes2->nCubes; i++ )
245 pcRes->pCubes[k++] = pcRes2->pCubes[i];
246 assert( k == pcRes->nCubes );
252 for ( i = 1; i < nWordsAll/
nWords; i++ )
253 for ( k = 0; k <
nWords; k++ )
254 pTemp[i*nWords + k] = pTemp[k];
274 unsigned uMasks[5] = { 0xAAAAAAAA, 0xCCCCCCCC, 0xF0F0F0F0, 0xFF00FF00, 0xFFFF0000 };
276 Kit_Sop_t * pcRes0 = &cRes0, * pcRes1 = &cRes1, * pcRes2 = &cRes2;
277 unsigned uOn0, uOn1, uOnDc0, uOnDc1, uRes0, uRes1, uRes2;
280 assert( (uOn & ~uOnDc) == 0 );
285 pcRes->pCubes = NULL;
288 if ( uOnDc == 0xFFFFFFFF )
293 if ( pcRes->pCubes == NULL )
298 pcRes->pCubes[0] = 0;
303 for ( Var = nVars-1; Var >= 0; Var-- )
310 uOnDc0 = uOnDc1 = uOnDc;
317 if ( pcRes0->nCubes == -1 )
323 if ( pcRes1->nCubes == -1 )
328 uRes2 =
Kit_TruthIsop5_rec( (uOn0 & ~uRes0) | (uOn1 & ~uRes1), uOnDc0 & uOnDc1, Var, pcRes2, vStore );
329 if ( pcRes2->nCubes == -1 )
335 pcRes->nLits = pcRes0->nLits + pcRes1->nLits + pcRes2->nLits + pcRes0->nCubes + pcRes1->nCubes;
336 pcRes->nCubes = pcRes0->nCubes + pcRes1->nCubes + pcRes2->nCubes;
338 if ( pcRes->pCubes == NULL )
344 for ( i = 0; i < pcRes0->nCubes; i++ )
345 pcRes->pCubes[k++] = pcRes0->pCubes[i] | (1 << ((Var<<1)+0));
346 for ( i = 0; i < pcRes1->nCubes; i++ )
347 pcRes->pCubes[k++] = pcRes1->pCubes[i] | (1 << ((Var<<1)+1));
348 for ( i = 0; i < pcRes2->nCubes; i++ )
349 pcRes->pCubes[k++] = pcRes2->pCubes[i];
350 assert( k == pcRes->nCubes );
352 uRes2 |= (uRes0 & ~uMasks[
Var]) | (uRes1 & uMasks[Var]);
static int Kit_TruthWordNum(int nVars)
void Kit_TruthCofactor0(unsigned *pTruth, int nVars, int iVar)
static void Kit_TruthFill(unsigned *pOut, int nVars)
typedefABC_NAMESPACE_IMPL_START struct Vec_Int_t_ Vec_Int_t
DECLARATIONS ///.
static unsigned Kit_TruthIsop5_rec(unsigned uOn, unsigned uOnDc, int nVars, Kit_Sop_t *pcRes, Vec_Int_t *vStore)
void Kit_TruthIsopPrintCover(Vec_Int_t *vCover, int nVars, int fCompl)
#define KIT_ISOP_MEM_LIMIT
DECLARATIONS ///.
static int Kit_TruthIsEqual(unsigned *pIn0, unsigned *pIn1, int nVars)
static int Kit_TruthIsConst0(unsigned *pIn, int nVars)
void Kit_TruthIsopPrint(unsigned *puTruth, int nVars, Vec_Int_t *vCover, int fTryBoth)
static unsigned * Vec_IntFetch(Vec_Int_t *p, int nWords)
static void Kit_TruthAnd(unsigned *pOut, unsigned *pIn0, unsigned *pIn1, int nVars)
static void Vec_IntGrow(Vec_Int_t *p, int nCapMin)
static int Kit_TruthIsConst1(unsigned *pIn, int nVars)
void Kit_TruthCofactor1(unsigned *pTruth, int nVars, int iVar)
static int Vec_IntEntry(Vec_Int_t *p, int i)
#define ABC_NAMESPACE_IMPL_END
int Kit_TruthIsop(unsigned *puTruth, int nVars, Vec_Int_t *vMemory, int fTryBoth)
FUNCTION DEFINITIONS ///.
static void Kit_TruthNot(unsigned *pOut, unsigned *pIn, int nVars)
#define ABC_NAMESPACE_IMPL_START
static void Kit_TruthSharp(unsigned *pOut, unsigned *pIn0, unsigned *pIn1, int nVars)
typedefABC_NAMESPACE_HEADER_START struct Kit_Sop_t_ Kit_Sop_t
INCLUDES ///.
static int Vec_IntSize(Vec_Int_t *p)
static unsigned * Kit_TruthIsop_rec(unsigned *puOn, unsigned *puOnDc, int nVars, Kit_Sop_t *pcRes, Vec_Int_t *vStore)
static void Vec_IntShrink(Vec_Int_t *p, int nSizeNew)
int Kit_TruthVarInSupport(unsigned *pTruth, int nVars, int iVar)
static void Vec_IntClear(Vec_Int_t *p)
#define Vec_IntForEachEntry(vVec, Entry, i)
MACRO DEFINITIONS ///.
static void Kit_TruthClear(unsigned *pOut, int nVars)
static void Kit_TruthOr(unsigned *pOut, unsigned *pIn0, unsigned *pIn1, int nVars)