ABC: A System for Sequential Synthesis and Verification
 
Loading...
Searching...
No Matches
dau.h File Reference
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <assert.h>
#include <time.h>
#include "misc/vec/vec.h"
Include dependency graph for dau.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define DAU_MAX_VAR   12
 INCLUDES ///.
 
#define DAU_MAX_STR   2000
 
#define DAU_MAX_WORD   (1<<(DAU_MAX_VAR-6))
 

Typedefs

typedef struct Dss_Man_t_ Dss_Man_t
 
typedef struct Abc_TtHieMan_t_ Abc_TtHieMan_t
 
typedef unsigned(* TtCanonicizeFunc) (Abc_TtHieMan_t *p, word *pTruth, int nVars, char *pCanonPerm, int flag)
 

Enumerations

enum  Dau_DsdType_t {
  DAU_DSD_NONE = 0 , DAU_DSD_CONST0 , DAU_DSD_VAR , DAU_DSD_AND ,
  DAU_DSD_XOR , DAU_DSD_MUX , DAU_DSD_PRIME
}
 BASIC TYPES ///. More...
 

Functions

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)
 
int Abc_TtCountOnesInCofsSimple (word *pTruth, int nVars, int *pStore)
 
unsigned Abc_TtCanonicizeHie (Abc_TtHieMan_t *p, word *pTruth, int nVars, char *pCanonPerm, int fExact)
 
Abc_TtHieMan_tAbc_TtHieManStart (int nVars, int nLevels)
 
void Abc_TtHieManStop (Abc_TtHieMan_t *p)
 
unsigned Abc_TtCanonicizeWrap (TtCanonicizeFunc func, Abc_TtHieMan_t *p, word *pTruth, int nVars, char *pCanonPerm, int flag)
 
unsigned Abc_TtCanonicizeAda (Abc_TtHieMan_t *p, word *pTruth, int nVars, char *pCanonPerm, int iThres)
 
int Abc_TtCountOnesInCofsQuick (word *pTruth, int nVars, int *pStore)
 
int * Dau_DsdComputeMatches (char *p)
 
int Dau_DsdDecompose (word *pTruth, int nVarsInit, int fSplitPrime, int fWriteTruth, char *pRes)
 
int Dau_DsdDecomposeLevel (word *pTruth, int nVarsInit, int fSplitPrime, int fWriteTruth, char *pRes, int *pVarLevels)
 
void Dau_DsdPrintFromTruthFile (FILE *pFile, word *pTruth, int nVarsInit)
 
void Dau_DsdPrintFromTruth (word *pTruth, int nVarsInit)
 
wordDau_DsdToTruth (char *p, int nVars)
 
word Dau_Dsd6ToTruth (char *p)
 
void Dau_DsdNormalize (char *p)
 
int Dau_DsdCountAnds (char *pDsd)
 
void Dau_DsdTruthCompose_rec (word *pFunc, word pFanins[DAU_MAX_VAR][DAU_MAX_WORD], word *pRes, int nVars, int nWordsR)
 
int Dau_DsdCheck1Step (void *p, word *pTruth, int nVarsInit, int *pVarLevels)
 
int Dsm_ManTruthToGia (void *p, word *pTruth, Vec_Int_t *vLeaves, Vec_Int_t *vCover)
 
void * Dsm_ManDeriveGia (void *p, int fUseMuxes)
 
void Dau_DsdRemoveBraces (char *pDsd, int *pMatches)
 
char * Dau_DsdMerge (char *pDsd0i, int *pPerm0, char *pDsd1i, int *pPerm1, int fCompl0, int fCompl1, int nVars)
 DECLARATIONS ///.
 
Vec_Int_tDau_DecFindSets_int (word *pInit, int nVars, int *pSched[16])
 
Vec_Int_tDau_DecFindSets (word *pInit, int nVars)
 
void Dau_DecSortSet (unsigned set, int nVars, int *pnUnique, int *pnShared, int *pnFree)
 
void Dau_DecPrintSets (Vec_Int_t *vSets, int nVars)
 
void Dau_DecPrintSet (unsigned set, int nVars, int fNewLine)
 
Dss_Man_tDss_ManAlloc (int nVars, int nNonDecLimit)
 
void Dss_ManFree (Dss_Man_t *p)
 
int Dss_ManMerge (Dss_Man_t *p, int *iDsd, int *nFans, int **pFans, unsigned uSharedMask, int nKLutSize, unsigned char *pPerm, word *pTruth)
 
void Dss_ManPrint (char *pFileName, Dss_Man_t *p)
 

Macro Definition Documentation

◆ DAU_MAX_STR

#define DAU_MAX_STR   2000

Definition at line 43 of file dau.h.

◆ DAU_MAX_VAR

#define DAU_MAX_VAR   12

INCLUDES ///.

CFile****************************************************************

FileName [dau.h]

SystemName [ABC: Logic synthesis and verification system.]

PackageName [DAG-aware unmapping.]

Synopsis [External declarations.]

Author [Alan Mishchenko]

Affiliation [UC Berkeley]

Date [Ver. 1.0. Started - June 20, 2005.]

Revision [

Id
dau.h,v 1.00 2005/06/20 00:00:00 alanmi Exp

] PARAMETERS ///

Definition at line 42 of file dau.h.

◆ DAU_MAX_WORD

#define DAU_MAX_WORD   (1<<(DAU_MAX_VAR-6))

Definition at line 44 of file dau.h.

Typedef Documentation

◆ Abc_TtHieMan_t

Definition at line 62 of file dau.h.

◆ Dss_Man_t

typedef struct Dss_Man_t_ Dss_Man_t

Definition at line 61 of file dau.h.

◆ TtCanonicizeFunc

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

Definition at line 63 of file dau.h.

Enumeration Type Documentation

◆ Dau_DsdType_t

BASIC TYPES ///.

Enumerator
DAU_DSD_NONE 
DAU_DSD_CONST0 
DAU_DSD_VAR 
DAU_DSD_AND 
DAU_DSD_XOR 
DAU_DSD_MUX 
DAU_DSD_PRIME 

Definition at line 51 of file dau.h.

51 {
52 DAU_DSD_NONE = 0, // 0: unknown
53 DAU_DSD_CONST0, // 1: constant
54 DAU_DSD_VAR, // 2: variable
55 DAU_DSD_AND, // 3: AND
56 DAU_DSD_XOR, // 4: XOR
57 DAU_DSD_MUX, // 5: MUX
58 DAU_DSD_PRIME // 6: PRIME
Dau_DsdType_t
BASIC TYPES ///.
Definition dau.h:51
@ DAU_DSD_VAR
Definition dau.h:54
@ DAU_DSD_XOR
Definition dau.h:56
@ DAU_DSD_CONST0
Definition dau.h:53
@ DAU_DSD_PRIME
Definition dau.h:58
@ DAU_DSD_NONE
Definition dau.h:52
@ DAU_DSD_MUX
Definition dau.h:57
@ DAU_DSD_AND
Definition dau.h:55

Function Documentation

◆ Abc_TtCanonicize()

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

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
unsigned __int64 word
DECLARATIONS ///.
Definition kitPerm.c:36
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 )
extern

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
#define assert(ex)
Definition util_old.h:213
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 * pTruth,
int nVars,
char * pCanonPerm,
int fExact )
extern

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 )
extern

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 )
extern

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 )
extern

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_TtCountOnesInCofsQuick()

int Abc_TtCountOnesInCofsQuick ( word * pTruth,
int nVars,
int * pStore )
extern

Definition at line 376 of file dauCount.c.

377{
378 if ( nVars == 0 )
379 return (int)(pTruth[0] & 1);
380 memset( pStore, 0, sizeof(int)*nVars );
381 return Abc_TtCountOnesInCofsQuick_rec( pTruth, nVars, pStore );
382}
int Abc_TtCountOnesInCofsQuick_rec(word *pTruth, int nVars, int *pStore)
Definition dauCount.c:347
char * memset()
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 )
extern

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 )
extern

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)
extern

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:

◆ Dau_DecFindSets()

Vec_Int_t * Dau_DecFindSets ( word * pInit,
int nVars )
extern

Definition at line 516 of file dauNonDsd.c.

517{
518 Vec_Int_t * vSets;
519 int v, * pSched[16] = {NULL};
520 for ( v = 2; v < nVars; v++ )
521 pSched[v] = Extra_GreyCodeSchedule( v );
522 vSets = Dau_DecFindSets_int( pInit, nVars, pSched );
523 for ( v = 2; v < nVars; v++ )
524 ABC_FREE( pSched[v] );
525 return vSets;
526}
typedefABC_NAMESPACE_IMPL_START struct Vec_Int_t_ Vec_Int_t
DECLARATIONS ///.
Definition bblif.c:37
Vec_Int_t * Dau_DecFindSets_int(word *pInit, int nVars, int *pSched[16])
Definition dauNonDsd.c:462
int * Extra_GreyCodeSchedule(int n)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Dau_DecFindSets_int()

Vec_Int_t * Dau_DecFindSets_int ( word * pInit,
int nVars,
int * pSched[16] )
extern

Definition at line 462 of file dauNonDsd.c.

463{
464 Vec_Int_t * vSets = Vec_IntAlloc( 32 );
465 int V2P[16], P2V[16], pVarsB[16];
466 int Limit = (1 << nVars);
467 int c, v, sizeB, sizeS, maskB, maskS;
468 unsigned setMixed;
469 word p[1<<10];
470 memcpy( p, pInit, sizeof(word) * Abc_TtWordNum(nVars) );
471 for ( v = 0; v < nVars; v++ )
472 assert( Abc_TtHasVar( p, nVars, v ) );
473 // initialize permutation
474 for ( v = 0; v < nVars; v++ )
475 V2P[v] = P2V[v] = v;
476 // iterate through bound sets of each size in increasing order
477 for ( sizeB = 2; sizeB < nVars; sizeB++ ) // bound set size
478 for ( maskB = 0; maskB < Limit; maskB++ ) // bound set
479 if ( Abc_TtBitCount16(maskB) == sizeB )
480 {
481 // permute variables to have bound set on top
482 Dau_DecMoveFreeToLSB( p, nVars, V2P, P2V, maskB, sizeB );
483 // collect bound set vars on levels nVars-sizeB to nVars-1
484 for ( c = 0; c < sizeB; c++ )
485 pVarsB[c] = P2V[nVars-sizeB+c];
486 // check disjoint
487// if ( Dau_DecCheckSetTopOld(p, nVars, nVars-sizeB, sizeB, 0, 0, NULL, NULL, NULL) )
488 if ( Dau_DecCheckSetTop(p, nVars, nVars-sizeB, sizeB, 0, 0, pSched[sizeB], NULL, NULL) )
489 {
490 Vec_IntPush( vSets, Dau_DecCreateSet(pVarsB, sizeB, 0) );
491 continue;
492 }
493 if ( sizeB == 2 )
494 continue;
495 // iterate through shared sets of each size in the increasing order
496 for ( sizeS = 1; sizeS <= sizeB - 2; sizeS++ ) // shared set size
497 if ( sizeS <= 3 )
498// sizeS = 1;
499 for ( maskS = 0; maskS < (1 << sizeB); maskS++ ) // shared set
500 if ( Abc_TtBitCount16(maskS) == sizeS )
501 {
502 setMixed = Dau_DecCreateSet( pVarsB, sizeB, maskS );
503// printf( "Considering %10d ", setMixed );
504// Dau_DecPrintSet( setMixed, nVars );
505 // check if it exists
506 if ( Dau_DecSetIsContained(vSets, setMixed) )
507 continue;
508 // check if it can be added
509// if ( Dau_DecCheckSetTopOld(p, nVars, nVars-sizeB, sizeB, sizeS, maskS, NULL, NULL, NULL) )
510 if ( Dau_DecCheckSetTop(p, nVars, nVars-sizeB, sizeB, sizeS, maskS, pSched[sizeB], NULL, NULL) )
511 Vec_IntPush( vSets, setMixed );
512 }
513 }
514 return vSets;
515}
void Dau_DecMoveFreeToLSB(word *p, int nVars, int *V2P, int *P2V, int maskB, int sizeB)
Definition dauNonDsd.c:454
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Dau_DecPrintSet()

void Dau_DecPrintSet ( unsigned set,
int nVars,
int fNewLine )
extern

Definition at line 390 of file dauNonDsd.c.

391{
392 int v, Counter = 0;
393 int nUnique = 0, nShared = 0, nFree = 0;
394 Dau_DecSortSet( set, nVars, &nUnique, &nShared, &nFree );
395 printf( "S =%2d D =%2d C =%2d ", nShared, nUnique+nShared, nShared+nFree+1 );
396
397 printf( "x=" );
398 for ( v = 0; v < nVars; v++ )
399 {
400 int Value = ((set >> (v << 1)) & 3);
401 if ( Value == 1 )
402 printf( "%c", 'a' + v ), Counter++;
403 else if ( Value == 3 )
404 printf( "%c", 'A' + v ), Counter++;
405 else assert( Value == 0 );
406 }
407 printf( " y=x" );
408 for ( v = 0; v < nVars; v++ )
409 {
410 int Value = ((set >> (v << 1)) & 3);
411 if ( Value == 0 )
412 printf( "%c", 'a' + v ), Counter++;
413 else if ( Value == 3 )
414 printf( "%c", 'A' + v ), Counter++;
415 }
416 for ( ; Counter < 15; Counter++ )
417 printf( " " );
418 if ( fNewLine )
419 printf( "\n" );
420}
void Dau_DecSortSet(unsigned set, int nVars, int *pnUnique, int *pnShared, int *pnFree)
Definition dauNonDsd.c:371
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Dau_DecPrintSets()

void Dau_DecPrintSets ( Vec_Int_t * vSets,
int nVars )
extern

Definition at line 434 of file dauNonDsd.c.

435{
436 int i, Entry;
437 printf( "The %d-variable set family contains %d sets:\n", nVars, Vec_IntSize(vSets) );
438 Vec_IntForEachEntry( vSets, Entry, i )
439 Dau_DecPrintSet( (unsigned)Entry, nVars, 1 );
440 printf( "\n" );
441}
void Dau_DecPrintSet(unsigned set, int nVars, int fNewLine)
Definition dauNonDsd.c:390
#define Vec_IntForEachEntry(vVec, Entry, i)
MACRO DEFINITIONS ///.
Definition vecInt.h:54
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Dau_DecSortSet()

void Dau_DecSortSet ( unsigned set,
int nVars,
int * pnUnique,
int * pnShared,
int * pnFree )
extern

Definition at line 371 of file dauNonDsd.c.

372{
373 int v;
374 int nUnique = 0, nShared = 0, nFree = 0;
375 for ( v = 0; v < nVars; v++ )
376 {
377 int Value = ((set >> (v << 1)) & 3);
378 if ( Value == 1 )
379 nUnique++;
380 else if ( Value == 3 )
381 nShared++;
382 else if ( Value == 0 )
383 nFree++;
384 else assert( 0 );
385 }
386 *pnUnique = nUnique;
387 *pnShared = nShared;
388 *pnFree = nFree;
389}
Here is the caller graph for this function:

◆ Dau_Dsd6ToTruth()

word Dau_Dsd6ToTruth ( char * p)
extern

Definition at line 445 of file dauDsd.c.

446{
447 word Res;
448 if ( *p == '0' && *(p+1) == 0 )
449 Res = 0;
450 else if ( *p == '1' && *(p+1) == 0 )
451 Res = ~(word)0;
452 else
453 Res = Dau_Dsd6ToTruth_rec( p, &p, Dau_DsdComputeMatches(p), s_Truths6 );
454 assert( *++p == 0 );
455 return Res;
456}
int * Dau_DsdComputeMatches(char *p)
Definition dauDsd.c:80
word Dau_Dsd6ToTruth_rec(char *pStr, char **p, int *pMatches, word *pTruths)
Definition dauDsd.c:353
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Dau_DsdCheck1Step()

int Dau_DsdCheck1Step ( void * p,
word * pTruth,
int nVarsInit,
int * pVarLevels )
extern

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

Synopsis [Find the best cofactoring variable.]

Description [Return -2 if non-DSD; -1 if full DSD; otherwise, returns cofactoring variables i (i >= 0).]

SideEffects []

SeeAlso []

Definition at line 893 of file dauDsd.c.

894{
895 word pCofTemp[DAU_MAX_WORD];
896 int pVarPrios[DAU_MAX_VAR];
897 int nWords = Abc_TtWordNum(nVarsInit);
898 int nSizeNonDec, nSizeNonDec0, nSizeNonDec1;
899 int i, vBest = -2, nSumCofsBest = ABC_INFINITY, nSumCofs;
900 nSizeNonDec = Dau_DsdDecompose( pTruth, nVarsInit, 0, 0, NULL );
901 if ( nSizeNonDec == 0 )
902 return -1;
903 assert( nSizeNonDec > 0 );
904 // find variable priority
905 for ( i = 0; i < nVarsInit; i++ )
906 pVarPrios[i] = i;
907 if ( pVarLevels )
908 {
909 extern int Dau_DsdLevelVar( void * pMan, int iVar );
910 int pVarLevels[DAU_MAX_VAR];
911 for ( i = 0; i < nVarsInit; i++ )
912 pVarLevels[i] = -Dau_DsdLevelVar( p, i );
913// for ( i = 0; i < nVarsInit; i++ )
914// printf( "%d ", -pVarLevels[i] );
915// printf( "\n" );
916 Vec_IntSelectSortCost2( pVarPrios, nVarsInit, pVarLevels );
917// for ( i = 0; i < nVarsInit; i++ )
918// printf( "%d ", pVarPrios[i] );
919// printf( "\n\n" );
920 }
921 for ( i = 0; i < nVarsInit; i++ )
922 {
923 assert( pVarPrios[i] >= 0 && pVarPrios[i] < nVarsInit );
924 // try first cofactor
925 Abc_TtCofactor0p( pCofTemp, pTruth, nWords, pVarPrios[i] );
926 nSumCofs = Abc_TtSupportSize( pCofTemp, nVarsInit );
927 nSizeNonDec0 = Dau_DsdDecompose( pCofTemp, nVarsInit, 0, 0, NULL );
928 // try second cofactor
929 Abc_TtCofactor1p( pCofTemp, pTruth, nWords, pVarPrios[i] );
930 nSumCofs += Abc_TtSupportSize( pCofTemp, nVarsInit );
931 nSizeNonDec1 = Dau_DsdDecompose( pCofTemp, nVarsInit, 0, 0, NULL );
932 // compare cofactors
933 if ( nSizeNonDec0 || nSizeNonDec1 )
934 continue;
935 if ( nSumCofsBest > nSumCofs )
936 {
937 vBest = pVarPrios[i];
938 nSumCofsBest = nSumCofs;
939 }
940 }
941 return vBest;
942}
#define ABC_INFINITY
MACRO DEFINITIONS ///.
Definition abc_global.h:250
int Dau_DsdDecompose(word *pTruth, int nVarsInit, int fSplitPrime, int fWriteTruth, char *pRes)
Definition dauDsd.c:1912
int Dau_DsdLevelVar(void *pMan, int iVar)
Definition dauDsd.c:1018
#define DAU_MAX_WORD
Definition dau.h:44
#define DAU_MAX_VAR
INCLUDES ///.
Definition dau.h:42
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Dau_DsdComputeMatches()

int * Dau_DsdComputeMatches ( char * p)
extern

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

Synopsis [DSD formula manipulation.]

Description []

SideEffects []

SeeAlso []

Definition at line 80 of file dauDsd.c.

81{
82 static int pMatches[DAU_MAX_STR];
83 int pNested[DAU_MAX_VAR];
84 int v, nNested = 0;
85 for ( v = 0; p[v]; v++ )
86 {
87 pMatches[v] = 0;
88 if ( p[v] == '(' || p[v] == '[' || p[v] == '<' || p[v] == '{' )
89 pNested[nNested++] = v;
90 else if ( p[v] == ')' || p[v] == ']' || p[v] == '>' || p[v] == '}' )
91 pMatches[pNested[--nNested]] = v;
92 assert( nNested < DAU_MAX_VAR );
93 }
94 assert( nNested == 0 );
95 return pMatches;
96}
#define DAU_MAX_STR
Definition dau.h:43
Here is the caller graph for this function:

◆ Dau_DsdCountAnds()

int Dau_DsdCountAnds ( char * pDsd)
extern

Definition at line 316 of file dauDsd.c.

317{
318 if ( pDsd[1] == 0 )
319 return 0;
320 return Dau_DsdCountAnds_rec( pDsd, &pDsd, Dau_DsdComputeMatches(pDsd) );
321}
int Dau_DsdCountAnds_rec(char *pStr, char **p, int *pMatches)
Definition dauDsd.c:279
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Dau_DsdDecompose()

int Dau_DsdDecompose ( word * pTruth,
int nVarsInit,
int fSplitPrime,
int fWriteTruth,
char * pRes )
extern

Definition at line 1912 of file dauDsd.c.

1913{
1914 Dau_Dsd_t P, * p = &P;
1915 p->fSplitPrime = fSplitPrime;
1916 p->fWriteTruth = fWriteTruth;
1917 p->pVarLevels = NULL;
1918 p->nSizeNonDec = 0;
1919 if ( (pTruth[0] & 1) == 0 && Abc_TtIsConst0(pTruth, Abc_TtWordNum(nVarsInit)) )
1920 { if ( pRes ) pRes[0] = '0', pRes[1] = 0; }
1921 else if ( (pTruth[0] & 1) && Abc_TtIsConst1(pTruth, Abc_TtWordNum(nVarsInit)) )
1922 { if ( pRes ) pRes[0] = '1', pRes[1] = 0; }
1923 else
1924 {
1925 int Status = Dau_DsdDecomposeInt( p, pTruth, nVarsInit );
1926 Dau_DsdRemoveBraces( p->pOutput, Dau_DsdComputeMatches(p->pOutput) );
1927 if ( pRes )
1928 strcpy( pRes, p->pOutput );
1929 assert( fSplitPrime || Status != 1 );
1930 if ( fSplitPrime && Status == 2 )
1931 return -1;
1932 }
1933// assert( p->nSizeNonDec == 0 );
1934 return p->nSizeNonDec;
1935}
typedefABC_NAMESPACE_IMPL_START struct Dau_Dsd_t_ Dau_Dsd_t
DECLARATIONS ///.
Definition dauArray.c:29
int Dau_DsdDecomposeInt(Dau_Dsd_t *p, word *pTruth, int nVarsInit)
Definition dauDsd.c:1897
void Dau_DsdRemoveBraces(char *pDsd, int *pMatches)
Definition dauMerge.c:554
int * Dau_DsdComputeMatches(char *p)
Definition dauDsd.c:80
char * strcpy()
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Dau_DsdDecomposeLevel()

int Dau_DsdDecomposeLevel ( word * pTruth,
int nVarsInit,
int fSplitPrime,
int fWriteTruth,
char * pRes,
int * pVarLevels )
extern

Definition at line 1936 of file dauDsd.c.

1937{
1938 Dau_Dsd_t P, * p = &P;
1939 p->fSplitPrime = fSplitPrime;
1940 p->fWriteTruth = fWriteTruth;
1941 p->pVarLevels = pVarLevels;
1942 p->nSizeNonDec = 0;
1943 if ( (pTruth[0] & 1) == 0 && Abc_TtIsConst0(pTruth, Abc_TtWordNum(nVarsInit)) )
1944 { if ( pRes ) pRes[0] = '0', pRes[1] = 0; }
1945 else if ( (pTruth[0] & 1) && Abc_TtIsConst1(pTruth, Abc_TtWordNum(nVarsInit)) )
1946 { if ( pRes ) pRes[0] = '1', pRes[1] = 0; }
1947 else
1948 {
1949 int Status = Dau_DsdDecomposeInt( p, pTruth, nVarsInit );
1950 Dau_DsdRemoveBraces( p->pOutput, Dau_DsdComputeMatches(p->pOutput) );
1951 if ( pRes )
1952 strcpy( pRes, p->pOutput );
1953 assert( fSplitPrime || Status != 1 );
1954 if ( fSplitPrime && Status == 2 )
1955 return -1;
1956 }
1957// assert( p->nSizeNonDec == 0 );
1958 return p->nSizeNonDec;
1959}
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Dau_DsdMerge()

char * Dau_DsdMerge ( char * pDsd0i,
int * pPerm0,
char * pDsd1i,
int * pPerm1,
int fCompl0,
int fCompl1,
int nVars )
extern

DECLARATIONS ///.

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

Synopsis [Performs merging of two DSD formulas.]

Description []

SideEffects []

SeeAlso []

Definition at line 587 of file dauMerge.c.

588{
589 int fVerbose = 0;
590 int fCheck = 0;
591 static int Counter = 0;
592 static char pRes[2*DAU_MAX_STR+10];
593 char pDsd0[DAU_MAX_STR];
594 char pDsd1[DAU_MAX_STR];
595 int pMatches0[DAU_MAX_STR];
596 int pMatches1[DAU_MAX_STR];
597 int pVarPres[DAU_MAX_VAR];
598 int pOld2New[DAU_MAX_VAR];
599 int pNew2Old[DAU_MAX_VAR];
600 int pStatus0[DAU_MAX_STR];
601 int pStatus1[DAU_MAX_STR];
602 int pMatches[DAU_MAX_STR];
603 int nVarsShared, nVarsTotal;
604 Dau_Sto_t S, * pS = &S;
605 word * pTruth, * pt = NULL, * pt0 = NULL, * pt1 = NULL;
606 word pParts[3][DAU_MAX_WORD];
607 int Status;
608 abctime clk = Abc_Clock();
609 Counter++;
610 // create local copies
611 Dau_DsdMergeCopy( pDsd0i, fCompl0, pDsd0 );
612 Dau_DsdMergeCopy( pDsd1i, fCompl1, pDsd1 );
613if ( fVerbose )
614printf( "\nAfter copying:\n" );
615if ( fVerbose )
616printf( "%s\n", pDsd0 );
617if ( fVerbose )
618printf( "%s\n", pDsd1 );
619 // handle constants
620 if ( Dau_DsdIsConst(pDsd0) || Dau_DsdIsConst(pDsd1) )
621 {
622 if ( Dau_DsdIsConst0(pDsd0) )
623 strcpy( pRes, pDsd0 );
624 else if ( Dau_DsdIsConst1(pDsd0) )
625 strcpy( pRes, pDsd1 );
626 else if ( Dau_DsdIsConst0(pDsd1) )
627 strcpy( pRes, pDsd1 );
628 else if ( Dau_DsdIsConst1(pDsd1) )
629 strcpy( pRes, pDsd0 );
630 else assert( 0 );
631 return pRes;
632 }
633
634 // compute matches
635 Dau_DsdMergeMatches( pDsd0, pMatches0 );
636 Dau_DsdMergeMatches( pDsd1, pMatches1 );
637 // implement permutation
638 Dau_DsdMergeReplace( pDsd0, pMatches0, pPerm0 );
639 Dau_DsdMergeReplace( pDsd1, pMatches1, pPerm1 );
640if ( fVerbose )
641printf( "After replacement:\n" );
642if ( fVerbose )
643printf( "%s\n", pDsd0 );
644if ( fVerbose )
645printf( "%s\n", pDsd1 );
646
647
648 if ( fCheck )
649 {
650 pt0 = Dau_DsdToTruth( pDsd0, nVars );
651 Abc_TtCopy( pParts[0], pt0, Abc_TtWordNum(nVars), 0 );
652 }
653 if ( fCheck )
654 {
655 pt1 = Dau_DsdToTruth( pDsd1, nVars );
656 Abc_TtCopy( pParts[1], pt1, Abc_TtWordNum(nVars), 0 );
657 Abc_TtAnd( pParts[2], pParts[0], pParts[1], Abc_TtWordNum(nVars), 0 );
658 }
659
660 // find shared varaiables
661 nVarsShared = Dau_DsdMergeFindShared(pDsd0, pDsd1, pMatches0, pMatches1, pVarPres);
662 if ( nVarsShared == 0 )
663 {
664 sprintf( pRes, "(%s%s)", pDsd0, pDsd1 );
665if ( fVerbose )
666printf( "Disjoint:\n" );
667if ( fVerbose )
668printf( "%s\n", pRes );
669
670 Dau_DsdMergeMatches( pRes, pMatches );
671 Dau_DsdRemoveBraces( pRes, pMatches );
672 Dau_DsdNormalize( pRes );
673if ( fVerbose )
674printf( "Normalized:\n" );
675if ( fVerbose )
676printf( "%s\n", pRes );
677
678 s_TimeComp[0] += Abc_Clock() - clk;
679 return pRes;
680 }
681s_TimeComp[3] += Abc_Clock() - clk;
682 // create variable mapping
683 nVarsTotal = Dau_DsdMergeCreateMaps( pVarPres, nVarsShared, pOld2New, pNew2Old );
684 // perform variable replacement
685 Dau_DsdMergeReplace( pDsd0, pMatches0, pOld2New );
686 Dau_DsdMergeReplace( pDsd1, pMatches1, pOld2New );
687 // find uniqueness status
688 Dau_DsdMergeStatus( pDsd0, pMatches0, nVarsShared, pStatus0 );
689 Dau_DsdMergeStatus( pDsd1, pMatches1, nVarsShared, pStatus1 );
690if ( fVerbose )
691printf( "Individual status:\n" );
692if ( fVerbose )
693Dau_DsdMergePrintWithStatus( pDsd0, pStatus0 );
694if ( fVerbose )
695Dau_DsdMergePrintWithStatus( pDsd1, pStatus1 );
696 // prepare storage
697 Dau_DsdMergeStoreClean( pS, nVarsShared );
698 // perform substitutions
699 Dau_DsdMergeStoreCleanOutput( pS );
700 Dau_DsdMergeSubstitute( pS, pDsd0, pMatches0, pStatus0 );
701 strcpy( pDsd0, pS->pOutput );
702if ( fVerbose )
703printf( "Substitutions:\n" );
704if ( fVerbose )
705printf( "%s\n", pDsd0 );
706
707 // perform substitutions
708 Dau_DsdMergeStoreCleanOutput( pS );
709 Dau_DsdMergeSubstitute( pS, pDsd1, pMatches1, pStatus1 );
710 strcpy( pDsd1, pS->pOutput );
711if ( fVerbose )
712printf( "%s\n", pDsd1 );
713if ( fVerbose )
714Dau_DsdMergeStorePrintDefs( pS );
715
716 // create new function
717// assert( nVarsTotal <= 6 );
718 sprintf( pS->pOutput, "(%s%s)", pDsd0, pDsd1 );
719 pTruth = Dau_DsdToTruth( pS->pOutput, nVarsTotal );
720 Status = Dau_DsdDecompose( pTruth, nVarsTotal, 0, 1, pS->pOutput );
721//printf( "%d ", Status );
722 if ( Status == -1 ) // did not find 1-step DSD
723 return NULL;
724// if ( Status > 6 ) // non-DSD part is too large
725// return NULL;
726 if ( Dau_DsdIsConst(pS->pOutput) )
727 {
728 strcpy( pRes, pS->pOutput );
729 return pRes;
730 }
731if ( fVerbose )
732printf( "Decomposition:\n" );
733if ( fVerbose )
734printf( "%s\n", pS->pOutput );
735 // substitute definitions
736 Dau_DsdMergeMatches( pS->pOutput, pMatches );
737 Dau_DsdMergeInlineDefinitions( pS->pOutput, pMatches, pS, pRes, nVarsShared );
738if ( fVerbose )
739printf( "Inlining:\n" );
740if ( fVerbose )
741printf( "%s\n", pRes );
742 // perform variable replacement
743 Dau_DsdMergeMatches( pRes, pMatches );
744 Dau_DsdMergeReplace( pRes, pMatches, pNew2Old );
745 Dau_DsdRemoveBraces( pRes, pMatches );
746if ( fVerbose )
747printf( "Replaced:\n" );
748if ( fVerbose )
749printf( "%s\n", pRes );
750 Dau_DsdNormalize( pRes );
751if ( fVerbose )
752printf( "Normalized:\n" );
753if ( fVerbose )
754printf( "%s\n", pRes );
755
756 if ( fCheck )
757 {
758 pt = Dau_DsdToTruth( pRes, nVars );
759 if ( !Abc_TtEqual( pParts[2], pt, Abc_TtWordNum(nVars) ) )
760 printf( "Dau_DsdMerge(): Verification failed!\n" );
761 }
762
763 if ( Status == 0 )
764 s_TimeComp[1] += Abc_Clock() - clk;
765 else
766 s_TimeComp[2] += Abc_Clock() - clk;
767 return pRes;
768}
ABC_INT64_T abctime
Definition abc_global.h:332
abctime s_TimeComp[4]
Definition dauMerge.c:574
typedefABC_NAMESPACE_IMPL_START struct Dau_Sto_t_ Dau_Sto_t
DECLARATIONS ///.
Definition dauMerge.c:47
void Dau_DsdRemoveBraces(char *pDsd, int *pMatches)
Definition dauMerge.c:554
word * Dau_DsdToTruth(char *p, int nVars)
Definition dauDsd.c:609
int Dau_DsdDecompose(word *pTruth, int nVarsInit, int fSplitPrime, int fWriteTruth, char *pRes)
Definition dauDsd.c:1912
void Dau_DsdNormalize(char *p)
Definition dauDsd.c:260
char * sprintf()
Here is the caller graph for this function:

◆ Dau_DsdNormalize()

void Dau_DsdNormalize ( char * p)
extern

Definition at line 260 of file dauDsd.c.

261{
262 if ( pDsd[1] != 0 )
263 Dau_DsdNormalize_rec( pDsd, &pDsd, Dau_DsdComputeMatches(pDsd) );
264}
void Dau_DsdNormalize_rec(char *pStr, char **p, int *pMatches)
Definition dauDsd.c:205
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Dau_DsdPrintFromTruth()

void Dau_DsdPrintFromTruth ( word * pTruth,
int nVarsInit )
extern

Definition at line 1968 of file dauDsd.c.

1969{
1970 char pRes[DAU_MAX_STR];
1971 word pTemp[DAU_MAX_WORD];
1972 Abc_TtCopy( pTemp, pTruth, Abc_TtWordNum(nVarsInit), 0 );
1973 Dau_DsdDecompose( pTemp, nVarsInit, 0, 1, pRes );
1974 fprintf( stdout, "%s\n", pRes );
1975}
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Dau_DsdPrintFromTruthFile()

void Dau_DsdPrintFromTruthFile ( FILE * pFile,
word * pTruth,
int nVarsInit )
extern

Definition at line 1960 of file dauDsd.c.

1961{
1962 char pRes[DAU_MAX_STR];
1963 word pTemp[DAU_MAX_WORD];
1964 Abc_TtCopy( pTemp, pTruth, Abc_TtWordNum(nVarsInit), 0 );
1965 Dau_DsdDecompose( pTemp, nVarsInit, 0, 1, pRes );
1966 fprintf( pFile, "%s\n", pRes );
1967}
Here is the call graph for this function:

◆ Dau_DsdRemoveBraces()

void Dau_DsdRemoveBraces ( char * pDsd,
int * pMatches )
extern

Definition at line 554 of file dauMerge.c.

555{
556 char * q, * p = pDsd;
557 if ( pDsd[1] == 0 )
558 return;
559 Dau_DsdRemoveBraces_rec( pDsd, &pDsd, pMatches );
560 for ( q = p; *p; p++ )
561 if ( *p != ' ' )
562 {
563 if ( *p == '!' && p != q && *(q-1) == '!' )
564 {
565 q--;
566 continue;
567 }
568 *q++ = *p;
569 }
570 *q = 0;
571}
void Dau_DsdRemoveBraces_rec(char *pStr, char **p, int *pMatches)
Definition dauMerge.c:520
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Dau_DsdToTruth()

word * Dau_DsdToTruth ( char * p,
int nVars )
extern

Definition at line 609 of file dauDsd.c.

610{
611 int nWords = Abc_TtWordNum( nVars );
612 word ** pTtElems = Dau_DsdTtElems();
613 word * pRes = pTtElems[DAU_MAX_VAR];
614 assert( nVars <= DAU_MAX_VAR );
615 if ( Dau_DsdIsConst0(p) )
616 Abc_TtConst0( pRes, nWords );
617 else if ( Dau_DsdIsConst1(p) )
618 Abc_TtConst1( pRes, nWords );
619 else
620 Dau_DsdToTruth_rec( p, &p, Dau_DsdComputeMatches(p), pTtElems, pRes, nVars );
621 assert( *++p == 0 );
622 return pRes;
623}
void Dau_DsdToTruth_rec(char *pStr, char **p, int *pMatches, word **pTtElems, word *pRes, int nVars)
Definition dauDsd.c:535
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Dau_DsdTruthCompose_rec()

void Dau_DsdTruthCompose_rec ( word * pFunc,
word pFanins[DAU_MAX_VAR][DAU_MAX_WORD],
word * pRes,
int nVars,
int nWordsR )
extern

Definition at line 501 of file dauDsd.c.

502{
503 int nWordsF;
504 if ( nVars <= 6 )
505 {
506 Dau_DsdTruth6Compose_rec( pFunc[0], pFanins, pRes, nVars, nWordsR );
507 return;
508 }
509 nWordsF = Abc_TtWordNum( nVars );
510 assert( nWordsF > 1 );
511 if ( Abc_TtIsConst0(pFunc, nWordsF) )
512 {
513 Abc_TtConst0( pRes, nWordsR );
514 return;
515 }
516 if ( Abc_TtIsConst1(pFunc, nWordsF) )
517 {
518 Abc_TtConst1( pRes, nWordsR );
519 return;
520 }
521 if ( !Abc_TtHasVar( pFunc, nVars, nVars-1 ) )
522 {
523 Dau_DsdTruthCompose_rec( pFunc, pFanins, pRes, nVars-1, nWordsR );
524 return;
525 }
526 {
527 word pTtTemp[2][DAU_MAX_WORD];
528 nVars--;
529 Dau_DsdTruthCompose_rec( pFunc, pFanins, pTtTemp[0], nVars, nWordsR );
530 Dau_DsdTruthCompose_rec( pFunc + nWordsF/2, pFanins, pTtTemp[1], nVars, nWordsR );
531 Abc_TtMux( pRes, pFanins[nVars], pTtTemp[1], pTtTemp[0], nWordsR );
532 return;
533 }
534}
void Dau_DsdTruth6Compose_rec(word Func, word pFanins[DAU_MAX_VAR][DAU_MAX_WORD], word *pRes, int nVars, int nWordsR)
Definition dauDsd.c:469
void Dau_DsdTruthCompose_rec(word *pFunc, word pFanins[DAU_MAX_VAR][DAU_MAX_WORD], word *pRes, int nVars, int nWordsR)
Definition dauDsd.c:501
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Dsm_ManDeriveGia()

void * Dsm_ManDeriveGia ( void * pGia,
int fUseMuxes )
extern

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

Synopsis [Performs structural hashing on the LUT functions.]

Description []

SideEffects []

SeeAlso []

Definition at line 503 of file dauGia.c.

504{
505 Gia_Man_t * p = (Gia_Man_t *)pGia;
506 Gia_Man_t * pNew, * pTemp;
507 Vec_Int_t * vCover, * vLeaves;
508 Gia_Obj_t * pObj;
509 int k, i, iLut, iVar;
510 word * pTruth;
511 assert( Gia_ManHasMapping(p) );
512 // create new manager
513 pNew = Gia_ManStart( 6*Gia_ManObjNum(p)/5 + 100 );
514 pNew->pName = Abc_UtilStrsav( p->pName );
515 pNew->pSpec = Abc_UtilStrsav( p->pSpec );
516 pNew->vLevels = Vec_IntStart( 6*Gia_ManObjNum(p)/5 + 100 );
517 if ( fUseMuxes )
518 pNew->pMuxes = ABC_CALLOC( unsigned, pNew->nObjsAlloc );
519 // map primary inputs
521 Gia_ManConst0(p)->Value = 0;
522 Gia_ManForEachCi( p, pObj, i )
523 pObj->Value = Gia_ManAppendCi(pNew);
524 // iterate through nodes used in the mapping
525 vLeaves = Vec_IntAlloc( 16 );
526 vCover = Vec_IntAlloc( 1 << 16 );
527 Gia_ManHashStart( pNew );
529 Gia_ManForEachAnd( p, pObj, iLut )
530 {
531 if ( Gia_ObjIsBuf(pObj) )
532 {
533 pObj->Value = Gia_ManAppendBuf( pNew, Gia_ObjFanin0Copy(pObj) );
534 continue;
535 }
536 if ( !Gia_ObjIsLut(p, iLut) )
537 continue;
538 // collect leaves
539 Vec_IntClear( vLeaves );
540 Gia_LutForEachFanin( p, iLut, iVar, k )
541 Vec_IntPush( vLeaves, iVar );
542 pTruth = Gia_ObjComputeTruthTableCut( p, Gia_ManObj(p, iLut), vLeaves );
543 // collect incoming literals
544 Vec_IntClear( vLeaves );
545 Gia_LutForEachFanin( p, iLut, iVar, k )
546 Vec_IntPush( vLeaves, Gia_ManObj(p, iVar)->Value );
547 Gia_ManObj(p, iLut)->Value = Dsm_ManTruthToGia( pNew, pTruth, vLeaves, vCover );
548 }
550 Gia_ManForEachCo( p, pObj, i )
551 pObj->Value = Gia_ManAppendCo( pNew, Gia_ObjFanin0Copy(pObj) );
552 Gia_ManHashStop( pNew );
553 Gia_ManSetRegNum( pNew, Gia_ManRegNum(p) );
554 Vec_IntFree( vLeaves );
555 Vec_IntFree( vCover );
556/*
557 Gia_ManForEachAnd( pNew, pObj, i )
558 {
559 int iLev = Gia_ObjLevelId(pNew, i);
560 int iLev0 = Gia_ObjLevelId(pNew, Gia_ObjFaninId0(pObj, i));
561 int iLev1 = Gia_ObjLevelId(pNew, Gia_ObjFaninId1(pObj, i));
562 assert( iLev == 1 + Abc_MaxInt(iLev0, iLev1) );
563 }
564*/
565 // perform cleanup
566 pNew = Gia_ManCleanup( pTemp = pNew );
567 Gia_ManStop( pTemp );
568 return pNew;
569}
int Dsm_ManTruthToGia(void *p, word *pTruth, Vec_Int_t *vLeaves, Vec_Int_t *vCover)
Definition dauGia.c:441
void Gia_ManStop(Gia_Man_t *p)
Definition giaMan.c:82
word * Gia_ObjComputeTruthTableCut(Gia_Man_t *p, Gia_Obj_t *pObj, Vec_Int_t *vLeaves)
Definition giaTruth.c:628
void Gia_ManHashStart(Gia_Man_t *p)
Definition giaHash.c:125
#define Gia_ManForEachAnd(p, pObj, i)
Definition gia.h:1214
void Gia_ManSetRegNum(Gia_Man_t *p, int nRegs)
Definition giaMan.c:764
Gia_Man_t * Gia_ManStart(int nObjsMax)
FUNCTION DEFINITIONS ///.
Definition giaMan.c:57
struct Gia_Obj_t_ Gia_Obj_t
Definition gia.h:76
#define Gia_LutForEachFanin(p, i, iFan, k)
Definition gia.h:1161
void Gia_ManFillValue(Gia_Man_t *p)
Definition giaUtil.c:369
struct Gia_Man_t_ Gia_Man_t
Definition gia.h:96
Gia_Man_t * Gia_ManCleanup(Gia_Man_t *p)
Definition giaScl.c:84
void Gia_ObjComputeTruthTableStart(Gia_Man_t *p, int nVarsMax)
Definition giaTruth.c:552
int Gia_ManLutSizeMax(Gia_Man_t *p)
Definition giaIf.c:127
void Gia_ObjComputeTruthTableStop(Gia_Man_t *p)
Definition giaTruth.c:568
#define Gia_ManForEachCo(p, pObj, i)
Definition gia.h:1236
#define Gia_ManForEachCi(p, pObj, i)
Definition gia.h:1228
void Gia_ManHashStop(Gia_Man_t *p)
Definition giaHash.c:149
Vec_Int_t * vLevels
Definition gia.h:120
unsigned * pMuxes
Definition gia.h:106
char * pSpec
Definition gia.h:100
int nObjsAlloc
Definition gia.h:104
char * pName
Definition gia.h:99
unsigned Value
Definition gia.h:89
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Dsm_ManTruthToGia()

int Dsm_ManTruthToGia ( void * p,
word * pTruth,
Vec_Int_t * vLeaves,
Vec_Int_t * vCover )
extern

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

Synopsis [Convert TT to GIA via DSD.]

Description []

SideEffects []

SeeAlso []

Definition at line 441 of file dauGia.c.

442{
443 int fUseMuxes = 0;
444 int fDelayBalance = 1;
445 Gia_Man_t * pGia = (Gia_Man_t *)p;
446 int nSizeNonDec;
447 char pDsd[DAU_MAX_STR];
448 word pTruthCopy[DAU_MAX_WORD];
449 Abc_TtCopy( pTruthCopy, pTruth, Abc_TtWordNum(Vec_IntSize(vLeaves)), 0 );
450 m_Calls++;
451 assert( Vec_IntSize(vLeaves) <= DAU_DSD_MAX_VAR );
452 if ( Vec_IntSize(vLeaves) == 0 )
453 return (int)(pTruth[0] & 1);
454 if ( Vec_IntSize(vLeaves) == 1 )
455 return Abc_LitNotCond( Vec_IntEntry(vLeaves, 0), (int)(pTruth[0] & 1) );
456 // collect delay information
457 if ( fDelayBalance && fUseMuxes )
458 {
459 int i, iLit, pVarLevels[DAU_DSD_MAX_VAR];
460 Vec_IntForEachEntry( vLeaves, iLit, i )
461 pVarLevels[i] = Gia_ObjLevelId( pGia, Abc_Lit2Var(iLit) );
462 nSizeNonDec = Dau_DsdDecomposeLevel( pTruthCopy, Vec_IntSize(vLeaves), fUseMuxes, 1, pDsd, pVarLevels );
463 }
464 else
465 nSizeNonDec = Dau_DsdDecompose( pTruthCopy, Vec_IntSize(vLeaves), fUseMuxes, 1, pDsd );
466 if ( nSizeNonDec )
467 m_NonDsd++;
468// printf( "%s\n", pDsd );
469 if ( fDelayBalance && pGia->vLevels )
470 return Dau_DsdToGia( pGia, pDsd, Vec_IntArray(vLeaves), vCover );
471 else
472 return Dau_DsdToGia2( pGia, pDsd, Vec_IntArray(vLeaves), vCover );
473}
int Dau_DsdToGia2(Gia_Man_t *pGia, char *p, int *pLits, Vec_Int_t *vCover)
Definition dauGia.c:195
#define DAU_DSD_MAX_VAR
Definition dauGia.c:33
int Dau_DsdToGia(Gia_Man_t *pGia, char *p, int *pLits, Vec_Int_t *vCover)
Definition dauGia.c:417
int Dau_DsdDecomposeLevel(word *pTruth, int nVarsInit, int fSplitPrime, int fWriteTruth, char *pRes, int *pVarLevels)
Definition dauDsd.c:1936
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Dss_ManAlloc()

Dss_Man_t * Dss_ManAlloc ( int nVars,
int nNonDecLimit )
extern

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 967 of file dauTree.c.

968{
969 Dss_Man_t * p;
970 p = ABC_CALLOC( Dss_Man_t, 1 );
971 p->nVars = nVars;
972 p->nNonDecLimit = nNonDecLimit;
973 p->nBins = Abc_PrimeCudd( 1000000 );
974 p->pBins = ABC_CALLOC( unsigned, p->nBins );
975 p->pMem = Mem_FlexStart();
976 p->vObjs = Vec_PtrAlloc( 10000 );
977 p->vNexts = Vec_IntAlloc( 10000 );
978 Dss_ObjAlloc( p, DAU_DSD_CONST0, 0, 0 );
979 Dss_ObjAlloc( p, DAU_DSD_VAR, 0, 0 )->nSupp = 1;
980 p->vLeaves = Vec_IntAlloc( 32 );
981 p->vCopies = Vec_IntAlloc( 32 );
982 p->pTtElems = Dss_ManTtElems();
983 p->pMemEnts = Mem_FlexStart();
984// Dss_ManCacheAlloc( p );
985 return p;
986}
Dss_Obj_t * Dss_ObjAlloc(Dss_Man_t *p, int Type, int nFans, int nTruthVars)
Definition dauTree.c:760
struct Dss_Man_t_ Dss_Man_t
Definition dau.h:61
Mem_Flex_t * Mem_FlexStart()
Definition mem.c:327
unsigned nSupp
Definition dauTree.c:56
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Dss_ManFree()

void Dss_ManFree ( Dss_Man_t * p)
extern

Definition at line 987 of file dauTree.c.

988{
989 Abc_PrintTime( 1, "Time begin ", p->timeBeg );
990 Abc_PrintTime( 1, "Time decomp", p->timeDec );
991 Abc_PrintTime( 1, "Time lookup", p->timeLook );
992 Abc_PrintTime( 1, "Time end ", p->timeEnd );
993
994// Dss_ManCacheProfile( p );
996 Mem_FlexStop( p->pMemEnts, 0 );
997 Vec_IntFreeP( &p->vCopies );
998 Vec_IntFreeP( &p->vLeaves );
999 Vec_IntFreeP( &p->vNexts );
1000 Vec_PtrFreeP( &p->vObjs );
1001 Mem_FlexStop( p->pMem, 0 );
1002 ABC_FREE( p->pBins );
1003 ABC_FREE( p );
1004}
void Dss_ManCacheFree(Dss_Man_t *p)
Definition dauTree.c:896
void Mem_FlexStop(Mem_Flex_t *p, int fVerbose)
Definition mem.c:359
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Dss_ManMerge()

int Dss_ManMerge ( Dss_Man_t * p,
int * iDsd,
int * nFans,
int ** pFans,
unsigned uSharedMask,
int nKLutSize,
unsigned char * pPerm,
word * pTruth )
extern

Definition at line 1539 of file dauTree.c.

1540{
1541 int fVerbose = 0;
1542 int fCheck = 0;
1543 static int Counter = 0;
1544// word pTtTemp[DAU_MAX_WORD];
1545 word * pTruthOne;
1546 int pPermResInt[DAU_MAX_VAR];
1547 Dss_Ent_t * pEnt, ** ppSpot;
1548 Dss_Fun_t * pFun;
1549 int i;
1550 abctime clk;
1551 Counter++;
1552 if ( DAU_MAX_VAR < nKLutSize )
1553 {
1554 printf( "Parameter DAU_MAX_VAR (%d) smaller than LUT size (%d).\n", DAU_MAX_VAR, nKLutSize );
1555 return -1;
1556 }
1557 assert( iDsd[0] <= iDsd[1] );
1558
1559if ( fVerbose )
1560{
1561Dss_ManPrintOne( stdout, p, iDsd[0], pFans[0] );
1562Dss_ManPrintOne( stdout, p, iDsd[1], pFans[1] );
1563}
1564
1565 // constant argument
1566 if ( iDsd[0] == 0 ) return 0;
1567 if ( iDsd[0] == 1 ) return iDsd[1];
1568 if ( iDsd[1] == 0 ) return 0;
1569 if ( iDsd[1] == 1 ) return iDsd[0];
1570
1571 // no overlap
1572clk = Abc_Clock();
1573 assert( nFans[0] == Dss_VecLitSuppSize(p->vObjs, iDsd[0]) );
1574 assert( nFans[1] == Dss_VecLitSuppSize(p->vObjs, iDsd[1]) );
1575 assert( nFans[0] + nFans[1] <= nKLutSize + Dss_WordCountOnes(uSharedMask) );
1576 // create map of shared variables
1577 pEnt = Dss_ManSharedMap( p, iDsd, nFans, pFans, uSharedMask );
1578p->timeBeg += Abc_Clock() - clk;
1579 // check cache
1580 if ( p->pCache == NULL )
1581 {
1582clk = Abc_Clock();
1583 if ( uSharedMask == 0 )
1584 pFun = Dss_ManOperationFun( p, iDsd, nFans[0] + nFans[1] );
1585 else
1586 pFun = Dss_ManBooleanAnd( p, pEnt, 0 );
1587 if ( pFun == NULL )
1588 return -1;
1589 assert( (int)pFun->nFans == Dss_VecLitSuppSize(p->vObjs, pFun->iDsd) );
1590 assert( (int)pFun->nFans <= nKLutSize );
1591p->timeDec += Abc_Clock() - clk;
1592 }
1593 else
1594 {
1595clk = Abc_Clock();
1596 ppSpot = Dss_ManCacheLookup( p, pEnt );
1597p->timeLook += Abc_Clock() - clk;
1598clk = Abc_Clock();
1599 if ( *ppSpot == NULL )
1600 {
1601 if ( uSharedMask == 0 )
1602 pFun = Dss_ManOperationFun( p, iDsd, nFans[0] + nFans[1] );
1603 else
1604 pFun = Dss_ManBooleanAnd( p, pEnt, 0 );
1605 if ( pFun == NULL )
1606 return -1;
1607 assert( (int)pFun->nFans == Dss_VecLitSuppSize(p->vObjs, pFun->iDsd) );
1608 assert( (int)pFun->nFans <= nKLutSize );
1609 // create cache entry
1610 *ppSpot = Dss_ManCacheCreate( p, pEnt, pFun );
1611 }
1612 pFun = (*ppSpot)->pFunc;
1613p->timeDec += Abc_Clock() - clk;
1614 }
1615
1616clk = Abc_Clock();
1617 for ( i = 0; i < (int)pFun->nFans; i++ )
1618 if ( pFun->pFans[i] < 2 * nFans[0] ) // first dec
1619 pPermRes[i] = (unsigned char)Dss_Lit2Lit( pFans[0], pFun->pFans[i] );
1620 else
1621 pPermRes[i] = (unsigned char)Dss_Lit2Lit( pFans[1], pFun->pFans[i] - 2 * nFans[0] );
1622 // perform support minimization
1623 if ( uSharedMask && pFun->nFans > 1 )
1624 {
1625 int pVarPres[DAU_MAX_VAR];
1626 int nSupp = 0;
1627 for ( i = 0; i < p->nVars; i++ )
1628 pVarPres[i] = -1;
1629 for ( i = 0; i < (int)pFun->nFans; i++ )
1630 pVarPres[ Abc_Lit2Var(pPermRes[i]) ] = i;
1631 for ( i = 0; i < p->nVars; i++ )
1632 if ( pVarPres[i] >= 0 )
1633 pPermRes[pVarPres[i]] = Abc_Var2Lit( nSupp++, Abc_LitIsCompl(pPermRes[pVarPres[i]]) );
1634 assert( nSupp == (int)pFun->nFans );
1635 }
1636
1637 for ( i = 0; i < (int)pFun->nFans; i++ )
1638 pPermResInt[i] = pPermRes[i];
1639p->timeEnd += Abc_Clock() - clk;
1640
1641if ( fVerbose )
1642{
1643Dss_ManPrintOne( stdout, p, pFun->iDsd, pPermResInt );
1644printf( "\n" );
1645}
1646
1647if ( Counter == 43418 )
1648{
1649// int s = 0;
1650// Dss_ManPrint( NULL, p );
1651}
1652
1653
1654 if ( fCheck )
1655 {
1656 pTruthOne = Dss_ManComputeTruth( p, pFun->iDsd, p->nVars, pPermResInt );
1657 if ( !Abc_TtEqual( pTruthOne, pTruth, Abc_TtWordNum(p->nVars) ) )
1658 {
1659 int s;
1660 // Kit_DsdPrintFromTruth( pTruthOne, p->nVars ); printf( "\n" );
1661 // Kit_DsdPrintFromTruth( pTruth, p->nVars ); printf( "\n" );
1662 printf( "Verification failed.\n" );
1663 s = 0;
1664 }
1665 }
1666 return pFun->iDsd;
1667}
Dss_Ent_t * Dss_ManSharedMap(Dss_Man_t *p, int *iDsd, int *nFans, int **pFans, unsigned uSharedMask)
Definition dauTree.c:1510
Dss_Ent_t ** Dss_ManCacheLookup(Dss_Man_t *p, Dss_Ent_t *pEnt)
Definition dauTree.c:927
struct Dss_Ent_t_ Dss_Ent_t
Definition dauTree.c:39
Dss_Fun_t * Dss_ManBooleanAnd(Dss_Man_t *p, Dss_Ent_t *pEnt, int Counter)
Definition dauTree.c:1433
typedefABC_NAMESPACE_IMPL_START struct Dss_Fun_t_ Dss_Fun_t
DECLARATIONS ///.
Definition dauTree.c:31
Dss_Fun_t * Dss_ManOperationFun(Dss_Man_t *p, int *iDsd, int nFansTot)
Definition dauTree.c:1389
Dss_Ent_t * Dss_ManCacheCreate(Dss_Man_t *p, Dss_Ent_t *pEnt0, Dss_Fun_t *pFun0)
Definition dauTree.c:944
word * Dss_ManComputeTruth(Dss_Man_t *p, int iDsd, int nVars, int *pPermLits)
Definition dauTree.c:1192
void Dss_ManPrintOne(FILE *pFile, Dss_Man_t *p, int iDsdLit, int *pPermLits)
Definition dauTree.c:1030
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Dss_ManPrint()

void Dss_ManPrint ( char * pFileName,
Dss_Man_t * p )
extern

Definition at line 1086 of file dauTree.c.

1087{
1088 Dss_Obj_t * pObj;
1089 int CountNonDsd = 0, CountNonDsdStr = 0;
1090 int i, clk = Abc_Clock();
1091 FILE * pFile;
1092 pFile = pFileName ? fopen( pFileName, "wb" ) : stdout;
1093 if ( pFileName && pFile == NULL )
1094 {
1095 printf( "cannot open output file\n" );
1096 return;
1097 }
1098 Dss_VecForEachObj( p->vObjs, pObj, i )
1099 {
1100 CountNonDsd += (pObj->Type == DAU_DSD_PRIME);
1101 CountNonDsdStr += Dss_ManCheckNonDec_rec( p, pObj );
1102 }
1103 fprintf( pFile, "Total number of objects = %8d\n", Vec_PtrSize(p->vObjs) );
1104 fprintf( pFile, "Non-DSD objects (max =%2d) = %8d\n", p->nNonDecLimit, CountNonDsd );
1105 fprintf( pFile, "Non-DSD structures = %8d\n", CountNonDsdStr );
1106 fprintf( pFile, "Memory used for objects = %6.2f MB.\n", 1.0*Mem_FlexReadMemUsage(p->pMem)/(1<<20) );
1107 fprintf( pFile, "Memory used for array = %6.2f MB.\n", 1.0*sizeof(void *)*Vec_PtrCap(p->vObjs)/(1<<20) );
1108 fprintf( pFile, "Memory used for hash table = %6.2f MB.\n", 1.0*sizeof(int)*p->nBins/(1<<20) );
1109 fprintf( pFile, "Memory used for cache = %6.2f MB.\n", 1.0*Mem_FlexReadMemUsage(p->pMemEnts)/(1<<20) );
1110 fprintf( pFile, "Cache hits = %8d %8d\n", p->nCacheHits[0], p->nCacheHits[1] );
1111 fprintf( pFile, "Cache misses = %8d %8d\n", p->nCacheMisses[0], p->nCacheMisses[1] );
1112 fprintf( pFile, "Cache entries = %8d %8d\n", p->nCacheEntries[0], p->nCacheEntries[1] );
1113 Abc_PrintTime( 1, "Time", Abc_Clock() - clk );
1114// Dss_ManHashProfile( p );
1115// Dss_ManDump( p );
1116// return;
1117 Dss_VecForEachObj( p->vObjs, pObj, i )
1118 {
1119 if ( i == 50 )
1120 break;
1121 Dss_ManPrintOne( pFile, p, Dss_Obj2Lit(pObj), NULL );
1122 }
1123 fprintf( pFile, "\n" );
1124 if ( pFileName )
1125 fclose( pFile );
1126}
int Dss_ManCheckNonDec_rec(Dss_Man_t *p, Dss_Obj_t *pObj)
Definition dauTree.c:1040
#define Dss_VecForEachObj(vVec, pObj, i)
Definition dauTree.c:127
struct Dss_Obj_t_ Dss_Obj_t
Definition dauTree.c:51
int Mem_FlexReadMemUsage(Mem_Flex_t *p)
Definition mem.c:461
unsigned Type
Definition dauTree.c:55
Here is the call graph for this function:
Here is the caller graph for this function: