ABC: A System for Sequential Synthesis and Verification
 
Loading...
Searching...
No Matches
extraBddMisc.c File Reference
#include "extraBdd.h"
Include dependency graph for extraBddMisc.c:

Go to the source code of this file.

Functions

void ddSupportStep2 (DdNode *f, int *support)
 
void ddClearFlag2 (DdNode *f)
 
DdNode * Extra_TransferPermute (DdManager *ddSource, DdManager *ddDestination, DdNode *f, int *Permute)
 
DdNode * Extra_TransferLevelByLevel (DdManager *ddSource, DdManager *ddDestination, DdNode *f)
 
DdNode * Extra_bddRemapUp (DdManager *dd, DdNode *bF)
 
DdNode * Extra_bddMove (DdManager *dd, DdNode *bF, int nVars)
 
void Extra_StopManager (DdManager *dd)
 
void Extra_bddPrint (DdManager *dd, DdNode *F)
 
void Extra_bddPrintSupport (DdManager *dd, DdNode *F)
 
int Extra_bddSuppSize (DdManager *dd, DdNode *bSupp)
 
int Extra_bddSuppContainVar (DdManager *dd, DdNode *bS, DdNode *bVar)
 
int Extra_bddSuppOverlapping (DdManager *dd, DdNode *S1, DdNode *S2)
 
int Extra_bddSuppDifferentVars (DdManager *dd, DdNode *S1, DdNode *S2, int DiffMax)
 
int Extra_bddSuppCheckContainment (DdManager *dd, DdNode *bL, DdNode *bH, DdNode **bLarge, DdNode **bSmall)
 
int * Extra_SupportArray (DdManager *dd, DdNode *f, int *support)
 
int * Extra_VectorSupportArray (DdManager *dd, DdNode **F, int n, int *support)
 
DdNode * Extra_bddFindOneCube (DdManager *dd, DdNode *bF)
 
DdNode * Extra_bddGetOneCube (DdManager *dd, DdNode *bFunc)
 
DdNode * Extra_bddComputeRangeCube (DdManager *dd, int iStart, int iStop)
 
DdNode * Extra_bddBitsToCube (DdManager *dd, int Code, int CodeWidth, DdNode **pbVars, int fMsbFirst)
 
DdNode * Extra_bddSupportNegativeCube (DdManager *dd, DdNode *f)
 
int Extra_bddIsVar (DdNode *bFunc)
 
DdNode * Extra_bddCreateAnd (DdManager *dd, int nVars)
 
DdNode * Extra_bddCreateOr (DdManager *dd, int nVars)
 
DdNode * Extra_bddCreateExor (DdManager *dd, int nVars)
 
DdNode * Extra_zddPrimes (DdManager *dd, DdNode *F)
 
void Extra_bddPermuteArray (DdManager *manager, DdNode **bNodesIn, DdNode **bNodesOut, int nNodes, int *permut)
 
DdNode * Extra_bddComputeCube (DdManager *dd, DdNode **bXVars, int nVars)
 
DdNode * Extra_bddChangePolarity (DdManager *dd, DdNode *bFunc, DdNode *bVars)
 
int Extra_bddVarIsInCube (DdNode *bCube, int iVar)
 
DdNode * Extra_bddAndPermute (DdManager *ddF, DdNode *bF, DdManager *ddG, DdNode *bG, int *pPermute)
 
DdNode * extraBddMove (DdManager *dd, DdNode *bF, DdNode *bDist)
 
void extraDecomposeCover (DdManager *dd, DdNode *zC, DdNode **zC0, DdNode **zC1, DdNode **zC2)
 
int Extra_bddCountCubes (DdManager *dd, DdNode **pFuncs, int nFuncs, int fMode, int nLimit, int *pGuide)
 
DdNode * extraComposeCover (DdManager *dd, DdNode *zC0, DdNode *zC1, DdNode *zC2, int TopVar)
 
DdNode * extraBddChangePolarity (DdManager *dd, DdNode *bFunc, DdNode *bVars)
 
void Extra_TestAndPerm (DdManager *ddF, DdNode *bF, DdNode *bG)
 
void Extra_zddDumpPla (DdManager *dd, DdNode *F, int nVars, char *pFileName)
 
void Extra_GraphExperiment ()
 
DdNode * extraZddCombination (DdManager *dd, int *VarValues, int nVars)
 
DdNode * Extra_zddCombination (DdManager *dd, int *VarValues, int nVars)
 
DdNode * Extra_zddRandomSet (DdManager *dd, int n, int k, double d)
 
void Extra_ZddTest ()
 
DdNode * extraBddTuples (DdManager *dd, DdNode *bVarsK, DdNode *bVarsN)
 
DdNode * Extra_bddTuples (DdManager *dd, int K, DdNode *VarsN)
 

Function Documentation

◆ ddClearFlag2()

void ddClearFlag2 ( DdNode * f)

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

Synopsis [Performs a DFS from f, clearing the LSB of the next pointers.]

Description []

SideEffects [None]

SeeAlso [ddSupportStep ddDagInt]

Definition at line 1724 of file extraBddMisc.c.

1726{
1727 if (!Cudd_IsComplement(f->next)) {
1728 return;
1729 }
1730 /* Clear visited flag. */
1731 f->next = Cudd_Regular(f->next);
1732 if (cuddIsConstant(f)) {
1733 return;
1734 }
1735 ddClearFlag2(cuddT(f));
1736 ddClearFlag2(Cudd_Regular(cuddE(f)));
1737 return;
1738
1739} /* end of ddClearFlag */
void ddClearFlag2(DdNode *f)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ ddSupportStep2()

void ddSupportStep2 ( DdNode * f,
int * support )

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

Synopsis [Performs the recursive step of Cudd_Support.]

Description [Performs the recursive step of Cudd_Support. Performs a DFS from f. The support is accumulated in supp as a side effect. Uses the LSB of the then pointer as visited flag.]

SideEffects [None]

SeeAlso [ddClearFlag]

Definition at line 1693 of file extraBddMisc.c.

1696{
1697 if (cuddIsConstant(f) || Cudd_IsComplement(f->next)) {
1698 return;
1699 }
1700
1701 support[f->index] = 1;
1702 ddSupportStep2(cuddT(f),support);
1703 ddSupportStep2(Cudd_Regular(cuddE(f)),support);
1704 /* Mark as visited. */
1705 f->next = Cudd_Not(f->next);
1706 return;
1707
1708} /* end of ddSupportStep */
void ddSupportStep2(DdNode *f, int *support)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Extra_bddAndPermute()

DdNode * Extra_bddAndPermute ( DdManager * ddF,
DdNode * bF,
DdManager * ddG,
DdNode * bG,
int * pPermute )

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

Synopsis [Computes the AND of two BDD with different orders.]

Description [Derives the result of Boolean AND of bF and bG in ddF. The array pPermute gives the mapping of variables of ddG into that of ddF.]

SideEffects []

SeeAlso []

Definition at line 1090 of file extraBddMisc.c.

1091{
1092 DdHashTable * table;
1093 DdNode * bRes;
1094 do
1095 {
1096 ddF->reordered = 0;
1097 table = cuddHashTableInit( ddF, 2, 256 );
1098 if (table == NULL) return NULL;
1099 bRes = extraBddAndPermute( table, ddF, bF, ddG, bG, pPermute );
1100 if ( bRes ) cuddRef( bRes );
1101 cuddHashTableQuit( table );
1102 if ( bRes ) cuddDeref( bRes );
1103//if ( ddF->reordered == 1 )
1104//printf( "Reordering happened\n" );
1105 }
1106 while ( ddF->reordered == 1 );
1107//printf( "|F| =%6d |G| =%6d |H| =%6d |F|*|G| =%9d\n",
1108// Cudd_DagSize(bF), Cudd_DagSize(bG), Cudd_DagSize(bRes),
1109// Cudd_DagSize(bF) * Cudd_DagSize(bG) );
1110 return ( bRes );
1111}
Here is the caller graph for this function:

◆ Extra_bddBitsToCube()

DdNode * Extra_bddBitsToCube ( DdManager * dd,
int Code,
int CodeWidth,
DdNode ** pbVars,
int fMsbFirst )

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

Synopsis [Computes the cube of BDD variables corresponding to bits it the bit-code]

Description [Returns a bdd composed of elementary bdds found in array BddVars[] such that the bdd vars encode the number Value of bit length CodeWidth (if fMsbFirst is 1, the most significant bit is encoded with the first bdd variable). If the variables BddVars are not specified, takes the first CodeWidth variables of the manager]

SideEffects []

SeeAlso []

Definition at line 730 of file extraBddMisc.c.

731{
732 int z;
733 DdNode * bTemp, * bVar, * bVarBdd, * bResult;
734
735 bResult = b1; Cudd_Ref( bResult );
736 for ( z = 0; z < CodeWidth; z++ )
737 {
738 bVarBdd = (pbVars)? pbVars[z]: dd->vars[z];
739 if ( fMsbFirst )
740 bVar = Cudd_NotCond( bVarBdd, (Code & (1 << (CodeWidth-1-z)))==0 );
741 else
742 bVar = Cudd_NotCond( bVarBdd, (Code & (1 << (z)))==0 );
743 bResult = Cudd_bddAnd( dd, bTemp = bResult, bVar ); Cudd_Ref( bResult );
744 Cudd_RecursiveDeref( dd, bTemp );
745 }
746 Cudd_Deref( bResult );
747
748 return bResult;
749} /* end of Extra_bddBitsToCube */
#define b1
Definition bbrImage.c:97
#define Code
Definition deflate.h:76
Here is the caller graph for this function:

◆ Extra_bddChangePolarity()

DdNode * Extra_bddChangePolarity ( DdManager * dd,
DdNode * bFunc,
DdNode * bVars )

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

Synopsis [Changes the polarity of vars listed in the cube.]

Description []

SideEffects []

SeeAlso []

Definition at line 1029 of file extraBddMisc.c.

1033{
1034 DdNode *res;
1035 do {
1036 dd->reordered = 0;
1037 res = extraBddChangePolarity( dd, bFunc, bVars );
1038 } while (dd->reordered == 1);
1039 return(res);
1040
1041} /* end of Extra_bddChangePolarity */
DdNode * extraBddChangePolarity(DdManager *dd, DdNode *bFunc, DdNode *bVars)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Extra_bddComputeCube()

DdNode * Extra_bddComputeCube ( DdManager * dd,
DdNode ** bXVars,
int nVars )

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

Synopsis [Computes the positive polarty cube composed of the first vars in the array.]

Description []

SideEffects []

SeeAlso []

Definition at line 1001 of file extraBddMisc.c.

1002{
1003 DdNode * bRes;
1004 DdNode * bTemp;
1005 int i;
1006
1007 bRes = b1; Cudd_Ref( bRes );
1008 for ( i = 0; i < nVars; i++ )
1009 {
1010 bRes = Cudd_bddAnd( dd, bTemp = bRes, bXVars[i] ); Cudd_Ref( bRes );
1011 Cudd_RecursiveDeref( dd, bTemp );
1012 }
1013
1014 Cudd_Deref( bRes );
1015 return bRes;
1016}
Here is the caller graph for this function:

◆ Extra_bddComputeRangeCube()

DdNode * Extra_bddComputeRangeCube ( DdManager * dd,
int iStart,
int iStop )

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

Synopsis [Performs the reordering-sensitive step of Extra_bddMove().]

Description []

SideEffects []

SeeAlso []

Definition at line 699 of file extraBddMisc.c.

700{
701 DdNode * bTemp, * bProd;
702 int i;
703 assert( iStart <= iStop );
704 assert( iStart >= 0 && iStart <= dd->size );
705 assert( iStop >= 0 && iStop <= dd->size );
706 bProd = b1; Cudd_Ref( bProd );
707 for ( i = iStart; i < iStop; i++ )
708 {
709 bProd = Cudd_bddAnd( dd, bTemp = bProd, dd->vars[i] ); Cudd_Ref( bProd );
710 Cudd_RecursiveDeref( dd, bTemp );
711 }
712 Cudd_Deref( bProd );
713 return bProd;
714}
#define assert(ex)
Definition util_old.h:213

◆ Extra_bddCountCubes()

int Extra_bddCountCubes ( DdManager * dd,
DdNode ** pFuncs,
int nFuncs,
int fMode,
int nLimit,
int * pGuide )

Definition at line 1485 of file extraBddMisc.c.

1486{
1487 DdNode * pF0, * pF1;
1488 int i, Count, Count0, Count1, CounterAll = 0;
1490 unsigned int saveLimit = dd->maxLive;
1491 dd->maxLive = dd->keys - dd->dead + 1000000; // limit on intermediate BDD nodes
1492 for ( i = 0; i < nFuncs; i++ )
1493 {
1494 if ( !pFuncs[i] )
1495 continue;
1496 pF1 = pF0 = NULL;
1497 Count0 = Count1 = nLimit;
1498 if ( fMode == -1 || fMode == 1 ) // both or pos
1499 pF1 = extraBddCountCubes( dd, pFuncs[i], pFuncs[i], table, &Count1, nLimit );
1500 pFuncs[i] = Cudd_Not( pFuncs[i] );
1501 if ( fMode == -1 || fMode == 0 ) // both or neg
1502 pF0 = extraBddCountCubes( dd, pFuncs[i], pFuncs[i], table, &Count0, Count1 );
1503 pFuncs[i] = Cudd_Not( pFuncs[i] );
1504 if ( !pF1 && !pF0 )
1505 break;
1506 if ( !pF0 ) pGuide[i] = 1, Count = Count1; // use pos
1507 else if ( !pF1 ) pGuide[i] = 0, Count = Count0; // use neg
1508 else if ( Count1 <= Count0 ) pGuide[i] = 1, Count = Count1; // use pos
1509 else pGuide[i] = 0, Count = Count0; // use neg
1510 CounterAll += Count;
1511 //printf( "Output %5d has %5d cubes (%d) (%5d and %5d)\n", nOuts++, Count, pGuide[i], Count1, Count0 );
1512 }
1513 dd->maxLive = saveLimit;
1514 st__free_table( table );
1515 return i == nFuncs ? CounterAll : -1;
1516} /* end of Extra_bddCountCubes */
int st__ptrhash(const char *, int)
Definition st.c:467
int st__ptrcmp(const char *, const char *)
Definition st.c:479
st__table * st__init_table(st__compare_func_type compare, st__hash_func_type hash)
Definition st.c:72
void st__free_table(st__table *table)
Definition st.c:81
Definition st.h:52
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Extra_bddCreateAnd()

DdNode * Extra_bddCreateAnd ( DdManager * dd,
int nVars )

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

Synopsis [Creates AND composed of the first nVars of the manager.]

Description []

SideEffects []

SeeAlso []

Definition at line 858 of file extraBddMisc.c.

859{
860 DdNode * bFunc, * bTemp;
861 int i;
862 bFunc = Cudd_ReadOne(dd); Cudd_Ref( bFunc );
863 for ( i = 0; i < nVars; i++ )
864 {
865 bFunc = Cudd_bddAnd( dd, bTemp = bFunc, Cudd_bddIthVar(dd,i) ); Cudd_Ref( bFunc );
866 Cudd_RecursiveDeref( dd, bTemp );
867 }
868 Cudd_Deref( bFunc );
869 return bFunc;
870}
Here is the caller graph for this function:

◆ Extra_bddCreateExor()

DdNode * Extra_bddCreateExor ( DdManager * dd,
int nVars )

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

Synopsis [Creates EXOR composed of the first nVars of the manager.]

Description []

SideEffects []

SeeAlso []

Definition at line 908 of file extraBddMisc.c.

909{
910 DdNode * bFunc, * bTemp;
911 int i;
912 bFunc = Cudd_ReadLogicZero(dd); Cudd_Ref( bFunc );
913 for ( i = 0; i < nVars; i++ )
914 {
915 bFunc = Cudd_bddXor( dd, bTemp = bFunc, Cudd_bddIthVar(dd,i) ); Cudd_Ref( bFunc );
916 Cudd_RecursiveDeref( dd, bTemp );
917 }
918 Cudd_Deref( bFunc );
919 return bFunc;
920}
Here is the caller graph for this function:

◆ Extra_bddCreateOr()

DdNode * Extra_bddCreateOr ( DdManager * dd,
int nVars )

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

Synopsis [Creates OR composed of the first nVars of the manager.]

Description []

SideEffects []

SeeAlso []

Definition at line 883 of file extraBddMisc.c.

884{
885 DdNode * bFunc, * bTemp;
886 int i;
887 bFunc = Cudd_ReadLogicZero(dd); Cudd_Ref( bFunc );
888 for ( i = 0; i < nVars; i++ )
889 {
890 bFunc = Cudd_bddOr( dd, bTemp = bFunc, Cudd_bddIthVar(dd,i) ); Cudd_Ref( bFunc );
891 Cudd_RecursiveDeref( dd, bTemp );
892 }
893 Cudd_Deref( bFunc );
894 return bFunc;
895}
Here is the caller graph for this function:

◆ Extra_bddFindOneCube()

DdNode * Extra_bddFindOneCube ( DdManager * dd,
DdNode * bF )

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

Synopsis [Find any cube belonging to the on-set of the function.]

Description []

SideEffects []

SeeAlso []

Definition at line 605 of file extraBddMisc.c.

606{
607 char * s_Temp;
608 DdNode * bCube, * bTemp;
609 int v;
610
611 // get the vector of variables in the cube
612 s_Temp = ABC_ALLOC( char, dd->size );
613 Cudd_bddPickOneCube( dd, bF, s_Temp );
614
615 // start the cube
616 bCube = b1; Cudd_Ref( bCube );
617 for ( v = 0; v < dd->size; v++ )
618 if ( s_Temp[v] == 0 )
619 {
620// Cube &= !s_XVars[v];
621 bCube = Cudd_bddAnd( dd, bTemp = bCube, Cudd_Not(dd->vars[v]) ); Cudd_Ref( bCube );
622 Cudd_RecursiveDeref( dd, bTemp );
623 }
624 else if ( s_Temp[v] == 1 )
625 {
626// Cube &= s_XVars[v];
627 bCube = Cudd_bddAnd( dd, bTemp = bCube, dd->vars[v] ); Cudd_Ref( bCube );
628 Cudd_RecursiveDeref( dd, bTemp );
629 }
630 Cudd_Deref(bCube);
631 ABC_FREE( s_Temp );
632 return bCube;
633}
#define ABC_ALLOC(type, num)
Definition abc_global.h:264
#define ABC_FREE(obj)
Definition abc_global.h:267
Here is the caller graph for this function:

◆ Extra_bddGetOneCube()

DdNode * Extra_bddGetOneCube ( DdManager * dd,
DdNode * bFunc )

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

Synopsis [Returns one cube contained in the given BDD.]

Description [This function returns the cube with the smallest bits-to-integer value.]

SideEffects []

Definition at line 645 of file extraBddMisc.c.

646{
647 DdNode * bFuncR, * bFunc0, * bFunc1;
648 DdNode * bRes0, * bRes1, * bRes;
649
650 bFuncR = Cudd_Regular(bFunc);
651 if ( cuddIsConstant(bFuncR) )
652 return bFunc;
653
654 // cofactor
655 if ( Cudd_IsComplement(bFunc) )
656 {
657 bFunc0 = Cudd_Not( cuddE(bFuncR) );
658 bFunc1 = Cudd_Not( cuddT(bFuncR) );
659 }
660 else
661 {
662 bFunc0 = cuddE(bFuncR);
663 bFunc1 = cuddT(bFuncR);
664 }
665
666 // try to find the cube with the negative literal
667 bRes0 = Extra_bddGetOneCube( dd, bFunc0 ); Cudd_Ref( bRes0 );
668
669 if ( bRes0 != b0 )
670 {
671 bRes = Cudd_bddAnd( dd, bRes0, Cudd_Not(dd->vars[bFuncR->index]) ); Cudd_Ref( bRes );
672 Cudd_RecursiveDeref( dd, bRes0 );
673 }
674 else
675 {
676 Cudd_RecursiveDeref( dd, bRes0 );
677 // try to find the cube with the positive literal
678 bRes1 = Extra_bddGetOneCube( dd, bFunc1 ); Cudd_Ref( bRes1 );
679 assert( bRes1 != b0 );
680 bRes = Cudd_bddAnd( dd, bRes1, dd->vars[bFuncR->index] ); Cudd_Ref( bRes );
681 Cudd_RecursiveDeref( dd, bRes1 );
682 }
683
684 Cudd_Deref( bRes );
685 return bRes;
686}
#define b0
Definition bbrImage.c:96
DdNode * Extra_bddGetOneCube(DdManager *dd, DdNode *bFunc)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Extra_bddIsVar()

int Extra_bddIsVar ( DdNode * bFunc)

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

Synopsis [Returns 1 if the BDD is the BDD of elementary variable.]

Description []

SideEffects []

SeeAlso []

Definition at line 839 of file extraBddMisc.c.

840{
841 bFunc = Cudd_Regular( bFunc );
842 if ( cuddIsConstant(bFunc) )
843 return 0;
844 return cuddIsConstant( cuddT(bFunc) ) && cuddIsConstant( Cudd_Regular(cuddE(bFunc)) );
845}

◆ Extra_bddMove()

DdNode * Extra_bddMove ( DdManager * dd,
DdNode * bF,
int nVars )

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

Synopsis [Moves the BDD by the given number of variables up or down.]

Description []

SideEffects []

SeeAlso [Extra_bddShift]

Definition at line 187 of file extraBddMisc.c.

191{
192 DdNode * res;
193 DdNode * bVars;
194 if ( nVars == 0 )
195 return bF;
196 if ( Cudd_IsConstant(bF) )
197 return bF;
198 assert( nVars <= dd->size );
199 if ( nVars > 0 )
200 bVars = dd->vars[nVars];
201 else
202 bVars = Cudd_Not(dd->vars[-nVars]);
203
204 do {
205 dd->reordered = 0;
206 res = extraBddMove( dd, bF, bVars );
207 } while (dd->reordered == 1);
208 return(res);
209
210} /* end of Extra_bddMove */
DdNode * extraBddMove(DdManager *dd, DdNode *bF, DdNode *bDist)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Extra_bddPermuteArray()

void Extra_bddPermuteArray ( DdManager * manager,
DdNode ** bNodesIn,
DdNode ** bNodesOut,
int nNodes,
int * permut )

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

Synopsis [Permutes the variables of the array of BDDs.]

Description [Given a permutation in array permut, creates a new BDD with permuted variables. There should be an entry in array permut for each variable in the manager. The i-th entry of permut holds the index of the variable that is to substitute the i-th variable. The DDs in the resulting array are already referenced.]

SideEffects [None]

SeeAlso [Cudd_addPermute Cudd_bddSwapVariables]

Definition at line 961 of file extraBddMisc.c.

962{
963 DdHashTable *table;
964 int i, k;
965 do
966 {
967 manager->reordered = 0;
968 table = cuddHashTableInit( manager, 1, 2 );
969
970 /* permute the output functions one-by-one */
971 for ( i = 0; i < nNodes; i++ )
972 {
973 bNodesOut[i] = cuddBddPermuteRecur( manager, table, bNodesIn[i], permut );
974 if ( bNodesOut[i] == NULL )
975 {
976 /* deref the array of the already computed outputs */
977 for ( k = 0; k < i; k++ )
978 Cudd_RecursiveDeref( manager, bNodesOut[k] );
979 break;
980 }
981 cuddRef( bNodesOut[i] );
982 }
983 /* Dispose of local cache. */
984 cuddHashTableQuit( table );
985 }
986 while ( manager->reordered == 1 );
987} /* end of Extra_bddPermuteArray */
Here is the caller graph for this function:

◆ Extra_bddPrint()

void Extra_bddPrint ( DdManager * dd,
DdNode * F )

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

Synopsis [Outputs the BDD in a readable format.]

Description []

SideEffects [None]

SeeAlso []

Definition at line 246 of file extraBddMisc.c.

247{
248 DdGen * Gen;
249 int * Cube;
250 CUDD_VALUE_TYPE Value;
251 int nVars = dd->size;
252 int fFirstCube = 1;
253 int i;
254
255 if ( F == NULL )
256 {
257 printf("NULL");
258 return;
259 }
260 if ( F == b0 )
261 {
262 printf("Constant 0");
263 return;
264 }
265 if ( F == b1 )
266 {
267 printf("Constant 1");
268 return;
269 }
270
271 Cudd_ForeachCube( dd, F, Gen, Cube, Value )
272 {
273 if ( fFirstCube )
274 fFirstCube = 0;
275 else
276// Output << " + ";
277 printf( " + " );
278
279 for ( i = 0; i < nVars; i++ )
280 if ( Cube[i] == 0 )
281 printf( "[%d]'", i );
282// printf( "%c'", (char)('a'+i) );
283 else if ( Cube[i] == 1 )
284 printf( "[%d]", i );
285// printf( "%c", (char)('a'+i) );
286 }
287
288// printf("\n");
289}
struct cube Cube
Here is the caller graph for this function:

◆ Extra_bddPrintSupport()

void Extra_bddPrintSupport ( DdManager * dd,
DdNode * F )

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

Synopsis [Outputs the BDD in a readable format.]

Description []

SideEffects [None]

SeeAlso []

Definition at line 302 of file extraBddMisc.c.

303{
304 DdNode * bSupp;
305 bSupp = Cudd_Support( dd, F ); Cudd_Ref( bSupp );
306 Extra_bddPrint( dd, bSupp );
307 Cudd_RecursiveDeref( dd, bSupp );
308}
void Extra_bddPrint(DdManager *dd, DdNode *F)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Extra_bddRemapUp()

DdNode * Extra_bddRemapUp ( DdManager * dd,
DdNode * bF )

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

Synopsis [Remaps the function to depend on the topmost variables on the manager.]

Description []

SideEffects []

SeeAlso []

Definition at line 145 of file extraBddMisc.c.

148{
149 int * pPermute;
150 DdNode * bSupp, * bTemp, * bRes;
151 int Counter;
152
153 pPermute = ABC_ALLOC( int, dd->size );
154
155 // get support
156 bSupp = Cudd_Support( dd, bF ); Cudd_Ref( bSupp );
157
158 // create the variable map
159 // to remap the DD into the upper part of the manager
160 Counter = 0;
161 for ( bTemp = bSupp; bTemp != dd->one; bTemp = cuddT(bTemp) )
162 pPermute[bTemp->index] = dd->invperm[Counter++];
163
164 // transfer the BDD and remap it
165 bRes = Cudd_bddPermute( dd, bF, pPermute ); Cudd_Ref( bRes );
166
167 // remove support
168 Cudd_RecursiveDeref( dd, bSupp );
169
170 // return
171 Cudd_Deref( bRes );
172 ABC_FREE( pPermute );
173 return bRes;
174}
Here is the caller graph for this function:

◆ Extra_bddSuppCheckContainment()

int Extra_bddSuppCheckContainment ( DdManager * dd,
DdNode * bL,
DdNode * bH,
DdNode ** bLarge,
DdNode ** bSmall )

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

Synopsis [Checks the support containment.]

Description [This function returns 1 if one support is contained in another. In this case, bLarge (bSmall) is assigned to point to the larger (smaller) support. If the supports are identical, return 0 and does not assign the supports!]

SideEffects []

SeeAlso []

Definition at line 443 of file extraBddMisc.c.

444{
445 DdNode * bSL = bL;
446 DdNode * bSH = bH;
447 int fLcontainsH = 1;
448 int fHcontainsL = 1;
449 int TopVar;
450
451 if ( bSL == bSH )
452 return 0;
453
454 while ( bSL != b1 || bSH != b1 )
455 {
456 if ( bSL == b1 )
457 { // Low component has no vars; High components has some vars
458 fLcontainsH = 0;
459 if ( fHcontainsL == 0 )
460 return 0;
461 else
462 break;
463 }
464
465 if ( bSH == b1 )
466 { // similarly
467 fHcontainsL = 0;
468 if ( fLcontainsH == 0 )
469 return 0;
470 else
471 break;
472 }
473
474 // determine the topmost var of the supports by comparing their levels
475 if ( dd->perm[bSL->index] < dd->perm[bSH->index] )
476 TopVar = bSL->index;
477 else
478 TopVar = bSH->index;
479
480 if ( TopVar == bSL->index && TopVar == bSH->index )
481 { // they are on the same level
482 // it does not tell us anything about their containment
483 // skip this var
484 bSL = cuddT(bSL);
485 bSH = cuddT(bSH);
486 }
487 else if ( TopVar == bSL->index ) // and TopVar != bSH->index
488 { // Low components is higher and contains more vars
489 // it is not possible that High component contains Low
490 fHcontainsL = 0;
491 // skip this var
492 bSL = cuddT(bSL);
493 }
494 else // if ( TopVar == bSH->index ) // and TopVar != bSL->index
495 { // similarly
496 fLcontainsH = 0;
497 // skip this var
498 bSH = cuddT(bSH);
499 }
500
501 // check the stopping condition
502 if ( !fHcontainsL && !fLcontainsH )
503 return 0;
504 }
505 // only one of them can be true at the same time
506 assert( !fHcontainsL || !fLcontainsH );
507 if ( fHcontainsL )
508 {
509 *bLarge = bH;
510 *bSmall = bL;
511 }
512 else // fLcontainsH
513 {
514 *bLarge = bL;
515 *bSmall = bH;
516 }
517 return 1;
518}

◆ Extra_bddSuppContainVar()

int Extra_bddSuppContainVar ( DdManager * dd,
DdNode * bS,
DdNode * bVar )

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

Synopsis [Returns 1 if the support contains the given BDD variable.]

Description []

SideEffects []

SeeAlso []

Definition at line 346 of file extraBddMisc.c.

347{
348 for( ; bS != b1; bS = cuddT(bS) )
349 if ( bS->index == bVar->index )
350 return 1;
351 return 0;
352}

◆ Extra_bddSuppDifferentVars()

int Extra_bddSuppDifferentVars ( DdManager * dd,
DdNode * S1,
DdNode * S2,
int DiffMax )

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

Synopsis [Returns the number of different vars in two supports.]

Description [Counts the number of variables that appear in one support and does not appear in other support. If the number exceeds DiffMax, returns DiffMax.]

SideEffects []

SeeAlso []

Definition at line 393 of file extraBddMisc.c.

394{
395 int Result = 0;
396 while ( S1->index != CUDD_CONST_INDEX && S2->index != CUDD_CONST_INDEX )
397 {
398 // if the top vars are the same, this var is the same
399 if ( S1->index == S2->index )
400 {
401 S1 = cuddT(S1);
402 S2 = cuddT(S2);
403 continue;
404 }
405 // the top var is different
406 Result++;
407
408 if ( Result >= DiffMax )
409 return DiffMax;
410
411 // if the top vars are different, skip the one, which is higher
412 if ( dd->perm[S1->index] < dd->perm[S2->index] )
413 S1 = cuddT(S1);
414 else
415 S2 = cuddT(S2);
416 }
417
418 // consider the remaining variables
419 if ( S1->index != CUDD_CONST_INDEX )
420 Result += Extra_bddSuppSize(dd,S1);
421 else if ( S2->index != CUDD_CONST_INDEX )
422 Result += Extra_bddSuppSize(dd,S2);
423
424 if ( Result >= DiffMax )
425 return DiffMax;
426 return Result;
427}
int Extra_bddSuppSize(DdManager *dd, DdNode *bSupp)
Here is the call graph for this function:

◆ Extra_bddSupportNegativeCube()

DdNode * Extra_bddSupportNegativeCube ( DdManager * dd,
DdNode * f )

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

Synopsis [Finds the support as a negative polarity cube.]

Description [Finds the variables on which a DD depends. Returns a BDD consisting of the product of the variables in the negative polarity if successful; NULL otherwise.]

SideEffects [None]

SeeAlso [Cudd_VectorSupport Cudd_Support]

Definition at line 764 of file extraBddMisc.c.

765{
766 int *support;
767 DdNode *res, *tmp, *var;
768 int i, j;
769 int size;
770
771 /* Allocate and initialize support array for ddSupportStep. */
772 size = ddMax( dd->size, dd->sizeZ );
773 support = ABC_ALLOC( int, size );
774 if ( support == NULL )
775 {
776 dd->errorCode = CUDD_MEMORY_OUT;
777 return ( NULL );
778 }
779 for ( i = 0; i < size; i++ )
780 {
781 support[i] = 0;
782 }
783
784 /* Compute support and clean up markers. */
785 ddSupportStep2( Cudd_Regular( f ), support );
786 ddClearFlag2( Cudd_Regular( f ) );
787
788 /* Transform support from array to cube. */
789 do
790 {
791 dd->reordered = 0;
792 res = DD_ONE( dd );
793 cuddRef( res );
794 for ( j = size - 1; j >= 0; j-- )
795 { /* for each level bottom-up */
796 i = ( j >= dd->size ) ? j : dd->invperm[j];
797 if ( support[i] == 1 )
798 {
799 var = cuddUniqueInter( dd, i, dd->one, Cudd_Not( dd->one ) );
801 var = Cudd_Not(var);
803 cuddRef( var );
804 tmp = cuddBddAndRecur( dd, res, var );
805 if ( tmp == NULL )
806 {
807 Cudd_RecursiveDeref( dd, res );
808 Cudd_RecursiveDeref( dd, var );
809 res = NULL;
810 break;
811 }
812 cuddRef( tmp );
813 Cudd_RecursiveDeref( dd, res );
814 Cudd_RecursiveDeref( dd, var );
815 res = tmp;
816 }
817 }
818 }
819 while ( dd->reordered == 1 );
820
821 ABC_FREE( support );
822 if ( res != NULL )
823 cuddDeref( res );
824 return ( res );
825
826} /* end of Extra_SupportNeg */
unsigned long long size
Definition giaNewBdd.h:39
unsigned short var
Definition giaNewBdd.h:35
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Extra_bddSuppOverlapping()

int Extra_bddSuppOverlapping ( DdManager * dd,
DdNode * S1,
DdNode * S2 )

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

Synopsis [Returns 1 if two supports represented as BDD cubes are overlapping.]

Description []

SideEffects []

SeeAlso []

Definition at line 365 of file extraBddMisc.c.

366{
367 while ( S1->index != CUDD_CONST_INDEX && S2->index != CUDD_CONST_INDEX )
368 {
369 // if the top vars are the same, they intersect
370 if ( S1->index == S2->index )
371 return 1;
372 // if the top vars are different, skip the one, which is higher
373 if ( dd->perm[S1->index] < dd->perm[S2->index] )
374 S1 = cuddT(S1);
375 else
376 S2 = cuddT(S2);
377 }
378 return 0;
379}

◆ Extra_bddSuppSize()

int Extra_bddSuppSize ( DdManager * dd,
DdNode * bSupp )

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

Synopsis [Returns the size of the support.]

Description []

SideEffects []

SeeAlso []

Definition at line 321 of file extraBddMisc.c.

322{
323 int Counter = 0;
324 while ( bSupp != b1 )
325 {
326 assert( !Cudd_IsComplement(bSupp) );
327 assert( cuddE(bSupp) == b0 );
328
329 bSupp = cuddT(bSupp);
330 Counter++;
331 }
332 return Counter;
333}
Here is the caller graph for this function:

◆ Extra_bddTuples()

DdNode * Extra_bddTuples ( DdManager * dd,
int K,
DdNode * VarsN )

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

Synopsis [Builds BDD representing the set of fixed-size variable tuples.]

Description [Creates BDD of all combinations of variables in Support that have k vars in them.]

SideEffects []

SeeAlso []

Definition at line 2691 of file extraBddMisc.c.

2695{
2696 DdNode *res;
2697 int autoDyn;
2698
2699 /* it is important that reordering does not happen,
2700 otherwise, this methods will not work */
2701
2702 autoDyn = dd->autoDyn;
2703 dd->autoDyn = 0;
2704
2705 do {
2706 /* transform the numeric arguments (K) into a DdNode * argument;
2707 * this allows us to use the standard internal CUDD cache */
2708 DdNode *VarSet = VarsN, *VarsK = VarsN;
2709 int nVars = 0, i;
2710
2711 /* determine the number of variables in VarSet */
2712 while ( VarSet != b1 )
2713 {
2714 nVars++;
2715 /* make sure that the VarSet is a cube */
2716 if ( cuddE( VarSet ) != b0 )
2717 return NULL;
2718 VarSet = cuddT( VarSet );
2719 }
2720 /* make sure that the number of variables in VarSet is less or equal
2721 that the number of variables that should be present in the tuples
2722 */
2723 if ( K > nVars )
2724 return NULL;
2725
2726 /* the second argument in the recursive call stands for <n>;
2727 * create the first argument, which stands for <k>
2728 * as when we are talking about the tuple of <k> out of <n> */
2729 for ( i = 0; i < nVars-K; i++ )
2730 VarsK = cuddT( VarsK );
2731
2732 dd->reordered = 0;
2733 res = extraBddTuples(dd, VarsK, VarsN );
2734
2735 } while (dd->reordered == 1);
2736 dd->autoDyn = autoDyn;
2737 return(res);
2738
2739} /* end of Extra_bddTuples */
DdNode * extraBddTuples(DdManager *dd, DdNode *bVarsK, DdNode *bVarsN)
Here is the call graph for this function:

◆ Extra_bddVarIsInCube()

int Extra_bddVarIsInCube ( DdNode * bCube,
int iVar )

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

Synopsis [Checks if the given variable belongs to the cube.]

Description [Return -1 if the var does not appear in the cube. Otherwise, returns polarity (0 or 1) of the var in the cube.]

SideEffects []

SeeAlso []

Definition at line 1056 of file extraBddMisc.c.

1057{
1058 DdNode * bCube0, * bCube1;
1059 while ( Cudd_Regular(bCube)->index != CUDD_CONST_INDEX )
1060 {
1061 bCube0 = Cudd_NotCond( cuddE(Cudd_Regular(bCube)), Cudd_IsComplement(bCube) );
1062 bCube1 = Cudd_NotCond( cuddT(Cudd_Regular(bCube)), Cudd_IsComplement(bCube) );
1063 // make sure it is a cube
1064 assert( (Cudd_IsComplement(bCube0) && Cudd_Regular(bCube0)->index == CUDD_CONST_INDEX) || // bCube0 == 0
1065 (Cudd_IsComplement(bCube1) && Cudd_Regular(bCube1)->index == CUDD_CONST_INDEX) ); // bCube1 == 0
1066 // quit if it is the last one
1067 if ( Cudd_Regular(bCube)->index == iVar )
1068 return (int)(Cudd_IsComplement(bCube0) && Cudd_Regular(bCube0)->index == CUDD_CONST_INDEX);
1069 // get the next cube
1070 if ( (Cudd_IsComplement(bCube0) && Cudd_Regular(bCube0)->index == CUDD_CONST_INDEX) )
1071 bCube = bCube1;
1072 else
1073 bCube = bCube0;
1074 }
1075 return -1;
1076}

◆ Extra_GraphExperiment()

void Extra_GraphExperiment ( )

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

Synopsis [Constructing ZDD of a graph.]

Description []

SideEffects []

SeeAlso []

Definition at line 2347 of file extraBddMisc.c.

2348{
2349 int Edges[5][5] = {
2350 {1, 3, 4},
2351 {1, 5},
2352 {2, 3, 5},
2353 {2, 4}
2354 };
2355 int e, n;
2356
2357 DdManager * dd = Cudd_Init( 0, 6, CUDD_UNIQUE_SLOTS, CUDD_CACHE_SLOTS, 0 );
2358
2359 // create the edges
2360 DdNode * zGraph, * zEdge, * zVar, * zTemp;
2361 zGraph = DD_ZERO(dd); Cudd_Ref( zGraph );
2362 for ( e = 0; Edges[e][0]; e++ )
2363 {
2364 zEdge = DD_ONE(dd); Cudd_Ref( zEdge );
2365 for ( n = 0; Edges[e][n]; n++ )
2366 {
2367 zVar = cuddZddGetNode( dd, Edges[e][n], DD_ONE(dd), DD_ZERO(dd) ); Cudd_Ref( zVar );
2368 zEdge = Cudd_zddUnateProduct( dd, zTemp = zEdge, zVar ); Cudd_Ref( zEdge );
2369 Cudd_RecursiveDerefZdd( dd, zTemp );
2370 Cudd_RecursiveDerefZdd( dd, zVar );
2371 }
2372 zGraph = Cudd_zddUnion( dd, zTemp = zGraph, zEdge ); Cudd_Ref( zGraph );
2373 Cudd_RecursiveDerefZdd( dd, zTemp );
2374 Cudd_RecursiveDerefZdd( dd, zEdge );
2375 }
2376
2377 Cudd_zddPrintMinterm( dd, zGraph );
2378
2379 Cudd_RecursiveDerefZdd( dd, zGraph );
2380 Cudd_Quit(dd);
2381}

◆ Extra_StopManager()

void Extra_StopManager ( DdManager * dd)

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 223 of file extraBddMisc.c.

224{
225 int RetValue;
226 // check for remaining references in the package
227 RetValue = Cudd_CheckZeroRef( dd );
228 if ( RetValue > 10 )
229// if ( RetValue )
230 printf( "\nThe number of referenced nodes = %d\n\n", RetValue );
231// Cudd_PrintInfo( dd, stdout );
232 Cudd_Quit( dd );
233}
Here is the caller graph for this function:

◆ Extra_SupportArray()

int * Extra_SupportArray ( DdManager * dd,
DdNode * f,
int * support )

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

Synopsis [Finds variables on which the DD depends and returns them as am array.]

Description [Finds the variables on which the DD depends. Returns an array with entries set to 1 for those variables that belong to the support; NULL otherwise. The array is allocated by the user and should have at least as many entries as the maximum number of variables in BDD and ZDD parts of the manager.]

SideEffects [None]

SeeAlso [Cudd_Support Cudd_VectorSupport Cudd_ClassifySupport]

Definition at line 537 of file extraBddMisc.c.

541{
542 int i, size;
543
544 /* Initialize support array for ddSupportStep. */
545 size = ddMax(dd->size, dd->sizeZ);
546 for (i = 0; i < size; i++)
547 support[i] = 0;
548
549 /* Compute support and clean up markers. */
550 ddSupportStep2(Cudd_Regular(f),support);
551 ddClearFlag2(Cudd_Regular(f));
552
553 return(support);
554
555} /* end of Extra_SupportArray */
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Extra_TestAndPerm()

void Extra_TestAndPerm ( DdManager * ddF,
DdNode * bF,
DdNode * bG )

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

Synopsis [Testbench.]

Description [This procedure takes BDD manager ddF and two BDDs in this manager (bF and bG). It creates a new manager ddG, transfers bG into it and then reorders it, resulting in bG2. Then it tries to compute the product of bF and bG2 in ddF.]

SideEffects []

SeeAlso []

Definition at line 2250 of file extraBddMisc.c.

2251{
2252 DdManager * ddG;
2253 DdNode * bG2, * bRes1, * bRes2;
2254 abctime clk;
2255 // disable variable ordering in ddF
2256 Cudd_AutodynDisable( ddF );
2257
2258 // create new BDD manager
2259 ddG = Cudd_Init( ddF->size, 0, CUDD_UNIQUE_SLOTS, CUDD_CACHE_SLOTS, 0 );
2260 // transfer BDD into it
2261 Cudd_ShuffleHeap( ddG, ddF->invperm );
2262 bG2 = Extra_TransferLevelByLevel( ddF, ddG, bG ); Cudd_Ref( bG2 );
2263 // reorder the new manager
2264 Cudd_ReduceHeap( ddG, CUDD_REORDER_SYMM_SIFT, 1 );
2265
2266 // compute the result
2267clk = Abc_Clock();
2268 bRes1 = Cudd_bddAnd( ddF, bF, bG ); Cudd_Ref( bRes1 );
2269Abc_PrintTime( 1, "Runtime of Cudd_bddAnd ", Abc_Clock() - clk );
2270
2271 // compute the result
2272Counter = 0;
2273clk = Abc_Clock();
2274 bRes2 = Extra_bddAndPermute( ddF, bF, ddG, bG2, NULL ); Cudd_Ref( bRes2 );
2275Abc_PrintTime( 1, "Runtime of new procedure", Abc_Clock() - clk );
2276printf( "Recursive calls = %d\n", Counter );
2277printf( "|F| =%6d |G| =%6d |H| =%6d |F|*|G| =%9d ",
2278 Cudd_DagSize(bF), Cudd_DagSize(bG), Cudd_DagSize(bRes2),
2279 Cudd_DagSize(bF) * Cudd_DagSize(bG) );
2280
2281 if ( bRes1 == bRes2 )
2282 printf( "Result verified.\n\n" );
2283 else
2284 printf( "Result is incorrect.\n\n" );
2285
2286 Cudd_RecursiveDeref( ddF, bRes1 );
2287 Cudd_RecursiveDeref( ddF, bRes2 );
2288 // quit the new manager
2289 Cudd_RecursiveDeref( ddG, bG2 );
2290 Extra_StopManager( ddG );
2291
2292 // re-enable variable ordering in ddF
2293 Cudd_AutodynEnable( ddF, CUDD_REORDER_SYMM_SIFT );
2294}
ABC_INT64_T abctime
Definition abc_global.h:332
void Extra_StopManager(DdManager *dd)
DdNode * Extra_bddAndPermute(DdManager *ddF, DdNode *bF, DdManager *ddG, DdNode *bG, int *pPermute)
DdNode * Extra_TransferLevelByLevel(DdManager *ddSource, DdManager *ddDestination, DdNode *f)
Here is the call graph for this function:

◆ Extra_TransferLevelByLevel()

DdNode * Extra_TransferLevelByLevel ( DdManager * ddSource,
DdManager * ddDestination,
DdNode * f )

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

Synopsis [Transfers the BDD from one manager into another level by level.]

Description [Transfers the BDD from one manager into another while preserving the correspondence between variables level by level.]

SideEffects [None]

SeeAlso []

Definition at line 112 of file extraBddMisc.c.

113{
114 DdNode * bRes;
115 int * pPermute;
116 int nMin, nMax, i;
117
118 nMin = ddMin(ddSource->size, ddDestination->size);
119 nMax = ddMax(ddSource->size, ddDestination->size);
120 pPermute = ABC_ALLOC( int, nMax );
121 // set up the variable permutation
122 for ( i = 0; i < nMin; i++ )
123 pPermute[ ddSource->invperm[i] ] = ddDestination->invperm[i];
124 if ( ddSource->size > ddDestination->size )
125 {
126 for ( ; i < nMax; i++ )
127 pPermute[ ddSource->invperm[i] ] = -1;
128 }
129 bRes = Extra_TransferPermute( ddSource, ddDestination, f, pPermute );
130 ABC_FREE( pPermute );
131 return bRes;
132}
DdNode * Extra_TransferPermute(DdManager *ddSource, DdManager *ddDestination, DdNode *f, int *Permute)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Extra_TransferPermute()

DdNode * Extra_TransferPermute ( DdManager * ddSource,
DdManager * ddDestination,
DdNode * f,
int * Permute )

AutomaticEnd Function********************************************************************

Synopsis [Convert a {A,B}DD from a manager to another with variable remapping.]

Description [Convert a {A,B}DD from a manager to another one. The orders of the variables in the two managers may be different. Returns a pointer to the {A,B}DD in the destination manager if successful; NULL otherwise. The i-th entry in the array Permute tells what is the index of the i-th variable from the old manager in the new manager.]

SideEffects [None]

SeeAlso []

Definition at line 87 of file extraBddMisc.c.

88{
89 DdNode * bRes;
90 do
91 {
92 ddDestination->reordered = 0;
93 bRes = extraTransferPermute( ddSource, ddDestination, f, Permute );
94 }
95 while ( ddDestination->reordered == 1 );
96 return ( bRes );
97
98} /* end of Extra_TransferPermute */
Here is the caller graph for this function:

◆ Extra_VectorSupportArray()

int * Extra_VectorSupportArray ( DdManager * dd,
DdNode ** F,
int n,
int * support )

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

Synopsis [Finds the variables on which a set of DDs depends.]

Description [Finds the variables on which a set of DDs depends. The set must contain either BDDs and ADDs, or ZDDs. Returns a BDD consisting of the product of the variables if successful; NULL otherwise.]

SideEffects [None]

SeeAlso [Cudd_Support Cudd_ClassifySupport]

Definition at line 572 of file extraBddMisc.c.

577{
578 int i, size;
579
580 /* Allocate and initialize support array for ddSupportStep. */
581 size = ddMax( dd->size, dd->sizeZ );
582 for ( i = 0; i < size; i++ )
583 support[i] = 0;
584
585 /* Compute support and clean up markers. */
586 for ( i = 0; i < n; i++ )
587 ddSupportStep2( Cudd_Regular(F[i]), support );
588 for ( i = 0; i < n; i++ )
589 ddClearFlag2( Cudd_Regular(F[i]) );
590
591 return support;
592}
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Extra_zddCombination()

DdNode * Extra_zddCombination ( DdManager * dd,
int * VarValues,
int nVars )

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

Synopsis [Creates ZDD of the combination containing given variables.]

Description [Creates ZDD of the combination containing given variables. VarValues contains 1 for a variable that belongs to the combination and 0 for a varible that does not belong. nVars is number of ZDD variables in the array.]

SideEffects [New ZDD variables are created if indices of the variables present in the combination are larger than the currently allocated number of ZDD variables.]

SeeAlso []

Definition at line 2451 of file extraBddMisc.c.

2455{
2456 DdNode *res;
2457 do {
2458 dd->reordered = 0;
2459 res = extraZddCombination(dd, VarValues, nVars);
2460 } while (dd->reordered == 1);
2461 return(res);
2462
2463} /* end of Extra_zddCombination */
DdNode * extraZddCombination(DdManager *dd, int *VarValues, int nVars)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Extra_zddDumpPla()

void Extra_zddDumpPla ( DdManager * dd,
DdNode * F,
int nVars,
char * pFileName )

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

Synopsis [Writes ZDD into a PLA file.]

Description []

SideEffects []

SeeAlso []

Definition at line 2307 of file extraBddMisc.c.

2308{
2309 DdGen *gen;
2310 char * pCube;
2311 int * pPath, i;
2312 FILE * pFile = fopen( pFileName, "wb" );
2313 if ( pFile == NULL )
2314 {
2315 printf( "Cannot open file \"%s\" for writing.\n", pFileName );
2316 return;
2317 }
2318 fprintf( pFile, "# PLA file dumped by Extra_zddDumpPla() in ABC\n" );
2319 fprintf( pFile, ".i %d\n", nVars );
2320 fprintf( pFile, ".o 1\n" );
2321 pCube = ABC_CALLOC( char, dd->sizeZ );
2322 Cudd_zddForeachPath( dd, F, gen, pPath )
2323 {
2324 for ( i = 0; i < nVars; i++ )
2325 pCube[i] = '-';
2326 for ( i = 0; i < nVars; i++ )
2327 if ( pPath[2*i] == 1 || pPath[2*i+1] == 1 )
2328 pCube[i] = '0' + (pPath[2*i] == 1);
2329 fprintf( pFile, "%s 1\n", pCube );
2330 }
2331 fprintf( pFile, ".e\n\n" );
2332 fclose( pFile );
2333 ABC_FREE( pCube );
2334}
#define ABC_CALLOC(type, num)
Definition abc_global.h:265

◆ Extra_zddPrimes()

DdNode * Extra_zddPrimes ( DdManager * dd,
DdNode * F )

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

Synopsis [Computes the set of primes as a ZDD.]

Description []

SideEffects []

SeeAlso []

Definition at line 933 of file extraBddMisc.c.

934{
935 DdNode *res;
936 do {
937 dd->reordered = 0;
938 res = extraZddPrimes(dd, F);
939 if ( dd->reordered == 1 )
940 printf("\nReordering in Extra_zddPrimes()\n");
941 } while (dd->reordered == 1);
942 return(res);
943
944} /* end of Extra_zddPrimes */

◆ Extra_zddRandomSet()

DdNode * Extra_zddRandomSet ( DdManager * dd,
int n,
int k,
double d )

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

Synopsis [Generates a random set of combinations.]

Description [Given a set of n elements, each of which is encoded using one ZDD variable, this function generates a random set of k subsets (combinations of elements) with density d. Assumes that k and n are positive integers. Returns NULL if density is less than 0.0 or more than 1.0.]

SideEffects [Allocates new ZDD variables if their current number is less than n.]

SeeAlso []

Definition at line 2480 of file extraBddMisc.c.

2485{
2486 DdNode *Result, *TempComb, *Aux;
2487 int c, v, Limit, *VarValues;
2488
2489 /* sanity check the parameters */
2490 if ( n <= 0 || k <= 0 || d < 0.0 || d > 1.0 )
2491 return NULL;
2492
2493 /* allocate temporary storage for variable values */
2494 VarValues = ABC_ALLOC( int, n );
2495 if (VarValues == NULL)
2496 {
2497 dd->errorCode = CUDD_MEMORY_OUT;
2498 return NULL;
2499 }
2500
2501 /* start the new set */
2502 Result = dd->zero;
2503 Cudd_Ref( Result );
2504
2505 /* seed random number generator */
2506 Cudd_Srandom( time(NULL) );
2507// Cudd_Srandom( 4 );
2508 /* determine the limit below which var belongs to the combination */
2509 Limit = (int)(d * 2147483561.0);
2510
2511 /* add combinations one by one */
2512 for ( c = 0; c < k; c++ )
2513 {
2514 for ( v = 0; v < n; v++ )
2515 if ( Cudd_Random() <= Limit )
2516 VarValues[v] = 1;
2517 else
2518 VarValues[v] = 0;
2519
2520 TempComb = Extra_zddCombination( dd, VarValues, n );
2521 Cudd_Ref( TempComb );
2522
2523 /* make sure that this combination is not already in the set */
2524 if ( c )
2525 { /* at least one combination is already included */
2526
2527 Aux = Cudd_zddDiff( dd, Result, TempComb );
2528 Cudd_Ref( Aux );
2529 if ( Aux != Result )
2530 {
2531 Cudd_RecursiveDerefZdd( dd, Aux );
2532 Cudd_RecursiveDerefZdd( dd, TempComb );
2533 c--;
2534 continue;
2535 }
2536 else
2537 { /* Aux is the same node as Result */
2538 Cudd_Deref( Aux );
2539 }
2540 }
2541
2542 Result = Cudd_zddUnion( dd, Aux = Result, TempComb );
2543 Cudd_Ref( Result );
2544 Cudd_RecursiveDerefZdd( dd, Aux );
2545 Cudd_RecursiveDerefZdd( dd, TempComb );
2546 }
2547
2548 ABC_FREE( VarValues );
2549 Cudd_Deref( Result );
2550 return Result;
2551
2552} /* end of Extra_zddRandomSet */
DdNode * Extra_zddCombination(DdManager *dd, int *VarValues, int nVars)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Extra_ZddTest()

void Extra_ZddTest ( )

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 2565 of file extraBddMisc.c.

2566{
2567 int N = 64;
2568 int K0 = 1000;
2569 int i, Size;
2570 DdManager * dd = Cudd_Init( 0, 32, CUDD_UNIQUE_SLOTS, CUDD_CACHE_SLOTS, 0 );
2571 for ( i = 1; i <= 10; i++ )
2572 {
2573 int K = K0 * i;
2574 DdNode * zRandSet = Extra_zddRandomSet( dd, N, K, 0.5 ); Cudd_Ref(zRandSet);
2575 Size = Cudd_zddDagSize(zRandSet);
2576 //Cudd_zddPrintMinterm( dd, zRandSet );
2577 printf( "N = %5d K = %5d BddSize = %6d MemBdd = %8.3f MB MemBit = %8.3f MB Ratio = %8.3f %%\n",
2578 N, K, Size, 20.0*Size/(1<<20), 0.125 * N * K /(1<<20), 100.0*(0.125 * N * K)/(20.0*Size) );
2579 Cudd_RecursiveDerefZdd( dd, zRandSet );
2580 }
2581 Cudd_Quit(dd);
2582}
DdNode * Extra_zddRandomSet(DdManager *dd, int n, int k, double d)
Here is the call graph for this function:

◆ extraBddChangePolarity()

DdNode * extraBddChangePolarity ( DdManager * dd,
DdNode * bFunc,
DdNode * bVars )

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

Synopsis [Performs the reordering-sensitive step of Extra_bddChangePolarity().]

Description []

SideEffects []

SeeAlso []

Definition at line 2041 of file extraBddMisc.c.

2045{
2046 DdNode * bRes;
2047
2048 if ( bVars == b1 )
2049 return bFunc;
2050 if ( Cudd_IsConstant(bFunc) )
2051 return bFunc;
2052
2053 if ( (bRes = cuddCacheLookup2(dd, extraBddChangePolarity, bFunc, bVars)) )
2054 return bRes;
2055 else
2056 {
2057 DdNode * bFR = Cudd_Regular(bFunc);
2058 int LevelF = dd->perm[bFR->index];
2059 int LevelV = dd->perm[bVars->index];
2060
2061 if ( LevelV < LevelF )
2062 bRes = extraBddChangePolarity( dd, bFunc, cuddT(bVars) );
2063 else // if ( LevelF <= LevelV )
2064 {
2065 DdNode * bRes0, * bRes1;
2066 DdNode * bF0, * bF1;
2067 DdNode * bVarsNext;
2068
2069 // cofactor the functions
2070 if ( bFR != bFunc ) // bFunc is complemented
2071 {
2072 bF0 = Cudd_Not( cuddE(bFR) );
2073 bF1 = Cudd_Not( cuddT(bFR) );
2074 }
2075 else
2076 {
2077 bF0 = cuddE(bFR);
2078 bF1 = cuddT(bFR);
2079 }
2080
2081 if ( LevelF == LevelV )
2082 bVarsNext = cuddT(bVars);
2083 else
2084 bVarsNext = bVars;
2085
2086 bRes0 = extraBddChangePolarity( dd, bF0, bVarsNext );
2087 if ( bRes0 == NULL )
2088 return NULL;
2089 cuddRef( bRes0 );
2090
2091 bRes1 = extraBddChangePolarity( dd, bF1, bVarsNext );
2092 if ( bRes1 == NULL )
2093 {
2094 Cudd_RecursiveDeref( dd, bRes0 );
2095 return NULL;
2096 }
2097 cuddRef( bRes1 );
2098
2099 if ( LevelF == LevelV )
2100 { // swap the cofactors
2101 DdNode * bTemp;
2102 bTemp = bRes0;
2103 bRes0 = bRes1;
2104 bRes1 = bTemp;
2105 }
2106
2107 /* only aRes0 and aRes1 are referenced at this point */
2108
2109 /* consider the case when Res0 and Res1 are the same node */
2110 if ( bRes0 == bRes1 )
2111 bRes = bRes1;
2112 /* consider the case when Res1 is complemented */
2113 else if ( Cudd_IsComplement(bRes1) )
2114 {
2115 bRes = cuddUniqueInter(dd, bFR->index, Cudd_Not(bRes1), Cudd_Not(bRes0));
2116 if ( bRes == NULL )
2117 {
2118 Cudd_RecursiveDeref(dd,bRes0);
2119 Cudd_RecursiveDeref(dd,bRes1);
2120 return NULL;
2121 }
2122 bRes = Cudd_Not(bRes);
2123 }
2124 else
2125 {
2126 bRes = cuddUniqueInter( dd, bFR->index, bRes1, bRes0 );
2127 if ( bRes == NULL )
2128 {
2129 Cudd_RecursiveDeref(dd,bRes0);
2130 Cudd_RecursiveDeref(dd,bRes1);
2131 return NULL;
2132 }
2133 }
2134 cuddDeref( bRes0 );
2135 cuddDeref( bRes1 );
2136 }
2137
2138 /* insert the result into cache */
2139 cuddCacheInsert2(dd, extraBddChangePolarity, bFunc, bVars, bRes);
2140 return bRes;
2141 }
2142} /* end of extraBddChangePolarity */
DdNode * extraBddChangePolarity(DdManager *dd, DdNode *bFunc, DdNode *bVars)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ extraBddMove()

DdNode * extraBddMove ( DdManager * dd,
DdNode * bF,
DdNode * bDist )

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

Synopsis [Performs the reordering-sensitive step of Extra_bddMove().]

Description []

SideEffects []

SeeAlso []

Definition at line 1128 of file extraBddMisc.c.

1132{
1133 DdNode * bRes;
1134
1135 if ( Cudd_IsConstant(bF) )
1136 return bF;
1137
1138 if ( (bRes = cuddCacheLookup2(dd, extraBddMove, bF, bDist)) )
1139 return bRes;
1140 else
1141 {
1142 DdNode * bRes0, * bRes1;
1143 DdNode * bF0, * bF1;
1144 DdNode * bFR = Cudd_Regular(bF);
1145 int VarNew;
1146
1147 if ( Cudd_IsComplement(bDist) )
1148 VarNew = bFR->index - Cudd_Not(bDist)->index;
1149 else
1150 VarNew = bFR->index + bDist->index;
1151 assert( VarNew < dd->size );
1152
1153 // cofactor the functions
1154 if ( bFR != bF ) // bFunc is complemented
1155 {
1156 bF0 = Cudd_Not( cuddE(bFR) );
1157 bF1 = Cudd_Not( cuddT(bFR) );
1158 }
1159 else
1160 {
1161 bF0 = cuddE(bFR);
1162 bF1 = cuddT(bFR);
1163 }
1164
1165 bRes0 = extraBddMove( dd, bF0, bDist );
1166 if ( bRes0 == NULL )
1167 return NULL;
1168 cuddRef( bRes0 );
1169
1170 bRes1 = extraBddMove( dd, bF1, bDist );
1171 if ( bRes1 == NULL )
1172 {
1173 Cudd_RecursiveDeref( dd, bRes0 );
1174 return NULL;
1175 }
1176 cuddRef( bRes1 );
1177
1178 /* only bRes0 and bRes1 are referenced at this point */
1179 bRes = cuddBddIteRecur( dd, dd->vars[VarNew], bRes1, bRes0 );
1180 if ( bRes == NULL )
1181 {
1182 Cudd_RecursiveDeref( dd, bRes0 );
1183 Cudd_RecursiveDeref( dd, bRes1 );
1184 return NULL;
1185 }
1186 cuddRef( bRes );
1187 Cudd_RecursiveDeref( dd, bRes0 );
1188 Cudd_RecursiveDeref( dd, bRes1 );
1189
1190 /* insert the result into cache */
1191 cuddCacheInsert2( dd, extraBddMove, bF, bDist, bRes );
1192 cuddDeref( bRes );
1193 return bRes;
1194 }
1195} /* end of extraBddMove */
DdNode * extraBddMove(DdManager *dd, DdNode *bF, DdNode *bFlag)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ extraBddTuples()

DdNode * extraBddTuples ( DdManager * dd,
DdNode * bVarsK,
DdNode * bVarsN )

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

Synopsis [Performs the reordering-sensitive step of Extra_bddTuples().]

Description [Generates in a bottom-up fashion BDD for all combinations composed of k variables out of variables belonging to bVarsN.]

SideEffects []

SeeAlso []

Definition at line 2597 of file extraBddMisc.c.

2601{
2602 DdNode *bRes, *bRes0, *bRes1;
2603 statLine(dd);
2604
2605 /* terminal cases */
2606/* if ( k < 0 || k > n )
2607 * return dd->zero;
2608 * if ( n == 0 )
2609 * return dd->one;
2610 */
2611 if ( cuddI( dd, bVarsK->index ) < cuddI( dd, bVarsN->index ) )
2612 return b0;
2613 if ( bVarsN == b1 )
2614 return b1;
2615
2616 /* check cache */
2617 bRes = cuddCacheLookup2(dd, extraBddTuples, bVarsK, bVarsN);
2618 if (bRes)
2619 return(bRes);
2620
2621 /* ZDD in which is variable is 0 */
2622/* bRes0 = extraBddTuples( dd, k, n-1 ); */
2623 bRes0 = extraBddTuples( dd, bVarsK, cuddT(bVarsN) );
2624 if ( bRes0 == NULL )
2625 return NULL;
2626 cuddRef( bRes0 );
2627
2628 /* ZDD in which is variable is 1 */
2629/* bRes1 = extraBddTuples( dd, k-1, n-1 ); */
2630 if ( bVarsK == b1 )
2631 {
2632 bRes1 = b0;
2633 cuddRef( bRes1 );
2634 }
2635 else
2636 {
2637 bRes1 = extraBddTuples( dd, cuddT(bVarsK), cuddT(bVarsN) );
2638 if ( bRes1 == NULL )
2639 {
2640 Cudd_RecursiveDeref( dd, bRes0 );
2641 return NULL;
2642 }
2643 cuddRef( bRes1 );
2644 }
2645
2646 /* consider the case when Res0 and Res1 are the same node */
2647 if ( bRes0 == bRes1 )
2648 bRes = bRes1;
2649 /* consider the case when Res1 is complemented */
2650 else if ( Cudd_IsComplement(bRes1) )
2651 {
2652 bRes = cuddUniqueInter(dd, bVarsN->index, Cudd_Not(bRes1), Cudd_Not(bRes0));
2653 if ( bRes == NULL )
2654 {
2655 Cudd_RecursiveDeref(dd,bRes0);
2656 Cudd_RecursiveDeref(dd,bRes1);
2657 return NULL;
2658 }
2659 bRes = Cudd_Not(bRes);
2660 }
2661 else
2662 {
2663 bRes = cuddUniqueInter( dd, bVarsN->index, bRes1, bRes0 );
2664 if ( bRes == NULL )
2665 {
2666 Cudd_RecursiveDeref(dd,bRes0);
2667 Cudd_RecursiveDeref(dd,bRes1);
2668 return NULL;
2669 }
2670 }
2671 cuddDeref( bRes0 );
2672 cuddDeref( bRes1 );
2673
2674 /* insert the result into cache */
2675 cuddCacheInsert2(dd, extraBddTuples, bVarsK, bVarsN, bRes);
2676 return bRes;
2677
2678} /* end of extraBddTuples */
DdNode * extraBddTuples(DdManager *dd, DdNode *bVarsK, DdNode *bVarsN)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ extraComposeCover()

DdNode * extraComposeCover ( DdManager * dd,
DdNode * zC0,
DdNode * zC1,
DdNode * zC2,
int TopVar )

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

Synopsis [Composed three subcovers into one ZDD.]

Description []

SideEffects [None]

SeeAlso []

Definition at line 1754 of file extraBddMisc.c.

1760{
1761 DdNode * zRes, * zTemp;
1762 /* compose with-neg-var and without-var using the neg ZDD var */
1763 zTemp = cuddZddGetNode( dd, 2*TopVar + 1, zC0, zC2 );
1764 if ( zTemp == NULL )
1765 {
1766 Cudd_RecursiveDerefZdd(dd, zC0);
1767 Cudd_RecursiveDerefZdd(dd, zC1);
1768 Cudd_RecursiveDerefZdd(dd, zC2);
1769 return NULL;
1770 }
1771 cuddRef( zTemp );
1772 cuddDeref( zC0 );
1773 cuddDeref( zC2 );
1774
1775 /* compose with-pos-var and previous result using the pos ZDD var */
1776 zRes = cuddZddGetNode( dd, 2*TopVar, zC1, zTemp );
1777 if ( zRes == NULL )
1778 {
1779 Cudd_RecursiveDerefZdd(dd, zC1);
1780 Cudd_RecursiveDerefZdd(dd, zTemp);
1781 return NULL;
1782 }
1783 cuddDeref( zC1 );
1784 cuddDeref( zTemp );
1785 return zRes;
1786} /* extraComposeCover */

◆ extraDecomposeCover()

void extraDecomposeCover ( DdManager * dd,
DdNode * zC,
DdNode ** zC0,
DdNode ** zC1,
DdNode ** zC2 )

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

Synopsis [Finds three cofactors of the cover w.r.t. to the topmost variable.]

Description [Finds three cofactors of the cover w.r.t. to the topmost variable. Does not check the cover for being a constant. Assumes that ZDD variables encoding positive and negative polarities are adjacent in the variable order. Is different from cuddZddGetCofactors3() in that it does not compute the cofactors w.r.t. the given variable but takes the cofactors with respent to the topmost variable. This function is more efficient when used in recursive procedures because it does not require referencing of the resulting cofactors (compare cuddZddProduct() and extraZddPrimeProduct()).]

SideEffects [None]

SeeAlso [cuddZddGetCofactors3]

Definition at line 1217 of file extraBddMisc.c.

1223{
1224 if ( (zC->index & 1) == 0 )
1225 { /* the top variable is present in positive polarity and maybe in negative */
1226
1227 DdNode *Temp = cuddE( zC );
1228 *zC1 = cuddT( zC );
1229 if ( cuddIZ(dd,Temp->index) == cuddIZ(dd,zC->index) + 1 )
1230 { /* Temp is not a terminal node
1231 * top var is present in negative polarity */
1232 *zC2 = cuddE( Temp );
1233 *zC0 = cuddT( Temp );
1234 }
1235 else
1236 { /* top var is not present in negative polarity */
1237 *zC2 = Temp;
1238 *zC0 = dd->zero;
1239 }
1240 }
1241 else
1242 { /* the top variable is present only in negative */
1243 *zC1 = dd->zero;
1244 *zC2 = cuddE( zC );
1245 *zC0 = cuddT( zC );
1246 }
1247} /* extraDecomposeCover */

◆ extraZddCombination()

DdNode * extraZddCombination ( DdManager * dd,
int * VarValues,
int nVars )

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

Synopsis [Performs the reordering-sensitive step of Extra_zddCombination().]

Description [Generates in a bottom-up fashion ZDD for one combination whose var values are given in the array VarValues. If necessary, creates new variables on the fly.]

SideEffects []

SeeAlso []

Definition at line 2399 of file extraBddMisc.c.

2403{
2404 int lev, index;
2405 DdNode *zRes, *zTemp;
2406
2407 /* transform the combination from the array VarValues into a ZDD cube. */
2408 zRes = dd->one;
2409 cuddRef(zRes);
2410
2411 /* go through levels starting bottom-up and create nodes
2412 * if these variables are present in the comb
2413 */
2414 for (lev = nVars - 1; lev >= 0; lev--)
2415 {
2416 index = (lev >= dd->sizeZ) ? lev : dd->invpermZ[lev];
2417 if (VarValues[index] == 1)
2418 {
2419 /* compose zRes with ZERO for the given ZDD variable */
2420 zRes = cuddZddGetNode( dd, index, zTemp = zRes, dd->zero );
2421 if ( zRes == NULL )
2422 {
2423 Cudd_RecursiveDerefZdd( dd, zTemp );
2424 return NULL;
2425 }
2426 cuddRef( zRes );
2427 cuddDeref( zTemp );
2428 }
2429 }
2430 cuddDeref( zRes );
2431 return zRes;
2432
2433} /* end of extraZddCombination */
Here is the caller graph for this function: