ABC: A System for Sequential Synthesis and Verification
 
Loading...
Searching...
No Matches
dauCanon.c File Reference
#include "dauInt.h"
#include "misc/util/utilTruth.h"
#include "misc/vec/vecMem.h"
#include "bool/lucky/lucky.h"
#include <math.h>
Include dependency graph for dauCanon.c:

Go to the source code of this file.

Classes

struct  Abc_TtHieMan_t_
 
struct  TiedGroup_
 
struct  Abc_TgMan_t_
 
struct  Abc_SccCost_t_
 

Macros

#define TT_MAX_LEVELS   5
 
#define CANON_VERIFY
 

Typedefs

typedef struct TiedGroup_ TiedGroup
 
typedef struct Abc_TgMan_t_ Abc_TgMan_t
 
typedef struct Abc_SccCost_t_ Abc_SccCost_t
 

Functions

void Abc_TtNormalizeSmallTruth (word *pTruth, int nVars)
 
int Abc_TtCountOnesInCofsSimple (word *pTruth, int nVars, int *pStore)
 
int Abc_TtScc (word *pTruth, int nVars)
 
int Abc_TtCountOnesInCofsFast6_rec (word Truth, int iVar, int nBytes, int *pStore)
 
int Abc_TtCountOnesInCofsFast_rec (word *pTruth, int iVar, int nWords, int *pStore)
 
int Abc_TtCountOnesInCofsFast (word *pTruth, int nVars, int *pStore)
 
void Abc_TtCofactorTest10 (word *pTruth, int nVars, int N)
 
int Abc_Tt6CofactorPermNaive (word *pTruth, int i, int fSwapOnly)
 
int Abc_TtCofactorPermNaive (word *pTruth, int i, int nWords, int fSwapOnly)
 
int Abc_TtCofactorPermConfig (word *pTruth, int i, int nWords, int fSwapOnly, int fNaive)
 
int Abc_TtCofactorPerm (word *pTruth, int i, int nWords, int fSwapOnly, char *pCanonPerm, unsigned *puCanonPhase, int fNaive)
 
unsigned Abc_TtCanonicize (word *pTruth, int nVars, char *pCanonPerm)
 FUNCTION DECLARATIONS ///.
 
unsigned Abc_TtCanonicizePerm (word *pTruth, int nVars, char *pCanonPerm)
 
unsigned Abc_TtCanonicizePhase (word *pTruth, int nVars)
 
Abc_TtHieMan_tAbc_TtHieManStart (int nVars, int nLevels)
 
void Abc_TtHieManStop (Abc_TtHieMan_t *p)
 
int Abc_TtHieRetrieveOrInsert (Abc_TtHieMan_t *p, int level, word *pTruth, word *pResult)
 
unsigned Abc_TtCanonicizeHie (Abc_TtHieMan_t *p, word *pTruthInit, int nVars, char *pCanonPerm, int fExact)
 
unsigned Abc_TtCanonicizeWrap (TtCanonicizeFunc func, Abc_TtHieMan_t *p, word *pTruth, int nVars, char *pCanonPerm, int flag)
 
int Abc_TgExpendSymmetry (Abc_TgMan_t *pMan, char *pDest)
 
unsigned Abc_TtCanonicizeAda (Abc_TtHieMan_t *p, word *pTruth, int nVars, char *pCanonPerm, int iThres)
 
unsigned Abc_TtCanonicizeCA (Abc_TtHieMan_t *p, word *pTruth, int nVars, char *pCanonPerm, int fCA)
 

Variables

word gpVerCopy [1024]
 

Macro Definition Documentation

◆ CANON_VERIFY

#define CANON_VERIFY

Definition at line 1495 of file dauCanon.c.

◆ TT_MAX_LEVELS

#define TT_MAX_LEVELS   5

Function*************************************************************

Synopsis [Hierarchical semi-canonical form computation.]

Description []

SideEffects []

SeeAlso []

Definition at line 1243 of file dauCanon.c.

Typedef Documentation

◆ Abc_SccCost_t

typedef struct Abc_SccCost_t_ Abc_SccCost_t

◆ Abc_TgMan_t

typedef struct Abc_TgMan_t_ Abc_TgMan_t

◆ TiedGroup

typedef struct TiedGroup_ TiedGroup

Function*************************************************************

Synopsis [Adaptive exact/semi-canonical form computation.]

Description []

SideEffects []

SeeAlso []

Function Documentation

◆ Abc_TgExpendSymmetry()

int Abc_TgExpendSymmetry ( Abc_TgMan_t * pMan,
char * pDest )
extern

Definition at line 1980 of file dauCanon.c.

1981{
1982 int i = 0, j, k, s;
1983 char * pPerm = pMan->pPerm;
1984 for (j = 0; j < pMan->nGVars; j++)
1985 for (k = pPerm[j]; k >= 0; k = pMan->symLink[k])
1986 pDest[i++] = k;
1987 s = i;
1988 for (k = pMan->symLink[pMan->nVars]; k >= 0; k = pMan->symLink[k])
1989 pDest[i++] = k;
1990 assert(i == pMan->nVars);
1991 return s;
1992}
char pPerm[16]
Definition dauCanon.c:1480
signed char symLink[17]
Definition dauCanon.c:1487
#define assert(ex)
Definition util_old.h:213
Here is the caller graph for this function:

◆ Abc_Tt6CofactorPermNaive()

int Abc_Tt6CofactorPermNaive ( word * pTruth,
int i,
int fSwapOnly )

Function*************************************************************

Synopsis [Naive evaluation.]

Description []

SideEffects []

SeeAlso []

Definition at line 740 of file dauCanon.c.

741{
742 if ( fSwapOnly )
743 {
744 word Copy = Abc_Tt6SwapAdjacent( pTruth[0], i );
745 if ( pTruth[0] > Copy )
746 {
747 pTruth[0] = Copy;
748 return 4;
749 }
750 return 0;
751 }
752 {
753 word Copy = pTruth[0];
754 word Best = pTruth[0];
755 int Config = 0;
756 // PXY
757 // 001
758 Copy = Abc_Tt6Flip( Copy, i );
759 if ( Best > Copy )
760 Best = Copy, Config = 1;
761 // PXY
762 // 011
763 Copy = Abc_Tt6Flip( Copy, i+1 );
764 if ( Best > Copy )
765 Best = Copy, Config = 3;
766 // PXY
767 // 010
768 Copy = Abc_Tt6Flip( Copy, i );
769 if ( Best > Copy )
770 Best = Copy, Config = 2;
771 // PXY
772 // 110
773 Copy = Abc_Tt6SwapAdjacent( Copy, i );
774 if ( Best > Copy )
775 Best = Copy, Config = 6;
776 // PXY
777 // 111
778 Copy = Abc_Tt6Flip( Copy, i+1 );
779 if ( Best > Copy )
780 Best = Copy, Config = 7;
781 // PXY
782 // 101
783 Copy = Abc_Tt6Flip( Copy, i );
784 if ( Best > Copy )
785 Best = Copy, Config = 5;
786 // PXY
787 // 100
788 Copy = Abc_Tt6Flip( Copy, i+1 );
789 if ( Best > Copy )
790 Best = Copy, Config = 4;
791 // PXY
792 // 000
793 Copy = Abc_Tt6SwapAdjacent( Copy, i );
794 assert( Copy == pTruth[0] );
795 assert( Best <= pTruth[0] );
796 pTruth[0] = Best;
797 return Config;
798 }
799}
unsigned __int64 word
DECLARATIONS ///.
Definition kitPerm.c:36
Here is the caller graph for this function:

◆ Abc_TtCanonicize()

unsigned Abc_TtCanonicize ( word * pTruth,
int nVars,
char * pCanonPerm )

FUNCTION DECLARATIONS ///.

Function*************************************************************

Synopsis [Semi-canonical form computation.]

Description []

SideEffects []

SeeAlso []

Definition at line 1036 of file dauCanon.c.

1037{
1038 int pStoreIn[17];
1039 unsigned uCanonPhase;
1040 int i, k, nWords = Abc_TtWordNum( nVars );
1041 int fNaive = 1;
1042
1043#ifdef CANON_VERIFY
1044 char pCanonPermCopy[16];
1045 static word pCopy1[1024];
1046 static word pCopy2[1024];
1047 Abc_TtCopy( pCopy1, pTruth, nWords, 0 );
1048#endif
1049
1050 uCanonPhase = Abc_TtSemiCanonicize( pTruth, nVars, pCanonPerm, pStoreIn, 0 );
1051 for ( k = 0; k < 5; k++ )
1052 {
1053 int fChanges = 0;
1054 for ( i = nVars - 2; i >= 0; i-- )
1055 if ( pStoreIn[i] == pStoreIn[i+1] )
1056 fChanges |= Abc_TtCofactorPerm( pTruth, i, nWords, pStoreIn[i] != pStoreIn[nVars]/2, pCanonPerm, &uCanonPhase, fNaive );
1057 if ( !fChanges )
1058 break;
1059 fChanges = 0;
1060 for ( i = 1; i < nVars - 1; i++ )
1061 if ( pStoreIn[i] == pStoreIn[i+1] )
1062 fChanges |= Abc_TtCofactorPerm( pTruth, i, nWords, pStoreIn[i] != pStoreIn[nVars]/2, pCanonPerm, &uCanonPhase, fNaive );
1063 if ( !fChanges )
1064 break;
1065 }
1066
1067#ifdef CANON_VERIFY
1068 Abc_TtCopy( pCopy2, pTruth, nWords, 0 );
1069 memcpy( pCanonPermCopy, pCanonPerm, sizeof(char) * nVars );
1070 Abc_TtImplementNpnConfig( pCopy2, nVars, pCanonPermCopy, uCanonPhase );
1071 if ( !Abc_TtEqual( pCopy1, pCopy2, nWords ) )
1072 printf( "Canonical form verification failed!\n" );
1073#endif
1074/*
1075 if ( !Abc_TtEqual( pCopy1, pCopy2, nWords ) )
1076 {
1077 Kit_DsdPrintFromTruth( pCopy1, nVars ); printf( "\n" );
1078 Kit_DsdPrintFromTruth( pCopy2, nVars ); printf( "\n" );
1079 i = 0;
1080 }
1081*/
1082 return uCanonPhase;
1083}
int nWords
Definition abcNpn.c:127
int Abc_TtCofactorPerm(word *pTruth, int i, int nWords, int fSwapOnly, char *pCanonPerm, unsigned *puCanonPhase, int fNaive)
Definition dauCanon.c:978
char * memcpy()
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Abc_TtCanonicizeAda()

unsigned Abc_TtCanonicizeAda ( Abc_TtHieMan_t * p,
word * pTruth,
int nVars,
char * pCanonPerm,
int iThres )

Function*************************************************************

Synopsis [Adaptive heuristic/exact canonical form computation.]

Description []

SideEffects []

SeeAlso []

Definition at line 2573 of file dauCanon.c.

2574{
2575 int nWords = Abc_TtWordNum(nVars);
2576 unsigned fExac = 0, fHash = 1 << 29;
2577 static word pCopy[1024];
2578 Abc_TgMan_t tgMan, tgManCopy;
2579 int iCost;
2580 const int MaxCost = 84; // maximun posible cost for function with 16 inputs
2581 const int nAlg = iThres >= 1000 ? 1 : 0;
2582 const int fHigh = (iThres % 1000) >= 100, nEnumThres = iThres % 100;
2583
2584 // handle constant
2585 if ( nVars == 0 ) {
2586 Abc_TtClear( pTruth, nWords );
2587 return 0;
2588 }
2589
2590 Abc_TtVerifySmallTruth(pTruth, nVars);
2591#ifdef CANON_VERIFY
2592 Abc_TtCopy(gpVerCopy, pTruth, nWords, 0);
2593#endif
2594
2595 assert(nVars <= 16);
2596 assert(!(nAlg && p == NULL));
2597 if (p && Abc_TtHieRetrieveOrInsert(p, -5, pTruth, pTruth) > 0) return fHash;
2598 Abc_TgInitMan(&tgMan, pTruth, nVars, nAlg, p ? p->vPhase : NULL);
2599 Abc_TgCreateGroups(&tgMan);
2600 if (p && Abc_TtHieRetrieveOrInsert(p, -4, pTruth, pTruth) > 0) return fHash;
2601 Abc_TgPurgeSymmetry(&tgMan, fHigh);
2602
2603 Abc_TgExpendSymmetry(&tgMan, pCanonPerm);
2604 Abc_TgImplementPerm(&tgMan, pCanonPerm);
2605 assert(Abc_TgCannonVerify(&tgMan));
2606
2607 iCost = Abc_TgEnumerationCost(&tgMan);
2608 if (p == NULL || p->nLastLevel == 0) {
2609 if (nEnumThres > MaxCost || iCost < nEnumThres) {
2610 Abc_TgManCopy(&tgManCopy, pCopy, &tgMan);
2611 Abc_TgFullEnumeration(&tgManCopy, &tgMan);
2612 }
2613 else
2614 Abc_TgSimpleEnumeration(&tgMan);
2615 }
2616 else {
2617 if (nEnumThres > MaxCost || iCost < nEnumThres) fExac = 1 << 30;
2618 if (Abc_TtHieRetrieveOrInsert(p, -3, pTruth, pTruth) > 0) return fHash + fExac;
2619 Abc_TgManCopy(&tgManCopy, pCopy, &tgMan);
2620 Abc_TgSimpleEnumeration(&tgMan);
2621 if (Abc_TtHieRetrieveOrInsert(p, -2, pTruth, pTruth) > 0) return fHash + fExac;
2622 if (fExac) {
2623 Abc_TgManCopy(&tgMan, pTruth, &tgManCopy);
2624 Abc_TgFullEnumeration(&tgManCopy, &tgMan);
2625 }
2626 Abc_TtHieRetrieveOrInsert(p, -1, pTruth, pTruth);
2627 }
2628 memcpy(pCanonPerm, tgMan.pPermT, sizeof(char) * nVars);
2629
2630#ifdef CANON_VERIFY
2631 if (!Abc_TgCannonVerify(&tgMan))
2632 printf("Canonical form verification failed!\n");
2633#endif
2634 return tgMan.uPhase;
2635}
int Abc_TtHieRetrieveOrInsert(Abc_TtHieMan_t *p, int level, word *pTruth, word *pResult)
Definition dauCanon.c:1286
int Abc_TgExpendSymmetry(Abc_TgMan_t *pMan, char *pDest)
Definition dauCanon.c:1980
struct Abc_TgMan_t_ Abc_TgMan_t
word gpVerCopy[1024]
Definition dauCanon.c:1550
Cube * p
Definition exorList.c:222
char pPermT[16]
Definition dauCanon.c:1481
unsigned uPhase
Definition dauCanon.c:1478
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Abc_TtCanonicizeCA()

unsigned Abc_TtCanonicizeCA ( Abc_TtHieMan_t * p,
word * pTruth,
int nVars,
char * pCanonPerm,
int fCA )

Definition at line 2637 of file dauCanon.c.

2638{
2639 int nWords = Abc_TtWordNum(nVars);
2640 unsigned fHard = 0, fHash = 1 << 29;
2641 static word pCopy[1024];
2642 Abc_TgMan_t tgMan, tgManCopy;
2643 Abc_SccCost_t sc;
2644
2645 // handle constant
2646 if (nVars == 0) {
2647 Abc_TtClear(pTruth, nWords);
2648 return 0;
2649 }
2650
2651 Abc_TtVerifySmallTruth(pTruth, nVars);
2652#ifdef CANON_VERIFY
2653 Abc_TtCopy(gpVerCopy, pTruth, nWords, 0);
2654#endif
2655
2656 assert(nVars <= 16);
2657 assert(p != NULL);
2658 if (Abc_TtHieRetrieveOrInsert(p, -5, pTruth, pTruth) > 0) return fHash;
2659 Abc_TgInitMan(&tgMan, pTruth, nVars, 2, p->vPhase);
2660
2661 Abc_TgCreateGroups(&tgMan);
2662 if (p && Abc_TtHieRetrieveOrInsert(p, -4, pTruth, pTruth) > 0) return fHash;
2663 Abc_TgPurgeSymmetry(&tgMan, 1);
2664
2665 Abc_TgExpendSymmetry(&tgMan, pCanonPerm);
2666 Abc_TgImplementPerm(&tgMan, pCanonPerm);
2667 assert(Abc_TgCannonVerify(&tgMan));
2668
2669 if (Abc_TtHieRetrieveOrInsert(p, -3, pTruth, pTruth) > 0) return fHash;
2670 Abc_TgManCopy(&tgManCopy, pCopy, &tgMan);
2671 Abc_TgSimpleEnumeration(&tgMan);
2672 if (Abc_TtHieRetrieveOrInsert(p, -2, pTruth, pTruth) > 0) return fHash;
2673 Abc_TgManCopy(&tgMan, pTruth, &tgManCopy);
2674 Abc_TtFill(pTruth, nWords);
2675
2676 assert(Abc_TgCannonVerify(&tgManCopy));
2677 sc = Abc_TgRecordPhase(&tgManCopy, 0);
2678 if (fCA && Abc_SccEnumCost(&tgManCopy, sc) > Abc_SccPhaseCost(&tgManCopy))
2679 {
2680 Abc_TgResetGroup(&tgManCopy);
2681 sc = Abc_TgRecordPhase(&tgManCopy, 1);
2682 fHard = 1 << 28;
2683 }
2684 Abc_TgFullEnumeration(&tgManCopy, &tgMan);
2685 Abc_TtHieRetrieveOrInsert(p, -1, pTruth, pTruth);
2686 memcpy(pCanonPerm, tgMan.pPermT, sizeof(char) * nVars);
2687
2688#ifdef CANON_VERIFY
2689 if (!Abc_TgCannonVerify(&tgMan))
2690 printf("Canonical form verification failed!\n");
2691#endif
2692 return tgMan.uPhase | fHard;
2693}
struct Abc_SccCost_t_ Abc_SccCost_t
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Abc_TtCanonicizeHie()

unsigned Abc_TtCanonicizeHie ( Abc_TtHieMan_t * p,
word * pTruthInit,
int nVars,
char * pCanonPerm,
int fExact )

Definition at line 1318 of file dauCanon.c.

1319{
1320 int fNaive = 1;
1321 int pStore[17];
1322 //static word pTruth[1024];
1323 word * pTruth = pTruthInit;
1324 unsigned uCanonPhase = 0;
1325 int nOnes, nWords = Abc_TtWordNum( nVars );
1326 int i, k;
1327 assert( nVars <= 16 );
1328
1329 // handle constant
1330 if ( nVars == 0 )
1331 {
1332 Abc_TtClear( pTruthInit, nWords );
1333 return 0;
1334 }
1335
1336 //Abc_TtCopy( pTruth, pTruthInit, nWords, 0 );
1337
1338 for ( i = 0; i < nVars; i++ )
1339 pCanonPerm[i] = i;
1340
1341 // normalize polarity
1342 nOnes = Abc_TtCountOnesInTruth( pTruth, nVars );
1343 if ( nOnes > nWords * 32 )
1344 {
1345 Abc_TtNot( pTruth, nWords );
1346 nOnes = nWords*64 - nOnes;
1347 uCanonPhase |= (1 << nVars);
1348 }
1349 // check cache
1350 if (Abc_TtHieRetrieveOrInsert(p, 0, pTruth, pTruthInit) > 0) return 0;
1351
1352 // normalize phase
1353 Abc_TtCountOnesInCofs( pTruth, nVars, pStore );
1354 pStore[nVars] = nOnes;
1355 for ( i = 0; i < nVars; i++ )
1356 {
1357 if ( pStore[i] >= nOnes - pStore[i] )
1358 continue;
1359 Abc_TtFlip( pTruth, nWords, i );
1360 uCanonPhase |= (1 << i);
1361 pStore[i] = nOnes - pStore[i];
1362 }
1363 // check cache
1364 if (Abc_TtHieRetrieveOrInsert(p, 1, pTruth, pTruthInit) > 0) return 0;
1365
1366 // normalize permutation
1367 {
1368 int k, BestK;
1369 for ( i = 0; i < nVars - 1; i++ )
1370 {
1371 BestK = i + 1;
1372 for ( k = i + 2; k < nVars; k++ )
1373 if ( pStore[BestK] > pStore[k] )
1374 BestK = k;
1375 if ( pStore[i] <= pStore[BestK] )
1376 continue;
1377 ABC_SWAP( int, pCanonPerm[i], pCanonPerm[BestK] );
1378 ABC_SWAP( int, pStore[i], pStore[BestK] );
1379 if ( ((uCanonPhase >> i) & 1) != ((uCanonPhase >> BestK) & 1) )
1380 {
1381 uCanonPhase ^= (1 << i);
1382 uCanonPhase ^= (1 << BestK);
1383 }
1384 Abc_TtSwapVars( pTruth, nVars, i, BestK );
1385 }
1386 }
1387 // check cache
1388 if (Abc_TtHieRetrieveOrInsert(p, 2, pTruth, pTruthInit) > 0) return 0;
1389
1390 // iterate TT permutations for tied variables
1391 for ( k = 0; k < 5; k++ )
1392 {
1393 int fChanges = 0;
1394 for ( i = nVars - 2; i >= 0; i-- )
1395 if ( pStore[i] == pStore[i+1] )
1396 fChanges |= Abc_TtCofactorPerm( pTruth, i, nWords, pStore[i] != pStore[nVars]/2, pCanonPerm, &uCanonPhase, fNaive );
1397 if ( !fChanges )
1398 break;
1399 fChanges = 0;
1400 for ( i = 1; i < nVars - 1; i++ )
1401 if ( pStore[i] == pStore[i+1] )
1402 fChanges |= Abc_TtCofactorPerm( pTruth, i, nWords, pStore[i] != pStore[nVars]/2, pCanonPerm, &uCanonPhase, fNaive );
1403 if ( !fChanges )
1404 break;
1405 }
1406 // check cache
1407 if (Abc_TtHieRetrieveOrInsert(p, 3, pTruth, pTruthInit) > 0) return 0;
1408
1409 // perform exact NPN using groups
1410 if ( fExact ) {
1411 extern void simpleMinimalGroups(word* x, word* pAux, word* minimal, int* pGroups, int nGroups, permInfo** pis, int nVars, int fFlipOutput, int fFlipInput);
1412 word pAuxWord[1024], pAuxWord1[1024];
1413 int pGroups[16];
1414 int nGroups = 0;
1415 permInfo * pis[17];
1416 // get groups
1417 pGroups[0] = 0;
1418 for (i = 0; i < nVars - 1; i++) {
1419 if (pStore[i] == pStore[i + 1]) {
1420 pGroups[nGroups]++;
1421 } else {
1422 pGroups[nGroups]++;
1423 nGroups++;
1424 pGroups[nGroups] = 0;
1425 }
1426 }
1427 pGroups[nGroups]++;
1428 nGroups++;
1429
1430 // compute permInfo from 0 to nVars (incl.)
1431 for (i = 0; i <= nVars; i++) {
1432 pis[i] = setPermInfoPtr(i);
1433 }
1434
1435 // do the exact matching
1436 if (nOnes == nWords * 32) /* balanced output */
1437 simpleMinimalGroups(pTruth, pAuxWord, pAuxWord1, pGroups, nGroups, pis, nVars, 1, 1);
1438 else if (pStore[0] != pStore[1] && pStore[0] == (nOnes - pStore[0])) /* balanced singleton input */
1439 simpleMinimalGroups(pTruth, pAuxWord, pAuxWord1, pGroups, nGroups, pis, nVars, 0, 1);
1440 else
1441 simpleMinimalGroups(pTruth, pAuxWord, pAuxWord1, pGroups, nGroups, pis, nVars, 0, 0);
1442
1443 // cleanup
1444 for (i = 0; i <= nVars; i++) {
1445 freePermInfoPtr(pis[i]);
1446 }
1447 }
1448 // update cache
1449 Abc_TtHieRetrieveOrInsert(p, 4, pTruth, pTruthInit);
1450 return 0;
1451}
#define ABC_SWAP(Type, a, b)
Definition abc_global.h:253
void freePermInfoPtr(permInfo *x)
permInfo * setPermInfoPtr(int var)
void simpleMinimalGroups(word *x, word *pAux, word *minimal, int *pGroups, int nGroups, permInfo **pis, int nVars, int fFlipOutput, int fFlipInput)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Abc_TtCanonicizePerm()

unsigned Abc_TtCanonicizePerm ( word * pTruth,
int nVars,
char * pCanonPerm )

Definition at line 1085 of file dauCanon.c.

1086{
1087 int pStoreIn[17];
1088 unsigned uCanonPhase;
1089 int i, k, nWords = Abc_TtWordNum( nVars );
1090 int fNaive = 1;
1091
1092#ifdef CANON_VERIFY
1093 char pCanonPermCopy[16];
1094 static word pCopy1[1024];
1095 static word pCopy2[1024];
1096 Abc_TtCopy( pCopy1, pTruth, nWords, 0 );
1097#endif
1098
1099 assert( nVars <= 16 );
1100 for ( i = 0; i < nVars; i++ )
1101 pCanonPerm[i] = i;
1102
1103 uCanonPhase = Abc_TtSemiCanonicize( pTruth, nVars, pCanonPerm, pStoreIn, 1 );
1104 for ( k = 0; k < 5; k++ )
1105 {
1106 int fChanges = 0;
1107 for ( i = nVars - 2; i >= 0; i-- )
1108 if ( pStoreIn[i] == pStoreIn[i+1] )
1109 fChanges |= Abc_TtCofactorPerm( pTruth, i, nWords, 1, pCanonPerm, &uCanonPhase, fNaive );
1110 if ( !fChanges )
1111 break;
1112 fChanges = 0;
1113 for ( i = 1; i < nVars - 1; i++ )
1114 if ( pStoreIn[i] == pStoreIn[i+1] )
1115 fChanges |= Abc_TtCofactorPerm( pTruth, i, nWords, 1, pCanonPerm, &uCanonPhase, fNaive );
1116 if ( !fChanges )
1117 break;
1118 }
1119
1120#ifdef CANON_VERIFY
1121 Abc_TtCopy( pCopy2, pTruth, nWords, 0 );
1122 memcpy( pCanonPermCopy, pCanonPerm, sizeof(char) * nVars );
1123 Abc_TtImplementNpnConfig( pCopy2, nVars, pCanonPermCopy, uCanonPhase );
1124 if ( !Abc_TtEqual( pCopy1, pCopy2, nWords ) )
1125 printf( "Canonical form verification failed!\n" );
1126#endif
1127
1128 assert( uCanonPhase == 0 );
1129 return uCanonPhase;
1130}
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Abc_TtCanonicizePhase()

unsigned Abc_TtCanonicizePhase ( word * pTruth,
int nVars )

Definition at line 1187 of file dauCanon.c.

1188{
1189 unsigned uCanonPhase = 0;
1190 int v, nWords = Abc_TtWordNum( nVars );
1191// static int Counter = 0;
1192// Counter++;
1193
1194#ifdef CANON_VERIFY
1195 static word pCopy1[1024];
1196 static word pCopy2[1024];
1197 Abc_TtCopy( pCopy1, pTruth, nWords, 0 );
1198#endif
1199
1200 if ( (pTruth[nWords-1] >> 63) & 1 )
1201 {
1202 Abc_TtNot( pTruth, nWords );
1203 uCanonPhase ^= (1 << nVars);
1204 }
1205
1206// while ( 1 )
1207// {
1208// unsigned uCanonPhase2 = uCanonPhase;
1209 for ( v = nVars - 1; v >= 6; v-- )
1210 if ( Abc_TtCanonicizePhaseVar6( pTruth, nVars, v ) == 1 )
1211 uCanonPhase ^= 1 << v;
1212 for ( ; v >= 0; v-- )
1213 if ( Abc_TtCanonicizePhaseVar5( pTruth, nVars, v ) == 1 )
1214 uCanonPhase ^= 1 << v;
1215// if ( uCanonPhase2 == uCanonPhase )
1216// break;
1217// }
1218
1219// for ( v = 5; v >= 0; v-- )
1220// assert( Abc_TtCanonicizePhaseVar5( pTruth, nVars, v ) != 1 );
1221
1222#ifdef CANON_VERIFY
1223 Abc_TtCopy( pCopy2, pTruth, nWords, 0 );
1224 Abc_TtImplementNpnConfig( pCopy2, nVars, NULL, uCanonPhase );
1225 if ( !Abc_TtEqual( pCopy1, pCopy2, nWords ) )
1226 printf( "Canonical form verification failed!\n" );
1227#endif
1228 return uCanonPhase;
1229}
Here is the caller graph for this function:

◆ Abc_TtCanonicizeWrap()

unsigned Abc_TtCanonicizeWrap ( TtCanonicizeFunc func,
Abc_TtHieMan_t * p,
word * pTruth,
int nVars,
char * pCanonPerm,
int flag )

Definition at line 1530 of file dauCanon.c.

1531{
1532 int nWords = Abc_TtWordNum(nVars);
1533 unsigned uCanonPhase1, uCanonPhase2;
1534 char pCanonPerm2[16];
1535 static word pTruth2[1024];
1536
1537 Abc_TtNormalizeSmallTruth(pTruth, nVars);
1538 if (Abc_TtCountOnesInTruth(pTruth, nVars) != nWords * 32)
1539 return func(p, pTruth, nVars, pCanonPerm, flag);
1540 Abc_TtCopy(pTruth2, pTruth, nWords, 1);
1541 uCanonPhase1 = func(p, pTruth, nVars, pCanonPerm, flag);
1542 uCanonPhase2 = func(p, pTruth2, nVars, pCanonPerm2, flag);
1543 if (Abc_TtCompareRev(pTruth, pTruth2, nWords) <= 0)
1544 return uCanonPhase1;
1545 Abc_TtCopy(pTruth, pTruth2, nWords, 0);
1546 memcpy(pCanonPerm, pCanonPerm2, nVars);
1547 return uCanonPhase2;
1548}
void Abc_TtNormalizeSmallTruth(word *pTruth, int nVars)
Definition dauCanon.c:300
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Abc_TtCofactorPerm()

int Abc_TtCofactorPerm ( word * pTruth,
int i,
int nWords,
int fSwapOnly,
char * pCanonPerm,
unsigned * puCanonPhase,
int fNaive )

Definition at line 978 of file dauCanon.c.

979{
980 if ( fSwapOnly )
981 {
982 int Config = Abc_TtCofactorPermConfig( pTruth, i, nWords, 1, 0 );
983 if ( Config )
984 {
985 if ( ((*puCanonPhase >> i) & 1) != ((*puCanonPhase >> (i+1)) & 1) )
986 {
987 *puCanonPhase ^= (1 << i);
988 *puCanonPhase ^= (1 << (i+1));
989 }
990 ABC_SWAP( int, pCanonPerm[i], pCanonPerm[i+1] );
991 }
992 return Config;
993 }
994 {
995 static word pCopy1[1024];
996 int Config;
997 Abc_TtCopy( pCopy1, pTruth, nWords, 0 );
998 Config = Abc_TtCofactorPermConfig( pTruth, i, nWords, 0, fNaive );
999 if ( Config == 0 )
1000 return 0;
1001 if ( Abc_TtCompareRev(pTruth, pCopy1, nWords) == 1 ) // made it worse
1002 {
1003 Abc_TtCopy( pTruth, pCopy1, nWords, 0 );
1004 return 0;
1005 }
1006 // improved
1007 if ( Config & 1 )
1008 *puCanonPhase ^= (1 << i);
1009 if ( Config & 2 )
1010 *puCanonPhase ^= (1 << (i+1));
1011 if ( Config & 4 )
1012 {
1013 if ( ((*puCanonPhase >> i) & 1) != ((*puCanonPhase >> (i+1)) & 1) )
1014 {
1015 *puCanonPhase ^= (1 << i);
1016 *puCanonPhase ^= (1 << (i+1));
1017 }
1018 ABC_SWAP( int, pCanonPerm[i], pCanonPerm[i+1] );
1019 }
1020 return Config;
1021 }
1022}
int Abc_TtCofactorPermConfig(word *pTruth, int i, int nWords, int fSwapOnly, int fNaive)
Definition dauCanon.c:880
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Abc_TtCofactorPermConfig()

int Abc_TtCofactorPermConfig ( word * pTruth,
int i,
int nWords,
int fSwapOnly,
int fNaive )

Function*************************************************************

Synopsis [Smart evaluation.]

Description []

SideEffects []

SeeAlso []

Definition at line 880 of file dauCanon.c.

881{
882 if ( nWords == 1 )
883 return Abc_Tt6CofactorPermNaive( pTruth, i, fSwapOnly );
884 if ( fNaive )
885 return Abc_TtCofactorPermNaive( pTruth, i, nWords, fSwapOnly );
886 if ( fSwapOnly )
887 {
888 if ( Abc_TtCompare2VarCofsRev( pTruth, nWords, i, 1, 2 ) < 0 ) // Cof1 < Cof2
889 {
890 Abc_TtSwapAdjacent( pTruth, nWords, i );
891 return 4;
892 }
893 return 0;
894 }
895 {
896 int fComp01, fComp02, fComp03, fComp12, fComp13, fComp23, Config = 0;
897 fComp01 = Abc_TtCompare2VarCofsRev( pTruth, nWords, i, 0, 1 );
898 fComp23 = Abc_TtCompare2VarCofsRev( pTruth, nWords, i, 2, 3 );
899 if ( fComp23 >= 0 ) // Cof2 >= Cof3
900 {
901 if ( fComp01 >= 0 ) // Cof0 >= Cof1
902 {
903 fComp13 = Abc_TtCompare2VarCofsRev( pTruth, nWords, i, 1, 3 );
904 if ( fComp13 < 0 ) // Cof1 < Cof3
905 Abc_TtFlip( pTruth, nWords, i + 1 ), Config = 2;
906 else if ( fComp13 == 0 ) // Cof1 == Cof3
907 {
908 fComp02 = Abc_TtCompare2VarCofsRev( pTruth, nWords, i, 0, 2 );
909 if ( fComp02 < 0 )
910 Abc_TtFlip( pTruth, nWords, i + 1 ), Config = 2;
911 }
912 // else Cof1 > Cof3 -- do nothing
913 }
914 else // Cof0 < Cof1
915 {
916 fComp03 = Abc_TtCompare2VarCofsRev( pTruth, nWords, i, 0, 3 );
917 if ( fComp03 < 0 ) // Cof0 < Cof3
918 {
919 Abc_TtFlip( pTruth, nWords, i );
920 Abc_TtFlip( pTruth, nWords, i + 1 ), Config = 3;
921 }
922 else // Cof0 >= Cof3
923 {
924 if ( fComp23 == 0 ) // can flip Cof0 and Cof1
925 Abc_TtFlip( pTruth, nWords, i ), Config = 1;
926 }
927 }
928 }
929 else // Cof2 < Cof3
930 {
931 if ( fComp01 >= 0 ) // Cof0 >= Cof1
932 {
933 fComp12 = Abc_TtCompare2VarCofsRev( pTruth, nWords, i, 1, 2 );
934 if ( fComp12 > 0 ) // Cof1 > Cof2
935 Abc_TtFlip( pTruth, nWords, i ), Config = 1;
936 else if ( fComp12 == 0 ) // Cof1 == Cof2
937 {
938 Abc_TtFlip( pTruth, nWords, i );
939 Abc_TtFlip( pTruth, nWords, i + 1 ), Config = 3;
940 }
941 else // Cof1 < Cof2
942 {
943 Abc_TtFlip( pTruth, nWords, i + 1 ), Config = 2;
944 if ( fComp01 == 0 )
945 Abc_TtFlip( pTruth, nWords, i ), Config ^= 1;
946 }
947 }
948 else // Cof0 < Cof1
949 {
950 fComp02 = Abc_TtCompare2VarCofsRev( pTruth, nWords, i, 0, 2 );
951 if ( fComp02 == -1 ) // Cof0 < Cof2
952 {
953 Abc_TtFlip( pTruth, nWords, i );
954 Abc_TtFlip( pTruth, nWords, i + 1 ), Config = 3;
955 }
956 else if ( fComp02 == 0 ) // Cof0 == Cof2
957 {
958 fComp13 = Abc_TtCompare2VarCofsRev( pTruth, nWords, i, 1, 3 );
959 if ( fComp13 >= 0 ) // Cof1 >= Cof3
960 Abc_TtFlip( pTruth, nWords, i ), Config = 1;
961 else // Cof1 < Cof3
962 {
963 Abc_TtFlip( pTruth, nWords, i );
964 Abc_TtFlip( pTruth, nWords, i + 1 ), Config = 3;
965 }
966 }
967 else // Cof0 > Cof2
968 Abc_TtFlip( pTruth, nWords, i ), Config = 1;
969 }
970 }
971 // perform final swap if needed
972 fComp12 = Abc_TtCompare2VarCofsRev( pTruth, nWords, i, 1, 2 );
973 if ( fComp12 < 0 ) // Cof1 < Cof2
974 Abc_TtSwapAdjacent( pTruth, nWords, i ), Config ^= 4;
975 return Config;
976 }
977}
int Abc_Tt6CofactorPermNaive(word *pTruth, int i, int fSwapOnly)
Definition dauCanon.c:740
int Abc_TtCofactorPermNaive(word *pTruth, int i, int nWords, int fSwapOnly)
Definition dauCanon.c:800
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Abc_TtCofactorPermNaive()

int Abc_TtCofactorPermNaive ( word * pTruth,
int i,
int nWords,
int fSwapOnly )

Definition at line 800 of file dauCanon.c.

801{
802 if ( fSwapOnly )
803 {
804 static word pCopy[1024];
805 Abc_TtCopy( pCopy, pTruth, nWords, 0 );
806 Abc_TtSwapAdjacent( pCopy, nWords, i );
807 if ( Abc_TtCompareRev(pTruth, pCopy, nWords) == 1 )
808 {
809 Abc_TtCopy( pTruth, pCopy, nWords, 0 );
810 return 4;
811 }
812 return 0;
813 }
814 {
815 static word pCopy[1024];
816 static word pBest[1024];
817 int Config = 0;
818 // save two copies
819 Abc_TtCopy( pCopy, pTruth, nWords, 0 );
820 Abc_TtCopy( pBest, pTruth, nWords, 0 );
821 // PXY
822 // 001
823 Abc_TtFlip( pCopy, nWords, i );
824 if ( Abc_TtCompareRev(pBest, pCopy, nWords) == 1 )
825 Abc_TtCopy( pBest, pCopy, nWords, 0 ), Config = 1;
826 // PXY
827 // 011
828 Abc_TtFlip( pCopy, nWords, i+1 );
829 if ( Abc_TtCompareRev(pBest, pCopy, nWords) == 1 )
830 Abc_TtCopy( pBest, pCopy, nWords, 0 ), Config = 3;
831 // PXY
832 // 010
833 Abc_TtFlip( pCopy, nWords, i );
834 if ( Abc_TtCompareRev(pBest, pCopy, nWords) == 1 )
835 Abc_TtCopy( pBest, pCopy, nWords, 0 ), Config = 2;
836 // PXY
837 // 110
838 Abc_TtSwapAdjacent( pCopy, nWords, i );
839 if ( Abc_TtCompareRev(pBest, pCopy, nWords) == 1 )
840 Abc_TtCopy( pBest, pCopy, nWords, 0 ), Config = 6;
841 // PXY
842 // 111
843 Abc_TtFlip( pCopy, nWords, i+1 );
844 if ( Abc_TtCompareRev(pBest, pCopy, nWords) == 1 )
845 Abc_TtCopy( pBest, pCopy, nWords, 0 ), Config = 7;
846 // PXY
847 // 101
848 Abc_TtFlip( pCopy, nWords, i );
849 if ( Abc_TtCompareRev(pBest, pCopy, nWords) == 1 )
850 Abc_TtCopy( pBest, pCopy, nWords, 0 ), Config = 5;
851 // PXY
852 // 100
853 Abc_TtFlip( pCopy, nWords, i+1 );
854 if ( Abc_TtCompareRev(pBest, pCopy, nWords) == 1 )
855 Abc_TtCopy( pBest, pCopy, nWords, 0 ), Config = 4;
856 // PXY
857 // 000
858 Abc_TtSwapAdjacent( pCopy, nWords, i );
859 assert( Abc_TtEqual( pTruth, pCopy, nWords ) );
860 if ( Config == 0 )
861 return 0;
862 assert( Abc_TtCompareRev(pTruth, pBest, nWords) == 1 );
863 Abc_TtCopy( pTruth, pBest, nWords, 0 );
864 return Config;
865 }
866}
Here is the caller graph for this function:

◆ Abc_TtCofactorTest10()

void Abc_TtCofactorTest10 ( word * pTruth,
int nVars,
int N )

Function*************************************************************

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 710 of file dauCanon.c.

711{
712 static word pCopy1[1024];
713 static word pCopy2[1024];
714 int nWords = Abc_TtWordNum( nVars );
715 int i;
716 for ( i = 0; i < nVars - 1; i++ )
717 {
718// Kit_DsdPrintFromTruth( pTruth, nVars ); printf( "\n" );
719 Abc_TtCopy( pCopy1, pTruth, nWords, 0 );
720 Abc_TtSwapAdjacent( pCopy1, nWords, i );
721// Kit_DsdPrintFromTruth( pCopy1, nVars ); printf( "\n" );
722 Abc_TtCopy( pCopy2, pTruth, nWords, 0 );
723 Abc_TtSwapVars( pCopy2, nVars, i, i+1 );
724// Kit_DsdPrintFromTruth( pCopy2, nVars ); printf( "\n" );
725 assert( Abc_TtEqual( pCopy1, pCopy2, nWords ) );
726 }
727}

◆ Abc_TtCountOnesInCofsFast()

int Abc_TtCountOnesInCofsFast ( word * pTruth,
int nVars,
int * pStore )

Definition at line 565 of file dauCanon.c.

566{
567 memset( pStore, 0, sizeof(int) * nVars );
568 assert( nVars >= 3 );
569 if ( nVars <= 6 )
570 return Abc_TtCountOnesInCofsFast6_rec( pTruth[0], nVars - 1, Abc_TtByteNum( nVars ), pStore );
571 else
572 return Abc_TtCountOnesInCofsFast_rec( pTruth, nVars - 1, Abc_TtWordNum( nVars ), pStore );
573}
int Abc_TtCountOnesInCofsFast_rec(word *pTruth, int iVar, int nWords, int *pStore)
Definition dauCanon.c:535
int Abc_TtCountOnesInCofsFast6_rec(word Truth, int iVar, int nBytes, int *pStore)
Definition dauCanon.c:499
char * memset()
Here is the call graph for this function:

◆ Abc_TtCountOnesInCofsFast6_rec()

int Abc_TtCountOnesInCofsFast6_rec ( word Truth,
int iVar,
int nBytes,
int * pStore )

Function*************************************************************

Synopsis [Minterm counting in all cofactors.]

Description []

SideEffects []

SeeAlso []

Definition at line 499 of file dauCanon.c.

500{
501 static int bit_count[256] = {
502 0,1,1,2,1,2,2,3,1,2,2,3,2,3,3,4,1,2,2,3,2,3,3,4,2,3,3,4,3,4,4,5,
503 1,2,2,3,2,3,3,4,2,3,3,4,3,4,4,5,2,3,3,4,3,4,4,5,3,4,4,5,4,5,5,6,
504 1,2,2,3,2,3,3,4,2,3,3,4,3,4,4,5,2,3,3,4,3,4,4,5,3,4,4,5,4,5,5,6,
505 2,3,3,4,3,4,4,5,3,4,4,5,4,5,5,6,3,4,4,5,4,5,5,6,4,5,5,6,5,6,6,7,
506 1,2,2,3,2,3,3,4,2,3,3,4,3,4,4,5,2,3,3,4,3,4,4,5,3,4,4,5,4,5,5,6,
507 2,3,3,4,3,4,4,5,3,4,4,5,4,5,5,6,3,4,4,5,4,5,5,6,4,5,5,6,5,6,6,7,
508 2,3,3,4,3,4,4,5,3,4,4,5,4,5,5,6,3,4,4,5,4,5,5,6,4,5,5,6,5,6,6,7,
509 3,4,4,5,4,5,5,6,4,5,5,6,5,6,6,7,4,5,5,6,5,6,6,7,5,6,6,7,6,7,7,8
510 };
511 int nMints0, nMints1;
512 if ( Truth == 0 )
513 return 0;
514 if ( ~Truth == 0 )
515 {
516 int i;
517 for ( i = 0; i <= iVar; i++ )
518 pStore[i] += nBytes * 4;
519 return nBytes * 8;
520 }
521 if ( nBytes == 1 )
522 {
523 assert( iVar == 2 );
524 pStore[0] += bit_count[ Truth & 0x55 ];
525 pStore[1] += bit_count[ Truth & 0x33 ];
526 pStore[2] += bit_count[ Truth & 0x0F ];
527 return bit_count[ Truth & 0xFF ];
528 }
529 nMints0 = Abc_TtCountOnesInCofsFast6_rec( Abc_Tt6Cofactor0(Truth, iVar), iVar - 1, nBytes/2, pStore );
530 nMints1 = Abc_TtCountOnesInCofsFast6_rec( Abc_Tt6Cofactor1(Truth, iVar), iVar - 1, nBytes/2, pStore );
531 pStore[iVar] += nMints0;
532 return nMints0 + nMints1;
533}
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Abc_TtCountOnesInCofsFast_rec()

int Abc_TtCountOnesInCofsFast_rec ( word * pTruth,
int iVar,
int nWords,
int * pStore )

Definition at line 535 of file dauCanon.c.

536{
537 int nMints0, nMints1;
538 if ( nWords == 1 )
539 {
540 assert( iVar == 5 );
541 return Abc_TtCountOnesInCofsFast6_rec( pTruth[0], iVar, 8, pStore );
542 }
543 assert( nWords > 1 );
544 assert( iVar > 5 );
545 if ( pTruth[0] & 1 )
546 {
547 if ( Abc_TtIsConst1( pTruth, nWords ) )
548 {
549 int i;
550 for ( i = 0; i <= iVar; i++ )
551 pStore[i] += nWords * 32;
552 return nWords * 64;
553 }
554 }
555 else
556 {
557 if ( Abc_TtIsConst0( pTruth, nWords ) )
558 return 0;
559 }
560 nMints0 = Abc_TtCountOnesInCofsFast_rec( pTruth, iVar - 1, nWords/2, pStore );
561 nMints1 = Abc_TtCountOnesInCofsFast_rec( pTruth + nWords/2, iVar - 1, nWords/2, pStore );
562 pStore[iVar] += nMints0;
563 return nMints0 + nMints1;
564}
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Abc_TtCountOnesInCofsSimple()

int Abc_TtCountOnesInCofsSimple ( word * pTruth,
int nVars,
int * pStore )

Definition at line 370 of file dauCanon.c.

371{
372 Abc_TtCountOnesInCofs( pTruth, nVars, pStore );
373 return Abc_TtCountOnesInTruth( pTruth, nVars );
374}
Here is the caller graph for this function:

◆ Abc_TtHieManStart()

Abc_TtHieMan_t * Abc_TtHieManStart ( int nVars,
int nLevels )

Definition at line 1255 of file dauCanon.c.

1256{
1257 Abc_TtHieMan_t * p = NULL;
1258 int i;
1259 if (nLevels > TT_MAX_LEVELS) return p;
1261 p->nLastLevel = nLevels - 1;
1262 p->nWords = Abc_TtWordNum(nVars);
1263 for (i = 0; i < nLevels; i++)
1264 {
1265 p->vTtMem[i] = Vec_MemAlloc(p->nWords, 12);
1266 Vec_MemHashAlloc(p->vTtMem[i], 10000);
1267 p->vRepres[i] = Vec_IntAlloc(1);
1268 }
1269 p->vPhase = Vec_IntAlloc(2500);
1270 return p;
1271}
#define ABC_CALLOC(type, num)
Definition abc_global.h:265
#define TT_MAX_LEVELS
Definition dauCanon.c:1243
struct Abc_TtHieMan_t_ Abc_TtHieMan_t
Definition dau.h:62
Here is the caller graph for this function:

◆ Abc_TtHieManStop()

void Abc_TtHieManStop ( Abc_TtHieMan_t * p)

Definition at line 1273 of file dauCanon.c.

1274{
1275 int i;
1276 for (i = 0; i <= p->nLastLevel; i++)
1277 {
1278 Vec_MemHashFree(p->vTtMem[i]);
1279 Vec_MemFreeP(&p->vTtMem[i]);
1280 Vec_IntFree(p->vRepres[i]);
1281 }
1282 Vec_IntFree( p->vPhase );
1283 ABC_FREE(p);
1284}
#define ABC_FREE(obj)
Definition abc_global.h:267
Here is the caller graph for this function:

◆ Abc_TtHieRetrieveOrInsert()

int Abc_TtHieRetrieveOrInsert ( Abc_TtHieMan_t * p,
int level,
word * pTruth,
word * pResult )

Definition at line 1286 of file dauCanon.c.

1287{
1288 int i, iSpot, truthId;
1289 word * pRepTruth;
1290 if (!p) return -1;
1291 if (level < 0) level += p->nLastLevel + 1;
1292 if (level < 0 || level > p->nLastLevel) return -1;
1293 iSpot = *Vec_MemHashLookup(p->vTtMem[level], pTruth);
1294 if (iSpot == -1) {
1295 p->vTruthId[level] = Vec_MemHashInsert(p->vTtMem[level], pTruth);
1296 if (level < p->nLastLevel) return 0;
1297 iSpot = p->vTruthId[level];
1298 }
1299 // return the class representative
1300 if (level < p->nLastLevel)
1301 truthId = Vec_IntEntry(p->vRepres[level], iSpot);
1302 else
1303 truthId = iSpot;
1304 for (i = 0; i < level; i++)
1305 Vec_IntSetEntry(p->vRepres[i], p->vTruthId[i], truthId);
1306
1307 pRepTruth = Vec_MemReadEntry(p->vTtMem[p->nLastLevel], truthId);
1308 if (level < p->nLastLevel) {
1309 Abc_TtCopy(pResult, pRepTruth, p->nWords, 0);
1310 return 1;
1311 }
1312 assert(Abc_TtEqual(pTruth, pRepTruth, p->nWords));
1313 if (pTruth != pResult)
1314 Abc_TtCopy(pResult, pRepTruth, p->nWords, 0);
1315 return 0;
1316}
Here is the caller graph for this function:

◆ Abc_TtNormalizeSmallTruth()

void Abc_TtNormalizeSmallTruth ( word * pTruth,
int nVars )

Function*************************************************************

Synopsis [Minterm counting in all cofactors.]

Description []

SideEffects []

SeeAlso []

Definition at line 300 of file dauCanon.c.

301{
302 if (nVars < 6) {
303 int shift, bits = (1 << nVars);
304 word base = *pTruth = *pTruth & ((((word)1) << bits) - 1);
305 for (shift = bits; shift < 64; shift += bits)
306 *pTruth |= base << shift;
307 }
308}
Here is the caller graph for this function:

◆ Abc_TtScc()

int Abc_TtScc ( word * pTruth,
int nVars )

Definition at line 393 of file dauCanon.c.

394{
395 int k, nWords = Abc_TtWordNum(nVars);
396 int sum = 0;
397 Abc_TtNormalizeSmallTruth(pTruth, nVars);
398 for (k = 0; k < nWords; k++)
399 sum += Abc_TtScc6(pTruth[k], Abc_TtBitCount16(k));
400 return sum;
401}
Here is the call graph for this function:

Variable Documentation

◆ gpVerCopy

word gpVerCopy[1024]

Definition at line 1550 of file dauCanon.c.