abc-master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
cudd.h File Reference
#include "bdd/mtr/mtr.h"
#include "bdd/epd/epd.h"

Go to the source code of this file.

Data Structures

struct  DdChildren
 
struct  DdNode
 

Macros

#define CUDD_VERSION   "2.4.2"
 
#define SIZEOF_VOID_P   4
 
#define SIZEOF_INT   4
 
#define SIZEOF_LONG   4
 
#define TRUE   1
 
#define FALSE   0
 
#define CUDD_VALUE_TYPE   double
 
#define CUDD_OUT_OF_MEM   -1
 
#define CUDD_UNIQUE_SLOTS   256 /* initial size of subtables */
 
#define CUDD_CACHE_SLOTS   262144 /* default size of the cache */
 
#define CUDD_RESIDUE_DEFAULT   0
 
#define CUDD_RESIDUE_MSB   1
 
#define CUDD_RESIDUE_TC   2
 
#define CUDD_MAXINDEX   ((DdHalfWord) ~0)
 
#define CUDD_CONST_INDEX   CUDD_MAXINDEX
 
#define DD_APA_BITS   16
 
#define DD_APA_BASE   (1 << DD_APA_BITS)
 
#define DD_APA_HEXPRINT   "%04x"
 
#define DD_APA_MASK   (DD_APA_BASE - 1)
 
#define Cudd_IsConstant(node)   ((Cudd_Regular(node))->index == CUDD_CONST_INDEX)
 
#define Cudd_Not(node)   ((DdNode *)((ptrint)(node) ^ 01))
 
#define Cudd_NotCond(node, c)   ((DdNode *)((ptrint)(node) ^ (c)))
 
#define Cudd_Regular(node)   ((DdNode *)((ptruint)(node) & ~01))
 
#define Cudd_Complement(node)   ((DdNode *)((ptruint)(node) | 01))
 
#define Cudd_IsComplement(node)   ((int) ((ptrint) (node) & 01))
 
#define Cudd_T(node)   ((Cudd_Regular(node))->type.kids.T)
 
#define Cudd_E(node)   ((Cudd_Regular(node))->type.kids.E)
 
#define Cudd_V(node)   ((Cudd_Regular(node))->type.value)
 
#define Cudd_ReadIndex(dd, index)   (Cudd_ReadPerm(dd,index))
 
#define Cudd_ForeachCube(manager, f, gen, cube, value)
 
#define Cudd_ForeachPrime(manager, l, u, gen, cube)
 
#define Cudd_ForeachNode(manager, f, gen, node)
 
#define Cudd_zddForeachPath(manager, f, gen, path)
 

Typedefs

typedef unsigned short DdHalfWord
 
typedef struct DdNode DdNode
 
typedef struct DdChildren DdChildren
 
typedef struct DdManager DdManager
 
typedef struct DdGen DdGen
 
typedef unsigned short int DdApaDigit
 
typedef unsigned int DdApaDoubleDigit
 
typedef DdApaDigitDdApaNumber
 
typedef struct DdTlcInfo DdTlcInfo
 
typedef int(* DD_HFP )(DdManager *, const char *, void *)
 
typedef DdNode *(* DD_PRFP )(DdManager *, int, DdNode **, DdNode **, DdNode **)
 
typedef DdNode *(* DD_AOP )(DdManager *, DdNode **, DdNode **)
 
typedef DdNode *(* DD_MAOP )(DdManager *, DdNode *)
 
typedef DdNode *(* DD_CTFP )(DdManager *, DdNode *, DdNode *)
 
typedef DdNode *(* DD_CTFP1 )(DdManager *, DdNode *)
 
typedef void(* DD_OOMFP )(long)
 
typedef int(* DD_QSFP )(const void *, const void *)
 

Enumerations

enum  Cudd_ReorderingType {
  CUDD_REORDER_SAME, CUDD_REORDER_NONE, CUDD_REORDER_RANDOM, CUDD_REORDER_RANDOM_PIVOT,
  CUDD_REORDER_SIFT, CUDD_REORDER_SIFT_CONVERGE, CUDD_REORDER_SYMM_SIFT, CUDD_REORDER_SYMM_SIFT_CONV,
  CUDD_REORDER_WINDOW2, CUDD_REORDER_WINDOW3, CUDD_REORDER_WINDOW4, CUDD_REORDER_WINDOW2_CONV,
  CUDD_REORDER_WINDOW3_CONV, CUDD_REORDER_WINDOW4_CONV, CUDD_REORDER_GROUP_SIFT, CUDD_REORDER_GROUP_SIFT_CONV,
  CUDD_REORDER_ANNEALING, CUDD_REORDER_GENETIC, CUDD_REORDER_LINEAR, CUDD_REORDER_LINEAR_CONVERGE,
  CUDD_REORDER_LAZY_SIFT, CUDD_REORDER_EXACT
}
 
enum  Cudd_AggregationType {
  CUDD_NO_CHECK, CUDD_GROUP_CHECK, CUDD_GROUP_CHECK2, CUDD_GROUP_CHECK3,
  CUDD_GROUP_CHECK4, CUDD_GROUP_CHECK5, CUDD_GROUP_CHECK6, CUDD_GROUP_CHECK7,
  CUDD_GROUP_CHECK8, CUDD_GROUP_CHECK9
}
 
enum  Cudd_HookType { CUDD_PRE_GC_HOOK, CUDD_POST_GC_HOOK, CUDD_PRE_REORDERING_HOOK, CUDD_POST_REORDERING_HOOK }
 
enum  Cudd_ErrorType {
  CUDD_NO_ERROR, CUDD_MEMORY_OUT, CUDD_TOO_MANY_NODES, CUDD_MAX_MEM_EXCEEDED,
  CUDD_INVALID_ARG, CUDD_INTERNAL_ERROR
}
 
enum  Cudd_LazyGroupType { CUDD_LAZY_NONE, CUDD_LAZY_SOFT_GROUP, CUDD_LAZY_HARD_GROUP, CUDD_LAZY_UNGROUP }
 
enum  Cudd_VariableType { CUDD_VAR_PRIMARY_INPUT, CUDD_VAR_PRESENT_STATE, CUDD_VAR_NEXT_STATE }
 

Functions

DdNodeCudd_addNewVar (DdManager *dd)
 
DdNodeCudd_addNewVarAtLevel (DdManager *dd, int level)
 
DdNodeCudd_bddNewVar (DdManager *dd)
 
DdNodeCudd_bddNewVarAtLevel (DdManager *dd, int level)
 
DdNodeCudd_addIthVar (DdManager *dd, int i)
 
DdNodeCudd_bddIthVar (DdManager *dd, int i)
 
DdNodeCudd_zddIthVar (DdManager *dd, int i)
 
int Cudd_zddVarsFromBddVars (DdManager *dd, int multiplicity)
 
DdNodeCudd_addConst (DdManager *dd, CUDD_VALUE_TYPE c)
 
int Cudd_IsNonConstant (DdNode *f)
 
void Cudd_AutodynEnable (DdManager *unique, Cudd_ReorderingType method)
 
void Cudd_AutodynDisable (DdManager *unique)
 
int Cudd_ReorderingStatus (DdManager *unique, Cudd_ReorderingType *method)
 
void Cudd_AutodynEnableZdd (DdManager *unique, Cudd_ReorderingType method)
 
void Cudd_AutodynDisableZdd (DdManager *unique)
 
int Cudd_ReorderingStatusZdd (DdManager *unique, Cudd_ReorderingType *method)
 
int Cudd_zddRealignmentEnabled (DdManager *unique)
 
void Cudd_zddRealignEnable (DdManager *unique)
 
void Cudd_zddRealignDisable (DdManager *unique)
 
int Cudd_bddRealignmentEnabled (DdManager *unique)
 
void Cudd_bddRealignEnable (DdManager *unique)
 
void Cudd_bddRealignDisable (DdManager *unique)
 
DdNodeCudd_ReadOne (DdManager *dd)
 
DdNodeCudd_ReadZddOne (DdManager *dd, int i)
 
DdNodeCudd_ReadZero (DdManager *dd)
 
DdNodeCudd_ReadLogicZero (DdManager *dd)
 
DdNodeCudd_ReadPlusInfinity (DdManager *dd)
 
DdNodeCudd_ReadMinusInfinity (DdManager *dd)
 
DdNodeCudd_ReadBackground (DdManager *dd)
 
void Cudd_SetBackground (DdManager *dd, DdNode *bck)
 
unsigned int Cudd_ReadCacheSlots (DdManager *dd)
 
double Cudd_ReadCacheUsedSlots (DdManager *dd)
 
double Cudd_ReadCacheLookUps (DdManager *dd)
 
double Cudd_ReadCacheHits (DdManager *dd)
 
double Cudd_ReadRecursiveCalls (DdManager *dd)
 
unsigned int Cudd_ReadMinHit (DdManager *dd)
 
void Cudd_SetMinHit (DdManager *dd, unsigned int hr)
 
unsigned int Cudd_ReadLooseUpTo (DdManager *dd)
 
void Cudd_SetLooseUpTo (DdManager *dd, unsigned int lut)
 
unsigned int Cudd_ReadMaxCache (DdManager *dd)
 
unsigned int Cudd_ReadMaxCacheHard (DdManager *dd)
 
void Cudd_SetMaxCacheHard (DdManager *dd, unsigned int mc)
 
int Cudd_ReadSize (DdManager *dd)
 
int Cudd_ReadZddSize (DdManager *dd)
 
unsigned int Cudd_ReadSlots (DdManager *dd)
 
double Cudd_ReadUsedSlots (DdManager *dd)
 
double Cudd_ExpectedUsedSlots (DdManager *dd)
 
unsigned int Cudd_ReadKeys (DdManager *dd)
 
unsigned int Cudd_ReadDead (DdManager *dd)
 
unsigned int Cudd_ReadMinDead (DdManager *dd)
 
int Cudd_ReadReorderings (DdManager *dd)
 
long Cudd_ReadReorderingTime (DdManager *dd)
 
int Cudd_ReadGarbageCollections (DdManager *dd)
 
long Cudd_ReadGarbageCollectionTime (DdManager *dd)
 
double Cudd_ReadNodesFreed (DdManager *dd)
 
double Cudd_ReadNodesDropped (DdManager *dd)
 
double Cudd_ReadUniqueLookUps (DdManager *dd)
 
double Cudd_ReadUniqueLinks (DdManager *dd)
 
int Cudd_ReadSiftMaxVar (DdManager *dd)
 
void Cudd_SetSiftMaxVar (DdManager *dd, int smv)
 
int Cudd_ReadSiftMaxSwap (DdManager *dd)
 
void Cudd_SetSiftMaxSwap (DdManager *dd, int sms)
 
double Cudd_ReadMaxGrowth (DdManager *dd)
 
void Cudd_SetMaxGrowth (DdManager *dd, double mg)
 
double Cudd_ReadMaxGrowthAlternate (DdManager *dd)
 
void Cudd_SetMaxGrowthAlternate (DdManager *dd, double mg)
 
int Cudd_ReadReorderingCycle (DdManager *dd)
 
void Cudd_SetReorderingCycle (DdManager *dd, int cycle)
 
MtrNodeCudd_ReadTree (DdManager *dd)
 
void Cudd_SetTree (DdManager *dd, MtrNode *tree)
 
void Cudd_FreeTree (DdManager *dd)
 
MtrNodeCudd_ReadZddTree (DdManager *dd)
 
void Cudd_SetZddTree (DdManager *dd, MtrNode *tree)
 
void Cudd_FreeZddTree (DdManager *dd)
 
unsigned int Cudd_NodeReadIndex (DdNode *node)
 
int Cudd_ReadPerm (DdManager *dd, int i)
 
int Cudd_ReadPermZdd (DdManager *dd, int i)
 
int Cudd_ReadInvPerm (DdManager *dd, int i)
 
int Cudd_ReadInvPermZdd (DdManager *dd, int i)
 
DdNodeCudd_ReadVars (DdManager *dd, int i)
 
CUDD_VALUE_TYPE Cudd_ReadEpsilon (DdManager *dd)
 
void Cudd_SetEpsilon (DdManager *dd, CUDD_VALUE_TYPE ep)
 
Cudd_AggregationType Cudd_ReadGroupcheck (DdManager *dd)
 
void Cudd_SetGroupcheck (DdManager *dd, Cudd_AggregationType gc)
 
int Cudd_GarbageCollectionEnabled (DdManager *dd)
 
void Cudd_EnableGarbageCollection (DdManager *dd)
 
void Cudd_DisableGarbageCollection (DdManager *dd)
 
int Cudd_DeadAreCounted (DdManager *dd)
 
void Cudd_TurnOnCountDead (DdManager *dd)
 
void Cudd_TurnOffCountDead (DdManager *dd)
 
int Cudd_ReadRecomb (DdManager *dd)
 
void Cudd_SetRecomb (DdManager *dd, int recomb)
 
int Cudd_ReadSymmviolation (DdManager *dd)
 
void Cudd_SetSymmviolation (DdManager *dd, int symmviolation)
 
int Cudd_ReadArcviolation (DdManager *dd)
 
void Cudd_SetArcviolation (DdManager *dd, int arcviolation)
 
int Cudd_ReadPopulationSize (DdManager *dd)
 
void Cudd_SetPopulationSize (DdManager *dd, int populationSize)
 
int Cudd_ReadNumberXovers (DdManager *dd)
 
void Cudd_SetNumberXovers (DdManager *dd, int numberXovers)
 
unsigned long Cudd_ReadMemoryInUse (DdManager *dd)
 
int Cudd_PrintInfo (DdManager *dd, FILE *fp)
 
long Cudd_ReadPeakNodeCount (DdManager *dd)
 
int Cudd_ReadPeakLiveNodeCount (DdManager *dd)
 
long Cudd_ReadNodeCount (DdManager *dd)
 
long Cudd_zddReadNodeCount (DdManager *dd)
 
int Cudd_AddHook (DdManager *dd, DD_HFP f, Cudd_HookType where)
 
int Cudd_RemoveHook (DdManager *dd, DD_HFP f, Cudd_HookType where)
 
int Cudd_IsInHook (DdManager *dd, DD_HFP f, Cudd_HookType where)
 
int Cudd_StdPreReordHook (DdManager *dd, const char *str, void *data)
 
int Cudd_StdPostReordHook (DdManager *dd, const char *str, void *data)
 
int Cudd_EnableReorderingReporting (DdManager *dd)
 
int Cudd_DisableReorderingReporting (DdManager *dd)
 
int Cudd_ReorderingReporting (DdManager *dd)
 
Cudd_ErrorType Cudd_ReadErrorCode (DdManager *dd)
 
void Cudd_ClearErrorCode (DdManager *dd)
 
FILE * Cudd_ReadStdout (DdManager *dd)
 
void Cudd_SetStdout (DdManager *dd, FILE *fp)
 
FILE * Cudd_ReadStderr (DdManager *dd)
 
void Cudd_SetStderr (DdManager *dd, FILE *fp)
 
unsigned int Cudd_ReadNextReordering (DdManager *dd)
 
void Cudd_SetNextReordering (DdManager *dd, unsigned int next)
 
double Cudd_ReadSwapSteps (DdManager *dd)
 
unsigned int Cudd_ReadMaxLive (DdManager *dd)
 
void Cudd_SetMaxLive (DdManager *dd, unsigned int maxLive)
 
unsigned long Cudd_ReadMaxMemory (DdManager *dd)
 
void Cudd_SetMaxMemory (DdManager *dd, unsigned long maxMemory)
 
int Cudd_bddBindVar (DdManager *dd, int index)
 
int Cudd_bddUnbindVar (DdManager *dd, int index)
 
int Cudd_bddVarIsBound (DdManager *dd, int index)
 
DdNodeCudd_addExistAbstract (DdManager *manager, DdNode *f, DdNode *cube)
 
DdNodeCudd_addUnivAbstract (DdManager *manager, DdNode *f, DdNode *cube)
 
DdNodeCudd_addOrAbstract (DdManager *manager, DdNode *f, DdNode *cube)
 
DdNodeCudd_addApply (DdManager *dd, DdNode *(*)(DdManager *, DdNode **, DdNode **), DdNode *f, DdNode *g)
 
DdNodeCudd_addPlus (DdManager *dd, DdNode **f, DdNode **g)
 
DdNodeCudd_addTimes (DdManager *dd, DdNode **f, DdNode **g)
 
DdNodeCudd_addThreshold (DdManager *dd, DdNode **f, DdNode **g)
 
DdNodeCudd_addSetNZ (DdManager *dd, DdNode **f, DdNode **g)
 
DdNodeCudd_addDivide (DdManager *dd, DdNode **f, DdNode **g)
 
DdNodeCudd_addMinus (DdManager *dd, DdNode **f, DdNode **g)
 
DdNodeCudd_addMinimum (DdManager *dd, DdNode **f, DdNode **g)
 
DdNodeCudd_addMaximum (DdManager *dd, DdNode **f, DdNode **g)
 
DdNodeCudd_addOneZeroMaximum (DdManager *dd, DdNode **f, DdNode **g)
 
DdNodeCudd_addDiff (DdManager *dd, DdNode **f, DdNode **g)
 
DdNodeCudd_addAgreement (DdManager *dd, DdNode **f, DdNode **g)
 
DdNodeCudd_addOr (DdManager *dd, DdNode **f, DdNode **g)
 
DdNodeCudd_addNand (DdManager *dd, DdNode **f, DdNode **g)
 
DdNodeCudd_addNor (DdManager *dd, DdNode **f, DdNode **g)
 
DdNodeCudd_addXor (DdManager *dd, DdNode **f, DdNode **g)
 
DdNodeCudd_addXnor (DdManager *dd, DdNode **f, DdNode **g)
 
DdNodeCudd_addMonadicApply (DdManager *dd, DdNode *(*op)(DdManager *, DdNode *), DdNode *f)
 
DdNodeCudd_addLog (DdManager *dd, DdNode *f)
 
DdNodeCudd_addFindMax (DdManager *dd, DdNode *f)
 
DdNodeCudd_addFindMin (DdManager *dd, DdNode *f)
 
DdNodeCudd_addIthBit (DdManager *dd, DdNode *f, int bit)
 
DdNodeCudd_addScalarInverse (DdManager *dd, DdNode *f, DdNode *epsilon)
 
DdNodeCudd_addIte (DdManager *dd, DdNode *f, DdNode *g, DdNode *h)
 
DdNodeCudd_addIteConstant (DdManager *dd, DdNode *f, DdNode *g, DdNode *h)
 
DdNodeCudd_addEvalConst (DdManager *dd, DdNode *f, DdNode *g)
 
int Cudd_addLeq (DdManager *dd, DdNode *f, DdNode *g)
 
DdNodeCudd_addCmpl (DdManager *dd, DdNode *f)
 
DdNodeCudd_addNegate (DdManager *dd, DdNode *f)
 
DdNodeCudd_addRoundOff (DdManager *dd, DdNode *f, int N)
 
DdNodeCudd_addWalsh (DdManager *dd, DdNode **x, DdNode **y, int n)
 
DdNodeCudd_addResidue (DdManager *dd, int n, int m, int options, int top)
 
DdNodeCudd_bddAndAbstract (DdManager *manager, DdNode *f, DdNode *g, DdNode *cube)
 
DdNodeCudd_bddAndAbstractLimit (DdManager *manager, DdNode *f, DdNode *g, DdNode *cube, unsigned int limit)
 
int Cudd_ApaNumberOfDigits (int binaryDigits)
 
DdApaNumber Cudd_NewApaNumber (int digits)
 
void Cudd_ApaCopy (int digits, DdApaNumber source, DdApaNumber dest)
 
DdApaDigit Cudd_ApaAdd (int digits, DdApaNumber a, DdApaNumber b, DdApaNumber sum)
 
DdApaDigit Cudd_ApaSubtract (int digits, DdApaNumber a, DdApaNumber b, DdApaNumber diff)
 
DdApaDigit Cudd_ApaShortDivision (int digits, DdApaNumber dividend, DdApaDigit divisor, DdApaNumber quotient)
 
unsigned int Cudd_ApaIntDivision (int digits, DdApaNumber dividend, unsigned int divisor, DdApaNumber quotient)
 
void Cudd_ApaShiftRight (int digits, DdApaDigit in, DdApaNumber a, DdApaNumber b)
 
void Cudd_ApaSetToLiteral (int digits, DdApaNumber number, DdApaDigit literal)
 
void Cudd_ApaPowerOfTwo (int digits, DdApaNumber number, int power)
 
int Cudd_ApaCompare (int digitsFirst, DdApaNumber first, int digitsSecond, DdApaNumber second)
 
int Cudd_ApaCompareRatios (int digitsFirst, DdApaNumber firstNum, unsigned int firstDen, int digitsSecond, DdApaNumber secondNum, unsigned int secondDen)
 
int Cudd_ApaPrintHex (FILE *fp, int digits, DdApaNumber number)
 
int Cudd_ApaPrintDecimal (FILE *fp, int digits, DdApaNumber number)
 
int Cudd_ApaPrintExponential (FILE *fp, int digits, DdApaNumber number, int precision)
 
DdApaNumber Cudd_ApaCountMinterm (DdManager *manager, DdNode *node, int nvars, int *digits)
 
int Cudd_ApaPrintMinterm (FILE *fp, DdManager *dd, DdNode *node, int nvars)
 
int Cudd_ApaPrintMintermExp (FILE *fp, DdManager *dd, DdNode *node, int nvars, int precision)
 
int Cudd_ApaPrintDensity (FILE *fp, DdManager *dd, DdNode *node, int nvars)
 
DdNodeCudd_UnderApprox (DdManager *dd, DdNode *f, int numVars, int threshold, int safe, double quality)
 
DdNodeCudd_OverApprox (DdManager *dd, DdNode *f, int numVars, int threshold, int safe, double quality)
 
DdNodeCudd_RemapUnderApprox (DdManager *dd, DdNode *f, int numVars, int threshold, double quality)
 
DdNodeCudd_RemapOverApprox (DdManager *dd, DdNode *f, int numVars, int threshold, double quality)
 
DdNodeCudd_BiasedUnderApprox (DdManager *dd, DdNode *f, DdNode *b, int numVars, int threshold, double quality1, double quality0)
 
DdNodeCudd_BiasedOverApprox (DdManager *dd, DdNode *f, DdNode *b, int numVars, int threshold, double quality1, double quality0)
 
DdNodeCudd_bddExistAbstract (DdManager *manager, DdNode *f, DdNode *cube)
 
DdNodeCudd_bddXorExistAbstract (DdManager *manager, DdNode *f, DdNode *g, DdNode *cube)
 
DdNodeCudd_bddUnivAbstract (DdManager *manager, DdNode *f, DdNode *cube)
 
DdNodeCudd_bddBooleanDiff (DdManager *manager, DdNode *f, int x)
 
int Cudd_bddVarIsDependent (DdManager *dd, DdNode *f, DdNode *var)
 
double Cudd_bddCorrelation (DdManager *manager, DdNode *f, DdNode *g)
 
double Cudd_bddCorrelationWeights (DdManager *manager, DdNode *f, DdNode *g, double *prob)
 
DdNodeCudd_bddIte (DdManager *dd, DdNode *f, DdNode *g, DdNode *h)
 
DdNodeCudd_bddIteConstant (DdManager *dd, DdNode *f, DdNode *g, DdNode *h)
 
DdNodeCudd_bddIntersect (DdManager *dd, DdNode *f, DdNode *g)
 
DdNodeCudd_bddAnd (DdManager *dd, DdNode *f, DdNode *g)
 
DdNodeCudd_bddAndLimit (DdManager *dd, DdNode *f, DdNode *g, unsigned int limit)
 
DdNodeCudd_bddOr (DdManager *dd, DdNode *f, DdNode *g)
 
DdNodeCudd_bddNand (DdManager *dd, DdNode *f, DdNode *g)
 
DdNodeCudd_bddNor (DdManager *dd, DdNode *f, DdNode *g)
 
DdNodeCudd_bddXor (DdManager *dd, DdNode *f, DdNode *g)
 
DdNodeCudd_bddXnor (DdManager *dd, DdNode *f, DdNode *g)
 
int Cudd_bddLeq (DdManager *dd, DdNode *f, DdNode *g)
 
DdNodeCudd_addBddThreshold (DdManager *dd, DdNode *f, CUDD_VALUE_TYPE value)
 
DdNodeCudd_addBddStrictThreshold (DdManager *dd, DdNode *f, CUDD_VALUE_TYPE value)
 
DdNodeCudd_addBddInterval (DdManager *dd, DdNode *f, CUDD_VALUE_TYPE lower, CUDD_VALUE_TYPE upper)
 
DdNodeCudd_addBddIthBit (DdManager *dd, DdNode *f, int bit)
 
DdNodeCudd_BddToAdd (DdManager *dd, DdNode *B)
 
DdNodeCudd_addBddPattern (DdManager *dd, DdNode *f)
 
DdNodeCudd_bddTransfer (DdManager *ddSource, DdManager *ddDestination, DdNode *f)
 
int Cudd_DebugCheck (DdManager *table)
 
int Cudd_CheckKeys (DdManager *table)
 
DdNodeCudd_bddClippingAnd (DdManager *dd, DdNode *f, DdNode *g, int maxDepth, int direction)
 
DdNodeCudd_bddClippingAndAbstract (DdManager *dd, DdNode *f, DdNode *g, DdNode *cube, int maxDepth, int direction)
 
DdNodeCudd_Cofactor (DdManager *dd, DdNode *f, DdNode *g)
 
DdNodeCudd_bddCompose (DdManager *dd, DdNode *f, DdNode *g, int v)
 
DdNodeCudd_addCompose (DdManager *dd, DdNode *f, DdNode *g, int v)
 
DdNodeCudd_addPermute (DdManager *manager, DdNode *node, int *permut)
 
DdNodeCudd_addSwapVariables (DdManager *dd, DdNode *f, DdNode **x, DdNode **y, int n)
 
DdNodeCudd_bddPermute (DdManager *manager, DdNode *node, int *permut)
 
DdNodeCudd_bddVarMap (DdManager *manager, DdNode *f)
 
int Cudd_SetVarMap (DdManager *manager, DdNode **x, DdNode **y, int n)
 
DdNodeCudd_bddSwapVariables (DdManager *dd, DdNode *f, DdNode **x, DdNode **y, int n)
 
DdNodeCudd_bddAdjPermuteX (DdManager *dd, DdNode *B, DdNode **x, int n)
 
DdNodeCudd_addVectorCompose (DdManager *dd, DdNode *f, DdNode **vector)
 
DdNodeCudd_addGeneralVectorCompose (DdManager *dd, DdNode *f, DdNode **vectorOn, DdNode **vectorOff)
 
DdNodeCudd_addNonSimCompose (DdManager *dd, DdNode *f, DdNode **vector)
 
DdNodeCudd_bddVectorCompose (DdManager *dd, DdNode *f, DdNode **vector)
 
int Cudd_bddApproxConjDecomp (DdManager *dd, DdNode *f, DdNode ***conjuncts)
 
int Cudd_bddApproxDisjDecomp (DdManager *dd, DdNode *f, DdNode ***disjuncts)
 
int Cudd_bddIterConjDecomp (DdManager *dd, DdNode *f, DdNode ***conjuncts)
 
int Cudd_bddIterDisjDecomp (DdManager *dd, DdNode *f, DdNode ***disjuncts)
 
int Cudd_bddGenConjDecomp (DdManager *dd, DdNode *f, DdNode ***conjuncts)
 
int Cudd_bddGenDisjDecomp (DdManager *dd, DdNode *f, DdNode ***disjuncts)
 
int Cudd_bddVarConjDecomp (DdManager *dd, DdNode *f, DdNode ***conjuncts)
 
int Cudd_bddVarDisjDecomp (DdManager *dd, DdNode *f, DdNode ***disjuncts)
 
DdNodeCudd_FindEssential (DdManager *dd, DdNode *f)
 
int Cudd_bddIsVarEssential (DdManager *manager, DdNode *f, int id, int phase)
 
DdTlcInfoCudd_FindTwoLiteralClauses (DdManager *dd, DdNode *f)
 
int Cudd_PrintTwoLiteralClauses (DdManager *dd, DdNode *f, char **names, FILE *fp)
 
int Cudd_ReadIthClause (DdTlcInfo *tlc, int i, DdHalfWord *var1, DdHalfWord *var2, int *phase1, int *phase2)
 
void Cudd_tlcInfoFree (DdTlcInfo *t)
 
int Cudd_DumpBlif (DdManager *dd, int n, DdNode **f, char **inames, char **onames, char *mname, FILE *fp, int mv)
 
int Cudd_DumpBlifBody (DdManager *dd, int n, DdNode **f, char **inames, char **onames, FILE *fp, int mv)
 
int Cudd_DumpDot (DdManager *dd, int n, DdNode **f, char **inames, char **onames, FILE *fp)
 
int Cudd_DumpDaVinci (DdManager *dd, int n, DdNode **f, char **inames, char **onames, FILE *fp)
 
int Cudd_DumpDDcal (DdManager *dd, int n, DdNode **f, char **inames, char **onames, FILE *fp)
 
int Cudd_DumpFactoredForm (DdManager *dd, int n, DdNode **f, char **inames, char **onames, FILE *fp)
 
DdNodeCudd_bddConstrain (DdManager *dd, DdNode *f, DdNode *c)
 
DdNodeCudd_bddRestrict (DdManager *dd, DdNode *f, DdNode *c)
 
DdNodeCudd_bddNPAnd (DdManager *dd, DdNode *f, DdNode *c)
 
DdNodeCudd_addConstrain (DdManager *dd, DdNode *f, DdNode *c)
 
DdNode ** Cudd_bddConstrainDecomp (DdManager *dd, DdNode *f)
 
DdNodeCudd_addRestrict (DdManager *dd, DdNode *f, DdNode *c)
 
DdNode ** Cudd_bddCharToVect (DdManager *dd, DdNode *f)
 
DdNodeCudd_bddLICompaction (DdManager *dd, DdNode *f, DdNode *c)
 
DdNodeCudd_bddSqueeze (DdManager *dd, DdNode *l, DdNode *u)
 
DdNodeCudd_bddMinimize (DdManager *dd, DdNode *f, DdNode *c)
 
DdNodeCudd_SubsetCompress (DdManager *dd, DdNode *f, int nvars, int threshold)
 
DdNodeCudd_SupersetCompress (DdManager *dd, DdNode *f, int nvars, int threshold)
 
MtrNodeCudd_MakeTreeNode (DdManager *dd, unsigned int low, unsigned int size, unsigned int type)
 
int Cudd_addHarwell (FILE *fp, DdManager *dd, DdNode **E, DdNode ***x, DdNode ***y, DdNode ***xn, DdNode ***yn_, int *nx, int *ny, int *m, int *n, int bx, int sx, int by, int sy, int pr)
 
DdManagerCudd_Init (unsigned int numVars, unsigned int numVarsZ, unsigned int numSlots, unsigned int cacheSize, unsigned long maxMemory)
 
void Cudd_Quit (DdManager *unique)
 
int Cudd_PrintLinear (DdManager *table)
 
int Cudd_ReadLinear (DdManager *table, int x, int y)
 
DdNodeCudd_bddLiteralSetIntersection (DdManager *dd, DdNode *f, DdNode *g)
 
DdNodeCudd_addMatrixMultiply (DdManager *dd, DdNode *A, DdNode *B, DdNode **z, int nz)
 
DdNodeCudd_addTimesPlus (DdManager *dd, DdNode *A, DdNode *B, DdNode **z, int nz)
 
DdNodeCudd_addTriangle (DdManager *dd, DdNode *f, DdNode *g, DdNode **z, int nz)
 
DdNodeCudd_addOuterSum (DdManager *dd, DdNode *M, DdNode *r, DdNode *c)
 
DdNodeCudd_PrioritySelect (DdManager *dd, DdNode *R, DdNode **x, DdNode **y, DdNode **z, DdNode *Pi, int n, DdNode *(*)(DdManager *, int, DdNode **, DdNode **, DdNode **))
 
DdNodeCudd_Xgty (DdManager *dd, int N, DdNode **z, DdNode **x, DdNode **y)
 
DdNodeCudd_Xeqy (DdManager *dd, int N, DdNode **x, DdNode **y)
 
DdNodeCudd_addXeqy (DdManager *dd, int N, DdNode **x, DdNode **y)
 
DdNodeCudd_Dxygtdxz (DdManager *dd, int N, DdNode **x, DdNode **y, DdNode **z)
 
DdNodeCudd_Dxygtdyz (DdManager *dd, int N, DdNode **x, DdNode **y, DdNode **z)
 
DdNodeCudd_Inequality (DdManager *dd, int N, int c, DdNode **x, DdNode **y)
 
DdNodeCudd_Disequality (DdManager *dd, int N, int c, DdNode **x, DdNode **y)
 
DdNodeCudd_bddInterval (DdManager *dd, int N, DdNode **x, unsigned int lowerB, unsigned int upperB)
 
DdNodeCudd_CProjection (DdManager *dd, DdNode *R, DdNode *Y)
 
DdNodeCudd_addHamming (DdManager *dd, DdNode **xVars, DdNode **yVars, int nVars)
 
int Cudd_MinHammingDist (DdManager *dd, DdNode *f, int *minterm, int upperBound)
 
DdNodeCudd_bddClosestCube (DdManager *dd, DdNode *f, DdNode *g, int *distance)
 
int Cudd_addRead (FILE *fp, DdManager *dd, DdNode **E, DdNode ***x, DdNode ***y, DdNode ***xn, DdNode ***yn_, int *nx, int *ny, int *m, int *n, int bx, int sx, int by, int sy)
 
int Cudd_bddRead (FILE *fp, DdManager *dd, DdNode **E, DdNode ***x, DdNode ***y, int *nx, int *ny, int *m, int *n, int bx, int sx, int by, int sy)
 
void Cudd_Ref (DdNode *n)
 
void Cudd_RecursiveDeref (DdManager *table, DdNode *n)
 
void Cudd_IterDerefBdd (DdManager *table, DdNode *n)
 
void Cudd_DelayedDerefBdd (DdManager *table, DdNode *n)
 
void Cudd_RecursiveDerefZdd (DdManager *table, DdNode *n)
 
void Cudd_Deref (DdNode *node)
 
int Cudd_CheckZeroRef (DdManager *manager)
 
int Cudd_ReduceHeap (DdManager *table, Cudd_ReorderingType heuristic, int minsize)
 
int Cudd_ShuffleHeap (DdManager *table, int *permutation)
 
DdNodeCudd_Eval (DdManager *dd, DdNode *f, int *inputs)
 
DdNodeCudd_ShortestPath (DdManager *manager, DdNode *f, int *weight, int *support, int *length)
 
DdNodeCudd_LargestCube (DdManager *manager, DdNode *f, int *length)
 
int Cudd_ShortestLength (DdManager *manager, DdNode *f, int *weight)
 
DdNodeCudd_Decreasing (DdManager *dd, DdNode *f, int i)
 
DdNodeCudd_Increasing (DdManager *dd, DdNode *f, int i)
 
int Cudd_EquivDC (DdManager *dd, DdNode *F, DdNode *G, DdNode *D)
 
int Cudd_bddLeqUnless (DdManager *dd, DdNode *f, DdNode *g, DdNode *D)
 
int Cudd_EqualSupNorm (DdManager *dd, DdNode *f, DdNode *g, CUDD_VALUE_TYPE tolerance, int pr)
 
DdNodeCudd_bddMakePrime (DdManager *dd, DdNode *cube, DdNode *f)
 
double * Cudd_CofMinterm (DdManager *dd, DdNode *node)
 
DdNodeCudd_SolveEqn (DdManager *bdd, DdNode *F, DdNode *Y, DdNode **G, int **yIndex, int n)
 
DdNodeCudd_VerifySol (DdManager *bdd, DdNode *F, DdNode **G, int *yIndex, int n)
 
DdNodeCudd_SplitSet (DdManager *manager, DdNode *S, DdNode **xVars, int n, double m)
 
DdNodeCudd_SubsetHeavyBranch (DdManager *dd, DdNode *f, int numVars, int threshold)
 
DdNodeCudd_SupersetHeavyBranch (DdManager *dd, DdNode *f, int numVars, int threshold)
 
DdNodeCudd_SubsetShortPaths (DdManager *dd, DdNode *f, int numVars, int threshold, int hardlimit)
 
DdNodeCudd_SupersetShortPaths (DdManager *dd, DdNode *f, int numVars, int threshold, int hardlimit)
 
void Cudd_SymmProfile (DdManager *table, int lower, int upper)
 
unsigned int Cudd_Prime (unsigned int p)
 
int Cudd_PrintMinterm (DdManager *manager, DdNode *node)
 
int Cudd_bddPrintCover (DdManager *dd, DdNode *l, DdNode *u)
 
int Cudd_PrintDebug (DdManager *dd, DdNode *f, int n, int pr)
 
int Cudd_DagSize (DdNode *node)
 
int Cudd_EstimateCofactor (DdManager *dd, DdNode *node, int i, int phase)
 
int Cudd_EstimateCofactorSimple (DdNode *node, int i)
 
int Cudd_SharingSize (DdNode **nodeArray, int n)
 
double Cudd_CountMinterm (DdManager *manager, DdNode *node, int nvars)
 
int Cudd_EpdCountMinterm (DdManager *manager, DdNode *node, int nvars, EpDouble *epd)
 
double Cudd_CountPath (DdNode *node)
 
double Cudd_CountPathsToNonZero (DdNode *node)
 
DdNodeCudd_Support (DdManager *dd, DdNode *f)
 
int * Cudd_SupportIndex (DdManager *dd, DdNode *f)
 
int Cudd_SupportSize (DdManager *dd, DdNode *f)
 
DdNodeCudd_VectorSupport (DdManager *dd, DdNode **F, int n)
 
int * Cudd_VectorSupportIndex (DdManager *dd, DdNode **F, int n)
 
int Cudd_VectorSupportSize (DdManager *dd, DdNode **F, int n)
 
int Cudd_ClassifySupport (DdManager *dd, DdNode *f, DdNode *g, DdNode **common, DdNode **onlyF, DdNode **onlyG)
 
int Cudd_CountLeaves (DdNode *node)
 
int Cudd_bddPickOneCube (DdManager *ddm, DdNode *node, char *string)
 
DdNodeCudd_bddPickOneMinterm (DdManager *dd, DdNode *f, DdNode **vars, int n)
 
DdNode ** Cudd_bddPickArbitraryMinterms (DdManager *dd, DdNode *f, DdNode **vars, int n, int k)
 
DdNodeCudd_SubsetWithMaskVars (DdManager *dd, DdNode *f, DdNode **vars, int nvars, DdNode **maskVars, int mvars)
 
DdGenCudd_FirstCube (DdManager *dd, DdNode *f, int **cube, CUDD_VALUE_TYPE *value)
 
int Cudd_NextCube (DdGen *gen, int **cube, CUDD_VALUE_TYPE *value)
 
DdGenCudd_FirstPrime (DdManager *dd, DdNode *l, DdNode *u, int **cube)
 
int Cudd_NextPrime (DdGen *gen, int **cube)
 
DdNodeCudd_bddComputeCube (DdManager *dd, DdNode **vars, int *phase, int n)
 
DdNodeCudd_addComputeCube (DdManager *dd, DdNode **vars, int *phase, int n)
 
DdNodeCudd_CubeArrayToBdd (DdManager *dd, int *array)
 
int Cudd_BddToCubeArray (DdManager *dd, DdNode *cube, int *array)
 
DdGenCudd_FirstNode (DdManager *dd, DdNode *f, DdNode **node)
 
int Cudd_NextNode (DdGen *gen, DdNode **node)
 
int Cudd_GenFree (DdGen *gen)
 
int Cudd_IsGenEmpty (DdGen *gen)
 
DdNodeCudd_IndicesToCube (DdManager *dd, int *array, int n)
 
void Cudd_PrintVersion (FILE *fp)
 
double Cudd_AverageDistance (DdManager *dd)
 
long Cudd_Random (void)
 
void Cudd_Srandom (long seed)
 
double Cudd_Density (DdManager *dd, DdNode *f, int nvars)
 
void Cudd_OutOfMem (long size)
 
int Cudd_zddCount (DdManager *zdd, DdNode *P)
 
double Cudd_zddCountDouble (DdManager *zdd, DdNode *P)
 
DdNodeCudd_zddProduct (DdManager *dd, DdNode *f, DdNode *g)
 
DdNodeCudd_zddUnateProduct (DdManager *dd, DdNode *f, DdNode *g)
 
DdNodeCudd_zddWeakDiv (DdManager *dd, DdNode *f, DdNode *g)
 
DdNodeCudd_zddDivide (DdManager *dd, DdNode *f, DdNode *g)
 
DdNodeCudd_zddWeakDivF (DdManager *dd, DdNode *f, DdNode *g)
 
DdNodeCudd_zddDivideF (DdManager *dd, DdNode *f, DdNode *g)
 
DdNodeCudd_zddComplement (DdManager *dd, DdNode *node)
 
MtrNodeCudd_MakeZddTreeNode (DdManager *dd, unsigned int low, unsigned int size, unsigned int type)
 
DdNodeCudd_zddIsop (DdManager *dd, DdNode *L, DdNode *U, DdNode **zdd_I)
 
DdNodeCudd_bddIsop (DdManager *dd, DdNode *L, DdNode *U)
 
DdNodeCudd_MakeBddFromZddCover (DdManager *dd, DdNode *node)
 
int Cudd_zddDagSize (DdNode *p_node)
 
double Cudd_zddCountMinterm (DdManager *zdd, DdNode *node, int path)
 
void Cudd_zddPrintSubtable (DdManager *table)
 
DdNodeCudd_zddPortFromBdd (DdManager *dd, DdNode *B)
 
DdNodeCudd_zddPortToBdd (DdManager *dd, DdNode *f)
 
int Cudd_zddReduceHeap (DdManager *table, Cudd_ReorderingType heuristic, int minsize)
 
int Cudd_zddShuffleHeap (DdManager *table, int *permutation)
 
DdNodeCudd_zddIte (DdManager *dd, DdNode *f, DdNode *g, DdNode *h)
 
DdNodeCudd_zddUnion (DdManager *dd, DdNode *P, DdNode *Q)
 
DdNodeCudd_zddIntersect (DdManager *dd, DdNode *P, DdNode *Q)
 
DdNodeCudd_zddDiff (DdManager *dd, DdNode *P, DdNode *Q)
 
DdNodeCudd_zddDiffConst (DdManager *zdd, DdNode *P, DdNode *Q)
 
DdNodeCudd_zddSubset1 (DdManager *dd, DdNode *P, int var)
 
DdNodeCudd_zddSubset0 (DdManager *dd, DdNode *P, int var)
 
DdNodeCudd_zddChange (DdManager *dd, DdNode *P, int var)
 
void Cudd_zddSymmProfile (DdManager *table, int lower, int upper)
 
int Cudd_zddPrintMinterm (DdManager *zdd, DdNode *node)
 
int Cudd_zddPrintCover (DdManager *zdd, DdNode *node)
 
int Cudd_zddPrintDebug (DdManager *zdd, DdNode *f, int n, int pr)
 
DdGenCudd_zddFirstPath (DdManager *zdd, DdNode *f, int **path)
 
int Cudd_zddNextPath (DdGen *gen, int **path)
 
char * Cudd_zddCoverPathToString (DdManager *zdd, int *path, char *str)
 
int Cudd_zddDumpDot (DdManager *dd, int n, DdNode **f, char **inames, char **onames, FILE *fp)
 
int Cudd_bddSetPiVar (DdManager *dd, int index)
 
int Cudd_bddSetPsVar (DdManager *dd, int index)
 
int Cudd_bddSetNsVar (DdManager *dd, int index)
 
int Cudd_bddIsPiVar (DdManager *dd, int index)
 
int Cudd_bddIsPsVar (DdManager *dd, int index)
 
int Cudd_bddIsNsVar (DdManager *dd, int index)
 
int Cudd_bddSetPairIndex (DdManager *dd, int index, int pairIndex)
 
int Cudd_bddReadPairIndex (DdManager *dd, int index)
 
int Cudd_bddSetVarToBeGrouped (DdManager *dd, int index)
 
int Cudd_bddSetVarHardGroup (DdManager *dd, int index)
 
int Cudd_bddResetVarToBeGrouped (DdManager *dd, int index)
 
int Cudd_bddIsVarToBeGrouped (DdManager *dd, int index)
 
int Cudd_bddSetVarToBeUngrouped (DdManager *dd, int index)
 
int Cudd_bddIsVarToBeUngrouped (DdManager *dd, int index)
 
int Cudd_bddIsVarHardGroup (DdManager *dd, int index)
 

Macro Definition Documentation

#define CUDD_CACHE_SLOTS   262144 /* default size of the cache */

Definition at line 98 of file cudd.h.

#define Cudd_Complement (   node)    ((DdNode *)((ptruint)(node) | 01))

Macro***********************************************************************

Synopsis [Returns the complemented version of a pointer.]

Description []

SideEffects [none]

SeeAlso [Cudd_Regular Cudd_IsComplement]

Definition at line 411 of file cudd.h.

#define CUDD_CONST_INDEX   CUDD_MAXINDEX

Definition at line 117 of file cudd.h.

#define Cudd_E (   node)    ((Cudd_Regular(node))->type.kids.E)

Macro***********************************************************************

Synopsis [Returns the else child of an internal node.]

Description [Returns the else child of an internal node. If node is a constant node, the result is unpredictable.]

SideEffects [none]

SeeAlso [Cudd_T Cudd_V]

Definition at line 455 of file cudd.h.

#define Cudd_ForeachCube (   manager,
  f,
  gen,
  cube,
  value 
)
Value:
for((gen) = Cudd_FirstCube(manager, f, &cube, &value);\
(void) Cudd_NextCube(gen, &cube, &value))
int Cudd_IsGenEmpty(DdGen *gen)
Definition: cuddUtil.c:2531
int Cudd_NextCube(DdGen *gen, int **cube, CUDD_VALUE_TYPE *value)
Definition: cuddUtil.c:1917
#define TRUE
Definition: cudd.h:88
int Cudd_GenFree(DdGen *gen)
Definition: cuddUtil.c:2491
DdGen * Cudd_FirstCube(DdManager *dd, DdNode *f, int **cube, CUDD_VALUE_TYPE *value)
Definition: cuddUtil.c:1798
int value

Macro***********************************************************************

Synopsis [Iterates over the cubes of a decision diagram.]

Description [Iterates over the cubes of a decision diagram f.

Cudd_ForeachCube allocates and frees the generator. Therefore the application should not try to do that. Also, the cube is freed at the end of Cudd_ForeachCube and hence is not available outside of the loop.

CAUTION: It is assumed that dynamic reordering will not occur while there are open generators. It is the user's responsibility to make sure that dynamic reordering does not occur. As long as new nodes are not created during generation, and dynamic reordering is not called explicitly, dynamic reordering will not occur. Alternatively, it is sufficient to disable dynamic reordering. It is a mistake to dispose of a diagram on which generation is ongoing.]

SideEffects [none]

SeeAlso [Cudd_ForeachNode Cudd_FirstCube Cudd_NextCube Cudd_GenFree Cudd_IsGenEmpty Cudd_AutodynDisable]

Definition at line 519 of file cudd.h.

#define Cudd_ForeachNode (   manager,
  f,
  gen,
  node 
)
Value:
for((gen) = Cudd_FirstNode(manager, f, &node);\
(void) Cudd_NextNode(gen, &node))
DdGen * Cudd_FirstNode(DdManager *dd, DdNode *f, DdNode **node)
Definition: cuddUtil.c:2400
int Cudd_NextNode(DdGen *gen, DdNode **node)
Definition: cuddUtil.c:2459
int Cudd_IsGenEmpty(DdGen *gen)
Definition: cuddUtil.c:2531
#define TRUE
Definition: cudd.h:88
int Cudd_GenFree(DdGen *gen)
Definition: cuddUtil.c:2491

Macro***********************************************************************

Synopsis [Iterates over the nodes of a decision diagram.]

Description [Iterates over the nodes of a decision diagram f.

The nodes are returned in a seemingly random order. Cudd_ForeachNode allocates and frees the generator. Therefore the application should not try to do that.

CAUTION: It is assumed that dynamic reordering will not occur while there are open generators. It is the user's responsibility to make sure that dynamic reordering does not occur. As long as new nodes are not created during generation, and dynamic reordering is not called explicitly, dynamic reordering will not occur. Alternatively, it is sufficient to disable dynamic reordering. It is a mistake to dispose of a diagram on which generation is ongoing.]

SideEffects [none]

SeeAlso [Cudd_ForeachCube Cudd_FirstNode Cudd_NextNode Cudd_GenFree Cudd_IsGenEmpty Cudd_AutodynDisable]

Definition at line 585 of file cudd.h.

#define Cudd_ForeachPrime (   manager,
  l,
  u,
  gen,
  cube 
)
Value:
for((gen) = Cudd_FirstPrime(manager, l, u, &cube);\
(void) Cudd_NextPrime(gen, &cube))
int Cudd_NextPrime(DdGen *gen, int **cube)
Definition: cuddUtil.c:2130
int Cudd_IsGenEmpty(DdGen *gen)
Definition: cuddUtil.c:2531
DdGen * Cudd_FirstPrime(DdManager *dd, DdNode *l, DdNode *u, int **cube)
Definition: cuddUtil.c:2028
#define TRUE
Definition: cudd.h:88
int Cudd_GenFree(DdGen *gen)
Definition: cuddUtil.c:2491

Macro***********************************************************************

Synopsis [Iterates over the primes of a Boolean function.]

Description [Iterates over the primes of a Boolean function producing a prime and irredundant cover.

The Boolean function is described by an upper bound and a lower bound. If the function is completely specified, the two bounds coincide. Cudd_ForeachPrime allocates and frees the generator. Therefore the application should not try to do that. Also, the cube is freed at the end of Cudd_ForeachPrime and hence is not available outside of the loop.

CAUTION: It is a mistake to change a diagram on which generation is ongoing.]

SideEffects [none]

SeeAlso [Cudd_ForeachCube Cudd_FirstPrime Cudd_NextPrime Cudd_GenFree Cudd_IsGenEmpty]

Definition at line 551 of file cudd.h.

#define Cudd_IsComplement (   node)    ((int) ((ptrint) (node) & 01))

Macro***********************************************************************

Synopsis [Returns 1 if a pointer is complemented.]

Description []

SideEffects [none]

SeeAlso [Cudd_Regular Cudd_Complement]

Definition at line 425 of file cudd.h.

#define Cudd_IsConstant (   node)    ((Cudd_Regular(node))->index == CUDD_CONST_INDEX)

Macro***********************************************************************

Synopsis [Returns 1 if the node is a constant node.]

Description [Returns 1 if the node is a constant node (rather than an internal node). All constant nodes have the same index (CUDD_CONST_INDEX). The pointer passed to Cudd_IsConstant may be either regular or complemented.]

SideEffects [none]

SeeAlso []

Definition at line 352 of file cudd.h.

#define CUDD_MAXINDEX   ((DdHalfWord) ~0)

Definition at line 112 of file cudd.h.

#define Cudd_Not (   node)    ((DdNode *)((ptrint)(node) ^ 01))

Macro***********************************************************************

Synopsis [Complements a DD.]

Description [Complements a DD by flipping the complement attribute of the pointer (the least significant bit).]

SideEffects [none]

SeeAlso [Cudd_NotCond]

Definition at line 367 of file cudd.h.

#define Cudd_NotCond (   node,
 
)    ((DdNode *)((ptrint)(node) ^ (c)))

Macro***********************************************************************

Synopsis [Complements a DD if a condition is true.]

Description [Complements a DD if condition c is true; c should be either 0 or 1, because it is used directly (for efficiency). If in doubt on the values c may take, use "(c) ? Cudd_Not(node) : node".]

SideEffects [none]

SeeAlso [Cudd_Not]

Definition at line 383 of file cudd.h.

#define CUDD_OUT_OF_MEM   -1

Definition at line 95 of file cudd.h.

#define Cudd_ReadIndex (   dd,
  index 
)    (Cudd_ReadPerm(dd,index))

Macro***********************************************************************

Synopsis [Returns the current position in the order of variable index.]

Description [Returns the current position in the order of variable index. This macro is obsolete and is kept for compatibility. New applications should use Cudd_ReadPerm instead.]

SideEffects [none]

SeeAlso [Cudd_ReadPerm]

Definition at line 487 of file cudd.h.

#define Cudd_Regular (   node)    ((DdNode *)((ptruint)(node) & ~01))

Macro***********************************************************************

Synopsis [Returns the regular version of a pointer.]

Description []

SideEffects [none]

SeeAlso [Cudd_Complement Cudd_IsComplement]

Definition at line 397 of file cudd.h.

#define CUDD_RESIDUE_DEFAULT   0

Definition at line 101 of file cudd.h.

#define CUDD_RESIDUE_MSB   1

Definition at line 102 of file cudd.h.

#define CUDD_RESIDUE_TC   2

Definition at line 103 of file cudd.h.

#define Cudd_T (   node)    ((Cudd_Regular(node))->type.kids.T)

Macro***********************************************************************

Synopsis [Returns the then child of an internal node.]

Description [Returns the then child of an internal node. If node is a constant node, the result is unpredictable.]

SideEffects [none]

SeeAlso [Cudd_E Cudd_V]

Definition at line 440 of file cudd.h.

#define CUDD_UNIQUE_SLOTS   256 /* initial size of subtables */

Definition at line 97 of file cudd.h.

#define Cudd_V (   node)    ((Cudd_Regular(node))->type.value)

Macro***********************************************************************

Synopsis [Returns the value of a constant node.]

Description [Returns the value of a constant node. If node is an internal node, the result is unpredictable.]

SideEffects [none]

SeeAlso [Cudd_T Cudd_E]

Definition at line 470 of file cudd.h.

#define CUDD_VALUE_TYPE   double

Definition at line 94 of file cudd.h.

#define CUDD_VERSION   "2.4.2"

CHeaderFile*****************************************************************

FileName [cudd.h]

PackageName [cudd]

Synopsis [The University of Colorado decision diagram package.]

Description [External functions and data strucures of the CUDD package.

  • To turn on the gathering of statistics, define DD_STATS.
  • To link with mis, define DD_MIS.

Modified by Abelardo Pardo to interface it to VIS. ]

SeeAlso []

Author [Fabio Somenzi]

Copyright [Copyright (c) 1995-2004, Regents of the University of Colorado

All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.

Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.

Neither the name of the University of Colorado nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.]

Revision [

Id:
cudd.h,v 1.174 2009/02/21 05:55:18 fabio Exp

]

Definition at line 75 of file cudd.h.

#define Cudd_zddForeachPath (   manager,
  f,
  gen,
  path 
)
Value:
for((gen) = Cudd_zddFirstPath(manager, f, &path);\
(void) Cudd_zddNextPath(gen, &path))
int Cudd_IsGenEmpty(DdGen *gen)
Definition: cuddUtil.c:2531
int Cudd_zddNextPath(DdGen *gen, int **path)
Definition: cuddZddUtil.c:387
DdGen * Cudd_zddFirstPath(DdManager *zdd, DdNode *f, int **path)
Definition: cuddZddUtil.c:275
#define TRUE
Definition: cudd.h:88
int Cudd_GenFree(DdGen *gen)
Definition: cuddUtil.c:2491

Macro***********************************************************************

Synopsis [Iterates over the paths of a ZDD.]

Description [Iterates over the paths of a ZDD f.

Cudd_zddForeachPath allocates and frees the generator. Therefore the application should not try to do that. Also, the path is freed at the end of Cudd_zddForeachPath and hence is not available outside of the loop.

CAUTION: It is assumed that dynamic reordering will not occur while there are open generators. It is the user's responsibility to make sure that dynamic reordering does not occur. As long as new nodes are not created during generation, and dynamic reordering is not called explicitly, dynamic reordering will not occur. Alternatively, it is sufficient to disable dynamic reordering. It is a mistake to dispose of a diagram on which generation is ongoing.]

SideEffects [none]

SeeAlso [Cudd_zddFirstPath Cudd_zddNextPath Cudd_GenFree Cudd_IsGenEmpty Cudd_AutodynDisable]

Definition at line 619 of file cudd.h.

#define DD_APA_BASE   (1 << DD_APA_BITS)

Definition at line 130 of file cudd.h.

#define DD_APA_BITS   16

Definition at line 129 of file cudd.h.

#define DD_APA_HEXPRINT   "%04x"

Definition at line 131 of file cudd.h.

#define DD_APA_MASK   (DD_APA_BASE - 1)

Definition at line 133 of file cudd.h.

#define FALSE   0

Definition at line 91 of file cudd.h.

#define SIZEOF_INT   4

Definition at line 81 of file cudd.h.

#define SIZEOF_LONG   4

Definition at line 84 of file cudd.h.

#define SIZEOF_VOID_P   4

Definition at line 78 of file cudd.h.

#define TRUE   1

Definition at line 88 of file cudd.h.

Typedef Documentation

typedef DdNode*(* DD_AOP)(DdManager *, DdNode **, DdNode **)

Definition at line 317 of file cudd.h.

typedef DdNode*(* DD_CTFP)(DdManager *, DdNode *, DdNode *)

Definition at line 321 of file cudd.h.

typedef DdNode*(* DD_CTFP1)(DdManager *, DdNode *)

Definition at line 322 of file cudd.h.

typedef int(* DD_HFP)(DdManager *, const char *, void *)

Definition at line 312 of file cudd.h.

typedef DdNode*(* DD_MAOP)(DdManager *, DdNode *)

Definition at line 319 of file cudd.h.

typedef void(* DD_OOMFP)(long)

Definition at line 324 of file cudd.h.

typedef DdNode*(* DD_PRFP)(DdManager *, int, DdNode **, DdNode **, DdNode **)

Definition at line 314 of file cudd.h.

typedef int(* DD_QSFP)(const void *, const void *)

Definition at line 326 of file cudd.h.

typedef unsigned short int DdApaDigit

Definition at line 303 of file cudd.h.

typedef unsigned int DdApaDoubleDigit

Definition at line 304 of file cudd.h.

Definition at line 306 of file cudd.h.

typedef struct DdChildren DdChildren
typedef struct DdGen DdGen

Definition at line 295 of file cudd.h.

typedef unsigned short DdHalfWord

Definition at line 262 of file cudd.h.

typedef struct DdManager DdManager

Definition at line 293 of file cudd.h.

typedef struct DdNode DdNode

Definition at line 270 of file cudd.h.

typedef struct DdTlcInfo DdTlcInfo

Definition at line 309 of file cudd.h.

Enumeration Type Documentation

Enum************************************************************************

Synopsis [Type of aggregation methods.]

Description [Type of aggregation methods.]

Enumerator
CUDD_NO_CHECK 
CUDD_GROUP_CHECK 
CUDD_GROUP_CHECK2 
CUDD_GROUP_CHECK3 
CUDD_GROUP_CHECK4 
CUDD_GROUP_CHECK5 
CUDD_GROUP_CHECK6 
CUDD_GROUP_CHECK7 
CUDD_GROUP_CHECK8 
CUDD_GROUP_CHECK9 

Definition at line 184 of file cudd.h.

Enum************************************************************************

Synopsis [Type of error codes.]

Description [Type of error codes.]

Enumerator
CUDD_NO_ERROR 
CUDD_MEMORY_OUT 
CUDD_TOO_MANY_NODES 
CUDD_MAX_MEM_EXCEEDED 
CUDD_INVALID_ARG 
CUDD_INTERNAL_ERROR 

Definition at line 220 of file cudd.h.

Enum************************************************************************

Synopsis [Type of hooks.]

Description [Type of hooks.]

Enumerator
CUDD_PRE_GC_HOOK 
CUDD_POST_GC_HOOK 
CUDD_PRE_REORDERING_HOOK 
CUDD_POST_REORDERING_HOOK 

Definition at line 205 of file cudd.h.

Enum************************************************************************

Synopsis [Group type for lazy sifting.]

Description [Group type for lazy sifting.]

Enumerator
CUDD_LAZY_NONE 
CUDD_LAZY_SOFT_GROUP 
CUDD_LAZY_HARD_GROUP 
CUDD_LAZY_UNGROUP 

Definition at line 237 of file cudd.h.

Enum************************************************************************

Synopsis [Type of reordering algorithm.]

Description [Type of reordering algorithm.]

Enumerator
CUDD_REORDER_SAME 
CUDD_REORDER_NONE 
CUDD_REORDER_RANDOM 
CUDD_REORDER_RANDOM_PIVOT 
CUDD_REORDER_SIFT 
CUDD_REORDER_SIFT_CONVERGE 
CUDD_REORDER_SYMM_SIFT 
CUDD_REORDER_SYMM_SIFT_CONV 
CUDD_REORDER_WINDOW2 
CUDD_REORDER_WINDOW3 
CUDD_REORDER_WINDOW4 
CUDD_REORDER_WINDOW2_CONV 
CUDD_REORDER_WINDOW3_CONV 
CUDD_REORDER_WINDOW4_CONV 
CUDD_REORDER_GROUP_SIFT 
CUDD_REORDER_GROUP_SIFT_CONV 
CUDD_REORDER_ANNEALING 
CUDD_REORDER_GENETIC 
CUDD_REORDER_LINEAR 
CUDD_REORDER_LINEAR_CONVERGE 
CUDD_REORDER_LAZY_SIFT 
CUDD_REORDER_EXACT 

Definition at line 151 of file cudd.h.

151  {
Cudd_ReorderingType
Definition: cudd.h:151

Enum************************************************************************

Synopsis [Variable type.]

Description [Variable type. Currently used only in lazy sifting.]

Enumerator
CUDD_VAR_PRIMARY_INPUT 
CUDD_VAR_PRESENT_STATE 
CUDD_VAR_NEXT_STATE 

Definition at line 252 of file cudd.h.

Function Documentation

DdNode* Cudd_addAgreement ( DdManager dd,
DdNode **  f,
DdNode **  g 
)

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

Synopsis [f if f==g; background if f!=g.]

Description [Returns NULL if not a terminal case; f op g otherwise, where f op g is f if f==g; background if f!=g.]

SideEffects [None]

SeeAlso [Cudd_addApply]

Definition at line 551 of file cuddAddApply.c.

555 {
556  DdNode *F, *G;
557 
558  F = *f; G = *g;
559  if (F == G) return(F);
560  if (F == dd->background) return(F);
561  if (G == dd->background) return(G);
562  if (cuddIsConstant(F) && cuddIsConstant(G)) return(dd->background);
563  return(NULL);
564 
565 } /* end of Cudd_addAgreement */
Definition: cudd.h:278
#define cuddIsConstant(node)
Definition: cuddInt.h:620
DdNode * background
Definition: cuddInt.h:349
DdNode* Cudd_addApply ( DdManager dd,
DdNode *)(DdManager *, DdNode **, DdNode **,
DdNode f,
DdNode g 
)
DdNode* Cudd_addBddInterval ( DdManager dd,
DdNode f,
CUDD_VALUE_TYPE  lower,
CUDD_VALUE_TYPE  upper 
)

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

Synopsis [Converts an ADD to a BDD.]

Description [Converts an ADD to a BDD by replacing all discriminants greater than or equal to lower and less than or equal to upper with 1, and all other discriminants with 0. Returns a pointer to the resulting BDD if successful; NULL otherwise.]

SideEffects [None]

SeeAlso [Cudd_addBddThreshold Cudd_addBddStrictThreshold Cudd_addBddPattern Cudd_BddToAdd]

Definition at line 244 of file cuddBridge.c.

249 {
250  DdNode *res;
251  DdNode *l;
252  DdNode *u;
253 
254  /* Create constant nodes for the interval bounds, so that we can use
255  ** the global cache.
256  */
257  l = cuddUniqueConst(dd,lower);
258  if (l == NULL) return(NULL);
259  cuddRef(l);
260  u = cuddUniqueConst(dd,upper);
261  if (u == NULL) {
262  Cudd_RecursiveDeref(dd,l);
263  return(NULL);
264  }
265  cuddRef(u);
266 
267  do {
268  dd->reordered = 0;
269  res = addBddDoInterval(dd, f, l, u);
270  } while (dd->reordered == 1);
271 
272  if (res == NULL) {
273  Cudd_RecursiveDeref(dd, l);
274  Cudd_RecursiveDeref(dd, u);
275  return(NULL);
276  }
277  cuddRef(res);
278  Cudd_RecursiveDeref(dd, l);
279  Cudd_RecursiveDeref(dd, u);
280  cuddDeref(res);
281  return(res);
282 
283 } /* end of Cudd_addBddInterval */
#define cuddRef(n)
Definition: cuddInt.h:584
#define cuddDeref(n)
Definition: cuddInt.h:604
void Cudd_RecursiveDeref(DdManager *table, DdNode *n)
Definition: cuddRef.c:154
Definition: cudd.h:278
DdNode * cuddUniqueConst(DdManager *unique, CUDD_VALUE_TYPE value)
Definition: cuddTable.c:1450
int reordered
Definition: cuddInt.h:409
static DdNode * addBddDoInterval(DdManager *dd, DdNode *f, DdNode *l, DdNode *u)
Definition: cuddBridge.c:716
DdNode* Cudd_addBddIthBit ( DdManager dd,
DdNode f,
int  bit 
)

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

Synopsis [Converts an ADD to a BDD by extracting the i-th bit from the leaves.]

Description [Converts an ADD to a BDD by replacing all discriminants whose i-th bit is equal to 1 with 1, and all other discriminants with 0. The i-th bit refers to the integer representation of the leaf value. If the value is has a fractional part, it is ignored. Repeated calls to this procedure allow one to transform an integer-valued ADD into an array of BDDs, one for each bit of the leaf values. Returns a pointer to the resulting BDD if successful; NULL otherwise.]

SideEffects [None]

SeeAlso [Cudd_addBddInterval Cudd_addBddPattern Cudd_BddToAdd]

Definition at line 306 of file cuddBridge.c.

310 {
311  DdNode *res;
312  DdNode *index;
313 
314  index = cuddUniqueConst(dd,(CUDD_VALUE_TYPE) bit);
315  if (index == NULL) return(NULL);
316  cuddRef(index);
317 
318  do {
319  dd->reordered = 0;
320  res = addBddDoIthBit(dd, f, index);
321  } while (dd->reordered == 1);
322 
323  if (res == NULL) {
324  Cudd_RecursiveDeref(dd, index);
325  return(NULL);
326  }
327  cuddRef(res);
328  Cudd_RecursiveDeref(dd, index);
329  cuddDeref(res);
330  return(res);
331 
332 } /* end of Cudd_addBddIthBit */
#define cuddRef(n)
Definition: cuddInt.h:584
#define cuddDeref(n)
Definition: cuddInt.h:604
void Cudd_RecursiveDeref(DdManager *table, DdNode *n)
Definition: cuddRef.c:154
Definition: cudd.h:278
DdNode * cuddUniqueConst(DdManager *unique, CUDD_VALUE_TYPE value)
Definition: cuddTable.c:1450
int reordered
Definition: cuddInt.h:409
#define CUDD_VALUE_TYPE
Definition: cudd.h:94
static DdNode * addBddDoIthBit(DdManager *dd, DdNode *f, DdNode *index)
Definition: cuddBridge.c:790
DdNode* Cudd_addBddPattern ( DdManager dd,
DdNode f 
)

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

Synopsis [Converts an ADD to a BDD.]

Description [Converts an ADD to a BDD by replacing all discriminants different from 0 with 1. Returns a pointer to the resulting BDD if successful; NULL otherwise.]

SideEffects [None]

SeeAlso [Cudd_BddToAdd Cudd_addBddThreshold Cudd_addBddInterval Cudd_addBddStrictThreshold]

Definition at line 379 of file cuddBridge.c.

382 {
383  DdNode *res;
384 
385  do {
386  dd->reordered = 0;
387  res = cuddAddBddDoPattern(dd, f);
388  } while (dd->reordered == 1);
389  return(res);
390 
391 } /* end of Cudd_addBddPattern */
Definition: cudd.h:278
int reordered
Definition: cuddInt.h:409
DdNode * cuddAddBddDoPattern(DdManager *dd, DdNode *f)
Definition: cuddBridge.c:493
DdNode* Cudd_addBddStrictThreshold ( DdManager dd,
DdNode f,
CUDD_VALUE_TYPE  value 
)

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

Synopsis [Converts an ADD to a BDD.]

Description [Converts an ADD to a BDD by replacing all discriminants STRICTLY greater than value with 1, and all other discriminants with 0. Returns a pointer to the resulting BDD if successful; NULL otherwise.]

SideEffects [None]

SeeAlso [Cudd_addBddInterval Cudd_addBddPattern Cudd_BddToAdd Cudd_addBddThreshold]

Definition at line 199 of file cuddBridge.c.

203 {
204  DdNode *res;
205  DdNode *val;
206 
207  val = cuddUniqueConst(dd,value);
208  if (val == NULL) return(NULL);
209  cuddRef(val);
210 
211  do {
212  dd->reordered = 0;
213  res = addBddDoStrictThreshold(dd, f, val);
214  } while (dd->reordered == 1);
215 
216  if (res == NULL) {
217  Cudd_RecursiveDeref(dd, val);
218  return(NULL);
219  }
220  cuddRef(res);
221  Cudd_RecursiveDeref(dd, val);
222  cuddDeref(res);
223  return(res);
224 
225 } /* end of Cudd_addBddStrictThreshold */
#define cuddRef(n)
Definition: cuddInt.h:584
#define cuddDeref(n)
Definition: cuddInt.h:604
void Cudd_RecursiveDeref(DdManager *table, DdNode *n)
Definition: cuddRef.c:154
Definition: cudd.h:278
DdNode * cuddUniqueConst(DdManager *unique, CUDD_VALUE_TYPE value)
Definition: cuddTable.c:1450
int reordered
Definition: cuddInt.h:409
static DdNode * addBddDoStrictThreshold(DdManager *dd, DdNode *f, DdNode *val)
Definition: cuddBridge.c:643
int value
DdNode* Cudd_addBddThreshold ( DdManager dd,
DdNode f,
CUDD_VALUE_TYPE  value 
)

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

Synopsis [Converts an ADD to a BDD.]

Description [Converts an ADD to a BDD by replacing all discriminants greater than or equal to value with 1, and all other discriminants with 0. Returns a pointer to the resulting BDD if successful; NULL otherwise.]

SideEffects [None]

SeeAlso [Cudd_addBddInterval Cudd_addBddPattern Cudd_BddToAdd Cudd_addBddStrictThreshold]

Definition at line 154 of file cuddBridge.c.

158 {
159  DdNode *res;
160  DdNode *val;
161 
162  val = cuddUniqueConst(dd,value);
163  if (val == NULL) return(NULL);
164  cuddRef(val);
165 
166  do {
167  dd->reordered = 0;
168  res = addBddDoThreshold(dd, f, val);
169  } while (dd->reordered == 1);
170 
171  if (res == NULL) {
172  Cudd_RecursiveDeref(dd, val);
173  return(NULL);
174  }
175  cuddRef(res);
176  Cudd_RecursiveDeref(dd, val);
177  cuddDeref(res);
178  return(res);
179 
180 } /* end of Cudd_addBddThreshold */
#define cuddRef(n)
Definition: cuddInt.h:584
#define cuddDeref(n)
Definition: cuddInt.h:604
void Cudd_RecursiveDeref(DdManager *table, DdNode *n)
Definition: cuddRef.c:154
Definition: cudd.h:278
DdNode * cuddUniqueConst(DdManager *unique, CUDD_VALUE_TYPE value)
Definition: cuddTable.c:1450
static DdNode * addBddDoThreshold(DdManager *dd, DdNode *f, DdNode *val)
Definition: cuddBridge.c:570
int reordered
Definition: cuddInt.h:409
int value
DdNode* Cudd_addCmpl ( DdManager dd,
DdNode f 
)

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

Synopsis [Computes the complement of an ADD a la C language.]

Description [Computes the complement of an ADD a la C language: The complement of 0 is 1 and the complement of everything else is 0. Returns a pointer to the resulting ADD if successful; NULL otherwise.]

SideEffects [None]

SeeAlso [Cudd_addNegate]

Definition at line 347 of file cuddAddIte.c.

350 {
351  DdNode *res;
352 
353  do {
354  dd->reordered = 0;
355  res = cuddAddCmplRecur(dd,f);
356  } while (dd->reordered == 1);
357  return(res);
358 
359 } /* end of Cudd_addCmpl */
Definition: cudd.h:278
int reordered
Definition: cuddInt.h:409
DdNode * cuddAddCmplRecur(DdManager *dd, DdNode *f)
Definition: cuddAddIte.c:562
DdNode* Cudd_addCompose ( DdManager dd,
DdNode f,
DdNode g,
int  v 
)

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

Synopsis [Substitutes g for x_v in the ADD for f.]

Description [Substitutes g for x_v in the ADD for f. v is the index of the variable to be substituted. g must be a 0-1 ADD. Cudd_bddCompose passes the corresponding projection function to the recursive procedure, so that the cache may be used. Returns the composed ADD if successful; NULL otherwise.]

SideEffects [None]

SeeAlso [Cudd_bddCompose]

Definition at line 204 of file cuddCompose.c.

209 {
210  DdNode *proj, *res;
211 
212  /* Sanity check. */
213  if (v < 0 || v >= dd->size) return(NULL);
214 
215  proj = dd->vars[v];
216  do {
217  dd->reordered = 0;
218  res = cuddAddComposeRecur(dd,f,g,proj);
219  } while (dd->reordered == 1);
220  return(res);
221 
222 } /* end of Cudd_addCompose */
Definition: cudd.h:278
int size
Definition: cuddInt.h:361
int reordered
Definition: cuddInt.h:409
DdNode * cuddAddComposeRecur(DdManager *dd, DdNode *f, DdNode *g, DdNode *proj)
Definition: cuddCompose.c:952
DdNode ** vars
Definition: cuddInt.h:390
DdNode* Cudd_addComputeCube ( DdManager dd,
DdNode **  vars,
int *  phase,
int  n 
)

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

Synopsis [Computes the cube of an array of ADD variables.]

Description [Computes the cube of an array of ADD variables. If non-null, the phase argument indicates which literal of each variable should appear in the cube. If phase[i] is nonzero, then the positive literal is used. If phase is NULL, the cube is positive unate. Returns a pointer to the result if successful; NULL otherwise.]

SideEffects [none]

SeeAlso [Cudd_bddComputeCube]

Definition at line 2246 of file cuddUtil.c.

2251 {
2252  DdNode *cube, *zero;
2253  DdNode *fn;
2254  int i;
2255 
2256  cube = DD_ONE(dd);
2257  cuddRef(cube);
2258  zero = DD_ZERO(dd);
2259 
2260  for (i = n - 1; i >= 0; i--) {
2261  if (phase == NULL || phase[i] != 0) {
2262  fn = Cudd_addIte(dd,vars[i],cube,zero);
2263  } else {
2264  fn = Cudd_addIte(dd,vars[i],zero,cube);
2265  }
2266  if (fn == NULL) {
2267  Cudd_RecursiveDeref(dd,cube);
2268  return(NULL);
2269  }
2270  cuddRef(fn);
2271  Cudd_RecursiveDeref(dd,cube);
2272  cube = fn;
2273  }
2274  cuddDeref(cube);
2275 
2276  return(cube);
2277 
2278 } /* end of Cudd_addComputeCube */
#define cuddRef(n)
Definition: cuddInt.h:584
#define cuddDeref(n)
Definition: cuddInt.h:604
void Cudd_RecursiveDeref(DdManager *table, DdNode *n)
Definition: cuddRef.c:154
Definition: cudd.h:278
static DdNode * zero
Definition: cuddUtil.c:148
static pcube phase
Definition: cvrm.c:405
DdNode * Cudd_addIte(DdManager *dd, DdNode *f, DdNode *g, DdNode *h)
Definition: cuddAddIte.c:129
#define DD_ONE(dd)
Definition: cuddInt.h:911
#define DD_ZERO(dd)
Definition: cuddInt.h:927
DdNode* Cudd_addConst ( DdManager dd,
CUDD_VALUE_TYPE  c 
)

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

Synopsis [Returns the ADD for constant c.]

Description [Retrieves the ADD for constant c if it already exists, or creates a new ADD. Returns a pointer to the ADD if successful; NULL otherwise.]

SideEffects [None]

SeeAlso [Cudd_addNewVar Cudd_addIthVar]

Definition at line 620 of file cuddAPI.c.

623 {
624  return(cuddUniqueConst(dd,c));
625 
626 } /* end of Cudd_addConst */
DdNode * cuddUniqueConst(DdManager *unique, CUDD_VALUE_TYPE value)
Definition: cuddTable.c:1450
DdNode* Cudd_addConstrain ( DdManager dd,
DdNode f,
DdNode c 
)

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

Synopsis [Computes f constrain c for ADDs.]

Description [Computes f constrain c (f @ c), for f an ADD and c a 0-1 ADD. List of special cases:

  • F @ 0 = 0
  • F @ 1 = F
  • 0 @ c = 0
  • 1 @ c = 1
  • F @ F = 1

Returns a pointer to the result if successful; NULL otherwise.]

SideEffects [None]

SeeAlso [Cudd_bddConstrain]

Definition at line 336 of file cuddGenCof.c.

340 {
341  DdNode *res;
342 
343  do {
344  dd->reordered = 0;
345  res = cuddAddConstrainRecur(dd,f,c);
346  } while (dd->reordered == 1);
347  return(res);
348 
349 } /* end of Cudd_addConstrain */
Definition: cudd.h:278
int reordered
Definition: cuddInt.h:409
DdNode * cuddAddConstrainRecur(DdManager *dd, DdNode *f, DdNode *c)
Definition: cuddGenCof.c:1203
DdNode* Cudd_addDiff ( DdManager dd,
DdNode **  f,
DdNode **  g 
)

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

Synopsis [Returns plusinfinity if f=g; returns min(f,g) if f!=g.]

Description [Returns NULL if not a terminal case; f op g otherwise, where f op g is plusinfinity if f=g; min(f,g) if f!=g.]

SideEffects [None]

SeeAlso [Cudd_addApply]

Definition at line 511 of file cuddAddApply.c.

515 {
516  DdNode *F, *G;
517 
518  F = *f; G = *g;
519  if (F == G) return(DD_PLUS_INFINITY(dd));
520  if (F == DD_PLUS_INFINITY(dd)) return(G);
521  if (G == DD_PLUS_INFINITY(dd)) return(F);
522  if (cuddIsConstant(F) && cuddIsConstant(G)) {
523  if (cuddV(F) != cuddV(G)) {
524  if (cuddV(F) < cuddV(G)) {
525  return(F);
526  } else {
527  return(G);
528  }
529  } else {
530  return(DD_PLUS_INFINITY(dd));
531  }
532  }
533  return(NULL);
534 
535 } /* end of Cudd_addDiff */
Definition: cudd.h:278
#define cuddV(node)
Definition: cuddInt.h:668
#define cuddIsConstant(node)
Definition: cuddInt.h:620
#define DD_PLUS_INFINITY(dd)
Definition: cuddInt.h:941
DdNode* Cudd_addDivide ( DdManager dd,
DdNode **  f,
DdNode **  g 
)

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

Synopsis [Integer and floating point division.]

Description [Integer and floating point division. Returns NULL if not a terminal case; f / g otherwise.]

SideEffects [None]

SeeAlso [Cudd_addApply]

Definition at line 312 of file cuddAddApply.c.

316 {
317  DdNode *res;
318  DdNode *F, *G;
320 
321  F = *f; G = *g;
322  /* We would like to use F == G -> F/G == 1, but F and G may
323  ** contain zeroes. */
324  if (F == DD_ZERO(dd)) return(DD_ZERO(dd));
325  if (G == DD_ONE(dd)) return(F);
326  if (cuddIsConstant(F) && cuddIsConstant(G)) {
327  value = cuddV(F)/cuddV(G);
328  res = cuddUniqueConst(dd,value);
329  return(res);
330  }
331  return(NULL);
332 
333 } /* end of Cudd_addDivide */
Definition: cudd.h:278
DdNode * cuddUniqueConst(DdManager *unique, CUDD_VALUE_TYPE value)
Definition: cuddTable.c:1450
#define cuddV(node)
Definition: cuddInt.h:668
#define cuddIsConstant(node)
Definition: cuddInt.h:620
#define CUDD_VALUE_TYPE
Definition: cudd.h:94
int value
#define DD_ONE(dd)
Definition: cuddInt.h:911
#define DD_ZERO(dd)
Definition: cuddInt.h:927
DdNode* Cudd_addEvalConst ( DdManager dd,
DdNode f,
DdNode g 
)

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

Synopsis [Checks whether ADD g is constant whenever ADD f is 1.]

Description [Checks whether ADD g is constant whenever ADD f is 1. f must be a 0-1 ADD. Returns a pointer to the resulting ADD (which may or may not be constant) or DD_NON_CONSTANT. If f is identically 0, the check is assumed to be successful, and the background value is returned. No new nodes are created.]

SideEffects [None]

SeeAlso [Cudd_addIteConstant Cudd_addLeq]

Definition at line 260 of file cuddAddIte.c.

264 {
265  DdNode *zero;
266  DdNode *Fv,*Fnv,*Gv,*Gnv,*r,*t,*e;
267  unsigned int topf,topg;
268 
269 #ifdef DD_DEBUG
271 #endif
272 
273  statLine(dd);
274  /* Terminal cases. */
275  if (f == DD_ONE(dd) || cuddIsConstant(g)) {
276  return(g);
277  }
278  if (f == (zero = DD_ZERO(dd))) {
279  return(dd->background);
280  }
281 
282 #ifdef DD_DEBUG
283  assert(!cuddIsConstant(f));
284 #endif
285  /* From now on, f and g are known not to be constants. */
286 
287  topf = cuddI(dd,f->index);
288  topg = cuddI(dd,g->index);
289 
290  /* Check cache. */
292  if (r != NULL) {
293  return(r);
294  }
295 
296  /* Compute cofactors. */
297  if (topf <= topg) {
298  Fv = cuddT(f); Fnv = cuddE(f);
299  } else {
300  Fv = Fnv = f;
301  }
302  if (topg <= topf) {
303  Gv = cuddT(g); Gnv = cuddE(g);
304  } else {
305  Gv = Gnv = g;
306  }
307 
308  /* Recursive step. */
309  if (Fv != zero) {
310  t = Cudd_addEvalConst(dd,Fv,Gv);
311  if (t == DD_NON_CONSTANT || !cuddIsConstant(t)) {
313  return(DD_NON_CONSTANT);
314  }
315  if (Fnv != zero) {
316  e = Cudd_addEvalConst(dd,Fnv,Gnv);
317  if (e == DD_NON_CONSTANT || !cuddIsConstant(e) || t != e) {
319  return(DD_NON_CONSTANT);
320  }
321  }
323  return(t);
324  } else { /* Fnv must be != zero */
325  e = Cudd_addEvalConst(dd,Fnv,Gnv);
326  cuddCacheInsert2(dd, Cudd_addEvalConst, f, g, e);
327  return(e);
328  }
329 
330 } /* end of Cudd_addEvalConst */
Definition: cudd.h:278
void cuddCacheInsert2(DdManager *table, DD_CTFP op, DdNode *f, DdNode *g, DdNode *data)
Definition: cuddCache.c:277
DdNode * Cudd_addEvalConst(DdManager *dd, DdNode *f, DdNode *g)
Definition: cuddAddIte.c:260
#define statLine(dd)
Definition: cuddInt.h:1037
#define Cudd_IsComplement(node)
Definition: cudd.h:425
#define cuddIsConstant(node)
Definition: cuddInt.h:620
#define DD_ADD_EVAL_CONST_TAG
Definition: cuddInt.h:185
DdNode * cuddConstantLookup(DdManager *table, ptruint op, DdNode *f, DdNode *g, DdNode *h)
Definition: cuddCache.c:721
#define cuddT(node)
Definition: cuddInt.h:636
#define cuddI(dd, index)
Definition: cuddInt.h:686
DdHalfWord index
Definition: cudd.h:279
#define cuddE(node)
Definition: cuddInt.h:652
#define assert(ex)
Definition: util_old.h:213
#define DD_ONE(dd)
Definition: cuddInt.h:911
static DdNode * zero
Definition: cuddApa.c:100
DdNode * background
Definition: cuddInt.h:349
#define DD_NON_CONSTANT
Definition: cuddInt.h:123
#define DD_ZERO(dd)
Definition: cuddInt.h:927
DdNode* Cudd_addExistAbstract ( DdManager manager,
DdNode f,
DdNode cube 
)

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

Synopsis [Existentially Abstracts all the variables in cube from f.]

Description [Abstracts all the variables in cube from f by summing over all possible values taken by the variables. Returns the abstracted ADD.]

SideEffects [None]

SeeAlso [Cudd_addUnivAbstract Cudd_bddExistAbstract Cudd_addOrAbstract]

Definition at line 129 of file cuddAddAbs.c.

133 {
134  DdNode *res;
135 
136  two = cuddUniqueConst(manager,(CUDD_VALUE_TYPE) 2);
137  if (two == NULL) return(NULL);
138  cuddRef(two);
139 
140  if (addCheckPositiveCube(manager, cube) == 0) {
141  (void) fprintf(manager->err,"Error: Can only abstract cubes");
142  return(NULL);
143  }
144 
145  do {
146  manager->reordered = 0;
147  res = cuddAddExistAbstractRecur(manager, f, cube);
148  } while (manager->reordered == 1);
149 
150  if (res == NULL) {
151  Cudd_RecursiveDeref(manager,two);
152  return(NULL);
153  }
154  cuddRef(res);
155  Cudd_RecursiveDeref(manager,two);
156  cuddDeref(res);
157 
158  return(res);
159 
160 } /* end of Cudd_addExistAbstract */
#define cuddRef(n)
Definition: cuddInt.h:584
static DdNode * two
Definition: cuddAddAbs.c:92
#define cuddDeref(n)
Definition: cuddInt.h:604
void Cudd_RecursiveDeref(DdManager *table, DdNode *n)
Definition: cuddRef.c:154
Definition: cudd.h:278
DdNode * cuddUniqueConst(DdManager *unique, CUDD_VALUE_TYPE value)
Definition: cuddTable.c:1450
FILE * err
Definition: cuddInt.h:442
DdNode * cuddAddExistAbstractRecur(DdManager *manager, DdNode *f, DdNode *cube)
Definition: cuddAddAbs.c:256
int reordered
Definition: cuddInt.h:409
#define CUDD_VALUE_TYPE
Definition: cudd.h:94
static int addCheckPositiveCube(DdManager *manager, DdNode *cube)
Definition: cuddAddAbs.c:570
DdNode* Cudd_addFindMax ( DdManager dd,
DdNode f 
)

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

Synopsis [Finds the maximum discriminant of f.]

Description [Returns a pointer to a constant ADD.]

SideEffects [None]

Definition at line 124 of file cuddAddFind.c.

127 {
128  DdNode *t, *e, *res;
129 
130  statLine(dd);
131  if (cuddIsConstant(f)) {
132  return(f);
133  }
134 
135  res = cuddCacheLookup1(dd,Cudd_addFindMax,f);
136  if (res != NULL) {
137  return(res);
138  }
139 
140  t = Cudd_addFindMax(dd,cuddT(f));
141  if (t == DD_PLUS_INFINITY(dd)) return(t);
142 
143  e = Cudd_addFindMax(dd,cuddE(f));
144 
145  res = (cuddV(t) >= cuddV(e)) ? t : e;
146 
148 
149  return(res);
150 
151 } /* end of Cudd_addFindMax */
Definition: cudd.h:278
#define statLine(dd)
Definition: cuddInt.h:1037
DdNode * Cudd_addFindMax(DdManager *dd, DdNode *f)
Definition: cuddAddFind.c:124
#define cuddV(node)
Definition: cuddInt.h:668
DdNode * cuddCacheLookup1(DdManager *table, DD_CTFP1 op, DdNode *f)
Definition: cuddCache.c:556
#define cuddIsConstant(node)
Definition: cuddInt.h:620
#define cuddT(node)
Definition: cuddInt.h:636
#define cuddE(node)
Definition: cuddInt.h:652
#define DD_PLUS_INFINITY(dd)
Definition: cuddInt.h:941
void cuddCacheInsert1(DdManager *table, DD_CTFP1 op, DdNode *f, DdNode *data)
Definition: cuddCache.c:323
DdNode* Cudd_addFindMin ( DdManager dd,
DdNode f 
)

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

Synopsis [Finds the minimum discriminant of f.]

Description [Returns a pointer to a constant ADD.]

SideEffects [None]

Definition at line 164 of file cuddAddFind.c.

167 {
168  DdNode *t, *e, *res;
169 
170  statLine(dd);
171  if (cuddIsConstant(f)) {
172  return(f);
173  }
174 
175  res = cuddCacheLookup1(dd,Cudd_addFindMin,f);
176  if (res != NULL) {
177  return(res);
178  }
179 
180  t = Cudd_addFindMin(dd,cuddT(f));
181  if (t == DD_MINUS_INFINITY(dd)) return(t);
182 
183  e = Cudd_addFindMin(dd,cuddE(f));
184 
185  res = (cuddV(t) <= cuddV(e)) ? t : e;
186 
188 
189  return(res);
190 
191 } /* end of Cudd_addFindMin */
Definition: cudd.h:278
DdNode * Cudd_addFindMin(DdManager *dd, DdNode *f)
Definition: cuddAddFind.c:164
#define statLine(dd)
Definition: cuddInt.h:1037
#define DD_MINUS_INFINITY(dd)
Definition: cuddInt.h:955
#define cuddV(node)
Definition: cuddInt.h:668
DdNode * cuddCacheLookup1(DdManager *table, DD_CTFP1 op, DdNode *f)
Definition: cuddCache.c:556
#define cuddIsConstant(node)
Definition: cuddInt.h:620
#define cuddT(node)
Definition: cuddInt.h:636
#define cuddE(node)
Definition: cuddInt.h:652
void cuddCacheInsert1(DdManager *table, DD_CTFP1 op, DdNode *f, DdNode *data)
Definition: cuddCache.c:323
DdNode* Cudd_addGeneralVectorCompose ( DdManager dd,
DdNode f,
DdNode **  vectorOn,
DdNode **  vectorOff 
)

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

Synopsis [Composes an ADD with a vector of ADDs.]

Description [Given a vector of ADDs, creates a new ADD by substituting the ADDs for the variables of the ADD f. vectorOn contains ADDs to be substituted for the x_v and vectorOff the ADDs to be substituted for x_v'. There should be an entry in vector for each variable in the manager. If no substitution is sought for a given variable, the corresponding projection function should be specified in the vector. This function implements simultaneous composition. Returns a pointer to the resulting ADD if successful; NULL otherwise.]

SideEffects [None]

SeeAlso [Cudd_addVectorCompose Cudd_addNonSimCompose Cudd_addPermute Cudd_addCompose Cudd_bddVectorCompose]

Definition at line 621 of file cuddCompose.c.

626 {
627  DdHashTable *table;
628  DdNode *res;
629  int deepest;
630  int i;
631 
632  do {
633  dd->reordered = 0;
634  /* Initialize local cache. */
635  table = cuddHashTableInit(dd,1,2);
636  if (table == NULL) return(NULL);
637 
638  /* Find deepest real substitution. */
639  for (deepest = dd->size - 1; deepest >= 0; deepest--) {
640  i = dd->invperm[deepest];
641  if (!ddIsIthAddVarPair(dd,vectorOn[i],vectorOff[i],i)) {
642  break;
643  }
644  }
645 
646  /* Recursively solve the problem. */
647  res = cuddAddGeneralVectorComposeRecur(dd,table,f,vectorOn,
648  vectorOff,deepest);
649  if (res != NULL) cuddRef(res);
650 
651  /* Dispose of local cache. */
652  cuddHashTableQuit(table);
653  } while (dd->reordered == 1);
654 
655  if (res != NULL) cuddDeref(res);
656  return(res);
657 
658 } /* end of Cudd_addGeneralVectorCompose */
#define cuddRef(n)
Definition: cuddInt.h:584
static DD_INLINE int ddIsIthAddVarPair(DdManager *dd, DdNode *f, DdNode *g, unsigned int i)
Definition: cuddCompose.c:1746
#define cuddDeref(n)
Definition: cuddInt.h:604
Definition: cudd.h:278
int size
Definition: cuddInt.h:361
int reordered
Definition: cuddInt.h:409
void cuddHashTableQuit(DdHashTable *hash)
Definition: cuddLCache.c:595
DdHashTable * cuddHashTableInit(DdManager *manager, unsigned int keySize, unsigned int initSize)
Definition: cuddLCache.c:538
int * invperm
Definition: cuddInt.h:388
static DdNode * cuddAddGeneralVectorComposeRecur(DdManager *dd, DdHashTable *table, DdNode *f, DdNode **vectorOn, DdNode **vectorOff, int deepest)
Definition: cuddCompose.c:1383
DdNode* Cudd_addHamming ( DdManager dd,
DdNode **  xVars,
DdNode **  yVars,
int  nVars 
)

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

Synopsis [Computes the Hamming distance ADD.]

Description [Computes the Hamming distance ADD. Returns an ADD that gives the Hamming distance between its two arguments if successful; NULL otherwise. The two vectors xVars and yVars identify the variables that form the two arguments.]

SideEffects [None]

SeeAlso []

Definition at line 1255 of file cuddPriority.c.

1260 {
1261  DdNode *result,*tempBdd;
1262  DdNode *tempAdd,*temp;
1263  int i;
1264 
1265  result = DD_ZERO(dd);
1266  cuddRef(result);
1267 
1268  for (i = 0; i < nVars; i++) {
1269  tempBdd = Cudd_bddIte(dd,xVars[i],Cudd_Not(yVars[i]),yVars[i]);
1270  if (tempBdd == NULL) {
1271  Cudd_RecursiveDeref(dd,result);
1272  return(NULL);
1273  }
1274  cuddRef(tempBdd);
1275  tempAdd = Cudd_BddToAdd(dd,tempBdd);
1276  if (tempAdd == NULL) {
1277  Cudd_RecursiveDeref(dd,tempBdd);
1278  Cudd_RecursiveDeref(dd,result);
1279  return(NULL);
1280  }
1281  cuddRef(tempAdd);
1282  Cudd_RecursiveDeref(dd,tempBdd);
1283  temp = Cudd_addApply(dd,Cudd_addPlus,tempAdd,result);
1284  if (temp == NULL) {
1285  Cudd_RecursiveDeref(dd,tempAdd);
1286  Cudd_RecursiveDeref(dd,result);
1287  return(NULL);
1288  }
1289  cuddRef(temp);
1290  Cudd_RecursiveDeref(dd,tempAdd);
1291  Cudd_RecursiveDeref(dd,result);
1292  result = temp;
1293  }
1294 
1295  cuddDeref(result);
1296  return(result);
1297 
1298 } /* end of Cudd_addHamming */
#define cuddRef(n)
Definition: cuddInt.h:584
#define cuddDeref(n)
Definition: cuddInt.h:604
void Cudd_RecursiveDeref(DdManager *table, DdNode *n)
Definition: cuddRef.c:154
Definition: cudd.h:278
#define Cudd_Not(node)
Definition: cudd.h:367
DdNode * Cudd_addApply(DdManager *dd, DdNode *(*)(DdManager *, DdNode **, DdNode **), DdNode *f, DdNode *g)
DdNode * Cudd_bddIte(DdManager *dd, DdNode *f, DdNode *g, DdNode *h)
Definition: cuddBddIte.c:143
DdNode * Cudd_addPlus(DdManager *dd, DdNode **f, DdNode **g)
Definition: cuddAddApply.c:168
DdNode * Cudd_BddToAdd(DdManager *dd, DdNode *B)
Definition: cuddBridge.c:349
static int result
Definition: cuddGenetic.c:125
#define DD_ZERO(dd)
Definition: cuddInt.h:927
int Cudd_addHarwell ( FILE *  fp,
DdManager dd,
DdNode **  E,
DdNode ***  x,
DdNode ***  y,
DdNode ***  xn,
DdNode ***  yn_,
int *  nx,
int *  ny,
int *  m,
int *  n,
int  bx,
int  sx,
int  by,
int  sy,
int  pr 
)

AutomaticStart AutomaticEnd Function********************************************************************

Synopsis [Reads in a matrix in the format of the Harwell-Boeing benchmark suite.]

Description [Reads in a matrix in the format of the Harwell-Boeing benchmark suite. The variables are ordered as follows:

x[0] y[0] x[1] y[1] ...

0 is the most significant bit. On input, nx and ny hold the numbers of row and column variables already in existence. On output, they hold the numbers of row and column variables actually used by the matrix. m and n are set to the numbers of rows and columns of the matrix. Their values on input are immaterial. Returns 1 on success; 0 otherwise. The ADD for the sparse matrix is returned in E, and its reference count is > 0.]

SideEffects [None]

SeeAlso [Cudd_addRead Cudd_bddRead]

Definition at line 124 of file cuddHarwell.c.

141 {
142  DdNode *one, *zero;
143  DdNode *w;
144  DdNode *cubex, *cubey, *minterm1;
145  int u, v, err, i, j, nv;
146  double val;
147  DdNode **lx = NULL, **ly = NULL, **lxn = NULL, **lyn = NULL; /* local copies of x, y, xn, yn_ */
148  int lnx, lny; /* local copies of nx and ny */
149  char title[73], key[9], mxtype[4], rhstyp[4];
150  int totcrd, ptrcrd, indcrd, valcrd, rhscrd,
151  nrow, ncol, nnzero, neltvl,
152  nrhs, nrhsix;
153  int *colptr, *rowind;
154 #if 0
155  int nguess, nexact;
156  int *rhsptr, *rhsind;
157 #endif
158 
159  if (*nx < 0 || *ny < 0) return(0);
160 
161  one = DD_ONE(dd);
162  zero = DD_ZERO(dd);
163 
164  /* Read the header */
165  err = fscanf(fp, "%72c %8c", title, key);
166  if (err == EOF) {
167  return(0);
168  } else if (err != 2) {
169  return(0);
170  }
171  title[72] = (char) 0;
172  key[8] = (char) 0;
173 
174  err = fscanf(fp, "%d %d %d %d %d", &totcrd, &ptrcrd, &indcrd,
175  &valcrd, &rhscrd);
176  if (err == EOF) {
177  return(0);
178  } else if (err != 5) {
179  return(0);
180  }
181 
182  err = fscanf(fp, "%3s %d %d %d %d", mxtype, &nrow, &ncol,
183  &nnzero, &neltvl);
184  if (err == EOF) {
185  return(0);
186  } else if (err != 5) {
187  return(0);
188  }
189 
190  /* Skip FORTRAN formats */
191  if (rhscrd == 0) {
192  err = fscanf(fp, "%*s %*s %*s \n");
193  } else {
194  err = fscanf(fp, "%*s %*s %*s %*s \n");
195  }
196  if (err == EOF) {
197  return(0);
198  } else if (err != 0) {
199  return(0);
200  }
201 
202  /* Print out some stuff if requested to be verbose */
203  if (pr>0) {
204  (void) fprintf(dd->out,"%s: type %s, %d rows, %d columns, %d entries\n", key,
205  mxtype, nrow, ncol, nnzero);
206  if (pr>1) (void) fprintf(dd->out,"%s\n", title);
207  }
208 
209  /* Check matrix type */
210  if (mxtype[0] != 'R' || mxtype[1] != 'U' || mxtype[2] != 'A') {
211  (void) fprintf(dd->err,"%s: Illegal matrix type: %s\n",
212  key, mxtype);
213  return(0);
214  }
215  if (neltvl != 0) return(0);
216 
217  /* Read optional 5-th line */
218  if (rhscrd != 0) {
219  err = fscanf(fp, "%3c %d %d", rhstyp, &nrhs, &nrhsix);
220  if (err == EOF) {
221  return(0);
222  } else if (err != 3) {
223  return(0);
224  }
225  rhstyp[3] = (char) 0;
226  if (rhstyp[0] != 'F') {
227  (void) fprintf(dd->err,
228  "%s: Sparse right-hand side not yet supported\n", key);
229  return(0);
230  }
231  if (pr>0) (void) fprintf(dd->out,"%d right-hand side(s)\n", nrhs);
232  } else {
233  nrhs = 0;
234  }
235 
236  /* Compute the number of variables */
237 
238  /* row and column numbers start from 0 */
239  u = nrow - 1;
240  for (i=0; u > 0; i++) {
241  u >>= 1;
242  }
243  lnx = i;
244  if (nrhs == 0) {
245  v = ncol - 1;
246  } else {
247  v = 2* (ddMax(ncol, nrhs) - 1);
248  }
249  for (i=0; v > 0; i++) {
250  v >>= 1;
251  }
252  lny = i;
253 
254  /* Allocate or reallocate arrays for variables as needed */
255  if (*nx == 0) {
256  if (lnx > 0) {
257  *x = lx = ABC_ALLOC(DdNode *,lnx);
258  if (lx == NULL) {
260  return(0);
261  }
262  *xn = lxn = ABC_ALLOC(DdNode *,lnx);
263  if (lxn == NULL) {
265  return(0);
266  }
267  } else {
268  *x = *xn = NULL;
269  }
270  } else if (lnx > *nx) {
271  *x = lx = ABC_REALLOC(DdNode *, *x, lnx);
272  if (lx == NULL) {
274  return(0);
275  }
276  *xn = lxn = ABC_REALLOC(DdNode *, *xn, lnx);
277  if (lxn == NULL) {
279  return(0);
280  }
281  } else {
282  lx = *x;
283  lxn = *xn;
284  }
285  if (*ny == 0) {
286  if (lny >0) {
287  *y = ly = ABC_ALLOC(DdNode *,lny);
288  if (ly == NULL) {
290  return(0);
291  }
292  *yn_ = lyn = ABC_ALLOC(DdNode *,lny);
293  if (lyn == NULL) {
295  return(0);
296  }
297  } else {
298  *y = *yn_ = NULL;
299  }
300  } else if (lny > *ny) {
301  *y = ly = ABC_REALLOC(DdNode *, *y, lny);
302  if (ly == NULL) {
304  return(0);
305  }
306  *yn_ = lyn = ABC_REALLOC(DdNode *, *yn_, lny);
307  if (lyn == NULL) {
309  return(0);
310  }
311  } else {
312  ly = *y;
313  lyn = *yn_;
314  }
315 
316  /* Create new variables as needed */
317  for (i= *nx,nv=bx+(*nx)*sx; i < lnx; i++,nv+=sx) {
318  do {
319  dd->reordered = 0;
320  lx[i] = cuddUniqueInter(dd, nv, one, zero);
321  } while (dd->reordered == 1);
322  if (lx[i] == NULL) return(0);
323  cuddRef(lx[i]);
324  do {
325  dd->reordered = 0;
326  lxn[i] = cuddUniqueInter(dd, nv, zero, one);
327  } while (dd->reordered == 1);
328  if (lxn[i] == NULL) return(0);
329  cuddRef(lxn[i]);
330  }
331  for (i= *ny,nv=by+(*ny)*sy; i < lny; i++,nv+=sy) {
332  do {
333  dd->reordered = 0;
334  ly[i] = cuddUniqueInter(dd, nv, one, zero);
335  } while (dd->reordered == 1);
336  if (ly[i] == NULL) return(0);
337  cuddRef(ly[i]);
338  do {
339  dd->reordered = 0;
340  lyn[i] = cuddUniqueInter(dd, nv, zero, one);
341  } while (dd->reordered == 1);
342  if (lyn[i] == NULL) return(0);
343  cuddRef(lyn[i]);
344  }
345 
346  /* Update matrix parameters */
347  *nx = lnx;
348  *ny = lny;
349  *m = nrow;
350  if (nrhs == 0) {
351  *n = ncol;
352  } else {
353  *n = (1 << (lny - 1)) + nrhs;
354  }
355 
356  /* Read structure data */
357  colptr = ABC_ALLOC(int, ncol+1);
358  if (colptr == NULL) {
360  return(0);
361  }
362  rowind = ABC_ALLOC(int, nnzero);
363  if (rowind == NULL) {
365  return(0);
366  }
367 
368  for (i=0; i<ncol+1; i++) {
369  err = fscanf(fp, " %d ", &u);
370  if (err == EOF){
371  ABC_FREE(colptr);
372  ABC_FREE(rowind);
373  return(0);
374  } else if (err != 1) {
375  ABC_FREE(colptr);
376  ABC_FREE(rowind);
377  return(0);
378  }
379  colptr[i] = u - 1;
380  }
381  if (colptr[0] != 0) {
382  (void) fprintf(dd->err,"%s: Unexpected colptr[0] (%d)\n",
383  key,colptr[0]);
384  ABC_FREE(colptr);
385  ABC_FREE(rowind);
386  return(0);
387  }
388  for (i=0; i<nnzero; i++) {
389  err = fscanf(fp, " %d ", &u);
390  if (err == EOF){
391  ABC_FREE(colptr);
392  ABC_FREE(rowind);
393  return(0);
394  } else if (err != 1) {
395  ABC_FREE(colptr);
396  ABC_FREE(rowind);
397  return(0);
398  }
399  rowind[i] = u - 1;
400  }
401 
402  *E = zero; cuddRef(*E);
403 
404  for (j=0; j<ncol; j++) {
405  v = j;
406  cubey = one; cuddRef(cubey);
407  for (nv = lny - 1; nv>=0; nv--) {
408  if (v & 1) {
409  w = Cudd_addApply(dd, Cudd_addTimes, cubey, ly[nv]);
410  } else {
411  w = Cudd_addApply(dd, Cudd_addTimes, cubey, lyn[nv]);
412  }
413  if (w == NULL) {
414  Cudd_RecursiveDeref(dd, cubey);
415  ABC_FREE(colptr);
416  ABC_FREE(rowind);
417  return(0);
418  }
419  cuddRef(w);
420  Cudd_RecursiveDeref(dd, cubey);
421  cubey = w;
422  v >>= 1;
423  }
424  for (i=colptr[j]; i<colptr[j+1]; i++) {
425  u = rowind[i];
426  err = fscanf(fp, " %lf ", &val);
427  if (err == EOF || err != 1){
428  Cudd_RecursiveDeref(dd, cubey);
429  ABC_FREE(colptr);
430  ABC_FREE(rowind);
431  return(0);
432  }
433  /* Create new Constant node if necessary */
434  cubex = cuddUniqueConst(dd, (CUDD_VALUE_TYPE) val);
435  if (cubex == NULL) {
436  Cudd_RecursiveDeref(dd, cubey);
437  ABC_FREE(colptr);
438  ABC_FREE(rowind);
439  return(0);
440  }
441  cuddRef(cubex);
442 
443  for (nv = lnx - 1; nv>=0; nv--) {
444  if (u & 1) {
445  w = Cudd_addApply(dd, Cudd_addTimes, cubex, lx[nv]);
446  } else {
447  w = Cudd_addApply(dd, Cudd_addTimes, cubex, lxn[nv]);
448  }
449  if (w == NULL) {
450  Cudd_RecursiveDeref(dd, cubey);
451  Cudd_RecursiveDeref(dd, cubex);
452  ABC_FREE(colptr);
453  ABC_FREE(rowind);
454  return(0);
455  }
456  cuddRef(w);
457  Cudd_RecursiveDeref(dd, cubex);
458  cubex = w;
459  u >>= 1;
460  }
461  minterm1 = Cudd_addApply(dd, Cudd_addTimes, cubey, cubex);
462  if (minterm1 == NULL) {
463  Cudd_RecursiveDeref(dd, cubey);
464  Cudd_RecursiveDeref(dd, cubex);
465  ABC_FREE(colptr);
466  ABC_FREE(rowind);
467  return(0);
468  }
469  cuddRef(minterm1);
470  Cudd_RecursiveDeref(dd, cubex);
471  w = Cudd_addApply(dd, Cudd_addPlus, *E, minterm1);
472  if (w == NULL) {
473  Cudd_RecursiveDeref(dd, cubey);
474  ABC_FREE(colptr);
475  ABC_FREE(rowind);
476  return(0);
477  }
478  cuddRef(w);
479  Cudd_RecursiveDeref(dd, minterm1);
480  Cudd_RecursiveDeref(dd, *E);
481  *E = w;
482  }
483  Cudd_RecursiveDeref(dd, cubey);
484  }
485  ABC_FREE(colptr);
486  ABC_FREE(rowind);
487 
488  /* Read right-hand sides */
489  for (j=0; j<nrhs; j++) {
490  v = j + (1<< (lny-1));
491  cubey = one; cuddRef(cubey);
492  for (nv = lny - 1; nv>=0; nv--) {
493  if (v & 1) {
494  w = Cudd_addApply(dd, Cudd_addTimes, cubey, ly[nv]);
495  } else {
496  w = Cudd_addApply(dd, Cudd_addTimes, cubey, lyn[nv]);
497  }
498  if (w == NULL) {
499  Cudd_RecursiveDeref(dd, cubey);
500  return(0);
501  }
502  cuddRef(w);
503  Cudd_RecursiveDeref(dd, cubey);
504  cubey = w;
505  v >>= 1;
506  }
507  for (i=0; i<nrow; i++) {
508  u = i;
509  err = fscanf(fp, " %lf ", &val);
510  if (err == EOF || err != 1){
511  Cudd_RecursiveDeref(dd, cubey);
512  return(0);
513  }
514  /* Create new Constant node if necessary */
515  if (val == (double) 0.0) continue;
516  cubex = cuddUniqueConst(dd, (CUDD_VALUE_TYPE) val);
517  if (cubex == NULL) {
518  Cudd_RecursiveDeref(dd, cubey);
519  return(0);
520  }
521  cuddRef(cubex);
522 
523  for (nv = lnx - 1; nv>=0; nv--) {
524  if (u & 1) {
525  w = Cudd_addApply(dd, Cudd_addTimes, cubex, lx[nv]);
526  } else {
527  w = Cudd_addApply(dd, Cudd_addTimes, cubex, lxn[nv]);
528  }
529  if (w == NULL) {
530  Cudd_RecursiveDeref(dd, cubey);
531  Cudd_RecursiveDeref(dd, cubex);
532  return(0);
533  }
534  cuddRef(w);
535  Cudd_RecursiveDeref(dd, cubex);
536  cubex = w;
537  u >>= 1;
538  }
539  minterm1 = Cudd_addApply(dd, Cudd_addTimes, cubey, cubex);
540  if (minterm1 == NULL) {
541  Cudd_RecursiveDeref(dd, cubey);
542  Cudd_RecursiveDeref(dd, cubex);
543  return(0);
544  }
545  cuddRef(minterm1);
546  Cudd_RecursiveDeref(dd, cubex);
547  w = Cudd_addApply(dd, Cudd_addPlus, *E, minterm1);
548  if (w == NULL) {
549  Cudd_RecursiveDeref(dd, cubey);
550  return(0);
551  }
552  cuddRef(w);
553  Cudd_RecursiveDeref(dd, minterm1);
554  Cudd_RecursiveDeref(dd, *E);
555  *E = w;
556  }
557  Cudd_RecursiveDeref(dd, cubey);
558  }
559 
560  return(1);
561 
562 } /* end of Cudd_addHarwell */
#define cuddRef(n)
Definition: cuddInt.h:584
void Cudd_RecursiveDeref(DdManager *table, DdNode *n)
Definition: cuddRef.c:154
Definition: cudd.h:278
DdNode * cuddUniqueConst(DdManager *unique, CUDD_VALUE_TYPE value)
Definition: cuddTable.c:1450
#define ABC_REALLOC(type, obj, num)
Definition: abc_global.h:233
FILE * err
Definition: cuddInt.h:442
#define ABC_ALLOC(type, num)
Definition: abc_global.h:229
DdNode * Cudd_addApply(DdManager *dd, DdNode *(*)(DdManager *, DdNode **, DdNode **), DdNode *f, DdNode *g)
int reordered
Definition: cuddInt.h:409
static DdNode * one
Definition: cuddDecomp.c:112
FILE * out
Definition: cuddInt.h:441
DdNode * Cudd_addPlus(DdManager *dd, DdNode **f, DdNode **g)
Definition: cuddAddApply.c:168
#define ddMax(x, y)
Definition: cuddInt.h:832
#define CUDD_VALUE_TYPE
Definition: cudd.h:94
#define ABC_FREE(obj)
Definition: abc_global.h:232
enum keys key
#define DD_ONE(dd)
Definition: cuddInt.h:911
DdNode * Cudd_addTimes(DdManager *dd, DdNode **f, DdNode **g)
Definition: cuddAddApply.c:208
Cudd_ErrorType errorCode
Definition: cuddInt.h:447
DdNode * cuddUniqueInter(DdManager *unique, int index, DdNode *T, DdNode *E)
Definition: cuddTable.c:1128
static DdNode * zero
Definition: cuddApa.c:100
#define DD_ZERO(dd)
Definition: cuddInt.h:927
int Cudd_AddHook ( DdManager dd,
DD_HFP  f,
Cudd_HookType  where 
)

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

Synopsis [Adds a function to a hook.]

Description [Adds a function to a hook. A hook is a list of application-provided functions called on certain occasions by the package. Returns 1 if the function is successfully added; 2 if the function was already in the list; 0 otherwise.]

SideEffects [None]

SeeAlso [Cudd_RemoveHook]

Definition at line 3244 of file cuddAPI.c.

3248 {
3249  DdHook **hook, *nextHook, *newHook;
3250 
3251  switch (where) {
3252  case CUDD_PRE_GC_HOOK:
3253  hook = &(dd->preGCHook);
3254  break;
3255  case CUDD_POST_GC_HOOK:
3256  hook = &(dd->postGCHook);
3257  break;
3259  hook = &(dd->preReorderingHook);
3260  break;
3262  hook = &(dd->postReorderingHook);
3263  break;
3264  default:
3265  return(0);
3266  }
3267  /* Scan the list and find whether the function is already there.
3268  ** If so, just return. */
3269  nextHook = *hook;
3270  while (nextHook != NULL) {
3271  if (nextHook->f == f) {
3272  return(2);
3273  }
3274  hook = &(nextHook->next);
3275  nextHook = nextHook->next;
3276  }
3277  /* The function was not in the list. Create a new item and append it
3278  ** to the end of the list. */
3279  newHook = ABC_ALLOC(DdHook,1);
3280  if (newHook == NULL) {
3281  dd->errorCode = CUDD_MEMORY_OUT;
3282  return(0);
3283  }
3284  newHook->next = NULL;
3285  newHook->f = f;
3286  *hook = newHook;
3287  return(1);
3288 
3289 } /* end of Cudd_AddHook */
DdHook * preReorderingHook
Definition: cuddInt.h:439
#define ABC_ALLOC(type, num)
Definition: abc_global.h:229
DD_HFP f
Definition: cuddInt.h:246
DdHook * postReorderingHook
Definition: cuddInt.h:440
struct DdHook * next
Definition: cuddInt.h:247
DdHook * postGCHook
Definition: cuddInt.h:438
DdHook * preGCHook
Definition: cuddInt.h:437
Cudd_ErrorType errorCode
Definition: cuddInt.h:447
DdNode* Cudd_addIte ( DdManager dd,
DdNode f,
DdNode g,
DdNode h 
)

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

Synopsis [Implements ITE(f,g,h).]

Description [Implements ITE(f,g,h). This procedure assumes that f is a 0-1 ADD. Returns a pointer to the resulting ADD if successful; NULL otherwise.]

SideEffects [None]

SeeAlso [Cudd_bddIte Cudd_addIteConstant Cudd_addApply]

Definition at line 129 of file cuddAddIte.c.

134 {
135  DdNode *res;
136 
137  do {
138  dd->reordered = 0;
139  res = cuddAddIteRecur(dd,f,g,h);
140  } while (dd->reordered == 1);
141  return(res);
142 
143 } /* end of Cudd_addIte */
Definition: cudd.h:278
int reordered
Definition: cuddInt.h:409
DdNode * cuddAddIteRecur(DdManager *dd, DdNode *f, DdNode *g, DdNode *h)
Definition: cuddAddIte.c:445
DdNode* Cudd_addIteConstant ( DdManager dd,
DdNode f,
DdNode g,
DdNode h 
)

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

Synopsis [Implements ITEconstant for ADDs.]

Description [Implements ITEconstant for ADDs. f must be a 0-1 ADD. Returns a pointer to the resulting ADD (which may or may not be constant) or DD_NON_CONSTANT. No new nodes are created. This function can be used, for instance, to check that g has a constant value (specified by h) whenever f is 1. If the constant value is unknown, then one should use Cudd_addEvalConst.]

SideEffects [None]

SeeAlso [Cudd_addIte Cudd_addEvalConst Cudd_bddIteConstant]

Definition at line 163 of file cuddAddIte.c.

168 {
169  DdNode *one,*zero;
170  DdNode *Fv,*Fnv,*Gv,*Gnv,*Hv,*Hnv,*r,*t,*e;
171  unsigned int topf,topg,toph,v;
172 
173  statLine(dd);
174  /* Trivial cases. */
175  if (f == (one = DD_ONE(dd))) { /* ITE(1,G,H) = G */
176  return(g);
177  }
178  if (f == (zero = DD_ZERO(dd))) { /* ITE(0,G,H) = H */
179  return(h);
180  }
181 
182  /* From now on, f is known not to be a constant. */
183  addVarToConst(f,&g,&h,one,zero);
184 
185  /* Check remaining one variable cases. */
186  if (g == h) { /* ITE(F,G,G) = G */
187  return(g);
188  }
189  if (cuddIsConstant(g) && cuddIsConstant(h)) {
190  return(DD_NON_CONSTANT);
191  }
192 
193  topf = cuddI(dd,f->index);
194  topg = cuddI(dd,g->index);
195  toph = cuddI(dd,h->index);
196  v = ddMin(topg,toph);
197 
198  /* ITE(F,G,H) = (x,G,H) (non constant) if F = (x,1,0), x < top(G,H). */
199  if (topf < v && cuddIsConstant(cuddT(f)) && cuddIsConstant(cuddE(f))) {
200  return(DD_NON_CONSTANT);
201  }
202 
203  /* Check cache. */
205  if (r != NULL) {
206  return(r);
207  }
208 
209  /* Compute cofactors. */
210  if (topf <= v) {
211  v = ddMin(topf,v); /* v = top_var(F,G,H) */
212  Fv = cuddT(f); Fnv = cuddE(f);
213  } else {
214  Fv = Fnv = f;
215  }
216  if (topg == v) {
217  Gv = cuddT(g); Gnv = cuddE(g);
218  } else {
219  Gv = Gnv = g;
220  }
221  if (toph == v) {
222  Hv = cuddT(h); Hnv = cuddE(h);
223  } else {
224  Hv = Hnv = h;
225  }
226 
227  /* Recursive step. */
228  t = Cudd_addIteConstant(dd,Fv,Gv,Hv);
229  if (t == DD_NON_CONSTANT || !cuddIsConstant(t)) {
231  return(DD_NON_CONSTANT);
232  }
233  e = Cudd_addIteConstant(dd,Fnv,Gnv,Hnv);
234  if (e == DD_NON_CONSTANT || !cuddIsConstant(e) || t != e) {
236  return(DD_NON_CONSTANT);
237  }
238  cuddCacheInsert(dd, DD_ADD_ITE_CONSTANT_TAG, f, g, h, t);
239  return(t);
240 
241 } /* end of Cudd_addIteConstant */
DdNode * Cudd_addIteConstant(DdManager *dd, DdNode *f, DdNode *g, DdNode *h)
Definition: cuddAddIte.c:163
Definition: cudd.h:278
static void addVarToConst(DdNode *f, DdNode **gp, DdNode **hp, DdNode *one, DdNode *zero)
Definition: cuddAddIte.c:625
#define DD_ADD_ITE_CONSTANT_TAG
Definition: cuddInt.h:184
void cuddCacheInsert(DdManager *table, ptruint op, DdNode *f, DdNode *g, DdNode *h, DdNode *data)
Definition: cuddCache.c:222
#define statLine(dd)
Definition: cuddInt.h:1037
static DdNode * one
Definition: cuddDecomp.c:112
#define cuddIsConstant(node)
Definition: cuddInt.h:620
#define ddMin(x, y)
Definition: cuddInt.h:818
DdNode * cuddConstantLookup(DdManager *table, ptruint op, DdNode *f, DdNode *g, DdNode *h)
Definition: cuddCache.c:721
#define cuddT(node)
Definition: cuddInt.h:636
#define cuddI(dd, index)
Definition: cuddInt.h:686
DdHalfWord index
Definition: cudd.h:279
#define cuddE(node)
Definition: cuddInt.h:652
#define DD_ONE(dd)
Definition: cuddInt.h:911
static DdNode * zero
Definition: cuddApa.c:100
#define DD_NON_CONSTANT
Definition: cuddInt.h:123
#define DD_ZERO(dd)
Definition: cuddInt.h:927
DdNode* Cudd_addIthBit ( DdManager dd,
DdNode f,
int  bit 
)

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

Synopsis [Extracts the i-th bit from an ADD.]

Description [Produces an ADD from another ADD by replacing all discriminants whose i-th bit is equal to 1 with 1, and all other discriminants with 0. The i-th bit refers to the integer representation of the leaf value. If the value is has a fractional part, it is ignored. Repeated calls to this procedure allow one to transform an integer-valued ADD into an array of ADDs, one for each bit of the leaf values. Returns a pointer to the resulting ADD if successful; NULL otherwise.]

SideEffects [None]

SeeAlso [Cudd_addBddIthBit]

Definition at line 213 of file cuddAddFind.c.

217 {
218  DdNode *res;
219  DdNode *index;
220 
221  /* Use a constant node to remember the bit, so that we can use the
222  ** global cache.
223  */
224  index = cuddUniqueConst(dd,(CUDD_VALUE_TYPE) bit);
225  if (index == NULL) return(NULL);
226  cuddRef(index);
227 
228  do {
229  dd->reordered = 0;
230  res = addDoIthBit(dd, f, index);
231  } while (dd->reordered == 1);
232 
233  if (res == NULL) {
234  Cudd_RecursiveDeref(dd, index);
235  return(NULL);
236  }
237  cuddRef(res);
238  Cudd_RecursiveDeref(dd, index);
239  cuddDeref(res);
240  return(res);
241 
242 } /* end of Cudd_addIthBit */
#define cuddRef(n)
Definition: cuddInt.h:584
#define cuddDeref(n)
Definition: cuddInt.h:604
void Cudd_RecursiveDeref(DdManager *table, DdNode *n)
Definition: cuddRef.c:154
Definition: cudd.h:278
DdNode * cuddUniqueConst(DdManager *unique, CUDD_VALUE_TYPE value)
Definition: cuddTable.c:1450
int reordered
Definition: cuddInt.h:409
static DdNode * addDoIthBit(DdManager *dd, DdNode *f, DdNode *index)
Definition: cuddAddFind.c:268
#define CUDD_VALUE_TYPE
Definition: cudd.h:94
DdNode* Cudd_addIthVar ( DdManager dd,
int  i 
)

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

Synopsis [Returns the ADD variable with index i.]

Description [Retrieves the ADD variable with index i if it already exists, or creates a new ADD variable. Returns a pointer to the variable if successful; NULL otherwise. An ADD variable differs from a BDD variable because it points to the arithmetic zero, instead of having a complement pointer to 1. ]

SideEffects [None]

SeeAlso [Cudd_addNewVar Cudd_bddIthVar Cudd_addConst Cudd_addNewVarAtLevel]

Definition at line 384 of file cuddAPI.c.

387 {
388  DdNode *res;
389 
390  if ((unsigned int) i >= CUDD_MAXINDEX - 1) return(NULL);
391  do {
392  dd->reordered = 0;
393  res = cuddUniqueInter(dd,i,DD_ONE(dd),DD_ZERO(dd));
394  } while (dd->reordered == 1);
395 
396  return(res);
397 
398 } /* end of Cudd_addIthVar */
Definition: cudd.h:278
int reordered
Definition: cuddInt.h:409
#define CUDD_MAXINDEX
Definition: cudd.h:112
#define DD_ONE(dd)
Definition: cuddInt.h:911
DdNode * cuddUniqueInter(DdManager *unique, int index, DdNode *T, DdNode *E)
Definition: cuddTable.c:1128
#define DD_ZERO(dd)
Definition: cuddInt.h:927
int Cudd_addLeq ( DdManager dd,
DdNode f,
DdNode g 
)

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

Synopsis [Determines whether f is less than or equal to g.]

Description [Returns 1 if f is less than or equal to g; 0 otherwise. No new nodes are created. This procedure works for arbitrary ADDs. For 0-1 ADDs Cudd_addEvalConst is more efficient.]

SideEffects [None]

SeeAlso [Cudd_addIteConstant Cudd_addEvalConst Cudd_bddLeq]

Definition at line 376 of file cuddAddIte.c.

380 {
381  DdNode *tmp, *fv, *fvn, *gv, *gvn;
382  unsigned int topf, topg, res;
383 
384  /* Terminal cases. */
385  if (f == g) return(1);
386 
387  statLine(dd);
388  if (cuddIsConstant(f)) {
389  if (cuddIsConstant(g)) return(cuddV(f) <= cuddV(g));
390  if (f == DD_MINUS_INFINITY(dd)) return(1);
391  if (f == DD_PLUS_INFINITY(dd)) return(0); /* since f != g */
392  }
393  if (g == DD_PLUS_INFINITY(dd)) return(1);
394  if (g == DD_MINUS_INFINITY(dd)) return(0); /* since f != g */
395 
396  /* Check cache. */
397  tmp = cuddCacheLookup2(dd,(DD_CTFP)Cudd_addLeq,f,g);
398  if (tmp != NULL) {
399  return(tmp == DD_ONE(dd));
400  }
401 
402  /* Compute cofactors. One of f and g is not constant. */
403  topf = cuddI(dd,f->index);
404  topg = cuddI(dd,g->index);
405  if (topf <= topg) {
406  fv = cuddT(f); fvn = cuddE(f);
407  } else {
408  fv = fvn = f;
409  }
410  if (topg <= topf) {
411  gv = cuddT(g); gvn = cuddE(g);
412  } else {
413  gv = gvn = g;
414  }
415 
416  res = Cudd_addLeq(dd,fvn,gvn) && Cudd_addLeq(dd,fv,gv);
417 
418  /* Store result in cache and return. */
420  Cudd_NotCond(DD_ONE(dd),res==0));
421  return(res);
422 
423 } /* end of Cudd_addLeq */
Definition: cudd.h:278
void cuddCacheInsert2(DdManager *table, DD_CTFP op, DdNode *f, DdNode *g, DdNode *data)
Definition: cuddCache.c:277
DdNode *(* DD_CTFP)(DdManager *, DdNode *, DdNode *)
Definition: cudd.h:321
#define statLine(dd)
Definition: cuddInt.h:1037
#define DD_MINUS_INFINITY(dd)
Definition: cuddInt.h:955
#define cuddV(node)
Definition: cuddInt.h:668
DdNode * cuddCacheLookup2(DdManager *table, DD_CTFP op, DdNode *f, DdNode *g)
Definition: cuddCache.c:502
int Cudd_addLeq(DdManager *dd, DdNode *f, DdNode *g)
Definition: cuddAddIte.c:376
#define cuddIsConstant(node)
Definition: cuddInt.h:620
#define cuddT(node)
Definition: cuddInt.h:636
#define cuddI(dd, index)
Definition: cuddInt.h:686
DdHalfWord index
Definition: cudd.h:279
#define cuddE(node)
Definition: cuddInt.h:652
#define Cudd_NotCond(node, c)
Definition: cudd.h:383
#define DD_PLUS_INFINITY(dd)
Definition: cuddInt.h:941
#define DD_ONE(dd)
Definition: cuddInt.h:911
DdNode* Cudd_addLog ( DdManager dd,
DdNode f 
)

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

Synopsis [Natural logarithm of an ADD.]

Description [Natural logarithm of an ADDs. Returns NULL if not a terminal case; log(f) otherwise. The discriminants of f must be positive double's.]

SideEffects [None]

SeeAlso [Cudd_addMonadicApply]

Definition at line 777 of file cuddAddApply.c.

780 {
781  if (cuddIsConstant(f)) {
782  CUDD_VALUE_TYPE value = log(cuddV(f));
783  DdNode *res = cuddUniqueConst(dd,value);
784  return(res);
785  }
786  return(NULL);
787 
788 } /* end of Cudd_addLog */
Definition: cudd.h:278
DdNode * cuddUniqueConst(DdManager *unique, CUDD_VALUE_TYPE value)
Definition: cuddTable.c:1450
#define cuddV(node)
Definition: cuddInt.h:668
#define cuddIsConstant(node)
Definition: cuddInt.h:620
#define CUDD_VALUE_TYPE
Definition: cudd.h:94
int value
DdNode* Cudd_addMatrixMultiply ( DdManager dd,
DdNode A,
DdNode B,
DdNode **  z,
int  nz 
)

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

Synopsis [Calculates the product of two matrices represented as ADDs.]

Description [Calculates the product of two matrices, A and B, represented as ADDs. This procedure implements the quasiring multiplication algorithm. A is assumed to depend on variables x (rows) and z (columns). B is assumed to depend on variables z (rows) and y (columns). The product of A and B then depends on x (rows) and y (columns). Only the z variables have to be explicitly identified; they are the "summation" variables. Returns a pointer to the result if successful; NULL otherwise.]

SideEffects [None]

SeeAlso [Cudd_addTimesPlus Cudd_addTriangle Cudd_bddAndAbstract]

Definition at line 132 of file cuddMatMult.c.

138 {
139  int i, nvars, *vars;
140  DdNode *res;
141 
142  /* Array vars says what variables are "summation" variables. */
143  nvars = dd->size;
144  vars = ABC_ALLOC(int,nvars);
145  if (vars == NULL) {
147  return(NULL);
148  }
149  for (i = 0; i < nvars; i++) {
150  vars[i] = 0;
151  }
152  for (i = 0; i < nz; i++) {
153  vars[z[i]->index] = 1;
154  }
155 
156  do {
157  dd->reordered = 0;
158  res = addMMRecur(dd,A,B,-1,vars);
159  } while (dd->reordered == 1);
160  ABC_FREE(vars);
161  return(res);
162 
163 } /* end of Cudd_addMatrixMultiply */
Definition: cudd.h:278
int size
Definition: cuddInt.h:361
#define ABC_ALLOC(type, num)
Definition: abc_global.h:229
int reordered
Definition: cuddInt.h:409
DdHalfWord index
Definition: cudd.h:279
#define ABC_FREE(obj)
Definition: abc_global.h:232
static DdNode * addMMRecur(DdManager *dd, DdNode *A, DdNode *B, int topP, int *vars)
Definition: cuddMatMult.c:333
Cudd_ErrorType errorCode
Definition: cuddInt.h:447
DdNode* Cudd_addMaximum ( DdManager dd,
DdNode **  f,
DdNode **  g 
)

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

Synopsis [Integer and floating point max.]

Description [Integer and floating point max for Cudd_addApply. Returns NULL if not a terminal case; max(f,g) otherwise.]

SideEffects [None]

SeeAlso [Cudd_addApply]

Definition at line 430 of file cuddAddApply.c.

434 {
435  DdNode *F, *G;
436 
437  F = *f; G = *g;
438  if (F == G) return(F);
439  if (F == DD_MINUS_INFINITY(dd)) return(G);
440  if (G == DD_MINUS_INFINITY(dd)) return(F);
441 #if 0
442  /* These special cases probably do not pay off. */
443  if (F == DD_PLUS_INFINITY(dd)) return(F);
444  if (G == DD_PLUS_INFINITY(dd)) return(G);
445 #endif
446  if (cuddIsConstant(F) && cuddIsConstant(G)) {
447  if (cuddV(F) >= cuddV(G)) {
448  return(F);
449  } else {
450  return(G);
451  }
452  }
453  if (F > G) { /* swap f and g */
454  *f = G;
455  *g = F;
456  }
457  return(NULL);
458 
459 } /* end of Cudd_addMaximum */
Definition: cudd.h:278
#define DD_MINUS_INFINITY(dd)
Definition: cuddInt.h:955
#define cuddV(node)
Definition: cuddInt.h:668
#define cuddIsConstant(node)
Definition: cuddInt.h:620
#define DD_PLUS_INFINITY(dd)
Definition: cuddInt.h:941
DdNode* Cudd_addMinimum ( DdManager dd,
DdNode **  f,
DdNode **  g 
)

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

Synopsis [Integer and floating point min.]

Description [Integer and floating point min for Cudd_addApply. Returns NULL if not a terminal case; min(f,g) otherwise.]

SideEffects [None]

SeeAlso [Cudd_addApply]

Definition at line 385 of file cuddAddApply.c.

389 {
390  DdNode *F, *G;
391 
392  F = *f; G = *g;
393  if (F == DD_PLUS_INFINITY(dd)) return(G);
394  if (G == DD_PLUS_INFINITY(dd)) return(F);
395  if (F == G) return(F);
396 #if 0
397  /* These special cases probably do not pay off. */
398  if (F == DD_MINUS_INFINITY(dd)) return(F);
399  if (G == DD_MINUS_INFINITY(dd)) return(G);
400 #endif
401  if (cuddIsConstant(F) && cuddIsConstant(G)) {
402  if (cuddV(F) <= cuddV(G)) {
403  return(F);
404  } else {
405  return(G);
406  }
407  }
408  if (F > G) { /* swap f and g */
409  *f = G;
410  *g = F;
411  }
412  return(NULL);
413 
414 } /* end of Cudd_addMinimum */
Definition: cudd.h:278
#define DD_MINUS_INFINITY(dd)
Definition: cuddInt.h:955
#define cuddV(node)
Definition: cuddInt.h:668
#define cuddIsConstant(node)
Definition: cuddInt.h:620
#define DD_PLUS_INFINITY(dd)
Definition: cuddInt.h:941
DdNode* Cudd_addMinus ( DdManager dd,
DdNode **  f,
DdNode **  g 
)

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

Synopsis [Integer and floating point subtraction.]

Description [Integer and floating point subtraction. Returns NULL if not a terminal case; f - g otherwise.]

SideEffects [None]

SeeAlso [Cudd_addApply]

Definition at line 349 of file cuddAddApply.c.

353 {
354  DdNode *res;
355  DdNode *F, *G;
357 
358  F = *f; G = *g;
359  if (F == G) return(DD_ZERO(dd));
360  if (F == DD_ZERO(dd)) return(cuddAddNegateRecur(dd,G));
361  if (G == DD_ZERO(dd)) return(F);
362  if (cuddIsConstant(F) && cuddIsConstant(G)) {
363  value = cuddV(F)-cuddV(G);
364  res = cuddUniqueConst(dd,value);
365  return(res);
366  }
367  return(NULL);
368 
369 } /* end of Cudd_addMinus */
Definition: cudd.h:278
DdNode * cuddUniqueConst(DdManager *unique, CUDD_VALUE_TYPE value)
Definition: cuddTable.c:1450
#define cuddV(node)
Definition: cuddInt.h:668
DdNode * cuddAddNegateRecur(DdManager *dd, DdNode *f)
Definition: cuddAddNeg.c:180
#define cuddIsConstant(node)
Definition: cuddInt.h:620
#define CUDD_VALUE_TYPE
Definition: cudd.h:94
int value
#define DD_ZERO(dd)
Definition: cuddInt.h:927
DdNode* Cudd_addMonadicApply ( DdManager dd,
DD_MAOP  op,
DdNode f 
)

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

Synopsis [Applies op to the discriminants of f.]

Description [Applies op to the discriminants of f. Returns a pointer to the result if succssful; NULL otherwise.]

SideEffects [None]

SeeAlso [Cudd_addApply Cudd_addLog]

Definition at line 747 of file cuddAddApply.c.

751 {
752  DdNode *res;
753 
754  do {
755  dd->reordered = 0;
756  res = cuddAddMonadicApplyRecur(dd,op,f);
757  } while (dd->reordered == 1);
758  return(res);
759 
760 } /* end of Cudd_addMonadicApply */
Definition: cudd.h:278
DdNode * cuddAddMonadicApplyRecur(DdManager *dd, DD_MAOP op, DdNode *f)
Definition: cuddAddApply.c:893
int reordered
Definition: cuddInt.h:409
DdNode* Cudd_addNand ( DdManager dd,
DdNode **  f,
DdNode **  g 
)

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

Synopsis [NAND of two 0-1 ADDs.]

Description [NAND of two 0-1 ADDs. Returns NULL if not a terminal case; f NAND g otherwise.]

SideEffects [None]

SeeAlso [Cudd_addApply]

Definition at line 615 of file cuddAddApply.c.

619 {
620  DdNode *F, *G;
621 
622  F = *f; G = *g;
623  if (F == DD_ZERO(dd) || G == DD_ZERO(dd)) return(DD_ONE(dd));
624  if (cuddIsConstant(F) && cuddIsConstant(G)) return(DD_ZERO(dd));
625  if (F > G) { /* swap f and g */
626  *f = G;
627  *g = F;
628  }
629  return(NULL);
630 
631 } /* end of Cudd_addNand */
Definition: cudd.h:278
#define cuddIsConstant(node)
Definition: cuddInt.h:620
#define DD_ONE(dd)
Definition: cuddInt.h:911
#define DD_ZERO(dd)
Definition: cuddInt.h:927
DdNode* Cudd_addNegate ( DdManager dd,
DdNode f 
)

AutomaticStart AutomaticEnd Function********************************************************************

Synopsis [Computes the additive inverse of an ADD.]

Description [Computes the additive inverse of an ADD. Returns a pointer to the result if successful; NULL otherwise.]

SideEffects [None]

SeeAlso [Cudd_addCmpl]

Definition at line 120 of file cuddAddNeg.c.

123 {
124  DdNode *res;
125 
126  do {
127  res = cuddAddNegateRecur(dd,f);
128  } while (dd->reordered == 1);
129  return(res);
130 
131 } /* end of Cudd_addNegate */
Definition: cudd.h:278
int reordered
Definition: cuddInt.h:409
DdNode * cuddAddNegateRecur(DdManager *dd, DdNode *f)
Definition: cuddAddNeg.c:180
DdNode* Cudd_addNewVar ( DdManager dd)

AutomaticStart

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

Synopsis [Returns a new ADD variable.]

Description [Creates a new ADD variable. The new variable has an index equal to the largest previous index plus 1. Returns a pointer to the new variable if successful; NULL otherwise. An ADD variable differs from a BDD variable because it points to the arithmetic zero, instead of having a complement pointer to 1. ]

SideEffects [None]

SeeAlso [Cudd_bddNewVar Cudd_addIthVar Cudd_addConst Cudd_addNewVarAtLevel]

Definition at line 259 of file cuddAPI.c.

261 {
262  DdNode *res;
263 
264  if ((unsigned int) dd->size >= CUDD_MAXINDEX - 1) return(NULL);
265  do {
266  dd->reordered = 0;
267  res = cuddUniqueInter(dd,dd->size,DD_ONE(dd),DD_ZERO(dd));
268  } while (dd->reordered == 1);
269 
270  return(res);
271 
272 } /* end of Cudd_addNewVar */
Definition: cudd.h:278
int size
Definition: cuddInt.h:361
int reordered
Definition: cuddInt.h:409
#define CUDD_MAXINDEX
Definition: cudd.h:112
#define DD_ONE(dd)
Definition: cuddInt.h:911
DdNode * cuddUniqueInter(DdManager *unique, int index, DdNode *T, DdNode *E)
Definition: cuddTable.c:1128
#define DD_ZERO(dd)
Definition: cuddInt.h:927
DdNode* Cudd_addNewVarAtLevel ( DdManager dd,
int  level 
)

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

Synopsis [Returns a new ADD variable at a specified level.]

Description [Creates a new ADD variable. The new variable has an index equal to the largest previous index plus 1 and is positioned at the specified level in the order. Returns a pointer to the new variable if successful; NULL otherwise.]

SideEffects [None]

SeeAlso [Cudd_addNewVar Cudd_addIthVar Cudd_bddNewVarAtLevel]

Definition at line 290 of file cuddAPI.c.

293 {
294  DdNode *res;
295 
296  if ((unsigned int) dd->size >= CUDD_MAXINDEX - 1) return(NULL);
297  if (level >= dd->size) return(Cudd_addIthVar(dd,level));
298  if (!cuddInsertSubtables(dd,1,level)) return(NULL);
299  do {
300  dd->reordered = 0;
301  res = cuddUniqueInter(dd,dd->size - 1,DD_ONE(dd),DD_ZERO(dd));
302  } while (dd->reordered == 1);
303 
304  return(res);
305 
306 } /* end of Cudd_addNewVarAtLevel */
Definition: cudd.h:278
int size
Definition: cuddInt.h:361
int reordered
Definition: cuddInt.h:409
int cuddInsertSubtables(DdManager *unique, int n, int level)
Definition: cuddTable.c:1795
DdNode * Cudd_addIthVar(DdManager *dd, int i)
Definition: cuddAPI.c:384
#define CUDD_MAXINDEX
Definition: cudd.h:112
#define DD_ONE(dd)
Definition: cuddInt.h:911
DdNode * cuddUniqueInter(DdManager *unique, int index, DdNode *T, DdNode *E)
Definition: cuddTable.c:1128
#define DD_ZERO(dd)
Definition: cuddInt.h:927
DdNode* Cudd_addNonSimCompose ( DdManager dd,
DdNode f,
DdNode **  vector 
)

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

Synopsis [Composes an ADD with a vector of 0-1 ADDs.]

Description [Given a vector of 0-1 ADDs, creates a new ADD by substituting the 0-1 ADDs for the variables of the ADD f. There should be an entry in vector for each variable in the manager. This function implements non-simultaneous composition. If any of the functions being composed depends on any of the variables being substituted, then the result depends on the order of composition, which in turn depends on the variable order: The variables farther from the roots in the order are substituted first. Returns a pointer to the resulting ADD if successful; NULL otherwise.]

SideEffects [None]

SeeAlso [Cudd_addVectorCompose Cudd_addPermute Cudd_addCompose]

Definition at line 682 of file cuddCompose.c.

686 {
687  DdNode *cube, *key, *var, *tmp, *piece;
688  DdNode *res;
689  int i, lastsub;
690 
691  /* The cache entry for this function is composed of three parts:
692  ** f itself, the replacement relation, and the cube of the
693  ** variables being substituted.
694  ** The replacement relation is the product of the terms (yi EXNOR gi).
695  ** This apporach allows us to use the global cache for this function,
696  ** with great savings in memory with respect to using arrays for the
697  ** cache entries.
698  ** First we build replacement relation and cube of substituted
699  ** variables from the vector specifying the desired composition.
700  */
701  key = DD_ONE(dd);
702  cuddRef(key);
703  cube = DD_ONE(dd);
704  cuddRef(cube);
705  for (i = (int) dd->size - 1; i >= 0; i--) {
706  if (ddIsIthAddVar(dd,vector[i],(unsigned int)i)) {
707  continue;
708  }
709  var = Cudd_addIthVar(dd,i);
710  if (var == NULL) {
711  Cudd_RecursiveDeref(dd,key);
712  Cudd_RecursiveDeref(dd,cube);
713  return(NULL);
714  }
715  cuddRef(var);
716  /* Update cube. */
717  tmp = Cudd_addApply(dd,Cudd_addTimes,var,cube);
718  if (tmp == NULL) {
719  Cudd_RecursiveDeref(dd,key);
720  Cudd_RecursiveDeref(dd,cube);
721  Cudd_RecursiveDeref(dd,var);
722  return(NULL);
723  }
724  cuddRef(tmp);
725  Cudd_RecursiveDeref(dd,cube);
726  cube = tmp;
727  /* Update replacement relation. */
728  piece = Cudd_addApply(dd,Cudd_addXnor,var,vector[i]);
729  if (piece == NULL) {
730  Cudd_RecursiveDeref(dd,key);
731  Cudd_RecursiveDeref(dd,var);
732  return(NULL);
733  }
734  cuddRef(piece);
735  Cudd_RecursiveDeref(dd,var);
736  tmp = Cudd_addApply(dd,Cudd_addTimes,key,piece);
737  if (tmp == NULL) {
738  Cudd_RecursiveDeref(dd,key);
739  Cudd_RecursiveDeref(dd,piece);
740  return(NULL);
741  }
742  cuddRef(tmp);
743  Cudd_RecursiveDeref(dd,key);
744  Cudd_RecursiveDeref(dd,piece);
745  key = tmp;
746  }
747 
748  /* Now try composition, until no reordering occurs. */
749  do {
750  /* Find real substitution with largest index. */
751  for (lastsub = dd->size - 1; lastsub >= 0; lastsub--) {
752  if (!ddIsIthAddVar(dd,vector[lastsub],(unsigned int)lastsub)) {
753  break;
754  }
755  }
756 
757  /* Recursively solve the problem. */
758  dd->reordered = 0;
759  res = cuddAddNonSimComposeRecur(dd,f,vector,key,cube,lastsub+1);
760  if (res != NULL) cuddRef(res);
761 
762  } while (dd->reordered == 1);
763 
764  Cudd_RecursiveDeref(dd,key);
765  Cudd_RecursiveDeref(dd,cube);
766  if (res != NULL) cuddDeref(res);
767  return(res);
768 
769 } /* end of Cudd_addNonSimCompose */
#define cuddRef(n)
Definition: cuddInt.h:584
#define cuddDeref(n)
Definition: cuddInt.h:604
void Cudd_RecursiveDeref(DdManager *table, DdNode *n)
Definition: cuddRef.c:154
Definition: cudd.h:278
int size
Definition: cuddInt.h:361
int var(Lit p)
Definition: SolverTypes.h:62
DdNode * Cudd_addApply(DdManager *dd, DdNode *(*)(DdManager *, DdNode **, DdNode **), DdNode *f, DdNode *g)
static DD_INLINE int ddIsIthAddVar(DdManager *dd, DdNode *f, unsigned int i)
Definition: cuddCompose.c:1721
int reordered
Definition: cuddInt.h:409
DdNode * Cudd_addIthVar(DdManager *dd, int i)
Definition: cuddAPI.c:384
DdNode * Cudd_addXnor(DdManager *dd, DdNode **f, DdNode **g)
Definition: cuddAddApply.c:713
enum keys key
static DdNode * cuddAddNonSimComposeRecur(DdManager *dd, DdNode *f, DdNode **vector, DdNode *key, DdNode *cube, int lastsub)
Definition: cuddCompose.c:1480
#define DD_ONE(dd)
Definition: cuddInt.h:911
DdNode * Cudd_addTimes(DdManager *dd, DdNode **f, DdNode **g)
Definition: cuddAddApply.c:208
DdNode* Cudd_addNor ( DdManager dd,
DdNode **  f,
DdNode **  g 
)

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

Synopsis [NOR of two 0-1 ADDs.]

Description [NOR of two 0-1 ADDs. Returns NULL if not a terminal case; f NOR g otherwise.]

SideEffects [None]

SeeAlso [Cudd_addApply]

Definition at line 647 of file cuddAddApply.c.

651 {
652  DdNode *F, *G;
653 
654  F = *f; G = *g;
655  if (F == DD_ONE(dd) || G == DD_ONE(dd)) return(DD_ZERO(dd));
656  if (cuddIsConstant(F) && cuddIsConstant(G)) return(DD_ONE(dd));
657  if (F > G) { /* swap f and g */
658  *f = G;
659  *g = F;
660  }
661  return(NULL);
662 
663 } /* end of Cudd_addNor */
Definition: cudd.h:278
#define cuddIsConstant(node)
Definition: cuddInt.h:620
#define DD_ONE(dd)
Definition: cuddInt.h:911
#define DD_ZERO(dd)
Definition: cuddInt.h:927
DdNode* Cudd_addOneZeroMaximum ( DdManager dd,
DdNode **  f,
DdNode **  g 
)

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

Synopsis [Returns 1 if f > g and 0 otherwise.]

Description [Returns 1 if f > g and 0 otherwise. Used in conjunction with Cudd_addApply. Returns NULL if not a terminal case.]

SideEffects [None]

SeeAlso [Cudd_addApply]

Definition at line 476 of file cuddAddApply.c.

480 {
481 
482  if (*f == *g) return(DD_ZERO(dd));
483  if (*g == DD_PLUS_INFINITY(dd))
484  return DD_ZERO(dd);
485  if (cuddIsConstant(*f) && cuddIsConstant(*g)) {
486  if (cuddV(*f) > cuddV(*g)) {
487  return(DD_ONE(dd));
488  } else {
489  return(DD_ZERO(dd));
490  }
491  }
492 
493  return(NULL);
494 
495 } /* end of Cudd_addOneZeroMaximum */
#define cuddV(node)
Definition: cuddInt.h:668
#define cuddIsConstant(node)
Definition: cuddInt.h:620
#define DD_PLUS_INFINITY(dd)
Definition: cuddInt.h:941
#define DD_ONE(dd)
Definition: cuddInt.h:911
#define DD_ZERO(dd)
Definition: cuddInt.h:927
DdNode* Cudd_addOr ( DdManager dd,
DdNode **  f,
DdNode **  g 
)

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

Synopsis [Disjunction of two 0-1 ADDs.]

Description [Disjunction of two 0-1 ADDs. Returns NULL if not a terminal case; f OR g otherwise.]

SideEffects [None]

SeeAlso [Cudd_addApply]

Definition at line 581 of file cuddAddApply.c.

585 {
586  DdNode *F, *G;
587 
588  F = *f; G = *g;
589  if (F == DD_ONE(dd) || G == DD_ONE(dd)) return(DD_ONE(dd));
590  if (cuddIsConstant(F)) return(G);
591  if (cuddIsConstant(G)) return(F);
592  if (F == G) return(F);
593  if (F > G) { /* swap f and g */
594  *f = G;
595  *g = F;
596  }
597  return(NULL);
598 
599 } /* end of Cudd_addOr */
Definition: cudd.h:278
#define cuddIsConstant(node)
Definition: cuddInt.h:620
#define DD_ONE(dd)
Definition: cuddInt.h:911
DdNode* Cudd_addOrAbstract ( DdManager manager,
DdNode f,
DdNode cube 
)

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

Synopsis [Disjunctively abstracts all the variables in cube from the 0-1 ADD f.]

Description [Abstracts all the variables in cube from the 0-1 ADD f by taking the disjunction over all possible values taken by the variables. Returns the abstracted ADD if successful; NULL otherwise.]

SideEffects [None]

SeeAlso [Cudd_addUnivAbstract Cudd_addExistAbstract]

Definition at line 216 of file cuddAddAbs.c.

220 {
221  DdNode *res;
222 
223  if (addCheckPositiveCube(manager, cube) == 0) {
224  (void) fprintf(manager->err,"Error: Can only abstract cubes");
225  return(NULL);
226  }
227 
228  do {
229  manager->reordered = 0;
230  res = cuddAddOrAbstractRecur(manager, f, cube);
231  } while (manager->reordered == 1);
232  return(res);
233 
234 } /* end of Cudd_addOrAbstract */
Definition: cudd.h:278
FILE * err
Definition: cuddInt.h:442
int reordered
Definition: cuddInt.h:409
static int addCheckPositiveCube(DdManager *manager, DdNode *cube)
Definition: cuddAddAbs.c:570
DdNode * cuddAddOrAbstractRecur(DdManager *manager, DdNode *f, DdNode *cube)
Definition: cuddAddAbs.c:469
DdNode* Cudd_addOuterSum ( DdManager dd,
DdNode M,
DdNode r,
DdNode c 
)

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

Synopsis [Takes the minimum of a matrix and the outer sum of two vectors.]

Description [Takes the pointwise minimum of a matrix and the outer sum of two vectors. This procedure is used in the Floyd-Warshall all-pair shortest path algorithm. Returns a pointer to the result if successful; NULL otherwise.]

SideEffects [None]

SeeAlso []

Definition at line 296 of file cuddMatMult.c.

301 {
302  DdNode *res;
303 
304  do {
305  dd->reordered = 0;
306  res = cuddAddOuterSumRecur(dd, M, r, c);
307  } while (dd->reordered == 1);
308  return(res);
309 
310 } /* end of Cudd_addOuterSum */
Definition: cudd.h:278
int reordered
Definition: cuddInt.h:409
static DdNode * cuddAddOuterSumRecur(DdManager *dd, DdNode *M, DdNode *r, DdNode *c)
Definition: cuddMatMult.c:639
DdNode* Cudd_addPermute ( DdManager manager,
DdNode node,
int *  permut 
)

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

Synopsis [Permutes the variables of an ADD.]

Description [Given a permutation in array permut, creates a new ADD 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. Returns a pointer to the resulting ADD if successful; NULL otherwise.]

SideEffects [None]

SeeAlso [Cudd_bddPermute Cudd_addSwapVariables]

Definition at line 242 of file cuddCompose.c.

246 {
247  DdHashTable *table;
248  DdNode *res;
249 
250  do {
251  manager->reordered = 0;
252  table = cuddHashTableInit(manager,1,2);
253  if (table == NULL) return(NULL);
254  /* Recursively solve the problem. */
255  res = cuddAddPermuteRecur(manager,table,node,permut);
256  if (res != NULL) cuddRef(res);
257  /* Dispose of local cache. */
258  cuddHashTableQuit(table);
259  } while (manager->reordered == 1);
260 
261  if (res != NULL) cuddDeref(res);
262  return(res);
263 
264 } /* end of Cudd_addPermute */
#define cuddRef(n)
Definition: cuddInt.h:584
#define cuddDeref(n)
Definition: cuddInt.h:604
Definition: cudd.h:278
int reordered
Definition: cuddInt.h:409
void cuddHashTableQuit(DdHashTable *hash)
Definition: cuddLCache.c:595
DdHashTable * cuddHashTableInit(DdManager *manager, unsigned int keySize, unsigned int initSize)
Definition: cuddLCache.c:538
static DdNode * cuddAddPermuteRecur(DdManager *manager, DdHashTable *table, DdNode *node, int *permut)
Definition: cuddCompose.c:1057
DdNode* Cudd_addPlus ( DdManager dd,
DdNode **  f,
DdNode **  g 
)

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

Synopsis [Integer and floating point addition.]

Description [Integer and floating point addition. Returns NULL if not a terminal case; f+g otherwise.]

SideEffects [None]

SeeAlso [Cudd_addApply]

Definition at line 168 of file cuddAddApply.c.

172 {
173  DdNode *res;
174  DdNode *F, *G;
176 
177  F = *f; G = *g;
178  if (F == DD_ZERO(dd)) return(G);
179  if (G == DD_ZERO(dd)) return(F);
180  if (cuddIsConstant(F) && cuddIsConstant(G)) {
181  value = cuddV(F)+cuddV(G);
182  res = cuddUniqueConst(dd,value);
183  return(res);
184  }
185  if (F > G) { /* swap f and g */
186  *f = G;
187  *g = F;
188  }
189  return(NULL);
190 
191 } /* end of Cudd_addPlus */
Definition: cudd.h:278
DdNode * cuddUniqueConst(DdManager *unique, CUDD_VALUE_TYPE value)
Definition: cuddTable.c:1450
#define cuddV(node)
Definition: cuddInt.h:668
#define cuddIsConstant(node)
Definition: cuddInt.h:620
#define CUDD_VALUE_TYPE
Definition: cudd.h:94
int value
#define DD_ZERO(dd)
Definition: cuddInt.h:927
int Cudd_addRead ( FILE *  fp,
DdManager dd,
DdNode **  E,
DdNode ***  x,
DdNode ***  y,
DdNode ***  xn,
DdNode ***  yn_,
int *  nx,
int *  ny,
int *  m,
int *  n,
int  bx,
int  sx,
int  by,
int  sy 
)

AutomaticStart AutomaticEnd Function********************************************************************

Synopsis [Reads in a sparse matrix.]

Description [Reads in a sparse matrix specified in a simple format. The first line of the input contains the numbers of rows and columns. The remaining lines contain the elements of the matrix, one per line. Given a background value (specified by the background field of the manager), only the values different from it are explicitly listed. Each foreground element is described by two integers, i.e., the row and column number, and a real number, i.e., the value.

Cudd_addRead produces an ADD that depends on two sets of variables: x and y. The x variables (x[0] ... x[nx-1]) encode the row index and the y variables (y[0] ... y[ny-1]) encode the column index. x[0] and y[0] are the most significant bits in the indices. The variables may already exist or may be created by the function. The index of x[i] is bx+i*sx, and the index of y[i] is by+i*sy.

On input, nx and ny hold the numbers of row and column variables already in existence. On output, they hold the numbers of row and column variables actually used by the matrix. When Cudd_addRead creates the variable arrays, the index of x[i] is bx+i*sx, and the index of y[i] is by+i*sy. When some variables already exist Cudd_addRead expects the indices of the existing x variables to be bx+i*sx, and the indices of the existing y variables to be by+i*sy.

m and n are set to the numbers of rows and columns of the matrix. Their values on input are immaterial. The ADD for the sparse matrix is returned in E, and its reference count is > 0. Cudd_addRead returns 1 in case of success; 0 otherwise.]

SideEffects [nx and ny are set to the numbers of row and column variables. m and n are set to the numbers of rows and columns. x and y are possibly extended to represent the array of row and column variables. Similarly for xn and yn_, which hold on return from Cudd_addRead the complements of the row and column variables.]

SeeAlso [Cudd_addHarwell Cudd_bddRead]

Definition at line 146 of file cuddRead.c.

162 {
163  DdNode *one, *zero;
164  DdNode *w, *neW;
165  DdNode *minterm1;
166  int u, v, err, i, nv;
167  int lnx, lny;
168  CUDD_VALUE_TYPE val;
169  DdNode **lx, **ly, **lxn, **lyn;
170 
171  one = DD_ONE(dd);
172  zero = DD_ZERO(dd);
173 
174  err = fscanf(fp, "%d %d", &u, &v);
175  if (err == EOF) {
176  return(0);
177  } else if (err != 2) {
178  return(0);
179  }
180 
181  *m = u;
182  /* Compute the number of x variables. */
183  lx = *x; lxn = *xn;
184  u--; /* row and column numbers start from 0 */
185  for (lnx=0; u > 0; lnx++) {
186  u >>= 1;
187  }
188  /* Here we rely on the fact that REALLOC of a null pointer is
189  ** translates to an ALLOC.
190  */
191  if (lnx > *nx) {
192  *x = lx = ABC_REALLOC(DdNode *, *x, lnx);
193  if (lx == NULL) {
195  return(0);
196  }
197  *xn = lxn = ABC_REALLOC(DdNode *, *xn, lnx);
198  if (lxn == NULL) {
200  return(0);
201  }
202  }
203 
204  *n = v;
205  /* Compute the number of y variables. */
206  ly = *y; lyn = *yn_;
207  v--; /* row and column numbers start from 0 */
208  for (lny=0; v > 0; lny++) {
209  v >>= 1;
210  }
211  /* Here we rely on the fact that REALLOC of a null pointer is
212  ** translates to an ALLOC.
213  */
214  if (lny > *ny) {
215  *y = ly = ABC_REALLOC(DdNode *, *y, lny);
216  if (ly == NULL) {
218  return(0);
219  }
220  *yn_ = lyn = ABC_REALLOC(DdNode *, *yn_, lny);
221  if (lyn == NULL) {
223  return(0);
224  }
225  }
226 
227  /* Create all new variables. */
228  for (i = *nx, nv = bx + (*nx) * sx; i < lnx; i++, nv += sx) {
229  do {
230  dd->reordered = 0;
231  lx[i] = cuddUniqueInter(dd, nv, one, zero);
232  } while (dd->reordered == 1);
233  if (lx[i] == NULL) return(0);
234  cuddRef(lx[i]);
235  do {
236  dd->reordered = 0;
237  lxn[i] = cuddUniqueInter(dd, nv, zero, one);
238  } while (dd->reordered == 1);
239  if (lxn[i] == NULL) return(0);
240  cuddRef(lxn[i]);
241  }
242  for (i = *ny, nv = by + (*ny) * sy; i < lny; i++, nv += sy) {
243  do {
244  dd->reordered = 0;
245  ly[i] = cuddUniqueInter(dd, nv, one, zero);
246  } while (dd->reordered == 1);
247  if (ly[i] == NULL) return(0);
248  cuddRef(ly[i]);
249  do {
250  dd->reordered = 0;
251  lyn[i] = cuddUniqueInter(dd, nv, zero, one);
252  } while (dd->reordered == 1);
253  if (lyn[i] == NULL) return(0);
254  cuddRef(lyn[i]);
255  }
256  *nx = lnx;
257  *ny = lny;
258 
259  *E = dd->background; /* this call will never cause reordering */
260  cuddRef(*E);
261 
262  while (! feof(fp)) {
263  err = fscanf(fp, "%d %d %lf", &u, &v, &val);
264  if (err == EOF) {
265  break;
266  } else if (err != 3) {
267  return(0);
268  } else if (u >= *m || v >= *n || u < 0 || v < 0) {
269  return(0);
270  }
271 
272  minterm1 = one; cuddRef(minterm1);
273 
274  /* Build minterm1 corresponding to this arc */
275  for (i = lnx - 1; i>=0; i--) {
276  if (u & 1) {
277  w = Cudd_addApply(dd, Cudd_addTimes, minterm1, lx[i]);
278  } else {
279  w = Cudd_addApply(dd, Cudd_addTimes, minterm1, lxn[i]);
280  }
281  if (w == NULL) {
282  Cudd_RecursiveDeref(dd, minterm1);
283  return(0);
284  }
285  cuddRef(w);
286  Cudd_RecursiveDeref(dd, minterm1);
287  minterm1 = w;
288  u >>= 1;
289  }
290  for (i = lny - 1; i>=0; i--) {
291  if (v & 1) {
292  w = Cudd_addApply(dd, Cudd_addTimes, minterm1, ly[i]);
293  } else {
294  w = Cudd_addApply(dd, Cudd_addTimes, minterm1, lyn[i]);
295  }
296  if (w == NULL) {
297  Cudd_RecursiveDeref(dd, minterm1);
298  return(0);
299  }
300  cuddRef(w);
301  Cudd_RecursiveDeref(dd, minterm1);
302  minterm1 = w;
303  v >>= 1;
304  }
305  /* Create new constant node if necessary.
306  ** This call will never cause reordering.
307  */
308  neW = cuddUniqueConst(dd, val);
309  if (neW == NULL) {
310  Cudd_RecursiveDeref(dd, minterm1);
311  return(0);
312  }
313  cuddRef(neW);
314 
315  w = Cudd_addIte(dd, minterm1, neW, *E);
316  if (w == NULL) {
317  Cudd_RecursiveDeref(dd, minterm1);
318  Cudd_RecursiveDeref(dd, neW);
319  return(0);
320  }
321  cuddRef(w);
322  Cudd_RecursiveDeref(dd, minterm1);
323  Cudd_RecursiveDeref(dd, neW);
324  Cudd_RecursiveDeref(dd, *E);
325  *E = w;
326  }
327  return(1);
328 
329 } /* end of Cudd_addRead */
#define cuddRef(n)
Definition: cuddInt.h:584
void Cudd_RecursiveDeref(DdManager *table, DdNode *n)
Definition: cuddRef.c:154
Definition: cudd.h:278
DdNode * cuddUniqueConst(DdManager *unique, CUDD_VALUE_TYPE value)
Definition: cuddTable.c:1450
#define ABC_REALLOC(type, obj, num)
Definition: abc_global.h:233
DdNode * Cudd_addApply(DdManager *dd, DdNode *(*)(DdManager *, DdNode **, DdNode **), DdNode *f, DdNode *g)
int reordered
Definition: cuddInt.h:409
static DdNode * one
Definition: cuddDecomp.c:112
DdNode * Cudd_addIte(DdManager *dd, DdNode *f, DdNode *g, DdNode *h)
Definition: cuddAddIte.c:129
#define CUDD_VALUE_TYPE
Definition: cudd.h:94
#define DD_ONE(dd)
Definition: cuddInt.h:911
DdNode * Cudd_addTimes(DdManager *dd, DdNode **f, DdNode **g)
Definition: cuddAddApply.c:208
Cudd_ErrorType errorCode
Definition: cuddInt.h:447
DdNode * cuddUniqueInter(DdManager *unique, int index, DdNode *T, DdNode *E)
Definition: cuddTable.c:1128
static DdNode * zero
Definition: cuddApa.c:100
DdNode * background
Definition: cuddInt.h:349
#define DD_ZERO(dd)
Definition: cuddInt.h:927
DdNode* Cudd_addResidue ( DdManager dd,
int  n,
int  m,
int  options,
int  top 
)

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

Synopsis [Builds an ADD for the residue modulo m of an n-bit number.]

Description [Builds an ADD for the residue modulo m of an n-bit number. The modulus must be at least 2, and the number of bits at least 1. Parameter options specifies whether the MSB should be on top or the LSB; and whther the number whose residue is computed is in two's complement notation or not. The macro CUDD_RESIDUE_DEFAULT specifies LSB on top and unsigned number. The macro CUDD_RESIDUE_MSB specifies MSB on top, and the macro CUDD_RESIDUE_TC specifies two's complement residue. To request MSB on top and two's complement residue simultaneously, one can OR the two macros: CUDD_RESIDUE_MSB | CUDD_RESIDUE_TC. Cudd_addResidue returns a pointer to the resulting ADD if successful; NULL otherwise.]

SideEffects [None]

SeeAlso []

Definition at line 161 of file cuddAddWalsh.c.

167 {
168  int msbLsb; /* MSB on top (1) or LSB on top (0) */
169  int tc; /* two's complement (1) or unsigned (0) */
170  int i, j, k, t, residue, thisOne, previous, index;
171  DdNode **array[2], *var, *tmp, *res;
172 
173  /* Sanity check. */
174  if (n < 1 && m < 2) return(NULL);
175 
176  msbLsb = options & CUDD_RESIDUE_MSB;
177  tc = options & CUDD_RESIDUE_TC;
178 
179  /* Allocate and initialize working arrays. */
180  array[0] = ABC_ALLOC(DdNode *,m);
181  if (array[0] == NULL) {
183  return(NULL);
184  }
185  array[1] = ABC_ALLOC(DdNode *,m);
186  if (array[1] == NULL) {
187  ABC_FREE(array[0]);
189  return(NULL);
190  }
191  for (i = 0; i < m; i++) {
192  array[0][i] = array[1][i] = NULL;
193  }
194 
195  /* Initialize residues. */
196  for (i = 0; i < m; i++) {
197  tmp = cuddUniqueConst(dd,(CUDD_VALUE_TYPE) i);
198  if (tmp == NULL) {
199  for (j = 0; j < i; j++) {
200  Cudd_RecursiveDeref(dd,array[1][j]);
201  }
202  ABC_FREE(array[0]);
203  ABC_FREE(array[1]);
204  return(NULL);
205  }
206  cuddRef(tmp);
207  array[1][i] = tmp;
208  }
209 
210  /* Main iteration. */
211  residue = 1; /* residue of 2**0 */
212  for (k = 0; k < n; k++) {
213  /* Choose current and previous arrays. */
214  thisOne = k & 1;
215  previous = thisOne ^ 1;
216  /* Build an ADD projection function. */
217  if (msbLsb) {
218  index = top+n-k-1;
219  } else {
220  index = top+k;
221  }
222  var = cuddUniqueInter(dd,index,DD_ONE(dd),DD_ZERO(dd));
223  if (var == NULL) {
224  for (j = 0; j < m; j++) {
225  Cudd_RecursiveDeref(dd,array[previous][j]);
226  }
227  ABC_FREE(array[0]);
228  ABC_FREE(array[1]);
229  return(NULL);
230  }
231  cuddRef(var);
232  for (i = 0; i < m; i ++) {
233  t = (i + residue) % m;
234  tmp = Cudd_addIte(dd,var,array[previous][t],array[previous][i]);
235  if (tmp == NULL) {
236  for (j = 0; j < i; j++) {
237  Cudd_RecursiveDeref(dd,array[thisOne][j]);
238  }
239  for (j = 0; j < m; j++) {
240  Cudd_RecursiveDeref(dd,array[previous][j]);
241  }
242  ABC_FREE(array[0]);
243  ABC_FREE(array[1]);
244  return(NULL);
245  }
246  cuddRef(tmp);
247  array[thisOne][i] = tmp;
248  }
249  /* One layer completed. Free the other array for the next iteration. */
250  for (i = 0; i < m; i++) {
251  Cudd_RecursiveDeref(dd,array[previous][i]);
252  }
253  Cudd_RecursiveDeref(dd,var);
254  /* Update residue of 2**k. */
255  residue = (2 * residue) % m;
256  /* Adjust residue for MSB, if this is a two's complement number. */
257  if (tc && (k == n - 1)) {
258  residue = (m - residue) % m;
259  }
260  }
261 
262  /* We are only interested in the 0-residue node of the top layer. */
263  for (i = 1; i < m; i++) {
264  Cudd_RecursiveDeref(dd,array[(n - 1) & 1][i]);
265  }
266  res = array[(n - 1) & 1][0];
267 
268  ABC_FREE(array[0]);
269  ABC_FREE(array[1]);
270 
271  cuddDeref(res);
272  return(res);
273 
274 } /* end of Cudd_addResidue */
#define cuddRef(n)
Definition: cuddInt.h:584
#define cuddDeref(n)
Definition: cuddInt.h:604
void Cudd_RecursiveDeref(DdManager *table, DdNode *n)
Definition: cuddRef.c:154
Definition: cudd.h:278
DdNode * cuddUniqueConst(DdManager *unique, CUDD_VALUE_TYPE value)
Definition: cuddTable.c:1450
int var(Lit p)
Definition: SolverTypes.h:62
#define ABC_ALLOC(type, num)
Definition: abc_global.h:229
#define CUDD_RESIDUE_TC
Definition: cudd.h:103
DdNode * Cudd_addIte(DdManager *dd, DdNode *f, DdNode *g, DdNode *h)
Definition: cuddAddIte.c:129
#define CUDD_VALUE_TYPE
Definition: cudd.h:94
#define ABC_FREE(obj)
Definition: abc_global.h:232
#define CUDD_RESIDUE_MSB
Definition: cudd.h:102
#define DD_ONE(dd)
Definition: cuddInt.h:911
Cudd_ErrorType errorCode
Definition: cuddInt.h:447
DdNode * cuddUniqueInter(DdManager *unique, int index, DdNode *T, DdNode *E)
Definition: cuddTable.c:1128
#define DD_ZERO(dd)
Definition: cuddInt.h:927
DdNode* Cudd_addRestrict ( DdManager dd,
DdNode f,
DdNode c 
)

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

Synopsis [ADD restrict according to Coudert and Madre's algorithm (ICCAD90).]

Description [ADD restrict according to Coudert and Madre's algorithm (ICCAD90). Returns the restricted ADD if successful; otherwise NULL. If application of restrict results in an ADD larger than the input ADD, the input ADD is returned.]

SideEffects [None]

SeeAlso [Cudd_addConstrain Cudd_bddRestrict]

Definition at line 431 of file cuddGenCof.c.

435 {
436  DdNode *supp_f, *supp_c;
437  DdNode *res, *commonSupport;
438  int intersection;
439  int sizeF, sizeRes;
440 
441  /* Check if supports intersect. */
442  supp_f = Cudd_Support(dd, f);
443  if (supp_f == NULL) {
444  return(NULL);
445  }
446  cuddRef(supp_f);
447  supp_c = Cudd_Support(dd, c);
448  if (supp_c == NULL) {
449  Cudd_RecursiveDeref(dd,supp_f);
450  return(NULL);
451  }
452  cuddRef(supp_c);
453  commonSupport = Cudd_bddLiteralSetIntersection(dd, supp_f, supp_c);
454  if (commonSupport == NULL) {
455  Cudd_RecursiveDeref(dd,supp_f);
456  Cudd_RecursiveDeref(dd,supp_c);
457  return(NULL);
458  }
459  cuddRef(commonSupport);
460  Cudd_RecursiveDeref(dd,supp_f);
461  Cudd_RecursiveDeref(dd,supp_c);
462  intersection = commonSupport != DD_ONE(dd);
463  Cudd_RecursiveDeref(dd,commonSupport);
464 
465  if (intersection) {
466  do {
467  dd->reordered = 0;
468  res = cuddAddRestrictRecur(dd, f, c);
469  } while (dd->reordered == 1);
470  sizeF = Cudd_DagSize(f);
471  sizeRes = Cudd_DagSize(res);
472  if (sizeF <= sizeRes) {
473  cuddRef(res);
474  Cudd_RecursiveDeref(dd, res);
475  return(f);
476  } else {
477  return(res);
478  }
479  } else {
480  return(f);
481  }
482 
483 } /* end of Cudd_addRestrict */
#define cuddRef(n)
Definition: cuddInt.h:584
void Cudd_RecursiveDeref(DdManager *table, DdNode *n)
Definition: cuddRef.c:154
Definition: cudd.h:278
DdNode * Cudd_Support(DdManager *dd, DdNode *f)
Definition: cuddUtil.c:740
int reordered
Definition: cuddInt.h:409
DdNode * Cudd_bddLiteralSetIntersection(DdManager *dd, DdNode *f, DdNode *g)
Definition: cuddLiteral.c:118
DdNode * cuddAddRestrictRecur(DdManager *dd, DdNode *f, DdNode *c)
Definition: cuddGenCof.c:1307
#define DD_ONE(dd)
Definition: cuddInt.h:911
int Cudd_DagSize(DdNode *node)
Definition: cuddUtil.c:442
DdNode* Cudd_addRoundOff ( DdManager dd,
DdNode f,
int  N 
)

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

Synopsis [Rounds off the discriminants of an ADD.]

Description [Rounds off the discriminants of an ADD. The discriminants are rounded off to N digits after the decimal. Returns a pointer to the result ADD if successful; NULL otherwise.]

SideEffects [None]

SeeAlso []

Definition at line 148 of file cuddAddNeg.c.

152 {
153  DdNode *res;
154  double trunc = pow(10.0,(double)N);
155 
156  do {
157  res = cuddAddRoundOffRecur(dd,f,trunc);
158  } while (dd->reordered == 1);
159  return(res);
160 
161 } /* end of Cudd_addRoundOff */
Definition: cudd.h:278
int reordered
Definition: cuddInt.h:409
DdNode * cuddAddRoundOffRecur(DdManager *dd, DdNode *f, double trunc)
Definition: cuddAddNeg.c:240
DdNode* Cudd_addScalarInverse ( DdManager dd,
DdNode f,
DdNode epsilon 
)

AutomaticStart AutomaticEnd Function********************************************************************

Synopsis [Computes the scalar inverse of an ADD.]

Description [Computes an n ADD where the discriminants are the multiplicative inverses of the corresponding discriminants of the argument ADD. Returns a pointer to the resulting ADD in case of success. Returns NULL if any discriminants smaller than epsilon is encountered.]

SideEffects [None]

Definition at line 120 of file cuddAddInv.c.

124 {
125  DdNode *res;
126 
127  if (!cuddIsConstant(epsilon)) {
128  (void) fprintf(dd->err,"Invalid epsilon\n");
129  return(NULL);
130  }
131  do {
132  dd->reordered = 0;
133  res = cuddAddScalarInverseRecur(dd,f,epsilon);
134  } while (dd->reordered == 1);
135  return(res);
136 
137 } /* end of Cudd_addScalarInverse */
Definition: cudd.h:278
FILE * err
Definition: cuddInt.h:442
int reordered
Definition: cuddInt.h:409
#define cuddIsConstant(node)
Definition: cuddInt.h:620
DdNode * cuddAddScalarInverseRecur(DdManager *dd, DdNode *f, DdNode *epsilon)
Definition: cuddAddInv.c:156
DdNode* Cudd_addSetNZ ( DdManager dd,
DdNode **  f,
DdNode **  g 
)

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

Synopsis [This operator sets f to the value of g wherever g != 0.]

Description [This operator sets f to the value of g wherever g != 0. Returns NULL if not a terminal case; f op g otherwise.]

SideEffects [None]

SeeAlso [Cudd_addApply]

Definition at line 282 of file cuddAddApply.c.

286 {
287  DdNode *F, *G;
288 
289  F = *f; G = *g;
290  if (F == G) return(F);
291  if (F == DD_ZERO(dd)) return(G);
292  if (G == DD_ZERO(dd)) return(F);
293  if (cuddIsConstant(G)) return(G);
294  return(NULL);
295 
296 } /* end of Cudd_addSetNZ */
Definition: cudd.h:278
#define cuddIsConstant(node)
Definition: cuddInt.h:620
#define DD_ZERO(dd)
Definition: cuddInt.h:927
DdNode* Cudd_addSwapVariables ( DdManager dd,
DdNode f,
DdNode **  x,
DdNode **  y,
int  n 
)

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

Synopsis [Swaps two sets of variables of the same size (x and y) in the ADD f.]

Description [Swaps two sets of variables of the same size (x and y) in the ADD f. The size is given by n. The two sets of variables are assumed to be disjoint. Returns a pointer to the resulting ADD if successful; NULL otherwise.]

SideEffects [None]

SeeAlso [Cudd_addPermute Cudd_bddSwapVariables]

Definition at line 283 of file cuddCompose.c.

289 {
290  DdNode *swapped;
291  int i, j, k;
292  int *permut;
293 
294  permut = ABC_ALLOC(int,dd->size);
295  if (permut == NULL) {
297  return(NULL);
298  }
299  for (i = 0; i < dd->size; i++) permut[i] = i;
300  for (i = 0; i < n; i++) {
301  j = x[i]->index;
302  k = y[i]->index;
303  permut[j] = k;
304  permut[k] = j;
305  }
306 
307  swapped = Cudd_addPermute(dd,f,permut);
308  ABC_FREE(permut);
309 
310  return(swapped);
311 
312 } /* end of Cudd_addSwapVariables */
Definition: cudd.h:278
int size
Definition: cuddInt.h:361
#define ABC_ALLOC(type, num)
Definition: abc_global.h:229
DdHalfWord index
Definition: cudd.h:279
#define ABC_FREE(obj)
Definition: abc_global.h:232
Cudd_ErrorType errorCode
Definition: cuddInt.h:447
DdNode * Cudd_addPermute(DdManager *manager, DdNode *node, int *permut)
Definition: cuddCompose.c:242
DdNode* Cudd_addThreshold ( DdManager dd,
DdNode **  f,
DdNode **  g 
)

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

Synopsis [f if f>=g; 0 if f<g.]

Description [Threshold operator for Apply (f if f >=g; 0 if f<g). Returns NULL if not a terminal case; f op g otherwise.]

SideEffects [None]

SeeAlso [Cudd_addApply]

Definition at line 248 of file cuddAddApply.c.

252 {
253  DdNode *F, *G;
254 
255  F = *f; G = *g;
256  if (F == G || F == DD_PLUS_INFINITY(dd)) return(F);
257  if (cuddIsConstant(F) && cuddIsConstant(G)) {
258  if (cuddV(F) >= cuddV(G)) {
259  return(F);
260  } else {
261  return(DD_ZERO(dd));
262  }
263  }
264  return(NULL);
265 
266 } /* end of Cudd_addThreshold */
Definition: cudd.h:278
#define cuddV(node)
Definition: cuddInt.h:668
#define cuddIsConstant(node)
Definition: cuddInt.h:620
#define DD_PLUS_INFINITY(dd)
Definition: cuddInt.h:941
#define DD_ZERO(dd)
Definition: cuddInt.h:927
DdNode* Cudd_addTimes ( DdManager dd,
DdNode **  f,
DdNode **  g 
)

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

Synopsis [Integer and floating point multiplication.]

Description [Integer and floating point multiplication. Returns NULL if not a terminal case; f * g otherwise. This function can be used also to take the AND of two 0-1 ADDs.]

SideEffects [None]

SeeAlso [Cudd_addApply]

Definition at line 208 of file cuddAddApply.c.

212 {
213  DdNode *res;
214  DdNode *F, *G;
216 
217  F = *f; G = *g;
218  if (F == DD_ZERO(dd) || G == DD_ZERO(dd)) return(DD_ZERO(dd));
219  if (F == DD_ONE(dd)) return(G);
220  if (G == DD_ONE(dd)) return(F);
221  if (cuddIsConstant(F) && cuddIsConstant(G)) {
222  value = cuddV(F)*cuddV(G);
223  res = cuddUniqueConst(dd,value);
224  return(res);
225  }
226  if (F > G) { /* swap f and g */
227  *f = G;
228  *g = F;
229  }
230  return(NULL);
231 
232 } /* end of Cudd_addTimes */
Definition: cudd.h:278
DdNode * cuddUniqueConst(DdManager *unique, CUDD_VALUE_TYPE value)
Definition: cuddTable.c:1450
#define cuddV(node)
Definition: cuddInt.h:668
#define cuddIsConstant(node)
Definition: cuddInt.h:620
#define CUDD_VALUE_TYPE
Definition: cudd.h:94
int value
#define DD_ONE(dd)
Definition: cuddInt.h:911
#define DD_ZERO(dd)
Definition: cuddInt.h:927
DdNode* Cudd_addTimesPlus ( DdManager dd,
DdNode A,
DdNode B,
DdNode **  z,
int  nz 
)

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

Synopsis [Calculates the product of two matrices represented as ADDs.]

Description [Calculates the product of two matrices, A and B, represented as ADDs, using the CMU matrix by matrix multiplication procedure by Clarke et al.. Matrix A has x's as row variables and z's as column variables, while matrix B has z's as row variables and y's as column variables. Returns the pointer to the result if successful; NULL otherwise. The resulting matrix has x's as row variables and y's as column variables.]

SideEffects [None]

SeeAlso [Cudd_addMatrixMultiply]

Definition at line 185 of file cuddMatMult.c.

191 {
192  DdNode *w, *cube, *tmp, *res;
193  int i;
194  tmp = Cudd_addApply(dd,Cudd_addTimes,A,B);
195  if (tmp == NULL) return(NULL);
196  Cudd_Ref(tmp);
197  Cudd_Ref(cube = DD_ONE(dd));
198  for (i = nz-1; i >= 0; i--) {
199  w = Cudd_addIte(dd,z[i],cube,DD_ZERO(dd));
200  if (w == NULL) {
201  Cudd_RecursiveDeref(dd,tmp);
202  return(NULL);
203  }
204  Cudd_Ref(w);
205  Cudd_RecursiveDeref(dd,cube);
206  cube = w;
207  }
208  res = Cudd_addExistAbstract(dd,tmp,cube);
209  if (res == NULL) {
210  Cudd_RecursiveDeref(dd,tmp);
211  Cudd_RecursiveDeref(dd,cube);
212  return(NULL);
213  }
214  Cudd_Ref(res);
215  Cudd_RecursiveDeref(dd,cube);
216  Cudd_RecursiveDeref(dd,tmp);
217  Cudd_Deref(res);
218  return(res);
219 
220 } /* end of Cudd_addTimesPlus */
void Cudd_RecursiveDeref(DdManager *table, DdNode *n)
Definition: cuddRef.c:154
Definition: cudd.h:278
void Cudd_Deref(DdNode *node)
Definition: cuddRef.c:438
DdNode * Cudd_addApply(DdManager *dd, DdNode *(*)(DdManager *, DdNode **, DdNode **), DdNode *f, DdNode *g)
DdNode * Cudd_addIte(DdManager *dd, DdNode *f, DdNode *g, DdNode *h)
Definition: cuddAddIte.c:129
DdNode * Cudd_addExistAbstract(DdManager *manager, DdNode *f, DdNode *cube)
Definition: cuddAddAbs.c:129
void Cudd_Ref(DdNode *n)
Definition: cuddRef.c:129
#define DD_ONE(dd)
Definition: cuddInt.h:911
DdNode * Cudd_addTimes(DdManager *dd, DdNode **f, DdNode **g)
Definition: cuddAddApply.c:208
#define DD_ZERO(dd)
Definition: cuddInt.h:927
DdNode* Cudd_addTriangle ( DdManager dd,
DdNode f,
DdNode g,
DdNode **  z,
int  nz 
)

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

Synopsis [Performs the triangulation step for the shortest path computation.]

Description [Implements the semiring multiplication algorithm used in the triangulation step for the shortest path computation. f is assumed to depend on variables x (rows) and z (columns). g is assumed to depend on variables z (rows) and y (columns). The product of f and g then depends on x (rows) and y (columns). Only the z variables have to be explicitly identified; they are the "abstraction" variables. Returns a pointer to the result if successful; NULL otherwise. ]

SideEffects [None]

SeeAlso [Cudd_addMatrixMultiply Cudd_bddAndAbstract]

Definition at line 243 of file cuddMatMult.c.

249 {
250  int i, nvars, *vars;
251  DdNode *res, *cube;
252 
253  nvars = dd->size;
254  vars = ABC_ALLOC(int, nvars);
255  if (vars == NULL) {
257  return(NULL);
258  }
259  for (i = 0; i < nvars; i++) vars[i] = -1;
260  for (i = 0; i < nz; i++) vars[z[i]->index] = i;
261  cube = Cudd_addComputeCube(dd, z, NULL, nz);
262  if (cube == NULL) {
263  ABC_FREE(vars);
264  return(NULL);
265  }
266  cuddRef(cube);
267 
268  do {
269  dd->reordered = 0;
270  res = addTriangleRecur(dd, f, g, vars, cube);
271  } while (dd->reordered == 1);
272  if (res != NULL) cuddRef(res);
273  Cudd_RecursiveDeref(dd,cube);
274  if (res != NULL) cuddDeref(res);
275  ABC_FREE(vars);
276  return(res);
277 
278 } /* end of Cudd_addTriangle */
#define cuddRef(n)
Definition: cuddInt.h:584
#define cuddDeref(n)
Definition: cuddInt.h:604
void Cudd_RecursiveDeref(DdManager *table, DdNode *n)
Definition: cuddRef.c:154
Definition: cudd.h:278
DdNode * Cudd_addComputeCube(DdManager *dd, DdNode **vars, int *phase, int n)
Definition: cuddUtil.c:2246
int size
Definition: cuddInt.h:361
#define ABC_ALLOC(type, num)
Definition: abc_global.h:229
int reordered
Definition: cuddInt.h:409
static DdNode * addTriangleRecur(DdManager *dd, DdNode *f, DdNode *g, int *vars, DdNode *cube)
Definition: cuddMatMult.c:544
#define ABC_FREE(obj)
Definition: abc_global.h:232
Cudd_ErrorType errorCode
Definition: cuddInt.h:447
DdNode* Cudd_addUnivAbstract ( DdManager manager,
DdNode f,
DdNode cube 
)

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

Synopsis [Universally Abstracts all the variables in cube from f.]

Description [Abstracts all the variables in cube from f by taking the product over all possible values taken by the variable. Returns the abstracted ADD if successful; NULL otherwise.]

SideEffects [None]

SeeAlso [Cudd_addExistAbstract Cudd_bddUnivAbstract Cudd_addOrAbstract]

Definition at line 178 of file cuddAddAbs.c.

182 {
183  DdNode *res;
184 
185  if (addCheckPositiveCube(manager, cube) == 0) {
186  (void) fprintf(manager->err,"Error: Can only abstract cubes");
187  return(NULL);
188  }
189 
190  do {
191  manager->reordered = 0;
192  res = cuddAddUnivAbstractRecur(manager, f, cube);
193  } while (manager->reordered == 1);
194 
195  return(res);
196 
197 } /* end of Cudd_addUnivAbstract */
Definition: cudd.h:278
DdNode * cuddAddUnivAbstractRecur(DdManager *manager, DdNode *f, DdNode *cube)
Definition: cuddAddAbs.c:361
FILE * err
Definition: cuddInt.h:442
int reordered
Definition: cuddInt.h:409
static int addCheckPositiveCube(DdManager *manager, DdNode *cube)
Definition: cuddAddAbs.c:570
DdNode* Cudd_addVectorCompose ( DdManager dd,
DdNode f,
DdNode **  vector 
)

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

Synopsis [Composes an ADD with a vector of 0-1 ADDs.]

Description [Given a vector of 0-1 ADDs, creates a new ADD by substituting the 0-1 ADDs for the variables of the ADD f. There should be an entry in vector for each variable in the manager. If no substitution is sought for a given variable, the corresponding projection function should be specified in the vector. This function implements simultaneous composition. Returns a pointer to the resulting ADD if successful; NULL otherwise.]

SideEffects [None]

SeeAlso [Cudd_addNonSimCompose Cudd_addPermute Cudd_addCompose Cudd_bddVectorCompose]

Definition at line 563 of file cuddCompose.c.

567 {
568  DdHashTable *table;
569  DdNode *res;
570  int deepest;
571  int i;
572 
573  do {
574  dd->reordered = 0;
575  /* Initialize local cache. */
576  table = cuddHashTableInit(dd,1,2);
577  if (table == NULL) return(NULL);
578 
579  /* Find deepest real substitution. */
580  for (deepest = dd->size - 1; deepest >= 0; deepest--) {
581  i = dd->invperm[deepest];
582  if (!ddIsIthAddVar(dd,vector[i],i)) {
583  break;
584  }
585  }
586 
587  /* Recursively solve the problem. */
588  res = cuddAddVectorComposeRecur(dd,table,f,vector,deepest);
589  if (res != NULL) cuddRef(res);
590 
591  /* Dispose of local cache. */
592  cuddHashTableQuit(table);
593  } while (dd->reordered == 1);
594 
595  if (res != NULL) cuddDeref(res);
596  return(res);
597 
598 } /* end of Cudd_addVectorCompose */
#define cuddRef(n)
Definition: cuddInt.h:584
#define cuddDeref(n)
Definition: cuddInt.h:604
Definition: cudd.h:278
int size
Definition: cuddInt.h:361
static DD_INLINE int ddIsIthAddVar(DdManager *dd, DdNode *f, unsigned int i)
Definition: cuddCompose.c:1721
int reordered
Definition: cuddInt.h:409
static DdNode * cuddAddVectorComposeRecur(DdManager *dd, DdHashTable *table, DdNode *f, DdNode **vector, int deepest)
Definition: cuddCompose.c:1307
void cuddHashTableQuit(DdHashTable *hash)
Definition: cuddLCache.c:595
DdHashTable * cuddHashTableInit(DdManager *manager, unsigned int keySize, unsigned int initSize)
Definition: cuddLCache.c:538
int * invperm
Definition: cuddInt.h:388
DdNode* Cudd_addWalsh ( DdManager dd,
DdNode **  x,
DdNode **  y,
int  n 
)

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

Synopsis [Generates a Walsh matrix in ADD form.]

Description [Generates a Walsh matrix in ADD form. Returns a pointer to the matrixi if successful; NULL otherwise.]

SideEffects [None]

Definition at line 120 of file cuddAddWalsh.c.

125 {
126  DdNode *res;
127 
128  do {
129  dd->reordered = 0;
130  res = addWalshInt(dd, x, y, n);
131  } while (dd->reordered == 1);
132  return(res);
133 
134 } /* end of Cudd_addWalsh */
Definition: cudd.h:278
int reordered
Definition: cuddInt.h:409
static DdNode * addWalshInt(DdManager *dd, DdNode **x, DdNode **y, int n)
Definition: cuddAddWalsh.c:298
DdNode* Cudd_addXeqy ( DdManager dd,
int  N,
DdNode **  x,
DdNode **  y 
)

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

Synopsis [Generates an ADD for the function x==y.]

Description [This function generates an ADD for the function x==y. Both x and y are N-bit numbers, x[0] x[1] ... x[N-1] and y[0] y[1] ... y[N-1], with 0 the most significant bit. The ADD is built bottom-up. It has 3*N-1 internal nodes, if the variables are ordered as follows: x[0] y[0] x[1] y[1] ... x[N-1] y[N-1]. ]

SideEffects [None]

SeeAlso [Cudd_Xeqy]

Definition at line 408 of file cuddPriority.c.

413 {
414  DdNode *one, *zero;
415  DdNode *u, *v, *w;
416  int i;
417 
418  one = DD_ONE(dd);
419  zero = DD_ZERO(dd);
420 
421  /* Build bottom part of ADD outside loop. */
422  v = Cudd_addIte(dd, y[N-1], one, zero);
423  if (v == NULL) return(NULL);
424  cuddRef(v);
425  w = Cudd_addIte(dd, y[N-1], zero, one);
426  if (w == NULL) {
427  Cudd_RecursiveDeref(dd, v);
428  return(NULL);
429  }
430  cuddRef(w);
431  u = Cudd_addIte(dd, x[N-1], v, w);
432  if (u == NULL) {
433  Cudd_RecursiveDeref(dd, v);
434  Cudd_RecursiveDeref(dd, w);
435  return(NULL);
436  }
437  cuddRef(u);
438  Cudd_RecursiveDeref(dd, v);
439  Cudd_RecursiveDeref(dd, w);
440 
441  /* Loop to build the rest of the ADD. */
442  for (i = N-2; i >= 0; i--) {
443  v = Cudd_addIte(dd, y[i], u, zero);
444  if (v == NULL) {
445  Cudd_RecursiveDeref(dd, u);
446  return(NULL);
447  }
448  cuddRef(v);
449  w = Cudd_addIte(dd, y[i], zero, u);
450  if (w == NULL) {
451  Cudd_RecursiveDeref(dd, u);
452  Cudd_RecursiveDeref(dd, v);
453  return(NULL);
454  }
455  cuddRef(w);
456  Cudd_RecursiveDeref(dd, u);
457  u = Cudd_addIte(dd, x[i], v, w);
458  if (w == NULL) {
459  Cudd_RecursiveDeref(dd, v);
460  Cudd_RecursiveDeref(dd, w);
461  return(NULL);
462  }
463  cuddRef(u);
464  Cudd_RecursiveDeref(dd, v);
465  Cudd_RecursiveDeref(dd, w);
466  }
467  cuddDeref(u);
468  return(u);
469 
470 } /* end of Cudd_addXeqy */
#define cuddRef(n)
Definition: cuddInt.h:584
#define cuddDeref(n)
Definition: cuddInt.h:604
void Cudd_RecursiveDeref(DdManager *table, DdNode *n)
Definition: cuddRef.c:154
Definition: cudd.h:278
static DdNode * one
Definition: cuddDecomp.c:112
DdNode * Cudd_addIte(DdManager *dd, DdNode *f, DdNode *g, DdNode *h)
Definition: cuddAddIte.c:129
#define DD_ONE(dd)
Definition: cuddInt.h:911
static DdNode * zero
Definition: cuddApa.c:100
#define DD_ZERO(dd)
Definition: cuddInt.h:927
DdNode* Cudd_addXnor ( DdManager dd,
DdNode **  f,
DdNode **  g 
)

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

Synopsis [XNOR of two 0-1 ADDs.]

Description [XNOR of two 0-1 ADDs. Returns NULL if not a terminal case; f XNOR g otherwise.]

SideEffects [None]

SeeAlso [Cudd_addApply]

Definition at line 713 of file cuddAddApply.c.

717 {
718  DdNode *F, *G;
719 
720  F = *f; G = *g;
721  if (F == G) return(DD_ONE(dd));
722  if (F == DD_ONE(dd) && G == DD_ONE(dd)) return(DD_ONE(dd));
723  if (G == DD_ZERO(dd) && F == DD_ZERO(dd)) return(DD_ONE(dd));
724  if (cuddIsConstant(F) && cuddIsConstant(G)) return(DD_ZERO(dd));
725  if (F > G) { /* swap f and g */
726  *f = G;
727  *g = F;
728  }
729  return(NULL);
730 
731 } /* end of Cudd_addXnor */
Definition: cudd.h:278
#define cuddIsConstant(node)
Definition: cuddInt.h:620
#define DD_ONE(dd)
Definition: cuddInt.h:911
#define DD_ZERO(dd)
Definition: cuddInt.h:927
DdNode* Cudd_addXor ( DdManager dd,
DdNode **  f,
DdNode **  g 
)

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

Synopsis [XOR of two 0-1 ADDs.]

Description [XOR of two 0-1 ADDs. Returns NULL if not a terminal case; f XOR g otherwise.]

SideEffects [None]

SeeAlso [Cudd_addApply]

Definition at line 679 of file cuddAddApply.c.

683 {
684  DdNode *F, *G;
685 
686  F = *f; G = *g;
687  if (F == G) return(DD_ZERO(dd));
688  if (F == DD_ONE(dd) && G == DD_ZERO(dd)) return(DD_ONE(dd));
689  if (G == DD_ONE(dd) && F == DD_ZERO(dd)) return(DD_ONE(dd));
690  if (cuddIsConstant(F) && cuddIsConstant(G)) return(DD_ZERO(dd));
691  if (F > G) { /* swap f and g */
692  *f = G;
693  *g = F;
694  }
695  return(NULL);
696 
697 } /* end of Cudd_addXor */
Definition: cudd.h:278
#define cuddIsConstant(node)
Definition: cuddInt.h:620
#define DD_ONE(dd)
Definition: cuddInt.h:911
#define DD_ZERO(dd)
Definition: cuddInt.h:927
DdApaDigit Cudd_ApaAdd ( int  digits,
DdApaNumber  a,
DdApaNumber  b,
DdApaNumber  sum 
)

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

Synopsis [Adds two arbitrary precision integers.]

Description [Adds two arbitrary precision integers. Returns the carry out of the most significant digit.]

SideEffects [The result of the sum is stored in parameter sum.]

SeeAlso []

Definition at line 221 of file cuddApa.c.

226 {
227  int i;
228  DdApaDoubleDigit partial = 0;
229 
230  for (i = digits - 1; i >= 0; i--) {
231  partial = a[i] + b[i] + DD_MSDIGIT(partial);
232  sum[i] = (DdApaDigit) DD_LSDIGIT(partial);
233  }
234  return((DdApaDigit) DD_MSDIGIT(partial));
235 
236 } /* end of Cudd_ApaAdd */
unsigned short int DdApaDigit
Definition: cudd.h:303
unsigned int DdApaDoubleDigit
Definition: cudd.h:304
#define DD_LSDIGIT(x)
Definition: cuddInt.h:995
#define DD_MSDIGIT(x)
Definition: cuddInt.h:1010
int Cudd_ApaCompare ( int  digitsFirst,
DdApaNumber  first,
int  digitsSecond,
DdApaNumber  second 
)

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

Synopsis [Compares two arbitrary precision integers.]

Description [Compares two arbitrary precision integers. Returns 1 if the first number is larger; 0 if they are equal; -1 if the second number is larger.]

SideEffects [None]

SeeAlso []

Definition at line 449 of file cuddApa.c.

454 {
455  int i;
456  int firstNZ, secondNZ;
457 
458  /* Find first non-zero in both numbers. */
459  for (firstNZ = 0; firstNZ < digitsFirst; firstNZ++)
460  if (first[firstNZ] != 0) break;
461  for (secondNZ = 0; secondNZ < digitsSecond; secondNZ++)
462  if (second[secondNZ] != 0) break;
463  if (digitsFirst - firstNZ > digitsSecond - secondNZ) return(1);
464  else if (digitsFirst - firstNZ < digitsSecond - secondNZ) return(-1);
465  for (i = 0; i < digitsFirst - firstNZ; i++) {
466  if (first[firstNZ + i] > second[secondNZ + i]) return(1);
467  else if (first[firstNZ + i] < second[secondNZ + i]) return(-1);
468  }
469  return(0);
470 
471 } /* end of Cudd_ApaCompare */
int Cudd_ApaCompareRatios ( int  digitsFirst,
DdApaNumber  firstNum,
unsigned int  firstDen,
int  digitsSecond,
DdApaNumber  secondNum,
unsigned int  secondDen 
)

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

Synopsis [Compares the ratios of two arbitrary precision integers to two unsigned ints.]

Description [Compares the ratios of two arbitrary precision integers to two unsigned ints. Returns 1 if the first number is larger; 0 if they are equal; -1 if the second number is larger.]

SideEffects [None]

SeeAlso []

Definition at line 489 of file cuddApa.c.

496 {
497  int result;
498  DdApaNumber first, second;
499  unsigned int firstRem, secondRem;
500 
501  first = Cudd_NewApaNumber(digitsFirst);
502  firstRem = Cudd_ApaIntDivision(digitsFirst,firstNum,firstDen,first);
503  second = Cudd_NewApaNumber(digitsSecond);
504  secondRem = Cudd_ApaIntDivision(digitsSecond,secondNum,secondDen,second);
505  result = Cudd_ApaCompare(digitsFirst,first,digitsSecond,second);
506  ABC_FREE(first);
507  ABC_FREE(second);
508  if (result == 0) {
509  if ((double)firstRem/firstDen > (double)secondRem/secondDen)
510  return(1);
511  else if ((double)firstRem/firstDen < (double)secondRem/secondDen)
512  return(-1);
513  }
514  return(result);
515 
516 } /* end of Cudd_ApaCompareRatios */
int Cudd_ApaCompare(int digitsFirst, DdApaNumber first, int digitsSecond, DdApaNumber second)
Definition: cuddApa.c:449
DdApaDigit * DdApaNumber
Definition: cudd.h:306
unsigned int Cudd_ApaIntDivision(int digits, DdApaNumber dividend, unsigned int divisor, DdApaNumber quotient)
Definition: cuddApa.c:324
#define ABC_FREE(obj)
Definition: abc_global.h:232
DdApaNumber Cudd_NewApaNumber(int digits)
Definition: cuddApa.c:174
static int result
Definition: cuddGenetic.c:125
void Cudd_ApaCopy ( int  digits,
DdApaNumber  source,
DdApaNumber  dest 
)

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

Synopsis [Makes a copy of an arbitrary precision integer.]

Description [Makes a copy of an arbitrary precision integer.]

SideEffects [Changes parameter dest.]

SeeAlso []

Definition at line 194 of file cuddApa.c.

198 {
199  int i;
200 
201  for (i = 0; i < digits; i++) {
202  dest[i] = source[i];
203  }
204 
205 } /* end of Cudd_ApaCopy */
DdApaNumber Cudd_ApaCountMinterm ( DdManager manager,
DdNode node,
int  nvars,
int *  digits 
)

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

Synopsis [Counts the number of minterms of a DD.]

Description [Counts the number of minterms of a DD. The function is assumed to depend on nvars variables. The minterm count is represented as an arbitrary precision unsigned integer, to allow for any number of variables CUDD supports. Returns a pointer to the array representing the number of minterms of the function rooted at node if successful; NULL otherwise.]

SideEffects [The number of digits of the result is returned in parameter digits.]

SeeAlso [Cudd_CountMinterm]

Definition at line 684 of file cuddApa.c.

689 {
690  DdApaNumber max, min;
691  st__table *table;
692  DdApaNumber i,count;
693 
694  background = manager->background;
695  zero = Cudd_Not(manager->one);
696 
697  *digits = Cudd_ApaNumberOfDigits(nvars+1);
698  max = Cudd_NewApaNumber(*digits);
699  if (max == NULL) {
700  return(NULL);
701  }
702  Cudd_ApaPowerOfTwo(*digits,max,nvars);
703  min = Cudd_NewApaNumber(*digits);
704  if (min == NULL) {
705  ABC_FREE(max);
706  return(NULL);
707  }
708  Cudd_ApaSetToLiteral(*digits,min,0);
710  if (table == NULL) {
711  ABC_FREE(max);
712  ABC_FREE(min);
713  return(NULL);
714  }
715  i = cuddApaCountMintermAux(Cudd_Regular(node),*digits,max,min,table);
716  if (i == NULL) {
717  ABC_FREE(max);
718  ABC_FREE(min);
719  st__foreach(table, cuddApaStCountfree, NULL);
720  st__free_table(table);
721  return(NULL);
722  }
723  count = Cudd_NewApaNumber(*digits);
724  if (count == NULL) {
725  ABC_FREE(max);
726  ABC_FREE(min);
727  st__foreach(table, cuddApaStCountfree, NULL);
728  st__free_table(table);
729  if (Cudd_Regular(node)->ref == 1) ABC_FREE(i);
730  return(NULL);
731  }
732  if (Cudd_IsComplement(node)) {
733  (void) Cudd_ApaSubtract(*digits,max,i,count);
734  } else {
735  Cudd_ApaCopy(*digits,i,count);
736  }
737  ABC_FREE(max);
738  ABC_FREE(min);
739  st__foreach(table, cuddApaStCountfree, NULL);
740  st__free_table(table);
741  if (Cudd_Regular(node)->ref == 1) ABC_FREE(i);
742  return(count);
743 
744 } /* end of Cudd_ApaCountMinterm */
void st__free_table(st__table *table)
Definition: st.c:81
#define Cudd_Not(node)
Definition: cudd.h:367
#define Cudd_Regular(node)
Definition: cudd.h:397
int st__ptrcmp(const char *, const char *)
Definition: st.c:480
static DdNode * background
Definition: cuddApa.c:100
int Cudd_ApaNumberOfDigits(int binaryDigits)
Definition: cuddApa.c:147
void Cudd_ApaSetToLiteral(int digits, DdApaNumber number, DdApaDigit literal)
Definition: cuddApa.c:389
void Cudd_ApaCopy(int digits, DdApaNumber source, DdApaNumber dest)
Definition: cuddApa.c:194
st__table * st__init_table(st__compare_func_type compare, st__hash_func_type hash)
Definition: st.c:72
#define Cudd_IsComplement(node)
Definition: cudd.h:425
Definition: st.h:52
static double max
Definition: cuddSubsetHB.c:134
DdApaDigit Cudd_ApaSubtract(int digits, DdApaNumber a, DdApaNumber b, DdApaNumber diff)
Definition: cuddApa.c:253
int st__foreach(st__table *table, enum st__retval(*func)(char *, char *, char *), char *arg)
Definition: st.c:421
DdApaDigit * DdApaNumber
Definition: cudd.h:306
#define ABC_FREE(obj)
Definition: abc_global.h:232
DdNode * one
Definition: cuddInt.h:345
DdApaNumber Cudd_NewApaNumber(int digits)
Definition: cuddApa.c:174
void Cudd_ApaPowerOfTwo(int digits, DdApaNumber number, int power)
Definition: cuddApa.c:417
static enum st__retval cuddApaStCountfree(char *key, char *value, char *arg)
Definition: cuddApa.c:972
int st__ptrhash(const char *, int)
Definition: st.c:468
static DdNode * zero
Definition: cuddApa.c:100
static DdApaNumber cuddApaCountMintermAux(DdNode *node, int digits, DdApaNumber max, DdApaNumber min, st__table *table)
Definition: cuddApa.c:899
DdNode * background
Definition: cuddInt.h:349
unsigned int Cudd_ApaIntDivision ( int  digits,
DdApaNumber  dividend,
unsigned int  divisor,
DdApaNumber  quotient 
)

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

Synopsis [Divides an arbitrary precision integer by an integer.]

Description [Divides an arbitrary precision integer by a 32-bit unsigned integer. Returns the remainder of the division. This procedure relies on the assumption that the number of bits of a DdApaDigit plus the number of bits of an unsigned int is less the number of bits of the mantissa of a double. This guarantees that the product of a DdApaDigit and an unsigned int can be represented without loss of precision by a double. On machines where this assumption is not satisfied, this procedure will malfunction.]

SideEffects [The quotient is returned in parameter quotient.]

SeeAlso [Cudd_ApaShortDivision]

Definition at line 324 of file cuddApa.c.

329 {
330  int i;
331  double partial;
332  unsigned int remainder = 0;
333  double ddiv = (double) divisor;
334 
335  for (i = 0; i < digits; i++) {
336  partial = (double) remainder * DD_APA_BASE + dividend[i];
337  quotient[i] = (DdApaDigit) (partial / ddiv);
338  remainder = (unsigned int) (partial - ((double)quotient[i] * ddiv));
339  }
340 
341  return(remainder);
342 
343 } /* end of Cudd_ApaIntDivision */
unsigned short int DdApaDigit
Definition: cudd.h:303
#define DD_APA_BASE
Definition: cudd.h:130
int Cudd_ApaNumberOfDigits ( int  binaryDigits)

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

Synopsis [Finds the number of digits for an arbitrary precision integer.]

Description [Finds the number of digits for an arbitrary precision integer given the maximum number of binary digits. The number of binary digits should be positive. Returns the number of digits if successful; 0 otherwise.]

SideEffects [None]

SeeAlso []

Definition at line 147 of file cuddApa.c.

149 {
150  int digits;
151 
152  digits = binaryDigits / DD_APA_BITS;
153  if ((digits * DD_APA_BITS) != binaryDigits)
154  digits++;
155  return(digits);
156 
157 } /* end of Cudd_ApaNumberOfDigits */
#define DD_APA_BITS
Definition: cudd.h:129
void Cudd_ApaPowerOfTwo ( int  digits,
DdApaNumber  number,
int  power 
)

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

Synopsis [Sets an arbitrary precision integer to a power of two.]

Description [Sets an arbitrary precision integer to a power of two. If the power of two is too large to be represented, the number is set to 0.]

SideEffects [The result is returned in parameter number.]

SeeAlso []

Definition at line 417 of file cuddApa.c.

421 {
422  int i;
423  int index;
424 
425  for (i = 0; i < digits; i++)
426  number[i] = 0;
427  i = digits - 1 - power / DD_APA_BITS;
428  if (i < 0) return;
429  index = power & (DD_APA_BITS - 1);
430  number[i] = 1 << index;
431 
432 } /* end of Cudd_ApaPowerOfTwo */
#define DD_APA_BITS
Definition: cudd.h:129
int Cudd_ApaPrintDecimal ( FILE *  fp,
int  digits,
DdApaNumber  number 
)

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

Synopsis [Prints an arbitrary precision integer in decimal format.]

Description [Prints an arbitrary precision integer in decimal format. Returns 1 if successful; 0 otherwise.]

SideEffects [None]

SeeAlso [Cudd_ApaPrintHex Cudd_ApaPrintExponential]

Definition at line 562 of file cuddApa.c.

566 {
567  int i, result;
568  DdApaDigit remainder;
569  DdApaNumber work;
570  unsigned char *decimal;
571  int leadingzero;
572  int decimalDigits = (int) (digits * log10((double) DD_APA_BASE)) + 1;
573 
574  work = Cudd_NewApaNumber(digits);
575  if (work == NULL)
576  return(0);
577  decimal = ABC_ALLOC(unsigned char, decimalDigits);
578  if (decimal == NULL) {
579  ABC_FREE(work);
580  return(0);
581  }
582  Cudd_ApaCopy(digits,number,work);
583  for (i = decimalDigits - 1; i >= 0; i--) {
584  remainder = Cudd_ApaShortDivision(digits,work,(DdApaDigit) 10,work);
585  decimal[i] = (unsigned char) remainder;
586  }
587  ABC_FREE(work);
588 
589  leadingzero = 1;
590  for (i = 0; i < decimalDigits; i++) {
591  leadingzero = leadingzero && (decimal[i] == 0);
592  if ((!leadingzero) || (i == (decimalDigits - 1))) {
593  result = fprintf(fp,"%1d",decimal[i]);
594  if (result == EOF) {
595  ABC_FREE(decimal);
596  return(0);
597  }
598  }
599  }
600  ABC_FREE(decimal);
601  return(1);
602 
603 } /* end of Cudd_ApaPrintDecimal */
#define ABC_ALLOC(type, num)
Definition: abc_global.h:229
unsigned short int DdApaDigit
Definition: cudd.h:303
void Cudd_ApaCopy(int digits, DdApaNumber source, DdApaNumber dest)
Definition: cuddApa.c:194
#define DD_APA_BASE
Definition: cudd.h:130
DdApaDigit Cudd_ApaShortDivision(int digits, DdApaNumber dividend, DdApaDigit divisor, DdApaNumber quotient)
Definition: cuddApa.c:283
DdApaDigit * DdApaNumber
Definition: cudd.h:306
#define ABC_FREE(obj)
Definition: abc_global.h:232
DdApaNumber Cudd_NewApaNumber(int digits)
Definition: cuddApa.c:174
static int result
Definition: cuddGenetic.c:125
int Cudd_ApaPrintDensity ( FILE *  fp,
DdManager dd,
DdNode node,
int  nvars 
)

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

Synopsis [Prints the density of a BDD or ADD using arbitrary precision arithmetic.]

Description [Prints the density of a BDD or ADD using arbitrary precision arithmetic. Returns 1 if successful; 0 otherwise.]

SideEffects [None]

SeeAlso []

Definition at line 838 of file cuddApa.c.

843 {
844  int digits;
845  int result;
846  DdApaNumber count,density;
847  unsigned int size, remainder, fractional;
848 
849  count = Cudd_ApaCountMinterm(dd,node,nvars,&digits);
850  if (count == NULL)
851  return(0);
852  size = Cudd_DagSize(node);
853  density = Cudd_NewApaNumber(digits);
854  remainder = Cudd_ApaIntDivision(digits,count,size,density);
855  result = Cudd_ApaPrintDecimal(fp,digits,density);
856  ABC_FREE(count);
857  ABC_FREE(density);
858  fractional = (unsigned int)((double)remainder / size * 1000000);
859  if (fprintf(fp,".%u\n", fractional) == EOF) {
860  return(0);
861  }
862  return(result);
863 
864 } /* end of Cudd_ApaPrintDensity */
DdApaNumber Cudd_ApaCountMinterm(DdManager *manager, DdNode *node, int nvars, int *digits)
Definition: cuddApa.c:684
static int size
Definition: cuddSign.c:86
DdApaDigit * DdApaNumber
Definition: cudd.h:306
unsigned int Cudd_ApaIntDivision(int digits, DdApaNumber dividend, unsigned int divisor, DdApaNumber quotient)
Definition: cuddApa.c:324
#define ABC_FREE(obj)
Definition: abc_global.h:232
int Cudd_ApaPrintDecimal(FILE *fp, int digits, DdApaNumber number)
Definition: cuddApa.c:562
DdApaNumber Cudd_NewApaNumber(int digits)
Definition: cuddApa.c:174
static int result
Definition: cuddGenetic.c:125
int Cudd_DagSize(DdNode *node)
Definition: cuddUtil.c:442
int Cudd_ApaPrintExponential ( FILE *  fp,
int  digits,
DdApaNumber  number,
int  precision 
)

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

Synopsis [Prints an arbitrary precision integer in exponential format.]

Description [Prints an arbitrary precision integer in exponential format. Returns 1 if successful; 0 otherwise.]

SideEffects [None]

SeeAlso [Cudd_ApaPrintHex Cudd_ApaPrintDecimal]

Definition at line 619 of file cuddApa.c.

624 {
625  int i, first, last, result;
626  DdApaDigit remainder;
627  DdApaNumber work;
628  unsigned char *decimal;
629  int decimalDigits = (int) (digits * log10((double) DD_APA_BASE)) + 1;
630 
631  work = Cudd_NewApaNumber(digits);
632  if (work == NULL)
633  return(0);
634  decimal = ABC_ALLOC(unsigned char, decimalDigits);
635  if (decimal == NULL) {
636  ABC_FREE(work);
637  return(0);
638  }
639  Cudd_ApaCopy(digits,number,work);
640  first = decimalDigits - 1;
641  for (i = decimalDigits - 1; i >= 0; i--) {
642  remainder = Cudd_ApaShortDivision(digits,work,(DdApaDigit) 10,work);
643  decimal[i] = (unsigned char) remainder;
644  if (remainder != 0) first = i; /* keep track of MS non-zero */
645  }
646  ABC_FREE(work);
647  last = ddMin(first + precision, decimalDigits);
648 
649  for (i = first; i < last; i++) {
650  result = fprintf(fp,"%s%1d",i == first+1 ? "." : "", decimal[i]);
651  if (result == EOF) {
652  ABC_FREE(decimal);
653  return(0);
654  }
655  }
656  ABC_FREE(decimal);
657  result = fprintf(fp,"e+%d",decimalDigits - first - 1);
658  if (result == EOF) {
659  return(0);
660  }
661  return(1);
662 
663 } /* end of Cudd_ApaPrintExponential */
#define ABC_ALLOC(type, num)
Definition: abc_global.h:229
unsigned short int DdApaDigit
Definition: cudd.h:303
void Cudd_ApaCopy(int digits, DdApaNumber source, DdApaNumber dest)
Definition: cuddApa.c:194
#define DD_APA_BASE
Definition: cudd.h:130
DdApaDigit Cudd_ApaShortDivision(int digits, DdApaNumber dividend, DdApaDigit divisor, DdApaNumber quotient)
Definition: cuddApa.c:283
#define ddMin(x, y)
Definition: cuddInt.h:818
DdApaDigit * DdApaNumber
Definition: cudd.h:306
#define ABC_FREE(obj)
Definition: abc_global.h:232
DdApaNumber Cudd_NewApaNumber(int digits)
Definition: cuddApa.c:174
static int result
Definition: cuddGenetic.c:125
int Cudd_ApaPrintHex ( FILE *  fp,
int  digits,
DdApaNumber  number 
)

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

Synopsis [Prints an arbitrary precision integer in hexadecimal format.]

Description [Prints an arbitrary precision integer in hexadecimal format. Returns 1 if successful; 0 otherwise.]

SideEffects [None]

SeeAlso [Cudd_ApaPrintDecimal Cudd_ApaPrintExponential]

Definition at line 532 of file cuddApa.c.

536 {
537  int i, result;
538 
539  for (i = 0; i < digits; i++) {
540  result = fprintf(fp,DD_APA_HEXPRINT,number[i]);
541  if (result == EOF)
542  return(0);
543  }
544  return(1);
545 
546 } /* end of Cudd_ApaPrintHex */
#define DD_APA_HEXPRINT
Definition: cudd.h:131
static int result
Definition: cuddGenetic.c:125
int Cudd_ApaPrintMinterm ( FILE *  fp,
DdManager dd,
DdNode node,
int  nvars 
)

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

Synopsis [Prints the number of minterms of a BDD or ADD using arbitrary precision arithmetic.]

Description [Prints the number of minterms of a BDD or ADD using arbitrary precision arithmetic. Returns 1 if successful; 0 otherwise.]

SideEffects [None]

SeeAlso [Cudd_ApaPrintMintermExp]

Definition at line 761 of file cuddApa.c.

766 {
767  int digits;
768  int result;
769  DdApaNumber count;
770 
771  count = Cudd_ApaCountMinterm(dd,node,nvars,&digits);
772  if (count == NULL)
773  return(0);
774  result = Cudd_ApaPrintDecimal(fp,digits,count);
775  ABC_FREE(count);
776  if (fprintf(fp,"\n") == EOF) {
777  return(0);
778  }
779  return(result);
780 
781 } /* end of Cudd_ApaPrintMinterm */
DdApaNumber Cudd_ApaCountMinterm(DdManager *manager, DdNode *node, int nvars, int *digits)
Definition: cuddApa.c:684
DdApaDigit * DdApaNumber
Definition: cudd.h:306
#define ABC_FREE(obj)
Definition: abc_global.h:232
int Cudd_ApaPrintDecimal(FILE *fp, int digits, DdApaNumber number)
Definition: cuddApa.c:562
static int result
Definition: cuddGenetic.c:125
int Cudd_ApaPrintMintermExp ( FILE *  fp,
DdManager dd,
DdNode node,
int  nvars,
int  precision 
)

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

Synopsis [Prints the number of minterms of a BDD or ADD in exponential format using arbitrary precision arithmetic.]

Description [Prints the number of minterms of a BDD or ADD in exponential format using arbitrary precision arithmetic. Parameter precision controls the number of signficant digits printed. Returns 1 if successful; 0 otherwise.]

SideEffects [None]

SeeAlso [Cudd_ApaPrintMinterm]

Definition at line 800 of file cuddApa.c.

806 {
807  int digits;
808  int result;
809  DdApaNumber count;
810 
811  count = Cudd_ApaCountMinterm(dd,node,nvars,&digits);
812  if (count == NULL)
813  return(0);
814  result = Cudd_ApaPrintExponential(fp,digits,count,precision);
815  ABC_FREE(count);
816  if (fprintf(fp,"\n") == EOF) {
817  return(0);
818  }
819  return(result);
820 
821 } /* end of Cudd_ApaPrintMintermExp */
DdApaNumber Cudd_ApaCountMinterm(DdManager *manager, DdNode *node, int nvars, int *digits)
Definition: cuddApa.c:684
DdApaDigit * DdApaNumber
Definition: cudd.h:306
#define ABC_FREE(obj)
Definition: abc_global.h:232
static int result
Definition: cuddGenetic.c:125
int Cudd_ApaPrintExponential(FILE *fp, int digits, DdApaNumber number, int precision)
Definition: cuddApa.c:619
void Cudd_ApaSetToLiteral ( int  digits,
DdApaNumber  number,
DdApaDigit  literal 
)

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

Synopsis [Sets an arbitrary precision integer to a one-digit literal.]

Description [Sets an arbitrary precision integer to a one-digit literal.]

SideEffects [The result is returned in parameter number.]

SeeAlso []

Definition at line 389 of file cuddApa.c.

393 {
394  int i;
395 
396  for (i = 0; i < digits - 1; i++)
397  number[i] = 0;
398  number[digits - 1] = literal;
399 
400 } /* end of Cudd_ApaSetToLiteral */
void Cudd_ApaShiftRight ( int  digits,
DdApaDigit  in,
DdApaNumber  a,
DdApaNumber  b 
)

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

Synopsis [Shifts right an arbitrary precision integer by one binary place.]

Description [Shifts right an arbitrary precision integer by one binary place. The most significant binary digit of the result is taken from parameter in.]

SideEffects [The result is returned in parameter b.]

SeeAlso []

Definition at line 361 of file cuddApa.c.

366 {
367  int i;
368 
369  for (i = digits - 1; i > 0; i--) {
370  b[i] = (a[i] >> 1) | ((a[i-1] & 1) << (DD_APA_BITS - 1));
371  }
372  b[0] = (a[0] >> 1) | (in << (DD_APA_BITS - 1));
373 
374 } /* end of Cudd_ApaShiftRight */
#define DD_APA_BITS
Definition: cudd.h:129
DdApaDigit Cudd_ApaShortDivision ( int  digits,
DdApaNumber  dividend,
DdApaDigit  divisor,
DdApaNumber  quotient 
)

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

Synopsis [Divides an arbitrary precision integer by a digit.]

Description [Divides an arbitrary precision integer by a digit.]

SideEffects [The quotient is returned in parameter quotient.]

SeeAlso []

Definition at line 283 of file cuddApa.c.

288 {
289  int i;
290  DdApaDigit remainder;
291  DdApaDoubleDigit partial;
292 
293  remainder = 0;
294  for (i = 0; i < digits; i++) {
295  partial = remainder * DD_APA_BASE + dividend[i];
296  quotient[i] = (DdApaDigit) (partial/(DdApaDoubleDigit)divisor);
297  remainder = (DdApaDigit) (partial % divisor);
298  }
299 
300  return(remainder);
301 
302 } /* end of Cudd_ApaShortDivision */
unsigned short int DdApaDigit
Definition: cudd.h:303
#define DD_APA_BASE
Definition: cudd.h:130
unsigned int DdApaDoubleDigit
Definition: cudd.h:304
DdApaDigit Cudd_ApaSubtract ( int  digits,
DdApaNumber  a,
DdApaNumber  b,
DdApaNumber  diff 
)

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

Synopsis [Subtracts two arbitrary precision integers.]

Description [Subtracts two arbitrary precision integers. Returns the borrow out of the most significant digit.]

SideEffects [The result of the subtraction is stored in parameter diff.]

SeeAlso []

Definition at line 253 of file cuddApa.c.

258 {
259  int i;
260  DdApaDoubleDigit partial = DD_APA_BASE;
261 
262  for (i = digits - 1; i >= 0; i--) {
263  partial = DD_MSDIGIT(partial) + DD_APA_MASK + a[i] - b[i];
264  diff[i] = (DdApaDigit) DD_LSDIGIT(partial);
265  }
266  return((DdApaDigit) DD_MSDIGIT(partial) - 1);
267 
268 } /* end of Cudd_ApaSubtract */
unsigned short int DdApaDigit
Definition: cudd.h:303
#define DD_APA_BASE
Definition: cudd.h:130
unsigned int DdApaDoubleDigit
Definition: cudd.h:304
#define DD_LSDIGIT(x)
Definition: cuddInt.h:995
#define DD_MSDIGIT(x)
Definition: cuddInt.h:1010
#define DD_APA_MASK
Definition: cudd.h:133
void Cudd_AutodynDisable ( DdManager unique)

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

Synopsis [Disables automatic dynamic reordering.]

Description []

SideEffects [None]

SeeAlso [Cudd_AutodynEnable Cudd_ReorderingStatus Cudd_AutodynDisableZdd]

Definition at line 708 of file cuddAPI.c.

710 {
711  unique->autoDyn = 0;
712  return;
713 
714 } /* end of Cudd_AutodynDisable */
int autoDyn
Definition: cuddInt.h:416
void Cudd_AutodynDisableZdd ( DdManager unique)

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

Synopsis [Disables automatic dynamic reordering of ZDDs.]

Description []

SideEffects [None]

SeeAlso [Cudd_AutodynEnableZdd Cudd_ReorderingStatusZdd Cudd_AutodynDisable]

Definition at line 786 of file cuddAPI.c.

788 {
789  unique->autoDynZ = 0;
790  return;
791 
792 } /* end of Cudd_AutodynDisableZdd */
int autoDynZ
Definition: cuddInt.h:417
void Cudd_AutodynEnable ( DdManager unique,
Cudd_ReorderingType  method 
)

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

Synopsis [Enables automatic dynamic reordering of BDDs and ADDs.]

Description [Enables automatic dynamic reordering of BDDs and ADDs. Parameter method is used to determine the method used for reordering. If CUDD_REORDER_SAME is passed, the method is unchanged.]

SideEffects [None]

SeeAlso [Cudd_AutodynDisable Cudd_ReorderingStatus Cudd_AutodynEnableZdd]

Definition at line 669 of file cuddAPI.c.

672 {
673  unique->autoDyn = 1;
674  if (method != CUDD_REORDER_SAME) {
675  unique->autoMethod = method;
676  }
677 #ifndef DD_NO_DEATH_ROW
678  /* If reordering is enabled, using the death row causes too many
679  ** invocations. Hence, we shrink the death row to just one entry.
680  */
681  cuddClearDeathRow(unique);
682  unique->deathRowDepth = 1;
683  unique->deadMask = unique->deathRowDepth - 1;
684  if ((unsigned) unique->nextDead > unique->deadMask) {
685  unique->nextDead = 0;
686  }
687  unique->deathRow = ABC_REALLOC(DdNodePtr, unique->deathRow,
688  unique->deathRowDepth);
689 #endif
690  return;
691 
692 } /* end of Cudd_AutodynEnable */
Cudd_ReorderingType autoMethod
Definition: cuddInt.h:418
Definition: cudd.h:278
unsigned deadMask
Definition: cuddInt.h:404
#define ABC_REALLOC(type, obj, num)
Definition: abc_global.h:233
DdNode ** deathRow
Definition: cuddInt.h:401
int nextDead
Definition: cuddInt.h:403
int deathRowDepth
Definition: cuddInt.h:402
void cuddClearDeathRow(DdManager *table)
Definition: cuddRef.c:726
int autoDyn
Definition: cuddInt.h:416
void Cudd_AutodynEnableZdd ( DdManager unique,
Cudd_ReorderingType  method 
)

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

Synopsis [Enables automatic dynamic reordering of ZDDs.]

Description [Enables automatic dynamic reordering of ZDDs. Parameter method is used to determine the method used for reordering ZDDs. If CUDD_REORDER_SAME is passed, the method is unchanged.]

SideEffects [None]

SeeAlso [Cudd_AutodynDisableZdd Cudd_ReorderingStatusZdd Cudd_AutodynEnable]

Definition at line 760 of file cuddAPI.c.

763 {
764  unique->autoDynZ = 1;
765  if (method != CUDD_REORDER_SAME) {
766  unique->autoMethodZ = method;
767  }
768  return;
769 
770 } /* end of Cudd_AutodynEnableZdd */
Cudd_ReorderingType autoMethodZ
Definition: cuddInt.h:419
int autoDynZ
Definition: cuddInt.h:417
double Cudd_AverageDistance ( DdManager dd)

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

Synopsis [Computes the average distance between adjacent nodes.]

Description [Computes the average distance between adjacent nodes in the manager. Adjacent nodes are node pairs such that the second node is the then child, else child, or next node in the collision list.]

SideEffects [None]

SeeAlso []

Definition at line 2614 of file cuddUtil.c.

2616 {
2617  double tetotal, nexttotal;
2618  double tesubtotal, nextsubtotal;
2619  double temeasured, nextmeasured;
2620  int i, j;
2621  int slots, nvars;
2622  long diff;
2623  DdNode *scan;
2624  DdNodePtr *nodelist;
2625  DdNode *sentinel = &(dd->sentinel);
2626 
2627  nvars = dd->size;
2628  if (nvars == 0) return(0.0);
2629 
2630  /* Initialize totals. */
2631  tetotal = 0.0;
2632  nexttotal = 0.0;
2633  temeasured = 0.0;
2634  nextmeasured = 0.0;
2635 
2636  /* Scan the variable subtables. */
2637  for (i = 0; i < nvars; i++) {
2638  nodelist = dd->subtables[i].nodelist;
2639  tesubtotal = 0.0;
2640  nextsubtotal = 0.0;
2641  slots = dd->subtables[i].slots;
2642  for (j = 0; j < slots; j++) {
2643  scan = nodelist[j];
2644  while (scan != sentinel) {
2645  diff = (long) scan - (long) cuddT(scan);
2646  tesubtotal += (double) ddAbs(diff);
2647  diff = (long) scan - (long) Cudd_Regular(cuddE(scan));
2648  tesubtotal += (double) ddAbs(diff);
2649  temeasured += 2.0;
2650  if (scan->next != sentinel) {
2651  diff = (long) scan - (long) scan->next;
2652  nextsubtotal += (double) ddAbs(diff);
2653  nextmeasured += 1.0;
2654  }
2655  scan = scan->next;
2656  }
2657  }
2658  tetotal += tesubtotal;
2659  nexttotal += nextsubtotal;
2660  }
2661 
2662  /* Scan the constant table. */
2663  nodelist = dd->constants.nodelist;
2664  nextsubtotal = 0.0;
2665  slots = dd->constants.slots;
2666  for (j = 0; j < slots; j++) {
2667  scan = nodelist[j];
2668  while (scan != NULL) {
2669  if (scan->next != NULL) {
2670  diff = (long) scan - (long) scan->next;
2671  nextsubtotal += (double) ddAbs(diff);
2672  nextmeasured += 1.0;
2673  }
2674  scan = scan->next;
2675  }
2676  }
2677  nexttotal += nextsubtotal;
2678 
2679  return((tetotal + nexttotal) / (temeasured + nextmeasured));
2680 
2681 } /* end of Cudd_AverageDistance */
Definition: cudd.h:278
int size
Definition: cuddInt.h:361
#define Cudd_Regular(node)
Definition: cudd.h:397
DdSubtable * subtables
Definition: cuddInt.h:365
DdNode sentinel
Definition: cuddInt.h:344
DdNode * next
Definition: cudd.h:281
#define ddAbs(x)
Definition: cuddInt.h:846
DdNode ** nodelist
Definition: cuddInt.h:327
#define cuddT(node)
Definition: cuddInt.h:636
unsigned int slots
Definition: cuddInt.h:329
#define cuddE(node)
Definition: cuddInt.h:652
DdSubtable constants
Definition: cuddInt.h:367
DdNode* Cudd_bddAdjPermuteX ( DdManager dd,
DdNode B,
DdNode **  x,
int  n 
)

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

Synopsis [Rearranges a set of variables in the BDD B.]

Description [Rearranges a set of variables in the BDD B. The size of the set is given by n. This procedure is intended for the `randomization' of the priority functions. Returns a pointer to the BDD if successful; NULL otherwise.]

SideEffects [None]

SeeAlso [Cudd_bddPermute Cudd_bddSwapVariables Cudd_Dxygtdxz Cudd_Dxygtdyz Cudd_PrioritySelect]

Definition at line 512 of file cuddCompose.c.

517 {
518  DdNode *swapped;
519  int i, j, k;
520  int *permut;
521 
522  permut = ABC_ALLOC(int,dd->size);
523  if (permut == NULL) {
525  return(NULL);
526  }
527  for (i = 0; i < dd->size; i++) permut[i] = i;
528  for (i = 0; i < n-2; i += 3) {
529  j = x[i]->index;
530  k = x[i+1]->index;
531  permut[j] = k;
532  permut[k] = j;
533  }
534 
535  swapped = Cudd_bddPermute(dd,B,permut);
536  ABC_FREE(permut);
537 
538  return(swapped);
539 
540 } /* end of Cudd_bddAdjPermuteX */
Definition: cudd.h:278
int size
Definition: cuddInt.h:361
#define ABC_ALLOC(type, num)
Definition: abc_global.h:229
DdNode * Cudd_bddPermute(DdManager *manager, DdNode *node, int *permut)
Definition: cuddCompose.c:332
DdHalfWord index
Definition: cudd.h:279
#define ABC_FREE(obj)
Definition: abc_global.h:232
Cudd_ErrorType errorCode
Definition: cuddInt.h:447
DdNode* Cudd_bddAnd ( DdManager dd,
DdNode f,
DdNode g 
)

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

Synopsis [Computes the conjunction of two BDDs f and g.]

Description [Computes the conjunction of two BDDs f and g. Returns a pointer to the resulting BDD if successful; NULL if the intermediate result blows up.]

SideEffects [None]

SeeAlso [Cudd_bddIte Cudd_addApply Cudd_bddAndAbstract Cudd_bddIntersect Cudd_bddOr Cudd_bddNand Cudd_bddNor Cudd_bddXor Cudd_bddXnor]

Definition at line 314 of file cuddBddIte.c.

318 {
319  DdNode *res;
320 
321  do {
322  dd->reordered = 0;
323  res = cuddBddAndRecur(dd,f,g);
324  } while (dd->reordered == 1);
325  return(res);
326 
327 } /* end of Cudd_bddAnd */
Definition: cudd.h:278
int reordered
Definition: cuddInt.h:409
DdNode * cuddBddAndRecur(DdManager *manager, DdNode *f, DdNode *g)
Definition: cuddBddIte.c:886
DdNode* Cudd_bddAndAbstract ( DdManager manager,
DdNode f,
DdNode g,
DdNode cube 
)

AutomaticStart AutomaticEnd Function********************************************************************

Synopsis [Takes the AND of two BDDs and simultaneously abstracts the variables in cube.]

Description [Takes the AND of two BDDs and simultaneously abstracts the variables in cube. The variables are existentially abstracted. Returns a pointer to the result is successful; NULL otherwise. Cudd_bddAndAbstract implements the semiring matrix multiplication algorithm for the boolean semiring.]

SideEffects [None]

SeeAlso [Cudd_addMatrixMultiply Cudd_addTriangle Cudd_bddAnd]

Definition at line 124 of file cuddAndAbs.c.

129 {
130  DdNode *res;
131 
132  do {
133  manager->reordered = 0;
134  res = cuddBddAndAbstractRecur(manager, f, g, cube);
135  } while (manager->reordered == 1);
136  return(res);
137 
138 } /* end of Cudd_bddAndAbstract */
Definition: cudd.h:278
DdNode * cuddBddAndAbstractRecur(DdManager *manager, DdNode *f, DdNode *g, DdNode *cube)
Definition: cuddAndAbs.c:200
int reordered
Definition: cuddInt.h:409
DdNode* Cudd_bddAndAbstractLimit ( DdManager manager,
DdNode f,
DdNode g,
DdNode cube,
unsigned int  limit 
)

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

Synopsis [Takes the AND of two BDDs and simultaneously abstracts the variables in cube. Returns NULL if too many nodes are required.]

Description [Takes the AND of two BDDs and simultaneously abstracts the variables in cube. The variables are existentially abstracted. Returns a pointer to the result is successful; NULL otherwise. In particular, if the number of new nodes created exceeds limit, this function returns NULL.]

SideEffects [None]

SeeAlso [Cudd_bddAndAbstract]

Definition at line 158 of file cuddAndAbs.c.

164 {
165  DdNode *res;
166  unsigned int saveLimit = manager->maxLive;
167 
168  manager->maxLive = (manager->keys - manager->dead) +
169  (manager->keysZ - manager->deadZ) + limit;
170  do {
171  manager->reordered = 0;
172  res = cuddBddAndAbstractRecur(manager, f, g, cube);
173  } while (manager->reordered == 1);
174  manager->maxLive = saveLimit;
175  return(res);
176 
177 } /* end of Cudd_bddAndAbstractLimit */
Definition: cudd.h:278
unsigned int deadZ
Definition: cuddInt.h:372
DdNode * cuddBddAndAbstractRecur(DdManager *manager, DdNode *f, DdNode *g, DdNode *cube)
Definition: cuddAndAbs.c:200
int reordered
Definition: cuddInt.h:409
unsigned int dead
Definition: cuddInt.h:371
unsigned int maxLive
Definition: cuddInt.h:373
unsigned int keys
Definition: cuddInt.h:369
unsigned int keysZ
Definition: cuddInt.h:370
DdNode* Cudd_bddAndLimit ( DdManager dd,
DdNode f,
DdNode g,
unsigned int  limit 
)

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

Synopsis [Computes the conjunction of two BDDs f and g. Returns NULL if too many nodes are required.]

Description [Computes the conjunction of two BDDs f and g. Returns a pointer to the resulting BDD if successful; NULL if the intermediate result blows up or more new nodes than limit are required.]

SideEffects [None]

SeeAlso [Cudd_bddAnd]

Definition at line 346 of file cuddBddIte.c.

351 {
352  DdNode *res;
353  unsigned int saveLimit = dd->maxLive;
354 
355  dd->maxLive = (dd->keys - dd->dead) + (dd->keysZ - dd->deadZ) + limit;
356  do {
357  dd->reordered = 0;
358  res = cuddBddAndRecur(dd,f,g);
359  } while (dd->reordered == 1);
360  dd->maxLive = saveLimit;
361  return(res);
362 
363 } /* end of Cudd_bddAndLimit */
Definition: cudd.h:278
unsigned int deadZ
Definition: cuddInt.h:372
int reordered
Definition: cuddInt.h:409
unsigned int dead
Definition: cuddInt.h:371
unsigned int maxLive
Definition: cuddInt.h:373
unsigned int keys
Definition: cuddInt.h:369
unsigned int keysZ
Definition: cuddInt.h:370
DdNode * cuddBddAndRecur(DdManager *manager, DdNode *f, DdNode *g)
Definition: cuddBddIte.c:886
int Cudd_bddApproxConjDecomp ( DdManager dd,
DdNode f,
DdNode ***  conjuncts 
)

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

Synopsis [Performs two-way conjunctive decomposition of a BDD.]

Description [Performs two-way conjunctive decomposition of a BDD. This procedure owes its name to the use of supersetting to obtain an initial factor of the given function. Returns the number of conjuncts produced, that is, 2 if successful; 1 if no meaningful decomposition was found; 0 otherwise. The conjuncts produced by this procedure tend to be imbalanced.]

SideEffects [The factors are returned in an array as side effects. The array is allocated by this function. It is the caller's responsibility to free it. On successful completion, the conjuncts are already referenced. If the function returns 0, the array for the conjuncts is not allocated. If the function returns 1, the only factor equals the function to be decomposed.]

SeeAlso [Cudd_bddApproxDisjDecomp Cudd_bddIterConjDecomp Cudd_bddGenConjDecomp Cudd_bddVarConjDecomp Cudd_RemapOverApprox Cudd_bddSqueeze Cudd_bddLICompaction]

Definition at line 175 of file cuddDecomp.c.

179 {
180  DdNode *superset1, *superset2, *glocal, *hlocal;
181  int nvars = Cudd_SupportSize(dd,f);
182 
183  /* Find a tentative first factor by overapproximation and minimization. */
184  superset1 = Cudd_RemapOverApprox(dd,f,nvars,0,1.0);
185  if (superset1 == NULL) return(0);
186  cuddRef(superset1);
187  superset2 = Cudd_bddSqueeze(dd,f,superset1);
188  if (superset2 == NULL) {
189  Cudd_RecursiveDeref(dd,superset1);
190  return(0);
191  }
192  cuddRef(superset2);
193  Cudd_RecursiveDeref(dd,superset1);
194 
195  /* Compute the second factor by minimization. */
196  hlocal = Cudd_bddLICompaction(dd,f,superset2);
197  if (hlocal == NULL) {
198  Cudd_RecursiveDeref(dd,superset2);
199  return(0);
200  }
201  cuddRef(hlocal);
202 
203  /* Refine the first factor by minimization. If h turns out to be f, this
204  ** step guarantees that g will be 1. */
205  glocal = Cudd_bddLICompaction(dd,superset2,hlocal);
206  if (glocal == NULL) {
207  Cudd_RecursiveDeref(dd,superset2);
208  Cudd_RecursiveDeref(dd,hlocal);
209  return(0);
210  }
211  cuddRef(glocal);
212  Cudd_RecursiveDeref(dd,superset2);
213 
214  if (glocal != DD_ONE(dd)) {
215  if (hlocal != DD_ONE(dd)) {
216  *conjuncts = ABC_ALLOC(DdNode *,2);
217  if (*conjuncts == NULL) {
218  Cudd_RecursiveDeref(dd,glocal);
219  Cudd_RecursiveDeref(dd,hlocal);
221  return(0);
222  }
223  (*conjuncts)[0] = glocal;
224  (*conjuncts)[1] = hlocal;
225  return(2);
226  } else {
227  Cudd_RecursiveDeref(dd,hlocal);
228  *conjuncts = ABC_ALLOC(DdNode *,1);
229  if (*conjuncts == NULL) {
230  Cudd_RecursiveDeref(dd,glocal);
232  return(0);
233  }
234  (*conjuncts)[0] = glocal;
235  return(1);
236  }
237  } else {
238  Cudd_RecursiveDeref(dd,glocal);
239  *conjuncts = ABC_ALLOC(DdNode *,1);
240  if (*conjuncts == NULL) {
241  Cudd_RecursiveDeref(dd,hlocal);
243  return(0);
244  }
245  (*conjuncts)[0] = hlocal;
246  return(1);
247  }
248 
249 } /* end of Cudd_bddApproxConjDecomp */
#define cuddRef(n)
Definition: cuddInt.h:584
void Cudd_RecursiveDeref(DdManager *table, DdNode *n)
Definition: cuddRef.c:154
Definition: cudd.h:278
DdNode * Cudd_RemapOverApprox(DdManager *dd, DdNode *f, int numVars, int threshold, double quality)
Definition: cuddApprox.c:366
#define ABC_ALLOC(type, num)
Definition: abc_global.h:229
DdNode * Cudd_bddLICompaction(DdManager *dd, DdNode *f, DdNode *c)
Definition: cuddGenCof.c:570
#define DD_ONE(dd)
Definition: cuddInt.h:911
int Cudd_SupportSize(DdManager *dd, DdNode *f)
Definition: cuddUtil.c:857
Cudd_ErrorType errorCode
Definition: cuddInt.h:447
DdNode * Cudd_bddSqueeze(DdManager *dd, DdNode *l, DdNode *u)
Definition: cuddGenCof.c:602
int Cudd_bddApproxDisjDecomp ( DdManager dd,
DdNode f,
DdNode ***  disjuncts 
)

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

Synopsis [Performs two-way disjunctive decomposition of a BDD.]

Description [Performs two-way disjunctive decomposition of a BDD. Returns the number of disjuncts produced, that is, 2 if successful; 1 if no meaningful decomposition was found; 0 otherwise. The disjuncts produced by this procedure tend to be imbalanced.]

SideEffects [The two disjuncts are returned in an array as side effects. The array is allocated by this function. It is the caller's responsibility to free it. On successful completion, the disjuncts are already referenced. If the function returns 0, the array for the disjuncts is not allocated. If the function returns 1, the only factor equals the function to be decomposed.]

SeeAlso [Cudd_bddApproxConjDecomp Cudd_bddIterDisjDecomp Cudd_bddGenDisjDecomp Cudd_bddVarDisjDecomp]

Definition at line 273 of file cuddDecomp.c.

277 {
278  int result, i;
279 
280  result = Cudd_bddApproxConjDecomp(dd,Cudd_Not(f),disjuncts);
281  for (i = 0; i < result; i++) {
282  (*disjuncts)[i] = Cudd_Not((*disjuncts)[i]);
283  }
284  return(result);
285 
286 } /* end of Cudd_bddApproxDisjDecomp */
#define Cudd_Not(node)
Definition: cudd.h:367
int Cudd_bddApproxConjDecomp(DdManager *dd, DdNode *f, DdNode ***conjuncts)
Definition: cuddDecomp.c:175
static int result
Definition: cuddGenetic.c:125
int Cudd_bddBindVar ( DdManager dd,
int  index 
)

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

Synopsis [Prevents sifting of a variable.]

Description [This function sets a flag to prevent sifting of a variable. Returns 1 if successful; 0 otherwise (i.e., invalid variable index).]

SideEffects [Changes the "bindVar" flag in DdSubtable.]

SeeAlso [Cudd_bddUnbindVar]

Definition at line 3899 of file cuddAPI.c.

3902 {
3903  if (index >= dd->size || index < 0) return(0);
3904  dd->subtables[dd->perm[index]].bindVar = 1;
3905  return(1);
3906 
3907 } /* end of Cudd_bddBindVar */
int size
Definition: cuddInt.h:361
int bindVar
Definition: cuddInt.h:334
DdSubtable * subtables
Definition: cuddInt.h:365
int * perm
Definition: cuddInt.h:386
DdNode* Cudd_bddBooleanDiff ( DdManager manager,
DdNode f,
int  x 
)

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

Synopsis [Computes the boolean difference of f with respect to x.]

Description [Computes the boolean difference of f with respect to the variable with index x. Returns the BDD of the boolean difference if successful; NULL otherwise.]

SideEffects [None]

SeeAlso []

Definition at line 246 of file cuddBddAbs.c.

250 {
251  DdNode *res, *var;
252 
253  /* If the variable is not currently in the manager, f cannot
254  ** depend on it.
255  */
256  if (x >= manager->size) return(Cudd_Not(DD_ONE(manager)));
257  var = manager->vars[x];
258 
259  do {
260  manager->reordered = 0;
261  res = cuddBddBooleanDiffRecur(manager, Cudd_Regular(f), var);
262  } while (manager->reordered == 1);
263 
264  return(res);
265 
266 } /* end of Cudd_bddBooleanDiff */
Definition: cudd.h:278
#define Cudd_Not(node)
Definition: cudd.h:367
int size
Definition: cuddInt.h:361
int var(Lit p)
Definition: SolverTypes.h:62
#define Cudd_Regular(node)
Definition: cudd.h:397
int reordered
Definition: cuddInt.h:409
DdNode * cuddBddBooleanDiffRecur(DdManager *manager, DdNode *f, DdNode *var)
Definition: cuddBddAbs.c:636
DdNode ** vars
Definition: cuddInt.h:390
#define DD_ONE(dd)
Definition: cuddInt.h:911
DdNode** Cudd_bddCharToVect ( DdManager dd,
DdNode f 
)

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

Synopsis [Computes a vector whose image equals a non-zero function.]

Description [Computes a vector of BDDs whose image equals a non-zero function. The result depends on the variable order. The i-th component of the vector depends only on the first i variables in the order. Each BDD in the vector is not larger than the BDD of the given characteristic function. This function is based on the description of char-to-vect in "Verification of Sequential Machines Using Boolean Functional Vectors" by O. Coudert, C. Berthet and J. C. Madre. Returns a pointer to an array containing the result if successful; NULL otherwise. The size of the array equals the number of variables in the manager. The components of the solution have their reference counts already incremented (unlike the results of most other functions in the package).]

SideEffects [None]

SeeAlso [Cudd_bddConstrain]

Definition at line 510 of file cuddGenCof.c.

513 {
514  int i, j;
515  DdNode **vect;
516  DdNode *res = NULL;
517 
518  if (f == Cudd_Not(DD_ONE(dd))) return(NULL);
519 
520  vect = ABC_ALLOC(DdNode *, dd->size);
521  if (vect == NULL) {
523  return(NULL);
524  }
525 
526  do {
527  dd->reordered = 0;
528  for (i = 0; i < dd->size; i++) {
529  res = cuddBddCharToVect(dd,f,dd->vars[dd->invperm[i]]);
530  if (res == NULL) {
531  /* Clean up the vector array in case reordering took place. */
532  for (j = 0; j < i; j++) {
533  Cudd_IterDerefBdd(dd, vect[dd->invperm[j]]);
534  }
535  break;
536  }
537  cuddRef(res);
538  vect[dd->invperm[i]] = res;
539  }
540  } while (dd->reordered == 1);
541  if (res == NULL) {
542  ABC_FREE(vect);
543  return(NULL);
544  }
545  return(vect);
546 
547 } /* end of Cudd_bddCharToVect */
void Cudd_IterDerefBdd(DdManager *table, DdNode *n)
Definition: cuddRef.c:217
#define cuddRef(n)
Definition: cuddInt.h:584
Definition: cudd.h:278
#define Cudd_Not(node)
Definition: cudd.h:367
int size
Definition: cuddInt.h:361
#define ABC_ALLOC(type, num)
Definition: abc_global.h:229
static DdNode * cuddBddCharToVect(DdManager *dd, DdNode *f, DdNode *x)
Definition: cuddGenCof.c:1566
int reordered
Definition: cuddInt.h:409
#define ABC_FREE(obj)
Definition: abc_global.h:232
DdNode ** vars
Definition: cuddInt.h:390
int * invperm
Definition: cuddInt.h:388
#define DD_ONE(dd)
Definition: cuddInt.h:911
Cudd_ErrorType errorCode
Definition: cuddInt.h:447
DdNode* Cudd_bddClippingAnd ( DdManager dd,
DdNode f,
DdNode g,
int  maxDepth,
int  direction 
)

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

Synopsis [Approximates the conjunction of two BDDs f and g.]

Description [Approximates the conjunction of two BDDs f and g. Returns a pointer to the resulting BDD if successful; NULL if the intermediate result blows up.]

SideEffects [None]

SeeAlso [Cudd_bddAnd]

Definition at line 129 of file cuddClip.c.

135 {
136  DdNode *res;
137 
138  do {
139  dd->reordered = 0;
140  res = cuddBddClippingAnd(dd,f,g,maxDepth,direction);
141  } while (dd->reordered == 1);
142  return(res);
143 
144 } /* end of Cudd_bddClippingAnd */
Definition: cudd.h:278
DdNode * cuddBddClippingAnd(DdManager *dd, DdNode *f, DdNode *g, int maxDepth, int direction)
Definition: cuddClip.c:201
int reordered
Definition: cuddInt.h:409
DdNode* Cudd_bddClippingAndAbstract ( DdManager dd,
DdNode f,
DdNode g,
DdNode cube,
int  maxDepth,
int  direction 
)

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

Synopsis [Approximates the conjunction of two BDDs f and g and simultaneously abstracts the variables in cube.]

Description [Approximates the conjunction of two BDDs f and g and simultaneously abstracts the variables in cube. The variables are existentially abstracted. Returns a pointer to the resulting BDD if successful; NULL if the intermediate result blows up.]

SideEffects [None]

SeeAlso [Cudd_bddAndAbstract Cudd_bddClippingAnd]

Definition at line 163 of file cuddClip.c.

170 {
171  DdNode *res;
172 
173  do {
174  dd->reordered = 0;
175  res = cuddBddClippingAndAbstract(dd,f,g,cube,maxDepth,direction);
176  } while (dd->reordered == 1);
177  return(res);
178 
179 } /* end of Cudd_bddClippingAndAbstract */
Definition: cudd.h:278
DdNode * cuddBddClippingAndAbstract(DdManager *dd, DdNode *f, DdNode *g, DdNode *cube, int maxDepth, int direction)
Definition: cuddClip.c:233
int reordered
Definition: cuddInt.h:409
DdNode* Cudd_bddClosestCube ( DdManager dd,
DdNode f,
DdNode g,
int *  distance 
)

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

Synopsis [Finds a cube of f at minimum Hamming distance from g.]

Description [Finds a cube of f at minimum Hamming distance from the minterms of g. All the minterms of the cube are at the minimum distance. If the distance is 0, the cube belongs to the intersection of f and g. Returns the cube if successful; NULL otherwise.]

SideEffects [The distance is returned as a side effect.]

SeeAlso [Cudd_MinHammingDist]

Definition at line 1359 of file cuddPriority.c.

1364 {
1365  DdNode *res, *acube;
1366  CUDD_VALUE_TYPE rdist;
1367 
1368  /* Compute the cube and distance as a single ADD. */
1369  do {
1370  dd->reordered = 0;
1371  res = cuddBddClosestCube(dd,f,g,CUDD_CONST_INDEX + 1.0);
1372  } while (dd->reordered == 1);
1373  if (res == NULL) return(NULL);
1374  cuddRef(res);
1375 
1376  /* Unpack distance and cube. */
1377  do {
1378  dd->reordered = 0;
1379  acube = separateCube(dd, res, &rdist);
1380  } while (dd->reordered == 1);
1381  if (acube == NULL) {
1382  Cudd_RecursiveDeref(dd, res);
1383  return(NULL);
1384  }
1385  cuddRef(acube);
1386  Cudd_RecursiveDeref(dd, res);
1387 
1388  /* Convert cube from ADD to BDD. */
1389  do {
1390  dd->reordered = 0;
1391  res = cuddAddBddDoPattern(dd, acube);
1392  } while (dd->reordered == 1);
1393  if (res == NULL) {
1394  Cudd_RecursiveDeref(dd, acube);
1395  return(NULL);
1396  }
1397  cuddRef(res);
1398  Cudd_RecursiveDeref(dd, acube);
1399 
1400  *distance = (int) rdist;
1401  cuddDeref(res);
1402  return(res);
1403 
1404 } /* end of Cudd_bddClosestCube */
#define cuddRef(n)
Definition: cuddInt.h:584
#define cuddDeref(n)
Definition: cuddInt.h:604
void Cudd_RecursiveDeref(DdManager *table, DdNode *n)
Definition: cuddRef.c:154
Definition: cudd.h:278
static DdNode * separateCube(DdManager *dd, DdNode *f, CUDD_VALUE_TYPE *distance)
int reordered
Definition: cuddInt.h:409
DdNode * cuddAddBddDoPattern(DdManager *dd, DdNode *f)
Definition: cuddBridge.c:493
#define CUDD_CONST_INDEX
Definition: cudd.h:117
#define CUDD_VALUE_TYPE
Definition: cudd.h:94
DdNode * cuddBddClosestCube(DdManager *dd, DdNode *f, DdNode *g, CUDD_VALUE_TYPE bound)
DdNode* Cudd_bddCompose ( DdManager dd,
DdNode f,
DdNode g,
int  v 
)

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

Synopsis [Substitutes g for x_v in the BDD for f.]

Description [Substitutes g for x_v in the BDD for f. v is the index of the variable to be substituted. Cudd_bddCompose passes the corresponding projection function to the recursive procedure, so that the cache may be used. Returns the composed BDD if successful; NULL otherwise.]

SideEffects [None]

SeeAlso [Cudd_addCompose]

Definition at line 167 of file cuddCompose.c.

172 {
173  DdNode *proj, *res;
174 
175  /* Sanity check. */
176  if (v < 0 || v >= dd->size) return(NULL);
177 
178  proj = dd->vars[v];
179  do {
180  dd->reordered = 0;
181  res = cuddBddComposeRecur(dd,f,g,proj);
182  } while (dd->reordered == 1);
183  return(res);
184 
185 } /* end of Cudd_bddCompose */
Definition: cudd.h:278
DdNode * cuddBddComposeRecur(DdManager *dd, DdNode *f, DdNode *g, DdNode *proj)
Definition: cuddCompose.c:850
int size
Definition: cuddInt.h:361
int reordered
Definition: cuddInt.h:409
DdNode ** vars
Definition: cuddInt.h:390
DdNode* Cudd_bddComputeCube ( DdManager dd,
DdNode **  vars,
int *  phase,
int  n 
)

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

Synopsis [Computes the cube of an array of BDD variables.]

Description [Computes the cube of an array of BDD variables. If non-null, the phase argument indicates which literal of each variable should appear in the cube. If phase[i] is nonzero, then the positive literal is used. If phase is NULL, the cube is positive unate. Returns a pointer to the result if successful; NULL otherwise.]

SideEffects [None]

SeeAlso [Cudd_addComputeCube Cudd_IndicesToCube Cudd_CubeArrayToBdd]

Definition at line 2196 of file cuddUtil.c.

2201 {
2202  DdNode *cube;
2203  DdNode *fn;
2204  int i;
2205 
2206  cube = DD_ONE(dd);
2207  cuddRef(cube);
2208 
2209  for (i = n - 1; i >= 0; i--) {
2210  if (phase == NULL || phase[i] != 0) {
2211  fn = Cudd_bddAnd(dd,vars[i],cube);
2212  } else {
2213  fn = Cudd_bddAnd(dd,Cudd_Not(vars[i]),cube);
2214  }
2215  if (fn == NULL) {
2216  Cudd_RecursiveDeref(dd,cube);
2217  return(NULL);
2218  }
2219  cuddRef(fn);
2220  Cudd_RecursiveDeref(dd,cube);
2221  cube = fn;
2222  }
2223  cuddDeref(cube);
2224 
2225  return(cube);
2226 
2227 } /* end of Cudd_bddComputeCube */
#define cuddRef(n)
Definition: cuddInt.h:584
#define cuddDeref(n)
Definition: cuddInt.h:604
void Cudd_RecursiveDeref(DdManager *table, DdNode *n)
Definition: cuddRef.c:154
Definition: cudd.h:278
#define Cudd_Not(node)
Definition: cudd.h:367
static pcube phase
Definition: cvrm.c:405
DdNode * Cudd_bddAnd(DdManager *dd, DdNode *f, DdNode *g)
Definition: cuddBddIte.c:314
#define DD_ONE(dd)
Definition: cuddInt.h:911
DdNode* Cudd_bddConstrain ( DdManager dd,
DdNode f,
DdNode c 
)

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

Synopsis [Computes f constrain c.]

Description [Computes f constrain c (f @ c). Uses a canonical form: (f' @ c) = ( f @ c)'. (Note: this is not true for c.) List of special cases:

  • f @ 0 = 0
  • f @ 1 = f
  • 0 @ c = 0
  • 1 @ c = 1
  • f @ f = 1
  • f @ f'= 0

Returns a pointer to the result if successful; NULL otherwise. Note that if F=(f1,...,fn) and reordering takes place while computing F @ c, then the image restriction property (Img(F,c) = Img(F @ c)) is lost.]

SideEffects [None]

SeeAlso [Cudd_bddRestrict Cudd_addConstrain]

Definition at line 180 of file cuddGenCof.c.

184 {
185  DdNode *res;
186 
187  do {
188  dd->reordered = 0;
189  res = cuddBddConstrainRecur(dd,f,c);
190  } while (dd->reordered == 1);
191  return(res);
192 
193 } /* end of Cudd_bddConstrain */
DdNode * cuddBddConstrainRecur(DdManager *dd, DdNode *f, DdNode *c)
Definition: cuddGenCof.c:783
Definition: cudd.h:278
int reordered
Definition: cuddInt.h:409
DdNode** Cudd_bddConstrainDecomp ( DdManager dd,
DdNode f 
)

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

Synopsis [BDD conjunctive decomposition as in McMillan's CAV96 paper.]

Description [BDD conjunctive decomposition as in McMillan's CAV96 paper. The decomposition is canonical only for a given variable order. If canonicity is required, variable ordering must be disabled after the decomposition has been computed. Returns an array with one entry for each BDD variable in the manager if successful; otherwise NULL. The components of the solution have their reference counts already incremented (unlike the results of most other functions in the package.]

SideEffects [None]

SeeAlso [Cudd_bddConstrain Cudd_bddExistAbstract]

Definition at line 371 of file cuddGenCof.c.

374 {
375  DdNode **decomp;
376  int res;
377  int i;
378 
379  /* Create an initialize decomposition array. */
380  decomp = ABC_ALLOC(DdNode *,dd->size);
381  if (decomp == NULL) {
383  return(NULL);
384  }
385  for (i = 0; i < dd->size; i++) {
386  decomp[i] = NULL;
387  }
388  do {
389  dd->reordered = 0;
390  /* Clean up the decomposition array in case reordering took place. */
391  for (i = 0; i < dd->size; i++) {
392  if (decomp[i] != NULL) {
393  Cudd_IterDerefBdd(dd, decomp[i]);
394  decomp[i] = NULL;
395  }
396  }
397  res = cuddBddConstrainDecomp(dd,f,decomp);
398  } while (dd->reordered == 1);
399  if (res == 0) {
400  ABC_FREE(decomp);
401  return(NULL);
402  }
403  /* Missing components are constant ones. */
404  for (i = 0; i < dd->size; i++) {
405  if (decomp[i] == NULL) {
406  decomp[i] = DD_ONE(dd);
407  cuddRef(decomp[i]);
408  }
409  }
410  return(decomp);
411 
412 } /* end of Cudd_bddConstrainDecomp */
void Cudd_IterDerefBdd(DdManager *table, DdNode *n)
Definition: cuddRef.c:217
#define cuddRef(n)
Definition: cuddInt.h:584
Definition: cudd.h:278
int size
Definition: cuddInt.h:361
#define ABC_ALLOC(type, num)
Definition: abc_global.h:229
static int cuddBddConstrainDecomp(DdManager *dd, DdNode *f, DdNode **decomp)
Definition: cuddGenCof.c:1504
int reordered
Definition: cuddInt.h:409
#define ABC_FREE(obj)
Definition: abc_global.h:232
#define DD_ONE(dd)
Definition: cuddInt.h:911
Cudd_ErrorType errorCode
Definition: cuddInt.h:447
double Cudd_bddCorrelation ( DdManager manager,
DdNode f,
DdNode g 
)

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

Synopsis [Computes the correlation of f and g.]

Description [Computes the correlation of f and g. If f == g, their correlation is 1. If f == g', their correlation is 0. Returns the fraction of minterms in the ON-set of the EXNOR of f and g. If it runs out of memory, returns (double)CUDD_OUT_OF_MEM.]

SideEffects [None]

SeeAlso [Cudd_bddCorrelationWeights]

Definition at line 147 of file cuddBddCorr.c.

151 {
152 
153  st__table *table;
154  double correlation;
155 
156 #ifdef CORREL_STATS
157  num_calls = 0;
158 #endif
159 
161  if (table == NULL) return((double)CUDD_OUT_OF_MEM);
162  correlation = bddCorrelationAux(manager,f,g,table);
163  st__foreach(table, CorrelCleanUp, NIL(char));
164  st__free_table(table);
165  return(correlation);
166 
167 } /* end of Cudd_bddCorrelation */
static double bddCorrelationAux(DdManager *dd, DdNode *f, DdNode *g, st__table *table)
Definition: cuddBddCorr.c:237
void st__free_table(st__table *table)
Definition: st.c:81
#define CUDD_OUT_OF_MEM
Definition: cudd.h:95
static int CorrelCompare(const char *key1, const char *key2)
Definition: cuddBddCorr.c:447
#define NIL(type)
Definition: avl.h:25
st__table * st__init_table(st__compare_func_type compare, st__hash_func_type hash)
Definition: st.c:72
Definition: st.h:52
static enum st__retval CorrelCleanUp(char *key, char *value, char *arg)
Definition: cuddBddCorr.c:504
int st__foreach(st__table *table, enum st__retval(*func)(char *, char *, char *), char *arg)
Definition: st.c:421
static int CorrelHash(const char *key, int modulus)
Definition: cuddBddCorr.c:474
double Cudd_bddCorrelationWeights ( DdManager manager,
DdNode f,
DdNode g,
double *  prob 
)

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

Synopsis [Computes the correlation of f and g for given input probabilities.]

Description [Computes the correlation of f and g for given input probabilities. On input, prob[i] is supposed to contain the probability of the i-th input variable to be 1. If f == g, their correlation is 1. If f == g', their correlation is 0. Returns the probability that f and g have the same value. If it runs out of memory, returns (double)CUDD_OUT_OF_MEM. The correlation of f and the constant one gives the probability of f.]

SideEffects [None]

SeeAlso [Cudd_bddCorrelation]

Definition at line 189 of file cuddBddCorr.c.

194 {
195 
196  st__table *table;
197  double correlation;
198 
199 #ifdef CORREL_STATS
200  num_calls = 0;
201 #endif
202 
204  if (table == NULL) return((double)CUDD_OUT_OF_MEM);
205  correlation = bddCorrelationWeightsAux(manager,f,g,prob,table);
206  st__foreach(table, CorrelCleanUp, NIL(char));
207  st__free_table(table);
208  return(correlation);
209 
210 } /* end of Cudd_bddCorrelationWeights */
void st__free_table(st__table *table)
Definition: st.c:81
#define CUDD_OUT_OF_MEM
Definition: cudd.h:95
static int CorrelCompare(const char *key1, const char *key2)
Definition: cuddBddCorr.c:447
static double bddCorrelationWeightsAux(DdManager *dd, DdNode *f, DdNode *g, double *prob, st__table *table)
Definition: cuddBddCorr.c:339
#define NIL(type)
Definition: avl.h:25
st__table * st__init_table(st__compare_func_type compare, st__hash_func_type hash)
Definition: st.c:72
Definition: st.h:52
static enum st__retval CorrelCleanUp(char *key, char *value, char *arg)
Definition: cuddBddCorr.c:504
int st__foreach(st__table *table, enum st__retval(*func)(char *, char *, char *), char *arg)
Definition: st.c:421
static int CorrelHash(const char *key, int modulus)
Definition: cuddBddCorr.c:474
DdNode* Cudd_bddExistAbstract ( DdManager manager,
DdNode f,
DdNode cube 
)

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

Synopsis [Existentially abstracts all the variables in cube from f.]

Description [Existentially abstracts all the variables in cube from f. Returns the abstracted BDD if successful; NULL otherwise.]

SideEffects [None]

SeeAlso [Cudd_bddUnivAbstract Cudd_addExistAbstract]

Definition at line 130 of file cuddBddAbs.c.

134 {
135  DdNode *res;
136 
137  if (bddCheckPositiveCube(manager, cube) == 0) {
138  (void) fprintf(manager->err,
139  "Error: Can only abstract positive cubes\n");
140  manager->errorCode = CUDD_INVALID_ARG;
141  return(NULL);
142  }
143 
144  do {
145  manager->reordered = 0;
146  res = cuddBddExistAbstractRecur(manager, f, cube);
147  } while (manager->reordered == 1);
148 
149  return(res);
150 
151 } /* end of Cudd_bddExistAbstract */
DdNode * cuddBddExistAbstractRecur(DdManager *manager, DdNode *f, DdNode *cube)
Definition: cuddBddAbs.c:352
Definition: cudd.h:278
FILE * err
Definition: cuddInt.h:442
int reordered
Definition: cuddInt.h:409
static int bddCheckPositiveCube(DdManager *manager, DdNode *cube)
Definition: cuddBddAbs.c:708
Cudd_ErrorType errorCode
Definition: cuddInt.h:447
int Cudd_bddGenConjDecomp ( DdManager dd,
DdNode f,
DdNode ***  conjuncts 
)

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

Synopsis [Performs two-way conjunctive decomposition of a BDD.]

Description [Performs two-way conjunctive decomposition of a BDD. This procedure owes its name to the fact tht it generalizes the decomposition based on the cofactors with respect to one variable. Returns the number of conjuncts produced, that is, 2 if successful; 1 if no meaningful decomposition was found; 0 otherwise. The conjuncts produced by this procedure tend to be balanced.]

SideEffects [The two factors are returned in an array as side effects. The array is allocated by this function. It is the caller's responsibility to free it. On successful completion, the conjuncts are already referenced. If the function returns 0, the array for the conjuncts is not allocated. If the function returns 1, the only factor equals the function to be decomposed.]

SeeAlso [Cudd_bddGenDisjDecomp Cudd_bddApproxConjDecomp Cudd_bddIterConjDecomp Cudd_bddVarConjDecomp]

Definition at line 496 of file cuddDecomp.c.

500 {
501  int result;
502  DdNode *glocal, *hlocal;
503 
504  one = DD_ONE(dd);
505  zero = Cudd_Not(one);
506 
507  do {
508  dd->reordered = 0;
509  result = cuddConjunctsAux(dd, f, &glocal, &hlocal);
510  } while (dd->reordered == 1);
511 
512  if (result == 0) {
513  return(0);
514  }
515 
516  if (glocal != one) {
517  if (hlocal != one) {
518  *conjuncts = ABC_ALLOC(DdNode *,2);
519  if (*conjuncts == NULL) {
520  Cudd_RecursiveDeref(dd,glocal);
521  Cudd_RecursiveDeref(dd,hlocal);
523  return(0);
524  }
525  (*conjuncts)[0] = glocal;
526  (*conjuncts)[1] = hlocal;
527  return(2);
528  } else {
529  Cudd_RecursiveDeref(dd,hlocal);
530  *conjuncts = ABC_ALLOC(DdNode *,1);
531  if (*conjuncts == NULL) {
532  Cudd_RecursiveDeref(dd,glocal);
534  return(0);
535  }
536  (*conjuncts)[0] = glocal;
537  return(1);
538  }
539  } else {
540  Cudd_RecursiveDeref(dd,glocal);
541  *conjuncts = ABC_ALLOC(DdNode *,1);
542  if (*conjuncts == NULL) {
543  Cudd_RecursiveDeref(dd,hlocal);
545  return(0);
546  }
547  (*conjuncts)[0] = hlocal;
548  return(1);
549  }
550 
551 } /* end of Cudd_bddGenConjDecomp */
void Cudd_RecursiveDeref(DdManager *table, DdNode *n)
Definition: cuddRef.c:154
Definition: cudd.h:278
#define Cudd_Not(node)
Definition: cudd.h:367
#define ABC_ALLOC(type, num)
Definition: abc_global.h:229
int reordered
Definition: cuddInt.h:409
static DdNode * one
Definition: cuddDecomp.c:112
static int result
Definition: cuddGenetic.c:125
#define DD_ONE(dd)
Definition: cuddInt.h:911
static int cuddConjunctsAux(DdManager *dd, DdNode *f, DdNode **c1, DdNode **c2)
Definition: cuddDecomp.c:2005
Cudd_ErrorType errorCode
Definition: cuddInt.h:447
static DdNode * zero
Definition: cuddDecomp.c:112
int Cudd_bddGenDisjDecomp ( DdManager dd,
DdNode f,
DdNode ***  disjuncts 
)

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

Synopsis [Performs two-way disjunctive decomposition of a BDD.]

Description [Performs two-way disjunctive decomposition of a BDD. Returns the number of disjuncts produced, that is, 2 if successful; 1 if no meaningful decomposition was found; 0 otherwise. The disjuncts produced by this procedure tend to be balanced.]

SideEffects [The two disjuncts are returned in an array as side effects. The array is allocated by this function. It is the caller's responsibility to free it. On successful completion, the disjuncts are already referenced. If the function returns 0, the array for the disjuncts is not allocated. If the function returns 1, the only factor equals the function to be decomposed.]

SeeAlso [Cudd_bddGenConjDecomp Cudd_bddApproxDisjDecomp Cudd_bddIterDisjDecomp Cudd_bddVarDisjDecomp]

Definition at line 575 of file cuddDecomp.c.

579 {
580  int result, i;
581 
582  result = Cudd_bddGenConjDecomp(dd,Cudd_Not(f),disjuncts);
583  for (i = 0; i < result; i++) {
584  (*disjuncts)[i] = Cudd_Not((*disjuncts)[i]);
585  }
586  return(result);
587 
588 } /* end of Cudd_bddGenDisjDecomp */
#define Cudd_Not(node)
Definition: cudd.h:367
int Cudd_bddGenConjDecomp(DdManager *dd, DdNode *f, DdNode ***conjuncts)
Definition: cuddDecomp.c:496
static int result
Definition: cuddGenetic.c:125
DdNode* Cudd_bddIntersect ( DdManager dd,
DdNode f,
DdNode g 
)

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

Synopsis [Returns a function included in the intersection of f and g.]

Description [Computes a function included in the intersection of f and g. (That is, a witness that the intersection is not empty.) Cudd_bddIntersect tries to build as few new nodes as possible. If the only result of interest is whether f and g intersect, Cudd_bddLeq should be used instead.]

SideEffects [None]

SeeAlso [Cudd_bddLeq Cudd_bddIteConstant]

Definition at line 282 of file cuddBddIte.c.

286 {
287  DdNode *res;
288 
289  do {
290  dd->reordered = 0;
291  res = cuddBddIntersectRecur(dd,f,g);
292  } while (dd->reordered == 1);
293 
294  return(res);
295 
296 } /* end of Cudd_bddIntersect */
Definition: cudd.h:278
int reordered
Definition: cuddInt.h:409
DdNode * cuddBddIntersectRecur(DdManager *dd, DdNode *f, DdNode *g)
Definition: cuddBddIte.c:771
DdNode* Cudd_bddInterval ( DdManager dd,
int  N,
DdNode **  x,
unsigned int  lowerB,
unsigned int  upperB 
)

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

Synopsis [Generates a BDD for the function lowerB ≤ x ≤ upperB.]

Description [This function generates a BDD for the function lowerB ≤ x ≤ upperB, where x is an N-bit number, x[0] x[1] ... x[N-1], with 0 the most significant bit (important!). The number of variables N should be sufficient to represent the bounds; otherwise, the bounds are truncated to their N least significant bits. Two BDDs are built bottom-up for lowerB ≤ x and x ≤ upperB, and they are finally conjoined.]

SideEffects [None]

SeeAlso [Cudd_Xgty]

Definition at line 1121 of file cuddPriority.c.

1127 {
1128  DdNode *one, *zero;
1129  DdNode *r, *rl, *ru;
1130  int i;
1131 
1132  one = DD_ONE(dd);
1133  zero = Cudd_Not(one);
1134 
1135  rl = one;
1136  cuddRef(rl);
1137  ru = one;
1138  cuddRef(ru);
1139 
1140  /* Loop to build the rest of the BDDs. */
1141  for (i = N-1; i >= 0; i--) {
1142  DdNode *vl, *vu;
1143  vl = Cudd_bddIte(dd, x[i],
1144  lowerB&1 ? rl : one,
1145  lowerB&1 ? zero : rl);
1146  if (vl == NULL) {
1147  Cudd_IterDerefBdd(dd, rl);
1148  Cudd_IterDerefBdd(dd, ru);
1149  return(NULL);
1150  }
1151  cuddRef(vl);
1152  Cudd_IterDerefBdd(dd, rl);
1153  rl = vl;
1154  lowerB >>= 1;
1155  vu = Cudd_bddIte(dd, x[i],
1156  upperB&1 ? ru : zero,
1157  upperB&1 ? one : ru);
1158  if (vu == NULL) {
1159  Cudd_IterDerefBdd(dd, rl);
1160  Cudd_IterDerefBdd(dd, ru);
1161  return(NULL);
1162  }
1163  cuddRef(vu);
1164  Cudd_IterDerefBdd(dd, ru);
1165  ru = vu;
1166  upperB >>= 1;
1167  }
1168 
1169  /* Conjoin the two bounds. */
1170  r = Cudd_bddAnd(dd, rl, ru);
1171  if (r == NULL) {
1172  Cudd_IterDerefBdd(dd, rl);
1173  Cudd_IterDerefBdd(dd, ru);
1174  return(NULL);
1175  }
1176  cuddRef(r);
1177  Cudd_IterDerefBdd(dd, rl);
1178  Cudd_IterDerefBdd(dd, ru);
1179  cuddDeref(r);
1180  return(r);
1181 
1182 } /* end of Cudd_bddInterval */
void Cudd_IterDerefBdd(DdManager *table, DdNode *n)
Definition: cuddRef.c:217
#define cuddRef(n)
Definition: cuddInt.h:584
#define cuddDeref(n)
Definition: cuddInt.h:604
Definition: cudd.h:278
#define Cudd_Not(node)
Definition: cudd.h:367
DdNode * Cudd_bddIte(DdManager *dd, DdNode *f, DdNode *g, DdNode *h)
Definition: cuddBddIte.c:143
static DdNode * one
Definition: cuddDecomp.c:112
DdNode * Cudd_bddAnd(DdManager *dd, DdNode *f, DdNode *g)
Definition: cuddBddIte.c:314
#define DD_ONE(dd)
Definition: cuddInt.h:911
static DdNode * zero
Definition: cuddApa.c:100
int Cudd_bddIsNsVar ( DdManager dd,
int  index 
)

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

Synopsis [Checks whether a variable is next state.]

Description [Checks whether a variable is next state. Returns 1 if the variable's type is present state; 0 if the variable exists but is not a present state; -1 if the variable does not exist.]

SideEffects [none]

SeeAlso [Cudd_bddSetNsVar Cudd_bddIsPiVar Cudd_bddIsPsVar]

Definition at line 4098 of file cuddAPI.c.

4101 {
4102  if (index >= dd->size || index < 0) return -1;
4103  return (dd->subtables[dd->perm[index]].varType == CUDD_VAR_NEXT_STATE);
4104 
4105 } /* end of Cudd_bddIsNsVar */
int size
Definition: cuddInt.h:361
DdSubtable * subtables
Definition: cuddInt.h:365
Cudd_VariableType varType
Definition: cuddInt.h:336
int * perm
Definition: cuddInt.h:386
DdNode* Cudd_bddIsop ( DdManager dd,
DdNode L,
DdNode U 
)

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

Synopsis [Computes a BDD in the interval between L and U with a simple sum-of-produuct cover.]

Description [Computes a BDD in the interval between L and U with a simple sum-of-produuct cover. This procedure is similar to Cudd_zddIsop, but it does not return the ZDD for the cover. Returns a pointer to the BDD if successful; NULL otherwise.]

SideEffects [None]

SeeAlso [Cudd_zddIsop]

Definition at line 174 of file cuddZddIsop.c.

178 {
179  DdNode *res;
180 
181  do {
182  dd->reordered = 0;
183  res = cuddBddIsop(dd, L, U);
184  } while (dd->reordered == 1);
185  return(res);
186 
187 } /* end of Cudd_bddIsop */
Definition: cudd.h:278
int reordered
Definition: cuddInt.h:409
DdNode * cuddBddIsop(DdManager *dd, DdNode *L, DdNode *U)
Definition: cuddZddIsop.c:575
int Cudd_bddIsPiVar ( DdManager dd,
int  index 
)

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

Synopsis [Checks whether a variable is primary input.]

Description [Checks whether a variable is primary input. Returns 1 if the variable's type is primary input; 0 if the variable exists but is not a primary input; -1 if the variable does not exist.]

SideEffects [none]

SeeAlso [Cudd_bddSetPiVar Cudd_bddIsPsVar Cudd_bddIsNsVar]

Definition at line 4050 of file cuddAPI.c.

4053 {
4054  if (index >= dd->size || index < 0) return -1;
4055  return (dd->subtables[dd->perm[index]].varType == CUDD_VAR_PRIMARY_INPUT);
4056 
4057 } /* end of Cudd_bddIsPiVar */
int size
Definition: cuddInt.h:361
DdSubtable * subtables
Definition: cuddInt.h:365
Cudd_VariableType varType
Definition: cuddInt.h:336
int * perm
Definition: cuddInt.h:386
int Cudd_bddIsPsVar ( DdManager dd,
int  index 
)

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

Synopsis [Checks whether a variable is present state.]

Description [Checks whether a variable is present state. Returns 1 if the variable's type is present state; 0 if the variable exists but is not a present state; -1 if the variable does not exist.]

SideEffects [none]

SeeAlso [Cudd_bddSetPsVar Cudd_bddIsPiVar Cudd_bddIsNsVar]

Definition at line 4074 of file cuddAPI.c.

4077 {
4078  if (index >= dd->size || index < 0) return -1;
4079  return (dd->subtables[dd->perm[index]].varType == CUDD_VAR_PRESENT_STATE);
4080 
4081 } /* end of Cudd_bddIsPsVar */
int size
Definition: cuddInt.h:361
DdSubtable * subtables
Definition: cuddInt.h:365
Cudd_VariableType varType
Definition: cuddInt.h:336
int * perm
Definition: cuddInt.h:386
int Cudd_bddIsVarEssential ( DdManager manager,
DdNode f,
int  id,
int  phase 
)

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

Synopsis [Determines whether a given variable is essential with a given phase in a BDD.]

Description [Determines whether a given variable is essential with a given phase in a BDD. Uses Cudd_bddIteConstant. Returns 1 if phase == 1 and f–>x_id, or if phase == 0 and f–>x_id'.]

SideEffects [None]

SeeAlso [Cudd_FindEssential]

Definition at line 239 of file cuddEssent.c.

244 {
245  DdNode *var;
246  int res;
247 
248  var = Cudd_bddIthVar(manager, id);
249 
250  var = Cudd_NotCond(var,phase == 0);
251 
252  res = Cudd_bddLeq(manager, f, var);
253 
254  return(res);
255 
256 } /* end of Cudd_bddIsVarEssential */
Definition: cudd.h:278
int var(Lit p)
Definition: SolverTypes.h:62
static pcube phase
Definition: cvrm.c:405
int Cudd_bddLeq(DdManager *dd, DdNode *f, DdNode *g)
Definition: cuddBddIte.c:536
DdNode * Cudd_bddIthVar(DdManager *dd, int i)
Definition: cuddAPI.c:416
#define Cudd_NotCond(node, c)
Definition: cudd.h:383
int Cudd_bddIsVarHardGroup ( DdManager dd,
int  index 
)

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

Synopsis [Checks whether a variable is set to be in a hard group.]

Description [Checks whether a variable is set to be in a hard group. This function is used for lazy sifting. Returns 1 if the variable is marked to be in a hard group; 0 if the variable exists, but it is not marked to be in a hard group; -1 if the variable does not exist.]

SideEffects [none]

SeeAlso [Cudd_bddSetVarHardGroup]

Definition at line 4326 of file cuddAPI.c.

4329 {
4330  if (index >= dd->size || index < 0) return(-1);
4331  if (dd->subtables[dd->perm[index]].varToBeGrouped == CUDD_LAZY_HARD_GROUP)
4332  return(1);
4333  return(0);
4334 
4335 } /* end of Cudd_bddIsVarToBeGrouped */
int size
Definition: cuddInt.h:361
DdSubtable * subtables
Definition: cuddInt.h:365
Cudd_LazyGroupType varToBeGrouped
Definition: cuddInt.h:339
int * perm
Definition: cuddInt.h:386
int Cudd_bddIsVarToBeGrouped ( DdManager dd,
int  index 
)

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

Synopsis [Checks whether a variable is set to be grouped.]

Description [Checks whether a variable is set to be grouped. This function is used for lazy sifting.]

SideEffects [none]

SeeAlso []

Definition at line 4249 of file cuddAPI.c.

4252 {
4253  if (index >= dd->size || index < 0) return(-1);
4254  if (dd->subtables[dd->perm[index]].varToBeGrouped == CUDD_LAZY_UNGROUP)
4255  return(0);
4256  else
4257  return(dd->subtables[dd->perm[index]].varToBeGrouped);
4258 
4259 } /* end of Cudd_bddIsVarToBeGrouped */
int size
Definition: cuddInt.h:361
DdSubtable * subtables
Definition: cuddInt.h:365
Cudd_LazyGroupType varToBeGrouped
Definition: cuddInt.h:339
int * perm
Definition: cuddInt.h:386
int Cudd_bddIsVarToBeUngrouped ( DdManager dd,
int  index 
)

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

Synopsis [Checks whether a variable is set to be ungrouped.]

Description [Checks whether a variable is set to be ungrouped. This function is used for lazy sifting. Returns 1 if the variable is marked to be ungrouped; 0 if the variable exists, but it is not marked to be ungrouped; -1 if the variable does not exist.]

SideEffects [none]

SeeAlso [Cudd_bddSetVarToBeUngrouped]

Definition at line 4301 of file cuddAPI.c.

4304 {
4305  if (index >= dd->size || index < 0) return(-1);
4306  return dd->subtables[dd->perm[index]].varToBeGrouped == CUDD_LAZY_UNGROUP;
4307 
4308 } /* end of Cudd_bddIsVarToBeGrouped */
int size
Definition: cuddInt.h:361
DdSubtable * subtables
Definition: cuddInt.h:365
Cudd_LazyGroupType varToBeGrouped
Definition: cuddInt.h:339
int * perm
Definition: cuddInt.h:386
DdNode* Cudd_bddIte ( DdManager dd,
DdNode f,
DdNode g,
DdNode h 
)

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

Synopsis [Implements ITE(f,g,h).]

Description [Implements ITE(f,g,h). Returns a pointer to the resulting BDD if successful; NULL if the intermediate result blows up.]

SideEffects [None]

SeeAlso [Cudd_addIte Cudd_bddIteConstant Cudd_bddIntersect]

Definition at line 143 of file cuddBddIte.c.

148 {
149  DdNode *res;
150 
151  do {
152  dd->reordered = 0;
153  res = cuddBddIteRecur(dd,f,g,h);
154  } while (dd->reordered == 1);
155  return(res);
156 
157 } /* end of Cudd_bddIte */
Definition: cudd.h:278
int reordered
Definition: cuddInt.h:409
DdNode * cuddBddIteRecur(DdManager *dd, DdNode *f, DdNode *g, DdNode *h)
Definition: cuddBddIte.c:633
DdNode* Cudd_bddIteConstant ( DdManager dd,
DdNode f,
DdNode g,
DdNode h 
)

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

Synopsis [Implements ITEconstant(f,g,h).]

Description [Implements ITEconstant(f,g,h). Returns a pointer to the resulting BDD (which may or may not be constant) or DD_NON_CONSTANT. No new nodes are created.]

SideEffects [None]

SeeAlso [Cudd_bddIte Cudd_bddIntersect Cudd_bddLeq Cudd_addIteConstant]

Definition at line 174 of file cuddBddIte.c.

179 {
180  DdNode *r, *Fv, *Fnv, *Gv, *Gnv, *H, *Hv, *Hnv, *t, *e;
181  DdNode *one = DD_ONE(dd);
182  DdNode *zero = Cudd_Not(one);
183  int comple;
184  unsigned int topf, topg, toph, v;
185 
186  statLine(dd);
187  /* Trivial cases. */
188  if (f == one) /* ITE(1,G,H) => G */
189  return(g);
190 
191  if (f == zero) /* ITE(0,G,H) => H */
192  return(h);
193 
194  /* f now not a constant. */
195  bddVarToConst(f, &g, &h, one); /* possibly convert g or h */
196  /* to constants */
197 
198  if (g == h) /* ITE(F,G,G) => G */
199  return(g);
200 
201  if (Cudd_IsConstant(g) && Cudd_IsConstant(h))
202  return(DD_NON_CONSTANT); /* ITE(F,1,0) or ITE(F,0,1) */
203  /* => DD_NON_CONSTANT */
204 
205  if (g == Cudd_Not(h))
206  return(DD_NON_CONSTANT); /* ITE(F,G,G') => DD_NON_CONSTANT */
207  /* if F != G and F != G' */
208 
209  comple = bddVarToCanonical(dd, &f, &g, &h, &topf, &topg, &toph);
210 
211  /* Cache lookup. */
213  if (r != NULL) {
214  return(Cudd_NotCond(r,comple && r != DD_NON_CONSTANT));
215  }
216 
217  v = ddMin(topg, toph);
218 
219  /* ITE(F,G,H) = (v,G,H) (non constant) if F = (v,1,0), v < top(G,H). */
220  if (topf < v && cuddT(f) == one && cuddE(f) == zero) {
221  return(DD_NON_CONSTANT);
222  }
223 
224  /* Compute cofactors. */
225  if (topf <= v) {
226  v = ddMin(topf, v); /* v = top_var(F,G,H) */
227  Fv = cuddT(f); Fnv = cuddE(f);
228  } else {
229  Fv = Fnv = f;
230  }
231 
232  if (topg == v) {
233  Gv = cuddT(g); Gnv = cuddE(g);
234  } else {
235  Gv = Gnv = g;
236  }
237 
238  if (toph == v) {
239  H = Cudd_Regular(h);
240  Hv = cuddT(H); Hnv = cuddE(H);
241  if (Cudd_IsComplement(h)) {
242  Hv = Cudd_Not(Hv);
243  Hnv = Cudd_Not(Hnv);
244  }
245  } else {
246  Hv = Hnv = h;
247  }
248 
249  /* Recursion. */
250  t = Cudd_bddIteConstant(dd, Fv, Gv, Hv);
251  if (t == DD_NON_CONSTANT || !Cudd_IsConstant(t)) {
253  return(DD_NON_CONSTANT);
254  }
255  e = Cudd_bddIteConstant(dd, Fnv, Gnv, Hnv);
256  if (e == DD_NON_CONSTANT || !Cudd_IsConstant(e) || t != e) {
258  return(DD_NON_CONSTANT);
259  }
260  cuddCacheInsert(dd, DD_BDD_ITE_CONSTANT_TAG, f, g, h, t);
261  return(Cudd_NotCond(t,comple));
262 
263 } /* end of Cudd_bddIteConstant */
static int bddVarToCanonical(DdManager *dd, DdNode **fp, DdNode **gp, DdNode **hp, unsigned int *topfp, unsigned int *topgp, unsigned int *tophp)
Definition: cuddBddIte.c:1173
Definition: cudd.h:278
#define Cudd_Not(node)
Definition: cudd.h:367
#define DD_BDD_ITE_CONSTANT_TAG
Definition: cuddInt.h:186
#define Cudd_IsConstant(node)
Definition: cudd.h:352
#define Cudd_Regular(node)
Definition: cudd.h:397
void cuddCacheInsert(DdManager *table, ptruint op, DdNode *f, DdNode *g, DdNode *h, DdNode *data)
Definition: cuddCache.c:222
DdNode * Cudd_bddIteConstant(DdManager *dd, DdNode *f, DdNode *g, DdNode *h)
Definition: cuddBddIte.c:174
#define statLine(dd)
Definition: cuddInt.h:1037
static void bddVarToConst(DdNode *f, DdNode **gp, DdNode **hp, DdNode *one)
Definition: cuddBddIte.c:1138
#define Cudd_IsComplement(node)
Definition: cudd.h:425
static DdNode * one
Definition: cuddDecomp.c:112
#define ddMin(x, y)
Definition: cuddInt.h:818
DdNode * cuddConstantLookup(DdManager *table, ptruint op, DdNode *f, DdNode *g, DdNode *h)
Definition: cuddCache.c:721
#define cuddT(node)
Definition: cuddInt.h:636
#define cuddE(node)
Definition: cuddInt.h:652
#define Cudd_NotCond(node, c)
Definition: cudd.h:383
#define DD_ONE(dd)
Definition: cuddInt.h:911
static DdNode * zero
Definition: cuddApa.c:100
#define DD_NON_CONSTANT
Definition: cuddInt.h:123
int Cudd_bddIterConjDecomp ( DdManager dd,
DdNode f,
DdNode ***  conjuncts 
)

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

Synopsis [Performs two-way conjunctive decomposition of a BDD.]

Description [Performs two-way conjunctive decomposition of a BDD. This procedure owes its name to the iterated use of supersetting to obtain a factor of the given function. Returns the number of conjuncts produced, that is, 2 if successful; 1 if no meaningful decomposition was found; 0 otherwise. The conjuncts produced by this procedure tend to be imbalanced.]

SideEffects [The factors are returned in an array as side effects. The array is allocated by this function. It is the caller's responsibility to free it. On successful completion, the conjuncts are already referenced. If the function returns 0, the array for the conjuncts is not allocated. If the function returns 1, the only factor equals the function to be decomposed.]

SeeAlso [Cudd_bddIterDisjDecomp Cudd_bddApproxConjDecomp Cudd_bddGenConjDecomp Cudd_bddVarConjDecomp Cudd_RemapOverApprox Cudd_bddSqueeze Cudd_bddLICompaction]

Definition at line 313 of file cuddDecomp.c.

317 {
318  DdNode *superset1, *superset2, *old[2], *res[2];
319  int sizeOld, sizeNew;
320  int nvars = Cudd_SupportSize(dd,f);
321 
322  old[0] = DD_ONE(dd);
323  cuddRef(old[0]);
324  old[1] = f;
325  cuddRef(old[1]);
326  sizeOld = Cudd_SharingSize(old,2);
327 
328  do {
329  /* Find a tentative first factor by overapproximation and
330  ** minimization. */
331  superset1 = Cudd_RemapOverApprox(dd,old[1],nvars,0,1.0);
332  if (superset1 == NULL) {
333  Cudd_RecursiveDeref(dd,old[0]);
334  Cudd_RecursiveDeref(dd,old[1]);
335  return(0);
336  }
337  cuddRef(superset1);
338  superset2 = Cudd_bddSqueeze(dd,old[1],superset1);
339  if (superset2 == NULL) {
340  Cudd_RecursiveDeref(dd,old[0]);
341  Cudd_RecursiveDeref(dd,old[1]);
342  Cudd_RecursiveDeref(dd,superset1);
343  return(0);
344  }
345  cuddRef(superset2);
346  Cudd_RecursiveDeref(dd,superset1);
347  res[0] = Cudd_bddAnd(dd,old[0],superset2);
348  if (res[0] == NULL) {
349  Cudd_RecursiveDeref(dd,superset2);
350  Cudd_RecursiveDeref(dd,old[0]);
351  Cudd_RecursiveDeref(dd,old[1]);
352  return(0);
353  }
354  cuddRef(res[0]);
355  Cudd_RecursiveDeref(dd,superset2);
356  if (res[0] == old[0]) {
357  Cudd_RecursiveDeref(dd,res[0]);
358  break; /* avoid infinite loop */
359  }
360 
361  /* Compute the second factor by minimization. */
362  res[1] = Cudd_bddLICompaction(dd,old[1],res[0]);
363  if (res[1] == NULL) {
364  Cudd_RecursiveDeref(dd,old[0]);
365  Cudd_RecursiveDeref(dd,old[1]);
366  return(0);
367  }
368  cuddRef(res[1]);
369 
370  sizeNew = Cudd_SharingSize(res,2);
371  if (sizeNew <= sizeOld) {
372  Cudd_RecursiveDeref(dd,old[0]);
373  old[0] = res[0];
374  Cudd_RecursiveDeref(dd,old[1]);
375  old[1] = res[1];
376  sizeOld = sizeNew;
377  } else {
378  Cudd_RecursiveDeref(dd,res[0]);
379  Cudd_RecursiveDeref(dd,res[1]);
380  break;
381  }
382 
383  } while (1);
384 
385  /* Refine the first factor by minimization. If h turns out to
386  ** be f, this step guarantees that g will be 1. */
387  superset1 = Cudd_bddLICompaction(dd,old[0],old[1]);
388  if (superset1 == NULL) {
389  Cudd_RecursiveDeref(dd,old[0]);
390  Cudd_RecursiveDeref(dd,old[1]);
391  return(0);
392  }
393  cuddRef(superset1);
394  Cudd_RecursiveDeref(dd,old[0]);
395  old[0] = superset1;
396 
397  if (old[0] != DD_ONE(dd)) {
398  if (old[1] != DD_ONE(dd)) {
399  *conjuncts = ABC_ALLOC(DdNode *,2);
400  if (*conjuncts == NULL) {
401  Cudd_RecursiveDeref(dd,old[0]);
402  Cudd_RecursiveDeref(dd,old[1]);
404  return(0);
405  }
406  (*conjuncts)[0] = old[0];
407  (*conjuncts)[1] = old[1];
408  return(2);
409  } else {
410  Cudd_RecursiveDeref(dd,old[1]);
411  *conjuncts = ABC_ALLOC(DdNode *,1);
412  if (*conjuncts == NULL) {
413  Cudd_RecursiveDeref(dd,old[0]);
415  return(0);
416  }
417  (*conjuncts)[0] = old[0];
418  return(1);
419  }
420  } else {
421  Cudd_RecursiveDeref(dd,old[0]);
422  *conjuncts = ABC_ALLOC(DdNode *,1);
423  if (*conjuncts == NULL) {
424  Cudd_RecursiveDeref(dd,old[1]);
426  return(0);
427  }
428  (*conjuncts)[0] = old[1];
429  return(1);
430  }
431 
432 } /* end of Cudd_bddIterConjDecomp */
#define cuddRef(n)
Definition: cuddInt.h:584
void Cudd_RecursiveDeref(DdManager *table, DdNode *n)
Definition: cuddRef.c:154
Definition: cudd.h:278
DdNode * Cudd_RemapOverApprox(DdManager *dd, DdNode *f, int numVars, int threshold, double quality)
Definition: cuddApprox.c:366
#define ABC_ALLOC(type, num)
Definition: abc_global.h:229
DdNode * Cudd_bddLICompaction(DdManager *dd, DdNode *f, DdNode *c)
Definition: cuddGenCof.c:570
DdNode * Cudd_bddAnd(DdManager *dd, DdNode *f, DdNode *g)
Definition: cuddBddIte.c:314
#define DD_ONE(dd)
Definition: cuddInt.h:911
int Cudd_SupportSize(DdManager *dd, DdNode *f)
Definition: cuddUtil.c:857
int Cudd_SharingSize(DdNode **nodeArray, int n)
Definition: cuddUtil.c:544
Cudd_ErrorType errorCode
Definition: cuddInt.h:447
DdNode * Cudd_bddSqueeze(DdManager *dd, DdNode *l, DdNode *u)
Definition: cuddGenCof.c:602
int Cudd_bddIterDisjDecomp ( DdManager dd,
DdNode f,
DdNode ***  disjuncts 
)

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

Synopsis [Performs two-way disjunctive decomposition of a BDD.]

Description [Performs two-way disjunctive decomposition of a BDD. Returns the number of disjuncts produced, that is, 2 if successful; 1 if no meaningful decomposition was found; 0 otherwise. The disjuncts produced by this procedure tend to be imbalanced.]

SideEffects [The two disjuncts are returned in an array as side effects. The array is allocated by this function. It is the caller's responsibility to free it. On successful completion, the disjuncts are already referenced. If the function returns 0, the array for the disjuncts is not allocated. If the function returns 1, the only factor equals the function to be decomposed.]

SeeAlso [Cudd_bddIterConjDecomp Cudd_bddApproxDisjDecomp Cudd_bddGenDisjDecomp Cudd_bddVarDisjDecomp]

Definition at line 456 of file cuddDecomp.c.

460 {
461  int result, i;
462 
463  result = Cudd_bddIterConjDecomp(dd,Cudd_Not(f),disjuncts);
464  for (i = 0; i < result; i++) {
465  (*disjuncts)[i] = Cudd_Not((*disjuncts)[i]);
466  }
467  return(result);
468 
469 } /* end of Cudd_bddIterDisjDecomp */
#define Cudd_Not(node)
Definition: cudd.h:367
int Cudd_bddIterConjDecomp(DdManager *dd, DdNode *f, DdNode ***conjuncts)
Definition: cuddDecomp.c:313
static int result
Definition: cuddGenetic.c:125
DdNode* Cudd_bddIthVar ( DdManager dd,
int  i 
)

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

Synopsis [Returns the BDD variable with index i.]

Description [Retrieves the BDD variable with index i if it already exists, or creates a new BDD variable. Returns a pointer to the variable if successful; NULL otherwise.]

SideEffects [None]

SeeAlso [Cudd_bddNewVar Cudd_addIthVar Cudd_bddNewVarAtLevel Cudd_ReadVars]

Definition at line 416 of file cuddAPI.c.

419 {
420  DdNode *res;
421 
422  if ((unsigned int) i >= CUDD_MAXINDEX - 1) return(NULL);
423  if (i < dd->size) {
424  res = dd->vars[i];
425  } else {
426  res = cuddUniqueInter(dd,i,dd->one,Cudd_Not(dd->one));
427  }
428 
429  return(res);
430 
431 } /* end of Cudd_bddIthVar */
Definition: cudd.h:278
#define Cudd_Not(node)
Definition: cudd.h:367
static int size
Definition: cuddSign.c:86
DdNode ** vars
Definition: cuddInt.h:390
DdNode * one
Definition: cuddInt.h:345
#define CUDD_MAXINDEX
Definition: cudd.h:112
DdNode * cuddUniqueInter(DdManager *unique, int index, DdNode *T, DdNode *E)
Definition: cuddTable.c:1128
int Cudd_bddLeq ( DdManager dd,
DdNode f,
DdNode g 
)

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

Synopsis [Determines whether f is less than or equal to g.]

Description [Returns 1 if f is less than or equal to g; 0 otherwise. No new nodes are created.]

SideEffects [None]

SeeAlso [Cudd_bddIteConstant Cudd_addEvalConst]

Definition at line 536 of file cuddBddIte.c.

540 {
541  DdNode *one, *zero, *tmp, *F, *fv, *fvn, *gv, *gvn;
542  unsigned int topf, topg, res;
543 
544  statLine(dd);
545  /* Terminal cases and normalization. */
546  if (f == g) return(1);
547 
548  if (Cudd_IsComplement(g)) {
549  /* Special case: if f is regular and g is complemented,
550  ** f(1,...,1) = 1 > 0 = g(1,...,1).
551  */
552  if (!Cudd_IsComplement(f)) return(0);
553  /* Both are complemented: Swap and complement because
554  ** f <= g <=> g' <= f' and we want the second argument to be regular.
555  */
556  tmp = g;
557  g = Cudd_Not(f);
558  f = Cudd_Not(tmp);
559  } else if (Cudd_IsComplement(f) && cuddF2L(g) < cuddF2L(f)) {
560  tmp = g;
561  g = Cudd_Not(f);
562  f = Cudd_Not(tmp);
563  }
564 
565  /* Now g is regular and, if f is not regular, f < g. */
566  one = DD_ONE(dd);
567  if (g == one) return(1); /* no need to test against zero */
568  if (f == one) return(0); /* since at this point g != one */
569  if (Cudd_Not(f) == g) return(0); /* because neither is constant */
570  zero = Cudd_Not(one);
571  if (f == zero) return(1);
572 
573  /* Here neither f nor g is constant. */
574 
575  /* Check cache. */
576  tmp = cuddCacheLookup2(dd,(DD_CTFP)Cudd_bddLeq,f,g);
577  if (tmp != NULL) {
578  return(tmp == one);
579  }
580 
581  /* Compute cofactors. */
582  F = Cudd_Regular(f);
583  topf = dd->perm[F->index];
584  topg = dd->perm[g->index];
585  if (topf <= topg) {
586  fv = cuddT(F); fvn = cuddE(F);
587  if (f != F) {
588  fv = Cudd_Not(fv);
589  fvn = Cudd_Not(fvn);
590  }
591  } else {
592  fv = fvn = f;
593  }
594  if (topg <= topf) {
595  gv = cuddT(g); gvn = cuddE(g);
596  } else {
597  gv = gvn = g;
598  }
599 
600  /* Recursive calls. Since we want to maximize the probability of
601  ** the special case f(1,...,1) > g(1,...,1), we consider the negative
602  ** cofactors first. Indeed, the complementation parity of the positive
603  ** cofactors is the same as the one of the parent functions.
604  */
605  res = Cudd_bddLeq(dd,fvn,gvn) && Cudd_bddLeq(dd,fv,gv);
606 
607  /* Store result in cache and return. */
608  cuddCacheInsert2(dd,(DD_CTFP)Cudd_bddLeq,f,g,(res ? one : zero));
609  return(res);
610 
611 } /* end of Cudd_bddLeq */
Definition: cudd.h:278
#define Cudd_Not(node)
Definition: cudd.h:367
void cuddCacheInsert2(DdManager *table, DD_CTFP op, DdNode *f, DdNode *g, DdNode *data)
Definition: cuddCache.c:277
#define Cudd_Regular(node)
Definition: cudd.h:397
DdNode *(* DD_CTFP)(DdManager *, DdNode *, DdNode *)
Definition: cudd.h:321
#define statLine(dd)
Definition: cuddInt.h:1037
DdNode * cuddCacheLookup2(DdManager *table, DD_CTFP op, DdNode *f, DdNode *g)
Definition: cuddCache.c:502
#define Cudd_IsComplement(node)
Definition: cudd.h:425
static DdNode * one
Definition: cuddDecomp.c:112
#define cuddF2L(f)
Definition: cuddInt.h:718
#define cuddT(node)
Definition: cuddInt.h:636
int Cudd_bddLeq(DdManager *dd, DdNode *f, DdNode *g)
Definition: cuddBddIte.c:536
DdHalfWord index
Definition: cudd.h:279
#define cuddE(node)
Definition: cuddInt.h:652
#define DD_ONE(dd)
Definition: cuddInt.h:911
int * perm
Definition: cuddInt.h:386
static DdNode * zero
Definition: cuddApa.c:100
int Cudd_bddLeqUnless ( DdManager dd,
DdNode f,
DdNode g,
DdNode D 
)

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

Synopsis [Tells whether f is less than of equal to G unless D is 1.]

Description [Tells whether f is less than of equal to G unless D is

  1. f, g, and D are BDDs. The function returns 1 if f is less than of equal to G, and 0 otherwise. No new nodes are created.]

SideEffects [None]

SeeAlso [Cudd_EquivDC Cudd_bddLeq Cudd_bddIteConstant]

Definition at line 622 of file cuddSat.c.

627 {
628  DdNode *tmp, *One, *F, *G;
629  DdNode *Ft, *Fe, *Gt, *Ge, *Dt, *De;
630  int res;
631  unsigned int flevel, glevel, dlevel, top;
632 
633  statLine(dd);
634 
635  One = DD_ONE(dd);
636 
637  /* Check terminal cases. */
638  if (f == g || g == One || f == Cudd_Not(One) || D == One ||
639  D == f || D == Cudd_Not(g)) return(1);
640  /* Check for two-operand cases. */
641  if (D == Cudd_Not(One) || D == g || D == Cudd_Not(f))
642  return(Cudd_bddLeq(dd,f,g));
643  if (g == Cudd_Not(One) || g == Cudd_Not(f)) return(Cudd_bddLeq(dd,f,D));
644  if (f == One) return(Cudd_bddLeq(dd,Cudd_Not(g),D));
645 
646  /* From now on, f, g, and D are non-constant, distinct, and
647  ** non-complementary. */
648 
649  /* Normalize call to increase cache efficiency. We rely on the
650  ** fact that f <= g unless D is equivalent to not(g) <= not(f)
651  ** unless D and to f <= D unless g. We make sure that D is
652  ** regular, and that at most one of f and g is complemented. We also
653  ** ensure that when two operands can be swapped, the one with the
654  ** lowest address comes first. */
655 
656  if (Cudd_IsComplement(D)) {
657  if (Cudd_IsComplement(g)) {
658  /* Special case: if f is regular and g is complemented,
659  ** f(1,...,1) = 1 > 0 = g(1,...,1). If D(1,...,1) = 0, return 0.
660  */
661  if (!Cudd_IsComplement(f)) return(0);
662  /* !g <= D unless !f or !D <= g unless !f */
663  tmp = D;
664  D = Cudd_Not(f);
665  if (g < tmp) {
666  f = Cudd_Not(g);
667  g = tmp;
668  } else {
669  f = Cudd_Not(tmp);
670  }
671  } else {
672  if (Cudd_IsComplement(f)) {
673  /* !D <= !f unless g or !D <= g unless !f */
674  tmp = f;
675  f = Cudd_Not(D);
676  if (tmp < g) {
677  D = g;
678  g = Cudd_Not(tmp);
679  } else {
680  D = Cudd_Not(tmp);
681  }
682  } else {
683  /* f <= D unless g or !D <= !f unless g */
684  tmp = D;
685  D = g;
686  if (tmp < f) {
687  g = Cudd_Not(f);
688  f = Cudd_Not(tmp);
689  } else {
690  g = tmp;
691  }
692  }
693  }
694  } else {
695  if (Cudd_IsComplement(g)) {
696  if (Cudd_IsComplement(f)) {
697  /* !g <= !f unless D or !g <= D unless !f */
698  tmp = f;
699  f = Cudd_Not(g);
700  if (D < tmp) {
701  g = D;
702  D = Cudd_Not(tmp);
703  } else {
704  g = Cudd_Not(tmp);
705  }
706  } else {
707  /* f <= g unless D or !g <= !f unless D */
708  if (g < f) {
709  tmp = g;
710  g = Cudd_Not(f);
711  f = Cudd_Not(tmp);
712  }
713  }
714  } else {
715  /* f <= g unless D or f <= D unless g */
716  if (D < g) {
717  tmp = D;
718  D = g;
719  g = tmp;
720  }
721  }
722  }
723 
724  /* From now on, D is regular. */
725 
726  /* Check cache. */
727  tmp = cuddCacheLookup(dd,DD_BDD_LEQ_UNLESS_TAG,f,g,D);
728  if (tmp != NULL) return(tmp == One);
729 
730  /* Find splitting variable. */
731  F = Cudd_Regular(f);
732  flevel = dd->perm[F->index];
733  G = Cudd_Regular(g);
734  glevel = dd->perm[G->index];
735  top = ddMin(flevel,glevel);
736  dlevel = dd->perm[D->index];
737  top = ddMin(top,dlevel);
738 
739  /* Compute cofactors. */
740  if (top == flevel) {
741  Ft = cuddT(F);
742  Fe = cuddE(F);
743  if (F != f) {
744  Ft = Cudd_Not(Ft);
745  Fe = Cudd_Not(Fe);
746  }
747  } else {
748  Ft = Fe = f;
749  }
750  if (top == glevel) {
751  Gt = cuddT(G);
752  Ge = cuddE(G);
753  if (G != g) {
754  Gt = Cudd_Not(Gt);
755  Ge = Cudd_Not(Ge);
756  }
757  } else {
758  Gt = Ge = g;
759  }
760  if (top == dlevel) {
761  Dt = cuddT(D);
762  De = cuddE(D);
763  } else {
764  Dt = De = D;
765  }
766 
767  /* Solve recursively. */
768  res = Cudd_bddLeqUnless(dd,Ft,Gt,Dt);
769  if (res != 0) {
770  res = Cudd_bddLeqUnless(dd,Fe,Ge,De);
771  }
773 
774  return(res);
775 
776 } /* end of Cudd_bddLeqUnless */
Definition: cudd.h:278
#define Cudd_Not(node)
Definition: cudd.h:367
#define Cudd_Regular(node)
Definition: cudd.h:397
void cuddCacheInsert(DdManager *table, ptruint op, DdNode *f, DdNode *g, DdNode *h, DdNode *data)
Definition: cuddCache.c:222
#define statLine(dd)
Definition: cuddInt.h:1037
#define Cudd_IsComplement(node)
Definition: cudd.h:425
#define ddMin(x, y)
Definition: cuddInt.h:818
#define cuddT(node)
Definition: cuddInt.h:636
#define DD_BDD_LEQ_UNLESS_TAG
Definition: cuddInt.h:188
int Cudd_bddLeq(DdManager *dd, DdNode *f, DdNode *g)
Definition: cuddBddIte.c:536
DdHalfWord index
Definition: cudd.h:279
#define cuddE(node)
Definition: cuddInt.h:652
#define Cudd_NotCond(node, c)
Definition: cudd.h:383
#define DD_ONE(dd)
Definition: cuddInt.h:911
int * perm
Definition: cuddInt.h:386
int Cudd_bddLeqUnless(DdManager *dd, DdNode *f, DdNode *g, DdNode *D)
Definition: cuddSat.c:622
DdNode * cuddCacheLookup(DdManager *table, ptruint op, DdNode *f, DdNode *g, DdNode *h)
Definition: cuddCache.c:369
DdNode* Cudd_bddLICompaction ( DdManager dd,
DdNode f,
DdNode c 
)

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

Synopsis [Performs safe minimization of a BDD.]

Description [Performs safe minimization of a BDD. Given the BDD f of a function to be minimized and a BDD c representing the care set, Cudd_bddLICompaction produces the BDD of a function that agrees with f wherever c is 1. Safe minimization means that the size of the result is guaranteed not to exceed the size of f. This function is based on the DAC97 paper by Hong et al.. Returns a pointer to the result if successful; NULL otherwise.]

SideEffects [None]

SeeAlso [Cudd_bddRestrict]

Definition at line 570 of file cuddGenCof.c.

574 {
575  DdNode *res;
576 
577  do {
578  dd->reordered = 0;
579  res = cuddBddLICompaction(dd,f,c);
580  } while (dd->reordered == 1);
581  return(res);
582 
583 } /* end of Cudd_bddLICompaction */
Definition: cudd.h:278
int reordered
Definition: cuddInt.h:409
DdNode * cuddBddLICompaction(DdManager *dd, DdNode *f, DdNode *c)
Definition: cuddGenCof.c:1434
DdNode* Cudd_bddLiteralSetIntersection ( DdManager dd,
DdNode f,
DdNode g 
)

AutomaticStart AutomaticEnd Function********************************************************************

Synopsis [Computes the intesection of two sets of literals represented as BDDs.]

Description [Computes the intesection of two sets of literals represented as BDDs. Each set is represented as a cube of the literals in the set. The empty set is represented by the constant 1. No variable can be simultaneously present in both phases in a set. Returns a pointer to the BDD representing the intersected sets, if successful; NULL otherwise.]

SideEffects [None]

Definition at line 118 of file cuddLiteral.c.

122 {
123  DdNode *res;
124 
125  do {
126  dd->reordered = 0;
128  } while (dd->reordered == 1);
129  return(res);
130 
131 } /* end of Cudd_bddLiteralSetIntersection */
Definition: cudd.h:278
DdNode * cuddBddLiteralSetIntersectionRecur(DdManager *dd, DdNode *f, DdNode *g)
Definition: cuddLiteral.c:153
int reordered
Definition: cuddInt.h:409
DdNode* Cudd_bddMakePrime ( DdManager dd,
DdNode cube,
DdNode f 
)

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

Synopsis [Expands cube to a prime implicant of f.]

Description [Expands cube to a prime implicant of f. Returns the prime if successful; NULL otherwise. In particular, NULL is returned if cube is not a real cube or is not an implicant of f.]

SideEffects [None]

SeeAlso []

Definition at line 864 of file cuddSat.c.

868 {
869  DdNode *res;
870 
871  if (!Cudd_bddLeq(dd,cube,f)) return(NULL);
872 
873  do {
874  dd->reordered = 0;
875  res = cuddBddMakePrime(dd,cube,f);
876  } while (dd->reordered == 1);
877  return(res);
878 
879 } /* end of Cudd_bddMakePrime */
Definition: cudd.h:278
DdNode * cuddBddMakePrime(DdManager *dd, DdNode *cube, DdNode *f)
Definition: cuddSat.c:900
int reordered
Definition: cuddInt.h:409
int Cudd_bddLeq(DdManager *dd, DdNode *f, DdNode *g)
Definition: cuddBddIte.c:536
DdNode* Cudd_bddMinimize ( DdManager dd,
DdNode f,
DdNode c 
)

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

Synopsis [Finds a small BDD that agrees with f over c.]

Description [Finds a small BDD that agrees with f over c. Returns a pointer to the result if successful; NULL otherwise.]

SideEffects [None]

SeeAlso [Cudd_bddRestrict Cudd_bddLICompaction Cudd_bddSqueeze]

Definition at line 653 of file cuddGenCof.c.

657 {
658  DdNode *cplus, *res;
659 
660  if (c == Cudd_Not(DD_ONE(dd))) return(c);
661  if (Cudd_IsConstant(f)) return(f);
662  if (f == c) return(DD_ONE(dd));
663  if (f == Cudd_Not(c)) return(Cudd_Not(DD_ONE(dd)));
664 
665  cplus = Cudd_RemapOverApprox(dd,c,0,0,1.0);
666  if (cplus == NULL) return(NULL);
667  cuddRef(cplus);
668  res = Cudd_bddLICompaction(dd,f,cplus);
669  if (res == NULL) {
670  Cudd_IterDerefBdd(dd,cplus);
671  return(NULL);
672  }
673  cuddRef(res);
674  Cudd_IterDerefBdd(dd,cplus);
675  cuddDeref(res);
676  return(res);
677 
678 } /* end of Cudd_bddMinimize */
void Cudd_IterDerefBdd(DdManager *table, DdNode *n)
Definition: cuddRef.c:217
#define cuddRef(n)
Definition: cuddInt.h:584
#define cuddDeref(n)
Definition: cuddInt.h:604
Definition: cudd.h:278
DdNode * Cudd_bddLICompaction(DdManager *dd, DdNode *f, DdNode *c)
Definition: cuddGenCof.c:570
#define Cudd_Not(node)
Definition: cudd.h:367
#define Cudd_IsConstant(node)
Definition: cudd.h:352
DdNode * Cudd_RemapOverApprox(DdManager *dd, DdNode *f, int numVars, int threshold, double quality)
Definition: cuddApprox.c:366
#define DD_ONE(dd)
Definition: cuddInt.h:911
DdNode* Cudd_bddNand ( DdManager dd,
DdNode f,
DdNode g 
)

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

Synopsis [Computes the NAND of two BDDs f and g.]

Description [Computes the NAND of two BDDs f and g. Returns a pointer to the resulting BDD if successful; NULL if the intermediate result blows up.]

SideEffects [None]

SeeAlso [Cudd_bddIte Cudd_addApply Cudd_bddAnd Cudd_bddOr Cudd_bddNor Cudd_bddXor Cudd_bddXnor]

Definition at line 413 of file cuddBddIte.c.

417 {
418  DdNode *res;
419 
420  do {
421  dd->reordered = 0;
422  res = cuddBddAndRecur(dd,f,g);
423  } while (dd->reordered == 1);
424  res = Cudd_NotCond(res,res != NULL);
425  return(res);
426 
427 } /* end of Cudd_bddNand */
Definition: cudd.h:278
int reordered
Definition: cuddInt.h:409
#define Cudd_NotCond(node, c)
Definition: cudd.h:383
DdNode * cuddBddAndRecur(DdManager *manager, DdNode *f, DdNode *g)
Definition: cuddBddIte.c:886
DdNode* Cudd_bddNewVar ( DdManager dd)

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

Synopsis [Returns a new BDD variable.]

Description [Creates a new BDD variable. The new variable has an index equal to the largest previous index plus 1. Returns a pointer to the new variable if successful; NULL otherwise.]

SideEffects [None]

SeeAlso [Cudd_addNewVar Cudd_bddIthVar Cudd_bddNewVarAtLevel]

Definition at line 323 of file cuddAPI.c.

325 {
326  DdNode *res;
327 
328  if ((unsigned int) dd->size >= CUDD_MAXINDEX - 1) return(NULL);
329  res = cuddUniqueInter(dd,dd->size,dd->one,Cudd_Not(dd->one));
330 
331  return(res);
332 
333 } /* end of Cudd_bddNewVar */
Definition: cudd.h:278
#define Cudd_Not(node)
Definition: cudd.h:367
int size
Definition: cuddInt.h:361
DdNode * one
Definition: cuddInt.h:345
#define CUDD_MAXINDEX
Definition: cudd.h:112
DdNode * cuddUniqueInter(DdManager *unique, int index, DdNode *T, DdNode *E)
Definition: cuddTable.c:1128
DdNode* Cudd_bddNewVarAtLevel ( DdManager dd,
int  level 
)

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

Synopsis [Returns a new BDD variable at a specified level.]

Description [Creates a new BDD variable. The new variable has an index equal to the largest previous index plus 1 and is positioned at the specified level in the order. Returns a pointer to the new variable if successful; NULL otherwise.]

SideEffects [None]

SeeAlso [Cudd_bddNewVar Cudd_bddIthVar Cudd_addNewVarAtLevel]

Definition at line 351 of file cuddAPI.c.

354 {
355  DdNode *res;
356 
357  if ((unsigned int) dd->size >= CUDD_MAXINDEX - 1) return(NULL);
358  if (level >= dd->size) return(Cudd_bddIthVar(dd,level));
359  if (!cuddInsertSubtables(dd,1,level)) return(NULL);
360  res = dd->vars[dd->size - 1];
361 
362  return(res);
363 
364 } /* end of Cudd_bddNewVarAtLevel */
Definition: cudd.h:278
int size
Definition: cuddInt.h:361
DdNode * Cudd_bddIthVar(DdManager *dd, int i)
Definition: cuddAPI.c:416
int cuddInsertSubtables(DdManager *unique, int n, int level)
Definition: cuddTable.c:1795
DdNode ** vars
Definition: cuddInt.h:390
#define CUDD_MAXINDEX
Definition: cudd.h:112
DdNode* Cudd_bddNor ( DdManager dd,
DdNode f,
DdNode g 
)

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

Synopsis [Computes the NOR of two BDDs f and g.]

Description [Computes the NOR of two BDDs f and g. Returns a pointer to the resulting BDD if successful; NULL if the intermediate result blows up.]

SideEffects [None]

SeeAlso [Cudd_bddIte Cudd_addApply Cudd_bddAnd Cudd_bddOr Cudd_bddNand Cudd_bddXor Cudd_bddXnor]

Definition at line 445 of file cuddBddIte.c.

449 {
450  DdNode *res;
451 
452  do {
453  dd->reordered = 0;
454  res = cuddBddAndRecur(dd,Cudd_Not(f),Cudd_Not(g));
455  } while (dd->reordered == 1);
456  return(res);
457 
458 } /* end of Cudd_bddNor */
Definition: cudd.h:278
#define Cudd_Not(node)
Definition: cudd.h:367
int reordered
Definition: cuddInt.h:409
DdNode * cuddBddAndRecur(DdManager *manager, DdNode *f, DdNode *g)
Definition: cuddBddIte.c:886
DdNode* Cudd_bddNPAnd ( DdManager dd,
DdNode f,
DdNode g 
)

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

Synopsis [Computes f non-polluting-and g.]

Description [Computes f non-polluting-and g. The non-polluting AND of f and g is a hybrid of AND and Restrict. From Restrict, this operation takes the idea of existentially quantifying the top variable of the second operand if it does not appear in the first. Therefore, the variables that appear in the result also appear in f. For the rest, the function behaves like AND. Since the two operands play different roles, non-polluting AND is not commutative.

Returns a pointer to the result if successful; NULL otherwise.]

SideEffects [None]

SeeAlso [Cudd_bddConstrain Cudd_bddRestrict]

Definition at line 299 of file cuddGenCof.c.

303 {
304  DdNode *res;
305 
306  do {
307  dd->reordered = 0;
308  res = cuddBddNPAndRecur(dd,f,g);
309  } while (dd->reordered == 1);
310  return(res);
311 
312 } /* end of Cudd_bddNPAnd */
Definition: cudd.h:278
int reordered
Definition: cuddInt.h:409
DdNode * cuddBddNPAndRecur(DdManager *manager, DdNode *f, DdNode *g)
Definition: cuddGenCof.c:1062
DdNode* Cudd_bddOr ( DdManager dd,
DdNode f,
DdNode g 
)

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

Synopsis [Computes the disjunction of two BDDs f and g.]

Description [Computes the disjunction of two BDDs f and g. Returns a pointer to the resulting BDD if successful; NULL if the intermediate result blows up.]

SideEffects [None]

SeeAlso [Cudd_bddIte Cudd_addApply Cudd_bddAnd Cudd_bddNand Cudd_bddNor Cudd_bddXor Cudd_bddXnor]

Definition at line 381 of file cuddBddIte.c.

385 {
386  DdNode *res;
387 
388  do {
389  dd->reordered = 0;
390  res = cuddBddAndRecur(dd,Cudd_Not(f),Cudd_Not(g));
391  } while (dd->reordered == 1);
392  res = Cudd_NotCond(res,res != NULL);
393  return(res);
394 
395 } /* end of Cudd_bddOr */
Definition: cudd.h:278
#define Cudd_Not(node)
Definition: cudd.h:367
int reordered
Definition: cuddInt.h:409
#define Cudd_NotCond(node, c)
Definition: cudd.h:383
DdNode * cuddBddAndRecur(DdManager *manager, DdNode *f, DdNode *g)
Definition: cuddBddIte.c:886
DdNode* Cudd_bddPermute ( DdManager manager,
DdNode node,
int *  permut 
)

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

Synopsis [Permutes the variables of a BDD.]

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. Returns a pointer to the resulting BDD if successful; NULL otherwise.]

SideEffects [None]

SeeAlso [Cudd_addPermute Cudd_bddSwapVariables]

Definition at line 332 of file cuddCompose.c.

336 {
337  DdHashTable *table;
338  DdNode *res;
339 
340  do {
341  manager->reordered = 0;
342  table = cuddHashTableInit(manager,1,2);
343  if (table == NULL) return(NULL);
344  res = cuddBddPermuteRecur(manager,table,node,permut);
345  if (res != NULL) cuddRef(res);
346  /* Dispose of local cache. */
347  cuddHashTableQuit(table);
348 
349  } while (manager->reordered == 1);
350 
351  if (res != NULL) cuddDeref(res);
352  return(res);
353 
354 } /* end of Cudd_bddPermute */
#define cuddRef(n)
Definition: cuddInt.h:584
#define cuddDeref(n)
Definition: cuddInt.h:604
Definition: cudd.h:278
int reordered
Definition: cuddInt.h:409
void cuddHashTableQuit(DdHashTable *hash)
Definition: cuddLCache.c:595
DdHashTable * cuddHashTableInit(DdManager *manager, unsigned int keySize, unsigned int initSize)
Definition: cuddLCache.c:538
static DdNode * cuddBddPermuteRecur(DdManager *manager, DdHashTable *table, DdNode *node, int *permut)
Definition: cuddCompose.c:1150
DdNode** Cudd_bddPickArbitraryMinterms ( DdManager dd,
DdNode f,
DdNode **  vars,
int  n,
int  k 
)

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

Synopsis [Picks k on-set minterms evenly distributed from given DD.]

Description [Picks k on-set minterms evenly distributed from given DD. The minterms are in terms of vars. The array vars should contain at least all variables in the support of f; if this condition is not met the minterms built by this procedure may not be contained in f. Builds an array of BDDs for the minterms and returns a pointer to it if successful; NULL otherwise. There are three reasons why the procedure may fail:

  • It may run out of memory;
  • the function f may be the constant 0;
  • the minterms may not be contained in f.

]

SideEffects [None]

SeeAlso [Cudd_bddPickOneMinterm Cudd_bddPickOneCube]

Definition at line 1393 of file cuddUtil.c.

1399 {
1400  char **string;
1401  int i, j, l, size;
1402  int *indices;
1403  int result;
1404  DdNode **old, *neW;
1405  double minterms;
1406  char *saveString;
1407  int saveFlag, savePoint = -1, isSame;
1408 
1409  minterms = Cudd_CountMinterm(dd,f,n);
1410  if ((double)k > minterms) {
1411  return(NULL);
1412  }
1413 
1414  size = dd->size;
1415  string = ABC_ALLOC(char *, k);
1416  if (string == NULL) {
1417  dd->errorCode = CUDD_MEMORY_OUT;
1418  return(NULL);
1419  }
1420  for (i = 0; i < k; i++) {
1421  string[i] = ABC_ALLOC(char, size + 1);
1422  if (string[i] == NULL) {
1423  for (j = 0; j < i; j++)
1424  ABC_FREE(string[i]);
1425  ABC_FREE(string);
1426  dd->errorCode = CUDD_MEMORY_OUT;
1427  return(NULL);
1428  }
1429  for (j = 0; j < size; j++) string[i][j] = '2';
1430  string[i][size] = '\0';
1431  }
1432  indices = ABC_ALLOC(int,n);
1433  if (indices == NULL) {
1434  dd->errorCode = CUDD_MEMORY_OUT;
1435  for (i = 0; i < k; i++)
1436  ABC_FREE(string[i]);
1437  ABC_FREE(string);
1438  return(NULL);
1439  }
1440 
1441  for (i = 0; i < n; i++) {
1442  indices[i] = vars[i]->index;
1443  }
1444 
1445  result = ddPickArbitraryMinterms(dd,f,n,k,string);
1446  if (result == 0) {
1447  for (i = 0; i < k; i++)
1448  ABC_FREE(string[i]);
1449  ABC_FREE(string);
1450  ABC_FREE(indices);
1451  return(NULL);
1452  }
1453 
1454  old = ABC_ALLOC(DdNode *, k);
1455  if (old == NULL) {
1456  dd->errorCode = CUDD_MEMORY_OUT;
1457  for (i = 0; i < k; i++)
1458  ABC_FREE(string[i]);
1459  ABC_FREE(string);
1460  ABC_FREE(indices);
1461  return(NULL);
1462  }
1463  saveString = ABC_ALLOC(char, size + 1);
1464  if (saveString == NULL) {
1465  dd->errorCode = CUDD_MEMORY_OUT;
1466  for (i = 0; i < k; i++)
1467  ABC_FREE(string[i]);
1468  ABC_FREE(string);
1469  ABC_FREE(indices);
1470  ABC_FREE(old);
1471  return(NULL);
1472  }
1473  saveFlag = 0;
1474 
1475  /* Build result BDD array. */
1476  for (i = 0; i < k; i++) {
1477  isSame = 0;
1478  if (!saveFlag) {
1479  for (j = i + 1; j < k; j++) {
1480  if (strcmp(string[i], string[j]) == 0) {
1481  savePoint = i;
1482  strcpy(saveString, string[i]);
1483  saveFlag = 1;
1484  break;
1485  }
1486  }
1487  } else {
1488  if (strcmp(string[i], saveString) == 0) {
1489  isSame = 1;
1490  } else {
1491  saveFlag = 0;
1492  for (j = i + 1; j < k; j++) {
1493  if (strcmp(string[i], string[j]) == 0) {
1494  savePoint = i;
1495  strcpy(saveString, string[i]);
1496  saveFlag = 1;
1497  break;
1498  }
1499  }
1500  }
1501  }
1502  /* Randomize choice for don't cares. */
1503  for (j = 0; j < n; j++) {
1504  if (string[i][indices[j]] == '2')
1505  string[i][indices[j]] =
1506  (char) ((Cudd_Random() & 0x20) ? '1' : '0');
1507  }
1508 
1509  while (isSame) {
1510  isSame = 0;
1511  for (j = savePoint; j < i; j++) {
1512  if (strcmp(string[i], string[j]) == 0) {
1513  isSame = 1;
1514  break;
1515  }
1516  }
1517  if (isSame) {
1518  strcpy(string[i], saveString);
1519  /* Randomize choice for don't cares. */
1520  for (j = 0; j < n; j++) {
1521  if (string[i][indices[j]] == '2')
1522  string[i][indices[j]] =
1523  (char) ((Cudd_Random() & 0x20) ? '1' : '0');
1524  }
1525  }
1526  }
1527 
1528  old[i] = Cudd_ReadOne(dd);
1529  cuddRef(old[i]);
1530 
1531  for (j = 0; j < n; j++) {
1532  if (string[i][indices[j]] == '0') {
1533  neW = Cudd_bddAnd(dd,old[i],Cudd_Not(vars[j]));
1534  } else {
1535  neW = Cudd_bddAnd(dd,old[i],vars[j]);
1536  }
1537  if (neW == NULL) {
1538  ABC_FREE(saveString);
1539  for (l = 0; l < k; l++)
1540  ABC_FREE(string[l]);
1541  ABC_FREE(string);
1542  ABC_FREE(indices);
1543  for (l = 0; l <= i; l++)
1544  Cudd_RecursiveDeref(dd,old[l]);
1545  ABC_FREE(old);
1546  return(NULL);
1547  }
1548  cuddRef(neW);
1549  Cudd_RecursiveDeref(dd,old[i]);
1550  old[i] = neW;
1551  }
1552 
1553  /* Test. */
1554  if (!Cudd_bddLeq(dd,old[i],f)) {
1555  ABC_FREE(saveString);
1556  for (l = 0; l < k; l++)
1557  ABC_FREE(string[l]);
1558  ABC_FREE(string);
1559  ABC_FREE(indices);
1560  for (l = 0; l <= i; l++)
1561  Cudd_RecursiveDeref(dd,old[l]);
1562  ABC_FREE(old);
1563  return(NULL);
1564  }
1565  }
1566 
1567  ABC_FREE(saveString);
1568  for (i = 0; i < k; i++) {
1569  cuddDeref(old[i]);
1570  ABC_FREE(string[i]);
1571  }
1572  ABC_FREE(string);
1573  ABC_FREE(indices);
1574  return(old);
1575 
1576 } /* end of Cudd_bddPickArbitraryMinterms */
#define cuddRef(n)
Definition: cuddInt.h:584
#define cuddDeref(n)
Definition: cuddInt.h:604
void Cudd_RecursiveDeref(DdManager *table, DdNode *n)
Definition: cuddRef.c:154
Definition: cudd.h:278
#define Cudd_Not(node)
Definition: cudd.h:367
static int ddPickArbitraryMinterms(DdManager *dd, DdNode *node, int nvars, int nminterms, char **string)
Definition: cuddUtil.c:3798
int size
Definition: cuddInt.h:361
#define ABC_ALLOC(type, num)
Definition: abc_global.h:229
int strcmp()
double Cudd_CountMinterm(DdManager *manager, DdNode *node, int nvars)
Definition: cuddUtil.c:578
long Cudd_Random(void)
Definition: cuddUtil.c:2702
static int size
Definition: cuddSign.c:86
char * strcpy()
DdNode * Cudd_ReadOne(DdManager *dd)
Definition: cuddAPI.c:987
int Cudd_bddLeq(DdManager *dd, DdNode *f, DdNode *g)
Definition: cuddBddIte.c:536
DdHalfWord index
Definition: cudd.h:279
#define ABC_FREE(obj)
Definition: abc_global.h:232
DdNode * Cudd_bddAnd(DdManager *dd, DdNode *f, DdNode *g)
Definition: cuddBddIte.c:314
static int result
Definition: cuddGenetic.c:125
Cudd_ErrorType errorCode
Definition: cuddInt.h:447
pset minterms()
int Cudd_bddPickOneCube ( DdManager ddm,
DdNode node,
char *  string 
)

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

Synopsis [Picks one on-set cube randomly from the given DD.]

Description [Picks one on-set cube randomly from the given DD. The cube is written into an array of characters. The array must have at least as many entries as there are variables. Returns 1 if successful; 0 otherwise.]

SideEffects [None]

SeeAlso [Cudd_bddPickOneMinterm]

Definition at line 1221 of file cuddUtil.c.

1225 {
1226  DdNode *N, *T, *E;
1227  DdNode *one, *bzero;
1228  char dir;
1229  int i;
1230 
1231  if (string == NULL || node == NULL) return(0);
1232 
1233  /* The constant 0 function has no on-set cubes. */
1234  one = DD_ONE(ddm);
1235  bzero = Cudd_Not(one);
1236  if (node == bzero) return(0);
1237 
1238  for (i = 0; i < ddm->size; i++) string[i] = 2;
1239 
1240  for (;;) {
1241 
1242  if (node == one) break;
1243 
1244  N = Cudd_Regular(node);
1245 
1246  T = cuddT(N); E = cuddE(N);
1247  if (Cudd_IsComplement(node)) {
1248  T = Cudd_Not(T); E = Cudd_Not(E);
1249  }
1250  if (T == bzero) {
1251  string[N->index] = 0;
1252  node = E;
1253  } else if (E == bzero) {
1254  string[N->index] = 1;
1255  node = T;
1256  } else {
1257  dir = (char) ((Cudd_Random() & 0x2000) >> 13);
1258  string[N->index] = dir;
1259  node = dir ? T : E;
1260  }
1261  }
1262  return(1);
1263 
1264 } /* end of Cudd_bddPickOneCube */
Definition: cudd.h:278
#define Cudd_Not(node)
Definition: cudd.h:367
int size
Definition: cuddInt.h:361
#define Cudd_Regular(node)
Definition: cudd.h:397
long Cudd_Random(void)
Definition: cuddUtil.c:2702
#define Cudd_IsComplement(node)
Definition: cudd.h:425
static DdNode * one
Definition: cuddDecomp.c:112
#define cuddT(node)
Definition: cuddInt.h:636
DdHalfWord index
Definition: cudd.h:279
#define cuddE(node)
Definition: cuddInt.h:652
#define DD_ONE(dd)
Definition: cuddInt.h:911
DdNode* Cudd_bddPickOneMinterm ( DdManager dd,
DdNode f,
DdNode **  vars,
int  n 
)

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

Synopsis [Picks one on-set minterm randomly from the given DD.]

Description [Picks one on-set minterm randomly from the given DD. The minterm is in terms of vars. The array vars should contain at least all variables in the support of f; if this condition is not met the minterm built by this procedure may not be contained in f. Builds a BDD for the minterm and returns a pointer to it if successful; NULL otherwise. There are three reasons why the procedure may fail:

  • It may run out of memory;
  • the function f may be the constant 0;
  • the minterm may not be contained in f.

]

SideEffects [None]

SeeAlso [Cudd_bddPickOneCube]

Definition at line 1291 of file cuddUtil.c.

1296 {
1297  char *string;
1298  int i, size;
1299  int *indices;
1300  int result;
1301  DdNode *old, *neW;
1302 
1303  size = dd->size;
1304  string = ABC_ALLOC(char, size);
1305  if (string == NULL) {
1306  dd->errorCode = CUDD_MEMORY_OUT;
1307  return(NULL);
1308  }
1309  indices = ABC_ALLOC(int,n);
1310  if (indices == NULL) {
1311  dd->errorCode = CUDD_MEMORY_OUT;
1312  ABC_FREE(string);
1313  return(NULL);
1314  }
1315 
1316  for (i = 0; i < n; i++) {
1317  indices[i] = vars[i]->index;
1318  }
1319 
1320  result = Cudd_bddPickOneCube(dd,f,string);
1321  if (result == 0) {
1322  ABC_FREE(string);
1323  ABC_FREE(indices);
1324  return(NULL);
1325  }
1326 
1327  /* Randomize choice for don't cares. */
1328  for (i = 0; i < n; i++) {
1329  if (string[indices[i]] == 2)
1330  string[indices[i]] = (char) ((Cudd_Random() & 0x20) >> 5);
1331  }
1332 
1333  /* Build result BDD. */
1334  old = Cudd_ReadOne(dd);
1335  cuddRef(old);
1336 
1337  for (i = n-1; i >= 0; i--) {
1338  neW = Cudd_bddAnd(dd,old,Cudd_NotCond(vars[i],string[indices[i]]==0));
1339  if (neW == NULL) {
1340  ABC_FREE(string);
1341  ABC_FREE(indices);
1342  Cudd_RecursiveDeref(dd,old);
1343  return(NULL);
1344  }
1345  cuddRef(neW);
1346  Cudd_RecursiveDeref(dd,old);
1347  old = neW;
1348  }
1349 
1350 #ifdef DD_DEBUG
1351  /* Test. */
1352  if (Cudd_bddLeq(dd,old,f)) {
1353  cuddDeref(old);
1354  } else {
1355  Cudd_RecursiveDeref(dd,old);
1356  old = NULL;
1357  }
1358 #else
1359  cuddDeref(old);
1360 #endif
1361 
1362  ABC_FREE(string);
1363  ABC_FREE(indices);
1364  return(old);
1365 
1366 } /* end of Cudd_bddPickOneMinterm */
#define cuddRef(n)
Definition: cuddInt.h:584
#define cuddDeref(n)
Definition: cuddInt.h:604
void Cudd_RecursiveDeref(DdManager *table, DdNode *n)
Definition: cuddRef.c:154
Definition: cudd.h:278
int size
Definition: cuddInt.h:361
#define ABC_ALLOC(type, num)
Definition: abc_global.h:229
long Cudd_Random(void)
Definition: cuddUtil.c:2702
static int size
Definition: cuddSign.c:86
DdNode * Cudd_ReadOne(DdManager *dd)
Definition: cuddAPI.c:987
int Cudd_bddLeq(DdManager *dd, DdNode *f, DdNode *g)
Definition: cuddBddIte.c:536
int Cudd_bddPickOneCube(DdManager *ddm, DdNode *node, char *string)
Definition: cuddUtil.c:1221
DdHalfWord index
Definition: cudd.h:279
#define ABC_FREE(obj)
Definition: abc_global.h:232
#define Cudd_NotCond(node, c)
Definition: cudd.h:383
DdNode * Cudd_bddAnd(DdManager *dd, DdNode *f, DdNode *g)
Definition: cuddBddIte.c:314
static int result
Definition: cuddGenetic.c:125
Cudd_ErrorType errorCode
Definition: cuddInt.h:447
int Cudd_bddPrintCover ( DdManager dd,
DdNode l,
DdNode u 
)

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

Synopsis [Prints a sum of prime implicants of a BDD.]

Description [Prints a sum of product cover for an incompletely specified function given by a lower bound and an upper bound. Each product is a prime implicant obtained by expanding the product corresponding to a path from node to the constant one. Uses the package default output file. Returns 1 if successful; 0 otherwise.]

SideEffects [None]

SeeAlso [Cudd_PrintMinterm]

Definition at line 253 of file cuddUtil.c.

257 {
258  int *array;
259  int q, result;
260  DdNode *lb;
261 #ifdef DD_DEBUG
262  DdNode *cover;
263 #endif
264 
265  array = ABC_ALLOC(int, Cudd_ReadSize(dd));
266  if (array == NULL) return(0);
267  lb = l;
268  cuddRef(lb);
269 #ifdef DD_DEBUG
270  cover = Cudd_ReadLogicZero(dd);
271  cuddRef(cover);
272 #endif
273  while (lb != Cudd_ReadLogicZero(dd)) {
274  DdNode *implicant, *prime, *tmp;
275  int length;
276  implicant = Cudd_LargestCube(dd,lb,&length);
277  if (implicant == NULL) {
278  Cudd_RecursiveDeref(dd,lb);
279  ABC_FREE(array);
280  return(0);
281  }
282  cuddRef(implicant);
283  prime = Cudd_bddMakePrime(dd,implicant,u);
284  if (prime == NULL) {
285  Cudd_RecursiveDeref(dd,lb);
286  Cudd_RecursiveDeref(dd,implicant);
287  ABC_FREE(array);
288  return(0);
289  }
290  cuddRef(prime);
291  Cudd_RecursiveDeref(dd,implicant);
292  tmp = Cudd_bddAnd(dd,lb,Cudd_Not(prime));
293  if (tmp == NULL) {
294  Cudd_RecursiveDeref(dd,lb);
295  Cudd_RecursiveDeref(dd,prime);
296  ABC_FREE(array);
297  return(0);
298  }
299  cuddRef(tmp);
300  Cudd_RecursiveDeref(dd,lb);
301  lb = tmp;
302  result = Cudd_BddToCubeArray(dd,prime,array);
303  if (result == 0) {
304  Cudd_RecursiveDeref(dd,lb);
305  Cudd_RecursiveDeref(dd,prime);
306  ABC_FREE(array);
307  return(0);
308  }
309  for (q = 0; q < dd->size; q++) {
310  switch (array[q]) {
311  case 0:
312  (void) fprintf(dd->out, "0");
313  break;
314  case 1:
315  (void) fprintf(dd->out, "1");
316  break;
317  case 2:
318  (void) fprintf(dd->out, "-");
319  break;
320  default:
321  (void) fprintf(dd->out, "?");
322  }
323  }
324  (void) fprintf(dd->out, " 1\n");
325 #ifdef DD_DEBUG
326  tmp = Cudd_bddOr(dd,prime,cover);
327  if (tmp == NULL) {
328  Cudd_RecursiveDeref(dd,cover);
329  Cudd_RecursiveDeref(dd,lb);
330  Cudd_RecursiveDeref(dd,prime);
331  ABC_FREE(array);
332  return(0);
333  }
334  cuddRef(tmp);
335  Cudd_RecursiveDeref(dd,cover);
336  cover = tmp;
337 #endif
338  Cudd_RecursiveDeref(dd,prime);
339  }
340  (void) fprintf(dd->out, "\n");
341  Cudd_RecursiveDeref(dd,lb);
342  ABC_FREE(array);
343 #ifdef DD_DEBUG
344  if (!Cudd_bddLeq(dd,cover,u) || !Cudd_bddLeq(dd,l,cover)) {
345  Cudd_RecursiveDeref(dd,cover);
346  return(0);
347  }
348  Cudd_RecursiveDeref(dd,cover);
349 #endif
350  return(1);
351 
352 } /* end of Cudd_bddPrintCover */
#define cuddRef(n)
Definition: cuddInt.h:584
void Cudd_RecursiveDeref(DdManager *table, DdNode *n)
Definition: cuddRef.c:154
Definition: cudd.h:278
#define Cudd_Not(node)
Definition: cudd.h:367
int size
Definition: cuddInt.h:361
DdNode * Cudd_ReadLogicZero(DdManager *dd)
Definition: cuddAPI.c:1058
#define ABC_ALLOC(type, num)
Definition: abc_global.h:229
int Cudd_ReadSize(DdManager *dd)
Definition: cuddAPI.c:1441
DdNode * Cudd_LargestCube(DdManager *manager, DdNode *f, int *length)
Definition: cuddSat.c:285
DdNode * Cudd_bddMakePrime(DdManager *dd, DdNode *cube, DdNode *f)
Definition: cuddSat.c:864
int Cudd_BddToCubeArray(DdManager *dd, DdNode *cube, int *array)
Definition: cuddUtil.c:2346
FILE * out
Definition: cuddInt.h:441
DdNode * Cudd_bddOr(DdManager *dd, DdNode *f, DdNode *g)
Definition: cuddBddIte.c:381
int Cudd_bddLeq(DdManager *dd, DdNode *f, DdNode *g)
Definition: cuddBddIte.c:536
#define ABC_FREE(obj)
Definition: abc_global.h:232
DdNode * Cudd_bddAnd(DdManager *dd, DdNode *f, DdNode *g)
Definition: cuddBddIte.c:314
static int result
Definition: cuddGenetic.c:125
int Cudd_bddRead ( FILE *  fp,
DdManager dd,
DdNode **  E,
DdNode ***  x,
DdNode ***  y,
int *  nx,
int *  ny,
int *  m,
int *  n,
int  bx,
int  sx,
int  by,
int  sy 
)

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

Synopsis [Reads in a graph (without labels) given as a list of arcs.]

Description [Reads in a graph (without labels) given as an adjacency matrix. The first line of the input contains the numbers of rows and columns of the adjacency matrix. The remaining lines contain the arcs of the graph, one per line. Each arc is described by two integers, i.e., the row and column number, or the indices of the two endpoints. Cudd_bddRead produces a BDD that depends on two sets of variables: x and y. The x variables (x[0] ... x[nx-1]) encode the row index and the y variables (y[0] ... y[ny-1]) encode the column index. x[0] and y[0] are the most significant bits in the indices. The variables may already exist or may be created by the function. The index of x[i] is bx+i*sx, and the index of y[i] is by+i*sy.

On input, nx and ny hold the numbers of row and column variables already in existence. On output, they hold the numbers of row and column variables actually used by the matrix. When Cudd_bddRead creates the variable arrays, the index of x[i] is bx+i*sx, and the index of y[i] is by+i*sy. When some variables already exist, Cudd_bddRead expects the indices of the existing x variables to be bx+i*sx, and the indices of the existing y variables to be by+i*sy.

m and n are set to the numbers of rows and columns of the matrix. Their values on input are immaterial. The BDD for the graph is returned in E, and its reference count is > 0. Cudd_bddRead returns 1 in case of success; 0 otherwise.]

SideEffects [nx and ny are set to the numbers of row and column variables. m and n are set to the numbers of rows and columns. x and y are possibly extended to represent the array of row and column variables.]

SeeAlso [Cudd_addHarwell Cudd_addRead]

Definition at line 369 of file cuddRead.c.

383 {
384  DdNode *one, *zero;
385  DdNode *w;
386  DdNode *minterm1;
387  int u, v, err, i, nv;
388  int lnx, lny;
389  DdNode **lx, **ly;
390 
391  one = DD_ONE(dd);
392  zero = Cudd_Not(one);
393 
394  err = fscanf(fp, "%d %d", &u, &v);
395  if (err == EOF) {
396  return(0);
397  } else if (err != 2) {
398  return(0);
399  }
400 
401  *m = u;
402  /* Compute the number of x variables. */
403  lx = *x;
404  u--; /* row and column numbers start from 0 */
405  for (lnx=0; u > 0; lnx++) {
406  u >>= 1;
407  }
408  if (lnx > *nx) {
409  *x = lx = ABC_REALLOC(DdNode *, *x, lnx);
410  if (lx == NULL) {
412  return(0);
413  }
414  }
415 
416  *n = v;
417  /* Compute the number of y variables. */
418  ly = *y;
419  v--; /* row and column numbers start from 0 */
420  for (lny=0; v > 0; lny++) {
421  v >>= 1;
422  }
423  if (lny > *ny) {
424  *y = ly = ABC_REALLOC(DdNode *, *y, lny);
425  if (ly == NULL) {
427  return(0);
428  }
429  }
430 
431  /* Create all new variables. */
432  for (i = *nx, nv = bx + (*nx) * sx; i < lnx; i++, nv += sx) {
433  do {
434  dd->reordered = 0;
435  lx[i] = cuddUniqueInter(dd, nv, one, zero);
436  } while (dd->reordered == 1);
437  if (lx[i] == NULL) return(0);
438  cuddRef(lx[i]);
439  }
440  for (i = *ny, nv = by + (*ny) * sy; i < lny; i++, nv += sy) {
441  do {
442  dd->reordered = 0;
443  ly[i] = cuddUniqueInter(dd, nv, one, zero);
444  } while (dd->reordered == 1);
445  if (ly[i] == NULL) return(0);
446  cuddRef(ly[i]);
447  }
448  *nx = lnx;
449  *ny = lny;
450 
451  *E = zero; /* this call will never cause reordering */
452  cuddRef(*E);
453 
454  while (! feof(fp)) {
455  err = fscanf(fp, "%d %d", &u, &v);
456  if (err == EOF) {
457  break;
458  } else if (err != 2) {
459  return(0);
460  } else if (u >= *m || v >= *n || u < 0 || v < 0) {
461  return(0);
462  }
463 
464  minterm1 = one; cuddRef(minterm1);
465 
466  /* Build minterm1 corresponding to this arc. */
467  for (i = lnx - 1; i>=0; i--) {
468  if (u & 1) {
469  w = Cudd_bddAnd(dd, minterm1, lx[i]);
470  } else {
471  w = Cudd_bddAnd(dd, minterm1, Cudd_Not(lx[i]));
472  }
473  if (w == NULL) {
474  Cudd_RecursiveDeref(dd, minterm1);
475  return(0);
476  }
477  cuddRef(w);
478  Cudd_RecursiveDeref(dd,minterm1);
479  minterm1 = w;
480  u >>= 1;
481  }
482  for (i = lny - 1; i>=0; i--) {
483  if (v & 1) {
484  w = Cudd_bddAnd(dd, minterm1, ly[i]);
485  } else {
486  w = Cudd_bddAnd(dd, minterm1, Cudd_Not(ly[i]));
487  }
488  if (w == NULL) {
489  Cudd_RecursiveDeref(dd, minterm1);
490  return(0);
491  }
492  cuddRef(w);
493  Cudd_RecursiveDeref(dd, minterm1);
494  minterm1 = w;
495  v >>= 1;
496  }
497 
498  w = Cudd_bddAnd(dd, Cudd_Not(minterm1), Cudd_Not(*E));
499  if (w == NULL) {
500  Cudd_RecursiveDeref(dd, minterm1);
501  return(0);
502  }
503  w = Cudd_Not(w);
504  cuddRef(w);
505  Cudd_RecursiveDeref(dd, minterm1);
506  Cudd_RecursiveDeref(dd, *E);
507  *E = w;
508  }
509  return(1);
510 
511 } /* end of Cudd_bddRead */
#define cuddRef(n)
Definition: cuddInt.h:584
void Cudd_RecursiveDeref(DdManager *table, DdNode *n)
Definition: cuddRef.c:154
Definition: cudd.h:278
#define Cudd_Not(node)
Definition: cudd.h:367
#define ABC_REALLOC(type, obj, num)
Definition: abc_global.h:233
int reordered
Definition: cuddInt.h:409
static DdNode * one
Definition: cuddDecomp.c:112
DdNode * Cudd_bddAnd(DdManager *dd, DdNode *f, DdNode *g)
Definition: cuddBddIte.c:314
#define DD_ONE(dd)
Definition: cuddInt.h:911
Cudd_ErrorType errorCode
Definition: cuddInt.h:447
DdNode * cuddUniqueInter(DdManager *unique, int index, DdNode *T, DdNode *E)
Definition: cuddTable.c:1128
static DdNode * zero
Definition: cuddApa.c:100
int Cudd_bddReadPairIndex ( DdManager dd,
int  index 
)

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

Synopsis [Reads a corresponding pair index for a given index.]

Description [Reads a corresponding pair index for a given index. These pair indices are present and next state variable. Returns the corresponding variable index if the variable exists; -1 otherwise.]

SideEffects [modifies the manager]

SeeAlso [Cudd_bddSetPairIndex]

Definition at line 4148 of file cuddAPI.c.

4151 {
4152  if (index >= dd->size || index < 0) return -1;
4153  return dd->subtables[dd->perm[index]].pairIndex;
4154 
4155 } /* end of Cudd_bddReadPairIndex */
int size
Definition: cuddInt.h:361
DdSubtable * subtables
Definition: cuddInt.h:365
int pairIndex
Definition: cuddInt.h:337
int * perm
Definition: cuddInt.h:386
void Cudd_bddRealignDisable ( DdManager unique)

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

Synopsis [Disables realignment of ZDD order to BDD order.]

Description []

SideEffects [None]

SeeAlso [Cudd_bddRealignEnable Cudd_bddRealignmentEnabled Cudd_zddRealignEnable Cudd_zddRealignmentEnabled]

Definition at line 965 of file cuddAPI.c.

967 {
968  unique->realignZ = 0;
969  return;
970 
971 } /* end of Cudd_bddRealignDisable */
int realignZ
Definition: cuddInt.h:421
void Cudd_bddRealignEnable ( DdManager unique)

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

Synopsis [Enables realignment of BDD order to ZDD order.]

Description [Enables realignment of the BDD variable order to the ZDD variable order after the ZDDs have been reordered. The number of ZDD variables must be a multiple of the number of BDD variables for realignment to make sense. If this condition is not met, Cudd_zddReduceHeap will return 0. Let M be the ratio of the two numbers. For the purpose of realignment, the ZDD variables from M*i to (M+1)*i-1 are reagarded as corresponding to BDD variable i. Realignment is initially disabled.]

SideEffects [None]

SeeAlso [Cudd_zddReduceHeap Cudd_bddRealignDisable Cudd_bddRealignmentEnabled Cudd_zddRealignDisable Cudd_zddRealignmentEnabled]

Definition at line 943 of file cuddAPI.c.

945 {
946  unique->realignZ = 1;
947  return;
948 
949 } /* end of Cudd_bddRealignEnable */
int realignZ
Definition: cuddInt.h:421
int Cudd_bddRealignmentEnabled ( DdManager unique)

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

Synopsis [Tells whether the realignment of BDD order to ZDD order is enabled.]

Description [Returns 1 if the realignment of BDD order to ZDD order is enabled; 0 otherwise.]

SideEffects [None]

SeeAlso [Cudd_bddRealignEnable Cudd_bddRealignDisable Cudd_zddRealignEnable Cudd_zddRealignDisable]

Definition at line 913 of file cuddAPI.c.

915 {
916  return(unique->realignZ);
917 
918 } /* end of Cudd_bddRealignmentEnabled */
int realignZ
Definition: cuddInt.h:421
int Cudd_bddResetVarToBeGrouped ( DdManager dd,
int  index 
)

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

Synopsis [Resets a variable not to be grouped.]

Description [Resets a variable not to be grouped. This function is used for lazy sifting. Returns 1 if successful; 0 otherwise.]

SideEffects [modifies the manager]

SeeAlso [Cudd_bddSetVarToBeGrouped Cudd_bddSetVarHardGroup]

Definition at line 4222 of file cuddAPI.c.

4225 {
4226  if (index >= dd->size || index < 0) return(0);
4227  if (dd->subtables[dd->perm[index]].varToBeGrouped <=
4229  dd->subtables[dd->perm[index]].varToBeGrouped = CUDD_LAZY_NONE;
4230  }
4231  return(1);
4232 
4233 } /* end of Cudd_bddResetVarToBeGrouped */
int size
Definition: cuddInt.h:361
DdSubtable * subtables
Definition: cuddInt.h:365
Cudd_LazyGroupType varToBeGrouped
Definition: cuddInt.h:339
int * perm
Definition: cuddInt.h:386
DdNode* Cudd_bddRestrict ( DdManager dd,
DdNode f,
DdNode c 
)

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

Synopsis [BDD restrict according to Coudert and Madre's algorithm (ICCAD90).]

Description [BDD restrict according to Coudert and Madre's algorithm (ICCAD90). Returns the restricted BDD if successful; otherwise NULL. If application of restrict results in a BDD larger than the input BDD, the input BDD is returned.]

SideEffects [None]

SeeAlso [Cudd_bddConstrain Cudd_addRestrict]

Definition at line 212 of file cuddGenCof.c.

216 {
217  DdNode *suppF, *suppC, *commonSupport;
218  DdNode *cplus, *res;
219  int retval;
220  int sizeF, sizeRes;
221 
222  /* Check terminal cases here to avoid computing supports in trivial cases.
223  ** This also allows us notto check later for the case c == 0, in which
224  ** there is no common support. */
225  if (c == Cudd_Not(DD_ONE(dd))) return(Cudd_Not(DD_ONE(dd)));
226  if (Cudd_IsConstant(f)) return(f);
227  if (f == c) return(DD_ONE(dd));
228  if (f == Cudd_Not(c)) return(Cudd_Not(DD_ONE(dd)));
229 
230  /* Check if supports intersect. */
231  retval = Cudd_ClassifySupport(dd,f,c,&commonSupport,&suppF,&suppC);
232  if (retval == 0) {
233  return(NULL);
234  }
235  cuddRef(commonSupport); cuddRef(suppF); cuddRef(suppC);
236  Cudd_IterDerefBdd(dd,suppF);
237 
238  if (commonSupport == DD_ONE(dd)) {
239  Cudd_IterDerefBdd(dd,commonSupport);
240  Cudd_IterDerefBdd(dd,suppC);
241  return(f);
242  }
243  Cudd_IterDerefBdd(dd,commonSupport);
244 
245  /* Abstract from c the variables that do not appear in f. */
246  cplus = Cudd_bddExistAbstract(dd, c, suppC);
247  if (cplus == NULL) {
248  Cudd_IterDerefBdd(dd,suppC);
249  return(NULL);
250  }
251  cuddRef(cplus);
252  Cudd_IterDerefBdd(dd,suppC);
253 
254  do {
255  dd->reordered = 0;
256  res = cuddBddRestrictRecur(dd, f, cplus);
257  } while (dd->reordered == 1);
258  if (res == NULL) {
259  Cudd_IterDerefBdd(dd,cplus);
260  return(NULL);
261  }
262  cuddRef(res);
263  Cudd_IterDerefBdd(dd,cplus);
264  /* Make restric safe by returning the smaller of the input and the
265  ** result. */
266  sizeF = Cudd_DagSize(f);
267  sizeRes = Cudd_DagSize(res);
268  if (sizeF <= sizeRes) {
269  Cudd_IterDerefBdd(dd, res);
270  return(f);
271  } else {
272  cuddDeref(res);
273  return(res);
274  }
275 
276 } /* end of Cudd_bddRestrict */
void Cudd_IterDerefBdd(DdManager *table, DdNode *n)
Definition: cuddRef.c:217
#define cuddRef(n)
Definition: cuddInt.h:584
#define cuddDeref(n)
Definition: cuddInt.h:604
Definition: cudd.h:278
#define Cudd_Not(node)
Definition: cudd.h:367
#define Cudd_IsConstant(node)
Definition: cudd.h:352
DdNode * Cudd_bddExistAbstract(DdManager *manager, DdNode *f, DdNode *cube)
Definition: cuddBddAbs.c:130
int reordered
Definition: cuddInt.h:409
int Cudd_ClassifySupport(DdManager *dd, DdNode *f, DdNode *g, DdNode **common, DdNode **onlyF, DdNode **onlyG)
Definition: cuddUtil.c:1085
#define DD_ONE(dd)
Definition: cuddInt.h:911
DdNode * cuddBddRestrictRecur(DdManager *dd, DdNode *f, DdNode *c)
Definition: cuddGenCof.c:912
int Cudd_DagSize(DdNode *node)
Definition: cuddUtil.c:442
int Cudd_bddSetNsVar ( DdManager dd,
int  index 
)

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

Synopsis [Sets a variable type to next state.]

Description [Sets a variable type to next state. The variable type is used by lazy sifting. Returns 1 if successful; 0 otherwise.]

SideEffects [modifies the manager]

SeeAlso [Cudd_bddSetPiVar Cudd_bddSetPsVar Cudd_bddIsNsVar]

Definition at line 4025 of file cuddAPI.c.

4028 {
4029  if (index >= dd->size || index < 0) return (0);
4030  dd->subtables[dd->perm[index]].varType = CUDD_VAR_NEXT_STATE;
4031  return(1);
4032 
4033 } /* end of Cudd_bddSetNsVar */
int size
Definition: cuddInt.h:361
DdSubtable * subtables
Definition: cuddInt.h:365
Cudd_VariableType varType
Definition: cuddInt.h:336
int * perm
Definition: cuddInt.h:386
int Cudd_bddSetPairIndex ( DdManager dd,
int  index,
int  pairIndex 
)

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

Synopsis [Sets a corresponding pair index for a given index.]

Description [Sets a corresponding pair index for a given index. These pair indices are present and next state variable. Returns 1 if successful; 0 otherwise.]

SideEffects [modifies the manager]

SeeAlso [Cudd_bddReadPairIndex]

Definition at line 4122 of file cuddAPI.c.

4126 {
4127  if (index >= dd->size || index < 0) return(0);
4128  dd->subtables[dd->perm[index]].pairIndex = pairIndex;
4129  return(1);
4130 
4131 } /* end of Cudd_bddSetPairIndex */
int size
Definition: cuddInt.h:361
DdSubtable * subtables
Definition: cuddInt.h:365
int pairIndex
Definition: cuddInt.h:337
int * perm
Definition: cuddInt.h:386
int Cudd_bddSetPiVar ( DdManager dd,
int  index 
)

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

Synopsis [Sets a variable type to primary input.]

Description [Sets a variable type to primary input. The variable type is used by lazy sifting. Returns 1 if successful; 0 otherwise.]

SideEffects [modifies the manager]

SeeAlso [Cudd_bddSetPsVar Cudd_bddSetNsVar Cudd_bddIsPiVar]

Definition at line 3977 of file cuddAPI.c.

3980 {
3981  if (index >= dd->size || index < 0) return (0);
3982  dd->subtables[dd->perm[index]].varType = CUDD_VAR_PRIMARY_INPUT;
3983  return(1);
3984 
3985 } /* end of Cudd_bddSetPiVar */
int size
Definition: cuddInt.h:361
DdSubtable * subtables
Definition: cuddInt.h:365
Cudd_VariableType varType
Definition: cuddInt.h:336
int * perm
Definition: cuddInt.h:386
int Cudd_bddSetPsVar ( DdManager dd,
int  index 
)

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

Synopsis [Sets a variable type to present state.]

Description [Sets a variable type to present state. The variable type is used by lazy sifting. Returns 1 if successful; 0 otherwise.]

SideEffects [modifies the manager]

SeeAlso [Cudd_bddSetPiVar Cudd_bddSetNsVar Cudd_bddIsPsVar]

Definition at line 4001 of file cuddAPI.c.

4004 {
4005  if (index >= dd->size || index < 0) return (0);
4006  dd->subtables[dd->perm[index]].varType = CUDD_VAR_PRESENT_STATE;
4007  return(1);
4008 
4009 } /* end of Cudd_bddSetPsVar */
int size
Definition: cuddInt.h:361
DdSubtable * subtables
Definition: cuddInt.h:365
Cudd_VariableType varType
Definition: cuddInt.h:336
int * perm
Definition: cuddInt.h:386
int Cudd_bddSetVarHardGroup ( DdManager dd,
int  index 
)

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

Synopsis [Sets a variable to be a hard group.]

Description [Sets a variable to be a hard group. This function is used for lazy sifting. Returns 1 if successful; 0 otherwise.]

SideEffects [modifies the manager]

SeeAlso [Cudd_bddSetVarToBeGrouped Cudd_bddResetVarToBeGrouped Cudd_bddIsVarHardGroup]

Definition at line 4198 of file cuddAPI.c.

4201 {
4202  if (index >= dd->size || index < 0) return(0);
4204  return(1);
4205 
4206 } /* end of Cudd_bddSetVarHardGrouped */
int size
Definition: cuddInt.h:361
DdSubtable * subtables
Definition: cuddInt.h:365
Cudd_LazyGroupType varToBeGrouped
Definition: cuddInt.h:339
int * perm
Definition: cuddInt.h:386
int Cudd_bddSetVarToBeGrouped ( DdManager dd,
int  index 
)

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

Synopsis [Sets a variable to be grouped.]

Description [Sets a variable to be grouped. This function is used for lazy sifting. Returns 1 if successful; 0 otherwise.]

SideEffects [modifies the manager]

SeeAlso [Cudd_bddSetVarHardGroup Cudd_bddResetVarToBeGrouped]

Definition at line 4171 of file cuddAPI.c.

4174 {
4175  if (index >= dd->size || index < 0) return(0);
4176  if (dd->subtables[dd->perm[index]].varToBeGrouped <= CUDD_LAZY_SOFT_GROUP) {
4178  }
4179  return(1);
4180 
4181 } /* end of Cudd_bddSetVarToBeGrouped */
int size
Definition: cuddInt.h:361
DdSubtable * subtables
Definition: cuddInt.h:365
Cudd_LazyGroupType varToBeGrouped
Definition: cuddInt.h:339
int * perm
Definition: cuddInt.h:386
int Cudd_bddSetVarToBeUngrouped ( DdManager dd,
int  index 
)

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

Synopsis [Sets a variable to be ungrouped.]

Description [Sets a variable to be ungrouped. This function is used for lazy sifting. Returns 1 if successful; 0 otherwise.]

SideEffects [modifies the manager]

SeeAlso [Cudd_bddIsVarToBeUngrouped]

Definition at line 4275 of file cuddAPI.c.

4278 {
4279  if (index >= dd->size || index < 0) return(0);
4280  dd->subtables[dd->perm[index]].varToBeGrouped = CUDD_LAZY_UNGROUP;
4281  return(1);
4282 
4283 } /* end of Cudd_bddSetVarToBeGrouped */
int size
Definition: cuddInt.h:361
DdSubtable * subtables
Definition: cuddInt.h:365
Cudd_LazyGroupType varToBeGrouped
Definition: cuddInt.h:339
int * perm
Definition: cuddInt.h:386
DdNode* Cudd_bddSqueeze ( DdManager dd,
DdNode l,
DdNode u 
)

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

Synopsis [Finds a small BDD in a function interval.]

Description [Finds a small BDD in a function interval. Given BDDs l and u, representing the lower bound and upper bound of a function interval, Cudd_bddSqueeze produces the BDD of a function within the interval with a small BDD. Returns a pointer to the result if successful; NULL otherwise.]

SideEffects [None]

SeeAlso [Cudd_bddRestrict Cudd_bddLICompaction]

Definition at line 602 of file cuddGenCof.c.

606 {
607  DdNode *res;
608  int sizeRes, sizeL, sizeU;
609 
610  do {
611  dd->reordered = 0;
612  res = cuddBddSqueeze(dd,l,u);
613  } while (dd->reordered == 1);
614  if (res == NULL) return(NULL);
615  /* We now compare the result with the bounds and return the smallest.
616  ** We first compare to u, so that in case l == 0 and u == 1, we return
617  ** 0 as in other minimization algorithms. */
618  sizeRes = Cudd_DagSize(res);
619  sizeU = Cudd_DagSize(u);
620  if (sizeU <= sizeRes) {
621  cuddRef(res);
622  Cudd_IterDerefBdd(dd,res);
623  res = u;
624  sizeRes = sizeU;
625  }
626  sizeL = Cudd_DagSize(l);
627  if (sizeL <= sizeRes) {
628  cuddRef(res);
629  Cudd_IterDerefBdd(dd,res);
630  res = l;
631  sizeRes = sizeL;
632  }
633  return(res);
634 
635 } /* end of Cudd_bddSqueeze */
void Cudd_IterDerefBdd(DdManager *table, DdNode *n)
Definition: cuddRef.c:217
#define cuddRef(n)
Definition: cuddInt.h:584
Definition: cudd.h:278
static DdNode * cuddBddSqueeze(DdManager *dd, DdNode *l, DdNode *u)
Definition: cuddGenCof.c:1967
int reordered
Definition: cuddInt.h:409
int Cudd_DagSize(DdNode *node)
Definition: cuddUtil.c:442
DdNode* Cudd_bddSwapVariables ( DdManager dd,
DdNode f,
DdNode **  x,
DdNode **  y,
int  n 
)

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

Synopsis [Swaps two sets of variables of the same size (x and y) in the BDD f.]

Description [Swaps two sets of variables of the same size (x and y) in the BDD f. The size is given by n. The two sets of variables are assumed to be disjoint. Returns a pointer to the resulting BDD if successful; NULL otherwise.]

SideEffects [None]

SeeAlso [Cudd_bddPermute Cudd_addSwapVariables]

Definition at line 464 of file cuddCompose.c.

470 {
471  DdNode *swapped;
472  int i, j, k;
473  int *permut;
474 
475  permut = ABC_ALLOC(int,dd->size);
476  if (permut == NULL) {
478  return(NULL);
479  }
480  for (i = 0; i < dd->size; i++) permut[i] = i;
481  for (i = 0; i < n; i++) {
482  j = x[i]->index;
483  k = y[i]->index;
484  permut[j] = k;
485  permut[k] = j;
486  }
487 
488  swapped = Cudd_bddPermute(dd,f,permut);
489  ABC_FREE(permut);
490 
491  return(swapped);
492 
493 } /* end of Cudd_bddSwapVariables */
Definition: cudd.h:278
int size
Definition: cuddInt.h:361
#define ABC_ALLOC(type, num)
Definition: abc_global.h:229
DdNode * Cudd_bddPermute(DdManager *manager, DdNode *node, int *permut)
Definition: cuddCompose.c:332
DdHalfWord index
Definition: cudd.h:279
#define ABC_FREE(obj)
Definition: abc_global.h:232
Cudd_ErrorType errorCode
Definition: cuddInt.h:447
DdNode* Cudd_BddToAdd ( DdManager dd,
DdNode B 
)

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

Synopsis [Converts a BDD to a 0-1 ADD.]

Description [Converts a BDD to a 0-1 ADD. Returns a pointer to the resulting ADD if successful; NULL otherwise.]

SideEffects [None]

SeeAlso [Cudd_addBddPattern Cudd_addBddThreshold Cudd_addBddInterval Cudd_addBddStrictThreshold]

Definition at line 349 of file cuddBridge.c.

352 {
353  DdNode *res;
354 
355  do {
356  dd->reordered = 0;
357  res = ddBddToAddRecur(dd, B);
358  } while (dd->reordered ==1);
359  return(res);
360 
361 } /* end of Cudd_BddToAdd */
Definition: cudd.h:278
static DdNode * ddBddToAddRecur(DdManager *dd, DdNode *B)
Definition: cuddBridge.c:866
int reordered
Definition: cuddInt.h:409
int Cudd_BddToCubeArray ( DdManager dd,
DdNode cube,
int *  array 
)

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

Synopsis [Builds a positional array from the BDD of a cube.]

Description [Builds a positional array from the BDD of a cube. Array must have one entry for each BDD variable. The positional array has 1 in i-th position if the variable of index i appears in true form in the cube; it has 0 in i-th position if the variable of index i appears in complemented form in the cube; finally, it has 2 in i-th position if the variable of index i does not appear in the cube. Returns 1 if successful (the BDD is indeed a cube); 0 otherwise.]

SideEffects [The result is in the array passed by reference.]

SeeAlso [Cudd_CubeArrayToBdd]

Definition at line 2346 of file cuddUtil.c.

2350 {
2351  DdNode *scan, *t, *e;
2352  int i;
2353  int size = Cudd_ReadSize(dd);
2354  DdNode *zero = Cudd_Not(DD_ONE(dd));
2355 
2356  for (i = size-1; i >= 0; i--) {
2357  array[i] = 2;
2358  }
2359  scan = cube;
2360  while (!Cudd_IsConstant(scan)) {
2361  int index = Cudd_Regular(scan)->index;
2362  cuddGetBranches(scan,&t,&e);
2363  if (t == zero) {
2364  array[index] = 0;
2365  scan = e;
2366  } else if (e == zero) {
2367  array[index] = 1;
2368  scan = t;
2369  } else {
2370  return(0); /* cube is not a cube */
2371  }
2372  }
2373  if (scan == zero) {
2374  return(0);
2375  } else {
2376  return(1);
2377  }
2378 
2379 } /* end of Cudd_BddToCubeArray */
Definition: cudd.h:278
#define Cudd_Not(node)
Definition: cudd.h:367
#define Cudd_IsConstant(node)
Definition: cudd.h:352
#define Cudd_Regular(node)
Definition: cudd.h:397
void cuddGetBranches(DdNode *g, DdNode **g1, DdNode **g0)
Definition: cuddCof.c:162
int Cudd_ReadSize(DdManager *dd)
Definition: cuddAPI.c:1441
static DdNode * zero
Definition: cuddUtil.c:148
static int size
Definition: cuddSign.c:86
#define DD_ONE(dd)
Definition: cuddInt.h:911
DdNode* Cudd_bddTransfer ( DdManager ddSource,
DdManager ddDestination,
DdNode f 
)

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

Synopsis [Convert a BDD from a manager to another one.]

Description [Convert a BDD from a manager to another one. The orders of the variables in the two managers may be different. Returns a pointer to the BDD in the destination manager if successful; NULL otherwise.]

SideEffects [None]

SeeAlso []

Definition at line 409 of file cuddBridge.c.

413 {
414  DdNode *res;
415  do {
416  ddDestination->reordered = 0;
417  res = cuddBddTransfer(ddSource, ddDestination, f);
418  } while (ddDestination->reordered == 1);
419  return(res);
420 
421 } /* end of Cudd_bddTransfer */
Definition: cudd.h:278
DdNode * cuddBddTransfer(DdManager *ddS, DdManager *ddD, DdNode *f)
Definition: cuddBridge.c:443
int reordered
Definition: cuddInt.h:409
int Cudd_bddUnbindVar ( DdManager dd,
int  index 
)

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

Synopsis [Allows the sifting of a variable.]

Description [This function resets the flag that prevents the sifting of a variable. In successive variable reorderings, the variable will NOT be skipped, that is, sifted. Initially all variables can be sifted. It is necessary to call this function only to re-enable sifting after a call to Cudd_bddBindVar. Returns 1 if successful; 0 otherwise (i.e., invalid variable index).]

SideEffects [Changes the "bindVar" flag in DdSubtable.]

SeeAlso [Cudd_bddBindVar]

Definition at line 3927 of file cuddAPI.c.

3930 {
3931  if (index >= dd->size || index < 0) return(0);
3932  dd->subtables[dd->perm[index]].bindVar = 0;
3933  return(1);
3934 
3935 } /* end of Cudd_bddUnbindVar */
int size
Definition: cuddInt.h:361
int bindVar
Definition: cuddInt.h:334
DdSubtable * subtables
Definition: cuddInt.h:365
int * perm
Definition: cuddInt.h:386
DdNode* Cudd_bddUnivAbstract ( DdManager manager,
DdNode f,
DdNode cube 
)

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

Synopsis [Universally abstracts all the variables in cube from f.]

Description [Universally abstracts all the variables in cube from f. Returns the abstracted BDD if successful; NULL otherwise.]

SideEffects [None]

SeeAlso [Cudd_bddExistAbstract Cudd_addUnivAbstract]

Definition at line 207 of file cuddBddAbs.c.

211 {
212  DdNode *res;
213 
214  if (bddCheckPositiveCube(manager, cube) == 0) {
215  (void) fprintf(manager->err,
216  "Error: Can only abstract positive cubes\n");
217  manager->errorCode = CUDD_INVALID_ARG;
218  return(NULL);
219  }
220 
221  do {
222  manager->reordered = 0;
223  res = cuddBddExistAbstractRecur(manager, Cudd_Not(f), cube);
224  } while (manager->reordered == 1);
225  if (res != NULL) res = Cudd_Not(res);
226 
227  return(res);
228 
229 } /* end of Cudd_bddUnivAbstract */
DdNode * cuddBddExistAbstractRecur(DdManager *manager, DdNode *f, DdNode *cube)
Definition: cuddBddAbs.c:352
Definition: cudd.h:278
#define Cudd_Not(node)
Definition: cudd.h:367
FILE * err
Definition: cuddInt.h:442
int reordered
Definition: cuddInt.h:409
static int bddCheckPositiveCube(DdManager *manager, DdNode *cube)
Definition: cuddBddAbs.c:708
Cudd_ErrorType errorCode
Definition: cuddInt.h:447
int Cudd_bddVarConjDecomp ( DdManager dd,
DdNode f,
DdNode ***  conjuncts 
)

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

Synopsis [Performs two-way conjunctive decomposition of a BDD.]

Description [Conjunctively decomposes one BDD according to a variable. If f is the function of the BDD and x is the variable, the decomposition is (f+x)(f+x'). The variable is chosen so as to balance the sizes of the two conjuncts and to keep them small. Returns the number of conjuncts produced, that is, 2 if successful; 1 if no meaningful decomposition was found; 0 otherwise.]

SideEffects [The two factors are returned in an array as side effects. The array is allocated by this function. It is the caller's responsibility to free it. On successful completion, the conjuncts are already referenced. If the function returns 0, the array for the conjuncts is not allocated. If the function returns 1, the only factor equals the function to be decomposed.]

SeeAlso [Cudd_bddVarDisjDecomp Cudd_bddGenConjDecomp Cudd_bddApproxConjDecomp Cudd_bddIterConjDecomp]

Definition at line 615 of file cuddDecomp.c.

619 {
620  int best;
621  int min;
622  DdNode *support, *scan, *var, *glocal, *hlocal;
623 
624  /* Find best cofactoring variable. */
625  support = Cudd_Support(dd,f);
626  if (support == NULL) return(0);
627  if (Cudd_IsConstant(support)) {
628  *conjuncts = ABC_ALLOC(DdNode *,1);
629  if (*conjuncts == NULL) {
631  return(0);
632  }
633  (*conjuncts)[0] = f;
634  cuddRef((*conjuncts)[0]);
635  return(1);
636  }
637  cuddRef(support);
638  min = 1000000000;
639  best = -1;
640  scan = support;
641  while (!Cudd_IsConstant(scan)) {
642  int i = scan->index;
643  int est1 = Cudd_EstimateCofactor(dd,f,i,1);
644  int est0 = Cudd_EstimateCofactor(dd,f,i,0);
645  /* Minimize the size of the larger of the two cofactors. */
646  int est = (est1 > est0) ? est1 : est0;
647  if (est < min) {
648  min = est;
649  best = i;
650  }
651  scan = cuddT(scan);
652  }
653 #ifdef DD_DEBUG
654  assert(best >= 0 && best < dd->size);
655 #endif
656  Cudd_RecursiveDeref(dd,support);
657 
658  var = Cudd_bddIthVar(dd,best);
659  glocal = Cudd_bddOr(dd,f,var);
660  if (glocal == NULL) {
661  return(0);
662  }
663  cuddRef(glocal);
664  hlocal = Cudd_bddOr(dd,f,Cudd_Not(var));
665  if (hlocal == NULL) {
666  Cudd_RecursiveDeref(dd,glocal);
667  return(0);
668  }
669  cuddRef(hlocal);
670 
671  if (glocal != DD_ONE(dd)) {
672  if (hlocal != DD_ONE(dd)) {
673  *conjuncts = ABC_ALLOC(DdNode *,2);
674  if (*conjuncts == NULL) {
675  Cudd_RecursiveDeref(dd,glocal);
676  Cudd_RecursiveDeref(dd,hlocal);
678  return(0);
679  }
680  (*conjuncts)[0] = glocal;
681  (*conjuncts)[1] = hlocal;
682  return(2);
683  } else {
684  Cudd_RecursiveDeref(dd,hlocal);
685  *conjuncts = ABC_ALLOC(DdNode *,1);
686  if (*conjuncts == NULL) {
687  Cudd_RecursiveDeref(dd,glocal);
689  return(0);
690  }
691  (*conjuncts)[0] = glocal;
692  return(1);
693  }
694  } else {
695  Cudd_RecursiveDeref(dd,glocal);
696  *conjuncts = ABC_ALLOC(DdNode *,1);
697  if (*conjuncts == NULL) {
698  Cudd_RecursiveDeref(dd,hlocal);
700  return(0);
701  }
702  (*conjuncts)[0] = hlocal;
703  return(1);
704  }
705 
706 } /* end of Cudd_bddVarConjDecomp */
#define cuddRef(n)
Definition: cuddInt.h:584
void Cudd_RecursiveDeref(DdManager *table, DdNode *n)
Definition: cuddRef.c:154
Definition: cudd.h:278
#define Cudd_Not(node)
Definition: cudd.h:367
DdNode * Cudd_Support(DdManager *dd, DdNode *f)
Definition: cuddUtil.c:740
int var(Lit p)
Definition: SolverTypes.h:62
#define Cudd_IsConstant(node)
Definition: cudd.h:352
#define ABC_ALLOC(type, num)
Definition: abc_global.h:229
static int size
Definition: cuddSign.c:86
DdNode * Cudd_bddOr(DdManager *dd, DdNode *f, DdNode *g)
Definition: cuddBddIte.c:381
#define cuddT(node)
Definition: cuddInt.h:636
int Cudd_EstimateCofactor(DdManager *dd, DdNode *node, int i, int phase)
Definition: cuddUtil.c:477
int support
Definition: abcSaucy.c:64
DdHalfWord index
Definition: cudd.h:279
DdNode * Cudd_bddIthVar(DdManager *dd, int i)
Definition: cuddAPI.c:416
#define assert(ex)
Definition: util_old.h:213
#define DD_ONE(dd)
Definition: cuddInt.h:911
Cudd_ErrorType errorCode
Definition: cuddInt.h:447
int Cudd_bddVarDisjDecomp ( DdManager dd,
DdNode f,
DdNode ***  disjuncts 
)

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

Synopsis [Performs two-way disjunctive decomposition of a BDD.]

Description [Performs two-way disjunctive decomposition of a BDD according to a variable. If f is the function of the BDD and x is the variable, the decomposition is f*x + f*x'. The variable is chosen so as to balance the sizes of the two disjuncts and to keep them small. Returns the number of disjuncts produced, that is, 2 if successful; 1 if no meaningful decomposition was found; 0 otherwise.]

SideEffects [The two disjuncts are returned in an array as side effects. The array is allocated by this function. It is the caller's responsibility to free it. On successful completion, the disjuncts are already referenced. If the function returns 0, the array for the disjuncts is not allocated. If the function returns 1, the only factor equals the function to be decomposed.]

SeeAlso [Cudd_bddVarConjDecomp Cudd_bddApproxDisjDecomp Cudd_bddIterDisjDecomp Cudd_bddGenDisjDecomp]

Definition at line 733 of file cuddDecomp.c.

737 {
738  int result, i;
739 
740  result = Cudd_bddVarConjDecomp(dd,Cudd_Not(f),disjuncts);
741  for (i = 0; i < result; i++) {
742  (*disjuncts)[i] = Cudd_Not((*disjuncts)[i]);
743  }
744  return(result);
745 
746 } /* end of Cudd_bddVarDisjDecomp */
#define Cudd_Not(node)
Definition: cudd.h:367
int Cudd_bddVarConjDecomp(DdManager *dd, DdNode *f, DdNode ***conjuncts)
Definition: cuddDecomp.c:615
static int result
Definition: cuddGenetic.c:125
int Cudd_bddVarIsBound ( DdManager dd,
int  index 
)

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

Synopsis [Tells whether a variable can be sifted.]

Description [This function returns 1 if a variable is enabled for sifting. Initially all variables can be sifted. This function returns 0 only if there has been a previous call to Cudd_bddBindVar for that variable not followed by a call to Cudd_bddUnbindVar. The function returns 0 also in the case in which the index of the variable is out of bounds.]

SideEffects [none]

SeeAlso [Cudd_bddBindVar Cudd_bddUnbindVar]

Definition at line 3954 of file cuddAPI.c.

3957 {
3958  if (index >= dd->size || index < 0) return(0);
3959  return(dd->subtables[dd->perm[index]].bindVar);
3960 
3961 } /* end of Cudd_bddVarIsBound */
int size
Definition: cuddInt.h:361
int bindVar
Definition: cuddInt.h:334
DdSubtable * subtables
Definition: cuddInt.h:365
int * perm
Definition: cuddInt.h:386
int Cudd_bddVarIsDependent ( DdManager dd,
DdNode f,
DdNode var 
)

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

Synopsis [Checks whether a variable is dependent on others in a function.]

Description [Checks whether a variable is dependent on others in a function. Returns 1 if the variable is dependent; 0 otherwise. No new nodes are created.]

SideEffects [None]

SeeAlso []

Definition at line 284 of file cuddBddAbs.c.

288 {
289  DdNode *F, *res, *zero, *ft, *fe;
290  unsigned topf, level;
291  DD_CTFP cacheOp;
292  int retval;
293 
294  zero = Cudd_Not(DD_ONE(dd));
295  if (Cudd_IsConstant(f)) return(f == zero);
296 
297  /* From now on f is not constant. */
298  F = Cudd_Regular(f);
299  topf = (unsigned) dd->perm[F->index];
300  level = (unsigned) dd->perm[var->index];
301 
302  /* Check terminal case. If topf > index of var, f does not depend on var.
303  ** Therefore, var is not dependent in f. */
304  if (topf > level) {
305  return(0);
306  }
307 
308  cacheOp = (DD_CTFP) Cudd_bddVarIsDependent;
309  res = cuddCacheLookup2(dd,cacheOp,f,var);
310  if (res != NULL) {
311  return(res != zero);
312  }
313 
314  /* Compute cofactors. */
315  ft = Cudd_NotCond(cuddT(F), f != F);
316  fe = Cudd_NotCond(cuddE(F), f != F);
317 
318  if (topf == level) {
319  retval = Cudd_bddLeq(dd,ft,Cudd_Not(fe));
320  } else {
321  retval = Cudd_bddVarIsDependent(dd,ft,var) &&
322  Cudd_bddVarIsDependent(dd,fe,var);
323  }
324 
325  cuddCacheInsert2(dd,cacheOp,f,var,Cudd_NotCond(zero,retval));
326 
327  return(retval);
328 
329 } /* Cudd_bddVarIsDependent */
Definition: cudd.h:278
#define Cudd_Not(node)
Definition: cudd.h:367
void cuddCacheInsert2(DdManager *table, DD_CTFP op, DdNode *f, DdNode *g, DdNode *data)
Definition: cuddCache.c:277
#define Cudd_IsConstant(node)
Definition: cudd.h:352
#define Cudd_Regular(node)
Definition: cudd.h:397
DdNode *(* DD_CTFP)(DdManager *, DdNode *, DdNode *)
Definition: cudd.h:321
DdNode * cuddCacheLookup2(DdManager *table, DD_CTFP op, DdNode *f, DdNode *g)
Definition: cuddCache.c:502
int Cudd_bddVarIsDependent(DdManager *dd, DdNode *f, DdNode *var)
Definition: cuddBddAbs.c:284
#define cuddT(node)
Definition: cuddInt.h:636
int Cudd_bddLeq(DdManager *dd, DdNode *f, DdNode *g)
Definition: cuddBddIte.c:536
DdHalfWord index
Definition: cudd.h:279
#define cuddE(node)
Definition: cuddInt.h:652
#define Cudd_NotCond(node, c)
Definition: cudd.h:383
#define DD_ONE(dd)
Definition: cuddInt.h:911
int * perm
Definition: cuddInt.h:386
static DdNode * zero
Definition: cuddApa.c:100
DdNode* Cudd_bddVarMap ( DdManager manager,
DdNode f 
)

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

Synopsis [Remaps the variables of a BDD using the default variable map.]

Description [Remaps the variables of a BDD using the default variable map. A typical use of this function is to swap two sets of variables. The variable map must be registered with Cudd_SetVarMap. Returns a pointer to the resulting BDD if successful; NULL otherwise.]

SideEffects [None]

SeeAlso [Cudd_bddPermute Cudd_bddSwapVariables Cudd_SetVarMap]

Definition at line 373 of file cuddCompose.c.

376 {
377  DdNode *res;
378 
379  if (manager->map == NULL) return(NULL);
380  do {
381  manager->reordered = 0;
382  res = cuddBddVarMapRecur(manager, f);
383  } while (manager->reordered == 1);
384 
385  return(res);
386 
387 } /* end of Cudd_bddVarMap */
int * map
Definition: cuddInt.h:391
Definition: cudd.h:278
int reordered
Definition: cuddInt.h:409
static DdNode * cuddBddVarMapRecur(DdManager *manager, DdNode *f)
Definition: cuddCompose.c:1232
DdNode* Cudd_bddVectorCompose ( DdManager dd,
DdNode f,
DdNode **  vector 
)

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

Synopsis [Composes a BDD with a vector of BDDs.]

Description [Given a vector of BDDs, creates a new BDD by substituting the BDDs for the variables of the BDD f. There should be an entry in vector for each variable in the manager. If no substitution is sought for a given variable, the corresponding projection function should be specified in the vector. This function implements simultaneous composition. Returns a pointer to the resulting BDD if successful; NULL otherwise.]

SideEffects [None]

SeeAlso [Cudd_bddPermute Cudd_bddCompose Cudd_addVectorCompose]

Definition at line 791 of file cuddCompose.c.

795 {
796  DdHashTable *table;
797  DdNode *res;
798  int deepest;
799  int i;
800 
801  do {
802  dd->reordered = 0;
803  /* Initialize local cache. */
804  table = cuddHashTableInit(dd,1,2);
805  if (table == NULL) return(NULL);
806 
807  /* Find deepest real substitution. */
808  for (deepest = dd->size - 1; deepest >= 0; deepest--) {
809  i = dd->invperm[deepest];
810  if (vector[i] != dd->vars[i]) {
811  break;
812  }
813  }
814 
815  /* Recursively solve the problem. */
816  res = cuddBddVectorComposeRecur(dd,table,f,vector, deepest);
817  if (res != NULL) cuddRef(res);
818 
819  /* Dispose of local cache. */
820  cuddHashTableQuit(table);
821  } while (dd->reordered == 1);
822 
823  if (res != NULL) cuddDeref(res);
824  return(res);
825 
826 } /* end of Cudd_bddVectorCompose */
#define cuddRef(n)
Definition: cuddInt.h:584
#define cuddDeref(n)
Definition: cuddInt.h:604
Definition: cudd.h:278
int size
Definition: cuddInt.h:361
int reordered
Definition: cuddInt.h:409
void cuddHashTableQuit(DdHashTable *hash)
Definition: cuddLCache.c:595
DdNode ** vars
Definition: cuddInt.h:390
DdHashTable * cuddHashTableInit(DdManager *manager, unsigned int keySize, unsigned int initSize)
Definition: cuddLCache.c:538
static DdNode * cuddBddVectorComposeRecur(DdManager *dd, DdHashTable *table, DdNode *f, DdNode **vector, int deepest)
Definition: cuddCompose.c:1640
int * invperm
Definition: cuddInt.h:388
DdNode* Cudd_bddXnor ( DdManager dd,
DdNode f,
DdNode g 
)

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

Synopsis [Computes the exclusive NOR of two BDDs f and g.]

Description [Computes the exclusive NOR of two BDDs f and g. Returns a pointer to the resulting BDD if successful; NULL if the intermediate result blows up.]

SideEffects [None]

SeeAlso [Cudd_bddIte Cudd_addApply Cudd_bddAnd Cudd_bddOr Cudd_bddNand Cudd_bddNor Cudd_bddXor]

Definition at line 507 of file cuddBddIte.c.

511 {
512  DdNode *res;
513 
514  do {
515  dd->reordered = 0;
516  res = cuddBddXorRecur(dd,f,Cudd_Not(g));
517  } while (dd->reordered == 1);
518  return(res);
519 
520 } /* end of Cudd_bddXnor */
Definition: cudd.h:278
#define Cudd_Not(node)
Definition: cudd.h:367
int reordered
Definition: cuddInt.h:409
DdNode * cuddBddXorRecur(DdManager *manager, DdNode *f, DdNode *g)
Definition: cuddBddIte.c:1017
DdNode* Cudd_bddXor ( DdManager dd,
DdNode f,
DdNode g 
)

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

Synopsis [Computes the exclusive OR of two BDDs f and g.]

Description [Computes the exclusive OR of two BDDs f and g. Returns a pointer to the resulting BDD if successful; NULL if the intermediate result blows up.]

SideEffects [None]

SeeAlso [Cudd_bddIte Cudd_addApply Cudd_bddAnd Cudd_bddOr Cudd_bddNand Cudd_bddNor Cudd_bddXnor]

Definition at line 476 of file cuddBddIte.c.

480 {
481  DdNode *res;
482 
483  do {
484  dd->reordered = 0;
485  res = cuddBddXorRecur(dd,f,g);
486  } while (dd->reordered == 1);
487  return(res);
488 
489 } /* end of Cudd_bddXor */
Definition: cudd.h:278
int reordered
Definition: cuddInt.h:409
DdNode * cuddBddXorRecur(DdManager *manager, DdNode *f, DdNode *g)
Definition: cuddBddIte.c:1017
DdNode* Cudd_bddXorExistAbstract ( DdManager manager,
DdNode f,
DdNode g,
DdNode cube 
)

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

Synopsis [Takes the exclusive OR of two BDDs and simultaneously abstracts the variables in cube.]

Description [Takes the exclusive OR of two BDDs and simultaneously abstracts the variables in cube. The variables are existentially abstracted. Returns a pointer to the result is successful; NULL otherwise.]

SideEffects [None]

SeeAlso [Cudd_bddUnivAbstract Cudd_bddExistAbstract Cudd_bddAndAbstract]

Definition at line 169 of file cuddBddAbs.c.

174 {
175  DdNode *res;
176 
177  if (bddCheckPositiveCube(manager, cube) == 0) {
178  (void) fprintf(manager->err,
179  "Error: Can only abstract positive cubes\n");
180  manager->errorCode = CUDD_INVALID_ARG;
181  return(NULL);
182  }
183 
184  do {
185  manager->reordered = 0;
186  res = cuddBddXorExistAbstractRecur(manager, f, g, cube);
187  } while (manager->reordered == 1);
188 
189  return(res);
190 
191 } /* end of Cudd_bddXorExistAbstract */
Definition: cudd.h:278
FILE * err
Definition: cuddInt.h:442
int reordered
Definition: cuddInt.h:409
DdNode * cuddBddXorExistAbstractRecur(DdManager *manager, DdNode *f, DdNode *g, DdNode *cube)
Definition: cuddBddAbs.c:464
static int bddCheckPositiveCube(DdManager *manager, DdNode *cube)
Definition: cuddBddAbs.c:708
Cudd_ErrorType errorCode
Definition: cuddInt.h:447
DdNode* Cudd_BiasedOverApprox ( DdManager dd,
DdNode f,
DdNode b,
int  numVars,
int  threshold,
double  quality1,
double  quality0 
)

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

Synopsis [Extracts a dense superset from a BDD with the biased underapproximation method.]

Description [Extracts a dense superset from a BDD. The procedure is identical to the underapproximation procedure except for the fact that it works on the complement of the given function. Extracting the subset of the complement function is equivalent to extracting the superset of the function. Returns a pointer to the BDD of the superset if successful. NULL if intermediate result causes the procedure to run out of memory. The parameter numVars is the maximum number of variables to be used in minterm calculation. The optimal number should be as close as possible to the size of the support of f. However, it is safe to pass the value returned by Cudd_ReadSize for numVars when the number of variables is under 1023. If numVars is larger than 1023, it will overflow. If a 0 parameter is passed then the procedure will compute a value which will avoid overflow but will cause underflow with 2046 variables or more.]

SideEffects [None]

SeeAlso [Cudd_SupersetHeavyBranch Cudd_SupersetShortPaths Cudd_RemapOverApprox Cudd_BiasedUnderApprox Cudd_ReadSize]

Definition at line 463 of file cuddApprox.c.

471 {
472  DdNode *subset, *g;
473 
474  g = Cudd_Not(f);
475  do {
476  dd->reordered = 0;
477  subset = cuddBiasedUnderApprox(dd, g, b, numVars, threshold, quality1,
478  quality0);
479  } while (dd->reordered == 1);
480 
481  return(Cudd_NotCond(subset, (subset != NULL)));
482 
483 } /* end of Cudd_BiasedOverApprox */
Definition: cudd.h:278
#define Cudd_Not(node)
Definition: cudd.h:367
DdNode * cuddBiasedUnderApprox(DdManager *dd, DdNode *f, DdNode *b, int numVars, int threshold, double quality1, double quality0)
Definition: cuddApprox.c:691
int reordered
Definition: cuddInt.h:409
#define Cudd_NotCond(node, c)
Definition: cudd.h:383
DdNode* Cudd_BiasedUnderApprox ( DdManager dd,
DdNode f,
DdNode b,
int  numVars,
int  threshold,
double  quality1,
double  quality0 
)

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

Synopsis [Extracts a dense subset from a BDD with the biased underapproximation method.]

Description [Extracts a dense subset from a BDD. This procedure uses a biased remapping technique and density as the cost function. The bias is a function. This procedure tries to approximate where the bias is 0 and preserve the given function where the bias is 1. Returns a pointer to the BDD of the subset if successful. NULL if the procedure runs out of memory. The parameter numVars is the maximum number of variables to be used in minterm calculation. The optimal number should be as close as possible to the size of the support of f. However, it is safe to pass the value returned by Cudd_ReadSize for numVars when the number of variables is under 1023. If numVars is larger than 1023, it will cause overflow. If a 0 parameter is passed then the procedure will compute a value which will avoid overflow but will cause underflow with 2046 variables or more.]

SideEffects [None]

SeeAlso [Cudd_SubsetShortPaths Cudd_SubsetHeavyBranch Cudd_UnderApprox Cudd_RemapUnderApprox Cudd_ReadSize]

Definition at line 413 of file cuddApprox.c.

421 {
422  DdNode *subset;
423 
424  do {
425  dd->reordered = 0;
426  subset = cuddBiasedUnderApprox(dd, f, b, numVars, threshold, quality1,
427  quality0);
428  } while (dd->reordered == 1);
429 
430  return(subset);
431 
432 } /* end of Cudd_BiasedUnderApprox */
Definition: cudd.h:278
DdNode * cuddBiasedUnderApprox(DdManager *dd, DdNode *f, DdNode *b, int numVars, int threshold, double quality1, double quality0)
Definition: cuddApprox.c:691
int reordered
Definition: cuddInt.h:409
int Cudd_CheckKeys ( DdManager table)

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

Synopsis [Checks for several conditions that should not occur.]

Description [Checks for the following conditions:

  • Wrong sizes of subtables.
  • Wrong number of keys found in unique subtable.
  • Wrong number of dead found in unique subtable.
  • Wrong number of keys found in the constant table
  • Wrong number of dead found in the constant table
  • Wrong number of total slots found
  • Wrong number of maximum keys found
  • Wrong number of total dead found

Reports the average length of non-empty lists. Returns the number of subtables for which the number of keys is wrong.]

SideEffects [None]

SeeAlso [Cudd_DebugCheck]

Definition at line 458 of file cuddCheck.c.

460 {
461  int size;
462  int i,j;
463  DdNodePtr *nodelist;
464  DdNode *node;
465  DdNode *sentinel = &(table->sentinel);
466  DdSubtable *subtable;
467  int keys;
468  int dead;
469  int count = 0;
470  int totalKeys = 0;
471  int totalSlots = 0;
472  int totalDead = 0;
473  int nonEmpty = 0;
474  unsigned int slots;
475  int logSlots;
476  int shift;
477 
478  size = table->size;
479 
480  for (i = 0; i < size; i++) {
481  subtable = &(table->subtables[i]);
482  nodelist = subtable->nodelist;
483  keys = subtable->keys;
484  dead = subtable->dead;
485  totalKeys += keys;
486  slots = subtable->slots;
487  shift = subtable->shift;
488  logSlots = sizeof(int) * 8 - shift;
489  if (((slots >> logSlots) << logSlots) != slots) {
490  (void) fprintf(table->err,
491  "Unique table %d is not the right power of 2\n", i);
492  (void) fprintf(table->err,
493  " slots = %u shift = %d\n", slots, shift);
494  }
495  totalSlots += slots;
496  totalDead += dead;
497  for (j = 0; (unsigned) j < slots; j++) {
498  node = nodelist[j];
499  if (node != sentinel) {
500  nonEmpty++;
501  }
502  while (node != sentinel) {
503  keys--;
504  if (node->ref == 0) {
505  dead--;
506  }
507  node = node->next;
508  }
509  }
510  if (keys != 0) {
511  (void) fprintf(table->err, "Wrong number of keys found \
512 in unique table %d (difference=%d)\n", i, keys);
513  count++;
514  }
515  if (dead != 0) {
516  (void) fprintf(table->err, "Wrong number of dead found \
517 in unique table no. %d (difference=%d)\n", i, dead);
518  }
519  } /* for each BDD/ADD subtable */
520 
521  /* Check the ZDD subtables. */
522  size = table->sizeZ;
523 
524  for (i = 0; i < size; i++) {
525  subtable = &(table->subtableZ[i]);
526  nodelist = subtable->nodelist;
527  keys = subtable->keys;
528  dead = subtable->dead;
529  totalKeys += keys;
530  totalSlots += subtable->slots;
531  totalDead += dead;
532  for (j = 0; (unsigned) j < subtable->slots; j++) {
533  node = nodelist[j];
534  if (node != NULL) {
535  nonEmpty++;
536  }
537  while (node != NULL) {
538  keys--;
539  if (node->ref == 0) {
540  dead--;
541  }
542  node = node->next;
543  }
544  }
545  if (keys != 0) {
546  (void) fprintf(table->err, "Wrong number of keys found \
547 in ZDD unique table no. %d (difference=%d)\n", i, keys);
548  count++;
549  }
550  if (dead != 0) {
551  (void) fprintf(table->err, "Wrong number of dead found \
552 in ZDD unique table no. %d (difference=%d)\n", i, dead);
553  }
554  } /* for each ZDD subtable */
555 
556  /* Check the constant table. */
557  subtable = &(table->constants);
558  nodelist = subtable->nodelist;
559  keys = subtable->keys;
560  dead = subtable->dead;
561  totalKeys += keys;
562  totalSlots += subtable->slots;
563  totalDead += dead;
564  for (j = 0; (unsigned) j < subtable->slots; j++) {
565  node = nodelist[j];
566  if (node != NULL) {
567  nonEmpty++;
568  }
569  while (node != NULL) {
570  keys--;
571  if (node->ref == 0) {
572  dead--;
573  }
574  node = node->next;
575  }
576  }
577  if (keys != 0) {
578  (void) fprintf(table->err, "Wrong number of keys found \
579 in the constant table (difference=%d)\n", keys);
580  count++;
581  }
582  if (dead != 0) {
583  (void) fprintf(table->err, "Wrong number of dead found \
584 in the constant table (difference=%d)\n", dead);
585  }
586  if ((unsigned) totalKeys != table->keys + table->keysZ) {
587  (void) fprintf(table->err, "Wrong number of total keys found \
588 (difference=%d)\n", (int) (totalKeys-table->keys));
589  }
590  if ((unsigned) totalSlots != table->slots) {
591  (void) fprintf(table->err, "Wrong number of total slots found \
592 (difference=%d)\n", (int) (totalSlots-table->slots));
593  }
594  if (table->minDead != (unsigned) (table->gcFrac * table->slots)) {
595  (void) fprintf(table->err, "Wrong number of minimum dead found \
596 (%u vs. %u)\n", table->minDead,
597  (unsigned) (table->gcFrac * (double) table->slots));
598  }
599  if ((unsigned) totalDead != table->dead + table->deadZ) {
600  (void) fprintf(table->err, "Wrong number of total dead found \
601 (difference=%d)\n", (int) (totalDead-table->dead));
602  }
603  (void)printf("Average length of non-empty lists = %g\n",
604  (double) table->keys / (double) nonEmpty);
605 
606  return(count);
607 
608 } /* end of Cudd_CheckKeys */
DdHalfWord ref
Definition: cudd.h:280
unsigned int keys
Definition: cuddInt.h:330
Definition: cudd.h:278
unsigned int deadZ
Definition: cuddInt.h:372
int size
Definition: cuddInt.h:361
double gcFrac
Definition: cuddInt.h:375
unsigned int slots
Definition: cuddInt.h:368
FILE * err
Definition: cuddInt.h:442
DdSubtable * subtables
Definition: cuddInt.h:365
unsigned int dead
Definition: cuddInt.h:371
DdNode sentinel
Definition: cuddInt.h:344
unsigned int keys
Definition: cuddInt.h:369
unsigned int dead
Definition: cuddInt.h:332
DdNode * next
Definition: cudd.h:281
DdNode ** nodelist
Definition: cuddInt.h:327
static int size
Definition: cuddSign.c:86
int sizeZ
Definition: cuddInt.h:362
unsigned int slots
Definition: cuddInt.h:329
DdSubtable constants
Definition: cuddInt.h:367
int shift
Definition: cuddInt.h:328
unsigned int keysZ
Definition: cuddInt.h:370
unsigned int minDead
Definition: cuddInt.h:374
DdSubtable * subtableZ
Definition: cuddInt.h:366
int Cudd_CheckZeroRef ( DdManager manager)

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

Synopsis [Checks the unique table for nodes with non-zero reference counts.]

Description [Checks the unique table for nodes with non-zero reference counts. It is normally called before Cudd_Quit to make sure that there are no memory leaks due to missing Cudd_RecursiveDeref's. Takes into account that reference counts may saturate and that the basic constants and the projection functions are referenced by the manager. Returns the number of nodes with non-zero reference count. (Except for the cases mentioned above.)]

SideEffects [None]

SeeAlso []

Definition at line 466 of file cuddRef.c.

468 {
469  int size;
470  int i, j;
471  int remain; /* the expected number of remaining references to one */
472  DdNodePtr *nodelist;
473  DdNode *node;
474  DdNode *sentinel = &(manager->sentinel);
475  DdSubtable *subtable;
476  int count = 0;
477  int index;
478 
479 #ifndef DD_NO_DEATH_ROW
480  cuddClearDeathRow(manager);
481 #endif
482 
483  /* First look at the BDD/ADD subtables. */
484  remain = 1; /* reference from the manager */
485  size = manager->size;
486  remain += 2 * size; /* reference from the BDD projection functions */
487 
488  for (i = 0; i < size; i++) {
489  subtable = &(manager->subtables[i]);
490  nodelist = subtable->nodelist;
491  for (j = 0; (unsigned) j < subtable->slots; j++) {
492  node = nodelist[j];
493  while (node != sentinel) {
494  if (node->ref != 0 && node->ref != DD_MAXREF) {
495  index = (int) node->index;
496  if (node != manager->vars[index]) {
497  count++;
498  } else {
499  if (node->ref != 1) {
500  count++;
501  }
502  }
503  }
504  node = node->next;
505  }
506  }
507  }
508 
509  /* Then look at the ZDD subtables. */
510  size = manager->sizeZ;
511  if (size) /* references from ZDD universe */
512  remain += 2;
513 
514  for (i = 0; i < size; i++) {
515  subtable = &(manager->subtableZ[i]);
516  nodelist = subtable->nodelist;
517  for (j = 0; (unsigned) j < subtable->slots; j++) {
518  node = nodelist[j];
519  while (node != NULL) {
520  if (node->ref != 0 && node->ref != DD_MAXREF) {
521  index = (int) node->index;
522  if (node == manager->univ[manager->permZ[index]]) {
523  if (node->ref > 2) {
524  count++;
525  }
526  } else {
527  count++;
528  }
529  }
530  node = node->next;
531  }
532  }
533  }
534 
535  /* Now examine the constant table. Plusinfinity, minusinfinity, and
536  ** zero are referenced by the manager. One is referenced by the
537  ** manager, by the ZDD universe, and by all projection functions.
538  ** All other nodes should have no references.
539  */
540  nodelist = manager->constants.nodelist;
541  for (j = 0; (unsigned) j < manager->constants.slots; j++) {
542  node = nodelist[j];
543  while (node != NULL) {
544  if (node->ref != 0 && node->ref != DD_MAXREF) {
545  if (node == manager->one) {
546  if ((int) node->ref != remain) {
547  count++;
548  }
549  } else if (node == manager->zero ||
550  node == manager->plusinfinity ||
551  node == manager->minusinfinity) {
552  if (node->ref != 1) {
553  count++;
554  }
555  } else {
556  count++;
557  }
558  }
559  node = node->next;
560  }
561  }
562  return(count);
563 
564 } /* end of Cudd_CheckZeroRef */
DdHalfWord ref
Definition: cudd.h:280
#define DD_MAXREF
Definition: cuddInt.h:100
Definition: cudd.h:278
int size
Definition: cuddInt.h:361
DdNode * zero
Definition: cuddInt.h:346
DdSubtable * subtables
Definition: cuddInt.h:365
int * permZ
Definition: cuddInt.h:387
DdNode sentinel
Definition: cuddInt.h:344
DdNode * next
Definition: cudd.h:281
if(last==0)
Definition: sparse_int.h:34
DdNode ** nodelist
Definition: cuddInt.h:327
static int size
Definition: cuddSign.c:86
int sizeZ
Definition: cuddInt.h:362
DdHalfWord index
Definition: cudd.h:279
DdNode ** vars
Definition: cuddInt.h:390
DdNode * one
Definition: cuddInt.h:345
DdNode * plusinfinity
Definition: cuddInt.h:347
DdSubtable constants
Definition: cuddInt.h:367
DdNode * minusinfinity
Definition: cuddInt.h:348
void cuddClearDeathRow(DdManager *table)
Definition: cuddRef.c:726
DdSubtable * subtableZ
Definition: cuddInt.h:366
DdNode ** univ
Definition: cuddInt.h:392
int Cudd_ClassifySupport ( DdManager dd,
DdNode f,
DdNode g,
DdNode **  common,
DdNode **  onlyF,
DdNode **  onlyG 
)

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

Synopsis [Classifies the variables in the support of two DDs.]

Description [Classifies the variables in the support of two DDs f and g, depending on whther they appear in both DDs, only in f, or only in g. Returns 1 if successful; 0 otherwise.]

SideEffects [The cubes of the three classes of variables are returned as side effects.]

SeeAlso [Cudd_Support Cudd_VectorSupport]

Definition at line 1085 of file cuddUtil.c.

1092 {
1093  int *supportF, *supportG;
1094  DdNode *tmp, *var;
1095  int i,j;
1096  int size;
1097 
1098  /* Allocate and initialize support arrays for ddSupportStep. */
1099  size = ddMax(dd->size, dd->sizeZ);
1100  supportF = ABC_ALLOC(int,size);
1101  if (supportF == NULL) {
1102  dd->errorCode = CUDD_MEMORY_OUT;
1103  return(0);
1104  }
1105  supportG = ABC_ALLOC(int,size);
1106  if (supportG == NULL) {
1107  dd->errorCode = CUDD_MEMORY_OUT;
1108  ABC_FREE(supportF);
1109  return(0);
1110  }
1111  for (i = 0; i < size; i++) {
1112  supportF[i] = 0;
1113  supportG[i] = 0;
1114  }
1115 
1116  /* Compute supports and clean up markers. */
1117  ddSupportStep(Cudd_Regular(f),supportF);
1119  ddSupportStep(Cudd_Regular(g),supportG);
1121 
1122  /* Classify variables and create cubes. */
1123  *common = *onlyF = *onlyG = DD_ONE(dd);
1124  cuddRef(*common); cuddRef(*onlyF); cuddRef(*onlyG);
1125  for (j = size - 1; j >= 0; j--) { /* for each level bottom-up */
1126  i = (j >= dd->size) ? j : dd->invperm[j];
1127  if (supportF[i] == 0 && supportG[i] == 0) continue;
1128  var = cuddUniqueInter(dd,i,dd->one,Cudd_Not(dd->one));
1129  cuddRef(var);
1130  if (supportG[i] == 0) {
1131  tmp = Cudd_bddAnd(dd,*onlyF,var);
1132  if (tmp == NULL) {
1133  Cudd_RecursiveDeref(dd,*common);
1134  Cudd_RecursiveDeref(dd,*onlyF);
1135  Cudd_RecursiveDeref(dd,*onlyG);
1136  Cudd_RecursiveDeref(dd,var);
1137  ABC_FREE(supportF); ABC_FREE(supportG);
1138  return(0);
1139  }
1140  cuddRef(tmp);
1141  Cudd_RecursiveDeref(dd,*onlyF);
1142  *onlyF = tmp;
1143  } else if (supportF[i] == 0) {
1144  tmp = Cudd_bddAnd(dd,*onlyG,var);
1145  if (tmp == NULL) {
1146  Cudd_RecursiveDeref(dd,*common);
1147  Cudd_RecursiveDeref(dd,*onlyF);
1148  Cudd_RecursiveDeref(dd,*onlyG);
1149  Cudd_RecursiveDeref(dd,var);
1150  ABC_FREE(supportF); ABC_FREE(supportG);
1151  return(0);
1152  }
1153  cuddRef(tmp);
1154  Cudd_RecursiveDeref(dd,*onlyG);
1155  *onlyG = tmp;
1156  } else {
1157  tmp = Cudd_bddAnd(dd,*common,var);
1158  if (tmp == NULL) {
1159  Cudd_RecursiveDeref(dd,*common);
1160  Cudd_RecursiveDeref(dd,*onlyF);
1161  Cudd_RecursiveDeref(dd,*onlyG);
1162  Cudd_RecursiveDeref(dd,var);
1163  ABC_FREE(supportF); ABC_FREE(supportG);
1164  return(0);
1165  }
1166  cuddRef(tmp);
1167  Cudd_RecursiveDeref(dd,*common);
1168  *common = tmp;
1169  }
1170  Cudd_RecursiveDeref(dd,var);
1171  }
1172 
1173  ABC_FREE(supportF); ABC_FREE(supportG);
1174  cuddDeref(*common); cuddDeref(*onlyF); cuddDeref(*onlyG);
1175  return(1);
1176 
1177 } /* end of Cudd_ClassifySupport */
#define cuddRef(n)
Definition: cuddInt.h:584
#define cuddDeref(n)
Definition: cuddInt.h:604
void Cudd_RecursiveDeref(DdManager *table, DdNode *n)
Definition: cuddRef.c:154
Definition: cudd.h:278
#define Cudd_Not(node)
Definition: cudd.h:367
int size
Definition: cuddInt.h:361
int var(Lit p)
Definition: SolverTypes.h:62
#define Cudd_Regular(node)
Definition: cudd.h:397
#define ABC_ALLOC(type, num)
Definition: abc_global.h:229
static void ddSupportStep(DdNode *f, int *support)
Definition: cuddUtil.c:3704
#define ddMax(x, y)
Definition: cuddInt.h:832
if(last==0)
Definition: sparse_int.h:34
static int size
Definition: cuddSign.c:86
int sizeZ
Definition: cuddInt.h:362
#define ABC_FREE(obj)
Definition: abc_global.h:232
DdNode * one
Definition: cuddInt.h:345
DdNode * Cudd_bddAnd(DdManager *dd, DdNode *f, DdNode *g)
Definition: cuddBddIte.c:314
static void ddClearFlag(DdNode *f)
Definition: cuddUtil.c:3735
int * invperm
Definition: cuddInt.h:388
#define DD_ONE(dd)
Definition: cuddInt.h:911
Cudd_ErrorType errorCode
Definition: cuddInt.h:447
DdNode * cuddUniqueInter(DdManager *unique, int index, DdNode *T, DdNode *E)
Definition: cuddTable.c:1128
void Cudd_ClearErrorCode ( DdManager dd)

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

Synopsis [Clear the error code of a manager.]

Description []

SideEffects [None]

SeeAlso [Cudd_ReadErrorCode]

Definition at line 3632 of file cuddAPI.c.

3634 {
3635  dd->errorCode = CUDD_NO_ERROR;
3636 
3637 } /* end of Cudd_ClearErrorCode */
Cudd_ErrorType errorCode
Definition: cuddInt.h:447
DdNode* Cudd_Cofactor ( DdManager dd,
DdNode f,
DdNode g 
)

AutomaticStart AutomaticEnd Function********************************************************************

Synopsis [Computes the cofactor of f with respect to g.]

Description [Computes the cofactor of f with respect to g; g must be the BDD or the ADD of a cube. Returns a pointer to the cofactor if successful; NULL otherwise.]

SideEffects [None]

SeeAlso [Cudd_bddConstrain Cudd_bddRestrict]

Definition at line 123 of file cuddCof.c.

127 {
128  DdNode *res,*zero;
129 
130  zero = Cudd_Not(DD_ONE(dd));
131  if (g == zero || g == DD_ZERO(dd)) {
132  (void) fprintf(dd->err,"Cudd_Cofactor: Invalid restriction 1\n");
134  return(NULL);
135  }
136  do {
137  dd->reordered = 0;
138  res = cuddCofactorRecur(dd,f,g);
139  } while (dd->reordered == 1);
140  return(res);
141 
142 } /* end of Cudd_Cofactor */
Definition: cudd.h:278
#define Cudd_Not(node)
Definition: cudd.h:367
FILE * err
Definition: cuddInt.h:442
int reordered
Definition: cuddInt.h:409
DdNode * cuddCofactorRecur(DdManager *dd, DdNode *f, DdNode *g)
Definition: cuddCof.c:230
#define DD_ONE(dd)
Definition: cuddInt.h:911
Cudd_ErrorType errorCode
Definition: cuddInt.h:447
static DdNode * zero
Definition: cuddApa.c:100
#define DD_ZERO(dd)
Definition: cuddInt.h:927
double* Cudd_CofMinterm ( DdManager dd,
DdNode node 
)

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

Synopsis [Computes the fraction of minterms in the on-set of all the positive cofactors of a BDD or ADD.]

Description [Computes the fraction of minterms in the on-set of all the positive cofactors of DD. Returns the pointer to an array of doubles if successful; NULL otherwise. The array has as many positions as there are BDD variables in the manager plus one. The last position of the array contains the fraction of the minterms in the ON-set of the function represented by the BDD or ADD. The other positions of the array hold the variable signatures.]

SideEffects [None]

Definition at line 131 of file cuddSign.c.

134 {
135  st__table *table;
136  double *values;
137  double *result = NULL;
138  int i, firstLevel;
139 
140 #ifdef DD_STATS
141  long startTime;
142  startTime = util_cpu_time();
143  num_calls = 0;
144  table_mem = sizeof( st__table);
145 #endif
146 
148  if (table == NULL) {
149  (void) fprintf(dd->err,
150  "out-of-memory, couldn't measure DD cofactors.\n");
152  return(NULL);
153  }
154  size = dd->size;
155  values = ddCofMintermAux(dd, node, table);
156  if (values != NULL) {
157  result = ABC_ALLOC(double,size + 1);
158  if (result != NULL) {
159 #ifdef DD_STATS
160  table_mem += (size + 1) * sizeof(double);
161 #endif
162  if (Cudd_IsConstant(node))
163  firstLevel = 1;
164  else
165  firstLevel = cuddI(dd,Cudd_Regular(node)->index);
166  for (i = 0; i < size; i++) {
167  if (i >= cuddI(dd,Cudd_Regular(node)->index)) {
168  result[dd->invperm[i]] = values[i - firstLevel];
169  } else {
170  result[dd->invperm[i]] = values[size - firstLevel];
171  }
172  }
173  result[size] = values[size - firstLevel];
174  } else {
176  }
177  }
178 
179 #ifdef DD_STATS
180  table_mem += table->num_bins * sizeof( st__table_entry *);
181 #endif
182  if (Cudd_Regular(node)->ref == 1) ABC_FREE(values);
183  st__foreach(table, cuddStCountfree, NULL);
184  st__free_table(table);
185 #ifdef DD_STATS
186  (void) fprintf(dd->out,"Number of calls: %d\tTable memory: %d bytes\n",
187  num_calls, table_mem);
188  (void) fprintf(dd->out,"Time to compute measures: %s\n",
189  util_print_time(util_cpu_time() - startTime));
190 #endif
191  if (result == NULL) {
192  (void) fprintf(dd->out,
193  "out-of-memory, couldn't measure DD cofactors.\n");
195  }
196  return(result);
197 
198 } /* end of Cudd_CofMinterm */
void st__free_table(st__table *table)
Definition: st.c:81
struct st__table st__table
Definition: st.h:51
int num_bins
Definition: st.h:55
static double * ddCofMintermAux(DdManager *dd, DdNode *node, st__table *table)
Definition: cuddSign.c:232
int size
Definition: cuddInt.h:361
#define Cudd_IsConstant(node)
Definition: cudd.h:352
#define Cudd_Regular(node)
Definition: cudd.h:397
enum st__retval cuddStCountfree(char *key, char *value, char *arg)
Definition: cuddUtil.c:2895
int st__ptrcmp(const char *, const char *)
Definition: st.c:480
FILE * err
Definition: cuddInt.h:442
#define ABC_ALLOC(type, num)
Definition: abc_global.h:229
#define util_cpu_time
Definition: util_hack.h:36
st__table * st__init_table(st__compare_func_type compare, st__hash_func_type hash)
Definition: st.c:72
FILE * out
Definition: cuddInt.h:441
Definition: st.h:52
Definition: st.h:45
static int size
Definition: cuddSign.c:86
int st__foreach(st__table *table, enum st__retval(*func)(char *, char *, char *), char *arg)
Definition: st.c:421
#define cuddI(dd, index)
Definition: cuddInt.h:686
#define ABC_FREE(obj)
Definition: abc_global.h:232
int * invperm
Definition: cuddInt.h:388
static int result
Definition: cuddGenetic.c:125
Cudd_ErrorType errorCode
Definition: cuddInt.h:447
int st__ptrhash(const char *, int)
Definition: st.c:468
int Cudd_CountLeaves ( DdNode node)

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

Synopsis [Counts the number of leaves in a DD.]

Description [Counts the number of leaves in a DD. Returns the number of leaves in the DD rooted at node if successful; CUDD_OUT_OF_MEM otherwise.]

SideEffects [None]

SeeAlso [Cudd_PrintDebug]

Definition at line 1194 of file cuddUtil.c.

1196 {
1197  int i;
1198 
1199  i = ddLeavesInt(Cudd_Regular(node));
1200  ddClearFlag(Cudd_Regular(node));
1201  return(i);
1202 
1203 } /* end of Cudd_CountLeaves */
#define Cudd_Regular(node)
Definition: cudd.h:397
static int ddLeavesInt(DdNode *n)
Definition: cuddUtil.c:3766
static void ddClearFlag(DdNode *f)
Definition: cuddUtil.c:3735
double Cudd_CountMinterm ( DdManager manager,
DdNode node,
int  nvars 
)

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

Synopsis [Counts the number of minterms of a DD.]

Description [Counts the number of minterms of a DD. The function is assumed to depend on nvars variables. The minterm count is represented as a double, to allow for a larger number of variables. Returns the number of minterms of the function rooted at node if successful; (double) CUDD_OUT_OF_MEM otherwise.]

SideEffects [None]

SeeAlso [Cudd_PrintDebug Cudd_CountPath]

Definition at line 578 of file cuddUtil.c.

582 {
583  double max;
584  DdHashTable *table;
585  double res;
586  CUDD_VALUE_TYPE epsilon;
587 
588  background = manager->background;
589  zero = Cudd_Not(manager->one);
590 
591  max = pow(2.0,(double)nvars);
592  table = cuddHashTableInit(manager,1,2);
593  if (table == NULL) {
594  return((double)CUDD_OUT_OF_MEM);
595  }
596  epsilon = Cudd_ReadEpsilon(manager);
597  Cudd_SetEpsilon(manager,(CUDD_VALUE_TYPE)0.0);
598  res = ddCountMintermAux(node,max,table);
599  cuddHashTableQuit(table);
600  Cudd_SetEpsilon(manager,epsilon);
601 
602  return(res);
603 
604 } /* end of Cudd_CountMinterm */
#define CUDD_OUT_OF_MEM
Definition: cudd.h:95
#define Cudd_Not(node)
Definition: cudd.h:367
static DdNode * background
Definition: cuddUtil.c:148
void Cudd_SetEpsilon(DdManager *dd, CUDD_VALUE_TYPE ep)
Definition: cuddAPI.c:2451
static DdNode * zero
Definition: cuddUtil.c:148
static double max
Definition: cuddSubsetHB.c:134
void cuddHashTableQuit(DdHashTable *hash)
Definition: cuddLCache.c:595
#define CUDD_VALUE_TYPE
Definition: cudd.h:94
DdNode * one
Definition: cuddInt.h:345
static double ddCountMintermAux(DdNode *node, double max, DdHashTable *table)
Definition: cuddUtil.c:3439
DdHashTable * cuddHashTableInit(DdManager *manager, unsigned int keySize, unsigned int initSize)
Definition: cuddLCache.c:538
CUDD_VALUE_TYPE Cudd_ReadEpsilon(DdManager *dd)
Definition: cuddAPI.c:2430
DdNode * background
Definition: cuddInt.h:349
double Cudd_CountPath ( DdNode node)

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

Synopsis [Counts the number of paths of a DD.]

Description [Counts the number of paths of a DD. Paths to all terminal nodes are counted. The path count is represented as a double, to allow for a larger number of variables. Returns the number of paths of the function rooted at node if successful; (double) CUDD_OUT_OF_MEM otherwise.]

SideEffects [None]

SeeAlso [Cudd_CountMinterm]

Definition at line 623 of file cuddUtil.c.

625 {
626 
627  st__table *table;
628  double i;
629 
631  if (table == NULL) {
632  return((double)CUDD_OUT_OF_MEM);
633  }
634  i = ddCountPathAux(Cudd_Regular(node),table);
635  st__foreach(table, cuddStCountfree, NULL);
636  st__free_table(table);
637  return(i);
638 
639 } /* end of Cudd_CountPath */
void st__free_table(st__table *table)
Definition: st.c:81
#define CUDD_OUT_OF_MEM
Definition: cudd.h:95
#define Cudd_Regular(node)
Definition: cudd.h:397
enum st__retval cuddStCountfree(char *key, char *value, char *arg)
Definition: cuddUtil.c:2895
int st__ptrcmp(const char *, const char *)
Definition: st.c:480
st__table * st__init_table(st__compare_func_type compare, st__hash_func_type hash)
Definition: st.c:72
Definition: st.h:52
static double ddCountPathAux(DdNode *node, st__table *table)
Definition: cuddUtil.c:3512
int st__foreach(st__table *table, enum st__retval(*func)(char *, char *, char *), char *arg)
Definition: st.c:421
int st__ptrhash(const char *, int)
Definition: st.c:468
double Cudd_CountPathsToNonZero ( DdNode node)

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

Synopsis [Counts the number of paths to a non-zero terminal of a DD.]

Description [Counts the number of paths to a non-zero terminal of a DD. The path count is represented as a double, to allow for a larger number of variables. Returns the number of paths of the function rooted at node.]

SideEffects [None]

SeeAlso [Cudd_CountMinterm Cudd_CountPath]

Definition at line 707 of file cuddUtil.c.

709 {
710 
711  st__table *table;
712  double i;
713 
715  if (table == NULL) {
716  return((double)CUDD_OUT_OF_MEM);
717  }
718  i = ddCountPathsToNonZero(node,table);
719  st__foreach(table, cuddStCountfree, NULL);
720  st__free_table(table);
721  return(i);
722 
723 } /* end of Cudd_CountPathsToNonZero */
void st__free_table(st__table *table)
Definition: st.c:81
static double ddCountPathsToNonZero(DdNode *N, st__table *table)
Definition: cuddUtil.c:3645
#define CUDD_OUT_OF_MEM
Definition: cudd.h:95
enum st__retval cuddStCountfree(char *key, char *value, char *arg)
Definition: cuddUtil.c:2895
int st__ptrcmp(const char *, const char *)
Definition: st.c:480
st__table * st__init_table(st__compare_func_type compare, st__hash_func_type hash)
Definition: st.c:72
Definition: st.h:52
int st__foreach(st__table *table, enum st__retval(*func)(char *, char *, char *), char *arg)
Definition: st.c:421
int st__ptrhash(const char *, int)
Definition: st.c:468
DdNode* Cudd_CProjection ( DdManager dd,
DdNode R,
DdNode Y 
)

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

Synopsis [Computes the compatible projection of R w.r.t. cube Y.]

Description [Computes the compatible projection of relation R with respect to cube Y. Returns a pointer to the c-projection if successful; NULL otherwise. For a comparison between Cudd_CProjection and Cudd_PrioritySelect, see the documentation of the latter.]

SideEffects [None]

SeeAlso [Cudd_PrioritySelect]

Definition at line 1200 of file cuddPriority.c.

1204 {
1205  DdNode *res;
1206  DdNode *support;
1207 
1208  if (cuddCheckCube(dd,Y) == 0) {
1209  (void) fprintf(dd->err,
1210  "Error: The third argument of Cudd_CProjection should be a cube\n");
1212  return(NULL);
1213  }
1214 
1215  /* Compute the support of Y, which is used by the abstraction step
1216  ** in cuddCProjectionRecur.
1217  */
1218  support = Cudd_Support(dd,Y);
1219  if (support == NULL) return(NULL);
1220  cuddRef(support);
1221 
1222  do {
1223  dd->reordered = 0;
1224  res = cuddCProjectionRecur(dd,R,Y,support);
1225  } while (dd->reordered == 1);
1226 
1227  if (res == NULL) {
1228  Cudd_RecursiveDeref(dd,support);
1229  return(NULL);
1230  }
1231  cuddRef(res);
1232  Cudd_RecursiveDeref(dd,support);
1233  cuddDeref(res);
1234 
1235  return(res);
1236 
1237 } /* end of Cudd_CProjection */
#define cuddRef(n)
Definition: cuddInt.h:584
#define cuddDeref(n)
Definition: cuddInt.h:604
void Cudd_RecursiveDeref(DdManager *table, DdNode *n)
Definition: cuddRef.c:154
Definition: cudd.h:278
DdNode * Cudd_Support(DdManager *dd, DdNode *f)
Definition: cuddUtil.c:740
FILE * err
Definition: cuddInt.h:442
int cuddCheckCube(DdManager *dd, DdNode *g)
Definition: cuddCof.c:193
DdNode * cuddCProjectionRecur(DdManager *dd, DdNode *R, DdNode *Y, DdNode *Ysupp)
int reordered
Definition: cuddInt.h:409
int support
Definition: abcSaucy.c:64
Cudd_ErrorType errorCode
Definition: cuddInt.h:447
DdNode* Cudd_CubeArrayToBdd ( DdManager dd,
int *  array 
)

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

Synopsis [Builds the BDD of a cube from a positional array.]

Description [Builds a cube from a positional array. The array must have one integer entry for each BDD variable. If the i-th entry is 1, the variable of index i appears in true form in the cube; If the i-th entry is 0, the variable of index i appears complemented in the cube; otherwise the variable does not appear in the cube. Returns a pointer to the BDD for the cube if successful; NULL otherwise.]

SideEffects [None]

SeeAlso [Cudd_bddComputeCube Cudd_IndicesToCube Cudd_BddToCubeArray]

Definition at line 2298 of file cuddUtil.c.

2301 {
2302  DdNode *cube, *var, *tmp;
2303  int i;
2304  int size = Cudd_ReadSize(dd);
2305 
2306  cube = DD_ONE(dd);
2307  cuddRef(cube);
2308  for (i = size - 1; i >= 0; i--) {
2309  if ((array[i] & ~1) == 0) {
2310  var = Cudd_bddIthVar(dd,i);
2311  tmp = Cudd_bddAnd(dd,cube,Cudd_NotCond(var,array[i]==0));
2312  if (tmp == NULL) {
2313  Cudd_RecursiveDeref(dd,cube);
2314  return(NULL);
2315  }
2316  cuddRef(tmp);
2317  Cudd_RecursiveDeref(dd,cube);
2318  cube = tmp;
2319  }
2320  }
2321  cuddDeref(cube);
2322  return(cube);
2323 
2324 } /* end of Cudd_CubeArrayToBdd */
#define cuddRef(n)
Definition: cuddInt.h:584
#define cuddDeref(n)
Definition: cuddInt.h:604
void Cudd_RecursiveDeref(DdManager *table, DdNode *n)
Definition: cuddRef.c:154
Definition: cudd.h:278
int var(Lit p)
Definition: SolverTypes.h:62
int Cudd_ReadSize(DdManager *dd)
Definition: cuddAPI.c:1441
static int size
Definition: cuddSign.c:86
DdNode * Cudd_bddIthVar(DdManager *dd, int i)
Definition: cuddAPI.c:416
#define Cudd_NotCond(node, c)
Definition: cudd.h:383
DdNode * Cudd_bddAnd(DdManager *dd, DdNode *f, DdNode *g)
Definition: cuddBddIte.c:314
#define DD_ONE(dd)
Definition: cuddInt.h:911
int Cudd_DagSize ( DdNode node)

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

Synopsis [Counts the number of nodes in a DD.]

Description [Counts the number of nodes in a DD. Returns the number of nodes in the graph rooted at node.]

SideEffects [None]

SeeAlso [Cudd_SharingSize Cudd_PrintDebug]

Definition at line 442 of file cuddUtil.c.

444 {
445  int i;
446 
447  i = ddDagInt(Cudd_Regular(node));
448  ddClearFlag(Cudd_Regular(node));
449 
450  return(i);
451 
452 } /* end of Cudd_DagSize */
#define Cudd_Regular(node)
Definition: cudd.h:397
static int ddDagInt(DdNode *n)
Definition: cuddUtil.c:3165
static void ddClearFlag(DdNode *f)
Definition: cuddUtil.c:3735
int Cudd_DeadAreCounted ( DdManager dd)

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

Synopsis [Tells whether dead nodes are counted towards triggering reordering.]

Description [Tells whether dead nodes are counted towards triggering reordering. Returns 1 if dead nodes are counted; 0 otherwise.]

SideEffects [None]

SeeAlso [Cudd_TurnOnCountDead Cudd_TurnOffCountDead]

Definition at line 2585 of file cuddAPI.c.

2587 {
2588  return(dd->countDead == 0 ? 1 : 0);
2589 
2590 } /* end of Cudd_DeadAreCounted */
unsigned int countDead
Definition: cuddInt.h:423
int Cudd_DebugCheck ( DdManager table)

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

Synopsis [Checks for inconsistencies in the DD heap.]

Description [Checks for inconsistencies in the DD heap:

  • node has illegal index
  • live node has dead children
  • node has illegal Then or Else pointers
  • BDD/ADD node has identical children
  • ZDD node has zero then child
  • wrong number of total nodes
  • wrong number of dead nodes
  • ref count error at node

Returns 0 if no inconsistencies are found; DD_OUT_OF_MEM if there is not enough memory; 1 otherwise.]

SideEffects [None]

SeeAlso [Cudd_CheckKeys]

Definition at line 142 of file cuddCheck.c.

144 {
145  unsigned int i;
146  int j,count;
147  int slots;
148  DdNodePtr *nodelist;
149  DdNode *f;
150  DdNode *sentinel = &(table->sentinel);
151  st__table *edgeTable; /* stores internal ref count for each node */
152  st__generator *gen;
153  int flag = 0;
154  int totalNode;
155  int deadNode;
156  int index;
157 
158 
159  edgeTable = st__init_table( st__ptrcmp, st__ptrhash);
160  if (edgeTable == NULL) return(CUDD_OUT_OF_MEM);
161 
162  /* Check the BDD/ADD subtables. */
163  for (i = 0; i < (unsigned) table->size; i++) {
164  index = table->invperm[i];
165  if (i != (unsigned) table->perm[index]) {
166  (void) fprintf(table->err,
167  "Permutation corrupted: invperm[%u] = %d\t perm[%d] = %d\n",
168  i, index, index, table->perm[index]);
169  }
170  nodelist = table->subtables[i].nodelist;
171  slots = table->subtables[i].slots;
172 
173  totalNode = 0;
174  deadNode = 0;
175  for (j = 0; j < slots; j++) { /* for each subtable slot */
176  f = nodelist[j];
177  while (f != sentinel) {
178  totalNode++;
179  if (cuddT(f) != NULL && cuddE(f) != NULL && f->ref != 0) {
180  if ((int) f->index != index) {
181  (void) fprintf(table->err,
182  "Error: node has illegal index\n");
183  cuddPrintNode(f,table->err);
184  flag = 1;
185  }
186  if ((unsigned) cuddI(table,cuddT(f)->index) <= i ||
187  (unsigned) cuddI(table,Cudd_Regular(cuddE(f))->index)
188  <= i) {
189  (void) fprintf(table->err,
190  "Error: node has illegal children\n");
191  cuddPrintNode(f,table->err);
192  flag = 1;
193  }
194  if (Cudd_Regular(cuddT(f)) != cuddT(f)) {
195  (void) fprintf(table->err,
196  "Error: node has illegal form\n");
197  cuddPrintNode(f,table->err);
198  flag = 1;
199  }
200  if (cuddT(f) == cuddE(f)) {
201  (void) fprintf(table->err,
202  "Error: node has identical children\n");
203  cuddPrintNode(f,table->err);
204  flag = 1;
205  }
206  if (cuddT(f)->ref == 0 || Cudd_Regular(cuddE(f))->ref == 0) {
207  (void) fprintf(table->err,
208  "Error: live node has dead children\n");
209  cuddPrintNode(f,table->err);
210  flag =1;
211  }
212  /* Increment the internal reference count for the
213  ** then child of the current node.
214  */
215  if ( st__lookup_int(edgeTable,(char *)cuddT(f),&count)) {
216  count++;
217  } else {
218  count = 1;
219  }
220  if ( st__insert(edgeTable,(char *)cuddT(f),
221  (char *)(long)count) == st__OUT_OF_MEM) {
222  st__free_table(edgeTable);
223  return(CUDD_OUT_OF_MEM);
224  }
225 
226  /* Increment the internal reference count for the
227  ** else child of the current node.
228  */
229  if ( st__lookup_int(edgeTable,(char *)Cudd_Regular(cuddE(f)),
230  &count)) {
231  count++;
232  } else {
233  count = 1;
234  }
235  if ( st__insert(edgeTable,(char *)Cudd_Regular(cuddE(f)),
236  (char *)(long)count) == st__OUT_OF_MEM) {
237  st__free_table(edgeTable);
238  return(CUDD_OUT_OF_MEM);
239  }
240  } else if (cuddT(f) != NULL && cuddE(f) != NULL && f->ref == 0) {
241  deadNode++;
242 #if 0
243  debugCheckParent(table,f);
244 #endif
245  } else {
246  fprintf(table->err,
247  "Error: node has illegal Then or Else pointers\n");
248  cuddPrintNode(f,table->err);
249  flag = 1;
250  }
251 
252  f = f->next;
253  } /* for each element of the collision list */
254  } /* for each subtable slot */
255 
256  if ((unsigned) totalNode != table->subtables[i].keys) {
257  fprintf(table->err,"Error: wrong number of total nodes\n");
258  flag = 1;
259  }
260  if ((unsigned) deadNode != table->subtables[i].dead) {
261  fprintf(table->err,"Error: wrong number of dead nodes\n");
262  flag = 1;
263  }
264  } /* for each BDD/ADD subtable */
265 
266  /* Check the ZDD subtables. */
267  for (i = 0; i < (unsigned) table->sizeZ; i++) {
268  index = table->invpermZ[i];
269  if (i != (unsigned) table->permZ[index]) {
270  (void) fprintf(table->err,
271  "Permutation corrupted: invpermZ[%u] = %d\t permZ[%d] = %d in ZDD\n",
272  i, index, index, table->permZ[index]);
273  }
274  nodelist = table->subtableZ[i].nodelist;
275  slots = table->subtableZ[i].slots;
276 
277  totalNode = 0;
278  deadNode = 0;
279  for (j = 0; j < slots; j++) { /* for each subtable slot */
280  f = nodelist[j];
281  while (f != NULL) {
282  totalNode++;
283  if (cuddT(f) != NULL && cuddE(f) != NULL && f->ref != 0) {
284  if ((int) f->index != index) {
285  (void) fprintf(table->err,
286  "Error: ZDD node has illegal index\n");
287  cuddPrintNode(f,table->err);
288  flag = 1;
289  }
290  if (Cudd_IsComplement(cuddT(f)) ||
291  Cudd_IsComplement(cuddE(f))) {
292  (void) fprintf(table->err,
293  "Error: ZDD node has complemented children\n");
294  cuddPrintNode(f,table->err);
295  flag = 1;
296  }
297  if ((unsigned) cuddIZ(table,cuddT(f)->index) <= i ||
298  (unsigned) cuddIZ(table,cuddE(f)->index) <= i) {
299  (void) fprintf(table->err,
300  "Error: ZDD node has illegal children\n");
301  cuddPrintNode(f,table->err);
302  cuddPrintNode(cuddT(f),table->err);
303  cuddPrintNode(cuddE(f),table->err);
304  flag = 1;
305  }
306  if (cuddT(f) == DD_ZERO(table)) {
307  (void) fprintf(table->err,
308  "Error: ZDD node has zero then child\n");
309  cuddPrintNode(f,table->err);
310  flag = 1;
311  }
312  if (cuddT(f)->ref == 0 || cuddE(f)->ref == 0) {
313  (void) fprintf(table->err,
314  "Error: ZDD live node has dead children\n");
315  cuddPrintNode(f,table->err);
316  flag =1;
317  }
318  /* Increment the internal reference count for the
319  ** then child of the current node.
320  */
321  if ( st__lookup_int(edgeTable,(char *)cuddT(f),&count)) {
322  count++;
323  } else {
324  count = 1;
325  }
326  if ( st__insert(edgeTable,(char *)cuddT(f),
327  (char *)(long)count) == st__OUT_OF_MEM) {
328  st__free_table(edgeTable);
329  return(CUDD_OUT_OF_MEM);
330  }
331 
332  /* Increment the internal reference count for the
333  ** else child of the current node.
334  */
335  if ( st__lookup_int(edgeTable,(char *)cuddE(f),&count)) {
336  count++;
337  } else {
338  count = 1;
339  }
340  if ( st__insert(edgeTable,(char *)cuddE(f),
341  (char *)(long)count) == st__OUT_OF_MEM) {
342  st__free_table(edgeTable);
343  table->errorCode = CUDD_MEMORY_OUT;
344  return(CUDD_OUT_OF_MEM);
345  }
346  } else if (cuddT(f) != NULL && cuddE(f) != NULL && f->ref == 0) {
347  deadNode++;
348 #if 0
349  debugCheckParent(table,f);
350 #endif
351  } else {
352  fprintf(table->err,
353  "Error: ZDD node has illegal Then or Else pointers\n");
354  cuddPrintNode(f,table->err);
355  flag = 1;
356  }
357 
358  f = f->next;
359  } /* for each element of the collision list */
360  } /* for each subtable slot */
361 
362  if ((unsigned) totalNode != table->subtableZ[i].keys) {
363  fprintf(table->err,
364  "Error: wrong number of total nodes in ZDD\n");
365  flag = 1;
366  }
367  if ((unsigned) deadNode != table->subtableZ[i].dead) {
368  fprintf(table->err,
369  "Error: wrong number of dead nodes in ZDD\n");
370  flag = 1;
371  }
372  } /* for each ZDD subtable */
373 
374  /* Check the constant table. */
375  nodelist = table->constants.nodelist;
376  slots = table->constants.slots;
377 
378  totalNode = 0;
379  deadNode = 0;
380  for (j = 0; j < slots; j++) {
381  f = nodelist[j];
382  while (f != NULL) {
383  totalNode++;
384  if (f->ref != 0) {
385  if (f->index != CUDD_CONST_INDEX) {
386  fprintf(table->err,"Error: node has illegal index\n");
387 #if SIZEOF_VOID_P == 8
388  fprintf(table->err,
389  " node 0x%lx, id = %u, ref = %u, value = %g\n",
390  (ptruint)f,f->index,f->ref,cuddV(f));
391 #else
392  fprintf(table->err,
393  " node 0x%x, id = %hu, ref = %hu, value = %g\n",
394  (ptruint)f,f->index,f->ref,cuddV(f));
395 #endif
396  flag = 1;
397  }
398  } else {
399  deadNode++;
400  }
401  f = f->next;
402  }
403  }
404  if ((unsigned) totalNode != table->constants.keys) {
405  (void) fprintf(table->err,
406  "Error: wrong number of total nodes in constants\n");
407  flag = 1;
408  }
409  if ((unsigned) deadNode != table->constants.dead) {
410  (void) fprintf(table->err,
411  "Error: wrong number of dead nodes in constants\n");
412  flag = 1;
413  }
414  gen = st__init_gen(edgeTable);
415  while ( st__gen(gen, (const char **)&f, (char **)&count)) {
416  if (count > (int)(f->ref) && f->ref != DD_MAXREF) {
417 #if SIZEOF_VOID_P == 8
418  fprintf(table->err,"ref count error at node 0x%lx, count = %d, id = %u, ref = %u, then = 0x%lx, else = 0x%lx\n",(ptruint)f,count,f->index,f->ref,(ptruint)cuddT(f),(ptruint)cuddE(f));
419 #else
420  fprintf(table->err,"ref count error at node 0x%x, count = %d, id = %hu, ref = %hu, then = 0x%x, else = 0x%x\n",(ptruint)f,count,f->index,f->ref,(ptruint)cuddT(f),(ptruint)cuddE(f));
421 #endif
422  debugFindParent(table,f);
423  flag = 1;
424  }
425  }
426  st__free_gen(gen);
427  st__free_table(edgeTable);
428 
429  return (flag);
430 
431 } /* end of Cudd_DebugCheck */
DdHalfWord ref
Definition: cudd.h:280
#define DD_MAXREF
Definition: cuddInt.h:100
void st__free_table(st__table *table)
Definition: st.c:81
unsigned int keys
Definition: cuddInt.h:330
#define CUDD_OUT_OF_MEM
Definition: cudd.h:95
#define cuddIZ(dd, index)
Definition: cuddInt.h:704
Definition: cudd.h:278
int * invpermZ
Definition: cuddInt.h:389
void st__free_gen(st__generator *gen)
Definition: st.c:556
int st__insert(st__table *table, const char *key, char *value)
Definition: st.c:171
static void debugFindParent(DdManager *table, DdNode *node)
Definition: cuddCheck.c:810
int size
Definition: cuddInt.h:361
#define Cudd_Regular(node)
Definition: cudd.h:397
int st__ptrcmp(const char *, const char *)
Definition: st.c:480
FILE * err
Definition: cuddInt.h:442
int st__lookup_int(st__table *table, char *key, int *value)
Definition: st.c:134
DdSubtable * subtables
Definition: cuddInt.h:365
int * permZ
Definition: cuddInt.h:387
#define cuddV(node)
Definition: cuddInt.h:668
ABC_PTRUINT_T ptruint
Definition: cuddInt.h:261
st__table * st__init_table(st__compare_func_type compare, st__hash_func_type hash)
Definition: st.c:72
#define Cudd_IsComplement(node)
Definition: cudd.h:425
DdNode sentinel
Definition: cuddInt.h:344
void cuddPrintNode(DdNode *f, FILE *fp)
Definition: cuddCheck.c:710
unsigned int dead
Definition: cuddInt.h:332
Definition: st.h:52
DdNode * next
Definition: cudd.h:281
#define CUDD_CONST_INDEX
Definition: cudd.h:117
DdNode ** nodelist
Definition: cuddInt.h:327
#define cuddT(node)
Definition: cuddInt.h:636
st__generator * st__init_gen(st__table *table)
Definition: st.c:486
#define st__OUT_OF_MEM
Definition: st.h:113
#define cuddI(dd, index)
Definition: cuddInt.h:686
int sizeZ
Definition: cuddInt.h:362
DdHalfWord index
Definition: cudd.h:279
unsigned int slots
Definition: cuddInt.h:329
#define cuddE(node)
Definition: cuddInt.h:652
int * invperm
Definition: cuddInt.h:388
DdSubtable constants
Definition: cuddInt.h:367
int * perm
Definition: cuddInt.h:386
Cudd_ErrorType errorCode
Definition: cuddInt.h:447
int st__ptrhash(const char *, int)
Definition: st.c:468
int st__gen(st__generator *gen, const char **key_p, char **value_p)
Definition: st.c:502
DdSubtable * subtableZ
Definition: cuddInt.h:366
#define DD_ZERO(dd)
Definition: cuddInt.h:927
DdNode* Cudd_Decreasing ( DdManager dd,
DdNode f,
int  i 
)

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

Synopsis [Determines whether a BDD is negative unate in a variable.]

Description [Determines whether the function represented by BDD f is negative unate (monotonic decreasing) in variable i. Returns the constant one is f is unate and the (logical) constant zero if it is not. This function does not generate any new nodes.]

SideEffects [None]

SeeAlso [Cudd_Increasing]

Definition at line 417 of file cuddSat.c.

421 {
422  unsigned int topf, level;
423  DdNode *F, *fv, *fvn, *res;
424  DD_CTFP cacheOp;
425 
426  statLine(dd);
427 #ifdef DD_DEBUG
428  assert(0 <= i && i < dd->size);
429 #endif
430 
431  F = Cudd_Regular(f);
432  topf = cuddI(dd,F->index);
433 
434  /* Check terminal case. If topf > i, f does not depend on var.
435  ** Therefore, f is unate in i.
436  */
437  level = (unsigned) dd->perm[i];
438  if (topf > level) {
439  return(DD_ONE(dd));
440  }
441 
442  /* From now on, f is not constant. */
443 
444  /* Check cache. */
445  cacheOp = (DD_CTFP) Cudd_Decreasing;
446  res = cuddCacheLookup2(dd,cacheOp,f,dd->vars[i]);
447  if (res != NULL) {
448  return(res);
449  }
450 
451  /* Compute cofactors. */
452  fv = cuddT(F); fvn = cuddE(F);
453  if (F != f) {
454  fv = Cudd_Not(fv);
455  fvn = Cudd_Not(fvn);
456  }
457 
458  if (topf == (unsigned) level) {
459  /* Special case: if fv is regular, fv(1,...,1) = 1;
460  ** If in addition fvn is complemented, fvn(1,...,1) = 0.
461  ** But then f(1,1,...,1) > f(0,1,...,1). Hence f is not
462  ** monotonic decreasing in i.
463  */
464  if (!Cudd_IsComplement(fv) && Cudd_IsComplement(fvn)) {
465  return(Cudd_Not(DD_ONE(dd)));
466  }
467  res = Cudd_bddLeq(dd,fv,fvn) ? DD_ONE(dd) : Cudd_Not(DD_ONE(dd));
468  } else {
469  res = Cudd_Decreasing(dd,fv,i);
470  if (res == DD_ONE(dd)) {
471  res = Cudd_Decreasing(dd,fvn,i);
472  }
473  }
474 
475  cuddCacheInsert2(dd,cacheOp,f,dd->vars[i],res);
476  return(res);
477 
478 } /* end of Cudd_Decreasing */
Definition: cudd.h:278
#define Cudd_Not(node)
Definition: cudd.h:367
void cuddCacheInsert2(DdManager *table, DD_CTFP op, DdNode *f, DdNode *g, DdNode *data)
Definition: cuddCache.c:277
#define Cudd_Regular(node)
Definition: cudd.h:397
DdNode *(* DD_CTFP)(DdManager *, DdNode *, DdNode *)
Definition: cudd.h:321
#define statLine(dd)
Definition: cuddInt.h:1037
DdNode * cuddCacheLookup2(DdManager *table, DD_CTFP op, DdNode *f, DdNode *g)
Definition: cuddCache.c:502
#define Cudd_IsComplement(node)
Definition: cudd.h:425
if(last==0)
Definition: sparse_int.h:34
static int size
Definition: cuddSign.c:86
#define cuddT(node)
Definition: cuddInt.h:636
#define cuddI(dd, index)
Definition: cuddInt.h:686
int Cudd_bddLeq(DdManager *dd, DdNode *f, DdNode *g)
Definition: cuddBddIte.c:536
DdNode * Cudd_Decreasing(DdManager *dd, DdNode *f, int i)
Definition: cuddSat.c:417
DdHalfWord index
Definition: cudd.h:279
DdNode ** vars
Definition: cuddInt.h:390
#define cuddE(node)
Definition: cuddInt.h:652
#define assert(ex)
Definition: util_old.h:213
#define DD_ONE(dd)
Definition: cuddInt.h:911
int * perm
Definition: cuddInt.h:386
void Cudd_DelayedDerefBdd ( DdManager table,
DdNode n 
)

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

Synopsis [Decreases the reference count of BDD node n.]

Description [Enqueues node n for later dereferencing. If the queue is full decreases the reference count of the oldest node N to make room for n. If N dies, recursively decreases the reference counts of its children. It is used to dispose of a BDD that is currently not needed, but may be useful again in the near future. The dereferencing proper is done as in Cudd_IterDerefBdd.]

SideEffects [None]

SeeAlso [Cudd_RecursiveDeref Cudd_IterDerefBdd]

Definition at line 274 of file cuddRef.c.

277 {
278  DdNode *N;
279  int ord;
280  DdNodePtr *stack;
281  int SP;
282 
283  unsigned int live = table->keys - table->dead;
284  if (live > table->peakLiveNodes) {
285  table->peakLiveNodes = live;
286  }
287 
288  n = Cudd_Regular(n);
289 #ifdef DD_DEBUG
290  assert(n->ref != 0);
291 #endif
292 
293 #ifdef DD_NO_DEATH_ROW
294  N = n;
295 #else
296  if (cuddIsConstant(n) || n->ref > 1) {
297 #ifdef DD_DEBUG
298  assert(n->ref != 1 && (!cuddIsConstant(n) || n == DD_ONE(table)));
299 #endif
300  cuddSatDec(n->ref);
301  return;
302  }
303 
304  N = table->deathRow[table->nextDead];
305 
306  if (N != NULL) {
307 #endif
308 #ifdef DD_DEBUG
310 #endif
311  stack = table->stack;
312  SP = 1;
313  do {
314 #ifdef DD_DEBUG
315  assert(N->ref != 0);
316 #endif
317  if (N->ref == 1) {
318  N->ref = 0;
319  table->dead++;
320 #ifdef DD_STATS
321  table->nodesDropped++;
322 #endif
323  ord = table->perm[N->index];
324  stack[SP++] = Cudd_Regular(cuddE(N));
325  table->subtables[ord].dead++;
326  N = cuddT(N);
327  } else {
328  cuddSatDec(N->ref);
329  N = stack[--SP];
330  }
331  } while (SP != 0);
332 #ifndef DD_NO_DEATH_ROW
333  }
334  table->deathRow[table->nextDead] = n;
335 
336  /* Udate insertion point. */
337  table->nextDead++;
338  table->nextDead &= table->deadMask;
339 #if 0
340  if (table->nextDead == table->deathRowDepth) {
341  if (table->deathRowDepth < table->looseUpTo / 2) {
342  extern void (*MMoutOfMemory)(long);
343  void (*saveHandler)(long) = MMoutOfMemory;
344  DdNodePtr *newRow;
346  newRow = ABC_REALLOC(DdNodePtr,table->deathRow,2*table->deathRowDepth);
347  MMoutOfMemory = saveHandler;
348  if (newRow == NULL) {
349  table->nextDead = 0;
350  } else {
351  int i;
352  table->memused += table->deathRowDepth;
353  i = table->deathRowDepth;
354  table->deathRowDepth <<= 1;
355  for (; i < table->deathRowDepth; i++) {
356  newRow[i] = NULL;
357  }
358  table->deadMask = table->deathRowDepth - 1;
359  table->deathRow = newRow;
360  }
361  } else {
362  table->nextDead = 0;
363  }
364  }
365 #endif
366 #endif
367 
368 } /* end of Cudd_DelayedDerefBdd */
DdHalfWord ref
Definition: cudd.h:280
void Cudd_OutOfMem(long size)
Definition: cuddUtil.c:2837
unsigned int peakLiveNodes
Definition: cuddInt.h:465
Definition: cudd.h:278
unsigned deadMask
Definition: cuddInt.h:404
#define ABC_REALLOC(type, obj, num)
Definition: abc_global.h:233
#define Cudd_Regular(node)
Definition: cudd.h:397
DdSubtable * subtables
Definition: cuddInt.h:365
DdNode ** deathRow
Definition: cuddInt.h:401
DdNode ** stack
Definition: cuddInt.h:380
unsigned int dead
Definition: cuddInt.h:371
#define Cudd_IsComplement(node)
Definition: cudd.h:425
unsigned int keys
Definition: cuddInt.h:369
unsigned int dead
Definition: cuddInt.h:332
#define cuddIsConstant(node)
Definition: cuddInt.h:620
#define cuddT(node)
Definition: cuddInt.h:636
int nextDead
Definition: cuddInt.h:403
unsigned long memused
Definition: cuddInt.h:449
int deathRowDepth
Definition: cuddInt.h:402
DdHalfWord index
Definition: cudd.h:279
unsigned int looseUpTo
Definition: cuddInt.h:377
#define cuddE(node)
Definition: cuddInt.h:652
#define cuddSatDec(x)
Definition: cuddInt.h:896
#define assert(ex)
Definition: util_old.h:213
#define DD_ONE(dd)
Definition: cuddInt.h:911
int * perm
Definition: cuddInt.h:386
#define MMoutOfMemory
Definition: util_hack.h:38
double Cudd_Density ( DdManager dd,
DdNode f,
int  nvars 
)

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

Synopsis [Computes the density of a BDD or ADD.]

Description [Computes the density of a BDD or ADD. The density is the ratio of the number of minterms to the number of nodes. If 0 is passed as number of variables, the number of variables existing in the manager is used. Returns the density if successful; (double) CUDD_OUT_OF_MEM otherwise.]

SideEffects [None]

SeeAlso [Cudd_CountMinterm Cudd_DagSize]

Definition at line 2802 of file cuddUtil.c.

2806 {
2807  double minterms;
2808  int nodes;
2809  double density;
2810 
2811  if (nvars == 0) nvars = dd->size;
2812  minterms = Cudd_CountMinterm(dd,f,nvars);
2813  if (minterms == (double) CUDD_OUT_OF_MEM) return(minterms);
2814  nodes = Cudd_DagSize(f);
2815  density = minterms / (double) nodes;
2816  return(density);
2817 
2818 } /* end of Cudd_Density */
#define CUDD_OUT_OF_MEM
Definition: cudd.h:95
int size
Definition: cuddInt.h:361
int nodes
Definition: abcSaucy.c:61
int Cudd_DagSize(DdNode *node)
Definition: cuddUtil.c:442
double Cudd_CountMinterm(DdManager *manager, DdNode *node, int nvars)
Definition: cuddUtil.c:578
pset minterms()
void Cudd_Deref ( DdNode node)

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

Synopsis [Decreases the reference count of node.]

Description [Decreases the reference count of node. It is primarily used in recursive procedures to decrease the ref count of a result node before returning it. This accomplishes the goal of removing the protection applied by a previous Cudd_Ref.]

SideEffects [None]

SeeAlso [Cudd_RecursiveDeref Cudd_RecursiveDerefZdd Cudd_Ref]

Definition at line 438 of file cuddRef.c.

440 {
441  node = Cudd_Regular(node);
442  cuddSatDec(node->ref);
443 
444 } /* end of Cudd_Deref */
DdHalfWord ref
Definition: cudd.h:280
#define Cudd_Regular(node)
Definition: cudd.h:397
#define cuddSatDec(x)
Definition: cuddInt.h:896
void Cudd_DisableGarbageCollection ( DdManager dd)

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

Synopsis [Disables garbage collection.]

Description [Disables garbage collection. Garbage collection is initially enabled. This function may be called to disable it. However, garbage collection will still occur when a new node must be created and no memory is left, or when garbage collection is required for correctness. (E.g., before reordering.)]

SideEffects [None]

SeeAlso [Cudd_EnableGarbageCollection Cudd_GarbageCollectionEnabled]

Definition at line 2563 of file cuddAPI.c.

2565 {
2566  dd->gcEnabled = 0;
2567 
2568 } /* end of Cudd_DisableGarbageCollection */
int gcEnabled
Definition: cuddInt.h:376
int Cudd_DisableReorderingReporting ( DdManager dd)

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

Synopsis [Disables reporting of reordering stats.]

Description [Disables reporting of reordering stats. Returns 1 if successful; 0 otherwise.]

SideEffects [Removes functions from the pre-reordering and post-reordering hooks.]

SeeAlso [Cudd_EnableReorderingReporting Cudd_ReorderingReporting]

Definition at line 3564 of file cuddAPI.c.

3566 {
3568  return(0);
3569  }
3571  return(0);
3572  }
3573  return(1);
3574 
3575 } /* end of Cudd_DisableReorderingReporting */
int Cudd_StdPostReordHook(DdManager *dd, const char *str, void *data)
Definition: cuddAPI.c:3501
int Cudd_StdPreReordHook(DdManager *dd, const char *str, void *data)
Definition: cuddAPI.c:3408
int Cudd_RemoveHook(DdManager *dd, DD_HFP f, Cudd_HookType where)
Definition: cuddAPI.c:3306
DdNode* Cudd_Disequality ( DdManager dd,
int  N,
int  c,
DdNode **  x,
DdNode **  y 
)

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

Synopsis [Generates a BDD for the function x - y != c.]

Description [This function generates a BDD for the function x -y != c. Both x and y are N-bit numbers, x[0] x[1] ... x[N-1] and y[0] y[1] ... y[N-1], with 0 the most significant bit. The BDD is built bottom-up. It has a linear number of nodes if the variables are ordered as follows: x[0] y[0] x[1] y[1] ... x[N-1] y[N-1].]

SideEffects [None]

SeeAlso [Cudd_Xgty]

Definition at line 932 of file cuddPriority.c.

938 {
939  /* The nodes at level i represent values of the difference that are
940  ** multiples of 2^i. We use variables with names starting with k
941  ** to denote the multipliers of 2^i in such multiples. */
942  int kTrueLb = c + 1;
943  int kTrueUb = c - 1;
944  int kFalse = c;
945  /* Mask used to compute the ceiling function. Since we divide by 2^i,
946  ** we want to know whether the dividend is a multiple of 2^i. If it is,
947  ** then ceiling and floor coincide; otherwise, they differ by one. */
948  int mask = 1;
949  int i;
950 
951  DdNode *f = NULL; /* the eventual result */
952  DdNode *one = DD_ONE(dd);
953  DdNode *zero = Cudd_Not(one);
954 
955  /* Two x-labeled nodes are created at most at each iteration. They are
956  ** stored, along with their k values, in these variables. At each level,
957  ** the old nodes are freed and the new nodes are copied into the old map.
958  */
959  DdNode *map[2] = {0};
960  int invalidIndex = 1 << (N-1);
961  int index[2] = {invalidIndex, invalidIndex};
962 
963  /* This should never happen. */
964  if (N < 0) return(NULL);
965 
966  /* If there are no bits, both operands are 0. The result depends on c. */
967  if (N == 0) {
968  if (c != 0) return(one);
969  else return(zero);
970  }
971 
972  /* The maximum or the minimum difference comparing to c can generate the terminal case */
973  if ((1 << N) - 1 < c || (-(1 << N) + 1) > c) return(one);
974 
975  /* Build the result bottom up. */
976  for (i = 1; i <= N; i++) {
977  int kTrueLbLower, kTrueUbLower;
978  int leftChild, middleChild, rightChild;
979  DdNode *g0, *g1, *fplus, *fequal, *fminus;
980  int j;
981  DdNode *newMap[2] = {NULL};
982  int newIndex[2];
983 
984  kTrueLbLower = kTrueLb;
985  kTrueUbLower = kTrueUb;
986  /* kTrueLb = floor((c-1)/2^i) + 2 */
987  kTrueLb = ((c-1) >> i) + 2;
988  /* kTrueUb = ceiling((c+1)/2^i) - 2 */
989  kTrueUb = ((c+1) >> i) + (((c+2) & mask) != 1) - 2;
990  mask = (mask << 1) | 1;
991  newIndex[0] = invalidIndex;
992  newIndex[1] = invalidIndex;
993 
994  for (j = kTrueUb + 1; j < kTrueLb; j++) {
995  /* Skip if node is not reachable from top of BDD. */
996  if ((j >= (1 << (N - i))) || (j <= -(1 << (N -i)))) continue;
997 
998  /* Find f- */
999  leftChild = (j << 1) - 1;
1000  if (leftChild >= kTrueLbLower || leftChild <= kTrueUbLower) {
1001  fminus = one;
1002  } else if (i == 1 && leftChild == kFalse) {
1003  fminus = zero;
1004  } else {
1005  assert(leftChild == index[0] || leftChild == index[1]);
1006  if (leftChild == index[0]) {
1007  fminus = map[0];
1008  } else {
1009  fminus = map[1];
1010  }
1011  }
1012 
1013  /* Find f= */
1014  middleChild = j << 1;
1015  if (middleChild >= kTrueLbLower || middleChild <= kTrueUbLower) {
1016  fequal = one;
1017  } else if (i == 1 && middleChild == kFalse) {
1018  fequal = zero;
1019  } else {
1020  assert(middleChild == index[0] || middleChild == index[1]);
1021  if (middleChild == index[0]) {
1022  fequal = map[0];
1023  } else {
1024  fequal = map[1];
1025  }
1026  }
1027 
1028  /* Find f+ */
1029  rightChild = (j << 1) + 1;
1030  if (rightChild >= kTrueLbLower || rightChild <= kTrueUbLower) {
1031  fplus = one;
1032  } else if (i == 1 && rightChild == kFalse) {
1033  fplus = zero;
1034  } else {
1035  assert(rightChild == index[0] || rightChild == index[1]);
1036  if (rightChild == index[0]) {
1037  fplus = map[0];
1038  } else {
1039  fplus = map[1];
1040  }
1041  }
1042 
1043  /* Build new nodes. */
1044  g1 = Cudd_bddIte(dd, y[N - i], fequal, fplus);
1045  if (g1 == NULL) {
1046  if (index[0] != invalidIndex) Cudd_IterDerefBdd(dd, map[0]);
1047  if (index[1] != invalidIndex) Cudd_IterDerefBdd(dd, map[1]);
1048  if (newIndex[0] != invalidIndex) Cudd_IterDerefBdd(dd, newMap[0]);
1049  if (newIndex[1] != invalidIndex) Cudd_IterDerefBdd(dd, newMap[1]);
1050  return(NULL);
1051  }
1052  cuddRef(g1);
1053  g0 = Cudd_bddIte(dd, y[N - i], fminus, fequal);
1054  if (g0 == NULL) {
1055  Cudd_IterDerefBdd(dd, g1);
1056  if (index[0] != invalidIndex) Cudd_IterDerefBdd(dd, map[0]);
1057  if (index[1] != invalidIndex) Cudd_IterDerefBdd(dd, map[1]);
1058  if (newIndex[0] != invalidIndex) Cudd_IterDerefBdd(dd, newMap[0]);
1059  if (newIndex[1] != invalidIndex) Cudd_IterDerefBdd(dd, newMap[1]);
1060  return(NULL);
1061  }
1062  cuddRef(g0);
1063  f = Cudd_bddIte(dd, x[N - i], g1, g0);
1064  if (f == NULL) {
1065  Cudd_IterDerefBdd(dd, g1);
1066  Cudd_IterDerefBdd(dd, g0);
1067  if (index[0] != invalidIndex) Cudd_IterDerefBdd(dd, map[0]);
1068  if (index[1] != invalidIndex) Cudd_IterDerefBdd(dd, map[1]);
1069  if (newIndex[0] != invalidIndex) Cudd_IterDerefBdd(dd, newMap[0]);
1070  if (newIndex[1] != invalidIndex) Cudd_IterDerefBdd(dd, newMap[1]);
1071  return(NULL);
1072  }
1073  cuddRef(f);
1074  Cudd_IterDerefBdd(dd, g1);
1075  Cudd_IterDerefBdd(dd, g0);
1076 
1077  /* Save newly computed node in map. */
1078  assert(newIndex[0] == invalidIndex || newIndex[1] == invalidIndex);
1079  if (newIndex[0] == invalidIndex) {
1080  newIndex[0] = j;
1081  newMap[0] = f;
1082  } else {
1083  newIndex[1] = j;
1084  newMap[1] = f;
1085  }
1086  }
1087 
1088  /* Copy new map to map. */
1089  if (index[0] != invalidIndex) Cudd_IterDerefBdd(dd, map[0]);
1090  if (index[1] != invalidIndex) Cudd_IterDerefBdd(dd, map[1]);
1091  map[0] = newMap[0];
1092  map[1] = newMap[1];
1093  index[0] = newIndex[0];
1094  index[1] = newIndex[1];
1095  }
1096 
1097  cuddDeref(f);
1098  return(f);
1099 
1100 } /* end of Cudd_Disequality */
void Cudd_IterDerefBdd(DdManager *table, DdNode *n)
Definition: cuddRef.c:217
#define cuddRef(n)
Definition: cuddInt.h:584
#define cuddDeref(n)
Definition: cuddInt.h:604
Definition: cudd.h:278
#define Cudd_Not(node)
Definition: cudd.h:367
void map()
DdNode * Cudd_bddIte(DdManager *dd, DdNode *f, DdNode *g, DdNode *h)
Definition: cuddBddIte.c:143
static DdNode * one
Definition: cuddDecomp.c:112
#define assert(ex)
Definition: util_old.h:213
#define DD_ONE(dd)
Definition: cuddInt.h:911
static DdNode * zero
Definition: cuddApa.c:100
int Cudd_DumpBlif ( DdManager dd,
int  n,
DdNode **  f,
char **  inames,
char **  onames,
char *  mname,
FILE *  fp,
int  mv 
)

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

Synopsis [Writes a blif file representing the argument BDDs.]

Description [Writes a blif file representing the argument BDDs as a network of multiplexers. One multiplexer is written for each BDD node. It returns 1 in case of success; 0 otherwise (e.g., out-of-memory, file system full, or an ADD with constants different from 0 and 1). Cudd_DumpBlif does not close the file: This is the caller responsibility. Cudd_DumpBlif uses a minimal unique subset of the hexadecimal address of a node as name for it. If the argument inames is non-null, it is assumed to hold the pointers to the names of the inputs. Similarly for onames.]

SideEffects [None]

SeeAlso [Cudd_DumpBlifBody Cudd_DumpDot Cudd_PrintDebug Cudd_DumpDDcal Cudd_DumpDaVinci Cudd_DumpFactoredForm]

Definition at line 136 of file cuddExport.c.

145 {
146  DdNode *support = NULL;
147  DdNode *scan;
148  int *sorted = NULL;
149  int nvars = dd->size;
150  int retval;
151  int i;
152 
153  /* Build a bit array with the support of f. */
154  sorted = ABC_ALLOC(int,nvars);
155  if (sorted == NULL) {
157  goto failure;
158  }
159  for (i = 0; i < nvars; i++) sorted[i] = 0;
160 
161  /* Take the union of the supports of each output function. */
162  support = Cudd_VectorSupport(dd,f,n);
163  if (support == NULL) goto failure;
164  cuddRef(support);
165  scan = support;
166  while (!cuddIsConstant(scan)) {
167  sorted[scan->index] = 1;
168  scan = cuddT(scan);
169  }
170  Cudd_RecursiveDeref(dd,support);
171  support = NULL; /* so that we do not try to free it in case of failure */
172 
173  /* Write the header (.model .inputs .outputs). */
174  if (mname == NULL) {
175  retval = fprintf(fp,".model DD\n.inputs");
176  } else {
177  retval = fprintf(fp,".model %s\n.inputs",mname);
178  }
179  if (retval == EOF) {
180  ABC_FREE(sorted);
181  return(0);
182  }
183 
184  /* Write the input list by scanning the support array. */
185  for (i = 0; i < nvars; i++) {
186  if (sorted[i]) {
187  if (inames == NULL) {
188  retval = fprintf(fp," %d", i);
189  } else {
190  retval = fprintf(fp," %s", inames[i]);
191  }
192  if (retval == EOF) goto failure;
193  }
194  }
195  ABC_FREE(sorted);
196  sorted = NULL;
197 
198  /* Write the .output line. */
199  retval = fprintf(fp,"\n.outputs");
200  if (retval == EOF) goto failure;
201  for (i = 0; i < n; i++) {
202  if (onames == NULL) {
203  retval = fprintf(fp," f%d", i);
204  } else {
205  retval = fprintf(fp," %s", onames[i]);
206  }
207  if (retval == EOF) goto failure;
208  }
209  retval = fprintf(fp,"\n");
210  if (retval == EOF) goto failure;
211 
212  retval = Cudd_DumpBlifBody(dd, n, f, inames, onames, fp, mv);
213  if (retval == 0) goto failure;
214 
215  /* Write trailer and return. */
216  retval = fprintf(fp,".end\n");
217  if (retval == EOF) goto failure;
218 
219  return(1);
220 
221 failure:
222  if (sorted != NULL) ABC_FREE(sorted);
223  if (support != NULL) Cudd_RecursiveDeref(dd,support);
224  return(0);
225 
226 } /* end of Cudd_DumpBlif */
#define cuddRef(n)
Definition: cuddInt.h:584
void Cudd_RecursiveDeref(DdManager *table, DdNode *n)
Definition: cuddRef.c:154
Definition: cudd.h:278
int size
Definition: cuddInt.h:361
int Cudd_DumpBlifBody(DdManager *dd, int n, DdNode **f, char **inames, char **onames, FILE *fp, int mv)
Definition: cuddExport.c:252
#define ABC_ALLOC(type, num)
Definition: abc_global.h:229
static const char * onames[]
Definition: testcudd.c:71
#define cuddIsConstant(node)
Definition: cuddInt.h:620
#define cuddT(node)
Definition: cuddInt.h:636
int support
Definition: abcSaucy.c:64
DdHalfWord index
Definition: cudd.h:279
#define ABC_FREE(obj)
Definition: abc_global.h:232
Cudd_ErrorType errorCode
Definition: cuddInt.h:447
DdNode * Cudd_VectorSupport(DdManager *dd, DdNode **F, int n)
Definition: cuddUtil.c:908
int Cudd_DumpBlifBody ( DdManager dd,
int  n,
DdNode **  f,
char **  inames,
char **  onames,
FILE *  fp,
int  mv 
)

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

Synopsis [Writes a blif body representing the argument BDDs.]

Description [Writes a blif body representing the argument BDDs as a network of multiplexers. No header (.model, .inputs, and .outputs) and footer (.end) are produced by this function. One multiplexer is written for each BDD node. It returns 1 in case of success; 0 otherwise (e.g., out-of-memory, file system full, or an ADD with constants different from 0 and 1). Cudd_DumpBlifBody does not close the file: This is the caller responsibility. Cudd_DumpBlifBody uses a minimal unique subset of the hexadecimal address of a node as name for it. If the argument inames is non-null, it is assumed to hold the pointers to the names of the inputs. Similarly for onames. This function prints out only .names part.]

SideEffects [None]

SeeAlso [Cudd_DumpBlif Cudd_DumpDot Cudd_PrintDebug Cudd_DumpDDcal Cudd_DumpDaVinci Cudd_DumpFactoredForm]

Definition at line 252 of file cuddExport.c.

260 {
261  st__table *visited = NULL;
262  int retval;
263  int i;
264 
265  /* Initialize symbol table for visited nodes. */
267  if (visited == NULL) goto failure;
268 
269  /* Call the function that really gets the job done. */
270  for (i = 0; i < n; i++) {
271  retval = ddDoDumpBlif(dd,Cudd_Regular(f[i]),fp,visited,inames,mv);
272  if (retval == 0) goto failure;
273  }
274 
275  /* To account for the possible complement on the root,
276  ** we put either a buffer or an inverter at the output of
277  ** the multiplexer representing the top node.
278  */
279  for (i = 0; i < n; i++) {
280  if (onames == NULL) {
281  retval = fprintf(fp,
282 #if SIZEOF_VOID_P == 8
283  ".names %lx f%d\n", (ptruint) f[i] / (ptruint) sizeof(DdNode), i);
284 #else
285  ".names %x f%d\n", (ptruint) f[i] / (ptruint) sizeof(DdNode), i);
286 #endif
287  } else {
288  retval = fprintf(fp,
289 #if SIZEOF_VOID_P == 8
290  ".names %lx %s\n", (ptruint) f[i] / (ptruint) sizeof(DdNode), onames[i]);
291 #else
292  ".names %x %s\n", (ptruint) f[i] / (ptruint) sizeof(DdNode), onames[i]);
293 #endif
294  }
295  if (retval == EOF) goto failure;
296  if (Cudd_IsComplement(f[i])) {
297  retval = fprintf(fp,"%s0 1\n", mv ? ".def 0\n" : "");
298  } else {
299  retval = fprintf(fp,"%s1 1\n", mv ? ".def 0\n" : "");
300  }
301  if (retval == EOF) goto failure;
302  }
303 
304  st__free_table(visited);
305  return(1);
306 
307 failure:
308  if (visited != NULL) st__free_table(visited);
309  return(0);
310 
311 } /* end of Cudd_DumpBlifBody */
void st__free_table(st__table *table)
Definition: st.c:81
Definition: cudd.h:278
#define Cudd_Regular(node)
Definition: cudd.h:397
int st__ptrcmp(const char *, const char *)
Definition: st.c:480
static int ddDoDumpBlif(DdManager *dd, DdNode *f, FILE *fp, st__table *visited, char **names, int mv)
Definition: cuddExport.c:956
struct DdNode DdNode
Definition: cudd.h:270
ABC_PTRUINT_T ptruint
Definition: cuddInt.h:261
static const char * onames[]
Definition: testcudd.c:71
st__table * st__init_table(st__compare_func_type compare, st__hash_func_type hash)
Definition: st.c:72
#define Cudd_IsComplement(node)
Definition: cudd.h:425
#define SIZEOF_VOID_P
Definition: cudd.h:78
Definition: st.h:52
int st__ptrhash(const char *, int)
Definition: st.c:468
int Cudd_DumpDaVinci ( DdManager dd,
int  n,
DdNode **  f,
char **  inames,
char **  onames,
FILE *  fp 
)

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

Synopsis [Writes a daVinci file representing the argument BDDs.]

Description [Writes a daVinci file representing the argument BDDs. It returns 1 in case of success; 0 otherwise (e.g., out-of-memory or file system full). Cudd_DumpDaVinci does not close the file: This is the caller responsibility. Cudd_DumpDaVinci uses a minimal unique subset of the hexadecimal address of a node as name for it. If the argument inames is non-null, it is assumed to hold the pointers to the names of the inputs. Similarly for onames.]

SideEffects [None]

SeeAlso [Cudd_DumpDot Cudd_PrintDebug Cudd_DumpBlif Cudd_DumpDDcal Cudd_DumpFactoredForm]

Definition at line 615 of file cuddExport.c.

622 {
623  DdNode *support = NULL;
624  DdNode *scan;
625  st__table *visited = NULL;
626  int retval;
627  int i;
628  st__generator *gen;
629  ptruint refAddr, diff, mask;
630 
631  /* Initialize symbol table for visited nodes. */
633  if (visited == NULL) goto failure;
634 
635  /* Collect all the nodes of this DD in the symbol table. */
636  for (i = 0; i < n; i++) {
637  retval = cuddCollectNodes(Cudd_Regular(f[i]),visited);
638  if (retval == 0) goto failure;
639  }
640 
641  /* Find how many most significant hex digits are identical
642  ** in the addresses of all the nodes. Build a mask based
643  ** on this knowledge, so that digits that carry no information
644  ** will not be printed. This is done in two steps.
645  ** 1. We scan the symbol table to find the bits that differ
646  ** in at least 2 addresses.
647  ** 2. We choose one of the possible masks. There are 8 possible
648  ** masks for 32-bit integer, and 16 possible masks for 64-bit
649  ** integers.
650  */
651 
652  /* Find the bits that are different. */
653  refAddr = (ptruint) Cudd_Regular(f[0]);
654  diff = 0;
655  gen = st__init_gen(visited);
656  while ( st__gen(gen, (const char **)&scan, NULL)) {
657  diff |= refAddr ^ (ptruint) scan;
658  }
659  st__free_gen(gen);
660 
661  /* Choose the mask. */
662  for (i = 0; (unsigned) i < 8 * sizeof(ptruint); i += 4) {
663  mask = (1 << i) - 1;
664  if (diff <= mask) break;
665  }
666  st__free_table(visited);
667 
668  /* Initialize symbol table for visited nodes. */
670  if (visited == NULL) goto failure;
671 
672  retval = fprintf(fp, "[");
673  if (retval == EOF) goto failure;
674  /* Call the function that really gets the job done. */
675  for (i = 0; i < n; i++) {
676  if (onames == NULL) {
677  retval = fprintf(fp,
678  "l(\"f%d\",n(\"root\",[a(\"OBJECT\",\"f%d\")],",
679  i,i);
680  } else {
681  retval = fprintf(fp,
682  "l(\"%s\",n(\"root\",[a(\"OBJECT\",\"%s\")],",
683  onames[i], onames[i]);
684  }
685  if (retval == EOF) goto failure;
686  retval = fprintf(fp, "[e(\"edge\",[a(\"EDGECOLOR\",\"%s\"),a(\"_DIR\",\"none\")],",
687  Cudd_IsComplement(f[i]) ? "red" : "blue");
688  if (retval == EOF) goto failure;
689  retval = ddDoDumpDaVinci(dd,Cudd_Regular(f[i]),fp,visited,inames,mask);
690  if (retval == 0) goto failure;
691  retval = fprintf(fp, ")]))%s", i == n-1 ? "" : ",");
692  if (retval == EOF) goto failure;
693  }
694 
695  /* Write trailer and return. */
696  retval = fprintf(fp, "]\n");
697  if (retval == EOF) goto failure;
698 
699  st__free_table(visited);
700  return(1);
701 
702 failure:
703  if (support != NULL) Cudd_RecursiveDeref(dd,support);
704  if (visited != NULL) st__free_table(visited);
705  return(0);
706 
707 } /* end of Cudd_DumpDaVinci */
static int ddDoDumpDaVinci(DdManager *dd, DdNode *f, FILE *fp, st__table *visited, char **names, ptruint mask)
Definition: cuddExport.c:1117
void st__free_table(st__table *table)
Definition: st.c:81
void Cudd_RecursiveDeref(DdManager *table, DdNode *n)
Definition: cuddRef.c:154
Definition: cudd.h:278
void st__free_gen(st__generator *gen)
Definition: st.c:556
#define Cudd_Regular(node)
Definition: cudd.h:397
int st__ptrcmp(const char *, const char *)
Definition: st.c:480
ABC_PTRUINT_T ptruint
Definition: cuddInt.h:261
static const char * onames[]
Definition: testcudd.c:71
st__table * st__init_table(st__compare_func_type compare, st__hash_func_type hash)
Definition: st.c:72
#define Cudd_IsComplement(node)
Definition: cudd.h:425
Definition: st.h:52
st__generator * st__init_gen(st__table *table)
Definition: st.c:486
int support
Definition: abcSaucy.c:64
int cuddCollectNodes(DdNode *f, st__table *visited)
Definition: cuddUtil.c:2925
int st__ptrhash(const char *, int)
Definition: st.c:468
int st__gen(st__generator *gen, const char **key_p, char **value_p)
Definition: st.c:502
int Cudd_DumpDDcal ( DdManager dd,
int  n,
DdNode **  f,
char **  inames,
char **  onames,
FILE *  fp 
)

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

Synopsis [Writes a DDcal file representing the argument BDDs.]

Description [Writes a DDcal file representing the argument BDDs. It returns 1 in case of success; 0 otherwise (e.g., out-of-memory or file system full). Cudd_DumpDDcal does not close the file: This is the caller responsibility. Cudd_DumpDDcal uses a minimal unique subset of the hexadecimal address of a node as name for it. If the argument inames is non-null, it is assumed to hold the pointers to the names of the inputs. Similarly for onames.]

SideEffects [None]

SeeAlso [Cudd_DumpDot Cudd_PrintDebug Cudd_DumpBlif Cudd_DumpDaVinci Cudd_DumpFactoredForm]

Definition at line 729 of file cuddExport.c.

736 {
737  DdNode *support = NULL;
738  DdNode *scan;
739  int *sorted = NULL;
740  int nvars = dd->size;
741  st__table *visited = NULL;
742  int retval;
743  int i;
744  st__generator *gen;
745  ptruint refAddr, diff, mask;
746 
747  /* Initialize symbol table for visited nodes. */
749  if (visited == NULL) goto failure;
750 
751  /* Collect all the nodes of this DD in the symbol table. */
752  for (i = 0; i < n; i++) {
753  retval = cuddCollectNodes(Cudd_Regular(f[i]),visited);
754  if (retval == 0) goto failure;
755  }
756 
757  /* Find how many most significant hex digits are identical
758  ** in the addresses of all the nodes. Build a mask based
759  ** on this knowledge, so that digits that carry no information
760  ** will not be printed. This is done in two steps.
761  ** 1. We scan the symbol table to find the bits that differ
762  ** in at least 2 addresses.
763  ** 2. We choose one of the possible masks. There are 8 possible
764  ** masks for 32-bit integer, and 16 possible masks for 64-bit
765  ** integers.
766  */
767 
768  /* Find the bits that are different. */
769  refAddr = (ptruint) Cudd_Regular(f[0]);
770  diff = 0;
771  gen = st__init_gen(visited);
772  while ( st__gen(gen, (const char **)&scan, NULL)) {
773  diff |= refAddr ^ (ptruint) scan;
774  }
775  st__free_gen(gen);
776 
777  /* Choose the mask. */
778  for (i = 0; (unsigned) i < 8 * sizeof(ptruint); i += 4) {
779  mask = (1 << i) - 1;
780  if (diff <= mask) break;
781  }
782  st__free_table(visited);
783  visited = NULL;
784 
785  /* Build a bit array with the support of f. */
786  sorted = ABC_ALLOC(int,nvars);
787  if (sorted == NULL) {
789  goto failure;
790  }
791  for (i = 0; i < nvars; i++) sorted[i] = 0;
792 
793  /* Take the union of the supports of each output function. */
794  support = Cudd_VectorSupport(dd,f,n);
795  if (support == NULL) goto failure;
796  cuddRef(support);
797  scan = support;
798  while (!cuddIsConstant(scan)) {
799  sorted[scan->index] = 1;
800  scan = cuddT(scan);
801  }
802  Cudd_RecursiveDeref(dd,support);
803  support = NULL; /* so that we do not try to free it in case of failure */
804  for (i = 0; i < nvars; i++) {
805  if (sorted[dd->invperm[i]]) {
806  if (inames == NULL || inames[dd->invperm[i]] == NULL) {
807  retval = fprintf(fp,"v%d", dd->invperm[i]);
808  } else {
809  retval = fprintf(fp,"%s", inames[dd->invperm[i]]);
810  }
811  if (retval == EOF) goto failure;
812  }
813  retval = fprintf(fp,"%s", i == nvars - 1 ? "\n" : " * ");
814  if (retval == EOF) goto failure;
815  }
816  ABC_FREE(sorted);
817  sorted = NULL;
818 
819  /* Initialize symbol table for visited nodes. */
821  if (visited == NULL) goto failure;
822 
823  /* Call the function that really gets the job done. */
824  for (i = 0; i < n; i++) {
825  retval = ddDoDumpDDcal(dd,Cudd_Regular(f[i]),fp,visited,inames,mask);
826  if (retval == 0) goto failure;
827  if (onames == NULL) {
828  retval = fprintf(fp, "f%d = ", i);
829  } else {
830  retval = fprintf(fp, "%s = ", onames[i]);
831  }
832  if (retval == EOF) goto failure;
833  retval = fprintf(fp, "n%p%s\n",
834  (void *) (((ptruint) f[i] & mask) /
835  (ptruint) sizeof(DdNode)),
836  Cudd_IsComplement(f[i]) ? "'" : "");
837  if (retval == EOF) goto failure;
838  }
839 
840  /* Write trailer and return. */
841  retval = fprintf(fp, "[");
842  if (retval == EOF) goto failure;
843  for (i = 0; i < n; i++) {
844  if (onames == NULL) {
845  retval = fprintf(fp, "f%d", i);
846  } else {
847  retval = fprintf(fp, "%s", onames[i]);
848  }
849  retval = fprintf(fp, "%s", i == n-1 ? "" : " ");
850  if (retval == EOF) goto failure;
851  }
852  retval = fprintf(fp, "]\n");
853  if (retval == EOF) goto failure;
854 
855  if ( visited )
856  st__free_table(visited);
857  return(1);
858 
859 failure:
860  if (sorted != NULL) ABC_FREE(sorted);
861  if (support != NULL) Cudd_RecursiveDeref(dd,support);
862  if (visited != NULL) st__free_table(visited);
863  return(0);
864 
865 } /* end of Cudd_DumpDDcal */
void st__free_table(st__table *table)
Definition: st.c:81
#define cuddRef(n)
Definition: cuddInt.h:584
void Cudd_RecursiveDeref(DdManager *table, DdNode *n)
Definition: cuddRef.c:154
Definition: cudd.h:278
void st__free_gen(st__generator *gen)
Definition: st.c:556
int size
Definition: cuddInt.h:361
#define Cudd_Regular(node)
Definition: cudd.h:397
int st__ptrcmp(const char *, const char *)
Definition: st.c:480
#define ABC_ALLOC(type, num)
Definition: abc_global.h:229
ABC_PTRUINT_T ptruint
Definition: cuddInt.h:261
static const char * onames[]
Definition: testcudd.c:71
st__table * st__init_table(st__compare_func_type compare, st__hash_func_type hash)
Definition: st.c:72
#define Cudd_IsComplement(node)
Definition: cudd.h:425
Definition: st.h:52
#define cuddIsConstant(node)
Definition: cuddInt.h:620
#define cuddT(node)
Definition: cuddInt.h:636
st__generator * st__init_gen(st__table *table)
Definition: st.c:486
int support
Definition: abcSaucy.c:64
static int ddDoDumpDDcal(DdManager *dd, DdNode *f, FILE *fp, st__table *visited, char **names, ptruint mask)
Definition: cuddExport.c:1216
DdHalfWord index
Definition: cudd.h:279
#define ABC_FREE(obj)
Definition: abc_global.h:232
int cuddCollectNodes(DdNode *f, st__table *visited)
Definition: cuddUtil.c:2925
int * invperm
Definition: cuddInt.h:388
Cudd_ErrorType errorCode
Definition: cuddInt.h:447
int st__ptrhash(const char *, int)
Definition: st.c:468
int st__gen(st__generator *gen, const char **key_p, char **value_p)
Definition: st.c:502
DdNode * Cudd_VectorSupport(DdManager *dd, DdNode **F, int n)
Definition: cuddUtil.c:908
int Cudd_DumpDot ( DdManager dd,
int  n,
DdNode **  f,
char **  inames,
char **  onames,
FILE *  fp 
)

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

Synopsis [Writes a dot file representing the argument DDs.]

Description [Writes a file representing the argument DDs in a format suitable for the graph drawing program dot. It returns 1 in case of success; 0 otherwise (e.g., out-of-memory, file system full). Cudd_DumpDot does not close the file: This is the caller responsibility. Cudd_DumpDot uses a minimal unique subset of the hexadecimal address of a node as name for it. If the argument inames is non-null, it is assumed to hold the pointers to the names of the inputs. Similarly for onames. Cudd_DumpDot uses the following convention to draw arcs:

  • solid line: THEN arcs;
  • dotted line: complement arcs;
  • dashed line: regular ELSE arcs.

The dot options are chosen so that the drawing fits on a letter-size sheet. ]

SideEffects [None]

SeeAlso [Cudd_DumpBlif Cudd_PrintDebug Cudd_DumpDDcal Cudd_DumpDaVinci Cudd_DumpFactoredForm]

Definition at line 344 of file cuddExport.c.

351 {
352  DdNode *support = NULL;
353  DdNode *scan;
354  int *sorted = NULL;
355  int nvars = dd->size;
356  st__table *visited = NULL;
357  st__generator *gen = NULL;
358  int retval;
359  int i, j;
360  int slots;
361  DdNodePtr *nodelist;
362  long refAddr, diff, mask;
363 
364  /* Build a bit array with the support of f. */
365  sorted = ABC_ALLOC(int,nvars);
366  if (sorted == NULL) {
368  goto failure;
369  }
370  for (i = 0; i < nvars; i++) sorted[i] = 0;
371 
372  /* Take the union of the supports of each output function. */
373  support = Cudd_VectorSupport(dd,f,n);
374  if (support == NULL) goto failure;
375  cuddRef(support);
376  scan = support;
377  while (!cuddIsConstant(scan)) {
378  sorted[scan->index] = 1;
379  scan = cuddT(scan);
380  }
381  Cudd_RecursiveDeref(dd,support);
382  support = NULL; /* so that we do not try to free it in case of failure */
383 
384  /* Initialize symbol table for visited nodes. */
386  if (visited == NULL) goto failure;
387 
388  /* Collect all the nodes of this DD in the symbol table. */
389  for (i = 0; i < n; i++) {
390  retval = cuddCollectNodes(Cudd_Regular(f[i]),visited);
391  if (retval == 0) goto failure;
392  }
393 
394  /* Find how many most significant hex digits are identical
395  ** in the addresses of all the nodes. Build a mask based
396  ** on this knowledge, so that digits that carry no information
397  ** will not be printed. This is done in two steps.
398  ** 1. We scan the symbol table to find the bits that differ
399  ** in at least 2 addresses.
400  ** 2. We choose one of the possible masks. There are 8 possible
401  ** masks for 32-bit integer, and 16 possible masks for 64-bit
402  ** integers.
403  */
404 
405  /* Find the bits that are different. */
406  refAddr = (long) Cudd_Regular(f[0]);
407  diff = 0;
408  gen = st__init_gen(visited);
409  if (gen == NULL) goto failure;
410  while ( st__gen(gen, (const char **)&scan, NULL)) {
411  diff |= refAddr ^ (long) scan;
412  }
413  st__free_gen(gen); gen = NULL;
414 
415  /* Choose the mask. */
416  for (i = 0; (unsigned) i < 8 * sizeof(long); i += 4) {
417  mask = (1 << i) - 1;
418  if (diff <= mask) break;
419  }
420 
421  /* Write the header and the global attributes. */
422  retval = fprintf(fp,"digraph \"DD\" {\n");
423  if (retval == EOF) return(0);
424  retval = fprintf(fp,
425  "size = \"7.5,10\"\ncenter = true;\nedge [dir = none];\n");
426  if (retval == EOF) return(0);
427 
428  /* Write the input name subgraph by scanning the support array. */
429  retval = fprintf(fp,"{ node [shape = plaintext];\n");
430  if (retval == EOF) goto failure;
431  retval = fprintf(fp," edge [style = invis];\n");
432  if (retval == EOF) goto failure;
433  /* We use a name ("CONST NODES") with an embedded blank, because
434  ** it is unlikely to appear as an input name.
435  */
436  retval = fprintf(fp," \"CONST NODES\" [style = invis];\n");
437  if (retval == EOF) goto failure;
438  for (i = 0; i < nvars; i++) {
439  if (sorted[dd->invperm[i]]) {
440  if (inames == NULL || inames[dd->invperm[i]] == NULL) {
441  retval = fprintf(fp,"\" %d \" -> ", dd->invperm[i]);
442  } else {
443  retval = fprintf(fp,"\" %s \" -> ", inames[dd->invperm[i]]);
444  }
445  if (retval == EOF) goto failure;
446  }
447  }
448  retval = fprintf(fp,"\"CONST NODES\"; \n}\n");
449  if (retval == EOF) goto failure;
450 
451  /* Write the output node subgraph. */
452  retval = fprintf(fp,"{ rank = same; node [shape = box]; edge [style = invis];\n");
453  if (retval == EOF) goto failure;
454  for (i = 0; i < n; i++) {
455  if (onames == NULL) {
456  retval = fprintf(fp,"\"F%d\"", i);
457  } else {
458  retval = fprintf(fp,"\" %s \"", onames[i]);
459  }
460  if (retval == EOF) goto failure;
461  if (i == n - 1) {
462  retval = fprintf(fp,"; }\n");
463  } else {
464  retval = fprintf(fp," -> ");
465  }
466  if (retval == EOF) goto failure;
467  }
468 
469  /* Write rank info: All nodes with the same index have the same rank. */
470  for (i = 0; i < nvars; i++) {
471  if (sorted[dd->invperm[i]]) {
472  retval = fprintf(fp,"{ rank = same; ");
473  if (retval == EOF) goto failure;
474  if (inames == NULL || inames[dd->invperm[i]] == NULL) {
475  retval = fprintf(fp,"\" %d \";\n", dd->invperm[i]);
476  } else {
477  retval = fprintf(fp,"\" %s \";\n", inames[dd->invperm[i]]);
478  }
479  if (retval == EOF) goto failure;
480  nodelist = dd->subtables[i].nodelist;
481  slots = dd->subtables[i].slots;
482  for (j = 0; j < slots; j++) {
483  scan = nodelist[j];
484  while (scan != NULL) {
485  if ( st__is_member(visited,(char *) scan)) {
486  retval = fprintf(fp,"\"%lx\";\n", ((mask & (ptrint) scan) / sizeof(DdNode)));
487  if (retval == EOF) goto failure;
488  }
489  scan = scan->next;
490  }
491  }
492  retval = fprintf(fp,"}\n");
493  if (retval == EOF) goto failure;
494  }
495  }
496 
497  /* All constants have the same rank. */
498  retval = fprintf(fp,
499  "{ rank = same; \"CONST NODES\";\n{ node [shape = box]; ");
500  if (retval == EOF) goto failure;
501  nodelist = dd->constants.nodelist;
502  slots = dd->constants.slots;
503  for (j = 0; j < slots; j++) {
504  scan = nodelist[j];
505  while (scan != NULL) {
506  if ( st__is_member(visited,(char *) scan)) {
507  retval = fprintf(fp,"\"%lx\";\n", ((mask & (ptrint) scan) / sizeof(DdNode)));
508  if (retval == EOF) goto failure;
509  }
510  scan = scan->next;
511  }
512  }
513  retval = fprintf(fp,"}\n}\n");
514  if (retval == EOF) goto failure;
515 
516  /* Write edge info. */
517  /* Edges from the output nodes. */
518  for (i = 0; i < n; i++) {
519  if (onames == NULL) {
520  retval = fprintf(fp,"\"F%d\"", i);
521  } else {
522  retval = fprintf(fp,"\" %s \"", onames[i]);
523  }
524  if (retval == EOF) goto failure;
525  /* Account for the possible complement on the root. */
526  if (Cudd_IsComplement(f[i])) {
527  retval = fprintf(fp," -> \"%lx\" [style = dotted];\n", ((mask & (ptrint) f[i]) / sizeof(DdNode)));
528  } else {
529  retval = fprintf(fp," -> \"%lx\" [style = solid];\n", ((mask & (ptrint) f[i]) / sizeof(DdNode)));
530  }
531  if (retval == EOF) goto failure;
532  }
533 
534  /* Edges from internal nodes. */
535  for (i = 0; i < nvars; i++) {
536  if (sorted[dd->invperm[i]]) {
537  nodelist = dd->subtables[i].nodelist;
538  slots = dd->subtables[i].slots;
539  for (j = 0; j < slots; j++) {
540  scan = nodelist[j];
541  while (scan != NULL) {
542  if ( st__is_member(visited,(char *) scan)) {
543  retval = fprintf(fp, "\"%lx\" -> \"%lx\";\n",
544  ((mask & (ptrint) scan) / sizeof(DdNode)),
545  ((mask & (ptrint) cuddT(scan)) / sizeof(DdNode)));
546  if (retval == EOF) goto failure;
547  if (Cudd_IsComplement(cuddE(scan))) {
548  retval = fprintf(fp,"\"%lx\" -> \"%lx\" [style = dotted];\n",
549  ((mask & (ptrint) scan) / sizeof(DdNode)),
550  ((mask & (ptrint) cuddE(scan)) / sizeof(DdNode)));
551  } else {
552  retval = fprintf(fp, "\"%lx\" -> \"%lx\" [style = dashed];\n",
553  ((mask & (ptrint) scan) / sizeof(DdNode)),
554  ((mask & (ptrint) cuddE(scan)) / sizeof(DdNode)));
555  }
556  if (retval == EOF) goto failure;
557  }
558  scan = scan->next;
559  }
560  }
561  }
562  }
563 
564  /* Write constant labels. */
565  nodelist = dd->constants.nodelist;
566  slots = dd->constants.slots;
567  for (j = 0; j < slots; j++) {
568  scan = nodelist[j];
569  while (scan != NULL) {
570  if ( st__is_member(visited,(char *) scan)) {
571  retval = fprintf(fp,"\"%lx\" [label = \"%g\"];\n",
572  ((mask & (ptrint) scan) / sizeof(DdNode)), cuddV(scan));
573  if (retval == EOF) goto failure;
574  }
575  scan = scan->next;
576  }
577  }
578 
579  /* Write trailer and return. */
580  retval = fprintf(fp,"}\n");
581  if (retval == EOF) goto failure;
582 
583  st__free_table(visited);
584  ABC_FREE(sorted);
585  return(1);
586 
587 failure:
588  if (sorted != NULL) ABC_FREE(sorted);
589  if (support != NULL) Cudd_RecursiveDeref(dd,support);
590  if (visited != NULL) st__free_table(visited);
591  return(0);
592 
593 } /* end of Cudd_DumpDot */
void st__free_table(st__table *table)
Definition: st.c:81
#define cuddRef(n)
Definition: cuddInt.h:584
void Cudd_RecursiveDeref(DdManager *table, DdNode *n)
Definition: cuddRef.c:154
Definition: cudd.h:278
void st__free_gen(st__generator *gen)
Definition: st.c:556
int size
Definition: cuddInt.h:361
#define Cudd_Regular(node)
Definition: cudd.h:397
int st__ptrcmp(const char *, const char *)
Definition: st.c:480
#define ABC_ALLOC(type, num)
Definition: abc_global.h:229
DdSubtable * subtables
Definition: cuddInt.h:365
#define st__is_member(table, key)
Definition: st.h:70
#define cuddV(node)
Definition: cuddInt.h:668
static const char * onames[]
Definition: testcudd.c:71
st__table * st__init_table(st__compare_func_type compare, st__hash_func_type hash)
Definition: st.c:72
#define Cudd_IsComplement(node)
Definition: cudd.h:425
ABC_PTRINT_T ptrint
Definition: cuddInt.h:260
Definition: st.h:52
#define cuddIsConstant(node)
Definition: cuddInt.h:620
DdNode ** nodelist
Definition: cuddInt.h:327
#define cuddT(node)
Definition: cuddInt.h:636
st__generator * st__init_gen(st__table *table)
Definition: st.c:486
int support
Definition: abcSaucy.c:64
DdHalfWord index
Definition: cudd.h:279
#define ABC_FREE(obj)
Definition: abc_global.h:232
unsigned int slots
Definition: cuddInt.h:329
#define cuddE(node)
Definition: cuddInt.h:652
int cuddCollectNodes(DdNode *f, st__table *visited)
Definition: cuddUtil.c:2925
int * invperm
Definition: cuddInt.h:388
DdSubtable constants
Definition: cuddInt.h:367
Cudd_ErrorType errorCode
Definition: cuddInt.h:447
int st__ptrhash(const char *, int)
Definition: st.c:468
int st__gen(st__generator *gen, const char **key_p, char **value_p)
Definition: st.c:502
DdNode * Cudd_VectorSupport(DdManager *dd, DdNode **F, int n)
Definition: cuddUtil.c:908
int Cudd_DumpFactoredForm ( DdManager dd,
int  n,
DdNode **  f,
char **  inames,
char **  onames,
FILE *  fp 
)

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

Synopsis [Writes factored forms representing the argument BDDs.]

Description [Writes factored forms representing the argument BDDs. The format of the factored form is the one used in the genlib files for technology mapping in sis. It returns 1 in case of success; 0 otherwise (e.g., file system full). Cudd_DumpFactoredForm does not close the file: This is the caller responsibility. Caution must be exercised because a factored form may be exponentially larger than the argument BDD. If the argument inames is non-null, it is assumed to hold the pointers to the names of the inputs. Similarly for onames.]

SideEffects [None]

SeeAlso [Cudd_DumpDot Cudd_PrintDebug Cudd_DumpBlif Cudd_DumpDaVinci Cudd_DumpDDcal]

Definition at line 889 of file cuddExport.c.

896 {
897  int retval;
898  int i;
899 
900  /* Call the function that really gets the job done. */
901  for (i = 0; i < n; i++) {
902  if (onames == NULL) {
903  retval = fprintf(fp, "f%d = ", i);
904  } else {
905  retval = fprintf(fp, "%s = ", onames[i]);
906  }
907  if (retval == EOF) return(0);
908  if (f[i] == DD_ONE(dd)) {
909  retval = fprintf(fp, "CONST1");
910  if (retval == EOF) return(0);
911  } else if (f[i] == Cudd_Not(DD_ONE(dd)) || f[i] == DD_ZERO(dd)) {
912  retval = fprintf(fp, "CONST0");
913  if (retval == EOF) return(0);
914  } else {
915  retval = fprintf(fp, "%s", Cudd_IsComplement(f[i]) ? "!(" : "");
916  if (retval == EOF) return(0);
917  retval = ddDoDumpFactoredForm(dd,Cudd_Regular(f[i]),fp,inames);
918  if (retval == 0) return(0);
919  retval = fprintf(fp, "%s", Cudd_IsComplement(f[i]) ? ")" : "");
920  if (retval == EOF) return(0);
921  }
922  retval = fprintf(fp, "%s", i == n-1 ? "" : "\n");
923  if (retval == EOF) return(0);
924  }
925 
926  return(1);
927 
928 } /* end of Cudd_DumpFactoredForm */
static int ddDoDumpFactoredForm(DdManager *dd, DdNode *f, FILE *fp, char **names)
Definition: cuddExport.c:1310
#define Cudd_Not(node)
Definition: cudd.h:367
#define Cudd_Regular(node)
Definition: cudd.h:397
static const char * onames[]
Definition: testcudd.c:71
#define Cudd_IsComplement(node)
Definition: cudd.h:425
#define DD_ONE(dd)
Definition: cuddInt.h:911
#define DD_ZERO(dd)
Definition: cuddInt.h:927
DdNode* Cudd_Dxygtdxz ( DdManager dd,
int  N,
DdNode **  x,
DdNode **  y,
DdNode **  z 
)

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

Synopsis [Generates a BDD for the function d(x,y) > d(x,z).]

Description [This function generates a BDD for the function d(x,y) > d(x,z); x, y, and z are N-bit numbers, x[0] x[1] ... x[N-1], y[0] y[1] ... y[N-1], and z[0] z[1] ... z[N-1], with 0 the most significant bit. The distance d(x,y) is defined as: {i=0}^{N-1}(|x_i - y_i| 2^{N-i-1}). The BDD is built bottom-up. It has 7*N-3 internal nodes, if the variables are ordered as follows: x[0] y[0] z[0] x[1] y[1] z[1] ... x[N-1] y[N-1] z[N-1]. ]

SideEffects [None]

SeeAlso [Cudd_PrioritySelect Cudd_Dxygtdyz Cudd_Xgty Cudd_bddAdjPermuteX]

Definition at line 494 of file cuddPriority.c.

500 {
501  DdNode *one, *zero;
502  DdNode *z1, *z2, *z3, *z4, *y1_, *y2, *x1;
503  int i;
504 
505  one = DD_ONE(dd);
506  zero = Cudd_Not(one);
507 
508  /* Build bottom part of BDD outside loop. */
509  y1_ = Cudd_bddIte(dd, y[N-1], one, Cudd_Not(z[N-1]));
510  if (y1_ == NULL) return(NULL);
511  cuddRef(y1_);
512  y2 = Cudd_bddIte(dd, y[N-1], z[N-1], one);
513  if (y2 == NULL) {
514  Cudd_RecursiveDeref(dd, y1_);
515  return(NULL);
516  }
517  cuddRef(y2);
518  x1 = Cudd_bddIte(dd, x[N-1], y1_, y2);
519  if (x1 == NULL) {
520  Cudd_RecursiveDeref(dd, y1_);
521  Cudd_RecursiveDeref(dd, y2);
522  return(NULL);
523  }
524  cuddRef(x1);
525  Cudd_RecursiveDeref(dd, y1_);
526  Cudd_RecursiveDeref(dd, y2);
527 
528  /* Loop to build the rest of the BDD. */
529  for (i = N-2; i >= 0; i--) {
530  z1 = Cudd_bddIte(dd, z[i], one, Cudd_Not(x1));
531  if (z1 == NULL) {
532  Cudd_RecursiveDeref(dd, x1);
533  return(NULL);
534  }
535  cuddRef(z1);
536  z2 = Cudd_bddIte(dd, z[i], x1, one);
537  if (z2 == NULL) {
538  Cudd_RecursiveDeref(dd, x1);
539  Cudd_RecursiveDeref(dd, z1);
540  return(NULL);
541  }
542  cuddRef(z2);
543  z3 = Cudd_bddIte(dd, z[i], one, x1);
544  if (z3 == NULL) {
545  Cudd_RecursiveDeref(dd, x1);
546  Cudd_RecursiveDeref(dd, z1);
547  Cudd_RecursiveDeref(dd, z2);
548  return(NULL);
549  }
550  cuddRef(z3);
551  z4 = Cudd_bddIte(dd, z[i], x1, zero);
552  if (z4 == NULL) {
553  Cudd_RecursiveDeref(dd, x1);
554  Cudd_RecursiveDeref(dd, z1);
555  Cudd_RecursiveDeref(dd, z2);
556  Cudd_RecursiveDeref(dd, z3);
557  return(NULL);
558  }
559  cuddRef(z4);
560  Cudd_RecursiveDeref(dd, x1);
561  y1_ = Cudd_bddIte(dd, y[i], z2, Cudd_Not(z1));
562  if (y1_ == NULL) {
563  Cudd_RecursiveDeref(dd, z1);
564  Cudd_RecursiveDeref(dd, z2);
565  Cudd_RecursiveDeref(dd, z3);
566  Cudd_RecursiveDeref(dd, z4);
567  return(NULL);
568  }
569  cuddRef(y1_);
570  y2 = Cudd_bddIte(dd, y[i], z4, z3);
571  if (y2 == NULL) {
572  Cudd_RecursiveDeref(dd, z1);
573  Cudd_RecursiveDeref(dd, z2);
574  Cudd_RecursiveDeref(dd, z3);
575  Cudd_RecursiveDeref(dd, z4);
576  Cudd_RecursiveDeref(dd, y1_);
577  return(NULL);
578  }
579  cuddRef(y2);
580  Cudd_RecursiveDeref(dd, z1);
581  Cudd_RecursiveDeref(dd, z2);
582  Cudd_RecursiveDeref(dd, z3);
583  Cudd_RecursiveDeref(dd, z4);
584  x1 = Cudd_bddIte(dd, x[i], y1_, y2);
585  if (x1 == NULL) {
586  Cudd_RecursiveDeref(dd, y1_);
587  Cudd_RecursiveDeref(dd, y2);
588  return(NULL);
589  }
590  cuddRef(x1);
591  Cudd_RecursiveDeref(dd, y1_);
592  Cudd_RecursiveDeref(dd, y2);
593  }
594  cuddDeref(x1);
595  return(Cudd_Not(x1));
596 
597 } /* end of Cudd_Dxygtdxz */
#define cuddRef(n)
Definition: cuddInt.h:584
#define cuddDeref(n)
Definition: cuddInt.h:604
void Cudd_RecursiveDeref(DdManager *table, DdNode *n)
Definition: cuddRef.c:154
Definition: cudd.h:278
#define z1
Definition: extraBdd.h:78
#define Cudd_Not(node)
Definition: cudd.h:367
DdNode * Cudd_bddIte(DdManager *dd, DdNode *f, DdNode *g, DdNode *h)
Definition: cuddBddIte.c:143
static DdNode * one
Definition: cuddDecomp.c:112
#define DD_ONE(dd)
Definition: cuddInt.h:911
static DdNode * zero
Definition: cuddApa.c:100
DdNode* Cudd_Dxygtdyz ( DdManager dd,
int  N,
DdNode **  x,
DdNode **  y,
DdNode **  z 
)

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

Synopsis [Generates a BDD for the function d(x,y) > d(y,z).]

Description [This function generates a BDD for the function d(x,y) > d(y,z); x, y, and z are N-bit numbers, x[0] x[1] ... x[N-1], y[0] y[1] ... y[N-1], and z[0] z[1] ... z[N-1], with 0 the most significant bit. The distance d(x,y) is defined as: {i=0}^{N-1}(|x_i - y_i| 2^{N-i-1}). The BDD is built bottom-up. It has 7*N-3 internal nodes, if the variables are ordered as follows: x[0] y[0] z[0] x[1] y[1] z[1] ... x[N-1] y[N-1] z[N-1]. ]

SideEffects [None]

SeeAlso [Cudd_PrioritySelect Cudd_Dxygtdxz Cudd_Xgty Cudd_bddAdjPermuteX]

Definition at line 621 of file cuddPriority.c.

627 {
628  DdNode *one, *zero;
629  DdNode *z1, *z2, *z3, *z4, *y1_, *y2, *x1;
630  int i;
631 
632  one = DD_ONE(dd);
633  zero = Cudd_Not(one);
634 
635  /* Build bottom part of BDD outside loop. */
636  y1_ = Cudd_bddIte(dd, y[N-1], one, z[N-1]);
637  if (y1_ == NULL) return(NULL);
638  cuddRef(y1_);
639  y2 = Cudd_bddIte(dd, y[N-1], z[N-1], zero);
640  if (y2 == NULL) {
641  Cudd_RecursiveDeref(dd, y1_);
642  return(NULL);
643  }
644  cuddRef(y2);
645  x1 = Cudd_bddIte(dd, x[N-1], y1_, Cudd_Not(y2));
646  if (x1 == NULL) {
647  Cudd_RecursiveDeref(dd, y1_);
648  Cudd_RecursiveDeref(dd, y2);
649  return(NULL);
650  }
651  cuddRef(x1);
652  Cudd_RecursiveDeref(dd, y1_);
653  Cudd_RecursiveDeref(dd, y2);
654 
655  /* Loop to build the rest of the BDD. */
656  for (i = N-2; i >= 0; i--) {
657  z1 = Cudd_bddIte(dd, z[i], x1, zero);
658  if (z1 == NULL) {
659  Cudd_RecursiveDeref(dd, x1);
660  return(NULL);
661  }
662  cuddRef(z1);
663  z2 = Cudd_bddIte(dd, z[i], x1, one);
664  if (z2 == NULL) {
665  Cudd_RecursiveDeref(dd, x1);
666  Cudd_RecursiveDeref(dd, z1);
667  return(NULL);
668  }
669  cuddRef(z2);
670  z3 = Cudd_bddIte(dd, z[i], one, x1);
671  if (z3 == NULL) {
672  Cudd_RecursiveDeref(dd, x1);
673  Cudd_RecursiveDeref(dd, z1);
674  Cudd_RecursiveDeref(dd, z2);
675  return(NULL);
676  }
677  cuddRef(z3);
678  z4 = Cudd_bddIte(dd, z[i], one, Cudd_Not(x1));
679  if (z4 == NULL) {
680  Cudd_RecursiveDeref(dd, x1);
681  Cudd_RecursiveDeref(dd, z1);
682  Cudd_RecursiveDeref(dd, z2);
683  Cudd_RecursiveDeref(dd, z3);
684  return(NULL);
685  }
686  cuddRef(z4);
687  Cudd_RecursiveDeref(dd, x1);
688  y1_ = Cudd_bddIte(dd, y[i], z2, z1);
689  if (y1_ == NULL) {
690  Cudd_RecursiveDeref(dd, z1);
691  Cudd_RecursiveDeref(dd, z2);
692  Cudd_RecursiveDeref(dd, z3);
693  Cudd_RecursiveDeref(dd, z4);
694  return(NULL);
695  }
696  cuddRef(y1_);
697  y2 = Cudd_bddIte(dd, y[i], z4, Cudd_Not(z3));
698  if (y2 == NULL) {
699  Cudd_RecursiveDeref(dd, z1);
700  Cudd_RecursiveDeref(dd, z2);
701  Cudd_RecursiveDeref(dd, z3);
702  Cudd_RecursiveDeref(dd, z4);
703  Cudd_RecursiveDeref(dd, y1_);
704  return(NULL);
705  }
706  cuddRef(y2);
707  Cudd_RecursiveDeref(dd, z1);
708  Cudd_RecursiveDeref(dd, z2);
709  Cudd_RecursiveDeref(dd, z3);
710  Cudd_RecursiveDeref(dd, z4);
711  x1 = Cudd_bddIte(dd, x[i], y1_, Cudd_Not(y2));
712  if (x1 == NULL) {
713  Cudd_RecursiveDeref(dd, y1_);
714  Cudd_RecursiveDeref(dd, y2);
715  return(NULL);
716  }
717  cuddRef(x1);
718  Cudd_RecursiveDeref(dd, y1_);
719  Cudd_RecursiveDeref(dd, y2);
720  }
721  cuddDeref(x1);
722  return(Cudd_Not(x1));
723 
724 } /* end of Cudd_Dxygtdyz */
#define cuddRef(n)
Definition: cuddInt.h:584
#define cuddDeref(n)
Definition: cuddInt.h:604
void Cudd_RecursiveDeref(DdManager *table, DdNode *n)
Definition: cuddRef.c:154
Definition: cudd.h:278
#define z1
Definition: extraBdd.h:78
#define Cudd_Not(node)
Definition: cudd.h:367
DdNode * Cudd_bddIte(DdManager *dd, DdNode *f, DdNode *g, DdNode *h)
Definition: cuddBddIte.c:143
static DdNode * one
Definition: cuddDecomp.c:112
#define DD_ONE(dd)
Definition: cuddInt.h:911
static DdNode * zero
Definition: cuddApa.c:100
void Cudd_EnableGarbageCollection ( DdManager dd)

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

Synopsis [Enables garbage collection.]

Description [Enables garbage collection. Garbage collection is initially enabled. Therefore it is necessary to call this function only if garbage collection has been explicitly disabled.]

SideEffects [None]

SeeAlso [Cudd_DisableGarbageCollection Cudd_GarbageCollectionEnabled]

Definition at line 2539 of file cuddAPI.c.

2541 {
2542  dd->gcEnabled = 1;
2543 
2544 } /* end of Cudd_EnableGarbageCollection */
int gcEnabled
Definition: cuddInt.h:376
int Cudd_EnableReorderingReporting ( DdManager dd)

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

Synopsis [Enables reporting of reordering stats.]

Description [Enables reporting of reordering stats. Returns 1 if successful; 0 otherwise.]

SideEffects [Installs functions in the pre-reordering and post-reordering hooks.]

SeeAlso [Cudd_DisableReorderingReporting Cudd_ReorderingReporting]

Definition at line 3536 of file cuddAPI.c.

3538 {
3540  return(0);
3541  }
3543  return(0);
3544  }
3545  return(1);
3546 
3547 } /* end of Cudd_EnableReorderingReporting */
int Cudd_StdPostReordHook(DdManager *dd, const char *str, void *data)
Definition: cuddAPI.c:3501
int Cudd_StdPreReordHook(DdManager *dd, const char *str, void *data)
Definition: cuddAPI.c:3408
int Cudd_AddHook(DdManager *dd, DD_HFP f, Cudd_HookType where)
Definition: cuddAPI.c:3244
int Cudd_EpdCountMinterm ( DdManager manager,
DdNode node,
int  nvars,
EpDouble epd 
)

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

Synopsis [Counts the number of minterms of a DD with extended precision.]

Description [Counts the number of minterms of a DD with extended precision. The function is assumed to depend on nvars variables. The minterm count is represented as an EpDouble, to allow any number of variables. Returns 0 if successful; CUDD_OUT_OF_MEM otherwise.]

SideEffects [None]

SeeAlso [Cudd_PrintDebug Cudd_CountPath]

Definition at line 657 of file cuddUtil.c.

662 {
663  EpDouble max, tmp;
664  st__table *table;
665  int status;
666 
667  background = manager->background;
668  zero = Cudd_Not(manager->one);
669 
670  EpdPow2(nvars, &max);
672  if (table == NULL) {
673  EpdMakeZero(epd, 0);
674  return(CUDD_OUT_OF_MEM);
675  }
676  status = ddEpdCountMintermAux(Cudd_Regular(node),&max,epd,table);
677  st__foreach(table, ddEpdFree, NULL);
678  st__free_table(table);
679  if (status == CUDD_OUT_OF_MEM) {
680  EpdMakeZero(epd, 0);
681  return(CUDD_OUT_OF_MEM);
682  }
683  if (Cudd_IsComplement(node)) {
684  EpdSubtract3(&max, epd, &tmp);
685  EpdCopy(&tmp, epd);
686  }
687  return(0);
688 
689 } /* end of Cudd_EpdCountMinterm */
void st__free_table(st__table *table)
Definition: st.c:81
#define CUDD_OUT_OF_MEM
Definition: cudd.h:95
int EpdCmp(const char *key1, const char *key2)
Definition: epd.c:93
#define Cudd_Not(node)
Definition: cudd.h:367
void EpdCopy(EpDouble *from, EpDouble *to)
Definition: epd.c:1182
#define Cudd_Regular(node)
Definition: cudd.h:397
static enum st__retval ddEpdFree(char *key, char *value, char *arg)
Definition: cuddUtil.c:3922
static DdNode * background
Definition: cuddUtil.c:148
void EpdPow2(int n, EpDouble *epd)
Definition: epd.c:917
void EpdSubtract3(EpDouble *epd1, EpDouble *epd2, EpDouble *epd3)
Definition: epd.c:850
st__table * st__init_table(st__compare_func_type compare, st__hash_func_type hash)
Definition: st.c:72
#define Cudd_IsComplement(node)
Definition: cudd.h:425
Definition: st.h:52
static DdNode * zero
Definition: cuddUtil.c:148
static double max
Definition: cuddSubsetHB.c:134
void EpdMakeZero(EpDouble *epd, int sign)
Definition: epd.c:1137
int st__foreach(st__table *table, enum st__retval(*func)(char *, char *, char *), char *arg)
Definition: st.c:421
DdNode * one
Definition: cuddInt.h:345
static int ddEpdCountMintermAux(DdNode *node, EpDouble *max, EpDouble *epd, st__table *table)
Definition: cuddUtil.c:3573
int st__ptrhash(const char *, int)
Definition: st.c:468
DdNode * background
Definition: cuddInt.h:349
int Cudd_EqualSupNorm ( DdManager dd,
DdNode f,
DdNode g,
CUDD_VALUE_TYPE  tolerance,
int  pr 
)

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

Synopsis [Compares two ADDs for equality within tolerance.]

Description [Compares two ADDs for equality within tolerance. Two ADDs are reported to be equal if the maximum difference between them (the sup norm of their difference) is less than or equal to the tolerance parameter. Returns 1 if the two ADDs are equal (within tolerance); 0 otherwise. If parameter pr is positive the first failure is reported to the standard output.]

SideEffects [None]

SeeAlso []

Definition at line 796 of file cuddSat.c.

802 {
803  DdNode *fv, *fvn, *gv, *gvn, *r;
804  unsigned int topf, topg;
805 
806  statLine(dd);
807  /* Check terminal cases. */
808  if (f == g) return(1);
809  if (Cudd_IsConstant(f) && Cudd_IsConstant(g)) {
810  if (ddEqualVal(cuddV(f),cuddV(g),tolerance)) {
811  return(1);
812  } else {
813  if (pr>0) {
814  (void) fprintf(dd->out,"Offending nodes:\n");
815  (void) fprintf(dd->out,
816  "f: address = %p\t value = %40.30f\n",
817  (void *) f, cuddV(f));
818  (void) fprintf(dd->out,
819  "g: address = %p\t value = %40.30f\n",
820  (void *) g, cuddV(g));
821  }
822  return(0);
823  }
824  }
825 
826  /* We only insert the result in the cache if the comparison is
827  ** successful. Therefore, if we hit we return 1. */
829  if (r != NULL) {
830  return(1);
831  }
832 
833  /* Compute the cofactors and solve the recursive subproblems. */
834  topf = cuddI(dd,f->index);
835  topg = cuddI(dd,g->index);
836 
837  if (topf <= topg) {fv = cuddT(f); fvn = cuddE(f);} else {fv = fvn = f;}
838  if (topg <= topf) {gv = cuddT(g); gvn = cuddE(g);} else {gv = gvn = g;}
839 
840  if (!Cudd_EqualSupNorm(dd,fv,gv,tolerance,pr)) return(0);
841  if (!Cudd_EqualSupNorm(dd,fvn,gvn,tolerance,pr)) return(0);
842 
844 
845  return(1);
846 
847 } /* end of Cudd_EqualSupNorm */
Definition: cudd.h:278
void cuddCacheInsert2(DdManager *table, DD_CTFP op, DdNode *f, DdNode *g, DdNode *data)
Definition: cuddCache.c:277
#define Cudd_IsConstant(node)
Definition: cudd.h:352
int Cudd_EqualSupNorm(DdManager *dd, DdNode *f, DdNode *g, CUDD_VALUE_TYPE tolerance, int pr)
Definition: cuddSat.c:796
DdNode *(* DD_CTFP)(DdManager *, DdNode *, DdNode *)
Definition: cudd.h:321
#define statLine(dd)
Definition: cuddInt.h:1037
#define cuddV(node)
Definition: cuddInt.h:668
DdNode * cuddCacheLookup2(DdManager *table, DD_CTFP op, DdNode *f, DdNode *g)
Definition: cuddCache.c:502
FILE * out
Definition: cuddInt.h:441
#define cuddT(node)
Definition: cuddInt.h:636
#define ddEqualVal(x, y, e)
Definition: cuddInt.h:861
#define cuddI(dd, index)
Definition: cuddInt.h:686
DdHalfWord index
Definition: cudd.h:279
#define cuddE(node)
Definition: cuddInt.h:652
#define DD_ONE(dd)
Definition: cuddInt.h:911
int Cudd_EquivDC ( DdManager dd,
DdNode F,
DdNode G,
DdNode D 
)

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

Synopsis [Tells whether F and G are identical wherever D is 0.]

Description [Tells whether F and G are identical wherever D is 0. F and G are either two ADDs or two BDDs. D is either a 0-1 ADD or a BDD. The function returns 1 if F and G are equivalent, and 0 otherwise. No new nodes are created.]

SideEffects [None]

SeeAlso [Cudd_bddLeqUnless]

Definition at line 522 of file cuddSat.c.

527 {
528  DdNode *tmp, *One, *Gr, *Dr;
529  DdNode *Fv, *Fvn, *Gv, *Gvn, *Dv, *Dvn;
530  int res;
531  unsigned int flevel, glevel, dlevel, top;
532 
533  One = DD_ONE(dd);
534 
535  statLine(dd);
536  /* Check terminal cases. */
537  if (D == One || F == G) return(1);
538  if (D == Cudd_Not(One) || D == DD_ZERO(dd) || F == Cudd_Not(G)) return(0);
539 
540  /* From now on, D is non-constant. */
541 
542  /* Normalize call to increase cache efficiency. */
543  if (F > G) {
544  tmp = F;
545  F = G;
546  G = tmp;
547  }
548  if (Cudd_IsComplement(F)) {
549  F = Cudd_Not(F);
550  G = Cudd_Not(G);
551  }
552 
553  /* From now on, F is regular. */
554 
555  /* Check cache. */
556  tmp = cuddCacheLookup(dd,DD_EQUIV_DC_TAG,F,G,D);
557  if (tmp != NULL) return(tmp == One);
558 
559  /* Find splitting variable. */
560  flevel = cuddI(dd,F->index);
561  Gr = Cudd_Regular(G);
562  glevel = cuddI(dd,Gr->index);
563  top = ddMin(flevel,glevel);
564  Dr = Cudd_Regular(D);
565  dlevel = dd->perm[Dr->index];
566  top = ddMin(top,dlevel);
567 
568  /* Compute cofactors. */
569  if (top == flevel) {
570  Fv = cuddT(F);
571  Fvn = cuddE(F);
572  } else {
573  Fv = Fvn = F;
574  }
575  if (top == glevel) {
576  Gv = cuddT(Gr);
577  Gvn = cuddE(Gr);
578  if (G != Gr) {
579  Gv = Cudd_Not(Gv);
580  Gvn = Cudd_Not(Gvn);
581  }
582  } else {
583  Gv = Gvn = G;
584  }
585  if (top == dlevel) {
586  Dv = cuddT(Dr);
587  Dvn = cuddE(Dr);
588  if (D != Dr) {
589  Dv = Cudd_Not(Dv);
590  Dvn = Cudd_Not(Dvn);
591  }
592  } else {
593  Dv = Dvn = D;
594  }
595 
596  /* Solve recursively. */
597  res = Cudd_EquivDC(dd,Fv,Gv,Dv);
598  if (res != 0) {
599  res = Cudd_EquivDC(dd,Fvn,Gvn,Dvn);
600  }
601  cuddCacheInsert(dd,DD_EQUIV_DC_TAG,F,G,D,(res) ? One : Cudd_Not(One));
602 
603  return(res);
604 
605 } /* end of Cudd_EquivDC */
Definition: cudd.h:278
#define Cudd_Not(node)
Definition: cudd.h:367
int Cudd_EquivDC(DdManager *dd, DdNode *F, DdNode *G, DdNode *D)
Definition: cuddSat.c:522
#define Cudd_Regular(node)
Definition: cudd.h:397
void cuddCacheInsert(DdManager *table, ptruint op, DdNode *f, DdNode *g, DdNode *h, DdNode *data)
Definition: cuddCache.c:222
#define statLine(dd)
Definition: cuddInt.h:1037
#define Cudd_IsComplement(node)
Definition: cudd.h:425
#define ddMin(x, y)
Definition: cuddInt.h:818
#define cuddT(node)
Definition: cuddInt.h:636
#define cuddI(dd, index)
Definition: cuddInt.h:686
#define DD_EQUIV_DC_TAG
Definition: cuddInt.h:182
DdHalfWord index
Definition: cudd.h:279
#define cuddE(node)
Definition: cuddInt.h:652
#define DD_ONE(dd)
Definition: cuddInt.h:911
int * perm
Definition: cuddInt.h:386
DdNode * cuddCacheLookup(DdManager *table, ptruint op, DdNode *f, DdNode *g, DdNode *h)
Definition: cuddCache.c:369
#define DD_ZERO(dd)
Definition: cuddInt.h:927
int Cudd_EstimateCofactor ( DdManager dd,
DdNode f,
int  i,
int  phase 
)

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

Synopsis [Estimates the number of nodes in a cofactor of a DD.]

Description [Estimates the number of nodes in a cofactor of a DD. Returns an estimate of the number of nodes in a cofactor of the graph rooted at node with respect to the variable whose index is i. In case of failure, returns CUDD_OUT_OF_MEM. This function uses a refinement of the algorithm of Cabodi et al. (ICCAD96). The refinement allows the procedure to account for part of the recombination that may occur in the part of the cofactor above the cofactoring variable. This procedure does no create any new node. It does keep a small table of results; therefore it may run out of memory. If this is a concern, one should use Cudd_EstimateCofactorSimple, which is faster, does not allocate any memory, but is less accurate.]

SideEffects [None]

SeeAlso [Cudd_DagSize Cudd_EstimateCofactorSimple]

Definition at line 477 of file cuddUtil.c.

483 {
484  int val;
485  DdNode *ptr;
486  st__table *table;
487 
489  if (table == NULL) return(CUDD_OUT_OF_MEM);
490  val = cuddEstimateCofactor(dd,table,Cudd_Regular(f),i,phase,&ptr);
492  st__free_table(table);
493 
494  return(val);
495 
496 } /* end of Cudd_EstimateCofactor */
void st__free_table(st__table *table)
Definition: st.c:81
#define CUDD_OUT_OF_MEM
Definition: cudd.h:95
static int cuddEstimateCofactor(DdManager *dd, st__table *table, DdNode *node, int i, int phase, DdNode **ptr)
Definition: cuddUtil.c:3240
Definition: cudd.h:278
#define Cudd_Regular(node)
Definition: cudd.h:397
int st__ptrcmp(const char *, const char *)
Definition: st.c:480
st__table * st__init_table(st__compare_func_type compare, st__hash_func_type hash)
Definition: st.c:72
Definition: st.h:52
static pcube phase
Definition: cvrm.c:405
static void ddClearFlag(DdNode *f)
Definition: cuddUtil.c:3735
int st__ptrhash(const char *, int)
Definition: st.c:468
int Cudd_EstimateCofactorSimple ( DdNode node,
int  i 
)

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

Synopsis [Estimates the number of nodes in a cofactor of a DD.]

Description [Estimates the number of nodes in a cofactor of a DD. Returns an estimate of the number of nodes in the positive cofactor of the graph rooted at node with respect to the variable whose index is i. This procedure implements with minor changes the algorithm of Cabodi et al. (ICCAD96). It does not allocate any memory, it does not change the state of the manager, and it is fast. However, it has been observed to overestimate the size of the cofactor by as much as a factor of 2.]

SideEffects [None]

SeeAlso [Cudd_DagSize]

Definition at line 517 of file cuddUtil.c.

520 {
521  int val;
522 
524  ddClearFlag(Cudd_Regular(node));
525 
526  return(val);
527 
528 } /* end of Cudd_EstimateCofactorSimple */
static int cuddEstimateCofactorSimple(DdNode *node, int i)
Definition: cuddUtil.c:3399
#define Cudd_Regular(node)
Definition: cudd.h:397
static void ddClearFlag(DdNode *f)
Definition: cuddUtil.c:3735
DdNode* Cudd_Eval ( DdManager dd,
DdNode f,
int *  inputs 
)

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

Synopsis [Returns the value of a DD for a given variable assignment.]

Description [Finds the value of a DD for a given variable assignment. The variable assignment is passed in an array of int's, that should specify a zero or a one for each variable in the support of the function. Returns a pointer to a constant node. No new nodes are produced.]

SideEffects [None]

SeeAlso [Cudd_bddLeq Cudd_addEvalConst]

Definition at line 157 of file cuddSat.c.

161 {
162  int comple;
163  DdNode *ptr;
164 
165  comple = Cudd_IsComplement(f);
166  ptr = Cudd_Regular(f);
167 
168  while (!cuddIsConstant(ptr)) {
169  if (inputs[ptr->index] == 1) {
170  ptr = cuddT(ptr);
171  } else {
172  comple ^= Cudd_IsComplement(cuddE(ptr));
173  ptr = Cudd_Regular(cuddE(ptr));
174  }
175  }
176  return(Cudd_NotCond(ptr,comple));
177 
178 } /* end of Cudd_Eval */
Definition: cudd.h:278
#define Cudd_Regular(node)
Definition: cudd.h:397
#define Cudd_IsComplement(node)
Definition: cudd.h:425
#define cuddIsConstant(node)
Definition: cuddInt.h:620
#define cuddT(node)
Definition: cuddInt.h:636
DdHalfWord index
Definition: cudd.h:279
#define cuddE(node)
Definition: cuddInt.h:652
#define Cudd_NotCond(node, c)
Definition: cudd.h:383
double Cudd_ExpectedUsedSlots ( DdManager dd)

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

Synopsis [Computes the expected fraction of used slots in the unique table.]

Description [Computes the fraction of slots in the unique table that should be in use. This expected value is based on the assumption that the hash function distributes the keys randomly; it can be compared with the result of Cudd_ReadUsedSlots to monitor the performance of the unique table hash function.]

SideEffects [None]

SeeAlso [Cudd_ReadSlots Cudd_ReadUsedSlots]

Definition at line 1572 of file cuddAPI.c.

1574 {
1575  int i;
1576  int size = dd->size;
1577  DdSubtable *subtable;
1578  double empty = 0.0;
1579 
1580  /* To each subtable we apply the corollary to Theorem 8.5 (occupancy
1581  ** distribution) from Sedgewick and Flajolet's Analysis of Algorithms.
1582  ** The corollary says that for a table with M buckets and a load ratio
1583  ** of r, the expected number of empty buckets is asymptotically given
1584  ** by M * exp(-r).
1585  */
1586 
1587  /* Scan each BDD/ADD subtable. */
1588  for (i = 0; i < size; i++) {
1589  subtable = &(dd->subtables[i]);
1590  empty += (double) subtable->slots *
1591  exp(-(double) subtable->keys / (double) subtable->slots);
1592  }
1593 
1594  /* Scan the ZDD subtables. */
1595  size = dd->sizeZ;
1596 
1597  for (i = 0; i < size; i++) {
1598  subtable = &(dd->subtableZ[i]);
1599  empty += (double) subtable->slots *
1600  exp(-(double) subtable->keys / (double) subtable->slots);
1601  }
1602 
1603  /* Constant table. */
1604  subtable = &(dd->constants);
1605  empty += (double) subtable->slots *
1606  exp(-(double) subtable->keys / (double) subtable->slots);
1607 
1608  return(1.0 - empty / (double) dd->slots);
1609 
1610 } /* end of Cudd_ExpectedUsedSlots */
unsigned int keys
Definition: cuddInt.h:330
int size
Definition: cuddInt.h:361
unsigned int slots
Definition: cuddInt.h:368
DdSubtable * subtables
Definition: cuddInt.h:365
static int size
Definition: cuddSign.c:86
int sizeZ
Definition: cuddInt.h:362
unsigned int slots
Definition: cuddInt.h:329
DdSubtable constants
Definition: cuddInt.h:367
static DdNode * empty
Definition: cuddZddLin.c:98
DdSubtable * subtableZ
Definition: cuddInt.h:366
DdNode* Cudd_FindEssential ( DdManager dd,
DdNode f 
)

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

Synopsis [Finds the essential variables of a DD.]

Description [Returns the cube of the essential variables. A positive literal means that the variable must be set to 1 for the function to be

  1. A negative literal means that the variable must be set to 0 for the function to be 1. Returns a pointer to the cube BDD if successful; NULL otherwise.]

SideEffects [None]

SeeAlso [Cudd_bddIsVarEssential]

Definition at line 209 of file cuddEssent.c.

212 {
213  DdNode *res;
214 
215  do {
216  dd->reordered = 0;
217  res = ddFindEssentialRecur(dd,f);
218  } while (dd->reordered == 1);
219  return(res);
220 
221 } /* end of Cudd_FindEssential */
Definition: cudd.h:278
int reordered
Definition: cuddInt.h:409
static DdNode * ddFindEssentialRecur(DdManager *dd, DdNode *f)
Definition: cuddEssent.c:486
DdTlcInfo* Cudd_FindTwoLiteralClauses ( DdManager dd,
DdNode f 
)

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

Synopsis [Finds the two literal clauses of a DD.]

Description [Returns the one- and two-literal clauses of a DD. Returns a pointer to the structure holding the clauses if successful; NULL otherwise. For a constant DD, the empty set of clauses is returned. This is obviously correct for a non-zero constant. For the constant zero, it is based on the assumption that only those clauses containing variables in the support of the function are considered. Since the support of a constant function is empty, no clauses are returned.]

SideEffects [None]

SeeAlso [Cudd_FindEssential]

Definition at line 277 of file cuddEssent.c.

280 {
281  DdTlcInfo *res;
282  st__table *table;
283  st__generator *gen;
284  DdTlcInfo *tlc;
285  DdNode *node;
286  int size = dd->size;
287 
288  if (Cudd_IsConstant(f)) {
289  res = emptyClauseSet();
290  return(res);
291  }
293  if (table == NULL) return(NULL);
294  Tolv = bitVectorAlloc(size);
295  if (Tolv == NULL) {
296  st__free_table(table);
297  return(NULL);
298  }
299  Tolp = bitVectorAlloc(size);
300  if (Tolp == NULL) {
301  st__free_table(table);
303  return(NULL);
304  }
305  Eolv = bitVectorAlloc(size);
306  if (Eolv == NULL) {
307  st__free_table(table);
310  return(NULL);
311  }
312  Eolp = bitVectorAlloc(size);
313  if (Eolp == NULL) {
314  st__free_table(table);
318  return(NULL);
319  }
320 
321  res = ddFindTwoLiteralClausesRecur(dd,f,table);
322  /* Dispose of table contents and free table. */
323  st__foreach_item(table, gen, (const char **)&node, (char **)&tlc) {
324  if (node != f) {
325  Cudd_tlcInfoFree(tlc);
326  }
327  }
328  st__free_table(table);
333 
334  if (res != NULL) {
335  int i;
336  for (i = 0; !sentinelp(res->vars[i], res->vars[i+1]); i += 2);
337  res->cnt = i >> 1;
338  }
339 
340  return(res);
341 
342 } /* end of Cudd_FindTwoLiteralClauses */
void st__free_table(st__table *table)
Definition: st.c:81
Definition: cudd.h:278
int size
Definition: cuddInt.h:361
#define Cudd_IsConstant(node)
Definition: cudd.h:352
int st__ptrcmp(const char *, const char *)
Definition: st.c:480
DdHalfWord * vars
Definition: cuddEssent.c:123
st__table * st__init_table(st__compare_func_type compare, st__hash_func_type hash)
Definition: st.c:72
static BitVector * Eolv
Definition: cuddEssent.c:155
static BitVector * Tolp
Definition: cuddEssent.c:154
Definition: st.h:52
static DdTlcInfo * emptyClauseSet(void)
Definition: cuddEssent.c:1140
static BitVector * Tolv
Definition: cuddEssent.c:153
static int size
Definition: cuddSign.c:86
static DdTlcInfo * ddFindTwoLiteralClausesRecur(DdManager *dd, DdNode *f, st__table *table)
Definition: cuddEssent.c:620
void Cudd_tlcInfoFree(DdTlcInfo *t)
Definition: cuddEssent.c:455
static void bitVectorFree(BitVector *vector)
Definition: cuddEssent.c:1383
DdHalfWord cnt
Definition: cuddEssent.c:125
static int sentinelp(DdHalfWord var1, DdHalfWord var2)
Definition: cuddEssent.c:1174
#define st__foreach_item(table, gen, key, value)
Definition: st.h:107
static BitVector * Eolp
Definition: cuddEssent.c:156
static BitVector * bitVectorAlloc(int size)
Definition: cuddEssent.c:1319
int st__ptrhash(const char *, int)
Definition: st.c:468
DdGen* Cudd_FirstCube ( DdManager dd,
DdNode f,
int **  cube,
CUDD_VALUE_TYPE value 
)

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

Synopsis [Finds the first cube of a decision diagram.]

Description [Defines an iterator on the onset of a decision diagram and finds its first cube. Returns a generator that contains the information necessary to continue the enumeration if successful; NULL otherwise.

A cube is represented as an array of literals, which are integers in {0, 1, 2}; 0 represents a complemented literal, 1 represents an uncomplemented literal, and 2 stands for don't care. The enumeration produces a disjoint cover of the function associated with the diagram. The size of the array equals the number of variables in the manager at the time Cudd_FirstCube is called.

For each cube, a value is also returned. This value is always 1 for a BDD, while it may be different from 1 for an ADD. For BDDs, the offset is the set of cubes whose value is the logical zero. For ADDs, the offset is the set of cubes whose value is the background value. The cubes of the offset are not enumerated.]

SideEffects [The first cube and its value are returned as side effects.]

SeeAlso [Cudd_ForeachCube Cudd_NextCube Cudd_GenFree Cudd_IsGenEmpty Cudd_FirstNode]

Definition at line 1798 of file cuddUtil.c.

1803 {
1804  DdGen *gen;
1805  DdNode *top, *treg, *next, *nreg, *prev, *preg;
1806  int i;
1807  int nvars;
1808 
1809  /* Sanity Check. */
1810  if (dd == NULL || f == NULL) return(NULL);
1811 
1812  /* Allocate generator an initialize it. */
1813  gen = ABC_ALLOC(DdGen,1);
1814  if (gen == NULL) {
1815  dd->errorCode = CUDD_MEMORY_OUT;
1816  return(NULL);
1817  }
1818 
1819  gen->manager = dd;
1820  gen->type = CUDD_GEN_CUBES;
1821  gen->status = CUDD_GEN_EMPTY;
1822  gen->gen.cubes.cube = NULL;
1823  gen->gen.cubes.value = DD_ZERO_VAL;
1824  gen->stack.sp = 0;
1825  gen->stack.stack = NULL;
1826  gen->node = NULL;
1827 
1828  nvars = dd->size;
1829  gen->gen.cubes.cube = ABC_ALLOC(int,nvars);
1830  if (gen->gen.cubes.cube == NULL) {
1831  dd->errorCode = CUDD_MEMORY_OUT;
1832  ABC_FREE(gen);
1833  return(NULL);
1834  }
1835  for (i = 0; i < nvars; i++) gen->gen.cubes.cube[i] = 2;
1836 
1837  /* The maximum stack depth is one plus the number of variables.
1838  ** because a path may have nodes at all levels, including the
1839  ** constant level.
1840  */
1841  gen->stack.stack = ABC_ALLOC(DdNodePtr, nvars+1);
1842  if (gen->stack.stack == NULL) {
1843  dd->errorCode = CUDD_MEMORY_OUT;
1844  ABC_FREE(gen->gen.cubes.cube);
1845  ABC_FREE(gen);
1846  return(NULL);
1847  }
1848  for (i = 0; i <= nvars; i++) gen->stack.stack[i] = NULL;
1849 
1850  /* Find the first cube of the onset. */
1851  gen->stack.stack[gen->stack.sp] = f; gen->stack.sp++;
1852 
1853  while (1) {
1854  top = gen->stack.stack[gen->stack.sp-1];
1855  treg = Cudd_Regular(top);
1856  if (!cuddIsConstant(treg)) {
1857  /* Take the else branch first. */
1858  gen->gen.cubes.cube[treg->index] = 0;
1859  next = cuddE(treg);
1860  if (top != treg) next = Cudd_Not(next);
1861  gen->stack.stack[gen->stack.sp] = next; gen->stack.sp++;
1862  } else if (top == Cudd_Not(DD_ONE(dd)) || top == dd->background) {
1863  /* Backtrack */
1864  while (1) {
1865  if (gen->stack.sp == 1) {
1866  /* The current node has no predecessor. */
1867  gen->status = CUDD_GEN_EMPTY;
1868  gen->stack.sp--;
1869  goto done;
1870  }
1871  prev = gen->stack.stack[gen->stack.sp-2];
1872  preg = Cudd_Regular(prev);
1873  nreg = cuddT(preg);
1874  if (prev != preg) {next = Cudd_Not(nreg);} else {next = nreg;}
1875  if (next != top) { /* follow the then branch next */
1876  gen->gen.cubes.cube[preg->index] = 1;
1877  gen->stack.stack[gen->stack.sp-1] = next;
1878  break;
1879  }
1880  /* Pop the stack and try again. */
1881  gen->gen.cubes.cube[preg->index] = 2;
1882  gen->stack.sp--;
1883  top = gen->stack.stack[gen->stack.sp-1];
1884  treg = Cudd_Regular(top);
1885  }
1886  } else {
1887  gen->status = CUDD_GEN_NONEMPTY;
1888  gen->gen.cubes.value = cuddV(top);
1889  goto done;
1890  }
1891  }
1892 
1893 done:
1894  *cube = gen->gen.cubes.cube;
1895  *value = gen->gen.cubes.value;
1896  return(gen);
1897 
1898 } /* end of Cudd_FirstCube */
DdNode * node
Definition: cuddInt.h:232
int type
Definition: cuddInt.h:206
Definition: cudd.h:278
#define Cudd_Not(node)
Definition: cudd.h:367
struct DdGen::@30::@32 cubes
int size
Definition: cuddInt.h:361
#define Cudd_Regular(node)
Definition: cudd.h:397
#define ABC_ALLOC(type, num)
Definition: abc_global.h:229
Definition: cuddInt.h:204
#define DD_ZERO_VAL
Definition: cuddInt.h:108
#define CUDD_GEN_NONEMPTY
Definition: cuddInt.h:197
#define cuddV(node)
Definition: cuddInt.h:668
DdNode ** stack
Definition: cuddInt.h:227
DdManager * manager
Definition: cuddInt.h:205
#define cuddIsConstant(node)
Definition: cuddInt.h:620
#define cuddT(node)
Definition: cuddInt.h:636
union DdGen::@30 gen
#define CUDD_GEN_EMPTY
Definition: cuddInt.h:196
DdHalfWord index
Definition: cudd.h:279
#define ABC_FREE(obj)
Definition: abc_global.h:232
#define CUDD_GEN_CUBES
Definition: cuddInt.h:192
#define cuddE(node)
Definition: cuddInt.h:652
int value
#define DD_ONE(dd)
Definition: cuddInt.h:911
Cudd_ErrorType errorCode
Definition: cuddInt.h:447
DdNode * background
Definition: cuddInt.h:349
int status
Definition: cuddInt.h:207
DdGen* Cudd_FirstNode ( DdManager dd,
DdNode f,
DdNode **  node 
)

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

Synopsis [Finds the first node of a decision diagram.]

Description [Defines an iterator on the nodes of a decision diagram and finds its first node. Returns a generator that contains the information necessary to continue the enumeration if successful; NULL otherwise. The nodes are enumerated in a reverse topological order, so that a node is always preceded in the enumeration by its descendants.]

SideEffects [The first node is returned as a side effect.]

SeeAlso [Cudd_ForeachNode Cudd_NextNode Cudd_GenFree Cudd_IsGenEmpty Cudd_FirstCube]

Definition at line 2400 of file cuddUtil.c.

2404 {
2405  DdGen *gen;
2406  int size;
2407 
2408  /* Sanity Check. */
2409  if (dd == NULL || f == NULL) return(NULL);
2410 
2411  /* Allocate generator an initialize it. */
2412  gen = ABC_ALLOC(DdGen,1);
2413  if (gen == NULL) {
2414  dd->errorCode = CUDD_MEMORY_OUT;
2415  return(NULL);
2416  }
2417 
2418  gen->manager = dd;
2419  gen->type = CUDD_GEN_NODES;
2420  gen->status = CUDD_GEN_EMPTY;
2421  gen->stack.sp = 0;
2422  gen->node = NULL;
2423 
2424  /* Collect all the nodes on the generator stack for later perusal. */
2425  gen->stack.stack = cuddNodeArray(Cudd_Regular(f), &size);
2426  if (gen->stack.stack == NULL) {
2427  ABC_FREE(gen);
2428  dd->errorCode = CUDD_MEMORY_OUT;
2429  return(NULL);
2430  }
2431  gen->gen.nodes.size = size;
2432 
2433  /* Find the first node. */
2434  if (gen->stack.sp < gen->gen.nodes.size) {
2435  gen->status = CUDD_GEN_NONEMPTY;
2436  gen->node = gen->stack.stack[gen->stack.sp];
2437  *node = gen->node;
2438  }
2439 
2440  return(gen);
2441 
2442 } /* end of Cudd_FirstNode */
DdNode * node
Definition: cuddInt.h:232
int type
Definition: cuddInt.h:206
#define CUDD_GEN_NODES
Definition: cuddInt.h:194
#define Cudd_Regular(node)
Definition: cudd.h:397
#define ABC_ALLOC(type, num)
Definition: abc_global.h:229
Definition: cuddInt.h:204
#define CUDD_GEN_NONEMPTY
Definition: cuddInt.h:197
DdNode ** stack
Definition: cuddInt.h:227
DdManager * manager
Definition: cuddInt.h:205
static int size
Definition: cuddSign.c:86
DdNodePtr * cuddNodeArray(DdNode *f, int *n)
Definition: cuddUtil.c:2979
union DdGen::@30 gen
#define CUDD_GEN_EMPTY
Definition: cuddInt.h:196
#define ABC_FREE(obj)
Definition: abc_global.h:232
struct DdGen::@30::@34 nodes
Cudd_ErrorType errorCode
Definition: cuddInt.h:447
int status
Definition: cuddInt.h:207
DdGen* Cudd_FirstPrime ( DdManager dd,
DdNode l,
DdNode u,
int **  cube 
)

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

Synopsis [Finds the first prime of a Boolean function.]

Description [Defines an iterator on a pair of BDDs describing a (possibly incompletely specified) Boolean functions and finds the first cube of a cover of the function. Returns a generator that contains the information necessary to continue the enumeration if successful; NULL otherwise.

The two argument BDDs are the lower and upper bounds of an interval. It is a mistake to call this function with a lower bound that is not less than or equal to the upper bound.

A cube is represented as an array of literals, which are integers in {0, 1, 2}; 0 represents a complemented literal, 1 represents an uncomplemented literal, and 2 stands for don't care. The enumeration produces a prime and irredundant cover of the function associated with the two BDDs. The size of the array equals the number of variables in the manager at the time Cudd_FirstCube is called.

This iterator can only be used on BDDs.]

SideEffects [The first cube is returned as side effect.]

SeeAlso [Cudd_ForeachPrime Cudd_NextPrime Cudd_GenFree Cudd_IsGenEmpty Cudd_FirstCube Cudd_FirstNode]

Definition at line 2028 of file cuddUtil.c.

2033 {
2034  DdGen *gen;
2035  DdNode *implicant, *prime, *tmp;
2036  int length, result;
2037 
2038  /* Sanity Check. */
2039  if (dd == NULL || l == NULL || u == NULL) return(NULL);
2040 
2041  /* Allocate generator an initialize it. */
2042  gen = ABC_ALLOC(DdGen,1);
2043  if (gen == NULL) {
2044  dd->errorCode = CUDD_MEMORY_OUT;
2045  return(NULL);
2046  }
2047 
2048  gen->manager = dd;
2049  gen->type = CUDD_GEN_PRIMES;
2050  gen->status = CUDD_GEN_EMPTY;
2051  gen->gen.primes.cube = NULL;
2052  gen->gen.primes.ub = u;
2053  gen->stack.sp = 0;
2054  gen->stack.stack = NULL;
2055  gen->node = l;
2056  cuddRef(l);
2057 
2058  gen->gen.primes.cube = ABC_ALLOC(int,dd->size);
2059  if (gen->gen.primes.cube == NULL) {
2060  dd->errorCode = CUDD_MEMORY_OUT;
2061  ABC_FREE(gen);
2062  return(NULL);
2063  }
2064 
2065  if (gen->node == Cudd_ReadLogicZero(dd)) {
2066  gen->status = CUDD_GEN_EMPTY;
2067  } else {
2068  implicant = Cudd_LargestCube(dd,gen->node,&length);
2069  if (implicant == NULL) {
2070  Cudd_RecursiveDeref(dd,gen->node);
2071  ABC_FREE(gen->gen.primes.cube);
2072  ABC_FREE(gen);
2073  return(NULL);
2074  }
2075  cuddRef(implicant);
2076  prime = Cudd_bddMakePrime(dd,implicant,gen->gen.primes.ub);
2077  if (prime == NULL) {
2078  Cudd_RecursiveDeref(dd,gen->node);
2079  Cudd_RecursiveDeref(dd,implicant);
2080  ABC_FREE(gen->gen.primes.cube);
2081  ABC_FREE(gen);
2082  return(NULL);
2083  }
2084  cuddRef(prime);
2085  Cudd_RecursiveDeref(dd,implicant);
2086  tmp = Cudd_bddAnd(dd,gen->node,Cudd_Not(prime));
2087  if (tmp == NULL) {
2088  Cudd_RecursiveDeref(dd,gen->node);
2089  Cudd_RecursiveDeref(dd,prime);
2090  ABC_FREE(gen->gen.primes.cube);
2091  ABC_FREE(gen);
2092  return(NULL);
2093  }
2094  cuddRef(tmp);
2095  Cudd_RecursiveDeref(dd,gen->node);
2096  gen->node = tmp;
2097  result = Cudd_BddToCubeArray(dd,prime,gen->gen.primes.cube);
2098  if (result == 0) {
2099  Cudd_RecursiveDeref(dd,gen->node);
2100  Cudd_RecursiveDeref(dd,prime);
2101  ABC_FREE(gen->gen.primes.cube);
2102  ABC_FREE(gen);
2103  return(NULL);
2104  }
2105  Cudd_RecursiveDeref(dd,prime);
2106  gen->status = CUDD_GEN_NONEMPTY;
2107  }
2108  *cube = gen->gen.primes.cube;
2109  return(gen);
2110 
2111 } /* end of Cudd_FirstPrime */
#define cuddRef(n)
Definition: cuddInt.h:584
DdNode * node
Definition: cuddInt.h:232
int type
Definition: cuddInt.h:206
void Cudd_RecursiveDeref(DdManager *table, DdNode *n)
Definition: cuddRef.c:154
Definition: cudd.h:278
#define Cudd_Not(node)
Definition: cudd.h:367
int size
Definition: cuddInt.h:361
DdNode * Cudd_ReadLogicZero(DdManager *dd)
Definition: cuddAPI.c:1058
#define ABC_ALLOC(type, num)
Definition: abc_global.h:229
Definition: cuddInt.h:204
#define CUDD_GEN_NONEMPTY
Definition: cuddInt.h:197
DdNode * Cudd_LargestCube(DdManager *manager, DdNode *f, int *length)
Definition: cuddSat.c:285
DdNode * Cudd_bddMakePrime(DdManager *dd, DdNode *cube, DdNode *f)
Definition: cuddSat.c:864
int Cudd_BddToCubeArray(DdManager *dd, DdNode *cube, int *array)
Definition: cuddUtil.c:2346
DdNode ** stack
Definition: cuddInt.h:227
DdManager * manager
Definition: cuddInt.h:205
union DdGen::@30 gen
#define CUDD_GEN_EMPTY
Definition: cuddInt.h:196
struct DdGen::@30::@33 primes
#define ABC_FREE(obj)
Definition: abc_global.h:232
DdNode * Cudd_bddAnd(DdManager *dd, DdNode *f, DdNode *g)
Definition: cuddBddIte.c:314
static int result
Definition: cuddGenetic.c:125
#define CUDD_GEN_PRIMES
Definition: cuddInt.h:193
Cudd_ErrorType errorCode
Definition: cuddInt.h:447
int status
Definition: cuddInt.h:207
void Cudd_FreeTree ( DdManager dd)

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

Synopsis [Frees the variable group tree of the manager.]

Description []

SideEffects [None]

SeeAlso [Cudd_SetTree Cudd_ReadTree Cudd_FreeZddTree]

Definition at line 2180 of file cuddAPI.c.

2182 {
2183  if (dd->tree != NULL) {
2184  Mtr_FreeTree(dd->tree);
2185  dd->tree = NULL;
2186  }
2187  return;
2188 
2189 } /* end of Cudd_FreeTree */
void Mtr_FreeTree(MtrNode *node)
Definition: mtrBasic.c:188
MtrNode * tree
Definition: cuddInt.h:424
void Cudd_FreeZddTree ( DdManager dd)

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

Synopsis [Frees the variable group tree of the manager.]

Description []

SideEffects [None]

SeeAlso [Cudd_SetZddTree Cudd_ReadZddTree Cudd_FreeTree]

Definition at line 2252 of file cuddAPI.c.

2254 {
2255  if (dd->treeZ != NULL) {
2256  Mtr_FreeTree(dd->treeZ);
2257  dd->treeZ = NULL;
2258  }
2259  return;
2260 
2261 } /* end of Cudd_FreeZddTree */
void Mtr_FreeTree(MtrNode *node)
Definition: mtrBasic.c:188
MtrNode * treeZ
Definition: cuddInt.h:425
int Cudd_GarbageCollectionEnabled ( DdManager dd)

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

Synopsis [Tells whether garbage collection is enabled.]

Description [Returns 1 if garbage collection is enabled; 0 otherwise.]

SideEffects [None]

SeeAlso [Cudd_EnableGarbageCollection Cudd_DisableGarbageCollection]

Definition at line 2517 of file cuddAPI.c.

2519 {
2520  return(dd->gcEnabled);
2521 
2522 } /* end of Cudd_GarbageCollectionEnabled */
int gcEnabled
Definition: cuddInt.h:376
int Cudd_GenFree ( DdGen gen)

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

Synopsis [Frees a CUDD generator.]

Description [Frees a CUDD generator. Always returns 0, so that it can be used in mis-like foreach constructs.]

SideEffects [None]

SeeAlso [Cudd_ForeachCube Cudd_ForeachNode Cudd_FirstCube Cudd_NextCube Cudd_FirstNode Cudd_NextNode Cudd_IsGenEmpty]

Definition at line 2491 of file cuddUtil.c.

2493 {
2494  if (gen == NULL) return(0);
2495  switch (gen->type) {
2496  case CUDD_GEN_CUBES:
2497  case CUDD_GEN_ZDD_PATHS:
2498  ABC_FREE(gen->gen.cubes.cube);
2499  ABC_FREE(gen->stack.stack);
2500  break;
2501  case CUDD_GEN_PRIMES:
2502  ABC_FREE(gen->gen.primes.cube);
2503  Cudd_RecursiveDeref(gen->manager,gen->node);
2504  break;
2505  case CUDD_GEN_NODES:
2506  ABC_FREE(gen->stack.stack);
2507  break;
2508  default:
2509  return(0);
2510  }
2511  ABC_FREE(gen);
2512  return(0);
2513 
2514 } /* end of Cudd_GenFree */
DdNode * node
Definition: cuddInt.h:232
int type
Definition: cuddInt.h:206
void Cudd_RecursiveDeref(DdManager *table, DdNode *n)
Definition: cuddRef.c:154
#define CUDD_GEN_ZDD_PATHS
Definition: cuddInt.h:195
struct DdGen::@30::@32 cubes
#define CUDD_GEN_NODES
Definition: cuddInt.h:194
DdNode ** stack
Definition: cuddInt.h:227
DdManager * manager
Definition: cuddInt.h:205
union DdGen::@30 gen
struct DdGen::@30::@33 primes
#define ABC_FREE(obj)
Definition: abc_global.h:232
#define CUDD_GEN_CUBES
Definition: cuddInt.h:192
#define CUDD_GEN_PRIMES
Definition: cuddInt.h:193
DdNode* Cudd_Increasing ( DdManager dd,
DdNode f,
int  i 
)

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

Synopsis [Determines whether a BDD is positive unate in a variable.]

Description [Determines whether the function represented by BDD f is positive unate (monotonic increasing) in variable i. It is based on Cudd_Decreasing and the fact that f is monotonic increasing in i if and only if its complement is monotonic decreasing in i.]

SideEffects [None]

SeeAlso [Cudd_Decreasing]

Definition at line 497 of file cuddSat.c.

501 {
502  return(Cudd_Decreasing(dd,Cudd_Not(f),i));
503 
504 } /* end of Cudd_Increasing */
#define Cudd_Not(node)
Definition: cudd.h:367
DdNode * Cudd_Decreasing(DdManager *dd, DdNode *f, int i)
Definition: cuddSat.c:417
DdNode* Cudd_IndicesToCube ( DdManager dd,
int *  array,
int  n 
)

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

Synopsis [Builds a cube of BDD variables from an array of indices.]

Description [Builds a cube of BDD variables from an array of indices. Returns a pointer to the result if successful; NULL otherwise.]

SideEffects [None]

SeeAlso [Cudd_bddComputeCube Cudd_CubeArrayToBdd]

Definition at line 2553 of file cuddUtil.c.

2557 {
2558  DdNode *cube, *tmp;
2559  int i;
2560 
2561  cube = DD_ONE(dd);
2562  cuddRef(cube);
2563  for (i = n - 1; i >= 0; i--) {
2564  tmp = Cudd_bddAnd(dd,Cudd_bddIthVar(dd,array[i]),cube);
2565  if (tmp == NULL) {
2566  Cudd_RecursiveDeref(dd,cube);
2567  return(NULL);
2568  }
2569  cuddRef(tmp);
2570  Cudd_RecursiveDeref(dd,cube);
2571  cube = tmp;
2572  }
2573 
2574  cuddDeref(cube);
2575  return(cube);
2576 
2577 } /* end of Cudd_IndicesToCube */
#define cuddRef(n)
Definition: cuddInt.h:584
#define cuddDeref(n)
Definition: cuddInt.h:604
void Cudd_RecursiveDeref(DdManager *table, DdNode *n)
Definition: cuddRef.c:154
Definition: cudd.h:278
DdNode * Cudd_bddIthVar(DdManager *dd, int i)
Definition: cuddAPI.c:416
DdNode * Cudd_bddAnd(DdManager *dd, DdNode *f, DdNode *g)
Definition: cuddBddIte.c:314
#define DD_ONE(dd)
Definition: cuddInt.h:911
DdNode* Cudd_Inequality ( DdManager dd,
int  N,
int  c,
DdNode **  x,
DdNode **  y 
)

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

Synopsis [Generates a BDD for the function x - y ≥ c.]

Description [This function generates a BDD for the function x -y ≥ c. Both x and y are N-bit numbers, x[0] x[1] ... x[N-1] and y[0] y[1] ... y[N-1], with 0 the most significant bit. The BDD is built bottom-up. It has a linear number of nodes if the variables are ordered as follows: x[0] y[0] x[1] y[1] ... x[N-1] y[N-1].]

SideEffects [None]

SeeAlso [Cudd_Xgty]

Definition at line 744 of file cuddPriority.c.

750 {
751  /* The nodes at level i represent values of the difference that are
752  ** multiples of 2^i. We use variables with names starting with k
753  ** to denote the multipliers of 2^i in such multiples. */
754  int kTrue = c;
755  int kFalse = c - 1;
756  /* Mask used to compute the ceiling function. Since we divide by 2^i,
757  ** we want to know whether the dividend is a multiple of 2^i. If it is,
758  ** then ceiling and floor coincide; otherwise, they differ by one. */
759  int mask = 1;
760  int i;
761 
762  DdNode *f = NULL; /* the eventual result */
763  DdNode *one = DD_ONE(dd);
764  DdNode *zero = Cudd_Not(one);
765 
766  /* Two x-labeled nodes are created at most at each iteration. They are
767  ** stored, along with their k values, in these variables. At each level,
768  ** the old nodes are freed and the new nodes are copied into the old map.
769  */
770  DdNode *map[2] = {0};
771  int invalidIndex = 1 << (N-1);
772  int index[2] = {invalidIndex, invalidIndex};
773 
774  /* This should never happen. */
775  if (N < 0) return(NULL);
776 
777  /* If there are no bits, both operands are 0. The result depends on c. */
778  if (N == 0) {
779  if (c >= 0) return(one);
780  else return(zero);
781  }
782 
783  /* The maximum or the minimum difference comparing to c can generate the terminal case */
784  if ((1 << N) - 1 < c) return(zero);
785  else if ((-(1 << N) + 1) >= c) return(one);
786 
787  /* Build the result bottom up. */
788  for (i = 1; i <= N; i++) {
789  int kTrueLower, kFalseLower;
790  int leftChild, middleChild, rightChild;
791  DdNode *g0, *g1, *fplus, *fequal, *fminus;
792  int j;
793  DdNode *newMap[2] = {NULL};
794  int newIndex[2];
795 
796  kTrueLower = kTrue;
797  kFalseLower = kFalse;
798  /* kTrue = ceiling((c-1)/2^i) + 1 */
799  kTrue = ((c-1) >> i) + ((c & mask) != 1) + 1;
800  mask = (mask << 1) | 1;
801  /* kFalse = floor(c/2^i) - 1 */
802  kFalse = (c >> i) - 1;
803  newIndex[0] = invalidIndex;
804  newIndex[1] = invalidIndex;
805 
806  for (j = kFalse + 1; j < kTrue; j++) {
807  /* Skip if node is not reachable from top of BDD. */
808  if ((j >= (1 << (N - i))) || (j <= -(1 << (N -i)))) continue;
809 
810  /* Find f- */
811  leftChild = (j << 1) - 1;
812  if (leftChild >= kTrueLower) {
813  fminus = one;
814  } else if (leftChild <= kFalseLower) {
815  fminus = zero;
816  } else {
817  assert(leftChild == index[0] || leftChild == index[1]);
818  if (leftChild == index[0]) {
819  fminus = map[0];
820  } else {
821  fminus = map[1];
822  }
823  }
824 
825  /* Find f= */
826  middleChild = j << 1;
827  if (middleChild >= kTrueLower) {
828  fequal = one;
829  } else if (middleChild <= kFalseLower) {
830  fequal = zero;
831  } else {
832  assert(middleChild == index[0] || middleChild == index[1]);
833  if (middleChild == index[0]) {
834  fequal = map[0];
835  } else {
836  fequal = map[1];
837  }
838  }
839 
840  /* Find f+ */
841  rightChild = (j << 1) + 1;
842  if (rightChild >= kTrueLower) {
843  fplus = one;
844  } else if (rightChild <= kFalseLower) {
845  fplus = zero;
846  } else {
847  assert(rightChild == index[0] || rightChild == index[1]);
848  if (rightChild == index[0]) {
849  fplus = map[0];
850  } else {
851  fplus = map[1];
852  }
853  }
854 
855  /* Build new nodes. */
856  g1 = Cudd_bddIte(dd, y[N - i], fequal, fplus);
857  if (g1 == NULL) {
858  if (index[0] != invalidIndex) Cudd_IterDerefBdd(dd, map[0]);
859  if (index[1] != invalidIndex) Cudd_IterDerefBdd(dd, map[1]);
860  if (newIndex[0] != invalidIndex) Cudd_IterDerefBdd(dd, newMap[0]);
861  if (newIndex[1] != invalidIndex) Cudd_IterDerefBdd(dd, newMap[1]);
862  return(NULL);
863  }
864  cuddRef(g1);
865  g0 = Cudd_bddIte(dd, y[N - i], fminus, fequal);
866  if (g0 == NULL) {
867  Cudd_IterDerefBdd(dd, g1);
868  if (index[0] != invalidIndex) Cudd_IterDerefBdd(dd, map[0]);
869  if (index[1] != invalidIndex) Cudd_IterDerefBdd(dd, map[1]);
870  if (newIndex[0] != invalidIndex) Cudd_IterDerefBdd(dd, newMap[0]);
871  if (newIndex[1] != invalidIndex) Cudd_IterDerefBdd(dd, newMap[1]);
872  return(NULL);
873  }
874  cuddRef(g0);
875  f = Cudd_bddIte(dd, x[N - i], g1, g0);
876  if (f == NULL) {
877  Cudd_IterDerefBdd(dd, g1);
878  Cudd_IterDerefBdd(dd, g0);
879  if (index[0] != invalidIndex) Cudd_IterDerefBdd(dd, map[0]);
880  if (index[1] != invalidIndex) Cudd_IterDerefBdd(dd, map[1]);
881  if (newIndex[0] != invalidIndex) Cudd_IterDerefBdd(dd, newMap[0]);
882  if (newIndex[1] != invalidIndex) Cudd_IterDerefBdd(dd, newMap[1]);
883  return(NULL);
884  }
885  cuddRef(f);
886  Cudd_IterDerefBdd(dd, g1);
887  Cudd_IterDerefBdd(dd, g0);
888 
889  /* Save newly computed node in map. */
890  assert(newIndex[0] == invalidIndex || newIndex[1] == invalidIndex);
891  if (newIndex[0] == invalidIndex) {
892  newIndex[0] = j;
893  newMap[0] = f;
894  } else {
895  newIndex[1] = j;
896  newMap[1] = f;
897  }
898  }
899 
900  /* Copy new map to map. */
901  if (index[0] != invalidIndex) Cudd_IterDerefBdd(dd, map[0]);
902  if (index[1] != invalidIndex) Cudd_IterDerefBdd(dd, map[1]);
903  map[0] = newMap[0];
904  map[1] = newMap[1];
905  index[0] = newIndex[0];
906  index[1] = newIndex[1];
907  }
908 
909  cuddDeref(f);
910  return(f);
911 
912 } /* end of Cudd_Inequality */
void Cudd_IterDerefBdd(DdManager *table, DdNode *n)
Definition: cuddRef.c:217
#define cuddRef(n)
Definition: cuddInt.h:584
#define cuddDeref(n)
Definition: cuddInt.h:604
Definition: cudd.h:278
#define Cudd_Not(node)
Definition: cudd.h:367
void map()
DdNode * Cudd_bddIte(DdManager *dd, DdNode *f, DdNode *g, DdNode *h)
Definition: cuddBddIte.c:143
static DdNode * one
Definition: cuddDecomp.c:112
#define assert(ex)
Definition: util_old.h:213
#define DD_ONE(dd)
Definition: cuddInt.h:911
static DdNode * zero
Definition: cuddApa.c:100
DdManager* Cudd_Init ( unsigned int  numVars,
unsigned int  numVarsZ,
unsigned int  numSlots,
unsigned int  cacheSize,
unsigned long  maxMemory 
)

AutomaticStart AutomaticEnd Function********************************************************************

Synopsis [Creates a new DD manager.]

Description [Creates a new DD manager, initializes the table, the basic constants and the projection functions. If maxMemory is 0, Cudd_Init decides suitable values for the maximum size of the cache and for the limit for fast unique table growth based on the available memory. Returns a pointer to the manager if successful; NULL otherwise.]

SideEffects [None]

SeeAlso [Cudd_Quit]

Definition at line 125 of file cuddInit.c.

131 {
132  DdManager *unique;
133  int i,result;
134  DdNode *one, *zero;
135  unsigned int maxCacheSize;
136  unsigned int looseUpTo;
137  extern DD_OOMFP MMoutOfMemory;
138  DD_OOMFP saveHandler;
139 
140  if (maxMemory == 0) {
141  maxMemory = getSoftDataLimit();
142  }
143  looseUpTo = (unsigned int) ((maxMemory / sizeof(DdNode)) /
145  unique = cuddInitTable(numVars,numVarsZ,numSlots,looseUpTo);
146  if (unique == NULL) return(NULL);
147  unique->maxmem = (unsigned long) maxMemory / 10 * 9;
148  maxCacheSize = (unsigned int) ((maxMemory / sizeof(DdCache)) /
150  result = cuddInitCache(unique,cacheSize,maxCacheSize);
151  if (result == 0) return(NULL);
152 
153  saveHandler = MMoutOfMemory;
154  MMoutOfMemory = Cudd_OutOfMem;
155  unique->stash = ABC_ALLOC(char,(maxMemory / DD_STASH_FRACTION) + 4);
156  MMoutOfMemory = saveHandler;
157  if (unique->stash == NULL) {
158  (void) fprintf(unique->err,"Unable to set aside memory\n");
159  }
160 
161  /* Initialize constants. */
162  unique->one = cuddUniqueConst(unique,1.0);
163  if (unique->one == NULL) return(0);
164  cuddRef(unique->one);
165  unique->zero = cuddUniqueConst(unique,0.0);
166  if (unique->zero == NULL) return(0);
167  cuddRef(unique->zero);
168 #ifdef HAVE_IEEE_754
169  if (DD_PLUS_INF_VAL != DD_PLUS_INF_VAL * 3 ||
171  (void) fprintf(unique->err,"Warning: Crippled infinite values\n");
172  (void) fprintf(unique->err,"Recompile without -DHAVE_IEEE_754\n");
173  }
174 #endif
175  unique->plusinfinity = cuddUniqueConst(unique,DD_PLUS_INF_VAL);
176  if (unique->plusinfinity == NULL) return(0);
177  cuddRef(unique->plusinfinity);
179  if (unique->minusinfinity == NULL) return(0);
180  cuddRef(unique->minusinfinity);
181  unique->background = unique->zero;
182 
183  /* The logical zero is different from the CUDD_VALUE_TYPE zero! */
184  one = unique->one;
185  zero = Cudd_Not(one);
186  /* Create the projection functions. */
187  unique->vars = ABC_ALLOC(DdNodePtr,unique->maxSize);
188  if (unique->vars == NULL) {
189  unique->errorCode = CUDD_MEMORY_OUT;
190  return(NULL);
191  }
192  for (i = 0; i < unique->size; i++) {
193  unique->vars[i] = cuddUniqueInter(unique,i,one,zero);
194  if (unique->vars[i] == NULL) return(0);
195  cuddRef(unique->vars[i]);
196  }
197 
198  if (unique->sizeZ)
199  cuddZddInitUniv(unique);
200 
201  unique->memused += sizeof(DdNode *) * unique->maxSize;
202 
203  unique->bFunc = NULL;
204  unique->bFunc2 = NULL;
205  unique->TimeStop = 0;
206  return(unique);
207 
208 } /* end of Cudd_Init */
#define cuddRef(n)
Definition: cuddInt.h:584
void(* DD_OOMFP)(long)
Definition: cudd.h:324
int cuddZddInitUniv(DdManager *zdd)
Definition: cuddInit.c:252
void Cudd_OutOfMem(long size)
Definition: cuddUtil.c:2837
abctime TimeStop
Definition: cuddInt.h:489
Definition: cudd.h:278
#define Cudd_Not(node)
Definition: cudd.h:367
#define DD_MAX_CACHE_FRACTION
Definition: cuddInt.h:140
DdNode * cuddUniqueConst(DdManager *unique, CUDD_VALUE_TYPE value)
Definition: cuddTable.c:1450
int size
Definition: cuddInt.h:361
#define DD_STASH_FRACTION
Definition: cuddInt.h:142
DdNode * zero
Definition: cuddInt.h:346
#define DD_MAX_LOOSE_FRACTION
Definition: cuddInt.h:138
FILE * err
Definition: cuddInt.h:442
DdNode * bFunc
Definition: cuddInt.h:487
#define ABC_ALLOC(type, num)
Definition: abc_global.h:229
#define DD_PLUS_INF_VAL
Definition: cuddInt.h:117
int cuddInitCache(DdManager *unique, unsigned int cacheSize, unsigned int maxCacheSize)
Definition: cuddCache.c:136
EXTERN long getSoftDataLimit()
char * stash
Definition: cuddInt.h:399
static DdNode * one
Definition: cuddDecomp.c:112
int maxSize
Definition: cuddInt.h:363
DdNode * bFunc2
Definition: cuddInt.h:488
DdManager * cuddInitTable(unsigned int numVars, unsigned int numVarsZ, unsigned int numSlots, unsigned int looseUpTo)
Definition: cuddTable.c:351
unsigned long memused
Definition: cuddInt.h:449
int sizeZ
Definition: cuddInt.h:362
DdNode ** vars
Definition: cuddInt.h:390
DdNode * one
Definition: cuddInt.h:345
DdNode * plusinfinity
Definition: cuddInt.h:347
static int result
Definition: cuddGenetic.c:125
unsigned long maxmem
Definition: cuddInt.h:450
DdNode * minusinfinity
Definition: cuddInt.h:348
#define DD_MINUS_INF_VAL
Definition: cuddInt.h:121
Cudd_ErrorType errorCode
Definition: cuddInt.h:447
DdNode * cuddUniqueInter(DdManager *unique, int index, DdNode *T, DdNode *E)
Definition: cuddTable.c:1128
static DdNode * zero
Definition: cuddApa.c:100
DdNode * background
Definition: cuddInt.h:349
#define MMoutOfMemory
Definition: util_hack.h:38
int Cudd_IsGenEmpty ( DdGen gen)

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

Synopsis [Queries the status of a generator.]

Description [Queries the status of a generator. Returns 1 if the generator is empty or NULL; 0 otherswise.]

SideEffects [None]

SeeAlso [Cudd_ForeachCube Cudd_ForeachNode Cudd_FirstCube Cudd_NextCube Cudd_FirstNode Cudd_NextNode Cudd_GenFree]

Definition at line 2531 of file cuddUtil.c.

2533 {
2534  if (gen == NULL) return(1);
2535  return(gen->status == CUDD_GEN_EMPTY);
2536 
2537 } /* end of Cudd_IsGenEmpty */
#define CUDD_GEN_EMPTY
Definition: cuddInt.h:196
int status
Definition: cuddInt.h:207
int Cudd_IsInHook ( DdManager dd,
DD_HFP  f,
Cudd_HookType  where 
)

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

Synopsis [Checks whether a function is in a hook.]

Description [Checks whether a function is in a hook. A hook is a list of application-provided functions called on certain occasions by the package. Returns 1 if the function is found; 0 otherwise.]

SideEffects [None]

SeeAlso [Cudd_AddHook Cudd_RemoveHook]

Definition at line 3359 of file cuddAPI.c.

3363 {
3364  DdHook *hook;
3365 
3366  switch (where) {
3367  case CUDD_PRE_GC_HOOK:
3368  hook = dd->preGCHook;
3369  break;
3370  case CUDD_POST_GC_HOOK:
3371  hook = dd->postGCHook;
3372  break;
3374  hook = dd->preReorderingHook;
3375  break;
3377  hook = dd->postReorderingHook;
3378  break;
3379  default:
3380  return(0);
3381  }
3382  /* Scan the list and find whether the function is already there. */
3383  while (hook != NULL) {
3384  if (hook->f == f) {
3385  return(1);
3386  }
3387  hook = hook->next;
3388  }
3389  return(0);
3390 
3391 } /* end of Cudd_IsInHook */
DdHook * preReorderingHook
Definition: cuddInt.h:439
DD_HFP f
Definition: cuddInt.h:246
DdHook * postReorderingHook
Definition: cuddInt.h:440
struct DdHook * next
Definition: cuddInt.h:247
DdHook * postGCHook
Definition: cuddInt.h:438
DdHook * preGCHook
Definition: cuddInt.h:437
int Cudd_IsNonConstant ( DdNode f)

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

Synopsis [Returns 1 if a DD node is not constant.]

Description [Returns 1 if a DD node is not constant. This function is useful to test the results of Cudd_bddIteConstant, Cudd_addIteConstant, Cudd_addEvalConst. These results may be a special value signifying non-constant. In the other cases the macro Cudd_IsConstant can be used.]

SideEffects [None]

SeeAlso [Cudd_IsConstant Cudd_bddIteConstant Cudd_addIteConstant Cudd_addEvalConst]

Definition at line 645 of file cuddAPI.c.

647 {
648  return(f == DD_NON_CONSTANT || !Cudd_IsConstant(f));
649 
650 } /* end of Cudd_IsNonConstant */
#define Cudd_IsConstant(node)
Definition: cudd.h:352
#define DD_NON_CONSTANT
Definition: cuddInt.h:123
void Cudd_IterDerefBdd ( DdManager table,
DdNode n 
)

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

Synopsis [Decreases the reference count of BDD node n.]

Description [Decreases the reference count of node n. If n dies, recursively decreases the reference counts of its children. It is used to dispose of a BDD that is no longer needed. It is more efficient than Cudd_RecursiveDeref, but it cannot be used on ADDs. The greater efficiency comes from being able to assume that no constant node will ever die as a result of a call to this procedure.]

SideEffects [None]

SeeAlso [Cudd_RecursiveDeref Cudd_DelayedDerefBdd]

Definition at line 217 of file cuddRef.c.

220 {
221  DdNode *N;
222  int ord;
223  DdNodePtr *stack = table->stack;
224  int SP = 1;
225 
226  unsigned int live = table->keys - table->dead;
227  if (live > table->peakLiveNodes) {
228  table->peakLiveNodes = live;
229  }
230 
231  N = Cudd_Regular(n);
232 
233  do {
234 #ifdef DD_DEBUG
235  assert(N->ref != 0);
236 #endif
237 
238  if (N->ref == 1) {
239  N->ref = 0;
240  table->dead++;
241 #ifdef DD_STATS
242  table->nodesDropped++;
243 #endif
244  ord = table->perm[N->index];
245  stack[SP++] = Cudd_Regular(cuddE(N));
246  table->subtables[ord].dead++;
247  N = cuddT(N);
248  } else {
249  cuddSatDec(N->ref);
250  N = stack[--SP];
251  }
252  } while (SP != 0);
253 
254 } /* end of Cudd_IterDerefBdd */
DdHalfWord ref
Definition: cudd.h:280
unsigned int peakLiveNodes
Definition: cuddInt.h:465
Definition: cudd.h:278
#define Cudd_Regular(node)
Definition: cudd.h:397
DdSubtable * subtables
Definition: cuddInt.h:365
DdNode ** stack
Definition: cuddInt.h:380
unsigned int dead
Definition: cuddInt.h:371
unsigned int keys
Definition: cuddInt.h:369
unsigned int dead
Definition: cuddInt.h:332
#define cuddT(node)
Definition: cuddInt.h:636
DdHalfWord index
Definition: cudd.h:279
#define cuddE(node)
Definition: cuddInt.h:652
#define cuddSatDec(x)
Definition: cuddInt.h:896
#define assert(ex)
Definition: util_old.h:213
int * perm
Definition: cuddInt.h:386
DdNode* Cudd_LargestCube ( DdManager manager,
DdNode f,
int *  length 
)

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

Synopsis [Finds a largest cube in a DD.]

Description [Finds a largest cube in a DD. f is the DD we want to get the largest cube for. The problem is translated into the one of finding a shortest path in f, when both THEN and ELSE arcs are assumed to have unit length. This yields a largest cube in the disjoint cover corresponding to the DD. Therefore, it is not necessarily the largest implicant of f. Returns the largest cube as a BDD.]

SideEffects [The number of literals of the cube is returned in length.]

SeeAlso [Cudd_ShortestPath]

Definition at line 285 of file cuddSat.c.

289 {
290  register DdNode *F;
291  st__table *visited;
292  DdNode *sol;
293  cuddPathPair *rootPair;
294  int complement, cost;
295 
296  one = DD_ONE(manager);
297  zero = DD_ZERO(manager);
298 
299  if (f == Cudd_Not(one) || f == zero) {
300  *length = DD_BIGGY;
301  return(Cudd_Not(one));
302  }
303  /* From this point on, a path exists. */
304 
305  do {
306  manager->reordered = 0;
307 
308  /* Initialize visited table. */
310 
311  /* Now get the length of the shortest path(s) from f to 1. */
312  (void) getLargest(f, visited);
313 
314  complement = Cudd_IsComplement(f);
315 
316  F = Cudd_Regular(f);
317 
318  if (! st__lookup(visited, (const char *)F, (char **)&rootPair)) return(NULL);
319 
320  if (complement) {
321  cost = rootPair->neg;
322  } else {
323  cost = rootPair->pos;
324  }
325 
326  /* Recover an actual shortest path. */
327  sol = getCube(manager,visited,f,cost);
328 
329  st__foreach(visited, freePathPair, NULL);
330  st__free_table(visited);
331 
332  } while (manager->reordered == 1);
333 
334  *length = cost;
335  return(sol);
336 
337 } /* end of Cudd_LargestCube */
void st__free_table(st__table *table)
Definition: st.c:81
Definition: cudd.h:278
#define Cudd_Not(node)
Definition: cudd.h:367
static enum st__retval freePathPair(char *key, char *value, char *arg)
Definition: cuddSat.c:964
#define Cudd_Regular(node)
Definition: cudd.h:397
int st__ptrcmp(const char *, const char *)
Definition: st.c:480
pcover complement(pcube *T)
Definition: compl.c:49
st__table * st__init_table(st__compare_func_type compare, st__hash_func_type hash)
Definition: st.c:72
int reordered
Definition: cuddInt.h:409
static DdNode * one
Definition: cuddSat.c:106
#define Cudd_IsComplement(node)
Definition: cudd.h:425
Definition: st.h:52
int st__foreach(st__table *table, enum st__retval(*func)(char *, char *, char *), char *arg)
Definition: st.c:421
static DdNode * getCube(DdManager *manager, st__table *visited, DdNode *f, int cost)
Definition: cuddSat.c:1274
int st__lookup(st__table *table, const char *key, char **value)
Definition: st.c:114
static DdNode * zero
Definition: cuddSat.c:106
static cuddPathPair getLargest(DdNode *root, st__table *visited)
Definition: cuddSat.c:1186
#define DD_BIGGY
Definition: cuddSat.c:83
#define DD_ONE(dd)
Definition: cuddInt.h:911
int st__ptrhash(const char *, int)
Definition: st.c:468
#define DD_ZERO(dd)
Definition: cuddInt.h:927
DdNode* Cudd_MakeBddFromZddCover ( DdManager dd,
DdNode node 
)

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

Synopsis [Converts a ZDD cover to a BDD graph.]

Description [Converts a ZDD cover to a BDD graph. If successful, it returns a BDD node, otherwise it returns NULL.]

SideEffects []

SeeAlso [cuddMakeBddFromZddCover]

Definition at line 203 of file cuddZddIsop.c.

206 {
207  DdNode *res;
208 
209  do {
210  dd->reordered = 0;
211  res = cuddMakeBddFromZddCover(dd, node);
212  } while (dd->reordered == 1);
213  return(res);
214 } /* end of Cudd_MakeBddFromZddCover */
Definition: cudd.h:278
DdNode * cuddMakeBddFromZddCover(DdManager *dd, DdNode *node)
Definition: cuddZddIsop.c:800
int reordered
Definition: cuddInt.h:409
MtrNode* Cudd_MakeTreeNode ( DdManager dd,
unsigned int  low,
unsigned int  size,
unsigned int  type 
)

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

Synopsis [Creates a new variable group.]

Description [Creates a new variable group. The group starts at variable and contains size variables. The parameter low is the index of the first variable. If the variable already exists, its current position in the order is known to the manager. If the variable does not exist yet, the position is assumed to be the same as the index. The group tree is created if it does not exist yet. Returns a pointer to the group if successful; NULL otherwise.]

SideEffects [The variable tree is changed.]

SeeAlso [Cudd_MakeZddTreeNode]

Definition at line 206 of file cuddGroup.c.

211 {
212  MtrNode *group;
213  MtrNode *tree;
214  unsigned int level;
215 
216  /* If the variable does not exist yet, the position is assumed to be
217  ** the same as the index. Therefore, applications that rely on
218  ** Cudd_bddNewVarAtLevel or Cudd_addNewVarAtLevel to create new
219  ** variables have to create the variables before they group them.
220  */
221  level = (low < (unsigned int) dd->size) ? dd->perm[low] : low;
222 
223  if (level + size - 1> (int) MTR_MAXHIGH)
224  return(NULL);
225 
226  /* If the tree does not exist yet, create it. */
227  tree = dd->tree;
228  if (tree == NULL) {
229  dd->tree = tree = Mtr_InitGroupTree(0, dd->size);
230  if (tree == NULL)
231  return(NULL);
232  tree->index = dd->invperm[0];
233  }
234 
235  /* Extend the upper bound of the tree if necessary. This allows the
236  ** application to create groups even before the variables are created.
237  */
238  tree->size = ddMax(tree->size, ddMax(level + size, (unsigned) dd->size));
239 
240  /* Create the group. */
241  group = Mtr_MakeGroup(tree, level, size, type);
242  if (group == NULL)
243  return(NULL);
244 
245  /* Initialize the index field to the index of the variable currently
246  ** in position low. This field will be updated by the reordering
247  ** procedure to provide a handle to the group once it has been moved.
248  */
249  group->index = (MtrHalfWord) low;
250 
251  return(group);
252 
253 } /* end of Cudd_MakeTreeNode */
#define MTR_MAXHIGH
Definition: mtr.h:112
unsigned short MtrHalfWord
Definition: mtr.h:128
MtrHalfWord size
Definition: mtr.h:134
int size
Definition: cuddInt.h:361
MtrNode * tree
Definition: cuddInt.h:424
MtrHalfWord index
Definition: mtr.h:135
#define ddMax(x, y)
Definition: cuddInt.h:832
static int size
Definition: cuddSign.c:86
Definition: mtr.h:131
MtrNode * Mtr_InitGroupTree(int lower, int size)
Definition: mtrGroup.c:121
int * invperm
Definition: cuddInt.h:388
MtrNode * Mtr_MakeGroup(MtrNode *root, unsigned int low, unsigned int high, unsigned int flags)
Definition: mtrGroup.c:158
int * perm
Definition: cuddInt.h:386
MtrNode* Cudd_MakeZddTreeNode ( DdManager dd,
unsigned int  low,
unsigned int  size,
unsigned int  type 
)

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

Synopsis [Creates a new ZDD variable group.]

Description [Creates a new ZDD variable group. The group starts at variable and contains size variables. The parameter low is the index of the first variable. If the variable already exists, its current position in the order is known to the manager. If the variable does not exist yet, the position is assumed to be the same as the index. The group tree is created if it does not exist yet. Returns a pointer to the group if successful; NULL otherwise.]

SideEffects [The ZDD variable tree is changed.]

SeeAlso [Cudd_MakeTreeNode]

Definition at line 163 of file cuddZddGroup.c.

168 {
169  MtrNode *group;
170  MtrNode *tree;
171  unsigned int level;
172 
173  /* If the variable does not exist yet, the position is assumed to be
174  ** the same as the index. Therefore, applications that rely on
175  ** Cudd_bddNewVarAtLevel or Cudd_addNewVarAtLevel to create new
176  ** variables have to create the variables before they group them.
177  */
178  level = (low < (unsigned int) dd->sizeZ) ? dd->permZ[low] : low;
179 
180  if (level + size - 1> (int) MTR_MAXHIGH)
181  return(NULL);
182 
183  /* If the tree does not exist yet, create it. */
184  tree = dd->treeZ;
185  if (tree == NULL) {
186  dd->treeZ = tree = Mtr_InitGroupTree(0, dd->sizeZ);
187  if (tree == NULL)
188  return(NULL);
189  tree->index = dd->invpermZ[0];
190  }
191 
192  /* Extend the upper bound of the tree if necessary. This allows the
193  ** application to create groups even before the variables are created.
194  */
195  tree->size = ddMax(tree->size, level + size);
196 
197  /* Create the group. */
198  group = Mtr_MakeGroup(tree, level, size, type);
199  if (group == NULL)
200  return(NULL);
201 
202  /* Initialize the index field to the index of the variable currently
203  ** in position low. This field will be updated by the reordering
204  ** procedure to provide a handle to the group once it has been moved.
205  */
206  group->index = (MtrHalfWord) low;
207 
208  return(group);
209 
210 } /* end of Cudd_MakeZddTreeNode */
#define MTR_MAXHIGH
Definition: mtr.h:112
unsigned short MtrHalfWord
Definition: mtr.h:128
MtrHalfWord size
Definition: mtr.h:134
int * invpermZ
Definition: cuddInt.h:389
int * permZ
Definition: cuddInt.h:387
MtrHalfWord index
Definition: mtr.h:135
#define ddMax(x, y)
Definition: cuddInt.h:832
static int size
Definition: cuddSign.c:86
Definition: mtr.h:131
MtrNode * Mtr_InitGroupTree(int lower, int size)
Definition: mtrGroup.c:121
int sizeZ
Definition: cuddInt.h:362
MtrNode * treeZ
Definition: cuddInt.h:425
MtrNode * Mtr_MakeGroup(MtrNode *root, unsigned int low, unsigned int high, unsigned int flags)
Definition: mtrGroup.c:158
int Cudd_MinHammingDist ( DdManager dd,
DdNode f,
int *  minterm,
int  upperBound 
)

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

Synopsis [Returns the minimum Hamming distance between f and minterm.]

Description [Returns the minimum Hamming distance between the minterms of a function f and a reference minterm. The function is given as a BDD; the minterm is given as an array of integers, one for each variable in the manager. Returns the minimum distance if it is less than the upper bound; the upper bound if the minimum distance is at least as large; CUDD_OUT_OF_MEM in case of failure.]

SideEffects [None]

SeeAlso [Cudd_addHamming Cudd_bddClosestCube]

Definition at line 1318 of file cuddPriority.c.

1323 {
1324  DdHashTable *table;
1325  CUDD_VALUE_TYPE epsilon;
1326  int res;
1327 
1328  table = cuddHashTableInit(dd,1,2);
1329  if (table == NULL) {
1330  return(CUDD_OUT_OF_MEM);
1331  }
1332  epsilon = Cudd_ReadEpsilon(dd);
1334  res = cuddMinHammingDistRecur(f,minterm,table,upperBound);
1335  cuddHashTableQuit(table);
1336  Cudd_SetEpsilon(dd,epsilon);
1337 
1338  return(res);
1339 
1340 } /* end of Cudd_MinHammingDist */
#define CUDD_OUT_OF_MEM
Definition: cudd.h:95
static int cuddMinHammingDistRecur(DdNode *f, int *minterm, DdHashTable *table, int upperBound)
void Cudd_SetEpsilon(DdManager *dd, CUDD_VALUE_TYPE ep)
Definition: cuddAPI.c:2451
void cuddHashTableQuit(DdHashTable *hash)
Definition: cuddLCache.c:595
#define CUDD_VALUE_TYPE
Definition: cudd.h:94
DdHashTable * cuddHashTableInit(DdManager *manager, unsigned int keySize, unsigned int initSize)
Definition: cuddLCache.c:538
CUDD_VALUE_TYPE Cudd_ReadEpsilon(DdManager *dd)
Definition: cuddAPI.c:2430
DdApaNumber Cudd_NewApaNumber ( int  digits)

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

Synopsis [Allocates memory for an arbitrary precision integer.]

Description [Allocates memory for an arbitrary precision integer. Returns a pointer to the allocated memory if successful; NULL otherwise.]

SideEffects [None]

SeeAlso []

Definition at line 174 of file cuddApa.c.

176 {
177  return(ABC_ALLOC(DdApaDigit, digits));
178 
179 } /* end of Cudd_NewApaNumber */
#define ABC_ALLOC(type, num)
Definition: abc_global.h:229
unsigned short int DdApaDigit
Definition: cudd.h:303
int Cudd_NextCube ( DdGen gen,
int **  cube,
CUDD_VALUE_TYPE value 
)

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

Synopsis [Generates the next cube of a decision diagram onset.]

Description [Generates the next cube of a decision diagram onset, using generator gen. Returns 0 if the enumeration is completed; 1 otherwise.]

SideEffects [The cube and its value are returned as side effects. The generator is modified.]

SeeAlso [Cudd_ForeachCube Cudd_FirstCube Cudd_GenFree Cudd_IsGenEmpty Cudd_NextNode]

Definition at line 1917 of file cuddUtil.c.

1921 {
1922  DdNode *top, *treg, *next, *nreg, *prev, *preg;
1923  DdManager *dd = gen->manager;
1924 
1925  /* Backtrack from previously reached terminal node. */
1926  while (1) {
1927  if (gen->stack.sp == 1) {
1928  /* The current node has no predecessor. */
1929  gen->status = CUDD_GEN_EMPTY;
1930  gen->stack.sp--;
1931  goto done;
1932  }
1933  top = gen->stack.stack[gen->stack.sp-1];
1934  treg = Cudd_Regular(top);
1935  prev = gen->stack.stack[gen->stack.sp-2];
1936  preg = Cudd_Regular(prev);
1937  nreg = cuddT(preg);
1938  if (prev != preg) {next = Cudd_Not(nreg);} else {next = nreg;}
1939  if (next != top) { /* follow the then branch next */
1940  gen->gen.cubes.cube[preg->index] = 1;
1941  gen->stack.stack[gen->stack.sp-1] = next;
1942  break;
1943  }
1944  /* Pop the stack and try again. */
1945  gen->gen.cubes.cube[preg->index] = 2;
1946  gen->stack.sp--;
1947  }
1948 
1949  while (1) {
1950  top = gen->stack.stack[gen->stack.sp-1];
1951  treg = Cudd_Regular(top);
1952  if (!cuddIsConstant(treg)) {
1953  /* Take the else branch first. */
1954  gen->gen.cubes.cube[treg->index] = 0;
1955  next = cuddE(treg);
1956  if (top != treg) next = Cudd_Not(next);
1957  gen->stack.stack[gen->stack.sp] = next; gen->stack.sp++;
1958  } else if (top == Cudd_Not(DD_ONE(dd)) || top == dd->background) {
1959  /* Backtrack */
1960  while (1) {
1961  if (gen->stack.sp == 1) {
1962  /* The current node has no predecessor. */
1963  gen->status = CUDD_GEN_EMPTY;
1964  gen->stack.sp--;
1965  goto done;
1966  }
1967  prev = gen->stack.stack[gen->stack.sp-2];
1968  preg = Cudd_Regular(prev);
1969  nreg = cuddT(preg);
1970  if (prev != preg) {next = Cudd_Not(nreg);} else {next = nreg;}
1971  if (next != top) { /* follow the then branch next */
1972  gen->gen.cubes.cube[preg->index] = 1;
1973  gen->stack.stack[gen->stack.sp-1] = next;
1974  break;
1975  }
1976  /* Pop the stack and try again. */
1977  gen->gen.cubes.cube[preg->index] = 2;
1978  gen->stack.sp--;
1979  top = gen->stack.stack[gen->stack.sp-1];
1980  treg = Cudd_Regular(top);
1981  }
1982  } else {
1983  gen->status = CUDD_GEN_NONEMPTY;
1984  gen->gen.cubes.value = cuddV(top);
1985  goto done;
1986  }
1987  }
1988 
1989 done:
1990  if (gen->status == CUDD_GEN_EMPTY) return(0);
1991  *cube = gen->gen.cubes.cube;
1992  *value = gen->gen.cubes.value;
1993  return(1);
1994 
1995 } /* end of Cudd_NextCube */
Definition: cudd.h:278
#define Cudd_Not(node)
Definition: cudd.h:367
struct DdGen::@30::@32 cubes
#define Cudd_Regular(node)
Definition: cudd.h:397
#define CUDD_GEN_NONEMPTY
Definition: cuddInt.h:197
#define cuddV(node)
Definition: cuddInt.h:668
DdNode ** stack
Definition: cuddInt.h:227
DdManager * manager
Definition: cuddInt.h:205
#define cuddIsConstant(node)
Definition: cuddInt.h:620
#define cuddT(node)
Definition: cuddInt.h:636
union DdGen::@30 gen
#define CUDD_GEN_EMPTY
Definition: cuddInt.h:196
DdHalfWord index
Definition: cudd.h:279
#define cuddE(node)
Definition: cuddInt.h:652
int value
#define DD_ONE(dd)
Definition: cuddInt.h:911
DdNode * background
Definition: cuddInt.h:349
int status
Definition: cuddInt.h:207
int Cudd_NextNode ( DdGen gen,
DdNode **  node 
)

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

Synopsis [Finds the next node of a decision diagram.]

Description [Finds the node of a decision diagram, using generator gen. Returns 0 if the enumeration is completed; 1 otherwise.]

SideEffects [The next node is returned as a side effect.]

SeeAlso [Cudd_ForeachNode Cudd_FirstNode Cudd_GenFree Cudd_IsGenEmpty Cudd_NextCube]

Definition at line 2459 of file cuddUtil.c.

2462 {
2463  /* Find the next node. */
2464  gen->stack.sp++;
2465  if (gen->stack.sp < gen->gen.nodes.size) {
2466  gen->node = gen->stack.stack[gen->stack.sp];
2467  *node = gen->node;
2468  return(1);
2469  } else {
2470  gen->status = CUDD_GEN_EMPTY;
2471  return(0);
2472  }
2473 
2474 } /* end of Cudd_NextNode */
DdNode * node
Definition: cuddInt.h:232
DdNode ** stack
Definition: cuddInt.h:227
union DdGen::@30 gen
#define CUDD_GEN_EMPTY
Definition: cuddInt.h:196
struct DdGen::@30::@34 nodes
int status
Definition: cuddInt.h:207
int Cudd_NextPrime ( DdGen gen,
int **  cube 
)

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

Synopsis [Generates the next prime of a Boolean function.]

Description [Generates the next cube of a Boolean function, using generator gen. Returns 0 if the enumeration is completed; 1 otherwise.]

SideEffects [The cube and is returned as side effects. The generator is modified.]

SeeAlso [Cudd_ForeachPrime Cudd_FirstPrime Cudd_GenFree Cudd_IsGenEmpty Cudd_NextCube Cudd_NextNode]

Definition at line 2130 of file cuddUtil.c.

2133 {
2134  DdNode *implicant, *prime, *tmp;
2135  DdManager *dd = gen->manager;
2136  int length, result;
2137 
2138  if (gen->node == Cudd_ReadLogicZero(dd)) {
2139  gen->status = CUDD_GEN_EMPTY;
2140  } else {
2141  implicant = Cudd_LargestCube(dd,gen->node,&length);
2142  if (implicant == NULL) {
2143  gen->status = CUDD_GEN_EMPTY;
2144  return(0);
2145  }
2146  cuddRef(implicant);
2147  prime = Cudd_bddMakePrime(dd,implicant,gen->gen.primes.ub);
2148  if (prime == NULL) {
2149  Cudd_RecursiveDeref(dd,implicant);
2150  gen->status = CUDD_GEN_EMPTY;
2151  return(0);
2152  }
2153  cuddRef(prime);
2154  Cudd_RecursiveDeref(dd,implicant);
2155  tmp = Cudd_bddAnd(dd,gen->node,Cudd_Not(prime));
2156  if (tmp == NULL) {
2157  Cudd_RecursiveDeref(dd,prime);
2158  gen->status = CUDD_GEN_EMPTY;
2159  return(0);
2160  }
2161  cuddRef(tmp);
2162  Cudd_RecursiveDeref(dd,gen->node);
2163  gen->node = tmp;
2164  result = Cudd_BddToCubeArray(dd,prime,gen->gen.primes.cube);
2165  if (result == 0) {
2166  Cudd_RecursiveDeref(dd,prime);
2167  gen->status = CUDD_GEN_EMPTY;
2168  return(0);
2169  }
2170  Cudd_RecursiveDeref(dd,prime);
2171  gen->status = CUDD_GEN_NONEMPTY;
2172  }
2173  if (gen->status == CUDD_GEN_EMPTY) return(0);
2174  *cube = gen->gen.primes.cube;
2175  return(1);
2176 
2177 } /* end of Cudd_NextPrime */
#define cuddRef(n)
Definition: cuddInt.h:584
DdNode * node
Definition: cuddInt.h:232
void Cudd_RecursiveDeref(DdManager *table, DdNode *n)
Definition: cuddRef.c:154
Definition: cudd.h:278
#define Cudd_Not(node)
Definition: cudd.h:367
DdNode * Cudd_ReadLogicZero(DdManager *dd)
Definition: cuddAPI.c:1058
#define CUDD_GEN_NONEMPTY
Definition: cuddInt.h:197
DdNode * Cudd_LargestCube(DdManager *manager, DdNode *f, int *length)
Definition: cuddSat.c:285
DdNode * Cudd_bddMakePrime(DdManager *dd, DdNode *cube, DdNode *f)
Definition: cuddSat.c:864
int Cudd_BddToCubeArray(DdManager *dd, DdNode *cube, int *array)
Definition: cuddUtil.c:2346
DdManager * manager
Definition: cuddInt.h:205
union DdGen::@30 gen
#define CUDD_GEN_EMPTY
Definition: cuddInt.h:196
struct DdGen::@30::@33 primes
DdNode * Cudd_bddAnd(DdManager *dd, DdNode *f, DdNode *g)
Definition: cuddBddIte.c:314
static int result
Definition: cuddGenetic.c:125
int status
Definition: cuddInt.h:207
unsigned int Cudd_NodeReadIndex ( DdNode node)

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

Synopsis [Returns the index of the node.]

Description [Returns the index of the node. The node pointer can be either regular or complemented.]

SideEffects [None]

SeeAlso [Cudd_ReadIndex]

Definition at line 2277 of file cuddAPI.c.

2279 {
2280  return((unsigned int) Cudd_Regular(node)->index);
2281 
2282 } /* end of Cudd_NodeReadIndex */
#define Cudd_Regular(node)
Definition: cudd.h:397
void Cudd_OutOfMem ( long  size)

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

Synopsis [Warns that a memory allocation failed.]

Description [Warns that a memory allocation failed. This function can be used as replacement of MMout_of_memory to prevent the safe_mem functions of the util package from exiting when malloc returns NULL. One possible use is in case of discretionary allocations; for instance, the allocation of memory to enlarge the computed table.]

SideEffects [None]

SeeAlso []

Definition at line 2837 of file cuddUtil.c.

2839 {
2840  (void) fflush(stdout);
2841  (void) fprintf(stderr, "\nunable to allocate %ld bytes\n", size);
2842  return;
2843 
2844 } /* end of Cudd_OutOfMem */
static int size
Definition: cuddSign.c:86
DdNode* Cudd_OverApprox ( DdManager dd,
DdNode f,
int  numVars,
int  threshold,
int  safe,
double  quality 
)

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

Synopsis [Extracts a dense superset from a BDD with Shiple's underapproximation method.]

Description [Extracts a dense superset from a BDD. The procedure is identical to the underapproximation procedure except for the fact that it works on the complement of the given function. Extracting the subset of the complement function is equivalent to extracting the superset of the function. Returns a pointer to the BDD of the superset if successful. NULL if intermediate result causes the procedure to run out of memory. The parameter numVars is the maximum number of variables to be used in minterm calculation. The optimal number should be as close as possible to the size of the support of f. However, it is safe to pass the value returned by Cudd_ReadSize for numVars when the number of variables is under 1023. If numVars is larger than 1023, it will overflow. If a 0 parameter is passed then the procedure will compute a value which will avoid overflow but will cause underflow with 2046 variables or more.]

SideEffects [None]

SeeAlso [Cudd_SupersetHeavyBranch Cudd_SupersetShortPaths Cudd_ReadSize]

Definition at line 275 of file cuddApprox.c.

282 {
283  DdNode *subset, *g;
284 
285  g = Cudd_Not(f);
286  do {
287  dd->reordered = 0;
288  subset = cuddUnderApprox(dd, g, numVars, threshold, safe, quality);
289  } while (dd->reordered == 1);
290 
291  return(Cudd_NotCond(subset, (subset != NULL)));
292 
293 } /* end of Cudd_OverApprox */
Definition: cudd.h:278
#define Cudd_Not(node)
Definition: cudd.h:367
DdNode * cuddUnderApprox(DdManager *dd, DdNode *f, int numVars, int threshold, int safe, double quality)
Definition: cuddApprox.c:511
int reordered
Definition: cuddInt.h:409
#define Cudd_NotCond(node, c)
Definition: cudd.h:383
unsigned int Cudd_Prime ( unsigned int  p)

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

Synopsis [Returns the next prime >= p.]

Description []

SideEffects [None]

Definition at line 188 of file cuddTable.c.

190 {
191  int i,pn;
192 
193  p--;
194  do {
195  p++;
196  if (p&1) {
197  pn = 1;
198  i = 3;
199  while ((unsigned) (i * i) <= p) {
200  if (p % i == 0) {
201  pn = 0;
202  break;
203  }
204  i += 2;
205  }
206  } else {
207  pn = 0;
208  }
209  } while (!pn);
210  return(p);
211 
212 } /* end of Cudd_Prime */
static Llb_Mgr_t * p
Definition: llb3Image.c:950
int Cudd_PrintDebug ( DdManager dd,
DdNode f,
int  n,
int  pr 
)

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

Synopsis [Prints to the standard output a DD and its statistics.]

Description [Prints to the standard output a DD and its statistics. The statistics include the number of nodes, the number of leaves, and the number of minterms. (The number of minterms is the number of assignments to the variables that cause the function to be different from the logical zero (for BDDs) and from the background value (for ADDs.) The statistics are printed if pr > 0. Specifically:

  • pr = 0 : prints nothing
  • pr = 1 : prints counts of nodes and minterms
  • pr = 2 : prints counts + disjoint sum of product
  • pr = 3 : prints counts + list of nodes
  • pr > 3 : prints counts + disjoint sum of product + list of nodes

For the purpose of counting the number of minterms, the function is supposed to depend on n variables. Returns 1 if successful; 0 otherwise.]

SideEffects [None]

SeeAlso [Cudd_DagSize Cudd_CountLeaves Cudd_CountMinterm Cudd_PrintMinterm]

Definition at line 382 of file cuddUtil.c.

387 {
388  DdNode *azero, *bzero;
389  int nodes;
390  int leaves;
391  double minterms;
392  int retval = 1;
393 
394  if (f == NULL) {
395  (void) fprintf(dd->out,": is the NULL DD\n");
396  (void) fflush(dd->out);
397  return(0);
398  }
399  azero = DD_ZERO(dd);
400  bzero = Cudd_Not(DD_ONE(dd));
401  if ((f == azero || f == bzero) && pr > 0){
402  (void) fprintf(dd->out,": is the zero DD\n");
403  (void) fflush(dd->out);
404  return(1);
405  }
406  if (pr > 0) {
407  nodes = Cudd_DagSize(f);
408  if (nodes == CUDD_OUT_OF_MEM) retval = 0;
409  leaves = Cudd_CountLeaves(f);
410  if (leaves == CUDD_OUT_OF_MEM) retval = 0;
411  minterms = Cudd_CountMinterm(dd, f, n);
412  if (minterms == (double)CUDD_OUT_OF_MEM) retval = 0;
413  (void) fprintf(dd->out,": %d nodes %d leaves %g minterms\n",
414  nodes, leaves, minterms);
415  if (pr > 2) {
416  if (!cuddP(dd, f)) retval = 0;
417  }
418  if (pr == 2 || pr > 3) {
419  if (!Cudd_PrintMinterm(dd,f)) retval = 0;
420  (void) fprintf(dd->out,"\n");
421  }
422  (void) fflush(dd->out);
423  }
424  return(retval);
425 
426 } /* end of Cudd_PrintDebug */
#define CUDD_OUT_OF_MEM
Definition: cudd.h:95
Definition: cudd.h:278
#define Cudd_Not(node)
Definition: cudd.h:367
int nodes
Definition: abcSaucy.c:61
int Cudd_DagSize(DdNode *node)
Definition: cuddUtil.c:442
double Cudd_CountMinterm(DdManager *manager, DdNode *node, int nvars)
Definition: cuddUtil.c:578
FILE * out
Definition: cuddInt.h:441
int Cudd_PrintMinterm(DdManager *manager, DdNode *node)
Definition: cuddUtil.c:216
int Cudd_CountLeaves(DdNode *node)
Definition: cuddUtil.c:1194
int cuddP(DdManager *dd, DdNode *f)
Definition: cuddUtil.c:2866
#define DD_ONE(dd)
Definition: cuddInt.h:911
pset minterms()
#define DD_ZERO(dd)
Definition: cuddInt.h:927
int Cudd_PrintInfo ( DdManager dd,
FILE *  fp 
)

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

Synopsis [Prints out statistics and settings for a CUDD manager.]

Description [Prints out statistics and settings for a CUDD manager. Returns 1 if successful; 0 otherwise.]

SideEffects [None]

SeeAlso []

Definition at line 2937 of file cuddAPI.c.

2940 {
2941  int retval;
2942  Cudd_ReorderingType autoMethod, autoMethodZ;
2943 
2944  /* Modifiable parameters. */
2945  retval = fprintf(fp,"**** CUDD modifiable parameters ****\n");
2946  if (retval == EOF) return(0);
2947  retval = fprintf(fp,"Hard limit for cache size: %u\n",
2948  Cudd_ReadMaxCacheHard(dd));
2949  if (retval == EOF) return(0);
2950  retval = fprintf(fp,"Cache hit threshold for resizing: %u%%\n",
2951  Cudd_ReadMinHit(dd));
2952  if (retval == EOF) return(0);
2953  retval = fprintf(fp,"Garbage collection enabled: %s\n",
2954  Cudd_GarbageCollectionEnabled(dd) ? "yes" : "no");
2955  if (retval == EOF) return(0);
2956  retval = fprintf(fp,"Limit for fast unique table growth: %u\n",
2957  Cudd_ReadLooseUpTo(dd));
2958  if (retval == EOF) return(0);
2959  retval = fprintf(fp,
2960  "Maximum number of variables sifted per reordering: %d\n",
2961  Cudd_ReadSiftMaxVar(dd));
2962  if (retval == EOF) return(0);
2963  retval = fprintf(fp,
2964  "Maximum number of variable swaps per reordering: %d\n",
2965  Cudd_ReadSiftMaxSwap(dd));
2966  if (retval == EOF) return(0);
2967  retval = fprintf(fp,"Maximum growth while sifting a variable: %g\n",
2968  Cudd_ReadMaxGrowth(dd));
2969  if (retval == EOF) return(0);
2970  retval = fprintf(fp,"Dynamic reordering of BDDs enabled: %s\n",
2971  Cudd_ReorderingStatus(dd,&autoMethod) ? "yes" : "no");
2972  if (retval == EOF) return(0);
2973  retval = fprintf(fp,"Default BDD reordering method: %d\n",
2974  (int) autoMethod);
2975  if (retval == EOF) return(0);
2976  retval = fprintf(fp,"Dynamic reordering of ZDDs enabled: %s\n",
2977  Cudd_ReorderingStatusZdd(dd,&autoMethodZ) ? "yes" : "no");
2978  if (retval == EOF) return(0);
2979  retval = fprintf(fp,"Default ZDD reordering method: %d\n",
2980  (int) autoMethodZ);
2981  if (retval == EOF) return(0);
2982  retval = fprintf(fp,"Realignment of ZDDs to BDDs enabled: %s\n",
2983  Cudd_zddRealignmentEnabled(dd) ? "yes" : "no");
2984  if (retval == EOF) return(0);
2985  retval = fprintf(fp,"Realignment of BDDs to ZDDs enabled: %s\n",
2986  Cudd_bddRealignmentEnabled(dd) ? "yes" : "no");
2987  if (retval == EOF) return(0);
2988  retval = fprintf(fp,"Dead nodes counted in triggering reordering: %s\n",
2989  Cudd_DeadAreCounted(dd) ? "yes" : "no");
2990  if (retval == EOF) return(0);
2991  retval = fprintf(fp,"Group checking criterion: %d\n",
2992  (int) Cudd_ReadGroupcheck(dd));
2993  if (retval == EOF) return(0);
2994  retval = fprintf(fp,"Recombination threshold: %d\n", Cudd_ReadRecomb(dd));
2995  if (retval == EOF) return(0);
2996  retval = fprintf(fp,"Symmetry violation threshold: %d\n",
2998  if (retval == EOF) return(0);
2999  retval = fprintf(fp,"Arc violation threshold: %d\n",
3000  Cudd_ReadArcviolation(dd));
3001  if (retval == EOF) return(0);
3002  retval = fprintf(fp,"GA population size: %d\n",
3004  if (retval == EOF) return(0);
3005  retval = fprintf(fp,"Number of crossovers for GA: %d\n",
3006  Cudd_ReadNumberXovers(dd));
3007  if (retval == EOF) return(0);
3008  retval = fprintf(fp,"Next reordering threshold: %u\n",
3010  if (retval == EOF) return(0);
3011 
3012  /* Non-modifiable parameters. */
3013  retval = fprintf(fp,"**** CUDD non-modifiable parameters ****\n");
3014  if (retval == EOF) return(0);
3015  retval = fprintf(fp,"Memory in use: %lu\n", Cudd_ReadMemoryInUse(dd));
3016  if (retval == EOF) return(0);
3017  retval = fprintf(fp,"Peak number of nodes: %ld\n",
3019  if (retval == EOF) return(0);
3020  retval = fprintf(fp,"Peak number of live nodes: %d\n",
3022  if (retval == EOF) return(0);
3023  retval = fprintf(fp,"Number of BDD variables: %d\n", dd->size);
3024  if (retval == EOF) return(0);
3025  retval = fprintf(fp,"Number of ZDD variables: %d\n", dd->sizeZ);
3026  if (retval == EOF) return(0);
3027  retval = fprintf(fp,"Number of cache entries: %u\n", dd->cacheSlots);
3028  if (retval == EOF) return(0);
3029  retval = fprintf(fp,"Number of cache look-ups: %.0f\n",
3030  Cudd_ReadCacheLookUps(dd));
3031  if (retval == EOF) return(0);
3032  retval = fprintf(fp,"Number of cache hits: %.0f\n",
3033  Cudd_ReadCacheHits(dd));
3034  if (retval == EOF) return(0);
3035  retval = fprintf(fp,"Number of cache insertions: %.0f\n",
3036  dd->cacheinserts);
3037  if (retval == EOF) return(0);
3038  retval = fprintf(fp,"Number of cache collisions: %.0f\n",
3039  dd->cachecollisions);
3040  if (retval == EOF) return(0);
3041  retval = fprintf(fp,"Number of cache deletions: %.0f\n",
3042  dd->cachedeletions);
3043  if (retval == EOF) return(0);
3044  retval = cuddCacheProfile(dd,fp);
3045  if (retval == 0) return(0);
3046  retval = fprintf(fp,"Soft limit for cache size: %u\n",
3047  Cudd_ReadMaxCache(dd));
3048  if (retval == EOF) return(0);
3049  retval = fprintf(fp,"Number of buckets in unique table: %u\n", dd->slots);
3050  if (retval == EOF) return(0);
3051  retval = fprintf(fp,"Used buckets in unique table: %.2f%% (expected %.2f%%)\n",
3052  100.0 * Cudd_ReadUsedSlots(dd),
3053  100.0 * Cudd_ExpectedUsedSlots(dd));
3054  if (retval == EOF) return(0);
3055 #ifdef DD_UNIQUE_PROFILE
3056  retval = fprintf(fp,"Unique lookups: %.0f\n", dd->uniqueLookUps);
3057  if (retval == EOF) return(0);
3058  retval = fprintf(fp,"Unique links: %.0f (%g per lookup)\n",
3059  dd->uniqueLinks, dd->uniqueLinks / dd->uniqueLookUps);
3060  if (retval == EOF) return(0);
3061 #endif
3062  retval = fprintf(fp,"Number of BDD and ADD nodes: %u\n", dd->keys);
3063  if (retval == EOF) return(0);
3064  retval = fprintf(fp,"Number of ZDD nodes: %u\n", dd->keysZ);
3065  if (retval == EOF) return(0);
3066  retval = fprintf(fp,"Number of dead BDD and ADD nodes: %u\n", dd->dead);
3067  if (retval == EOF) return(0);
3068  retval = fprintf(fp,"Number of dead ZDD nodes: %u\n", dd->deadZ);
3069  if (retval == EOF) return(0);
3070  retval = fprintf(fp,"Total number of nodes allocated: %d\n", (int)dd->allocated);
3071  if (retval == EOF) return(0);
3072  retval = fprintf(fp,"Total number of nodes reclaimed: %.0f\n",
3073  dd->reclaimed);
3074  if (retval == EOF) return(0);
3075 #ifdef DD_STATS
3076  retval = fprintf(fp,"Nodes freed: %.0f\n", dd->nodesFreed);
3077  if (retval == EOF) return(0);
3078  retval = fprintf(fp,"Nodes dropped: %.0f\n", dd->nodesDropped);
3079  if (retval == EOF) return(0);
3080 #endif
3081 #ifdef DD_COUNT
3082  retval = fprintf(fp,"Number of recursive calls: %.0f\n",
3084  if (retval == EOF) return(0);
3085 #endif
3086  retval = fprintf(fp,"Garbage collections so far: %d\n",
3088  if (retval == EOF) return(0);
3089  retval = fprintf(fp,"Time for garbage collection: %.2f sec\n",
3090  ((double)Cudd_ReadGarbageCollectionTime(dd)/1000.0));
3091  if (retval == EOF) return(0);
3092  retval = fprintf(fp,"Reorderings so far: %d\n", dd->reorderings);
3093  if (retval == EOF) return(0);
3094  retval = fprintf(fp,"Time for reordering: %.2f sec\n",
3095  ((double)Cudd_ReadReorderingTime(dd)/1000.0));
3096  if (retval == EOF) return(0);
3097 #ifdef DD_COUNT
3098  retval = fprintf(fp,"Node swaps in reordering: %.0f\n",
3099  Cudd_ReadSwapSteps(dd));
3100  if (retval == EOF) return(0);
3101 #endif
3102 
3103  return(1);
3104 
3105 } /* end of Cudd_PrintInfo */
ABC_INT64_T allocated
Definition: cuddInt.h:382
int Cudd_ReadSiftMaxSwap(DdManager *dd)
Definition: cuddAPI.c:1938
unsigned int deadZ
Definition: cuddInt.h:372
double Cudd_ExpectedUsedSlots(DdManager *dd)
Definition: cuddAPI.c:1572
unsigned int Cudd_ReadMaxCache(DdManager *dd)
Definition: cuddAPI.c:1371
long Cudd_ReadPeakNodeCount(DdManager *dd)
Definition: cuddAPI.c:3122
int Cudd_ReorderingStatusZdd(DdManager *unique, Cudd_ReorderingType *method)
Definition: cuddAPI.c:812
int size
Definition: cuddInt.h:361
int Cudd_ReadRecomb(DdManager *dd)
Definition: cuddAPI.c:2657
double Cudd_ReadSwapSteps(DdManager *dd)
Definition: cuddAPI.c:3787
unsigned int slots
Definition: cuddInt.h:368
Cudd_AggregationType Cudd_ReadGroupcheck(DdManager *dd)
Definition: cuddAPI.c:2474
unsigned int Cudd_ReadMaxCacheHard(DdManager *dd)
Definition: cuddAPI.c:1391
int Cudd_GarbageCollectionEnabled(DdManager *dd)
Definition: cuddAPI.c:2517
unsigned int Cudd_ReadMinHit(DdManager *dd)
Definition: cuddAPI.c:1272
int Cudd_DeadAreCounted(DdManager *dd)
Definition: cuddAPI.c:2585
unsigned long Cudd_ReadMemoryInUse(DdManager *dd)
Definition: cuddAPI.c:2916
double cachecollisions
Definition: cuddInt.h:457
int Cudd_ReadArcviolation(DdManager *dd)
Definition: cuddAPI.c:2764
double cacheinserts
Definition: cuddInt.h:458
unsigned int dead
Definition: cuddInt.h:371
unsigned int cacheSlots
Definition: cuddInt.h:353
unsigned int keys
Definition: cuddInt.h:369
int Cudd_ReadSymmviolation(DdManager *dd)
Definition: cuddAPI.c:2710
unsigned int Cudd_ReadNextReordering(DdManager *dd)
Definition: cuddAPI.c:3742
double Cudd_ReadCacheLookUps(DdManager *dd)
Definition: cuddAPI.c:1204
int Cudd_ReadPopulationSize(DdManager *dd)
Definition: cuddAPI.c:2817
int Cudd_bddRealignmentEnabled(DdManager *unique)
Definition: cuddAPI.c:913
int reorderings
Definition: cuddInt.h:410
int Cudd_ReadPeakLiveNodeCount(DdManager *dd)
Definition: cuddAPI.c:3151
double Cudd_ReadUsedSlots(DdManager *dd)
Definition: cuddAPI.c:1503
double Cudd_ReadCacheHits(DdManager *dd)
Definition: cuddAPI.c:1225
int Cudd_zddRealignmentEnabled(DdManager *unique)
Definition: cuddAPI.c:837
unsigned int Cudd_ReadLooseUpTo(DdManager *dd)
Definition: cuddAPI.c:1321
int cuddCacheProfile(DdManager *table, FILE *fp)
Definition: cuddCache.c:785
int Cudd_ReadSiftMaxVar(DdManager *dd)
Definition: cuddAPI.c:1891
long Cudd_ReadReorderingTime(DdManager *dd)
Definition: cuddAPI.c:1718
double Cudd_ReadMaxGrowth(DdManager *dd)
Definition: cuddAPI.c:1988
int Cudd_ReadGarbageCollections(DdManager *dd)
Definition: cuddAPI.c:1741
int Cudd_ReadNumberXovers(DdManager *dd)
Definition: cuddAPI.c:2870
int sizeZ
Definition: cuddInt.h:362
int Cudd_ReorderingStatus(DdManager *unique, Cudd_ReorderingType *method)
Definition: cuddAPI.c:735
double cachedeletions
Definition: cuddInt.h:460
unsigned int keysZ
Definition: cuddInt.h:370
double Cudd_ReadRecursiveCalls(DdManager *dd)
Definition: cuddAPI.c:1246
Cudd_ReorderingType
Definition: cudd.h:151
long Cudd_ReadGarbageCollectionTime(DdManager *dd)
Definition: cuddAPI.c:1762
double reclaimed
Definition: cuddInt.h:384
int Cudd_PrintLinear ( DdManager table)

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

Synopsis [Prints the linear transform matrix.]

Description [Prints the linear transform matrix. Returns 1 in case of success; 0 otherwise.]

SideEffects [none]

SeeAlso []

Definition at line 153 of file cuddLinear.c.

155 {
156  int i,j,k;
157  int retval;
158  int nvars = table->linearSize;
159  int wordsPerRow = ((nvars - 1) >> LOGBPL) + 1;
160  long word;
161 
162  for (i = 0; i < nvars; i++) {
163  for (j = 0; j < wordsPerRow; j++) {
164  word = table->linear[i*wordsPerRow + j];
165  for (k = 0; k < BPL; k++) {
166  retval = fprintf(table->out,"%ld",word & 1);
167  if (retval == 0) return(0);
168  word >>= 1;
169  }
170  }
171  retval = fprintf(table->out,"\n");
172  if (retval == 0) return(0);
173  }
174  return(1);
175 
176 } /* end of Cudd_PrintLinear */
#define BPL
Definition: cuddLinear.c:82
#define LOGBPL
Definition: cuddLinear.c:83
FILE * out
Definition: cuddInt.h:441
unsigned __int64 word
DECLARATIONS ///.
Definition: kitPerm.c:36
long * linear
Definition: cuddInt.h:395
int linearSize
Definition: cuddInt.h:393
int Cudd_PrintMinterm ( DdManager manager,
DdNode node 
)

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

Synopsis [Prints a disjoint sum of products.]

Description [Prints a disjoint sum of product cover for the function rooted at node. Each product corresponds to a path from node to a leaf node different from the logical zero, and different from the background value. Uses the package default output file. Returns 1 if successful; 0 otherwise.]

SideEffects [None]

SeeAlso [Cudd_PrintDebug Cudd_bddPrintCover]

Definition at line 216 of file cuddUtil.c.

219 {
220  int i, *list;
221 
222  background = manager->background;
223  zero = Cudd_Not(manager->one);
224  list = ABC_ALLOC(int,manager->size);
225  if (list == NULL) {
226  manager->errorCode = CUDD_MEMORY_OUT;
227  return(0);
228  }
229  for (i = 0; i < manager->size; i++) list[i] = 2;
230  ddPrintMintermAux(manager,node,list);
231  ABC_FREE(list);
232  return(1);
233 
234 } /* end of Cudd_PrintMinterm */
#define Cudd_Not(node)
Definition: cudd.h:367
int size
Definition: cuddInt.h:361
#define ABC_ALLOC(type, num)
Definition: abc_global.h:229
static DdNode * background
Definition: cuddUtil.c:148
static void ddPrintMintermAux(DdManager *dd, DdNode *node, int *list)
Definition: cuddUtil.c:3111
static DdNode * zero
Definition: cuddUtil.c:148
#define ABC_FREE(obj)
Definition: abc_global.h:232
DdNode * one
Definition: cuddInt.h:345
Cudd_ErrorType errorCode
Definition: cuddInt.h:447
DdNode * background
Definition: cuddInt.h:349
int Cudd_PrintTwoLiteralClauses ( DdManager dd,
DdNode f,
char **  names,
FILE *  fp 
)

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

Synopsis [Prints the two literal clauses of a DD.]

Description [Prints the one- and two-literal clauses. Returns 1 if successful; 0 otherwise. The argument "names" can be NULL, in which case the variable indices are printed.]

SideEffects [None]

SeeAlso [Cudd_FindTwoLiteralClauses]

Definition at line 393 of file cuddEssent.c.

398 {
399  DdHalfWord *vars;
400  BitVector *phases;
401  int i;
403  FILE *ifp = fp == NULL ? dd->out : fp;
404 
405  if (res == NULL) return(0);
406  vars = res->vars;
407  phases = res->phases;
408  for (i = 0; !sentinelp(vars[i], vars[i+1]); i += 2) {
409  if (names != NULL) {
410  if (vars[i+1] == CUDD_MAXINDEX) {
411  (void) fprintf(ifp, "%s%s\n",
412  bitVectorRead(phases, i) ? "~" : " ",
413  names[vars[i]]);
414  } else {
415  (void) fprintf(ifp, "%s%s | %s%s\n",
416  bitVectorRead(phases, i) ? "~" : " ",
417  names[vars[i]],
418  bitVectorRead(phases, i+1) ? "~" : " ",
419  names[vars[i+1]]);
420  }
421  } else {
422  if (vars[i+1] == CUDD_MAXINDEX) {
423  (void) fprintf(ifp, "%s%d\n",
424  bitVectorRead(phases, i) ? "~" : " ",
425  (int) vars[i]);
426  } else {
427  (void) fprintf(ifp, "%s%d | %s%d\n",
428  bitVectorRead(phases, i) ? "~" : " ",
429  (int) vars[i],
430  bitVectorRead(phases, i+1) ? "~" : " ",
431  (int) vars[i+1]);
432  }
433  }
434  }
435  Cudd_tlcInfoFree(res);
436 
437  return(1);
438 
439 } /* end of Cudd_PrintTwoLiteralClauses */
unsigned short DdHalfWord
Definition: cudd.h:262
DdHalfWord * vars
Definition: cuddEssent.c:123
DdTlcInfo * Cudd_FindTwoLiteralClauses(DdManager *dd, DdNode *f)
Definition: cuddEssent.c:277
long * phases
Definition: cuddEssent.c:124
FILE * out
Definition: cuddInt.h:441
void Cudd_tlcInfoFree(DdTlcInfo *t)
Definition: cuddEssent.c:455
static int sentinelp(DdHalfWord var1, DdHalfWord var2)
Definition: cuddEssent.c:1174
#define CUDD_MAXINDEX
Definition: cudd.h:112
long BitVector
Definition: cuddEssent.c:142
static DD_INLINE short bitVectorRead(BitVector *vector, int i)
Definition: cuddEssent.c:1404
void Cudd_PrintVersion ( FILE *  fp)

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

Synopsis [Prints the package version number.]

Description []

SideEffects [None]

SeeAlso []

Definition at line 2592 of file cuddUtil.c.

2594 {
2595  (void) fprintf(fp, "%s\n", CUDD_VERSION);
2596 
2597 } /* end of Cudd_PrintVersion */
#define CUDD_VERSION
Definition: cudd.h:75
DdNode* Cudd_PrioritySelect ( DdManager dd,
DdNode R,
DdNode **  x,
DdNode **  y,
DdNode **  z,
DdNode Pi,
int  n,
DdNode *)(DdManager *, int, DdNode **, DdNode **, DdNode ** 
)
void Cudd_Quit ( DdManager unique)

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

Synopsis [Deletes resources associated with a DD manager.]

Description [Deletes resources associated with a DD manager and resets the global statistical counters. (Otherwise, another manaqger subsequently created would inherit the stats of this one.)]

SideEffects [None]

SeeAlso [Cudd_Init]

Definition at line 225 of file cuddInit.c.

227 {
228  if (unique->stash != NULL) ABC_FREE(unique->stash);
229  cuddFreeTable(unique);
230 
231 } /* end of Cudd_Quit */
char * stash
Definition: cuddInt.h:399
#define ABC_FREE(obj)
Definition: abc_global.h:232
void cuddFreeTable(DdManager *unique)
Definition: cuddTable.c:659
long Cudd_Random ( void  )

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

Synopsis [Portable random number generator.]

Description [Portable number generator based on ran2 from "Numerical Recipes in C." It is a long period (> 2 * 10^18) random number generator of L'Ecuyer with Bays-Durham shuffle. Returns a long integer uniformly distributed between 0 and 2147483561 (inclusive of the endpoint values). The random generator can be explicitly initialized by calling Cudd_Srandom. If no explicit initialization is performed, then the seed 1 is assumed.]

SideEffects [None]

SeeAlso [Cudd_Srandom]

Definition at line 2702 of file cuddUtil.c.

2703 {
2704  int i; /* index in the shuffle table */
2705  long int w; /* work variable */
2706 
2707  /* cuddRand == 0 if the geneartor has not been initialized yet. */
2708  if (cuddRand == 0) Cudd_Srandom(1);
2709 
2710  /* Compute cuddRand = (cuddRand * LEQA1) % MODULUS1 avoiding
2711  ** overflows by Schrage's method.
2712  */
2713  w = cuddRand / LEQQ1;
2714  cuddRand = LEQA1 * (cuddRand - w * LEQQ1) - w * LEQR1;
2715  cuddRand += (cuddRand < 0) * MODULUS1;
2716 
2717  /* Compute cuddRand2 = (cuddRand2 * LEQA2) % MODULUS2 avoiding
2718  ** overflows by Schrage's method.
2719  */
2720  w = cuddRand2 / LEQQ2;
2721  cuddRand2 = LEQA2 * (cuddRand2 - w * LEQQ2) - w * LEQR2;
2722  cuddRand2 += (cuddRand2 < 0) * MODULUS2;
2723 
2724  /* cuddRand is shuffled with the Bays-Durham algorithm.
2725  ** shuffleSelect and cuddRand2 are combined to generate the output.
2726  */
2727 
2728  /* Pick one element from the shuffle table; "i" will be in the range
2729  ** from 0 to STAB_SIZE-1.
2730  */
2731  i = (int) (shuffleSelect / STAB_DIV);
2732  /* Mix the element of the shuffle table with the current iterate of
2733  ** the second sub-generator, and replace the chosen element of the
2734  ** shuffle table with the current iterate of the first sub-generator.
2735  */
2737  shuffleTable[i] = cuddRand;
2738  shuffleSelect += (shuffleSelect < 1) * (MODULUS1 - 1);
2739  /* Since shuffleSelect != 0, and we want to be able to return 0,
2740  ** here we subtract 1 before returning.
2741  */
2742  return(shuffleSelect - 1);
2743 
2744 } /* end of Cudd_Random */
void Cudd_Srandom(long seed)
Definition: cuddUtil.c:2764
#define LEQQ1
Definition: cuddUtil.c:122
#define LEQQ2
Definition: cuddUtil.c:126
#define MODULUS1
Definition: cuddUtil.c:120
#define LEQR2
Definition: cuddUtil.c:127
static long shuffleSelect
Definition: cuddUtil.c:152
static long shuffleTable[STAB_SIZE]
Definition: cuddUtil.c:153
static long cuddRand
Definition: cuddUtil.c:150
#define LEQA2
Definition: cuddUtil.c:125
#define LEQR1
Definition: cuddUtil.c:123
#define STAB_DIV
Definition: cuddUtil.c:129
static long cuddRand2
Definition: cuddUtil.c:151
#define MODULUS2
Definition: cuddUtil.c:124
#define LEQA1
Definition: cuddUtil.c:121
int Cudd_ReadArcviolation ( DdManager dd)

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

Synopsis [Returns the current value of the arcviolation parameter used in group sifting.]

Description [Returns the current value of the arcviolation parameter. This parameter is used in group sifting to decide how many arcs into y not coming from x are tolerable when checking for aggregation due to extended symmetry. The value should be between 0 and 100. A small value causes fewer variables to be aggregated. The default value is 0.]

SideEffects [None]

SeeAlso [Cudd_SetArcviolation]

Definition at line 2764 of file cuddAPI.c.

2766 {
2767  return(dd->arcviolation);
2768 
2769 } /* end of Cudd_ReadArcviolation */
int arcviolation
Definition: cuddInt.h:429
DdNode* Cudd_ReadBackground ( DdManager dd)

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

Synopsis [Reads the background constant of the manager.]

Description []

SideEffects [None]

Definition at line 1112 of file cuddAPI.c.

1114 {
1115  return(dd->background);
1116 
1117 } /* end of Cudd_ReadBackground */
DdNode * background
Definition: cuddInt.h:349
double Cudd_ReadCacheHits ( DdManager dd)

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

Synopsis [Returns the number of cache hits.]

Description []

SideEffects [None]

SeeAlso [Cudd_ReadCacheLookUps]

Definition at line 1225 of file cuddAPI.c.

1227 {
1228  return(dd->cacheHits + dd->totCachehits);
1229 
1230 } /* end of Cudd_ReadCacheHits */
double cacheHits
Definition: cuddInt.h:356
double totCachehits
Definition: cuddInt.h:455
double Cudd_ReadCacheLookUps ( DdManager dd)

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

Synopsis [Returns the number of cache look-ups.]

Description [Returns the number of cache look-ups.]

SideEffects [None]

SeeAlso [Cudd_ReadCacheHits]

Definition at line 1204 of file cuddAPI.c.

1206 {
1207  return(dd->cacheHits + dd->cacheMisses +
1208  dd->totCachehits + dd->totCacheMisses);
1209 
1210 } /* end of Cudd_ReadCacheLookUps */
double totCacheMisses
Definition: cuddInt.h:456
double cacheHits
Definition: cuddInt.h:356
double cacheMisses
Definition: cuddInt.h:355
double totCachehits
Definition: cuddInt.h:455
unsigned int Cudd_ReadCacheSlots ( DdManager dd)

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

Synopsis [Reads the number of slots in the cache.]

Description []

SideEffects [None]

SeeAlso [Cudd_ReadCacheUsedSlots]

Definition at line 1152 of file cuddAPI.c.

1154 {
1155  return(dd->cacheSlots);
1156 
1157 } /* end of Cudd_ReadCacheSlots */
unsigned int cacheSlots
Definition: cuddInt.h:353
double Cudd_ReadCacheUsedSlots ( DdManager dd)

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

Synopsis [Reads the fraction of used slots in the cache.]

Description [Reads the fraction of used slots in the cache. The unused slots are those in which no valid data is stored. Garbage collection, variable reordering, and cache resizing may cause used slots to become unused.]

SideEffects [None]

SeeAlso [Cudd_ReadCacheSlots]

Definition at line 1175 of file cuddAPI.c.

1177 {
1178  unsigned long used = 0;
1179  int slots = dd->cacheSlots;
1180  DdCache *cache = dd->cache;
1181  int i;
1182 
1183  for (i = 0; i < slots; i++) {
1184  used += cache[i].h != 0;
1185  }
1186 
1187  return((double)used / (double) dd->cacheSlots);
1188 
1189 } /* end of Cudd_ReadCacheUsedSlots */
ptruint h
Definition: cuddInt.h:318
unsigned int cacheSlots
Definition: cuddInt.h:353
DdCache * cache
Definition: cuddInt.h:352
unsigned int Cudd_ReadDead ( DdManager dd)

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

Synopsis [Returns the number of dead nodes in the unique table.]

Description []

SideEffects [None]

SeeAlso [Cudd_ReadKeys]

Definition at line 1646 of file cuddAPI.c.

1648 {
1649  return(dd->dead);
1650 
1651 } /* end of Cudd_ReadDead */
unsigned int dead
Definition: cuddInt.h:371
CUDD_VALUE_TYPE Cudd_ReadEpsilon ( DdManager dd)

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

Synopsis [Reads the epsilon parameter of the manager.]

Description [Reads the epsilon parameter of the manager. The epsilon parameter control the comparison between floating point numbers.]

SideEffects [None]

SeeAlso [Cudd_SetEpsilon]

Definition at line 2430 of file cuddAPI.c.

2432 {
2433  return(dd->epsilon);
2434 
2435 } /* end of Cudd_ReadEpsilon */
CUDD_VALUE_TYPE epsilon
Definition: cuddInt.h:407
Cudd_ErrorType Cudd_ReadErrorCode ( DdManager dd)

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

Synopsis [Returns the code of the last error.]

Description [Returns the code of the last error. The error codes are defined in cudd.h.]

SideEffects [None]

SeeAlso [Cudd_ClearErrorCode]

Definition at line 3612 of file cuddAPI.c.

3614 {
3615  return(dd->errorCode);
3616 
3617 } /* end of Cudd_ReadErrorCode */
Cudd_ErrorType errorCode
Definition: cuddInt.h:447
int Cudd_ReadGarbageCollections ( DdManager dd)

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

Synopsis [Returns the number of times garbage collection has occurred.]

Description [Returns the number of times garbage collection has occurred in the manager. The number includes both the calls from reordering procedures and those caused by requests to create new nodes.]

SideEffects [None]

SeeAlso [Cudd_ReadGarbageCollectionTime]

Definition at line 1741 of file cuddAPI.c.

1743 {
1744  return(dd->garbageCollections);
1745 
1746 } /* end of Cudd_ReadGarbageCollections */
int garbageCollections
Definition: cuddInt.h:452
long Cudd_ReadGarbageCollectionTime ( DdManager dd)

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

Synopsis [Returns the time spent in garbage collection.]

Description [Returns the number of milliseconds spent doing garbage collection since the manager was initialized.]

SideEffects [None]

SeeAlso [Cudd_ReadGarbageCollections]

Definition at line 1762 of file cuddAPI.c.

1764 {
1765  return(dd->GCTime);
1766 
1767 } /* end of Cudd_ReadGarbageCollectionTime */
long GCTime
Definition: cuddInt.h:453
Cudd_AggregationType Cudd_ReadGroupcheck ( DdManager dd)

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

Synopsis [Reads the groupcheck parameter of the manager.]

Description [Reads the groupcheck parameter of the manager. The groupcheck parameter determines the aggregation criterion in group sifting.]

SideEffects [None]

SeeAlso [Cudd_SetGroupcheck]

Definition at line 2474 of file cuddAPI.c.

2476 {
2477  return(dd->groupcheck);
2478 
2479 } /* end of Cudd_ReadGroupCheck */
Cudd_AggregationType groupcheck
Definition: cuddInt.h:426
int Cudd_ReadInvPerm ( DdManager dd,
int  i 
)

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

Synopsis [Returns the index of the variable currently in the i-th position of the order.]

Description [Returns the index of the variable currently in the i-th position of the order. If the index is CUDD_CONST_INDEX, returns CUDD_CONST_INDEX; otherwise, if the index is out of bounds returns -1.]

SideEffects [None]

SeeAlso [Cudd_ReadPerm Cudd_ReadInvPermZdd]

Definition at line 2354 of file cuddAPI.c.

2357 {
2358  if (i == CUDD_CONST_INDEX) return(CUDD_CONST_INDEX);
2359  if (i < 0 || i >= dd->size) return(-1);
2360  return(dd->invperm[i]);
2361 
2362 } /* end of Cudd_ReadInvPerm */
int size
Definition: cuddInt.h:361
#define CUDD_CONST_INDEX
Definition: cudd.h:117
int * invperm
Definition: cuddInt.h:388
int Cudd_ReadInvPermZdd ( DdManager dd,
int  i 
)

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

Synopsis [Returns the index of the ZDD variable currently in the i-th position of the order.]

Description [Returns the index of the ZDD variable currently in the i-th position of the order. If the index is CUDD_CONST_INDEX, returns CUDD_CONST_INDEX; otherwise, if the index is out of bounds returns -1.]

SideEffects [None]

SeeAlso [Cudd_ReadPerm Cudd_ReadInvPermZdd]

Definition at line 2380 of file cuddAPI.c.

2383 {
2384  if (i == CUDD_CONST_INDEX) return(CUDD_CONST_INDEX);
2385  if (i < 0 || i >= dd->sizeZ) return(-1);
2386  return(dd->invpermZ[i]);
2387 
2388 } /* end of Cudd_ReadInvPermZdd */
int * invpermZ
Definition: cuddInt.h:389
#define CUDD_CONST_INDEX
Definition: cudd.h:117
int sizeZ
Definition: cuddInt.h:362
int Cudd_ReadIthClause ( DdTlcInfo tlc,
int  i,
DdHalfWord var1,
DdHalfWord var2,
int *  phase1,
int *  phase2 
)

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

Synopsis [Accesses the i-th clause of a DD.]

Description [Accesses the i-th clause of a DD given the clause set which must be already computed. Returns 1 if successful; 0 if i is out of range, or in case of error.]

SideEffects [the four components of a clause are returned as side effects.]

SeeAlso [Cudd_FindTwoLiteralClauses]

Definition at line 359 of file cuddEssent.c.

366 {
367  if (tlc == NULL) return(0);
368  if (tlc->vars == NULL || tlc->phases == NULL) return(0);
369  if (i < 0 || (unsigned) i >= tlc->cnt) return(0);
370  *var1 = tlc->vars[2*i];
371  *var2 = tlc->vars[2*i+1];
372  *phase1 = (int) bitVectorRead(tlc->phases, 2*i);
373  *phase2 = (int) bitVectorRead(tlc->phases, 2*i+1);
374  return(1);
375 
376 } /* end of Cudd_ReadIthClause */
static const int var1
Definition: satSolver.c:77
DdHalfWord * vars
Definition: cuddEssent.c:123
long * phases
Definition: cuddEssent.c:124
DdHalfWord cnt
Definition: cuddEssent.c:125
static DD_INLINE short bitVectorRead(BitVector *vector, int i)
Definition: cuddEssent.c:1404
unsigned int Cudd_ReadKeys ( DdManager dd)

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

Synopsis [Returns the number of nodes in the unique table.]

Description [Returns the total number of nodes currently in the unique table, including the dead nodes.]

SideEffects [None]

SeeAlso [Cudd_ReadDead]

Definition at line 1626 of file cuddAPI.c.

1628 {
1629  return(dd->keys);
1630 
1631 } /* end of Cudd_ReadKeys */
unsigned int keys
Definition: cuddInt.h:369
int Cudd_ReadLinear ( DdManager table,
int  x,
int  y 
)

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

Synopsis [Reads an entry of the linear transform matrix.]

Description [Reads an entry of the linear transform matrix.]

SideEffects [none]

SeeAlso []

Definition at line 191 of file cuddLinear.c.

195 {
196  int nvars = table->size;
197  int wordsPerRow = ((nvars - 1) >> LOGBPL) + 1;
198  long word;
199  int bit;
200  int result;
201 
202  assert(table->size == table->linearSize);
203 
204  word = wordsPerRow * x + (y >> LOGBPL);
205  bit = y & (BPL-1);
206  result = (int) ((table->linear[word] >> bit) & 1);
207  return(result);
208 
209 } /* end of Cudd_ReadLinear */
#define BPL
Definition: cuddLinear.c:82
int size
Definition: cuddInt.h:361
#define LOGBPL
Definition: cuddLinear.c:83
unsigned __int64 word
DECLARATIONS ///.
Definition: kitPerm.c:36
long * linear
Definition: cuddInt.h:395
int linearSize
Definition: cuddInt.h:393
#define assert(ex)
Definition: util_old.h:213
static int result
Definition: cuddGenetic.c:125
DdNode* Cudd_ReadLogicZero ( DdManager dd)

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

Synopsis [Returns the logic zero constant of the manager.]

Description [Returns the zero constant of the manager. The logic zero constant is the complement of the one constant, and is distinct from the arithmetic zero.]

SideEffects [None]

SeeAlso [Cudd_ReadOne Cudd_ReadZero]

Definition at line 1058 of file cuddAPI.c.

1060 {
1061  return(Cudd_Not(DD_ONE(dd)));
1062 
1063 } /* end of Cudd_ReadLogicZero */
#define Cudd_Not(node)
Definition: cudd.h:367
#define DD_ONE(dd)
Definition: cuddInt.h:911
unsigned int Cudd_ReadLooseUpTo ( DdManager dd)

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

Synopsis [Reads the looseUpTo parameter of the manager.]

Description []

SideEffects [None]

SeeAlso [Cudd_SetLooseUpTo Cudd_ReadMinHit Cudd_ReadMinDead]

Definition at line 1321 of file cuddAPI.c.

1323 {
1324  return(dd->looseUpTo);
1325 
1326 } /* end of Cudd_ReadLooseUpTo */
unsigned int looseUpTo
Definition: cuddInt.h:377
unsigned int Cudd_ReadMaxCache ( DdManager dd)

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

Synopsis [Returns the soft limit for the cache size.]

Description [Returns the soft limit for the cache size. The soft limit]

SideEffects [None]

SeeAlso [Cudd_ReadMaxCache]

Definition at line 1371 of file cuddAPI.c.

1373 {
1374  return(2 * dd->cacheSlots + dd->cacheSlack);
1375 
1376 } /* end of Cudd_ReadMaxCache */
unsigned int cacheSlots
Definition: cuddInt.h:353
int cacheSlack
Definition: cuddInt.h:358
unsigned int Cudd_ReadMaxCacheHard ( DdManager dd)

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

Synopsis [Reads the maxCacheHard parameter of the manager.]

Description []

SideEffects [None]

SeeAlso [Cudd_SetMaxCacheHard Cudd_ReadMaxCache]

Definition at line 1391 of file cuddAPI.c.

1393 {
1394  return(dd->maxCacheHard);
1395 
1396 } /* end of Cudd_ReadMaxCache */
unsigned int maxCacheHard
Definition: cuddInt.h:359
double Cudd_ReadMaxGrowth ( DdManager dd)

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

Synopsis [Reads the maxGrowth parameter of the manager.]

Description [Reads the maxGrowth parameter of the manager. This parameter determines how much the number of nodes can grow during sifting of a variable. Overall, sifting never increases the size of the decision diagrams. This parameter only refers to intermediate results. A lower value will speed up sifting, possibly at the expense of quality.]

SideEffects [None]

SeeAlso [Cudd_SetMaxGrowth Cudd_ReadMaxGrowthAlternate]

Definition at line 1988 of file cuddAPI.c.

1990 {
1991  return(dd->maxGrowth);
1992 
1993 } /* end of Cudd_ReadMaxGrowth */
double maxGrowth
Definition: cuddInt.h:413
double Cudd_ReadMaxGrowthAlternate ( DdManager dd)

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

Synopsis [Reads the maxGrowthAlt parameter of the manager.]

Description [Reads the maxGrowthAlt parameter of the manager. This parameter is analogous to the maxGrowth paramter, and is used every given number of reorderings instead of maxGrowth. The number of reorderings is set with Cudd_SetReorderingCycle. If the number of reorderings is 0 (default) maxGrowthAlt is never used.]

SideEffects [None]

SeeAlso [Cudd_ReadMaxGrowth Cudd_SetMaxGrowthAlternate Cudd_SetReorderingCycle Cudd_ReadReorderingCycle]

Definition at line 2039 of file cuddAPI.c.

2041 {
2042  return(dd->maxGrowthAlt);
2043 
2044 } /* end of Cudd_ReadMaxGrowthAlternate */
double maxGrowthAlt
Definition: cuddInt.h:414
unsigned int Cudd_ReadMaxLive ( DdManager dd)

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

Synopsis [Reads the maximum allowed number of live nodes.]

Description [Reads the maximum allowed number of live nodes. When this number is exceeded, the package returns NULL.]

SideEffects [none]

SeeAlso [Cudd_SetMaxLive]

Definition at line 3812 of file cuddAPI.c.

3814 {
3815  return(dd->maxLive);
3816 
3817 } /* end of Cudd_ReadMaxLive */
unsigned int maxLive
Definition: cuddInt.h:373
unsigned long Cudd_ReadMaxMemory ( DdManager dd)

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

Synopsis [Reads the maximum allowed memory.]

Description [Reads the maximum allowed memory. When this number is exceeded, the package returns NULL.]

SideEffects [none]

SeeAlso [Cudd_SetMaxMemory]

Definition at line 3855 of file cuddAPI.c.

3857 {
3858  return(dd->maxmemhard);
3859 
3860 } /* end of Cudd_ReadMaxMemory */
unsigned long maxmemhard
Definition: cuddInt.h:451
unsigned long Cudd_ReadMemoryInUse ( DdManager dd)

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

Synopsis [Returns the memory in use by the manager measured in bytes.]

Description []

SideEffects [None]

SeeAlso []

Definition at line 2916 of file cuddAPI.c.

2918 {
2919  return(dd->memused);
2920 
2921 } /* end of Cudd_ReadMemoryInUse */
unsigned long memused
Definition: cuddInt.h:449
unsigned int Cudd_ReadMinDead ( DdManager dd)

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

Synopsis [Reads the minDead parameter of the manager.]

Description [Reads the minDead parameter of the manager. The minDead parameter is used by the package to decide whether to collect garbage or resize a subtable of the unique table when the subtable becomes too full. The application can indirectly control the value of minDead by setting the looseUpTo parameter.]

SideEffects [None]

SeeAlso [Cudd_ReadDead Cudd_ReadLooseUpTo Cudd_SetLooseUpTo]

Definition at line 1670 of file cuddAPI.c.

1672 {
1673  return(dd->minDead);
1674 
1675 } /* end of Cudd_ReadMinDead */
unsigned int minDead
Definition: cuddInt.h:374
unsigned int Cudd_ReadMinHit ( DdManager dd)

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

Synopsis [Reads the hit rate that causes resizinig of the computed table.]

Description []

SideEffects [None]

SeeAlso [Cudd_SetMinHit]

Definition at line 1272 of file cuddAPI.c.

1274 {
1275  /* Internally, the package manipulates the ratio of hits to
1276  ** misses instead of the ratio of hits to accesses. */
1277  return((unsigned int) (0.5 + 100 * dd->minHit / (1 + dd->minHit)));
1278 
1279 } /* end of Cudd_ReadMinHit */
double minHit
Definition: cuddInt.h:357
DdNode* Cudd_ReadMinusInfinity ( DdManager dd)

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

Synopsis [Reads the minus-infinity constant from the manager.]

Description []

SideEffects [None]

Definition at line 1094 of file cuddAPI.c.

1096 {
1097  return(dd->minusinfinity);
1098 
1099 } /* end of Cudd_ReadMinusInfinity */
DdNode * minusinfinity
Definition: cuddInt.h:348
unsigned int Cudd_ReadNextReordering ( DdManager dd)

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

Synopsis [Returns the threshold for the next dynamic reordering.]

Description [Returns the threshold for the next dynamic reordering. The threshold is in terms of number of nodes and is in effect only if reordering is enabled. The count does not include the dead nodes, unless the countDead parameter of the manager has been changed from its default setting.]

SideEffects [None]

SeeAlso [Cudd_SetNextReordering]

Definition at line 3742 of file cuddAPI.c.

3744 {
3745  return(dd->nextDyn);
3746 
3747 } /* end of Cudd_ReadNextReordering */
unsigned int nextDyn
Definition: cuddInt.h:422
long Cudd_ReadNodeCount ( DdManager dd)

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

Synopsis [Reports the number of nodes in BDDs and ADDs.]

Description [Reports the number of live nodes in BDDs and ADDs. This number does not include the isolated projection functions and the unused constants. These nodes that are not counted are not part of the DDs manipulated by the application.]

SideEffects [None]

SeeAlso [Cudd_ReadPeakNodeCount Cudd_zddReadNodeCount]

Definition at line 3179 of file cuddAPI.c.

3181 {
3182  long count;
3183  int i;
3184 
3185 #ifndef DD_NO_DEATH_ROW
3186  cuddClearDeathRow(dd);
3187 #endif
3188 
3189  count = (long) (dd->keys - dd->dead);
3190 
3191  /* Count isolated projection functions. Their number is subtracted
3192  ** from the node count because they are not part of the BDDs.
3193  */
3194  for (i=0; i < dd->size; i++) {
3195  if (dd->vars[i]->ref == 1) count--;
3196  }
3197  /* Subtract from the count the unused constants. */
3198  if (DD_ZERO(dd)->ref == 1) count--;
3199  if (DD_PLUS_INFINITY(dd)->ref == 1) count--;
3200  if (DD_MINUS_INFINITY(dd)->ref == 1) count--;
3201 
3202  return(count);
3203 
3204 } /* end of Cudd_ReadNodeCount */
DdHalfWord ref
Definition: cudd.h:280
int size
Definition: cuddInt.h:361
#define DD_MINUS_INFINITY(dd)
Definition: cuddInt.h:955
unsigned int dead
Definition: cuddInt.h:371
unsigned int keys
Definition: cuddInt.h:369
void cuddClearDeathRow(DdManager *table)
Definition: cuddRef.c:726
DdNode ** vars
Definition: cuddInt.h:390
#define DD_PLUS_INFINITY(dd)
Definition: cuddInt.h:941
#define DD_ZERO(dd)
Definition: cuddInt.h:927
double Cudd_ReadNodesDropped ( DdManager dd)

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

Synopsis [Returns the number of nodes dropped.]

Description [Returns the number of nodes killed by dereferencing if the keeping of this statistic is enabled; -1 otherwise. This statistic is enabled only if the package is compiled with DD_STATS defined.]

SideEffects [None]

SeeAlso [Cudd_ReadNodesFreed]

Definition at line 1810 of file cuddAPI.c.

1812 {
1813 #ifdef DD_STATS
1814  return(dd->nodesDropped);
1815 #else
1816  return(-1.0);
1817 #endif
1818 
1819 } /* end of Cudd_ReadNodesDropped */
double Cudd_ReadNodesFreed ( DdManager dd)

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

Synopsis [Returns the number of nodes freed.]

Description [Returns the number of nodes returned to the free list if the keeping of this statistic is enabled; -1 otherwise. This statistic is enabled only if the package is compiled with DD_STATS defined.]

SideEffects [None]

SeeAlso [Cudd_ReadNodesDropped]

Definition at line 1784 of file cuddAPI.c.

1786 {
1787 #ifdef DD_STATS
1788  return(dd->nodesFreed);
1789 #else
1790  return(-1.0);
1791 #endif
1792 
1793 } /* end of Cudd_ReadNodesFreed */
int Cudd_ReadNumberXovers ( DdManager dd)

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

Synopsis [Reads the current number of crossovers used by the genetic algorithm for reordering.]

Description [Reads the current number of crossovers used by the genetic algorithm for variable reordering. A larger number of crossovers will cause the genetic algorithm to take more time, but will generally produce better results. The default value is 0, in which case the package uses three times the number of variables as number of crossovers, with a maximum of 60.]

SideEffects [None]

SeeAlso [Cudd_SetNumberXovers]

Definition at line 2870 of file cuddAPI.c.

2872 {
2873  return(dd->numberXovers);
2874 
2875 } /* end of Cudd_ReadNumberXovers */
int numberXovers
Definition: cuddInt.h:431
DdNode* Cudd_ReadOne ( DdManager dd)

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

Synopsis [Returns the one constant of the manager.]

Description [Returns the one constant of the manager. The one constant is common to ADDs and BDDs.]

SideEffects [None]

SeeAlso [Cudd_ReadZero Cudd_ReadLogicZero Cudd_ReadZddOne]

Definition at line 987 of file cuddAPI.c.

989 {
990  return(dd->one);
991 
992 } /* end of Cudd_ReadOne */
DdNode * one
Definition: cuddInt.h:345
int Cudd_ReadPeakLiveNodeCount ( DdManager dd)

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

Synopsis [Reports the peak number of live nodes.]

Description [Reports the peak number of live nodes. This count is kept only if CUDD is compiled with DD_STATS defined. If DD_STATS is not defined, this function returns -1.]

SideEffects [None]

SeeAlso [Cudd_ReadNodeCount Cudd_PrintInfo Cudd_ReadPeakNodeCount]

Definition at line 3151 of file cuddAPI.c.

3153 {
3154  unsigned int live = dd->keys - dd->dead;
3155 
3156  if (live > dd->peakLiveNodes) {
3157  dd->peakLiveNodes = live;
3158  }
3159  return((int)dd->peakLiveNodes);
3160 
3161 } /* end of Cudd_ReadPeakLiveNodeCount */
unsigned int peakLiveNodes
Definition: cuddInt.h:465
unsigned int dead
Definition: cuddInt.h:371
unsigned int keys
Definition: cuddInt.h:369
long Cudd_ReadPeakNodeCount ( DdManager dd)

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

Synopsis [Reports the peak number of nodes.]

Description [Reports the peak number of nodes. This number includes node on the free list. At the peak, the number of nodes on the free list is guaranteed to be less than DD_MEM_CHUNK.]

SideEffects [None]

SeeAlso [Cudd_ReadNodeCount Cudd_PrintInfo]

Definition at line 3122 of file cuddAPI.c.

3124 {
3125  long count = 0;
3126  DdNodePtr *scan = dd->memoryList;
3127 
3128  while (scan != NULL) {
3129  count += DD_MEM_CHUNK;
3130  scan = (DdNodePtr *) *scan;
3131  }
3132  return(count);
3133 
3134 } /* end of Cudd_ReadPeakNodeCount */
Definition: cudd.h:278
DdNode ** memoryList
Definition: cuddInt.h:397
#define DD_MEM_CHUNK
Definition: cuddInt.h:104
int Cudd_ReadPerm ( DdManager dd,
int  i 
)

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

Synopsis [Returns the current position of the i-th variable in the order.]

Description [Returns the current position of the i-th variable in the order. If the index is CUDD_CONST_INDEX, returns CUDD_CONST_INDEX; otherwise, if the index is out of bounds returns -1.]

SideEffects [None]

SeeAlso [Cudd_ReadInvPerm Cudd_ReadPermZdd]

Definition at line 2301 of file cuddAPI.c.

2304 {
2305  if (i == CUDD_CONST_INDEX) return(CUDD_CONST_INDEX);
2306  if (i < 0 || i >= dd->size) return(-1);
2307  return(dd->perm[i]);
2308 
2309 } /* end of Cudd_ReadPerm */
int size
Definition: cuddInt.h:361
#define CUDD_CONST_INDEX
Definition: cudd.h:117
int * perm
Definition: cuddInt.h:386
int Cudd_ReadPermZdd ( DdManager dd,
int  i 
)

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

Synopsis [Returns the current position of the i-th ZDD variable in the order.]

Description [Returns the current position of the i-th ZDD variable in the order. If the index is CUDD_CONST_INDEX, returns CUDD_CONST_INDEX; otherwise, if the index is out of bounds returns -1.]

SideEffects [None]

SeeAlso [Cudd_ReadInvPermZdd Cudd_ReadPerm]

Definition at line 2328 of file cuddAPI.c.

2331 {
2332  if (i == CUDD_CONST_INDEX) return(CUDD_CONST_INDEX);
2333  if (i < 0 || i >= dd->sizeZ) return(-1);
2334  return(dd->permZ[i]);
2335 
2336 } /* end of Cudd_ReadPermZdd */
int * permZ
Definition: cuddInt.h:387
#define CUDD_CONST_INDEX
Definition: cudd.h:117
int sizeZ
Definition: cuddInt.h:362
DdNode* Cudd_ReadPlusInfinity ( DdManager dd)

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

Synopsis [Reads the plus-infinity constant from the manager.]

Description []

SideEffects [None]

Definition at line 1076 of file cuddAPI.c.

1078 {
1079  return(dd->plusinfinity);
1080 
1081 } /* end of Cudd_ReadPlusInfinity */
DdNode * plusinfinity
Definition: cuddInt.h:347
int Cudd_ReadPopulationSize ( DdManager dd)

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

Synopsis [Reads the current size of the population used by the genetic algorithm for reordering.]

Description [Reads the current size of the population used by the genetic algorithm for variable reordering. A larger population size will cause the genetic algorithm to take more time, but will generally produce better results. The default value is 0, in which case the package uses three times the number of variables as population size, with a maximum of 120.]

SideEffects [None]

SeeAlso [Cudd_SetPopulationSize]

Definition at line 2817 of file cuddAPI.c.

2819 {
2820  return(dd->populationSize);
2821 
2822 } /* end of Cudd_ReadPopulationSize */
int populationSize
Definition: cuddInt.h:430
int Cudd_ReadRecomb ( DdManager dd)

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

Synopsis [Returns the current value of the recombination parameter used in group sifting.]

Description [Returns the current value of the recombination parameter used in group sifting. A larger (positive) value makes the aggregation of variables due to the second difference criterion more likely. A smaller (negative) value makes aggregation less likely.]

SideEffects [None]

SeeAlso [Cudd_SetRecomb]

Definition at line 2657 of file cuddAPI.c.

2659 {
2660  return(dd->recomb);
2661 
2662 } /* end of Cudd_ReadRecomb */
int recomb
Definition: cuddInt.h:427
double Cudd_ReadRecursiveCalls ( DdManager dd)

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

Synopsis [Returns the number of recursive calls.]

Description [Returns the number of recursive calls if the package is compiled with DD_COUNT defined.]

SideEffects [None]

SeeAlso []

Definition at line 1246 of file cuddAPI.c.

1248 {
1249 #ifdef DD_COUNT
1250  return(dd->recursiveCalls);
1251 #else
1252  return(-1.0);
1253 #endif
1254 
1255 } /* end of Cudd_ReadRecursiveCalls */
int Cudd_ReadReorderingCycle ( DdManager dd)

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

Synopsis [Reads the reordCycle parameter of the manager.]

Description [Reads the reordCycle parameter of the manager. This parameter determines how often the alternate threshold on maximum growth is used in reordering.]

SideEffects [None]

SeeAlso [Cudd_ReadMaxGrowthAlternate Cudd_SetMaxGrowthAlternate Cudd_SetReorderingCycle]

Definition at line 2088 of file cuddAPI.c.

2090 {
2091  return(dd->reordCycle);
2092 
2093 } /* end of Cudd_ReadReorderingCycle */
int reordCycle
Definition: cuddInt.h:415
int Cudd_ReadReorderings ( DdManager dd)

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

Synopsis [Returns the number of times reordering has occurred.]

Description [Returns the number of times reordering has occurred in the manager. The number includes both the calls to Cudd_ReduceHeap from the application program and those automatically performed by the package. However, calls that do not even initiate reordering are not counted. A call may not initiate reordering if there are fewer than minsize live nodes in the manager, or if CUDD_REORDER_NONE is specified as reordering method. The calls to Cudd_ShuffleHeap are not counted.]

SideEffects [None]

SeeAlso [Cudd_ReduceHeap Cudd_ReadReorderingTime]

Definition at line 1696 of file cuddAPI.c.

1698 {
1699  return(dd->reorderings);
1700 
1701 } /* end of Cudd_ReadReorderings */
int reorderings
Definition: cuddInt.h:410
long Cudd_ReadReorderingTime ( DdManager dd)

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

Synopsis [Returns the time spent in reordering.]

Description [Returns the number of milliseconds spent reordering variables since the manager was initialized. The time spent in collecting garbage before reordering is included.]

SideEffects [None]

SeeAlso [Cudd_ReadReorderings]

Definition at line 1718 of file cuddAPI.c.

1720 {
1721  return(dd->reordTime);
1722 
1723 } /* end of Cudd_ReadReorderingTime */
long reordTime
Definition: cuddInt.h:454
int Cudd_ReadSiftMaxSwap ( DdManager dd)

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

Synopsis [Reads the siftMaxSwap parameter of the manager.]

Description [Reads the siftMaxSwap parameter of the manager. This parameter gives the maximum number of swaps that will be attempted for each invocation of sifting. The real number of swaps may exceed the set limit because the package will always complete the sifting of the variable that causes the limit to be reached.]

SideEffects [None]

SeeAlso [Cudd_ReadSiftMaxVar Cudd_SetSiftMaxSwap]

Definition at line 1938 of file cuddAPI.c.

1940 {
1941  return(dd->siftMaxSwap);
1942 
1943 } /* end of Cudd_ReadSiftMaxSwap */
int siftMaxSwap
Definition: cuddInt.h:412
int Cudd_ReadSiftMaxVar ( DdManager dd)

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

Synopsis [Reads the siftMaxVar parameter of the manager.]

Description [Reads the siftMaxVar parameter of the manager. This parameter gives the maximum number of variables that will be sifted for each invocation of sifting.]

SideEffects [None]

SeeAlso [Cudd_ReadSiftMaxSwap Cudd_SetSiftMaxVar]

Definition at line 1891 of file cuddAPI.c.

1893 {
1894  return(dd->siftMaxVar);
1895 
1896 } /* end of Cudd_ReadSiftMaxVar */
int siftMaxVar
Definition: cuddInt.h:411
int Cudd_ReadSize ( DdManager dd)

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

Synopsis [Returns the number of BDD variables in existance.]

Description []

SideEffects [None]

SeeAlso [Cudd_ReadZddSize]

Definition at line 1441 of file cuddAPI.c.

1443 {
1444  return(dd->size);
1445 
1446 } /* end of Cudd_ReadSize */
int size
Definition: cuddInt.h:361
unsigned int Cudd_ReadSlots ( DdManager dd)

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

Synopsis [Returns the total number of slots of the unique table.]

Description [Returns the total number of slots of the unique table. This number ismainly for diagnostic purposes.]

SideEffects [None]

Definition at line 1480 of file cuddAPI.c.

1482 {
1483  return(dd->slots);
1484 
1485 } /* end of Cudd_ReadSlots */
unsigned int slots
Definition: cuddInt.h:368
FILE* Cudd_ReadStderr ( DdManager dd)

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

Synopsis [Reads the stderr of a manager.]

Description [Reads the stderr of a manager. This is the file pointer to which messages normally going to stderr are written. It is initialized to stderr. Cudd_SetStderr allows the application to redirect it.]

SideEffects [None]

SeeAlso [Cudd_SetStderr Cudd_ReadStdout]

Definition at line 3697 of file cuddAPI.c.

3699 {
3700  return(dd->err);
3701 
3702 } /* end of Cudd_ReadStderr */
FILE * err
Definition: cuddInt.h:442
FILE* Cudd_ReadStdout ( DdManager dd)

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

Synopsis [Reads the stdout of a manager.]

Description [Reads the stdout of a manager. This is the file pointer to which messages normally going to stdout are written. It is initialized to stdout. Cudd_SetStdout allows the application to redirect it.]

SideEffects [None]

SeeAlso [Cudd_SetStdout Cudd_ReadStderr]

Definition at line 3654 of file cuddAPI.c.

3656 {
3657  return(dd->out);
3658 
3659 } /* end of Cudd_ReadStdout */
FILE * out
Definition: cuddInt.h:441
double Cudd_ReadSwapSteps ( DdManager dd)

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

Synopsis [Reads the number of elementary reordering steps.]

Description []

SideEffects [none]

SeeAlso []

Definition at line 3787 of file cuddAPI.c.

3789 {
3790 #ifdef DD_COUNT
3791  return(dd->swapSteps);
3792 #else
3793  return(-1);
3794 #endif
3795 
3796 } /* end of Cudd_ReadSwapSteps */
int Cudd_ReadSymmviolation ( DdManager dd)

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

Synopsis [Returns the current value of the symmviolation parameter used in group sifting.]

Description [Returns the current value of the symmviolation parameter. This parameter is used in group sifting to decide how many violations to the symmetry conditions f10 = f01 or f11 = f00 are tolerable when checking for aggregation due to extended symmetry. The value should be between 0 and 100. A small value causes fewer variables to be aggregated. The default value is 0.]

SideEffects [None]

SeeAlso [Cudd_SetSymmviolation]

Definition at line 2710 of file cuddAPI.c.

2712 {
2713  return(dd->symmviolation);
2714 
2715 } /* end of Cudd_ReadSymmviolation */
int symmviolation
Definition: cuddInt.h:428
MtrNode* Cudd_ReadTree ( DdManager dd)

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

Synopsis [Returns the variable group tree of the manager.]

Description []

SideEffects [None]

SeeAlso [Cudd_SetTree Cudd_FreeTree Cudd_ReadZddTree]

Definition at line 2132 of file cuddAPI.c.

2134 {
2135  return(dd->tree);
2136 
2137 } /* end of Cudd_ReadTree */
MtrNode * tree
Definition: cuddInt.h:424
double Cudd_ReadUniqueLinks ( DdManager dd)

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

Synopsis [Returns the number of links followed in the unique table.]

Description [Returns the number of links followed during look-ups in the unique table if the keeping of this statistic is enabled; -1 otherwise. If an item is found in the first position of its collision list, the number of links followed is taken to be 0. If it is in second position, the number of links is 1, and so on. This statistic is enabled only if the package is compiled with DD_UNIQUE_PROFILE defined.]

SideEffects [None]

SeeAlso [Cudd_ReadUniqueLookUps]

Definition at line 1865 of file cuddAPI.c.

1867 {
1868 #ifdef DD_UNIQUE_PROFILE
1869  return(dd->uniqueLinks);
1870 #else
1871  return(-1.0);
1872 #endif
1873 
1874 } /* end of Cudd_ReadUniqueLinks */
double Cudd_ReadUniqueLookUps ( DdManager dd)

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

Synopsis [Returns the number of look-ups in the unique table.]

Description [Returns the number of look-ups in the unique table if the keeping of this statistic is enabled; -1 otherwise. This statistic is enabled only if the package is compiled with DD_UNIQUE_PROFILE defined.]

SideEffects [None]

SeeAlso [Cudd_ReadUniqueLinks]

Definition at line 1836 of file cuddAPI.c.

1838 {
1839 #ifdef DD_UNIQUE_PROFILE
1840  return(dd->uniqueLookUps);
1841 #else
1842  return(-1.0);
1843 #endif
1844 
1845 } /* end of Cudd_ReadUniqueLookUps */
double Cudd_ReadUsedSlots ( DdManager dd)

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

Synopsis [Reads the fraction of used slots in the unique table.]

Description [Reads the fraction of used slots in the unique table. The unused slots are those in which no valid data is stored. Garbage collection, variable reordering, and subtable resizing may cause used slots to become unused.]

SideEffects [None]

SeeAlso [Cudd_ReadSlots]

Definition at line 1503 of file cuddAPI.c.

1505 {
1506  unsigned long used = 0;
1507  int i, j;
1508  int size = dd->size;
1509  DdNodePtr *nodelist;
1510  DdSubtable *subtable;
1511  DdNode *node;
1512  DdNode *sentinel = &(dd->sentinel);
1513 
1514  /* Scan each BDD/ADD subtable. */
1515  for (i = 0; i < size; i++) {
1516  subtable = &(dd->subtables[i]);
1517  nodelist = subtable->nodelist;
1518  for (j = 0; (unsigned) j < subtable->slots; j++) {
1519  node = nodelist[j];
1520  if (node != sentinel) {
1521  used++;
1522  }
1523  }
1524  }
1525 
1526  /* Scan the ZDD subtables. */
1527  size = dd->sizeZ;
1528 
1529  for (i = 0; i < size; i++) {
1530  subtable = &(dd->subtableZ[i]);
1531  nodelist = subtable->nodelist;
1532  for (j = 0; (unsigned) j < subtable->slots; j++) {
1533  node = nodelist[j];
1534  if (node != NULL) {
1535  used++;
1536  }
1537  }
1538  }
1539 
1540  /* Constant table. */
1541  subtable = &(dd->constants);
1542  nodelist = subtable->nodelist;
1543  for (j = 0; (unsigned) j < subtable->slots; j++) {
1544  node = nodelist[j];
1545  if (node != NULL) {
1546  used++;
1547  }
1548  }
1549 
1550  return((double)used / (double) dd->slots);
1551 
1552 } /* end of Cudd_ReadUsedSlots */
Definition: cudd.h:278
int size
Definition: cuddInt.h:361
unsigned int slots
Definition: cuddInt.h:368
DdSubtable * subtables
Definition: cuddInt.h:365
DdNode sentinel
Definition: cuddInt.h:344
DdNode ** nodelist
Definition: cuddInt.h:327
static int size
Definition: cuddSign.c:86
int sizeZ
Definition: cuddInt.h:362
DdSubtable constants
Definition: cuddInt.h:367
DdSubtable * subtableZ
Definition: cuddInt.h:366
DdNode* Cudd_ReadVars ( DdManager dd,
int  i 
)

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

Synopsis [Returns the i-th element of the vars array.]

Description [Returns the i-th element of the vars array if it falls within the array bounds; NULL otherwise. If i is the index of an existing variable, this function produces the same result as Cudd_bddIthVar. However, if the i-th var does not exist yet, Cudd_bddIthVar will create it, whereas Cudd_ReadVars will not.]

SideEffects [None]

SeeAlso [Cudd_bddIthVar]

Definition at line 2407 of file cuddAPI.c.

2410 {
2411  if (i < 0 || i > dd->size) return(NULL);
2412  return(dd->vars[i]);
2413 
2414 } /* end of Cudd_ReadVars */
int size
Definition: cuddInt.h:361
DdNode ** vars
Definition: cuddInt.h:390
DdNode* Cudd_ReadZddOne ( DdManager dd,
int  i 
)

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

Synopsis [Returns the ZDD for the constant 1 function.]

Description [Returns the ZDD for the constant 1 function. The representation of the constant 1 function as a ZDD depends on how many variables it (nominally) depends on. The index of the topmost variable in the support is given as argument i.]

SideEffects [None]

SeeAlso [Cudd_ReadOne]

Definition at line 1010 of file cuddAPI.c.

1013 {
1014  if (i < 0)
1015  return(NULL);
1016  return(i < dd->sizeZ ? dd->univ[i] : DD_ONE(dd));
1017 
1018 } /* end of Cudd_ReadZddOne */
#define DD_ONE(dd)
Definition: cuddInt.h:911
DdNode ** univ
Definition: cuddInt.h:392
int Cudd_ReadZddSize ( DdManager dd)

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

Synopsis [Returns the number of ZDD variables in existance.]

Description []

SideEffects [None]

SeeAlso [Cudd_ReadSize]

Definition at line 1461 of file cuddAPI.c.

1463 {
1464  return(dd->sizeZ);
1465 
1466 } /* end of Cudd_ReadZddSize */
int sizeZ
Definition: cuddInt.h:362
MtrNode* Cudd_ReadZddTree ( DdManager dd)

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

Synopsis [Returns the variable group tree of the manager.]

Description []

SideEffects [None]

SeeAlso [Cudd_SetZddTree Cudd_FreeZddTree Cudd_ReadTree]

Definition at line 2204 of file cuddAPI.c.

2206 {
2207  return(dd->treeZ);
2208 
2209 } /* end of Cudd_ReadZddTree */
MtrNode * treeZ
Definition: cuddInt.h:425
DdNode* Cudd_ReadZero ( DdManager dd)

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

Synopsis [Returns the zero constant of the manager.]

Description [Returns the zero constant of the manager. The zero constant is the arithmetic zero, rather than the logic zero. The latter is the complement of the one constant.]

SideEffects [None]

SeeAlso [Cudd_ReadOne Cudd_ReadLogicZero]

Definition at line 1036 of file cuddAPI.c.

1038 {
1039  return(DD_ZERO(dd));
1040 
1041 } /* end of Cudd_ReadZero */
#define DD_ZERO(dd)
Definition: cuddInt.h:927
void Cudd_RecursiveDeref ( DdManager table,
DdNode n 
)

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

Synopsis [Decreases the reference count of node n.]

Description [Decreases the reference count of node n. If n dies, recursively decreases the reference counts of its children. It is used to dispose of a DD that is no longer needed.]

SideEffects [None]

SeeAlso [Cudd_Deref Cudd_Ref Cudd_RecursiveDerefZdd]

Definition at line 154 of file cuddRef.c.

157 {
158  DdNode *N;
159  int ord;
160  DdNodePtr *stack = table->stack;
161  int SP = 1;
162 
163  unsigned int live = table->keys - table->dead;
164  if (live > table->peakLiveNodes) {
165  table->peakLiveNodes = live;
166  }
167 
168  N = Cudd_Regular(n);
169 
170  do {
171 #ifdef DD_DEBUG
172  assert(N->ref != 0);
173 #endif
174 
175  if (N->ref == 1) {
176  N->ref = 0;
177  table->dead++;
178 #ifdef DD_STATS
179  table->nodesDropped++;
180 #endif
181  if (cuddIsConstant(N)) {
182  table->constants.dead++;
183  N = stack[--SP];
184  } else {
185  ord = table->perm[N->index];
186  stack[SP++] = Cudd_Regular(cuddE(N));
187  table->subtables[ord].dead++;
188  N = cuddT(N);
189  }
190  } else {
191  cuddSatDec(N->ref);
192  N = stack[--SP];
193  }
194  } while (SP != 0);
195 
196 } /* end of Cudd_RecursiveDeref */
DdHalfWord ref
Definition: cudd.h:280
unsigned int peakLiveNodes
Definition: cuddInt.h:465
Definition: cudd.h:278
#define Cudd_Regular(node)
Definition: cudd.h:397
DdSubtable * subtables
Definition: cuddInt.h:365
DdNode ** stack
Definition: cuddInt.h:380
unsigned int dead
Definition: cuddInt.h:371
unsigned int keys
Definition: cuddInt.h:369
unsigned int dead
Definition: cuddInt.h:332
#define cuddIsConstant(node)
Definition: cuddInt.h:620
#define cuddT(node)
Definition: cuddInt.h:636
DdHalfWord index
Definition: cudd.h:279
#define cuddE(node)
Definition: cuddInt.h:652
#define cuddSatDec(x)
Definition: cuddInt.h:896
#define assert(ex)
Definition: util_old.h:213
DdSubtable constants
Definition: cuddInt.h:367
int * perm
Definition: cuddInt.h:386
void Cudd_RecursiveDerefZdd ( DdManager table,
DdNode n 
)

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

Synopsis [Decreases the reference count of ZDD node n.]

Description [Decreases the reference count of ZDD node n. If n dies, recursively decreases the reference counts of its children. It is used to dispose of a ZDD that is no longer needed.]

SideEffects [None]

SeeAlso [Cudd_Deref Cudd_Ref Cudd_RecursiveDeref]

Definition at line 385 of file cuddRef.c.

388 {
389  DdNode *N;
390  int ord;
391  DdNodePtr *stack = table->stack;
392  int SP = 1;
393 
394  N = n;
395 
396  do {
397 #ifdef DD_DEBUG
398  assert(N->ref != 0);
399 #endif
400 
401  cuddSatDec(N->ref);
402 
403  if (N->ref == 0) {
404  table->deadZ++;
405 #ifdef DD_STATS
406  table->nodesDropped++;
407 #endif
408 #ifdef DD_DEBUG
409  assert(!cuddIsConstant(N));
410 #endif
411  ord = table->permZ[N->index];
412  stack[SP++] = cuddE(N);
413  table->subtableZ[ord].dead++;
414  N = cuddT(N);
415  } else {
416  N = stack[--SP];
417  }
418  } while (SP != 0);
419 
420 } /* end of Cudd_RecursiveDerefZdd */
DdHalfWord ref
Definition: cudd.h:280
Definition: cudd.h:278
unsigned int deadZ
Definition: cuddInt.h:372
int * permZ
Definition: cuddInt.h:387
DdNode ** stack
Definition: cuddInt.h:380
unsigned int dead
Definition: cuddInt.h:332
#define cuddIsConstant(node)
Definition: cuddInt.h:620
#define cuddT(node)
Definition: cuddInt.h:636
DdHalfWord index
Definition: cudd.h:279
#define cuddE(node)
Definition: cuddInt.h:652
#define cuddSatDec(x)
Definition: cuddInt.h:896
#define assert(ex)
Definition: util_old.h:213
DdSubtable * subtableZ
Definition: cuddInt.h:366
int Cudd_ReduceHeap ( DdManager table,
Cudd_ReorderingType  heuristic,
int  minsize 
)

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

Synopsis [Main dynamic reordering routine.]

Description [Main dynamic reordering routine. Calls one of the possible reordering procedures:

  • Swapping
  • Sifting
  • Symmetric Sifting
  • Group Sifting
  • Window Permutation
  • Simulated Annealing
  • Genetic Algorithm
  • Dynamic Programming (exact)

For sifting, symmetric sifting, group sifting, and window permutation it is possible to request reordering to convergence.

The core of all methods is the reordering procedure cuddSwapInPlace() which swaps two adjacent variables and is based on Rudell's paper. Returns 1 in case of success; 0 otherwise. In the case of symmetric sifting (with and without convergence) returns 1 plus the number of symmetric variables, in case of success.]

SideEffects [Changes the variable order for all diagrams and clears the cache.]

Definition at line 176 of file cuddReorder.c.

180 {
181  DdHook *hook;
182  int result;
183  unsigned int nextDyn;
184 #ifdef DD_STATS
185  unsigned int initialSize;
186  unsigned int finalSize;
187 #endif
188  long localTime;
189 
190  /* Don't reorder if there are too many dead nodes. */
191  if (table->keys - table->dead < (unsigned) minsize)
192  return(1);
193 
194  if (heuristic == CUDD_REORDER_SAME) {
195  heuristic = table->autoMethod;
196  }
197  if (heuristic == CUDD_REORDER_NONE) {
198  return(1);
199  }
200 
201  /* This call to Cudd_ReduceHeap does initiate reordering. Therefore
202  ** we count it.
203  */
204  table->reorderings++;
205 
206  localTime = util_cpu_time();
207 
208  /* Run the hook functions. */
209  hook = table->preReorderingHook;
210  while (hook != NULL) {
211  int res = (hook->f)(table, "BDD", (void *)heuristic);
212  if (res == 0) return(0);
213  hook = hook->next;
214  }
215 
216  if (!ddReorderPreprocess(table)) return(0);
218 
219  if (table->keys > table->peakLiveNodes) {
220  table->peakLiveNodes = table->keys;
221  }
222 #ifdef DD_STATS
223  initialSize = table->keys - table->isolated;
224  ddTotalNISwaps = 0;
225 
226  switch(heuristic) {
227  case CUDD_REORDER_RANDOM:
229  (void) fprintf(table->out,"#:I_RANDOM ");
230  break;
231  case CUDD_REORDER_SIFT:
237  (void) fprintf(table->out,"#:I_SIFTING ");
238  break;
245  (void) fprintf(table->out,"#:I_WINDOW ");
246  break;
248  (void) fprintf(table->out,"#:I_ANNEAL ");
249  break;
251  (void) fprintf(table->out,"#:I_GENETIC ");
252  break;
253  case CUDD_REORDER_LINEAR:
255  (void) fprintf(table->out,"#:I_LINSIFT ");
256  break;
257  case CUDD_REORDER_EXACT:
258  (void) fprintf(table->out,"#:I_EXACT ");
259  break;
260  default:
261  return(0);
262  }
263  (void) fprintf(table->out,"%8d: initial size",initialSize);
264 #endif
265 
266  /* See if we should use alternate threshold for maximum growth. */
267  if (table->reordCycle && table->reorderings % table->reordCycle == 0) {
268  double saveGrowth = table->maxGrowth;
269  table->maxGrowth = table->maxGrowthAlt;
270  result = cuddTreeSifting(table,heuristic);
271  table->maxGrowth = saveGrowth;
272  } else {
273  result = cuddTreeSifting(table,heuristic);
274  }
275 
276 #ifdef DD_STATS
277  (void) fprintf(table->out,"\n");
278  finalSize = table->keys - table->isolated;
279  (void) fprintf(table->out,"#:F_REORDER %8d: final size\n",finalSize);
280  (void) fprintf(table->out,"#:T_REORDER %8g: total time (sec)\n",
281  ((double)(util_cpu_time() - localTime)/1000.0));
282  (void) fprintf(table->out,"#:N_REORDER %8d: total swaps\n",
284  (void) fprintf(table->out,"#:M_REORDER %8d: NI swaps\n",ddTotalNISwaps);
285 #endif
286 
287  if (result == 0)
288  return(0);
289 
290  if (!ddReorderPostprocess(table))
291  return(0);
292 
293  if (table->realign) {
294  if (!cuddZddAlignToBdd(table))
295  return(0);
296  }
297 
298  nextDyn = (table->keys - table->constants.keys + 1) *
299  DD_DYN_RATIO + table->constants.keys;
300  if (table->reorderings < 20 || nextDyn > table->nextDyn)
301  table->nextDyn = nextDyn;
302  else
303  table->nextDyn += 20;
304  table->reordered = 1;
305 
306  /* Run hook functions. */
307  hook = table->postReorderingHook;
308  while (hook != NULL) {
309  int res = (hook->f)(table, "BDD", (void *)localTime);
310  if (res == 0) return(0);
311  hook = hook->next;
312  }
313  /* Update cumulative reordering time. */
314  table->reordTime += util_cpu_time() - localTime;
315 
316  return(result);
317 
318 } /* end of Cudd_ReduceHeap */
unsigned int keys
Definition: cuddInt.h:330
long reordTime
Definition: cuddInt.h:454
Cudd_ReorderingType autoMethod
Definition: cuddInt.h:418
unsigned int peakLiveNodes
Definition: cuddInt.h:465
DdHook * preReorderingHook
Definition: cuddInt.h:439
int reordCycle
Definition: cuddInt.h:415
double maxGrowthAlt
Definition: cuddInt.h:414
int realign
Definition: cuddInt.h:420
double maxGrowth
Definition: cuddInt.h:413
#define DD_DYN_RATIO
Definition: cuddInt.h:152
#define util_cpu_time
Definition: util_hack.h:36
DD_HFP f
Definition: cuddInt.h:246
int ddTotalNumberSwapping
Definition: cuddReorder.c:107
int reordered
Definition: cuddInt.h:409
unsigned int nextDyn
Definition: cuddInt.h:422
unsigned int dead
Definition: cuddInt.h:371
DdHook * postReorderingHook
Definition: cuddInt.h:440
unsigned int keys
Definition: cuddInt.h:369
static int ddReorderPostprocess(DdManager *table)
Definition: cuddReorder.c:1864
FILE * out
Definition: cuddInt.h:441
if(last==0)
Definition: sparse_int.h:34
int reorderings
Definition: cuddInt.h:410
int cuddTreeSifting(DdManager *table, Cudd_ReorderingType method)
Definition: cuddGroup.c:274
static int ddReorderPreprocess(DdManager *table)
Definition: cuddReorder.c:1826
struct DdHook * next
Definition: cuddInt.h:247
int cuddZddAlignToBdd(DdManager *table)
Definition: cuddZddReord.c:352
DdSubtable constants
Definition: cuddInt.h:367
static int result
Definition: cuddGenetic.c:125
int isolated
Definition: cuddInt.h:385
void Cudd_Ref ( DdNode n)

AutomaticStart AutomaticEnd Function********************************************************************

Synopsis [Increases the reference count of a node, if it is not saturated.]

Description []

SideEffects [None]

SeeAlso [Cudd_RecursiveDeref Cudd_Deref]

Definition at line 129 of file cuddRef.c.

131 {
132 
133  n = Cudd_Regular(n);
134 
135  cuddSatInc(n->ref);
136 
137 } /* end of Cudd_Ref */
DdHalfWord ref
Definition: cudd.h:280
#define Cudd_Regular(node)
Definition: cudd.h:397
#define cuddSatInc(x)
Definition: cuddInt.h:878
DdNode* Cudd_RemapOverApprox ( DdManager dd,
DdNode f,
int  numVars,
int  threshold,
double  quality 
)

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

Synopsis [Extracts a dense superset from a BDD with the remapping underapproximation method.]

Description [Extracts a dense superset from a BDD. The procedure is identical to the underapproximation procedure except for the fact that it works on the complement of the given function. Extracting the subset of the complement function is equivalent to extracting the superset of the function. Returns a pointer to the BDD of the superset if successful. NULL if intermediate result causes the procedure to run out of memory. The parameter numVars is the maximum number of variables to be used in minterm calculation. The optimal number should be as close as possible to the size of the support of f. However, it is safe to pass the value returned by Cudd_ReadSize for numVars when the number of variables is under 1023. If numVars is larger than 1023, it will overflow. If a 0 parameter is passed then the procedure will compute a value which will avoid overflow but will cause underflow with 2046 variables or more.]

SideEffects [None]

SeeAlso [Cudd_SupersetHeavyBranch Cudd_SupersetShortPaths Cudd_ReadSize]

Definition at line 366 of file cuddApprox.c.

372 {
373  DdNode *subset, *g;
374 
375  g = Cudd_Not(f);
376  do {
377  dd->reordered = 0;
378  subset = cuddRemapUnderApprox(dd, g, numVars, threshold, quality);
379  } while (dd->reordered == 1);
380 
381  return(Cudd_NotCond(subset, (subset != NULL)));
382 
383 } /* end of Cudd_RemapOverApprox */
Definition: cudd.h:278
#define Cudd_Not(node)
Definition: cudd.h:367
int reordered
Definition: cuddInt.h:409
DdNode * cuddRemapUnderApprox(DdManager *dd, DdNode *f, int numVars, int threshold, double quality)
Definition: cuddApprox.c:601
#define Cudd_NotCond(node, c)
Definition: cudd.h:383
DdNode* Cudd_RemapUnderApprox ( DdManager dd,
DdNode f,
int  numVars,
int  threshold,
double  quality 
)

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

Synopsis [Extracts a dense subset from a BDD with the remapping underapproximation method.]

Description [Extracts a dense subset from a BDD. This procedure uses a remapping technique and density as the cost function. Returns a pointer to the BDD of the subset if successful. NULL if the procedure runs out of memory. The parameter numVars is the maximum number of variables to be used in minterm calculation. The optimal number should be as close as possible to the size of the support of f. However, it is safe to pass the value returned by Cudd_ReadSize for numVars when the number of variables is under 1023. If numVars is larger than 1023, it will cause overflow. If a 0 parameter is passed then the procedure will compute a value which will avoid overflow but will cause underflow with 2046 variables or more.]

SideEffects [None]

SeeAlso [Cudd_SubsetShortPaths Cudd_SubsetHeavyBranch Cudd_UnderApprox Cudd_ReadSize]

Definition at line 320 of file cuddApprox.c.

326 {
327  DdNode *subset;
328 
329  do {
330  dd->reordered = 0;
331  subset = cuddRemapUnderApprox(dd, f, numVars, threshold, quality);
332  } while (dd->reordered == 1);
333 
334  return(subset);
335 
336 } /* end of Cudd_RemapUnderApprox */
Definition: cudd.h:278
int reordered
Definition: cuddInt.h:409
DdNode * cuddRemapUnderApprox(DdManager *dd, DdNode *f, int numVars, int threshold, double quality)
Definition: cuddApprox.c:601
int Cudd_RemoveHook ( DdManager dd,
DD_HFP  f,
Cudd_HookType  where 
)

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

Synopsis [Removes a function from a hook.]

Description [Removes a function from a hook. A hook is a list of application-provided functions called on certain occasions by the package. Returns 1 if successful; 0 the function was not in the list.]

SideEffects [None]

SeeAlso [Cudd_AddHook]

Definition at line 3306 of file cuddAPI.c.

3310 {
3311  DdHook **hook, *nextHook;
3312 
3313  switch (where) {
3314  case CUDD_PRE_GC_HOOK:
3315  hook = &(dd->preGCHook);
3316  break;
3317  case CUDD_POST_GC_HOOK:
3318  hook = &(dd->postGCHook);
3319  break;
3321  hook = &(dd->preReorderingHook);
3322  break;
3324  hook = &(dd->postReorderingHook);
3325  break;
3326  default:
3327  return(0);
3328  }
3329  nextHook = *hook;
3330  while (nextHook != NULL) {
3331  if (nextHook->f == f) {
3332  *hook = nextHook->next;
3333  ABC_FREE(nextHook);
3334  return(1);
3335  }
3336  hook = &(nextHook->next);
3337  nextHook = nextHook->next;
3338  }
3339 
3340  return(0);
3341 
3342 } /* end of Cudd_RemoveHook */
DdHook * preReorderingHook
Definition: cuddInt.h:439
DD_HFP f
Definition: cuddInt.h:246
DdHook * postReorderingHook
Definition: cuddInt.h:440
struct DdHook * next
Definition: cuddInt.h:247
#define ABC_FREE(obj)
Definition: abc_global.h:232
DdHook * postGCHook
Definition: cuddInt.h:438
DdHook * preGCHook
Definition: cuddInt.h:437
int Cudd_ReorderingReporting ( DdManager dd)

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

Synopsis [Returns 1 if reporting of reordering stats is enabled.]

Description [Returns 1 if reporting of reordering stats is enabled; 0 otherwise.]

SideEffects [none]

SeeAlso [Cudd_EnableReorderingReporting Cudd_DisableReorderingReporting]

Definition at line 3591 of file cuddAPI.c.

3593 {
3595 
3596 } /* end of Cudd_ReorderingReporting */
int Cudd_StdPreReordHook(DdManager *dd, const char *str, void *data)
Definition: cuddAPI.c:3408
int Cudd_IsInHook(DdManager *dd, DD_HFP f, Cudd_HookType where)
Definition: cuddAPI.c:3359
int Cudd_ReorderingStatus ( DdManager unique,
Cudd_ReorderingType method 
)

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

Synopsis [Reports the status of automatic dynamic reordering of BDDs and ADDs.]

Description [Reports the status of automatic dynamic reordering of BDDs and ADDs. Parameter method is set to the reordering method currently selected. Returns 1 if automatic reordering is enabled; 0 otherwise.]

SideEffects [Parameter method is set to the reordering method currently selected.]

SeeAlso [Cudd_AutodynEnable Cudd_AutodynDisable Cudd_ReorderingStatusZdd]

Definition at line 735 of file cuddAPI.c.

738 {
739  *method = unique->autoMethod;
740  return(unique->autoDyn);
741 
742 } /* end of Cudd_ReorderingStatus */
Cudd_ReorderingType autoMethod
Definition: cuddInt.h:418
int autoDyn
Definition: cuddInt.h:416
int Cudd_ReorderingStatusZdd ( DdManager unique,
Cudd_ReorderingType method 
)

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

Synopsis [Reports the status of automatic dynamic reordering of ZDDs.]

Description [Reports the status of automatic dynamic reordering of ZDDs. Parameter method is set to the ZDD reordering method currently selected. Returns 1 if automatic reordering is enabled; 0 otherwise.]

SideEffects [Parameter method is set to the ZDD reordering method currently selected.]

SeeAlso [Cudd_AutodynEnableZdd Cudd_AutodynDisableZdd Cudd_ReorderingStatus]

Definition at line 812 of file cuddAPI.c.

815 {
816  *method = unique->autoMethodZ;
817  return(unique->autoDynZ);
818 
819 } /* end of Cudd_ReorderingStatusZdd */
Cudd_ReorderingType autoMethodZ
Definition: cuddInt.h:419
int autoDynZ
Definition: cuddInt.h:417
void Cudd_SetArcviolation ( DdManager dd,
int  arcviolation 
)

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

Synopsis [Sets the value of the arcviolation parameter used in group sifting.]

Description [Sets the value of the arcviolation parameter. This parameter is used in group sifting to decide how many arcs into y not coming from x are tolerable when checking for aggregation due to extended symmetry. The value should be between 0 and 100. A small value causes fewer variables to be aggregated. The default value is 0.]

SideEffects [None]

SeeAlso [Cudd_ReadArcviolation]

Definition at line 2790 of file cuddAPI.c.

2793 {
2794  dd->arcviolation = arcviolation;
2795 
2796 } /* end of Cudd_SetArcviolation */
int arcviolation
Definition: cuddInt.h:429
void Cudd_SetBackground ( DdManager dd,
DdNode bck 
)

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

Synopsis [Sets the background constant of the manager.]

Description [Sets the background constant of the manager. It assumes that the DdNode pointer bck is already referenced.]

SideEffects [None]

Definition at line 1131 of file cuddAPI.c.

1134 {
1135  dd->background = bck;
1136 
1137 } /* end of Cudd_SetBackground */
DdNode * background
Definition: cuddInt.h:349
void Cudd_SetEpsilon ( DdManager dd,
CUDD_VALUE_TYPE  ep 
)

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

Synopsis [Sets the epsilon parameter of the manager to ep.]

Description [Sets the epsilon parameter of the manager to ep. The epsilon parameter control the comparison between floating point numbers.]

SideEffects [None]

SeeAlso [Cudd_ReadEpsilon]

Definition at line 2451 of file cuddAPI.c.

2454 {
2455  dd->epsilon = ep;
2456 
2457 } /* end of Cudd_SetEpsilon */
CUDD_VALUE_TYPE epsilon
Definition: cuddInt.h:407
void Cudd_SetGroupcheck ( DdManager dd,
Cudd_AggregationType  gc 
)

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

Synopsis [Sets the parameter groupcheck of the manager to gc.]

Description [Sets the parameter groupcheck of the manager to gc. The groupcheck parameter determines the aggregation criterion in group sifting.]

SideEffects [None]

SeeAlso [Cudd_ReadGroupCheck]

Definition at line 2496 of file cuddAPI.c.

2499 {
2500  dd->groupcheck = gc;
2501 
2502 } /* end of Cudd_SetGroupcheck */
Cudd_AggregationType groupcheck
Definition: cuddInt.h:426
void Cudd_SetLooseUpTo ( DdManager dd,
unsigned int  lut 
)

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

Synopsis [Sets the looseUpTo parameter of the manager.]

Description [Sets the looseUpTo parameter of the manager. This parameter of the manager controls the threshold beyond which no fast growth of the unique table is allowed. The threshold is given as a number of slots. If the value passed to this function is 0, the function determines a suitable value based on the available memory.]

SideEffects [None]

SeeAlso [Cudd_ReadLooseUpTo Cudd_SetMinHit]

Definition at line 1345 of file cuddAPI.c.

1348 {
1349  if (lut == 0) {
1350  unsigned long datalimit = getSoftDataLimit();
1351  lut = (unsigned int) (datalimit / (sizeof(DdNode) *
1353  }
1354  dd->looseUpTo = lut;
1355 
1356 } /* end of Cudd_SetLooseUpTo */
Definition: cudd.h:278
#define DD_MAX_LOOSE_FRACTION
Definition: cuddInt.h:138
EXTERN long getSoftDataLimit()
unsigned int looseUpTo
Definition: cuddInt.h:377
void Cudd_SetMaxCacheHard ( DdManager dd,
unsigned int  mc 
)

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

Synopsis [Sets the maxCacheHard parameter of the manager.]

Description [Sets the maxCacheHard parameter of the manager. The cache cannot grow larger than maxCacheHard entries. This parameter allows an application to control the trade-off of memory versus speed. If the value passed to this function is 0, the function determines a suitable maximum cache size based on the available memory.]

SideEffects [None]

SeeAlso [Cudd_ReadMaxCacheHard Cudd_SetMaxCache]

Definition at line 1415 of file cuddAPI.c.

1418 {
1419  if (mc == 0) {
1420  unsigned long datalimit = getSoftDataLimit();
1421  mc = (unsigned int) (datalimit / (sizeof(DdCache) *
1423  }
1424  dd->maxCacheHard = mc;
1425 
1426 } /* end of Cudd_SetMaxCacheHard */
#define DD_MAX_CACHE_FRACTION
Definition: cuddInt.h:140
unsigned int maxCacheHard
Definition: cuddInt.h:359
EXTERN long getSoftDataLimit()
void Cudd_SetMaxGrowth ( DdManager dd,
double  mg 
)

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

Synopsis [Sets the maxGrowth parameter of the manager.]

Description [Sets the maxGrowth parameter of the manager. This parameter determines how much the number of nodes can grow during sifting of a variable. Overall, sifting never increases the size of the decision diagrams. This parameter only refers to intermediate results. A lower value will speed up sifting, possibly at the expense of quality.]

SideEffects [None]

SeeAlso [Cudd_ReadMaxGrowth Cudd_SetMaxGrowthAlternate]

Definition at line 2013 of file cuddAPI.c.

2016 {
2017  dd->maxGrowth = mg;
2018 
2019 } /* end of Cudd_SetMaxGrowth */
double maxGrowth
Definition: cuddInt.h:413
void Cudd_SetMaxGrowthAlternate ( DdManager dd,
double  mg 
)

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

Synopsis [Sets the maxGrowthAlt parameter of the manager.]

Description [Sets the maxGrowthAlt parameter of the manager. This parameter is analogous to the maxGrowth paramter, and is used every given number of reorderings instead of maxGrowth. The number of reorderings is set with Cudd_SetReorderingCycle. If the number of reorderings is 0 (default) maxGrowthAlt is never used.]

SideEffects [None]

SeeAlso [Cudd_ReadMaxGrowthAlternate Cudd_SetMaxGrowth Cudd_SetReorderingCycle Cudd_ReadReorderingCycle]

Definition at line 2064 of file cuddAPI.c.

2067 {
2068  dd->maxGrowthAlt = mg;
2069 
2070 } /* end of Cudd_SetMaxGrowthAlternate */
double maxGrowthAlt
Definition: cuddInt.h:414
void Cudd_SetMaxLive ( DdManager dd,
unsigned int  maxLive 
)

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

Synopsis [Sets the maximum allowed number of live nodes.]

Description [Sets the maximum allowed number of live nodes. When this number is exceeded, the package returns NULL.]

SideEffects [none]

SeeAlso [Cudd_ReadMaxLive]

Definition at line 3833 of file cuddAPI.c.

3836 {
3837  dd->maxLive = maxLive;
3838 
3839 } /* end of Cudd_SetMaxLive */
unsigned int maxLive
Definition: cuddInt.h:373
void Cudd_SetMaxMemory ( DdManager dd,
unsigned long  maxMemory 
)

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

Synopsis [Sets the maximum allowed memory.]

Description [Sets the maximum allowed memory. When this number is exceeded, the package returns NULL.]

SideEffects [none]

SeeAlso [Cudd_ReadMaxMemory]

Definition at line 3876 of file cuddAPI.c.

3879 {
3880  dd->maxmemhard = maxMemory;
3881 
3882 } /* end of Cudd_SetMaxMemory */
unsigned long maxmemhard
Definition: cuddInt.h:451
void Cudd_SetMinHit ( DdManager dd,
unsigned int  hr 
)

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

Synopsis [Sets the hit rate that causes resizinig of the computed table.]

Description [Sets the minHit parameter of the manager. This parameter controls the resizing of the computed table. If the hit rate is larger than the specified value, and the cache is not already too large, then its size is doubled.]

SideEffects [None]

SeeAlso [Cudd_ReadMinHit]

Definition at line 1298 of file cuddAPI.c.

1301 {
1302  /* Internally, the package manipulates the ratio of hits to
1303  ** misses instead of the ratio of hits to accesses. */
1304  dd->minHit = (double) hr / (100.0 - (double) hr);
1305 
1306 } /* end of Cudd_SetMinHit */
double minHit
Definition: cuddInt.h:357
void Cudd_SetNextReordering ( DdManager dd,
unsigned int  next 
)

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

Synopsis [Sets the threshold for the next dynamic reordering.]

Description [Sets the threshold for the next dynamic reordering. The threshold is in terms of number of nodes and is in effect only if reordering is enabled. The count does not include the dead nodes, unless the countDead parameter of the manager has been changed from its default setting.]

SideEffects [None]

SeeAlso [Cudd_ReadNextReordering]

Definition at line 3766 of file cuddAPI.c.

3769 {
3770  dd->nextDyn = next;
3771 
3772 } /* end of Cudd_SetNextReordering */
unsigned int nextDyn
Definition: cuddInt.h:422
void Cudd_SetNumberXovers ( DdManager dd,
int  numberXovers 
)

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

Synopsis [Sets the number of crossovers used by the genetic algorithm for reordering.]

Description [Sets the number of crossovers used by the genetic algorithm for variable reordering. A larger number of crossovers will cause the genetic algorithm to take more time, but will generally produce better results. The default value is 0, in which case the package uses three times the number of variables as number of crossovers, with a maximum of 60.]

SideEffects [None]

SeeAlso [Cudd_ReadNumberXovers]

Definition at line 2896 of file cuddAPI.c.

2899 {
2900  dd->numberXovers = numberXovers;
2901 
2902 } /* end of Cudd_SetNumberXovers */
int numberXovers
Definition: cuddInt.h:431
void Cudd_SetPopulationSize ( DdManager dd,
int  populationSize 
)

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

Synopsis [Sets the size of the population used by the genetic algorithm for reordering.]

Description [Sets the size of the population used by the genetic algorithm for variable reordering. A larger population size will cause the genetic algorithm to take more time, but will generally produce better results. The default value is 0, in which case the package uses three times the number of variables as population size, with a maximum of 120.]

SideEffects [Changes the manager.]

SeeAlso [Cudd_ReadPopulationSize]

Definition at line 2843 of file cuddAPI.c.

2846 {
2847  dd->populationSize = populationSize;
2848 
2849 } /* end of Cudd_SetPopulationSize */
int populationSize
Definition: cuddInt.h:430
void Cudd_SetRecomb ( DdManager dd,
int  recomb 
)

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

Synopsis [Sets the value of the recombination parameter used in group sifting.]

Description [Sets the value of the recombination parameter used in group sifting. A larger (positive) value makes the aggregation of variables due to the second difference criterion more likely. A smaller (negative) value makes aggregation less likely. The default value is 0.]

SideEffects [Changes the manager.]

SeeAlso [Cudd_ReadRecomb]

Definition at line 2682 of file cuddAPI.c.

2685 {
2686  dd->recomb = recomb;
2687 
2688 } /* end of Cudd_SetRecomb */
int recomb
Definition: cuddInt.h:427
void Cudd_SetReorderingCycle ( DdManager dd,
int  cycle 
)

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

Synopsis [Sets the reordCycle parameter of the manager.]

Description [Sets the reordCycle parameter of the manager. This parameter determines how often the alternate threshold on maximum growth is used in reordering.]

SideEffects [None]

SeeAlso [Cudd_ReadMaxGrowthAlternate Cudd_SetMaxGrowthAlternate Cudd_ReadReorderingCycle]

Definition at line 2111 of file cuddAPI.c.

2114 {
2115  dd->reordCycle = cycle;
2116 
2117 } /* end of Cudd_SetReorderingCycle */
int reordCycle
Definition: cuddInt.h:415
void Cudd_SetSiftMaxSwap ( DdManager dd,
int  sms 
)

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

Synopsis [Sets the siftMaxSwap parameter of the manager.]

Description [Sets the siftMaxSwap parameter of the manager. This parameter gives the maximum number of swaps that will be attempted for each invocation of sifting. The real number of swaps may exceed the set limit because the package will always complete the sifting of the variable that causes the limit to be reached.]

SideEffects [None]

SeeAlso [Cudd_SetSiftMaxVar Cudd_ReadSiftMaxSwap]

Definition at line 1962 of file cuddAPI.c.

1965 {
1966  dd->siftMaxSwap = sms;
1967 
1968 } /* end of Cudd_SetSiftMaxSwap */
int siftMaxSwap
Definition: cuddInt.h:412
void Cudd_SetSiftMaxVar ( DdManager dd,
int  smv 
)

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

Synopsis [Sets the siftMaxVar parameter of the manager.]

Description [Sets the siftMaxVar parameter of the manager. This parameter gives the maximum number of variables that will be sifted for each invocation of sifting.]

SideEffects [None]

SeeAlso [Cudd_SetSiftMaxSwap Cudd_ReadSiftMaxVar]

Definition at line 1913 of file cuddAPI.c.

1916 {
1917  dd->siftMaxVar = smv;
1918 
1919 } /* end of Cudd_SetSiftMaxVar */
int siftMaxVar
Definition: cuddInt.h:411
void Cudd_SetStderr ( DdManager dd,
FILE *  fp 
)

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

Synopsis [Sets the stderr of a manager.]

Description []

SideEffects [None]

SeeAlso [Cudd_ReadStderr Cudd_SetStdout]

Definition at line 3717 of file cuddAPI.c.

3720 {
3721  dd->err = fp;
3722 
3723 } /* end of Cudd_SetStderr */
FILE * err
Definition: cuddInt.h:442
void Cudd_SetStdout ( DdManager dd,
FILE *  fp 
)

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

Synopsis [Sets the stdout of a manager.]

Description []

SideEffects [None]

SeeAlso [Cudd_ReadStdout Cudd_SetStderr]

Definition at line 3674 of file cuddAPI.c.

3677 {
3678  dd->out = fp;
3679 
3680 } /* end of Cudd_SetStdout */
FILE * out
Definition: cuddInt.h:441
void Cudd_SetSymmviolation ( DdManager dd,
int  symmviolation 
)

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

Synopsis [Sets the value of the symmviolation parameter used in group sifting.]

Description [Sets the value of the symmviolation parameter. This parameter is used in group sifting to decide how many violations to the symmetry conditions f10 = f01 or f11 = f00 are tolerable when checking for aggregation due to extended symmetry. The value should be between 0 and 100. A small value causes fewer variables to be aggregated. The default value is 0.]

SideEffects [Changes the manager.]

SeeAlso [Cudd_ReadSymmviolation]

Definition at line 2737 of file cuddAPI.c.

2740 {
2741  dd->symmviolation = symmviolation;
2742 
2743 } /* end of Cudd_SetSymmviolation */
int symmviolation
Definition: cuddInt.h:428
void Cudd_SetTree ( DdManager dd,
MtrNode tree 
)

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

Synopsis [Sets the variable group tree of the manager.]

Description []

SideEffects [None]

SeeAlso [Cudd_FreeTree Cudd_ReadTree Cudd_SetZddTree]

Definition at line 2152 of file cuddAPI.c.

2155 {
2156  if (dd->tree != NULL) {
2157  Mtr_FreeTree(dd->tree);
2158  }
2159  dd->tree = tree;
2160  if (tree == NULL) return;
2161 
2162  fixVarTree(tree, dd->perm, dd->size);
2163  return;
2164 
2165 } /* end of Cudd_SetTree */
int size
Definition: cuddInt.h:361
void Mtr_FreeTree(MtrNode *node)
Definition: mtrBasic.c:188
MtrNode * tree
Definition: cuddInt.h:424
static void fixVarTree(MtrNode *treenode, int *perm, int size)
Definition: cuddAPI.c:4359
int * perm
Definition: cuddInt.h:386
int Cudd_SetVarMap ( DdManager manager,
DdNode **  x,
DdNode **  y,
int  n 
)

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

Synopsis [Registers a variable mapping with the manager.]

Description [Registers with the manager a variable mapping described by two sets of variables. This variable mapping is then used by functions like Cudd_bddVarMap. This function is convenient for those applications that perform the same mapping several times. However, if several different permutations are used, it may be more efficient not to rely on the registered mapping, because changing mapping causes the cache to be cleared. (The initial setting, however, does not clear the cache.) The two sets of variables (x and y) must have the same size (x and y). The size is given by n. The two sets of variables are normally disjoint, but this restriction is not imposeded by the function. When new variables are created, the map is automatically extended (each new variable maps to itself). The typical use, however, is to wait until all variables are created, and then create the map. Returns 1 if the mapping is successfully registered with the manager; 0 otherwise.]

SideEffects [Modifies the manager. May clear the cache.]

SeeAlso [Cudd_bddVarMap Cudd_bddPermute Cudd_bddSwapVariables]

Definition at line 416 of file cuddCompose.c.

421 {
422  int i;
423 
424  if (manager->map != NULL) {
425  cuddCacheFlush(manager);
426  } else {
427  manager->map = ABC_ALLOC(int,manager->maxSize);
428  if (manager->map == NULL) {
429  manager->errorCode = CUDD_MEMORY_OUT;
430  return(0);
431  }
432  manager->memused += sizeof(int) * manager->maxSize;
433  }
434  /* Initialize the map to the identity. */
435  for (i = 0; i < manager->size; i++) {
436  manager->map[i] = i;
437  }
438  /* Create the map. */
439  for (i = 0; i < n; i++) {
440  manager->map[x[i]->index] = y[i]->index;
441  manager->map[y[i]->index] = x[i]->index;
442  }
443  return(1);
444 
445 } /* end of Cudd_SetVarMap */
void cuddCacheFlush(DdManager *table)
Definition: cuddCache.c:1047
int * map
Definition: cuddInt.h:391
int size
Definition: cuddInt.h:361
#define ABC_ALLOC(type, num)
Definition: abc_global.h:229
int maxSize
Definition: cuddInt.h:363
unsigned long memused
Definition: cuddInt.h:449
DdHalfWord index
Definition: cudd.h:279
Cudd_ErrorType errorCode
Definition: cuddInt.h:447
void Cudd_SetZddTree ( DdManager dd,
MtrNode tree 
)

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

Synopsis [Sets the ZDD variable group tree of the manager.]

Description []

SideEffects [None]

SeeAlso [Cudd_FreeZddTree Cudd_ReadZddTree Cudd_SetTree]

Definition at line 2224 of file cuddAPI.c.

2227 {
2228  if (dd->treeZ != NULL) {
2229  Mtr_FreeTree(dd->treeZ);
2230  }
2231  dd->treeZ = tree;
2232  if (tree == NULL) return;
2233 
2234  fixVarTree(tree, dd->permZ, dd->sizeZ);
2235  return;
2236 
2237 } /* end of Cudd_SetZddTree */
void Mtr_FreeTree(MtrNode *node)
Definition: mtrBasic.c:188
int * permZ
Definition: cuddInt.h:387
int sizeZ
Definition: cuddInt.h:362
MtrNode * treeZ
Definition: cuddInt.h:425
static void fixVarTree(MtrNode *treenode, int *perm, int size)
Definition: cuddAPI.c:4359
int Cudd_SharingSize ( DdNode **  nodeArray,
int  n 
)

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

Synopsis [Counts the number of nodes in an array of DDs.]

Description [Counts the number of nodes in an array of DDs. Shared nodes are counted only once. Returns the total number of nodes.]

SideEffects [None]

SeeAlso [Cudd_DagSize]

Definition at line 544 of file cuddUtil.c.

547 {
548  int i,j;
549 
550  i = 0;
551  for (j = 0; j < n; j++) {
552  i += ddDagInt(Cudd_Regular(nodeArray[j]));
553  }
554  for (j = 0; j < n; j++) {
555  ddClearFlag(Cudd_Regular(nodeArray[j]));
556  }
557  return(i);
558 
559 } /* end of Cudd_SharingSize */
#define Cudd_Regular(node)
Definition: cudd.h:397
static int ddDagInt(DdNode *n)
Definition: cuddUtil.c:3165
static void ddClearFlag(DdNode *f)
Definition: cuddUtil.c:3735
int Cudd_ShortestLength ( DdManager manager,
DdNode f,
int *  weight 
)

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

Synopsis [Find the length of the shortest path(s) in a DD.]

Description [Find the length of the shortest path(s) in a DD. f is the DD we want to get the shortest path for; weight[i] is the weight of the THEN edge coming from the node whose index is i. All ELSE edges have 0 weight. Returns the length of the shortest path(s) if such a path is found; a large number if the function is identically 0, and CUDD_OUT_OF_MEM in case of failure.]

SideEffects [None]

SeeAlso [Cudd_ShortestPath]

Definition at line 357 of file cuddSat.c.

361 {
362  register DdNode *F;
363  st__table *visited;
364  cuddPathPair *my_pair;
365  int complement, cost;
366 
367  one = DD_ONE(manager);
368  zero = DD_ZERO(manager);
369 
370  if (f == Cudd_Not(one) || f == zero) {
371  return(DD_BIGGY);
372  }
373 
374  /* From this point on, a path exists. */
375  /* Initialize visited table and support. */
377 
378  /* Now get the length of the shortest path(s) from f to 1. */
379  (void) getShortest(f, weight, NULL, visited);
380 
381  complement = Cudd_IsComplement(f);
382 
383  F = Cudd_Regular(f);
384 
385  if (! st__lookup(visited, (const char *)F, (char **)&my_pair)) return(CUDD_OUT_OF_MEM);
386 
387  if (complement) {
388  cost = my_pair->neg;
389  } else {
390  cost = my_pair->pos;
391  }
392 
393  st__foreach(visited, freePathPair, NULL);
394  st__free_table(visited);
395 
396  return(cost);
397 
398 } /* end of Cudd_ShortestLength */
void st__free_table(st__table *table)
Definition: st.c:81
#define CUDD_OUT_OF_MEM
Definition: cudd.h:95
Definition: cudd.h:278
#define Cudd_Not(node)
Definition: cudd.h:367
static enum st__retval freePathPair(char *key, char *value, char *arg)
Definition: cuddSat.c:964
#define Cudd_Regular(node)
Definition: cudd.h:397
int st__ptrcmp(const char *, const char *)
Definition: st.c:480
pcover complement(pcube *T)
Definition: compl.c:49
st__table * st__init_table(st__compare_func_type compare, st__hash_func_type hash)
Definition: st.c:72
static DdNode * one
Definition: cuddSat.c:106
#define Cudd_IsComplement(node)
Definition: cudd.h:425
Definition: st.h:52
int st__foreach(st__table *table, enum st__retval(*func)(char *, char *, char *), char *arg)
Definition: st.c:421
int st__lookup(st__table *table, const char *key, char **value)
Definition: st.c:114
static DdNode * zero
Definition: cuddSat.c:106
#define DD_BIGGY
Definition: cuddSat.c:83
static cuddPathPair getShortest(DdNode *root, int *cost, int *support, st__table *visited)
Definition: cuddSat.c:997
#define DD_ONE(dd)
Definition: cuddInt.h:911
int st__ptrhash(const char *, int)
Definition: st.c:468
#define DD_ZERO(dd)
Definition: cuddInt.h:927
DdNode* Cudd_ShortestPath ( DdManager manager,
DdNode f,
int *  weight,
int *  support,
int *  length 
)

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

Synopsis [Finds a shortest path in a DD.]

Description [Finds a shortest path in a DD. f is the DD we want to get the shortest path for; weight[i] is the weight of the THEN arc coming from the node whose index is i. If weight is NULL, then unit weights are assumed for all THEN arcs. All ELSE arcs have 0 weight. If non-NULL, both weight and support should point to arrays with at least as many entries as there are variables in the manager. Returns the shortest path as the BDD of a cube.]

SideEffects [support contains on return the true support of f. If support is NULL on entry, then Cudd_ShortestPath does not compute the true support info. length contains the length of the path.]

SeeAlso [Cudd_ShortestLength Cudd_LargestCube]

Definition at line 201 of file cuddSat.c.

207 {
208  DdNode *F;
209  st__table *visited;
210  DdNode *sol;
211  cuddPathPair *rootPair;
212  int complement, cost;
213  int i;
214 
215  one = DD_ONE(manager);
216  zero = DD_ZERO(manager);
217 
218  /* Initialize support. Support does not depend on variable order.
219  ** Hence, it does not need to be reinitialized if reordering occurs.
220  */
221  if (support) {
222  for (i = 0; i < manager->size; i++) {
223  support[i] = 0;
224  }
225  }
226 
227  if (f == Cudd_Not(one) || f == zero) {
228  *length = DD_BIGGY;
229  return(Cudd_Not(one));
230  }
231  /* From this point on, a path exists. */
232 
233  do {
234  manager->reordered = 0;
235 
236  /* Initialize visited table. */
238 
239  /* Now get the length of the shortest path(s) from f to 1. */
240  (void) getShortest(f, weight, support, visited);
241 
242  complement = Cudd_IsComplement(f);
243 
244  F = Cudd_Regular(f);
245 
246  if (! st__lookup(visited, (const char *)F, (char **)&rootPair)) return(NULL);
247 
248  if (complement) {
249  cost = rootPair->neg;
250  } else {
251  cost = rootPair->pos;
252  }
253 
254  /* Recover an actual shortest path. */
255  sol = getPath(manager,visited,f,weight,cost);
256 
257  st__foreach(visited, freePathPair, NULL);
258  st__free_table(visited);
259 
260  } while (manager->reordered == 1);
261 
262  *length = cost;
263  return(sol);
264 
265 } /* end of Cudd_ShortestPath */
void st__free_table(st__table *table)
Definition: st.c:81
static DdNode * getPath(DdManager *manager, st__table *visited, DdNode *f, int *weight, int cost)
Definition: cuddSat.c:1093
Definition: cudd.h:278
#define Cudd_Not(node)
Definition: cudd.h:367
static enum st__retval freePathPair(char *key, char *value, char *arg)
Definition: cuddSat.c:964
int size
Definition: cuddInt.h:361
#define Cudd_Regular(node)
Definition: cudd.h:397
int st__ptrcmp(const char *, const char *)
Definition: st.c:480
pcover complement(pcube *T)
Definition: compl.c:49
st__table * st__init_table(st__compare_func_type compare, st__hash_func_type hash)
Definition: st.c:72
int reordered
Definition: cuddInt.h:409
static DdNode * one
Definition: cuddSat.c:106
#define Cudd_IsComplement(node)
Definition: cudd.h:425
Definition: st.h:52
int st__foreach(st__table *table, enum st__retval(*func)(char *, char *, char *), char *arg)
Definition: st.c:421
int support
Definition: abcSaucy.c:64
int st__lookup(st__table *table, const char *key, char **value)
Definition: st.c:114
static DdNode * zero
Definition: cuddSat.c:106
#define DD_BIGGY
Definition: cuddSat.c:83
static cuddPathPair getShortest(DdNode *root, int *cost, int *support, st__table *visited)
Definition: cuddSat.c:997
#define DD_ONE(dd)
Definition: cuddInt.h:911
int st__ptrhash(const char *, int)
Definition: st.c:468
#define DD_ZERO(dd)
Definition: cuddInt.h:927
int Cudd_ShuffleHeap ( DdManager table,
int *  permutation 
)

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

Synopsis [Reorders variables according to given permutation.]

Description [Reorders variables according to given permutation. The i-th entry of the permutation array contains the index of the variable that should be brought to the i-th level. The size of the array should be equal or greater to the number of variables currently in use. Returns 1 in case of success; 0 otherwise.]

SideEffects [Changes the variable order for all diagrams and clears the cache.]

SeeAlso [Cudd_ReduceHeap]

Definition at line 338 of file cuddReorder.c.

341 {
342 
343  int result;
344  int i;
345  int identity = 1;
346  int *perm;
347 
348  /* Don't waste time in case of identity permutation. */
349  for (i = 0; i < table->size; i++) {
350  if (permutation[i] != table->invperm[i]) {
351  identity = 0;
352  break;
353  }
354  }
355  if (identity == 1) {
356  return(1);
357  }
358  if (!ddReorderPreprocess(table)) return(0);
359  if (table->keys > table->peakLiveNodes) {
360  table->peakLiveNodes = table->keys;
361  }
362 
363  perm = ABC_ALLOC(int, table->size);
364  for (i = 0; i < table->size; i++)
365  perm[permutation[i]] = i;
366  if (!ddCheckPermuation(table,table->tree,perm,permutation)) {
367  ABC_FREE(perm);
368  return(0);
369  }
370  if (!ddUpdateMtrTree(table,table->tree,perm,permutation)) {
371  ABC_FREE(perm);
372  return(0);
373  }
374  ABC_FREE(perm);
375 
376  result = ddShuffle(table,permutation);
377 
378  if (!ddReorderPostprocess(table)) return(0);
379 
380  return(result);
381 
382 } /* end of Cudd_ShuffleHeap */
static int ddCheckPermuation(DdManager *table, MtrNode *treenode, int *perm, int *invperm)
Definition: cuddReorder.c:2103
unsigned int peakLiveNodes
Definition: cuddInt.h:465
int size
Definition: cuddInt.h:361
#define ABC_ALLOC(type, num)
Definition: abc_global.h:229
MtrNode * tree
Definition: cuddInt.h:424
unsigned int keys
Definition: cuddInt.h:369
static int ddReorderPostprocess(DdManager *table)
Definition: cuddReorder.c:1864
static int ddUpdateMtrTree(DdManager *table, MtrNode *treenode, int *perm, int *invperm)
Definition: cuddReorder.c:2044
static int ddReorderPreprocess(DdManager *table)
Definition: cuddReorder.c:1826
#define ABC_FREE(obj)
Definition: abc_global.h:232
static int ddShuffle(DdManager *table, int *permutation)
Definition: cuddReorder.c:1897
int * invperm
Definition: cuddInt.h:388
static int result
Definition: cuddGenetic.c:125
DdNode* Cudd_SolveEqn ( DdManager bdd,
DdNode F,
DdNode Y,
DdNode **  G,
int **  yIndex,
int  n 
)

AutomaticStart AutomaticEnd Function********************************************************************

Synopsis [Implements the solution of F(x,y) = 0.]

Description [Implements the solution for F(x,y) = 0. The return value is the consistency condition. The y variables are the unknowns and the remaining variables are the parameters. Returns the consistency condition if successful; NULL otherwise. Cudd_SolveEqn allocates an array and fills it with the indices of the unknowns. This array is used by Cudd_VerifySol.]

SideEffects [The solution is returned in G; the indices of the y variables are returned in yIndex.]

SeeAlso [Cudd_VerifySol]

Definition at line 126 of file cuddSolve.c.

133 {
134  DdNode *res;
135  int *temp;
136 
137  *yIndex = temp = ABC_ALLOC(int, n);
138  if (temp == NULL) {
139  bdd->errorCode = CUDD_MEMORY_OUT;
140  (void) fprintf(bdd->out,
141  "Cudd_SolveEqn: Out of memory for yIndex\n");
142  return(NULL);
143  }
144 
145  do {
146  bdd->reordered = 0;
147  res = cuddSolveEqnRecur(bdd, F, Y, G, n, temp, 0);
148  } while (bdd->reordered == 1);
149 
150  return(res);
151 
152 } /* end of Cudd_SolveEqn */
Definition: cudd.h:278
#define ABC_ALLOC(type, num)
Definition: abc_global.h:229
int reordered
Definition: cuddInt.h:409
FILE * out
Definition: cuddInt.h:441
DdNode * cuddSolveEqnRecur(DdManager *bdd, DdNode *F, DdNode *Y, DdNode **G, int n, int *yIndex, int i)
Definition: cuddSolve.c:210
Cudd_ErrorType errorCode
Definition: cuddInt.h:447
DdNode* Cudd_SplitSet ( DdManager manager,
DdNode S,
DdNode **  xVars,
int  n,
double  m 
)

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

Synopsis [Returns m minterms from a BDD.]

Description [Returns m minterms from a BDD whose support has n variables at most. The procedure tries to create as few extra nodes as possible. The function represented by S depends on at most n of the variables in xVars. Returns a BDD with m minterms of the on-set of S if successful; NULL otherwise.]

SideEffects [None]

SeeAlso []

Definition at line 128 of file cuddSplit.c.

134 {
135  DdNode *result;
136  DdNode *zero, *one;
137  double max, num;
138  st__table *mtable;
139  int *varSeen;
140  int i,index, size;
141 
142  size = manager->size;
143  one = DD_ONE(manager);
144  zero = Cudd_Not(one);
145 
146  /* Trivial cases. */
147  if (m == 0.0) {
148  return(zero);
149  }
150  if (S == zero) {
151  return(NULL);
152  }
153 
154  max = pow(2.0,(double)n);
155  if (m > max)
156  return(NULL);
157 
158  do {
159  manager->reordered = 0;
160  /* varSeen is used to mark the variables that are encountered
161  ** while traversing the BDD S.
162  */
163  varSeen = ABC_ALLOC(int, size);
164  if (varSeen == NULL) {
165  manager->errorCode = CUDD_MEMORY_OUT;
166  return(NULL);
167  }
168  for (i = 0; i < size; i++) {
169  varSeen[i] = -1;
170  }
171  for (i = 0; i < n; i++) {
172  index = (xVars[i])->index;
173  varSeen[manager->invperm[index]] = 0;
174  }
175 
176  if (S == one) {
177  if (m == max) {
178  ABC_FREE(varSeen);
179  return(S);
180  }
181  result = selectMintermsFromUniverse(manager,varSeen,m);
182  if (result)
183  cuddRef(result);
184  ABC_FREE(varSeen);
185  } else {
187  if (mtable == NULL) {
188  (void) fprintf(manager->out,
189  "Cudd_SplitSet: out-of-memory.\n");
190  ABC_FREE(varSeen);
191  manager->errorCode = CUDD_MEMORY_OUT;
192  return(NULL);
193  }
194  /* The nodes of BDD S are annotated by the number of minterms
195  ** in their onset. The node and the number of minterms in its
196  ** onset are stored in mtable.
197  */
198  num = bddAnnotateMintermCount(manager,S,max,mtable);
199  if (m == num) {
200  st__foreach(mtable,cuddStCountfree,NIL(char));
201  st__free_table(mtable);
202  ABC_FREE(varSeen);
203  return(S);
204  }
205 
206  result = cuddSplitSetRecur(manager,mtable,varSeen,S,m,max,0);
207  if (result)
208  cuddRef(result);
209  st__foreach(mtable,cuddStCountfree,NULL);
210  st__free_table(mtable);
211  ABC_FREE(varSeen);
212  }
213  } while (manager->reordered == 1);
214 
215  cuddDeref(result);
216  return(result);
217 
218 } /* end of Cudd_SplitSet */
void st__free_table(st__table *table)
Definition: st.c:81
#define cuddRef(n)
Definition: cuddInt.h:584
#define cuddDeref(n)
Definition: cuddInt.h:604
Definition: cudd.h:278
#define Cudd_Not(node)
Definition: cudd.h:367
int size
Definition: cuddInt.h:361
enum st__retval cuddStCountfree(char *key, char *value, char *arg)
Definition: cuddUtil.c:2895
int st__ptrcmp(const char *, const char *)
Definition: st.c:480
#define ABC_ALLOC(type, num)
Definition: abc_global.h:229
#define NIL(type)
Definition: avl.h:25
st__table * st__init_table(st__compare_func_type compare, st__hash_func_type hash)
Definition: st.c:72
int reordered
Definition: cuddInt.h:409
static DdNode * one
Definition: cuddDecomp.c:112
FILE * out
Definition: cuddInt.h:441
Definition: st.h:52
static double max
Definition: cuddSubsetHB.c:134
static double bddAnnotateMintermCount(DdManager *manager, DdNode *node, double max, st__table *table)
Definition: cuddSplit.c:633
static int size
Definition: cuddSign.c:86
int st__foreach(st__table *table, enum st__retval(*func)(char *, char *, char *), char *arg)
Definition: st.c:421
#define ABC_FREE(obj)
Definition: abc_global.h:232
int * invperm
Definition: cuddInt.h:388
static int result
Definition: cuddGenetic.c:125
static ABC_NAMESPACE_IMPL_START DdNode * selectMintermsFromUniverse(DdManager *manager, int *varSeen, double n)
Definition: cuddSplit.c:499
#define DD_ONE(dd)
Definition: cuddInt.h:911
DdNode * cuddSplitSetRecur(DdManager *manager, st__table *mtable, int *varSeen, DdNode *p, double n, double max, int index)
Definition: cuddSplit.c:247
Cudd_ErrorType errorCode
Definition: cuddInt.h:447
int st__ptrhash(const char *, int)
Definition: st.c:468
static DdNode * zero
Definition: cuddApa.c:100
void Cudd_Srandom ( long  seed)

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

Synopsis [Initializer for the portable random number generator.]

Description [Initializer for the portable number generator based on ran2 in "Numerical Recipes in C." The input is the seed for the generator. If it is negative, its absolute value is taken as seed. If it is 0, then 1 is taken as seed. The initialized sets up the two recurrences used to generate a long-period stream, and sets up the shuffle table.]

SideEffects [None]

SeeAlso [Cudd_Random]

Definition at line 2764 of file cuddUtil.c.

2766 {
2767  int i;
2768 
2769  if (seed < 0) cuddRand = -seed;
2770  else if (seed == 0) cuddRand = 1;
2771  else cuddRand = seed;
2772  cuddRand2 = cuddRand;
2773  /* Load the shuffle table (after 11 warm-ups). */
2774  for (i = 0; i < STAB_SIZE + 11; i++) {
2775  long int w;
2776  w = cuddRand / LEQQ1;
2777  cuddRand = LEQA1 * (cuddRand - w * LEQQ1) - w * LEQR1;
2778  cuddRand += (cuddRand < 0) * MODULUS1;
2780  }
2782 
2783 } /* end of Cudd_Srandom */
#define LEQQ1
Definition: cuddUtil.c:122
#define MODULUS1
Definition: cuddUtil.c:120
static long shuffleSelect
Definition: cuddUtil.c:152
static long shuffleTable[STAB_SIZE]
Definition: cuddUtil.c:153
static long cuddRand
Definition: cuddUtil.c:150
#define STAB_SIZE
Definition: cuddUtil.c:128
#define LEQR1
Definition: cuddUtil.c:123
static long cuddRand2
Definition: cuddUtil.c:151
#define LEQA1
Definition: cuddUtil.c:121
int Cudd_StdPostReordHook ( DdManager dd,
const char *  str,
void *  data 
)

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

Synopsis [Sample hook function to call after reordering.]

Description [Sample hook function to call after reordering. Prints on the manager's stdout final size and reordering time. Returns 1 if successful; 0 otherwise.]

SideEffects [None]

SeeAlso [Cudd_StdPreReordHook]

Definition at line 3501 of file cuddAPI.c.

3505 {
3506  long initialTime = (long) data;
3507  int retval;
3508  long finalTime = util_cpu_time();
3509  double totalTimeSec = (double)(finalTime - initialTime) / 1000.0;
3510 
3511  retval = fprintf(dd->out,"%ld nodes in %g sec\n", strcmp(str, "BDD") == 0 ?
3513  totalTimeSec);
3514  if (retval == EOF) return(0);
3515  retval = fflush(dd->out);
3516  if (retval == EOF) return(0);
3517  return(1);
3518 
3519 } /* end of Cudd_StdPostReordHook */
long Cudd_ReadNodeCount(DdManager *dd)
Definition: cuddAPI.c:3179
#define util_cpu_time
Definition: util_hack.h:36
int strcmp()
FILE * out
Definition: cuddInt.h:441
long Cudd_zddReadNodeCount(DdManager *dd)
Definition: cuddAPI.c:3221
int Cudd_StdPreReordHook ( DdManager dd,
const char *  str,
void *  data 
)

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

Synopsis [Sample hook function to call before reordering.]

Description [Sample hook function to call before reordering. Prints on the manager's stdout reordering method and initial size. Returns 1 if successful; 0 otherwise.]

SideEffects [None]

SeeAlso [Cudd_StdPostReordHook]

Definition at line 3408 of file cuddAPI.c.

3412 {
3414  int retval;
3415 
3416  retval = fprintf(dd->out,"%s reordering with ", str);
3417  if (retval == EOF) return(0);
3418  switch (method) {
3426  retval = fprintf(dd->out,"converging ");
3427  if (retval == EOF) return(0);
3428  break;
3429  default:
3430  break;
3431  }
3432  switch (method) {
3433  case CUDD_REORDER_RANDOM:
3435  retval = fprintf(dd->out,"random");
3436  break;
3437  case CUDD_REORDER_SIFT:
3439  retval = fprintf(dd->out,"sifting");
3440  break;
3443  retval = fprintf(dd->out,"symmetric sifting");
3444  break;
3446  retval = fprintf(dd->out,"lazy sifting");
3447  break;
3450  retval = fprintf(dd->out,"group sifting");
3451  break;
3452  case CUDD_REORDER_WINDOW2:
3453  case CUDD_REORDER_WINDOW3:
3454  case CUDD_REORDER_WINDOW4:
3458  retval = fprintf(dd->out,"window");
3459  break;
3461  retval = fprintf(dd->out,"annealing");
3462  break;
3463  case CUDD_REORDER_GENETIC:
3464  retval = fprintf(dd->out,"genetic");
3465  break;
3466  case CUDD_REORDER_LINEAR:
3468  retval = fprintf(dd->out,"linear sifting");
3469  break;
3470  case CUDD_REORDER_EXACT:
3471  retval = fprintf(dd->out,"exact");
3472  break;
3473  default:
3474  return(0);
3475  }
3476  if (retval == EOF) return(0);
3477 
3478  retval = fprintf(dd->out,": from %ld to ... ", strcmp(str, "BDD") == 0 ?
3480  if (retval == EOF) return(0);
3481  fflush(dd->out);
3482  return(1);
3483 
3484 } /* end of Cudd_StdPreReordHook */
long Cudd_ReadNodeCount(DdManager *dd)
Definition: cuddAPI.c:3179
int strcmp()
ABC_PTRUINT_T ptruint
Definition: cuddInt.h:261
FILE * out
Definition: cuddInt.h:441
long Cudd_zddReadNodeCount(DdManager *dd)
Definition: cuddAPI.c:3221
Cudd_ReorderingType
Definition: cudd.h:151
DdNode* Cudd_SubsetCompress ( DdManager dd,
DdNode f,
int  nvars,
int  threshold 
)

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

Synopsis [Find a dense subset of BDD f.]

Description [Finds a dense subset of BDD f. Density is the ratio of number of minterms to number of nodes. Uses several techniques in series. It is more expensive than other subsetting procedures, but often produces better results. See Cudd_SubsetShortPaths for a description of the threshold and nvars parameters. Returns a pointer to the result if successful; NULL otherwise.]

SideEffects [None]

SeeAlso [Cudd_SubsetRemap Cudd_SubsetShortPaths Cudd_SubsetHeavyBranch Cudd_bddSqueeze]

Definition at line 700 of file cuddGenCof.c.

705 {
706  DdNode *res, *tmp1, *tmp2;
707 
708  tmp1 = Cudd_SubsetShortPaths(dd, f, nvars, threshold, 0);
709  if (tmp1 == NULL) return(NULL);
710  cuddRef(tmp1);
711  tmp2 = Cudd_RemapUnderApprox(dd,tmp1,nvars,0,1.0);
712  if (tmp2 == NULL) {
713  Cudd_IterDerefBdd(dd,tmp1);
714  return(NULL);
715  }
716  cuddRef(tmp2);
717  Cudd_IterDerefBdd(dd,tmp1);
718  res = Cudd_bddSqueeze(dd,tmp2,f);
719  if (res == NULL) {
720  Cudd_IterDerefBdd(dd,tmp2);
721  return(NULL);
722  }
723  cuddRef(res);
724  Cudd_IterDerefBdd(dd,tmp2);
725  cuddDeref(res);
726  return(res);
727 
728 } /* end of Cudd_SubsetCompress */
void Cudd_IterDerefBdd(DdManager *table, DdNode *n)
Definition: cuddRef.c:217
#define cuddRef(n)
Definition: cuddInt.h:584
#define cuddDeref(n)
Definition: cuddInt.h:604
Definition: cudd.h:278
DdNode * Cudd_bddSqueeze(DdManager *dd, DdNode *l, DdNode *u)
Definition: cuddGenCof.c:602
DdNode * Cudd_RemapUnderApprox(DdManager *dd, DdNode *f, int numVars, int threshold, double quality)
Definition: cuddApprox.c:320
DdNode * Cudd_SubsetShortPaths(DdManager *dd, DdNode *f, int numVars, int threshold, int hardlimit)
Definition: cuddSubsetSP.c:220
DdNode* Cudd_SubsetHeavyBranch ( DdManager dd,
DdNode f,
int  numVars,
int  threshold 
)

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

Synopsis [Extracts a dense subset from a BDD with the heavy branch heuristic.]

Description [Extracts a dense subset from a BDD. This procedure builds a subset by throwing away one of the children of each node, starting from the root, until the result is small enough. The child that is eliminated from the result is the one that contributes the fewer minterms. Returns a pointer to the BDD of the subset if successful. NULL if the procedure runs out of memory. The parameter numVars is the maximum number of variables to be used in minterm calculation and node count calculation. The optimal number should be as close as possible to the size of the support of f. However, it is safe to pass the value returned by Cudd_ReadSize for numVars when the number of variables is under 1023. If numVars is larger than 1023, it will overflow. If a 0 parameter is passed then the procedure will compute a value which will avoid overflow but will cause underflow with 2046 variables or more.]

SideEffects [None]

SeeAlso [Cudd_SubsetShortPaths Cudd_SupersetHeavyBranch Cudd_ReadSize]

Definition at line 209 of file cuddSubsetHB.c.

214 {
215  DdNode *subset;
216 
217  memOut = 0;
218  do {
219  dd->reordered = 0;
220  subset = cuddSubsetHeavyBranch(dd, f, numVars, threshold);
221  } while ((dd->reordered == 1) && (!memOut));
222 
223  return(subset);
224 
225 } /* end of Cudd_SubsetHeavyBranch */
Definition: cudd.h:278
DdNode * cuddSubsetHeavyBranch(DdManager *dd, DdNode *f, int numVars, int threshold)
Definition: cuddSubsetHB.c:305
int reordered
Definition: cuddInt.h:409
static int memOut
Definition: cuddSubsetHB.c:123
DdNode* Cudd_SubsetShortPaths ( DdManager dd,
DdNode f,
int  numVars,
int  threshold,
int  hardlimit 
)

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

Synopsis [Extracts a dense subset from a BDD with the shortest paths heuristic.]

Description [Extracts a dense subset from a BDD. This procedure tries to preserve the shortest paths of the input BDD, because they give many minterms and contribute few nodes. This procedure may increase the number of nodes in trying to create the subset or reduce the number of nodes due to recombination as compared to the original BDD. Hence the threshold may not be strictly adhered to. In practice, recombination overshadows the increase in the number of nodes and results in small BDDs as compared to the threshold. The hardlimit specifies whether threshold needs to be strictly adhered to. If it is set to 1, the procedure ensures that result is never larger than the specified limit but may be considerably less than the threshold. Returns a pointer to the BDD for the subset if successful; NULL otherwise. The value for numVars should be as close as possible to the size of the support of f for better efficiency. However, it is safe to pass the value returned by Cudd_ReadSize for numVars. If 0 is passed, then the value returned by Cudd_ReadSize is used.]

SideEffects [None]

SeeAlso [Cudd_SupersetShortPaths Cudd_SubsetHeavyBranch Cudd_ReadSize]

Definition at line 220 of file cuddSubsetSP.c.

226 {
227  DdNode *subset;
228 
229  memOut = 0;
230  do {
231  dd->reordered = 0;
232  subset = cuddSubsetShortPaths(dd, f, numVars, threshold, hardlimit);
233  } while((dd->reordered ==1) && (!memOut));
234 
235  return(subset);
236 
237 } /* end of Cudd_SubsetShortPaths */
DdNode * cuddSubsetShortPaths(DdManager *dd, DdNode *f, int numVars, int threshold, int hardlimit)
Definition: cuddSubsetSP.c:316
Definition: cudd.h:278
static int memOut
Definition: cuddSubsetSP.c:139
int reordered
Definition: cuddInt.h:409
DdNode* Cudd_SubsetWithMaskVars ( DdManager dd,
DdNode f,
DdNode **  vars,
int  nvars,
DdNode **  maskVars,
int  mvars 
)

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

Synopsis [Extracts a subset from a BDD.]

Description [Extracts a subset from a BDD in the following procedure.

  1. Compute the weight for each mask variable by counting the number of minterms for both positive and negative cofactors of the BDD with respect to each mask variable. (weight = #positive - #negative)
  2. Find a representative cube of the BDD by using the weight. From the top variable of the BDD, for each variable, if the weight is greater than 0.0, choose THEN branch, othereise ELSE branch, until meeting the constant 1.
  3. Quantify out the variables not in maskVars from the representative cube and if a variable in maskVars is don't care, replace the variable with a constant(1 or 0) depending on the weight.
  4. Make a subset of the BDD by multiplying with the modified cube.]

SideEffects [None]

SeeAlso []

Definition at line 1602 of file cuddUtil.c.

1609 {
1610  double *weight;
1611  char *string;
1612  int i, size;
1613  int *indices, *mask;
1614  int result;
1615  DdNode *zero, *cube, *newCube, *subset;
1616  DdNode *cof;
1617 
1618  DdNode *support;
1619  support = Cudd_Support(dd,f);
1620  cuddRef(support);
1621  Cudd_RecursiveDeref(dd,support);
1622 
1623  zero = Cudd_Not(dd->one);
1624  size = dd->size;
1625 
1626  weight = ABC_ALLOC(double,size);
1627  if (weight == NULL) {
1628  dd->errorCode = CUDD_MEMORY_OUT;
1629  return(NULL);
1630  }
1631  for (i = 0; i < size; i++) {
1632  weight[i] = 0.0;
1633  }
1634  for (i = 0; i < mvars; i++) {
1635  cof = Cudd_Cofactor(dd, f, maskVars[i]);
1636  cuddRef(cof);
1637  weight[i] = Cudd_CountMinterm(dd, cof, nvars);
1638  Cudd_RecursiveDeref(dd,cof);
1639 
1640  cof = Cudd_Cofactor(dd, f, Cudd_Not(maskVars[i]));
1641  cuddRef(cof);
1642  weight[i] -= Cudd_CountMinterm(dd, cof, nvars);
1643  Cudd_RecursiveDeref(dd,cof);
1644  }
1645 
1646  string = ABC_ALLOC(char, size + 1);
1647  if (string == NULL) {
1648  dd->errorCode = CUDD_MEMORY_OUT;
1649  ABC_FREE(weight);
1650  return(NULL);
1651  }
1652  mask = ABC_ALLOC(int, size);
1653  if (mask == NULL) {
1654  dd->errorCode = CUDD_MEMORY_OUT;
1655  ABC_FREE(weight);
1656  ABC_FREE(string);
1657  return(NULL);
1658  }
1659  for (i = 0; i < size; i++) {
1660  string[i] = '2';
1661  mask[i] = 0;
1662  }
1663  string[size] = '\0';
1664  indices = ABC_ALLOC(int,nvars);
1665  if (indices == NULL) {
1666  dd->errorCode = CUDD_MEMORY_OUT;
1667  ABC_FREE(weight);
1668  ABC_FREE(string);
1669  ABC_FREE(mask);
1670  return(NULL);
1671  }
1672  for (i = 0; i < nvars; i++) {
1673  indices[i] = vars[i]->index;
1674  }
1675 
1676  result = ddPickRepresentativeCube(dd,f,weight,string);
1677  if (result == 0) {
1678  ABC_FREE(weight);
1679  ABC_FREE(string);
1680  ABC_FREE(mask);
1681  ABC_FREE(indices);
1682  return(NULL);
1683  }
1684 
1685  cube = Cudd_ReadOne(dd);
1686  cuddRef(cube);
1687  zero = Cudd_Not(Cudd_ReadOne(dd));
1688  for (i = 0; i < nvars; i++) {
1689  if (string[indices[i]] == '0') {
1690  newCube = Cudd_bddIte(dd,cube,Cudd_Not(vars[i]),zero);
1691  } else if (string[indices[i]] == '1') {
1692  newCube = Cudd_bddIte(dd,cube,vars[i],zero);
1693  } else
1694  continue;
1695  if (newCube == NULL) {
1696  ABC_FREE(weight);
1697  ABC_FREE(string);
1698  ABC_FREE(mask);
1699  ABC_FREE(indices);
1700  Cudd_RecursiveDeref(dd,cube);
1701  return(NULL);
1702  }
1703  cuddRef(newCube);
1704  Cudd_RecursiveDeref(dd,cube);
1705  cube = newCube;
1706  }
1707  Cudd_RecursiveDeref(dd,cube);
1708 
1709  for (i = 0; i < mvars; i++) {
1710  mask[maskVars[i]->index] = 1;
1711  }
1712  for (i = 0; i < nvars; i++) {
1713  if (mask[indices[i]]) {
1714  if (string[indices[i]] == '2') {
1715  if (weight[indices[i]] >= 0.0)
1716  string[indices[i]] = '1';
1717  else
1718  string[indices[i]] = '0';
1719  }
1720  } else {
1721  string[indices[i]] = '2';
1722  }
1723  }
1724 
1725  cube = Cudd_ReadOne(dd);
1726  cuddRef(cube);
1727  zero = Cudd_Not(Cudd_ReadOne(dd));
1728 
1729  /* Build result BDD. */
1730  for (i = 0; i < nvars; i++) {
1731  if (string[indices[i]] == '0') {
1732  newCube = Cudd_bddIte(dd,cube,Cudd_Not(vars[i]),zero);
1733  } else if (string[indices[i]] == '1') {
1734  newCube = Cudd_bddIte(dd,cube,vars[i],zero);
1735  } else
1736  continue;
1737  if (newCube == NULL) {
1738  ABC_FREE(weight);
1739  ABC_FREE(string);
1740  ABC_FREE(mask);
1741  ABC_FREE(indices);
1742  Cudd_RecursiveDeref(dd,cube);
1743  return(NULL);
1744  }
1745  cuddRef(newCube);
1746  Cudd_RecursiveDeref(dd,cube);
1747  cube = newCube;
1748  }
1749 
1750  subset = Cudd_bddAnd(dd,f,cube);
1751  cuddRef(subset);
1752  Cudd_RecursiveDeref(dd,cube);
1753 
1754  /* Test. */
1755  if (Cudd_bddLeq(dd,subset,f)) {
1756  cuddDeref(subset);
1757  } else {
1758  Cudd_RecursiveDeref(dd,subset);
1759  subset = NULL;
1760  }
1761 
1762  ABC_FREE(weight);
1763  ABC_FREE(string);
1764  ABC_FREE(mask);
1765  ABC_FREE(indices);
1766  return(subset);
1767 
1768 } /* end of Cudd_SubsetWithMaskVars */
#define cuddRef(n)
Definition: cuddInt.h:584
#define cuddDeref(n)
Definition: cuddInt.h:604
void Cudd_RecursiveDeref(DdManager *table, DdNode *n)
Definition: cuddRef.c:154
Definition: cudd.h:278
#define Cudd_Not(node)
Definition: cudd.h:367
int size
Definition: cuddInt.h:361
#define ABC_ALLOC(type, num)
Definition: abc_global.h:229
DdNode * Cudd_bddIte(DdManager *dd, DdNode *f, DdNode *g, DdNode *h)
Definition: cuddBddIte.c:143
static int ddPickRepresentativeCube(DdManager *dd, DdNode *node, double *weight, char *string)
Definition: cuddUtil.c:3859
double Cudd_CountMinterm(DdManager *manager, DdNode *node, int nvars)
Definition: cuddUtil.c:578
DdNode * Cudd_Cofactor(DdManager *dd, DdNode *f, DdNode *g)
Definition: cuddCof.c:123
static DdNode * zero
Definition: cuddUtil.c:148
static int size
Definition: cuddSign.c:86
int support
Definition: abcSaucy.c:64
DdNode * Cudd_ReadOne(DdManager *dd)
Definition: cuddAPI.c:987
int Cudd_bddLeq(DdManager *dd, DdNode *f, DdNode *g)
Definition: cuddBddIte.c:536
DdHalfWord index
Definition: cudd.h:279
#define ABC_FREE(obj)
Definition: abc_global.h:232
DdNode * one
Definition: cuddInt.h:345
DdNode * Cudd_bddAnd(DdManager *dd, DdNode *f, DdNode *g)
Definition: cuddBddIte.c:314
static int result
Definition: cuddGenetic.c:125
DdNode * Cudd_Support(DdManager *dd, DdNode *f)
Definition: cuddUtil.c:740
Cudd_ErrorType errorCode
Definition: cuddInt.h:447
DdNode* Cudd_SupersetCompress ( DdManager dd,
DdNode f,
int  nvars,
int  threshold 
)

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

Synopsis [Find a dense superset of BDD f.]

Description [Finds a dense superset of BDD f. Density is the ratio of number of minterms to number of nodes. Uses several techniques in series. It is more expensive than other supersetting procedures, but often produces better results. See Cudd_SupersetShortPaths for a description of the threshold and nvars parameters. Returns a pointer to the result if successful; NULL otherwise.]

SideEffects [None]

SeeAlso [Cudd_SubsetCompress Cudd_SupersetRemap Cudd_SupersetShortPaths Cudd_SupersetHeavyBranch Cudd_bddSqueeze]

Definition at line 750 of file cuddGenCof.c.

755 {
756  DdNode *subset;
757 
758  subset = Cudd_SubsetCompress(dd, Cudd_Not(f),nvars,threshold);
759 
760  return(Cudd_NotCond(subset, (subset != NULL)));
761 
762 } /* end of Cudd_SupersetCompress */
Definition: cudd.h:278
#define Cudd_Not(node)
Definition: cudd.h:367
DdNode * Cudd_SubsetCompress(DdManager *dd, DdNode *f, int nvars, int threshold)
Definition: cuddGenCof.c:700
#define Cudd_NotCond(node, c)
Definition: cudd.h:383
DdNode* Cudd_SupersetHeavyBranch ( DdManager dd,
DdNode f,
int  numVars,
int  threshold 
)

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

Synopsis [Extracts a dense superset from a BDD with the heavy branch heuristic.]

Description [Extracts a dense superset from a BDD. The procedure is identical to the subset procedure except for the fact that it receives the complement of the given function. Extracting the subset of the complement function is equivalent to extracting the superset of the function. This procedure builds a superset by throwing away one of the children of each node starting from the root of the complement function, until the result is small enough. The child that is eliminated from the result is the one that contributes the fewer minterms. Returns a pointer to the BDD of the superset if successful. NULL if intermediate result causes the procedure to run out of memory. The parameter numVars is the maximum number of variables to be used in minterm calculation and node count calculation. The optimal number should be as close as possible to the size of the support of f. However, it is safe to pass the value returned by Cudd_ReadSize for numVars when the number of variables is under 1023. If numVars is larger than 1023, it will overflow. If a 0 parameter is passed then the procedure will compute a value which will avoid overflow but will cause underflow with 2046 variables or more.]

SideEffects [None]

SeeAlso [Cudd_SubsetHeavyBranch Cudd_SupersetShortPaths Cudd_ReadSize]

Definition at line 259 of file cuddSubsetHB.c.

264 {
265  DdNode *subset, *g;
266 
267  g = Cudd_Not(f);
268  memOut = 0;
269  do {
270  dd->reordered = 0;
271  subset = cuddSubsetHeavyBranch(dd, g, numVars, threshold);
272  } while ((dd->reordered == 1) && (!memOut));
273 
274  return(Cudd_NotCond(subset, (subset != NULL)));
275 
276 } /* end of Cudd_SupersetHeavyBranch */
Definition: cudd.h:278
#define Cudd_Not(node)
Definition: cudd.h:367
DdNode * cuddSubsetHeavyBranch(DdManager *dd, DdNode *f, int numVars, int threshold)
Definition: cuddSubsetHB.c:305
int reordered
Definition: cuddInt.h:409
#define Cudd_NotCond(node, c)
Definition: cudd.h:383
static int memOut
Definition: cuddSubsetHB.c:123
DdNode* Cudd_SupersetShortPaths ( DdManager dd,
DdNode f,
int  numVars,
int  threshold,
int  hardlimit 
)

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

Synopsis [Extracts a dense superset from a BDD with the shortest paths heuristic.]

Description [Extracts a dense superset from a BDD. The procedure is identical to the subset procedure except for the fact that it receives the complement of the given function. Extracting the subset of the complement function is equivalent to extracting the superset of the function. This procedure tries to preserve the shortest paths of the complement BDD, because they give many minterms and contribute few nodes. This procedure may increase the number of nodes in trying to create the superset or reduce the number of nodes due to recombination as compared to the original BDD. Hence the threshold may not be strictly adhered to. In practice, recombination overshadows the increase in the number of nodes and results in small BDDs as compared to the threshold. The hardlimit specifies whether threshold needs to be strictly adhered to. If it is set to 1, the procedure ensures that result is never larger than the specified limit but may be considerably less than the threshold. Returns a pointer to the BDD for the superset if successful; NULL otherwise. The value for numVars should be as close as possible to the size of the support of f for better efficiency. However, it is safe to pass the value returned by Cudd_ReadSize for numVar. If 0 is passed, then the value returned by Cudd_ReadSize is used.]

SideEffects [None]

SeeAlso [Cudd_SubsetShortPaths Cudd_SupersetHeavyBranch Cudd_ReadSize]

Definition at line 272 of file cuddSubsetSP.c.

278 {
279  DdNode *subset, *g;
280 
281  g = Cudd_Not(f);
282  memOut = 0;
283  do {
284  dd->reordered = 0;
285  subset = cuddSubsetShortPaths(dd, g, numVars, threshold, hardlimit);
286  } while((dd->reordered ==1) && (!memOut));
287 
288  return(Cudd_NotCond(subset, (subset != NULL)));
289 
290 } /* end of Cudd_SupersetShortPaths */
DdNode * cuddSubsetShortPaths(DdManager *dd, DdNode *f, int numVars, int threshold, int hardlimit)
Definition: cuddSubsetSP.c:316
Definition: cudd.h:278
#define Cudd_Not(node)
Definition: cudd.h:367
static int memOut
Definition: cuddSubsetSP.c:139
int reordered
Definition: cuddInt.h:409
#define Cudd_NotCond(node, c)
Definition: cudd.h:383
DdNode* Cudd_Support ( DdManager dd,
DdNode f 
)

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

Synopsis [Finds the variables on which a DD depends.]

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

SideEffects [None]

SeeAlso [Cudd_VectorSupport Cudd_ClassifySupport]

Definition at line 740 of file cuddUtil.c.

743 {
744  int *support;
745  DdNode *res, *tmp, *var;
746  int i,j;
747  int size;
748 
749  /* Allocate and initialize support array for ddSupportStep. */
750  size = ddMax(dd->size, dd->sizeZ);
751  support = ABC_ALLOC(int,size);
752  if (support == NULL) {
754  return(NULL);
755  }
756  for (i = 0; i < size; i++) {
757  support[i] = 0;
758  }
759 
760  /* Compute support and clean up markers. */
761  ddSupportStep(Cudd_Regular(f),support);
763 
764  /* Transform support from array to cube. */
765  do {
766  dd->reordered = 0;
767  res = DD_ONE(dd);
768  cuddRef(res);
769  for (j = size - 1; j >= 0; j--) { /* for each level bottom-up */
770  i = (j >= dd->size) ? j : dd->invperm[j];
771  if (support[i] == 1) {
772  /* The following call to cuddUniqueInter is guaranteed
773  ** not to trigger reordering because the node we look up
774  ** already exists. */
775  var = cuddUniqueInter(dd,i,dd->one,Cudd_Not(dd->one));
776  cuddRef(var);
777  tmp = cuddBddAndRecur(dd,res,var);
778  if (tmp == NULL) {
779  Cudd_RecursiveDeref(dd,res);
780  Cudd_RecursiveDeref(dd,var);
781  res = NULL;
782  break;
783  }
784  cuddRef(tmp);
785  Cudd_RecursiveDeref(dd,res);
786  Cudd_RecursiveDeref(dd,var);
787  res = tmp;
788  }
789  }
790  } while (dd->reordered == 1);
791 
792  ABC_FREE(support);
793  if (res != NULL) cuddDeref(res);
794  return(res);
795 
796 } /* end of Cudd_Support */
#define cuddRef(n)
Definition: cuddInt.h:584
#define cuddDeref(n)
Definition: cuddInt.h:604
void Cudd_RecursiveDeref(DdManager *table, DdNode *n)
Definition: cuddRef.c:154
Definition: cudd.h:278
#define Cudd_Not(node)
Definition: cudd.h:367
int size
Definition: cuddInt.h:361
int var(Lit p)
Definition: SolverTypes.h:62
#define Cudd_Regular(node)
Definition: cudd.h:397
#define ABC_ALLOC(type, num)
Definition: abc_global.h:229
int reordered
Definition: cuddInt.h:409
static void ddSupportStep(DdNode *f, int *support)
Definition: cuddUtil.c:3704
#define ddMax(x, y)
Definition: cuddInt.h:832
if(last==0)
Definition: sparse_int.h:34
static int size
Definition: cuddSign.c:86
int support
Definition: abcSaucy.c:64
int sizeZ
Definition: cuddInt.h:362
#define ABC_FREE(obj)
Definition: abc_global.h:232
DdNode * one
Definition: cuddInt.h:345
static void ddClearFlag(DdNode *f)
Definition: cuddUtil.c:3735
int * invperm
Definition: cuddInt.h:388
#define DD_ONE(dd)
Definition: cuddInt.h:911
DdNode * cuddBddAndRecur(DdManager *manager, DdNode *f, DdNode *g)
Definition: cuddBddIte.c:886
Cudd_ErrorType errorCode
Definition: cuddInt.h:447
DdNode * cuddUniqueInter(DdManager *unique, int index, DdNode *T, DdNode *E)
Definition: cuddTable.c:1128
int* Cudd_SupportIndex ( DdManager dd,
DdNode f 
)

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

Synopsis [Finds the variables on which a DD depends.]

Description [Finds the variables on which a DD depends. Returns an index array of the variables if successful; NULL otherwise. The size of the array equals the number of variables in the manager. Each entry of the array is 1 if the corresponding variable is in the support of the DD and 0 otherwise.]

SideEffects [None]

SeeAlso [Cudd_Support Cudd_VectorSupport Cudd_ClassifySupport]

Definition at line 815 of file cuddUtil.c.

818 {
819  int *support;
820  int i;
821  int size;
822 
823  /* Allocate and initialize support array for ddSupportStep. */
824  size = ddMax(dd->size, dd->sizeZ);
825  support = ABC_ALLOC(int,size);
826  if (support == NULL) {
828  return(NULL);
829  }
830  for (i = 0; i < size; i++) {
831  support[i] = 0;
832  }
833 
834  /* Compute support and clean up markers. */
835  ddSupportStep(Cudd_Regular(f),support);
837 
838  return(support);
839 
840 } /* end of Cudd_SupportIndex */
int size
Definition: cuddInt.h:361
#define Cudd_Regular(node)
Definition: cudd.h:397
#define ABC_ALLOC(type, num)
Definition: abc_global.h:229
static void ddSupportStep(DdNode *f, int *support)
Definition: cuddUtil.c:3704
#define ddMax(x, y)
Definition: cuddInt.h:832
static int size
Definition: cuddSign.c:86
int support
Definition: abcSaucy.c:64
int sizeZ
Definition: cuddInt.h:362
static void ddClearFlag(DdNode *f)
Definition: cuddUtil.c:3735
Cudd_ErrorType errorCode
Definition: cuddInt.h:447
int Cudd_SupportSize ( DdManager dd,
DdNode f 
)

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

Synopsis [Counts the variables on which a DD depends.]

Description [Counts the variables on which a DD depends. Returns the number of the variables if successful; CUDD_OUT_OF_MEM otherwise.]

SideEffects [None]

SeeAlso [Cudd_Support]

Definition at line 857 of file cuddUtil.c.

860 {
861  int *support;
862  int i;
863  int size;
864  int count;
865 
866  /* Allocate and initialize support array for ddSupportStep. */
867  size = ddMax(dd->size, dd->sizeZ);
868  support = ABC_ALLOC(int,size);
869  if (support == NULL) {
871  return(CUDD_OUT_OF_MEM);
872  }
873  for (i = 0; i < size; i++) {
874  support[i] = 0;
875  }
876 
877  /* Compute support and clean up markers. */
878  ddSupportStep(Cudd_Regular(f),support);
880 
881  /* Count support variables. */
882  count = 0;
883  for (i = 0; i < size; i++) {
884  if (support[i] == 1) count++;
885  }
886 
887  ABC_FREE(support);
888  return(count);
889 
890 } /* end of Cudd_SupportSize */
#define CUDD_OUT_OF_MEM
Definition: cudd.h:95
int size
Definition: cuddInt.h:361
#define Cudd_Regular(node)
Definition: cudd.h:397
#define ABC_ALLOC(type, num)
Definition: abc_global.h:229
static void ddSupportStep(DdNode *f, int *support)
Definition: cuddUtil.c:3704
#define ddMax(x, y)
Definition: cuddInt.h:832
static int size
Definition: cuddSign.c:86
int support
Definition: abcSaucy.c:64
int sizeZ
Definition: cuddInt.h:362
#define ABC_FREE(obj)
Definition: abc_global.h:232
static void ddClearFlag(DdNode *f)
Definition: cuddUtil.c:3735
Cudd_ErrorType errorCode
Definition: cuddInt.h:447
void Cudd_SymmProfile ( DdManager table,
int  lower,
int  upper 
)

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

Synopsis [Prints statistics on symmetric variables.]

Description []

SideEffects [None]

Definition at line 142 of file cuddSymmetry.c.

146 {
147  int i,x,gbot;
148  int TotalSymm = 0;
149  int TotalSymmGroups = 0;
150 
151  for (i = lower; i <= upper; i++) {
152  if (table->subtables[i].next != (unsigned) i) {
153  x = i;
154  (void) fprintf(table->out,"Group:");
155  do {
156  (void) fprintf(table->out," %d",table->invperm[x]);
157  TotalSymm++;
158  gbot = x;
159  x = table->subtables[x].next;
160  } while (x != i);
161  TotalSymmGroups++;
162 #ifdef DD_DEBUG
163  assert(table->subtables[gbot].next == (unsigned) i);
164 #endif
165  i = gbot;
166  (void) fprintf(table->out,"\n");
167  }
168  }
169  (void) fprintf(table->out,"Total Symmetric = %d\n",TotalSymm);
170  (void) fprintf(table->out,"Total Groups = %d\n",TotalSymmGroups);
171 
172 } /* end of Cudd_SymmProfile */
DdSubtable * subtables
Definition: cuddInt.h:365
FILE * out
Definition: cuddInt.h:441
unsigned int next
Definition: cuddInt.h:333
#define assert(ex)
Definition: util_old.h:213
int * invperm
Definition: cuddInt.h:388
void Cudd_tlcInfoFree ( DdTlcInfo t)

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

Synopsis [Frees a DdTlcInfo Structure.]

Description [Frees a DdTlcInfo Structure as well as the memory pointed by it.]

SideEffects [None]

SeeAlso []

Definition at line 455 of file cuddEssent.c.

457 {
458  if (t->vars != NULL) ABC_FREE(t->vars);
459  if (t->phases != NULL) ABC_FREE(t->phases);
460  ABC_FREE(t);
461 
462 } /* end of Cudd_tlcInfoFree */
DdHalfWord * vars
Definition: cuddEssent.c:123
long * phases
Definition: cuddEssent.c:124
#define ABC_FREE(obj)
Definition: abc_global.h:232
void Cudd_TurnOffCountDead ( DdManager dd)

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

Synopsis [Causes the dead nodes not to be counted towards triggering reordering.]

Description [Causes the dead nodes not to be counted towards triggering reordering. This causes less frequent reorderings. By default dead nodes are not counted. Therefore there is no need to call this function unless Cudd_TurnOnCountDead has been previously called.]

SideEffects [Changes the manager.]

SeeAlso [Cudd_TurnOnCountDead Cudd_DeadAreCounted]

Definition at line 2633 of file cuddAPI.c.

2635 {
2636  dd->countDead = ~0;
2637 
2638 } /* end of Cudd_TurnOffCountDead */
unsigned int countDead
Definition: cuddInt.h:423
void Cudd_TurnOnCountDead ( DdManager dd)

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

Synopsis [Causes the dead nodes to be counted towards triggering reordering.]

Description [Causes the dead nodes to be counted towards triggering reordering. This causes more frequent reorderings. By default dead nodes are not counted.]

SideEffects [Changes the manager.]

SeeAlso [Cudd_TurnOffCountDead Cudd_DeadAreCounted]

Definition at line 2608 of file cuddAPI.c.

2610 {
2611  dd->countDead = 0;
2612 
2613 } /* end of Cudd_TurnOnCountDead */
unsigned int countDead
Definition: cuddInt.h:423
DdNode* Cudd_UnderApprox ( DdManager dd,
DdNode f,
int  numVars,
int  threshold,
int  safe,
double  quality 
)

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

Synopsis [Extracts a dense subset from a BDD with Shiple's underapproximation method.]

Description [Extracts a dense subset from a BDD. This procedure uses a variant of Tom Shiple's underapproximation method. The main difference from the original method is that density is used as cost function. Returns a pointer to the BDD of the subset if successful. NULL if the procedure runs out of memory. The parameter numVars is the maximum number of variables to be used in minterm calculation. The optimal number should be as close as possible to the size of the support of f. However, it is safe to pass the value returned by Cudd_ReadSize for numVars when the number of variables is under 1023. If numVars is larger than 1023, it will cause overflow. If a 0 parameter is passed then the procedure will compute a value which will avoid overflow but will cause underflow with 2046 variables or more.]

SideEffects [None]

SeeAlso [Cudd_SubsetShortPaths Cudd_SubsetHeavyBranch Cudd_ReadSize]

Definition at line 228 of file cuddApprox.c.

235 {
236  DdNode *subset;
237 
238  do {
239  dd->reordered = 0;
240  subset = cuddUnderApprox(dd, f, numVars, threshold, safe, quality);
241  } while (dd->reordered == 1);
242 
243  return(subset);
244 
245 } /* end of Cudd_UnderApprox */
Definition: cudd.h:278
DdNode * cuddUnderApprox(DdManager *dd, DdNode *f, int numVars, int threshold, int safe, double quality)
Definition: cuddApprox.c:511
int reordered
Definition: cuddInt.h:409
DdNode* Cudd_VectorSupport ( DdManager dd,
DdNode **  F,
int  n 
)

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 908 of file cuddUtil.c.

912 {
913  int *support;
914  DdNode *res, *tmp, *var;
915  int i,j;
916  int size;
917 
918  /* Allocate and initialize support array for ddSupportStep. */
919  size = ddMax(dd->size, dd->sizeZ);
920  support = ABC_ALLOC(int,size);
921  if (support == NULL) {
923  return(NULL);
924  }
925  for (i = 0; i < size; i++) {
926  support[i] = 0;
927  }
928 
929  /* Compute support and clean up markers. */
930  for (i = 0; i < n; i++) {
931  ddSupportStep(Cudd_Regular(F[i]),support);
932  }
933  for (i = 0; i < n; i++) {
934  ddClearFlag(Cudd_Regular(F[i]));
935  }
936 
937  /* Transform support from array to cube. */
938  res = DD_ONE(dd);
939  cuddRef(res);
940  for (j = size - 1; j >= 0; j--) { /* for each level bottom-up */
941  i = (j >= dd->size) ? j : dd->invperm[j];
942  if (support[i] == 1) {
943  var = cuddUniqueInter(dd,i,dd->one,Cudd_Not(dd->one));
944  cuddRef(var);
945  tmp = Cudd_bddAnd(dd,res,var);
946  if (tmp == NULL) {
947  Cudd_RecursiveDeref(dd,res);
948  Cudd_RecursiveDeref(dd,var);
949  ABC_FREE(support);
950  return(NULL);
951  }
952  cuddRef(tmp);
953  Cudd_RecursiveDeref(dd,res);
954  Cudd_RecursiveDeref(dd,var);
955  res = tmp;
956  }
957  }
958 
959  ABC_FREE(support);
960  cuddDeref(res);
961  return(res);
962 
963 } /* end of Cudd_VectorSupport */
#define cuddRef(n)
Definition: cuddInt.h:584
#define cuddDeref(n)
Definition: cuddInt.h:604
void Cudd_RecursiveDeref(DdManager *table, DdNode *n)
Definition: cuddRef.c:154
Definition: cudd.h:278
#define Cudd_Not(node)
Definition: cudd.h:367
int size
Definition: cuddInt.h:361
int var(Lit p)
Definition: SolverTypes.h:62
#define Cudd_Regular(node)
Definition: cudd.h:397
#define ABC_ALLOC(type, num)
Definition: abc_global.h:229
static void ddSupportStep(DdNode *f, int *support)
Definition: cuddUtil.c:3704
#define ddMax(x, y)
Definition: cuddInt.h:832
if(last==0)
Definition: sparse_int.h:34
static int size
Definition: cuddSign.c:86
int support
Definition: abcSaucy.c:64
int sizeZ
Definition: cuddInt.h:362
#define ABC_FREE(obj)
Definition: abc_global.h:232
DdNode * one
Definition: cuddInt.h:345
DdNode * Cudd_bddAnd(DdManager *dd, DdNode *f, DdNode *g)
Definition: cuddBddIte.c:314
static void ddClearFlag(DdNode *f)
Definition: cuddUtil.c:3735
int * invperm
Definition: cuddInt.h:388
#define DD_ONE(dd)
Definition: cuddInt.h:911
Cudd_ErrorType errorCode
Definition: cuddInt.h:447
DdNode * cuddUniqueInter(DdManager *unique, int index, DdNode *T, DdNode *E)
Definition: cuddTable.c:1128
int* Cudd_VectorSupportIndex ( DdManager dd,
DdNode **  F,
int  n 
)

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 an index array of the variables if successful; NULL otherwise.]

SideEffects [None]

SeeAlso [Cudd_SupportIndex Cudd_VectorSupport Cudd_ClassifySupport]

Definition at line 980 of file cuddUtil.c.

984 {
985  int *support;
986  int i;
987  int size;
988 
989  /* Allocate and initialize support array for ddSupportStep. */
990  size = ddMax(dd->size, dd->sizeZ);
991  support = ABC_ALLOC(int,size);
992  if (support == NULL) {
994  return(NULL);
995  }
996  for (i = 0; i < size; i++) {
997  support[i] = 0;
998  }
999 
1000  /* Compute support and clean up markers. */
1001  for (i = 0; i < n; i++) {
1002  ddSupportStep(Cudd_Regular(F[i]),support);
1003  }
1004  for (i = 0; i < n; i++) {
1005  ddClearFlag(Cudd_Regular(F[i]));
1006  }
1007 
1008  return(support);
1009 
1010 } /* end of Cudd_VectorSupportIndex */
int size
Definition: cuddInt.h:361
#define Cudd_Regular(node)
Definition: cudd.h:397
#define ABC_ALLOC(type, num)
Definition: abc_global.h:229
static void ddSupportStep(DdNode *f, int *support)
Definition: cuddUtil.c:3704
#define ddMax(x, y)
Definition: cuddInt.h:832
static int size
Definition: cuddSign.c:86
int support
Definition: abcSaucy.c:64
int sizeZ
Definition: cuddInt.h:362
static void ddClearFlag(DdNode *f)
Definition: cuddUtil.c:3735
Cudd_ErrorType errorCode
Definition: cuddInt.h:447
int Cudd_VectorSupportSize ( DdManager dd,
DdNode **  F,
int  n 
)

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

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

Description [Counts the variables on which a set of DDs depends. The set must contain either BDDs and ADDs, or ZDDs. Returns the number of the variables if successful; CUDD_OUT_OF_MEM otherwise.]

SideEffects [None]

SeeAlso [Cudd_VectorSupport Cudd_SupportSize]

Definition at line 1028 of file cuddUtil.c.

1032 {
1033  int *support;
1034  int i;
1035  int size;
1036  int count;
1037 
1038  /* Allocate and initialize support array for ddSupportStep. */
1039  size = ddMax(dd->size, dd->sizeZ);
1040  support = ABC_ALLOC(int,size);
1041  if (support == NULL) {
1042  dd->errorCode = CUDD_MEMORY_OUT;
1043  return(CUDD_OUT_OF_MEM);
1044  }
1045  for (i = 0; i < size; i++) {
1046  support[i] = 0;
1047  }
1048 
1049  /* Compute support and clean up markers. */
1050  for (i = 0; i < n; i++) {
1051  ddSupportStep(Cudd_Regular(F[i]),support);
1052  }
1053  for (i = 0; i < n; i++) {
1054  ddClearFlag(Cudd_Regular(F[i]));
1055  }
1056 
1057  /* Count vriables in support. */
1058  count = 0;
1059  for (i = 0; i < size; i++) {
1060  if (support[i] == 1) count++;
1061  }
1062 
1063  ABC_FREE(support);
1064  return(count);
1065 
1066 } /* end of Cudd_VectorSupportSize */
#define CUDD_OUT_OF_MEM
Definition: cudd.h:95
int size
Definition: cuddInt.h:361
#define Cudd_Regular(node)
Definition: cudd.h:397
#define ABC_ALLOC(type, num)
Definition: abc_global.h:229
static void ddSupportStep(DdNode *f, int *support)
Definition: cuddUtil.c:3704
#define ddMax(x, y)
Definition: cuddInt.h:832
static int size
Definition: cuddSign.c:86
int support
Definition: abcSaucy.c:64
int sizeZ
Definition: cuddInt.h:362
#define ABC_FREE(obj)
Definition: abc_global.h:232
static void ddClearFlag(DdNode *f)
Definition: cuddUtil.c:3735
Cudd_ErrorType errorCode
Definition: cuddInt.h:447
DdNode* Cudd_VerifySol ( DdManager bdd,
DdNode F,
DdNode **  G,
int *  yIndex,
int  n 
)

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

Synopsis [Checks the solution of F(x,y) = 0.]

Description [Checks the solution of F(x,y) = 0. This procedure substitutes the solution components for the unknowns of F and returns the resulting BDD for F.]

SideEffects [Frees the memory pointed by yIndex.]

SeeAlso [Cudd_SolveEqn]

Definition at line 169 of file cuddSolve.c.

175 {
176  DdNode *res;
177 
178  do {
179  bdd->reordered = 0;
180  res = cuddVerifySol(bdd, F, G, yIndex, n);
181  } while (bdd->reordered == 1);
182 
183  ABC_FREE(yIndex);
184 
185  return(res);
186 
187 } /* end of Cudd_VerifySol */
DdNode * cuddVerifySol(DdManager *bdd, DdNode *F, DdNode **G, int *yIndex, int n)
Definition: cuddSolve.c:336
Definition: cudd.h:278
int reordered
Definition: cuddInt.h:409
#define ABC_FREE(obj)
Definition: abc_global.h:232
DdNode* Cudd_Xeqy ( DdManager dd,
int  N,
DdNode **  x,
DdNode **  y 
)

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

Synopsis [Generates a BDD for the function x==y.]

Description [This function generates a BDD for the function x==y. Both x and y are N-bit numbers, x[0] x[1] ... x[N-1] and y[0] y[1] ... y[N-1], with 0 the most significant bit. The BDD is built bottom-up. It has 3*N-1 internal nodes, if the variables are ordered as follows: x[0] y[0] x[1] y[1] ... x[N-1] y[N-1]. ]

SideEffects [None]

SeeAlso [Cudd_addXeqy]

Definition at line 345 of file cuddPriority.c.

350 {
351  DdNode *u, *v, *w;
352  int i;
353 
354  /* Build bottom part of BDD outside loop. */
355  u = Cudd_bddIte(dd, x[N-1], y[N-1], Cudd_Not(y[N-1]));
356  if (u == NULL) return(NULL);
357  cuddRef(u);
358 
359  /* Loop to build the rest of the BDD. */
360  for (i = N-2; i >= 0; i--) {
361  v = Cudd_bddAnd(dd, y[i], u);
362  if (v == NULL) {
363  Cudd_RecursiveDeref(dd, u);
364  return(NULL);
365  }
366  cuddRef(v);
367  w = Cudd_bddAnd(dd, Cudd_Not(y[i]), u);
368  if (w == NULL) {
369  Cudd_RecursiveDeref(dd, u);
370  Cudd_RecursiveDeref(dd, v);
371  return(NULL);
372  }
373  cuddRef(w);
374  Cudd_RecursiveDeref(dd, u);
375  u = Cudd_bddIte(dd, x[i], v, w);
376  if (u == NULL) {
377  Cudd_RecursiveDeref(dd, v);
378  Cudd_RecursiveDeref(dd, w);
379  return(NULL);
380  }
381  cuddRef(u);
382  Cudd_RecursiveDeref(dd, v);
383  Cudd_RecursiveDeref(dd, w);
384  }
385  cuddDeref(u);
386  return(u);
387 
388 } /* end of Cudd_Xeqy */
#define cuddRef(n)
Definition: cuddInt.h:584
#define cuddDeref(n)
Definition: cuddInt.h:604
void Cudd_RecursiveDeref(DdManager *table, DdNode *n)
Definition: cuddRef.c:154
Definition: cudd.h:278
#define Cudd_Not(node)
Definition: cudd.h:367
DdNode * Cudd_bddIte(DdManager *dd, DdNode *f, DdNode *g, DdNode *h)
Definition: cuddBddIte.c:143
DdNode * Cudd_bddAnd(DdManager *dd, DdNode *f, DdNode *g)
Definition: cuddBddIte.c:314
DdNode* Cudd_Xgty ( DdManager dd,
int  N,
DdNode **  z,
DdNode **  x,
DdNode **  y 
)

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

Synopsis [Generates a BDD for the function x > y.]

Description [This function generates a BDD for the function x > y. Both x and y are N-bit numbers, x[0] x[1] ... x[N-1] and y[0] y[1] ... y[N-1], with 0 the most significant bit. The BDD is built bottom-up. It has 3*N-1 internal nodes, if the variables are ordered as follows: x[0] y[0] x[1] y[1] ... x[N-1] y[N-1]. Argument z is not used by Cudd_Xgty: it is included to make it call-compatible to Cudd_Dxygtdxz and Cudd_Dxygtdyz.]

SideEffects [None]

SeeAlso [Cudd_PrioritySelect Cudd_Dxygtdxz Cudd_Dxygtdyz]

Definition at line 280 of file cuddPriority.c.

286 {
287  DdNode *u, *v, *w;
288  int i;
289 
290  /* Build bottom part of BDD outside loop. */
291  u = Cudd_bddAnd(dd, x[N-1], Cudd_Not(y[N-1]));
292  if (u == NULL) return(NULL);
293  cuddRef(u);
294 
295  /* Loop to build the rest of the BDD. */
296  for (i = N-2; i >= 0; i--) {
297  v = Cudd_bddAnd(dd, y[i], Cudd_Not(u));
298  if (v == NULL) {
299  Cudd_RecursiveDeref(dd, u);
300  return(NULL);
301  }
302  cuddRef(v);
303  w = Cudd_bddAnd(dd, Cudd_Not(y[i]), u);
304  if (w == NULL) {
305  Cudd_RecursiveDeref(dd, u);
306  Cudd_RecursiveDeref(dd, v);
307  return(NULL);
308  }
309  cuddRef(w);
310  Cudd_RecursiveDeref(dd, u);
311  u = Cudd_bddIte(dd, x[i], Cudd_Not(v), w);
312  if (u == NULL) {
313  Cudd_RecursiveDeref(dd, v);
314  Cudd_RecursiveDeref(dd, w);
315  return(NULL);
316  }
317  cuddRef(u);
318  Cudd_RecursiveDeref(dd, v);
319  Cudd_RecursiveDeref(dd, w);
320 
321  }
322  cuddDeref(u);
323  return(u);
324 
325 } /* end of Cudd_Xgty */
#define cuddRef(n)
Definition: cuddInt.h:584
#define cuddDeref(n)
Definition: cuddInt.h:604
void Cudd_RecursiveDeref(DdManager *table, DdNode *n)
Definition: cuddRef.c:154
Definition: cudd.h:278
#define Cudd_Not(node)
Definition: cudd.h:367
DdNode * Cudd_bddIte(DdManager *dd, DdNode *f, DdNode *g, DdNode *h)
Definition: cuddBddIte.c:143
DdNode * Cudd_bddAnd(DdManager *dd, DdNode *f, DdNode *g)
Definition: cuddBddIte.c:314
DdNode* Cudd_zddChange ( DdManager dd,
DdNode P,
int  var 
)

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

Synopsis [Substitutes a variable with its complement in a ZDD.]

Description [Substitutes a variable with its complement in a ZDD. returns a pointer to the result if successful; NULL otherwise.]

SideEffects [None]

SeeAlso []

Definition at line 392 of file cuddZddSetop.c.

396 {
397  DdNode *res;
398 
399  if ((unsigned int) var >= CUDD_MAXINDEX - 1) return(NULL);
400 
401  do {
402  dd->reordered = 0;
403  res = cuddZddChange(dd, P, var);
404  } while (dd->reordered == 1);
405  return(res);
406 
407 } /* end of Cudd_zddChange */
Definition: cudd.h:278
int var(Lit p)
Definition: SolverTypes.h:62
int reordered
Definition: cuddInt.h:409
DdNode * cuddZddChange(DdManager *dd, DdNode *P, int var)
Definition: cuddZddSetop.c:971
#define CUDD_MAXINDEX
Definition: cudd.h:112
DdNode* Cudd_zddComplement ( DdManager dd,
DdNode node 
)

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

Synopsis [Computes a complement cover for a ZDD node.]

Description [Computes a complement cover for a ZDD node. For lack of a better method, we first extract the function BDD from the ZDD cover, then make the complement of the ZDD cover from the complement of the BDD node by using ISOP. Returns a pointer to the resulting cover if successful; NULL otherwise. The result depends on current variable order.]

SideEffects [The result depends on current variable order.]

SeeAlso []

Definition at line 332 of file cuddZddFuncs.c.

335 {
336  DdNode *b, *isop, *zdd_I;
337 
338  /* Check cache */
339  zdd_I = cuddCacheLookup1Zdd(dd, cuddZddComplement, node);
340  if (zdd_I)
341  return(zdd_I);
342 
343  b = Cudd_MakeBddFromZddCover(dd, node);
344  if (!b)
345  return(NULL);
346  Cudd_Ref(b);
347  isop = Cudd_zddIsop(dd, Cudd_Not(b), Cudd_Not(b), &zdd_I);
348  if (!isop) {
349  Cudd_RecursiveDeref(dd, b);
350  return(NULL);
351  }
352  Cudd_Ref(isop);
353  Cudd_Ref(zdd_I);
354  Cudd_RecursiveDeref(dd, b);
355  Cudd_RecursiveDeref(dd, isop);
356 
357  cuddCacheInsert1(dd, cuddZddComplement, node, zdd_I);
358  Cudd_Deref(zdd_I);
359  return(zdd_I);
360 } /* end of Cudd_zddComplement */
void Cudd_RecursiveDeref(DdManager *table, DdNode *n)
Definition: cuddRef.c:154
Definition: cudd.h:278
#define Cudd_Not(node)
Definition: cudd.h:367
void Cudd_Deref(DdNode *node)
Definition: cuddRef.c:438
DdNode * Cudd_MakeBddFromZddCover(DdManager *dd, DdNode *node)
Definition: cuddZddIsop.c:203
DdNode * Cudd_zddIsop(DdManager *dd, DdNode *L, DdNode *U, DdNode **zdd_I)
Definition: cuddZddIsop.c:136
void Cudd_Ref(DdNode *n)
Definition: cuddRef.c:129
DdNode * cuddZddComplement(DdManager *dd, DdNode *node)
DdNode * cuddCacheLookup1Zdd(DdManager *table, DD_CTFP1 op, DdNode *f)
Definition: cuddCache.c:664
void cuddCacheInsert1(DdManager *table, DD_CTFP1 op, DdNode *f, DdNode *data)
Definition: cuddCache.c:323
int Cudd_zddCount ( DdManager zdd,
DdNode P 
)

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

Synopsis [Counts the number of minterms in a ZDD.]

Description [Returns an integer representing the number of minterms in a ZDD.]

SideEffects [None]

SeeAlso [Cudd_zddCountDouble]

Definition at line 137 of file cuddZddCount.c.

140 {
141  st__table *table;
142  int res;
143  DdNode *base, *empty;
144 
145  base = DD_ONE(zdd);
146  empty = DD_ZERO(zdd);
148  if (table == NULL) return(CUDD_OUT_OF_MEM);
149  res = cuddZddCountStep(P, table, base, empty);
150  if (res == CUDD_OUT_OF_MEM) {
151  zdd->errorCode = CUDD_MEMORY_OUT;
152  }
153  st__foreach(table, st__zdd_countfree, NIL(char));
154  st__free_table(table);
155 
156  return(res);
157 
158 } /* end of Cudd_zddCount */
void st__free_table(st__table *table)
Definition: st.c:81
#define CUDD_OUT_OF_MEM
Definition: cudd.h:95
Definition: cudd.h:278
int st__ptrcmp(const char *, const char *)
Definition: st.c:480
static enum st__retval st__zdd_countfree(char *key, char *value, char *arg)
Definition: cuddZddCount.c:323
static int cuddZddCountStep(DdNode *P, st__table *table, DdNode *base, DdNode *empty)
Definition: cuddZddCount.c:222
#define NIL(type)
Definition: avl.h:25
st__table * st__init_table(st__compare_func_type compare, st__hash_func_type hash)
Definition: st.c:72
Definition: st.h:52
int st__foreach(st__table *table, enum st__retval(*func)(char *, char *, char *), char *arg)
Definition: st.c:421
static DdNode * empty
Definition: cuddZddLin.c:98
#define DD_ONE(dd)
Definition: cuddInt.h:911
Cudd_ErrorType errorCode
Definition: cuddInt.h:447
int st__ptrhash(const char *, int)
Definition: st.c:468
#define DD_ZERO(dd)
Definition: cuddInt.h:927
double Cudd_zddCountDouble ( DdManager zdd,
DdNode P 
)

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

Synopsis [Counts the number of minterms of a ZDD.]

Description [Counts the number of minterms of a ZDD. The result is returned as a double. If the procedure runs out of memory, it returns (double) CUDD_OUT_OF_MEM. This procedure is used in Cudd_zddCountMinterm.]

SideEffects [None]

SeeAlso [Cudd_zddCountMinterm Cudd_zddCount]

Definition at line 176 of file cuddZddCount.c.

179 {
180  st__table *table;
181  double res;
182  DdNode *base, *empty;
183 
184  base = DD_ONE(zdd);
185  empty = DD_ZERO(zdd);
187  if (table == NULL) return((double)CUDD_OUT_OF_MEM);
188  res = cuddZddCountDoubleStep(P, table, base, empty);
189  if (res == (double)CUDD_OUT_OF_MEM) {
190  zdd->errorCode = CUDD_MEMORY_OUT;
191  }
192  st__foreach(table, st__zdd_count_dbl_free, NIL(char));
193  st__free_table(table);
194 
195  return(res);
196 
197 } /* end of Cudd_zddCountDouble */
void st__free_table(st__table *table)
Definition: st.c:81
#define CUDD_OUT_OF_MEM
Definition: cudd.h:95
Definition: cudd.h:278
int st__ptrcmp(const char *, const char *)
Definition: st.c:480
#define NIL(type)
Definition: avl.h:25
st__table * st__init_table(st__compare_func_type compare, st__hash_func_type hash)
Definition: st.c:72
Definition: st.h:52
int st__foreach(st__table *table, enum st__retval(*func)(char *, char *, char *), char *arg)
Definition: st.c:421
static DdNode * empty
Definition: cuddZddLin.c:98
#define DD_ONE(dd)
Definition: cuddInt.h:911
static double cuddZddCountDoubleStep(DdNode *P, st__table *table, DdNode *base, DdNode *empty)
Definition: cuddZddCount.c:272
Cudd_ErrorType errorCode
Definition: cuddInt.h:447
int st__ptrhash(const char *, int)
Definition: st.c:468
static enum st__retval st__zdd_count_dbl_free(char *key, char *value, char *arg)
Definition: cuddZddCount.c:350
#define DD_ZERO(dd)
Definition: cuddInt.h:927
double Cudd_zddCountMinterm ( DdManager zdd,
DdNode node,
int  path 
)

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

Synopsis [Counts the number of minterms of a ZDD.]

Description [Counts the number of minterms of the ZDD rooted at node. This procedure takes a parameter path that specifies how many variables are in the support of the function. If the procedure runs out of memory, it returns (double) CUDD_OUT_OF_MEM.]

SideEffects [None]

SeeAlso [Cudd_zddCountDouble]

Definition at line 158 of file cuddZddMisc.c.

162 {
163  double dc_var, minterms;
164 
165  dc_var = (double)((double)(zdd->sizeZ) - (double)path);
166  minterms = Cudd_zddCountDouble(zdd, node) / pow(2.0, dc_var);
167  return(minterms);
168 
169 } /* end of Cudd_zddCountMinterm */
int sizeZ
Definition: cuddInt.h:362
double Cudd_zddCountDouble(DdManager *zdd, DdNode *P)
Definition: cuddZddCount.c:176
pset minterms()
char* Cudd_zddCoverPathToString ( DdManager zdd,
int *  path,
char *  str 
)

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

Synopsis [Converts a path of a ZDD representing a cover to a string.]

Description [Converts a path of a ZDD representing a cover to a string. The string represents an implicant of the cover. The path is typically produced by Cudd_zddForeachPath. Returns a pointer to the string if successful; NULL otherwise. If the str input is NULL, it allocates a new string. The string passed to this function must have enough room for all variables and for the terminator.]

SideEffects [None]

SeeAlso [Cudd_zddForeachPath]

Definition at line 475 of file cuddZddUtil.c.

480 {
481  int nvars = zdd->sizeZ;
482  int i;
483  char *res;
484 
485  if (nvars & 1) return(NULL);
486  nvars >>= 1;
487  if (str == NULL) {
488  res = ABC_ALLOC(char, nvars+1);
489  if (res == NULL) return(NULL);
490  } else {
491  res = str;
492  }
493  for (i = 0; i < nvars; i++) {
494  int v = (path[2*i] << 2) | path[2*i+1];
495  switch (v) {
496  case 0:
497  case 2:
498  case 8:
499  case 10:
500  res[i] = '-';
501  break;
502  case 1:
503  case 9:
504  res[i] = '0';
505  break;
506  case 4:
507  case 6:
508  res[i] = '1';
509  break;
510  default:
511  res[i] = '?';
512  }
513  }
514  res[nvars] = 0;
515 
516  return(res);
517 
518 } /* end of Cudd_zddCoverPathToString */
#define ABC_ALLOC(type, num)
Definition: abc_global.h:229
int sizeZ
Definition: cuddInt.h:362
int Cudd_zddDagSize ( DdNode p_node)

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

Synopsis [Counts the number of nodes in a ZDD.]

Description [Counts the number of nodes in a ZDD. This function duplicates Cudd_DagSize and is only retained for compatibility.]

SideEffects [None]

SeeAlso [Cudd_DagSize]

Definition at line 127 of file cuddZddMisc.c.

129 {
130 
131  int i;
132  st__table *table;
133 
135  i = cuddZddDagInt(p_node, table);
136  st__free_table(table);
137  return(i);
138 
139 } /* end of Cudd_zddDagSize */
void st__free_table(st__table *table)
Definition: st.c:81
int st__ptrcmp(const char *, const char *)
Definition: st.c:480
st__table * st__init_table(st__compare_func_type compare, st__hash_func_type hash)
Definition: st.c:72
Definition: st.h:52
static int cuddZddDagInt(DdNode *n, st__table *tab)
Definition: cuddZddMisc.c:265
int st__ptrhash(const char *, int)
Definition: st.c:468
DdNode* Cudd_zddDiff ( DdManager dd,
DdNode P,
DdNode Q 
)

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

Synopsis [Computes the difference of two ZDDs.]

Description [Computes the difference of two ZDDs. Returns a pointer to the result if successful; NULL otherwise.]

SideEffects [None]

SeeAlso [Cudd_zddDiffConst]

Definition at line 236 of file cuddZddSetop.c.

240 {
241  DdNode *res;
242 
243  do {
244  dd->reordered = 0;
245  res = cuddZddDiff(dd, P, Q);
246  } while (dd->reordered == 1);
247  return(res);
248 
249 } /* end of Cudd_zddDiff */
Definition: cudd.h:278
int reordered
Definition: cuddInt.h:409
DdNode * cuddZddDiff(DdManager *zdd, DdNode *P, DdNode *Q)
Definition: cuddZddSetop.c:717
DdNode* Cudd_zddDiffConst ( DdManager zdd,
DdNode P,
DdNode Q 
)

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

Synopsis [Performs the inclusion test for ZDDs (P implies Q).]

Description [Inclusion test for ZDDs (P implies Q). No new nodes are generated by this procedure. Returns empty if true; a valid pointer different from empty or DD_NON_CONSTANT otherwise.]

SideEffects [None]

SeeAlso [Cudd_zddDiff]

Definition at line 266 of file cuddZddSetop.c.

270 {
271  int p_top, q_top;
272  DdNode *empty = DD_ZERO(zdd), *t, *res;
273  DdManager *table = zdd;
274 
275  statLine(zdd);
276  if (P == empty)
277  return(empty);
278  if (Q == empty)
279  return(P);
280  if (P == Q)
281  return(empty);
282 
283  /* Check cache. The cache is shared by cuddZddDiff(). */
284  res = cuddCacheLookup2Zdd(table, cuddZddDiff, P, Q);
285  if (res != NULL)
286  return(res);
287 
288  if (cuddIsConstant(P))
289  p_top = P->index;
290  else
291  p_top = zdd->permZ[P->index];
292  if (cuddIsConstant(Q))
293  q_top = Q->index;
294  else
295  q_top = zdd->permZ[Q->index];
296  if (p_top < q_top) {
297  res = DD_NON_CONSTANT;
298  } else if (p_top > q_top) {
299  res = Cudd_zddDiffConst(zdd, P, cuddE(Q));
300  } else {
301  t = Cudd_zddDiffConst(zdd, cuddT(P), cuddT(Q));
302  if (t != empty)
303  res = DD_NON_CONSTANT;
304  else
305  res = Cudd_zddDiffConst(zdd, cuddE(P), cuddE(Q));
306  }
307 
308  cuddCacheInsert2(table, cuddZddDiff, P, Q, res);
309 
310  return(res);
311 
312 } /* end of Cudd_zddDiffConst */
DdNode * cuddCacheLookup2Zdd(DdManager *table, DD_CTFP op, DdNode *f, DdNode *g)
Definition: cuddCache.c:610
Definition: cudd.h:278
void cuddCacheInsert2(DdManager *table, DD_CTFP op, DdNode *f, DdNode *g, DdNode *data)
Definition: cuddCache.c:277
int * permZ
Definition: cuddInt.h:387
#define statLine(dd)
Definition: cuddInt.h:1037
#define cuddIsConstant(node)
Definition: cuddInt.h:620
#define cuddT(node)
Definition: cuddInt.h:636
DdNode * Cudd_zddDiffConst(DdManager *zdd, DdNode *P, DdNode *Q)
Definition: cuddZddSetop.c:266
DdNode * cuddZddDiff(DdManager *zdd, DdNode *P, DdNode *Q)
Definition: cuddZddSetop.c:717
DdHalfWord index
Definition: cudd.h:279
#define cuddE(node)
Definition: cuddInt.h:652
static DdNode * empty
Definition: cuddZddLin.c:98
#define DD_NON_CONSTANT
Definition: cuddInt.h:123
#define DD_ZERO(dd)
Definition: cuddInt.h:927
DdNode* Cudd_zddDivide ( DdManager dd,
DdNode f,
DdNode g 
)

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

Synopsis [Computes the quotient of two unate covers.]

Description [Computes the quotient of two unate covers represented by ZDDs. Unate covers use one ZDD variable for each BDD variable. Returns a pointer to the resulting ZDD if successful; NULL otherwise.]

SideEffects [None]

SeeAlso [Cudd_zddWeakDiv]

Definition at line 241 of file cuddZddFuncs.c.

245 {
246  DdNode *res;
247 
248  do {
249  dd->reordered = 0;
250  res = cuddZddDivide(dd, f, g);
251  } while (dd->reordered == 1);
252  return(res);
253 
254 } /* end of Cudd_zddDivide */
DdNode * cuddZddDivide(DdManager *dd, DdNode *f, DdNode *g)
Definition: cudd.h:278
int reordered
Definition: cuddInt.h:409
DdNode* Cudd_zddDivideF ( DdManager dd,
DdNode f,
DdNode g 
)

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

Synopsis [Modified version of Cudd_zddDivide.]

Description [Modified version of Cudd_zddDivide. This function may disappear in future releases.]

SideEffects [None]

SeeAlso []

Definition at line 299 of file cuddZddFuncs.c.

303 {
304  DdNode *res;
305 
306  do {
307  dd->reordered = 0;
308  res = cuddZddDivideF(dd, f, g);
309  } while (dd->reordered == 1);
310  return(res);
311 
312 } /* end of Cudd_zddDivideF */
Definition: cudd.h:278
int reordered
Definition: cuddInt.h:409
DdNode * cuddZddDivideF(DdManager *dd, DdNode *f, DdNode *g)
int Cudd_zddDumpDot ( DdManager dd,
int  n,
DdNode **  f,
char **  inames,
char **  onames,
FILE *  fp 
)

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

Synopsis [Writes a dot file representing the argument ZDDs.]

Description [Writes a file representing the argument ZDDs in a format suitable for the graph drawing program dot. It returns 1 in case of success; 0 otherwise (e.g., out-of-memory, file system full). Cudd_zddDumpDot does not close the file: This is the caller responsibility. Cudd_zddDumpDot uses a minimal unique subset of the hexadecimal address of a node as name for it. If the argument inames is non-null, it is assumed to hold the pointers to the names of the inputs. Similarly for onames. Cudd_zddDumpDot uses the following convention to draw arcs:

  • solid line: THEN arcs;
  • dashed line: ELSE arcs.

The dot options are chosen so that the drawing fits on a letter-size sheet. ]

SideEffects [None]

SeeAlso [Cudd_DumpDot Cudd_zddPrintDebug]

Definition at line 549 of file cuddZddUtil.c.

556 {
557  DdNode *support = NULL;
558  DdNode *scan;
559  int *sorted = NULL;
560  int nvars = dd->sizeZ;
561  st__table *visited = NULL;
562  st__generator *gen;
563  int retval;
564  int i, j;
565  int slots;
566  DdNodePtr *nodelist;
567  long refAddr, diff, mask;
568 
569  /* Build a bit array with the support of f. */
570  sorted = ABC_ALLOC(int,nvars);
571  if (sorted == NULL) {
573  goto failure;
574  }
575  for (i = 0; i < nvars; i++) sorted[i] = 0;
576 
577  /* Take the union of the supports of each output function. */
578  for (i = 0; i < n; i++) {
579  support = Cudd_Support(dd,f[i]);
580  if (support == NULL) goto failure;
581  cuddRef(support);
582  scan = support;
583  while (!cuddIsConstant(scan)) {
584  sorted[scan->index] = 1;
585  scan = cuddT(scan);
586  }
587  Cudd_RecursiveDeref(dd,support);
588  }
589  support = NULL; /* so that we do not try to free it in case of failure */
590 
591  /* Initialize symbol table for visited nodes. */
593  if (visited == NULL) goto failure;
594 
595  /* Collect all the nodes of this DD in the symbol table. */
596  for (i = 0; i < n; i++) {
597  retval = cuddCollectNodes(f[i],visited);
598  if (retval == 0) goto failure;
599  }
600 
601  /* Find how many most significant hex digits are identical
602  ** in the addresses of all the nodes. Build a mask based
603  ** on this knowledge, so that digits that carry no information
604  ** will not be printed. This is done in two steps.
605  ** 1. We scan the symbol table to find the bits that differ
606  ** in at least 2 addresses.
607  ** 2. We choose one of the possible masks. There are 8 possible
608  ** masks for 32-bit integer, and 16 possible masks for 64-bit
609  ** integers.
610  */
611 
612  /* Find the bits that are different. */
613  refAddr = (long) f[0];
614  diff = 0;
615  gen = st__init_gen(visited);
616  while ( st__gen(gen, (const char **)&scan, NULL)) {
617  diff |= refAddr ^ (long) scan;
618  }
619  st__free_gen(gen);
620 
621  /* Choose the mask. */
622  for (i = 0; (unsigned) i < 8 * sizeof(long); i += 4) {
623  mask = (1 << i) - 1;
624  if (diff <= mask) break;
625  }
626 
627  /* Write the header and the global attributes. */
628  retval = fprintf(fp,"digraph \"ZDD\" {\n");
629  if (retval == EOF) return(0);
630  retval = fprintf(fp,
631  "size = \"7.5,10\"\ncenter = true;\nedge [dir = none];\n");
632  if (retval == EOF) return(0);
633 
634  /* Write the input name subgraph by scanning the support array. */
635  retval = fprintf(fp,"{ node [shape = plaintext];\n");
636  if (retval == EOF) goto failure;
637  retval = fprintf(fp," edge [style = invis];\n");
638  if (retval == EOF) goto failure;
639  /* We use a name ("CONST NODES") with an embedded blank, because
640  ** it is unlikely to appear as an input name.
641  */
642  retval = fprintf(fp," \"CONST NODES\" [style = invis];\n");
643  if (retval == EOF) goto failure;
644  for (i = 0; i < nvars; i++) {
645  if (sorted[dd->invpermZ[i]]) {
646  if (inames == NULL) {
647  retval = fprintf(fp,"\" %d \" -> ", dd->invpermZ[i]);
648  } else {
649  retval = fprintf(fp,"\" %s \" -> ", inames[dd->invpermZ[i]]);
650  }
651  if (retval == EOF) goto failure;
652  }
653  }
654  retval = fprintf(fp,"\"CONST NODES\"; \n}\n");
655  if (retval == EOF) goto failure;
656 
657  /* Write the output node subgraph. */
658  retval = fprintf(fp,"{ rank = same; node [shape = box]; edge [style = invis];\n");
659  if (retval == EOF) goto failure;
660  for (i = 0; i < n; i++) {
661  if (onames == NULL) {
662  retval = fprintf(fp,"\"F%d\"", i);
663  } else {
664  retval = fprintf(fp,"\" %s \"", onames[i]);
665  }
666  if (retval == EOF) goto failure;
667  if (i == n - 1) {
668  retval = fprintf(fp,"; }\n");
669  } else {
670  retval = fprintf(fp," -> ");
671  }
672  if (retval == EOF) goto failure;
673  }
674 
675  /* Write rank info: All nodes with the same index have the same rank. */
676  for (i = 0; i < nvars; i++) {
677  if (sorted[dd->invpermZ[i]]) {
678  retval = fprintf(fp,"{ rank = same; ");
679  if (retval == EOF) goto failure;
680  if (inames == NULL) {
681  retval = fprintf(fp,"\" %d \";\n", dd->invpermZ[i]);
682  } else {
683  retval = fprintf(fp,"\" %s \";\n", inames[dd->invpermZ[i]]);
684  }
685  if (retval == EOF) goto failure;
686  nodelist = dd->subtableZ[i].nodelist;
687  slots = dd->subtableZ[i].slots;
688  for (j = 0; j < slots; j++) {
689  scan = nodelist[j];
690  while (scan != NULL) {
691  if ( st__is_member(visited,(char *) scan)) {
692  retval = fprintf(fp,"\"%p\";\n", (void *)
693  ((mask & (ptrint) scan) /
694  sizeof(DdNode)));
695  if (retval == EOF) goto failure;
696  }
697  scan = scan->next;
698  }
699  }
700  retval = fprintf(fp,"}\n");
701  if (retval == EOF) goto failure;
702  }
703  }
704 
705  /* All constants have the same rank. */
706  retval = fprintf(fp,
707  "{ rank = same; \"CONST NODES\";\n{ node [shape = box]; ");
708  if (retval == EOF) goto failure;
709  nodelist = dd->constants.nodelist;
710  slots = dd->constants.slots;
711  for (j = 0; j < slots; j++) {
712  scan = nodelist[j];
713  while (scan != NULL) {
714  if ( st__is_member(visited,(char *) scan)) {
715  retval = fprintf(fp,"\"%p\";\n", (void *)
716  ((mask & (ptrint) scan) / sizeof(DdNode)));
717  if (retval == EOF) goto failure;
718  }
719  scan = scan->next;
720  }
721  }
722  retval = fprintf(fp,"}\n}\n");
723  if (retval == EOF) goto failure;
724 
725  /* Write edge info. */
726  /* Edges from the output nodes. */
727  for (i = 0; i < n; i++) {
728  if (onames == NULL) {
729  retval = fprintf(fp,"\"F%d\"", i);
730  } else {
731  retval = fprintf(fp,"\" %s \"", onames[i]);
732  }
733  if (retval == EOF) goto failure;
734  retval = fprintf(fp," -> \"%p\" [style = solid];\n",
735  (void *) ((mask & (ptrint) f[i]) /
736  sizeof(DdNode)));
737  if (retval == EOF) goto failure;
738  }
739 
740  /* Edges from internal nodes. */
741  for (i = 0; i < nvars; i++) {
742  if (sorted[dd->invpermZ[i]]) {
743  nodelist = dd->subtableZ[i].nodelist;
744  slots = dd->subtableZ[i].slots;
745  for (j = 0; j < slots; j++) {
746  scan = nodelist[j];
747  while (scan != NULL) {
748  if ( st__is_member(visited,(char *) scan)) {
749  retval = fprintf(fp,
750  "\"%p\" -> \"%p\";\n",
751  (void *) ((mask & (ptrint) scan) / sizeof(DdNode)),
752  (void *) ((mask & (ptrint) cuddT(scan)) /
753  sizeof(DdNode)));
754  if (retval == EOF) goto failure;
755  retval = fprintf(fp,
756  "\"%p\" -> \"%p\" [style = dashed];\n",
757  (void *) ((mask & (ptrint) scan)
758  / sizeof(DdNode)),
759  (void *) ((mask & (ptrint)
760  cuddE(scan)) /
761  sizeof(DdNode)));
762  if (retval == EOF) goto failure;
763  }
764  scan = scan->next;
765  }
766  }
767  }
768  }
769 
770  /* Write constant labels. */
771  nodelist = dd->constants.nodelist;
772  slots = dd->constants.slots;
773  for (j = 0; j < slots; j++) {
774  scan = nodelist[j];
775  while (scan != NULL) {
776  if ( st__is_member(visited,(char *) scan)) {
777  retval = fprintf(fp,"\"%p\" [label = \"%g\"];\n",
778  (void *) ((mask & (ptrint) scan) /
779  sizeof(DdNode)),
780  cuddV(scan));
781  if (retval == EOF) goto failure;
782  }
783  scan = scan->next;
784  }
785  }
786 
787  /* Write trailer and return. */
788  retval = fprintf(fp,"}\n");
789  if (retval == EOF) goto failure;
790 
791  st__free_table(visited);
792  ABC_FREE(sorted);
793  return(1);
794 
795 failure:
796  if (sorted != NULL) ABC_FREE(sorted);
797  if (visited != NULL) st__free_table(visited);
798  return(0);
799 
800 } /* end of Cudd_zddDumpBlif */
void st__free_table(st__table *table)
Definition: st.c:81
#define cuddRef(n)
Definition: cuddInt.h:584
void Cudd_RecursiveDeref(DdManager *table, DdNode *n)
Definition: cuddRef.c:154
Definition: cudd.h:278
int * invpermZ
Definition: cuddInt.h:389
void st__free_gen(st__generator *gen)
Definition: st.c:556
DdNode * Cudd_Support(DdManager *dd, DdNode *f)
Definition: cuddUtil.c:740
int st__ptrcmp(const char *, const char *)
Definition: st.c:480
#define ABC_ALLOC(type, num)
Definition: abc_global.h:229
#define st__is_member(table, key)
Definition: st.h:70
#define cuddV(node)
Definition: cuddInt.h:668
static const char * onames[]
Definition: testcudd.c:71
st__table * st__init_table(st__compare_func_type compare, st__hash_func_type hash)
Definition: st.c:72
ABC_PTRINT_T ptrint
Definition: cuddInt.h:260
Definition: st.h:52
#define cuddIsConstant(node)
Definition: cuddInt.h:620
DdNode ** nodelist
Definition: cuddInt.h:327
#define cuddT(node)
Definition: cuddInt.h:636
st__generator * st__init_gen(st__table *table)
Definition: st.c:486
int support
Definition: abcSaucy.c:64
int sizeZ
Definition: cuddInt.h:362
DdHalfWord index
Definition: cudd.h:279
#define ABC_FREE(obj)
Definition: abc_global.h:232
unsigned int slots
Definition: cuddInt.h:329
#define cuddE(node)
Definition: cuddInt.h:652
int cuddCollectNodes(DdNode *f, st__table *visited)
Definition: cuddUtil.c:2925
DdSubtable constants
Definition: cuddInt.h:367
Cudd_ErrorType errorCode
Definition: cuddInt.h:447
int st__ptrhash(const char *, int)
Definition: st.c:468
int st__gen(st__generator *gen, const char **key_p, char **value_p)
Definition: st.c:502
DdSubtable * subtableZ
Definition: cuddInt.h:366
DdGen* Cudd_zddFirstPath ( DdManager zdd,
DdNode f,
int **  path 
)

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

Synopsis [Finds the first path of a ZDD.]

Description [Defines an iterator on the paths of a ZDD and finds its first path. Returns a generator that contains the information necessary to continue the enumeration if successful; NULL otherwise.

A path is represented as an array of literals, which are integers in {0, 1, 2}; 0 represents an else arc out of a node, 1 represents a then arc out of a node, and 2 stands for the absence of a node. The size of the array equals the number of variables in the manager at the time Cudd_zddFirstCube is called.

The paths that end in the empty terminal are not enumerated.]

SideEffects [The first path is returned as a side effect.]

SeeAlso [Cudd_zddForeachPath Cudd_zddNextPath Cudd_GenFree Cudd_IsGenEmpty]

Definition at line 275 of file cuddZddUtil.c.

279 {
280  DdGen *gen;
281  DdNode *top, *next, *prev;
282  int i;
283  int nvars;
284 
285  /* Sanity Check. */
286  if (zdd == NULL || f == NULL) return(NULL);
287 
288  /* Allocate generator an initialize it. */
289  gen = ABC_ALLOC(DdGen,1);
290  if (gen == NULL) {
291  zdd->errorCode = CUDD_MEMORY_OUT;
292  return(NULL);
293  }
294 
295  gen->manager = zdd;
296  gen->type = CUDD_GEN_ZDD_PATHS;
297  gen->status = CUDD_GEN_EMPTY;
298  gen->gen.cubes.cube = NULL;
299  gen->gen.cubes.value = DD_ZERO_VAL;
300  gen->stack.sp = 0;
301  gen->stack.stack = NULL;
302  gen->node = NULL;
303 
304  nvars = zdd->sizeZ;
305  gen->gen.cubes.cube = ABC_ALLOC(int,nvars);
306  if (gen->gen.cubes.cube == NULL) {
307  zdd->errorCode = CUDD_MEMORY_OUT;
308  ABC_FREE(gen);
309  return(NULL);
310  }
311  for (i = 0; i < nvars; i++) gen->gen.cubes.cube[i] = 2;
312 
313  /* The maximum stack depth is one plus the number of variables.
314  ** because a path may have nodes at all levels, including the
315  ** constant level.
316  */
317  gen->stack.stack = ABC_ALLOC(DdNodePtr, nvars+1);
318  if (gen->stack.stack == NULL) {
319  zdd->errorCode = CUDD_MEMORY_OUT;
320  ABC_FREE(gen->gen.cubes.cube);
321  ABC_FREE(gen);
322  return(NULL);
323  }
324  for (i = 0; i <= nvars; i++) gen->stack.stack[i] = NULL;
325 
326  /* Find the first path of the ZDD. */
327  gen->stack.stack[gen->stack.sp] = f; gen->stack.sp++;
328 
329  while (1) {
330  top = gen->stack.stack[gen->stack.sp-1];
331  if (!cuddIsConstant(Cudd_Regular(top))) {
332  /* Take the else branch first. */
333  gen->gen.cubes.cube[Cudd_Regular(top)->index] = 0;
334  next = cuddE(Cudd_Regular(top));
335  gen->stack.stack[gen->stack.sp] = Cudd_Not(next); gen->stack.sp++;
336  } else if (Cudd_Regular(top) == DD_ZERO(zdd)) {
337  /* Backtrack. */
338  while (1) {
339  if (gen->stack.sp == 1) {
340  /* The current node has no predecessor. */
341  gen->status = CUDD_GEN_EMPTY;
342  gen->stack.sp--;
343  goto done;
344  }
345  prev = Cudd_Regular(gen->stack.stack[gen->stack.sp-2]);
346  next = cuddT(prev);
347  if (next != top) { /* follow the then branch next */
348  gen->gen.cubes.cube[prev->index] = 1;
349  gen->stack.stack[gen->stack.sp-1] = next;
350  break;
351  }
352  /* Pop the stack and try again. */
353  gen->gen.cubes.cube[prev->index] = 2;
354  gen->stack.sp--;
355  top = gen->stack.stack[gen->stack.sp-1];
356  }
357  } else {
358  gen->status = CUDD_GEN_NONEMPTY;
359  gen->gen.cubes.value = cuddV(Cudd_Regular(top));
360  goto done;
361  }
362  }
363 
364 done:
365  *path = gen->gen.cubes.cube;
366  return(gen);
367 
368 } /* end of Cudd_zddFirstPath */
DdNode * node
Definition: cuddInt.h:232
int type
Definition: cuddInt.h:206
Definition: cudd.h:278
#define Cudd_Not(node)
Definition: cudd.h:367
#define CUDD_GEN_ZDD_PATHS
Definition: cuddInt.h:195
struct DdGen::@30::@32 cubes
#define Cudd_Regular(node)
Definition: cudd.h:397
#define ABC_ALLOC(type, num)
Definition: abc_global.h:229
Definition: cuddInt.h:204
#define DD_ZERO_VAL
Definition: cuddInt.h:108
#define CUDD_GEN_NONEMPTY
Definition: cuddInt.h:197
#define cuddV(node)
Definition: cuddInt.h:668
DdNode ** stack
Definition: cuddInt.h:227
DdManager * manager
Definition: cuddInt.h:205
#define cuddIsConstant(node)
Definition: cuddInt.h:620
#define cuddT(node)
Definition: cuddInt.h:636
union DdGen::@30 gen
#define CUDD_GEN_EMPTY
Definition: cuddInt.h:196
int sizeZ
Definition: cuddInt.h:362
DdHalfWord index
Definition: cudd.h:279
#define ABC_FREE(obj)
Definition: abc_global.h:232
#define cuddE(node)
Definition: cuddInt.h:652
Cudd_ErrorType errorCode
Definition: cuddInt.h:447
int status
Definition: cuddInt.h:207
#define DD_ZERO(dd)
Definition: cuddInt.h:927
DdNode* Cudd_zddIntersect ( DdManager dd,
DdNode P,
DdNode Q 
)

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

Synopsis [Computes the intersection of two ZDDs.]

Description [Computes the intersection of two ZDDs. Returns a pointer to the result if successful; NULL otherwise.]

SideEffects [None]

SeeAlso []

Definition at line 207 of file cuddZddSetop.c.

211 {
212  DdNode *res;
213 
214  do {
215  dd->reordered = 0;
216  res = cuddZddIntersect(dd, P, Q);
217  } while (dd->reordered == 1);
218  return(res);
219 
220 } /* end of Cudd_zddIntersect */
Definition: cudd.h:278
int reordered
Definition: cuddInt.h:409
DdNode * cuddZddIntersect(DdManager *zdd, DdNode *P, DdNode *Q)
Definition: cuddZddSetop.c:642
DdNode* Cudd_zddIsop ( DdManager dd,
DdNode L,
DdNode U,
DdNode **  zdd_I 
)

AutomaticStart AutomaticEnd Function********************************************************************

Synopsis [Computes an ISOP in ZDD form from BDDs.]

Description [Computes an irredundant sum of products (ISOP) in ZDD form from BDDs. The two BDDs L and U represent the lower bound and the upper bound, respectively, of the function. The ISOP uses two ZDD variables for each BDD variable: One for the positive literal, and one for the negative literal. These two variables should be adjacent in the ZDD order. The two ZDD variables corresponding to BDD variable i should have indices 2i and 2i+1. The result of this procedure depends on the variable order. If successful, Cudd_zddIsop returns the BDD for the function chosen from the interval. The ZDD representing the irredundant cover is returned as a side effect in zdd_I. In case of failure, NULL is returned.]

SideEffects [zdd_I holds the pointer to the ZDD for the ISOP on successful return.]

SeeAlso [Cudd_bddIsop Cudd_zddVarsFromBddVars]

Definition at line 136 of file cuddZddIsop.c.

141 {
142  DdNode *res;
143  int autoDynZ;
144 
145  autoDynZ = dd->autoDynZ;
146  dd->autoDynZ = 0;
147 
148  do {
149  dd->reordered = 0;
150  res = cuddZddIsop(dd, L, U, zdd_I);
151  } while (dd->reordered == 1);
152  dd->autoDynZ = autoDynZ;
153  return(res);
154 
155 } /* end of Cudd_zddIsop */
Definition: cudd.h:278
DdNode * cuddZddIsop(DdManager *dd, DdNode *L, DdNode *U, DdNode **zdd_I)
Definition: cuddZddIsop.c:234
int reordered
Definition: cuddInt.h:409
int autoDynZ
Definition: cuddInt.h:417
DdNode* Cudd_zddIte ( DdManager dd,
DdNode f,
DdNode g,
DdNode h 
)

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

Synopsis [Computes the ITE of three ZDDs.]

Description [Computes the ITE of three ZDDs. Returns a pointer to the result if successful; NULL otherwise.]

SideEffects [None]

SeeAlso []

Definition at line 148 of file cuddZddSetop.c.

153 {
154  DdNode *res;
155 
156  do {
157  dd->reordered = 0;
158  res = cuddZddIte(dd, f, g, h);
159  } while (dd->reordered == 1);
160  return(res);
161 
162 } /* end of Cudd_zddIte */
DdNode * cuddZddIte(DdManager *dd, DdNode *f, DdNode *g, DdNode *h)
Definition: cuddZddSetop.c:427
Definition: cudd.h:278
int reordered
Definition: cuddInt.h:409
DdNode* Cudd_zddIthVar ( DdManager dd,
int  i 
)

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

Synopsis [Returns the ZDD variable with index i.]

Description [Retrieves the ZDD variable with index i if it already exists, or creates a new ZDD variable. Returns a pointer to the variable if successful; NULL otherwise.]

SideEffects [None]

SeeAlso [Cudd_bddIthVar Cudd_addIthVar]

Definition at line 448 of file cuddAPI.c.

451 {
452  DdNode *res;
453  DdNode *zvar;
454  DdNode *lower;
455  int j;
456 
457  if ((unsigned int) i >= CUDD_MAXINDEX - 1) return(NULL);
458 
459  /* The i-th variable function has the following structure:
460  ** at the level corresponding to index i there is a node whose "then"
461  ** child points to the universe, and whose "else" child points to zero.
462  ** Above that level there are nodes with identical children.
463  */
464 
465  /* First we build the node at the level of index i. */
466  lower = (i < dd->sizeZ - 1) ? dd->univ[dd->permZ[i]+1] : DD_ONE(dd);
467  do {
468  dd->reordered = 0;
469  zvar = cuddUniqueInterZdd(dd, i, lower, DD_ZERO(dd));
470  } while (dd->reordered == 1);
471 
472  if (zvar == NULL)
473  return(NULL);
474  cuddRef(zvar);
475 
476  /* Now we add the "filler" nodes above the level of index i. */
477  for (j = dd->permZ[i] - 1; j >= 0; j--) {
478  do {
479  dd->reordered = 0;
480  res = cuddUniqueInterZdd(dd, dd->invpermZ[j], zvar, zvar);
481  } while (dd->reordered == 1);
482  if (res == NULL) {
483  Cudd_RecursiveDerefZdd(dd,zvar);
484  return(NULL);
485  }
486  cuddRef(res);
487  Cudd_RecursiveDerefZdd(dd,zvar);
488  zvar = res;
489  }
490  cuddDeref(zvar);
491  return(zvar);
492 
493 } /* end of Cudd_zddIthVar */
#define cuddRef(n)
Definition: cuddInt.h:584
void Cudd_RecursiveDerefZdd(DdManager *table, DdNode *n)
Definition: cuddRef.c:385
#define cuddDeref(n)
Definition: cuddInt.h:604
Definition: cudd.h:278
int * invpermZ
Definition: cuddInt.h:389
int * permZ
Definition: cuddInt.h:387
int reordered
Definition: cuddInt.h:409
DdNode * cuddUniqueInterZdd(DdManager *unique, int index, DdNode *T, DdNode *E)
Definition: cuddTable.c:1343
int sizeZ
Definition: cuddInt.h:362
#define CUDD_MAXINDEX
Definition: cudd.h:112
#define DD_ONE(dd)
Definition: cuddInt.h:911
DdNode ** univ
Definition: cuddInt.h:392
#define DD_ZERO(dd)
Definition: cuddInt.h:927
int Cudd_zddNextPath ( DdGen gen,
int **  path 
)

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

Synopsis [Generates the next path of a ZDD.]

Description [Generates the next path of a ZDD onset, using generator gen. Returns 0 if the enumeration is completed; 1 otherwise.]

SideEffects [The path is returned as a side effect. The generator is modified.]

SeeAlso [Cudd_zddForeachPath Cudd_zddFirstPath Cudd_GenFree Cudd_IsGenEmpty]

Definition at line 387 of file cuddZddUtil.c.

390 {
391  DdNode *top, *next, *prev;
392  DdManager *zdd = gen->manager;
393 
394  /* Backtrack from previously reached terminal node. */
395  while (1) {
396  if (gen->stack.sp == 1) {
397  /* The current node has no predecessor. */
398  gen->status = CUDD_GEN_EMPTY;
399  gen->stack.sp--;
400  goto done;
401  }
402  top = gen->stack.stack[gen->stack.sp-1];
403  prev = Cudd_Regular(gen->stack.stack[gen->stack.sp-2]);
404  next = cuddT(prev);
405  if (next != top) { /* follow the then branch next */
406  gen->gen.cubes.cube[prev->index] = 1;
407  gen->stack.stack[gen->stack.sp-1] = next;
408  break;
409  }
410  /* Pop the stack and try again. */
411  gen->gen.cubes.cube[prev->index] = 2;
412  gen->stack.sp--;
413  }
414 
415  while (1) {
416  top = gen->stack.stack[gen->stack.sp-1];
417  if (!cuddIsConstant(Cudd_Regular(top))) {
418  /* Take the else branch first. */
419  gen->gen.cubes.cube[Cudd_Regular(top)->index] = 0;
420  next = cuddE(Cudd_Regular(top));
421  gen->stack.stack[gen->stack.sp] = Cudd_Not(next); gen->stack.sp++;
422  } else if (Cudd_Regular(top) == DD_ZERO(zdd)) {
423  /* Backtrack. */
424  while (1) {
425  if (gen->stack.sp == 1) {
426  /* The current node has no predecessor. */
427  gen->status = CUDD_GEN_EMPTY;
428  gen->stack.sp--;
429  goto done;
430  }
431  prev = Cudd_Regular(gen->stack.stack[gen->stack.sp-2]);
432  next = cuddT(prev);
433  if (next != top) { /* follow the then branch next */
434  gen->gen.cubes.cube[prev->index] = 1;
435  gen->stack.stack[gen->stack.sp-1] = next;
436  break;
437  }
438  /* Pop the stack and try again. */
439  gen->gen.cubes.cube[prev->index] = 2;
440  gen->stack.sp--;
441  top = gen->stack.stack[gen->stack.sp-1];
442  }
443  } else {
444  gen->status = CUDD_GEN_NONEMPTY;
445  gen->gen.cubes.value = cuddV(Cudd_Regular(top));
446  goto done;
447  }
448  }
449 
450 done:
451  if (gen->status == CUDD_GEN_EMPTY) return(0);
452  *path = gen->gen.cubes.cube;
453  return(1);
454 
455 } /* end of Cudd_zddNextPath */
Definition: cudd.h:278
#define Cudd_Not(node)
Definition: cudd.h:367
struct DdGen::@30::@32 cubes
#define Cudd_Regular(node)
Definition: cudd.h:397
#define CUDD_GEN_NONEMPTY
Definition: cuddInt.h:197
#define cuddV(node)
Definition: cuddInt.h:668
DdNode ** stack
Definition: cuddInt.h:227
DdManager * manager
Definition: cuddInt.h:205
#define cuddIsConstant(node)
Definition: cuddInt.h:620
#define cuddT(node)
Definition: cuddInt.h:636
union DdGen::@30 gen
#define CUDD_GEN_EMPTY
Definition: cuddInt.h:196
DdHalfWord index
Definition: cudd.h:279
#define cuddE(node)
Definition: cuddInt.h:652
int status
Definition: cuddInt.h:207
#define DD_ZERO(dd)
Definition: cuddInt.h:927
DdNode* Cudd_zddPortFromBdd ( DdManager dd,
DdNode B 
)

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

Synopsis [Converts a BDD into a ZDD.]

Description [Converts a BDD into a ZDD. This function assumes that there is a one-to-one correspondence between the BDD variables and the ZDD variables, and that the variable order is the same for both types of variables. These conditions are established if the ZDD variables are created by one call to Cudd_zddVarsFromBddVars with multiplicity =

  1. Returns a pointer to the resulting ZDD if successful; NULL otherwise.]

SideEffects [None]

SeeAlso [Cudd_zddVarsFromBddVars]

Definition at line 131 of file cuddZddPort.c.

134 {
135  DdNode *res;
136 
137  do {
138  dd->reordered = 0;
139  res = zddPortFromBddStep(dd,B,0);
140  } while (dd->reordered == 1);
141 
142  return(res);
143 
144 } /* end of Cudd_zddPortFromBdd */
static DdNode * zddPortFromBddStep(DdManager *dd, DdNode *B, int expected)
Definition: cuddZddPort.c:197
Definition: cudd.h:278
int reordered
Definition: cuddInt.h:409
DdNode* Cudd_zddPortToBdd ( DdManager dd,
DdNode f 
)

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

Synopsis [Converts a ZDD into a BDD.]

Description [Converts a ZDD into a BDD. Returns a pointer to the resulting ZDD if successful; NULL otherwise.]

SideEffects [None]

SeeAlso [Cudd_zddPortFromBdd]

Definition at line 160 of file cuddZddPort.c.

163 {
164  DdNode *res;
165 
166  do {
167  dd->reordered = 0;
168  res = zddPortToBddStep(dd,f,0);
169  } while (dd->reordered == 1);
170 
171  return(res);
172 
173 } /* end of Cudd_zddPortToBdd */
Definition: cudd.h:278
static DdNode * zddPortToBddStep(DdManager *dd, DdNode *f, int depth)
Definition: cuddZddPort.c:305
int reordered
Definition: cuddInt.h:409
int Cudd_zddPrintCover ( DdManager zdd,
DdNode node 
)

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

Synopsis [Prints a sum of products from a ZDD representing a cover.]

Description [Prints a sum of products from a ZDD representing a cover. Returns 1 if successful; 0 otherwise.]

SideEffects [None]

SeeAlso [Cudd_zddPrintMinterm]

Definition at line 169 of file cuddZddUtil.c.

172 {
173  int i, size;
174  int *list;
175 
176  size = (int)zdd->sizeZ;
177  if (size % 2 != 0) return(0); /* number of variables should be even */
178  list = ABC_ALLOC(int, size);
179  if (list == NULL) {
180  zdd->errorCode = CUDD_MEMORY_OUT;
181  return(0);
182  }
183  for (i = 0; i < size; i++) list[i] = 3; /* bogus value should disappear */
184  zddPrintCoverAux(zdd, node, 0, list);
185  ABC_FREE(list);
186  return(1);
187 
188 } /* end of Cudd_zddPrintCover */
#define ABC_ALLOC(type, num)
Definition: abc_global.h:229
static void zddPrintCoverAux(DdManager *zdd, DdNode *node, int level, int *list)
Definition: cuddZddUtil.c:1010
if(last==0)
Definition: sparse_int.h:34
static int size
Definition: cuddSign.c:86
int sizeZ
Definition: cuddInt.h:362
#define ABC_FREE(obj)
Definition: abc_global.h:232
Cudd_ErrorType errorCode
Definition: cuddInt.h:447
int Cudd_zddPrintDebug ( DdManager zdd,
DdNode f,
int  n,
int  pr 
)

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

Synopsis [Prints to the standard output a ZDD and its statistics.]

Description [Prints to the standard output a DD and its statistics. The statistics include the number of nodes and the number of minterms. (The number of minterms is also the number of combinations in the set.) The statistics are printed if pr > 0. Specifically:

  • pr = 0 : prints nothing
  • pr = 1 : prints counts of nodes and minterms
  • pr = 2 : prints counts + disjoint sum of products
  • pr = 3 : prints counts + list of nodes
  • pr > 3 : prints counts + disjoint sum of products + list of nodes

Returns 1 if successful; 0 otherwise. ]

SideEffects [None]

SeeAlso []

Definition at line 215 of file cuddZddUtil.c.

220 {
221  DdNode *empty = DD_ZERO(zdd);
222  int nodes;
223  double minterms;
224  int retval = 1;
225 
226  if (f == empty && pr > 0) {
227  (void) fprintf(zdd->out,": is the empty ZDD\n");
228  (void) fflush(zdd->out);
229  return(1);
230  }
231 
232  if (pr > 0) {
233  nodes = Cudd_zddDagSize(f);
234  if (nodes == CUDD_OUT_OF_MEM) retval = 0;
235  minterms = Cudd_zddCountMinterm(zdd, f, n);
236  if (minterms == (double)CUDD_OUT_OF_MEM) retval = 0;
237  (void) fprintf(zdd->out,": %d nodes %g minterms\n",
238  nodes, minterms);
239  if (pr > 2)
240  if (!cuddZddP(zdd, f)) retval = 0;
241  if (pr == 2 || pr > 3) {
242  if (!Cudd_zddPrintMinterm(zdd, f)) retval = 0;
243  (void) fprintf(zdd->out,"\n");
244  }
245  (void) fflush(zdd->out);
246  }
247  return(retval);
248 
249 } /* end of Cudd_zddPrintDebug */
#define CUDD_OUT_OF_MEM
Definition: cudd.h:95
Definition: cudd.h:278
int Cudd_zddPrintMinterm(DdManager *zdd, DdNode *node)
Definition: cuddZddUtil.c:135
int nodes
Definition: abcSaucy.c:61
double Cudd_zddCountMinterm(DdManager *zdd, DdNode *node, int path)
Definition: cuddZddMisc.c:158
int Cudd_zddDagSize(DdNode *p_node)
Definition: cuddZddMisc.c:127
FILE * out
Definition: cuddInt.h:441
static DdNode * empty
Definition: cuddZddLin.c:98
pset minterms()
int cuddZddP(DdManager *zdd, DdNode *f)
Definition: cuddZddUtil.c:822
#define DD_ZERO(dd)
Definition: cuddInt.h:927
int Cudd_zddPrintMinterm ( DdManager zdd,
DdNode node 
)

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

Synopsis [Prints a disjoint sum of product form for a ZDD.]

Description [Prints a disjoint sum of product form for a ZDD. Returns 1 if successful; 0 otherwise.]

SideEffects [None]

SeeAlso [Cudd_zddPrintDebug Cudd_zddPrintCover]

Definition at line 135 of file cuddZddUtil.c.

138 {
139  int i, size;
140  int *list;
141 
142  size = (int)zdd->sizeZ;
143  list = ABC_ALLOC(int, size);
144  if (list == NULL) {
145  zdd->errorCode = CUDD_MEMORY_OUT;
146  return(0);
147  }
148  for (i = 0; i < size; i++) list[i] = 3; /* bogus value should disappear */
149  zdd_print_minterm_aux(zdd, node, 0, list);
150  ABC_FREE(list);
151  return(1);
152 
153 } /* end of Cudd_zddPrintMinterm */
static void zdd_print_minterm_aux(DdManager *zdd, DdNode *node, int level, int *list)
Definition: cuddZddUtil.c:938
#define ABC_ALLOC(type, num)
Definition: abc_global.h:229
static int size
Definition: cuddSign.c:86
int sizeZ
Definition: cuddInt.h:362
#define ABC_FREE(obj)
Definition: abc_global.h:232
Cudd_ErrorType errorCode
Definition: cuddInt.h:447
void Cudd_zddPrintSubtable ( DdManager table)

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

Synopsis [Prints the ZDD table.]

Description [Prints the ZDD table for debugging purposes.]

SideEffects [None]

SeeAlso []

Definition at line 184 of file cuddZddMisc.c.

186 {
187  int i, j;
188  DdNode *z1, *z1_next, *base;
189  DdSubtable *ZSubTable;
190 
191  base = table->one;
192  for (i = table->sizeZ - 1; i >= 0; i--) {
193  ZSubTable = &(table->subtableZ[i]);
194  printf("subtable[%d]:\n", i);
195  for (j = ZSubTable->slots - 1; j >= 0; j--) {
196  z1 = ZSubTable->nodelist[j];
197  while (z1 != NIL(DdNode)) {
198  (void) fprintf(table->out,
199 #if SIZEOF_VOID_P == 8
200  "ID = 0x%lx\tindex = %u\tr = %u\t",
201  (ptruint) z1 / (ptruint) sizeof(DdNode),
202  z1->index, z1->ref);
203 #else
204  "ID = 0x%x\tindex = %hu\tr = %hu\t",
205  (ptruint) z1 / (ptruint) sizeof(DdNode),
206  z1->index, z1->ref);
207 #endif
208  z1_next = cuddT(z1);
209  if (Cudd_IsConstant(z1_next)) {
210  (void) fprintf(table->out, "T = %d\t\t",
211  (z1_next == base));
212  }
213  else {
214 #if SIZEOF_VOID_P == 8
215  (void) fprintf(table->out, "T = 0x%lx\t",
216  (ptruint) z1_next / (ptruint) sizeof(DdNode));
217 #else
218  (void) fprintf(table->out, "T = 0x%x\t",
219  (ptruint) z1_next / (ptruint) sizeof(DdNode));
220 #endif
221  }
222  z1_next = cuddE(z1);
223  if (Cudd_IsConstant(z1_next)) {
224  (void) fprintf(table->out, "E = %d\n",
225  (z1_next == base));
226  }
227  else {
228 #if SIZEOF_VOID_P == 8
229  (void) fprintf(table->out, "E = 0x%lx\n",
230  (ptruint) z1_next / (ptruint) sizeof(DdNode));
231 #else
232  (void) fprintf(table->out, "E = 0x%x\n",
233  (ptruint) z1_next / (ptruint) sizeof(DdNode));
234 #endif
235  }
236 
237  z1_next = z1->next;
238  z1 = z1_next;
239  }
240  }
241  }
242  putchar('\n');
243 
244 } /* Cudd_zddPrintSubtable */
DdHalfWord ref
Definition: cudd.h:280
Definition: cudd.h:278
#define z1
Definition: extraBdd.h:78
#define Cudd_IsConstant(node)
Definition: cudd.h:352
#define NIL(type)
Definition: avl.h:25
struct DdNode DdNode
Definition: cudd.h:270
ABC_PTRUINT_T ptruint
Definition: cuddInt.h:261
#define SIZEOF_VOID_P
Definition: cudd.h:78
FILE * out
Definition: cuddInt.h:441
DdNode * next
Definition: cudd.h:281
DdNode ** nodelist
Definition: cuddInt.h:327
#define cuddT(node)
Definition: cuddInt.h:636
int sizeZ
Definition: cuddInt.h:362
DdHalfWord index
Definition: cudd.h:279
unsigned int slots
Definition: cuddInt.h:329
DdNode * one
Definition: cuddInt.h:345
#define cuddE(node)
Definition: cuddInt.h:652
DdSubtable * subtableZ
Definition: cuddInt.h:366
DdNode* Cudd_zddProduct ( DdManager dd,
DdNode f,
DdNode g 
)

AutomaticStart AutomaticEnd Function********************************************************************

Synopsis [Computes the product of two covers represented by ZDDs.]

Description [Computes the product of two covers represented by ZDDs. The result is also a ZDD. Returns a pointer to the result if successful; NULL otherwise. The covers on which Cudd_zddProduct operates use two ZDD variables for each function variable (one ZDD variable for each literal of the variable). Those two ZDD variables should be adjacent in the order.]

SideEffects [None]

SeeAlso [Cudd_zddUnateProduct]

Definition at line 145 of file cuddZddFuncs.c.

149 {
150  DdNode *res;
151 
152  do {
153  dd->reordered = 0;
154  res = cuddZddProduct(dd, f, g);
155  } while (dd->reordered == 1);
156  return(res);
157 
158 } /* end of Cudd_zddProduct */
Definition: cudd.h:278
DdNode * cuddZddProduct(DdManager *dd, DdNode *f, DdNode *g)
Definition: cuddZddFuncs.c:380
int reordered
Definition: cuddInt.h:409
long Cudd_zddReadNodeCount ( DdManager dd)

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

Synopsis [Reports the number of nodes in ZDDs.]

Description [Reports the number of nodes in ZDDs. This number always includes the two constants 1 and 0.]

SideEffects [None]

SeeAlso [Cudd_ReadPeakNodeCount Cudd_ReadNodeCount]

Definition at line 3221 of file cuddAPI.c.

3223 {
3224  return((long)(dd->keysZ - dd->deadZ + 2));
3225 
3226 } /* end of Cudd_zddReadNodeCount */
unsigned int deadZ
Definition: cuddInt.h:372
unsigned int keysZ
Definition: cuddInt.h:370
void Cudd_zddRealignDisable ( DdManager unique)

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

Synopsis [Disables realignment of ZDD order to BDD order.]

Description []

SideEffects [None]

SeeAlso [Cudd_zddRealignEnable Cudd_zddRealignmentEnabled Cudd_bddRealignEnable Cudd_bddRealignmentEnabled]

Definition at line 889 of file cuddAPI.c.

891 {
892  unique->realign = 0;
893  return;
894 
895 } /* end of Cudd_zddRealignDisable */
int realign
Definition: cuddInt.h:420
void Cudd_zddRealignEnable ( DdManager unique)

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

Synopsis [Enables realignment of ZDD order to BDD order.]

Description [Enables realignment of the ZDD variable order to the BDD variable order after the BDDs and ADDs have been reordered. The number of ZDD variables must be a multiple of the number of BDD variables for realignment to make sense. If this condition is not met, Cudd_ReduceHeap will return 0. Let M be the ratio of the two numbers. For the purpose of realignment, the ZDD variables from M*i to (M+1)*i-1 are reagarded as corresponding to BDD variable i. Realignment is initially disabled.]

SideEffects [None]

SeeAlso [Cudd_ReduceHeap Cudd_zddRealignDisable Cudd_zddRealignmentEnabled Cudd_bddRealignDisable Cudd_bddRealignmentEnabled]

Definition at line 867 of file cuddAPI.c.

869 {
870  unique->realign = 1;
871  return;
872 
873 } /* end of Cudd_zddRealignEnable */
int realign
Definition: cuddInt.h:420
int Cudd_zddRealignmentEnabled ( DdManager unique)

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

Synopsis [Tells whether the realignment of ZDD order to BDD order is enabled.]

Description [Returns 1 if the realignment of ZDD order to BDD order is enabled; 0 otherwise.]

SideEffects [None]

SeeAlso [Cudd_zddRealignEnable Cudd_zddRealignDisable Cudd_bddRealignEnable Cudd_bddRealignDisable]

Definition at line 837 of file cuddAPI.c.

839 {
840  return(unique->realign);
841 
842 } /* end of Cudd_zddRealignmentEnabled */
int realign
Definition: cuddInt.h:420
int Cudd_zddReduceHeap ( DdManager table,
Cudd_ReorderingType  heuristic,
int  minsize 
)

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

Synopsis [Main dynamic reordering routine for ZDDs.]

Description [Main dynamic reordering routine for ZDDs. Calls one of the possible reordering procedures:

  • Swapping
  • Sifting
  • Symmetric Sifting

For sifting and symmetric sifting it is possible to request reordering to convergence.

The core of all methods is the reordering procedure cuddZddSwapInPlace() which swaps two adjacent variables. Returns 1 in case of success; 0 otherwise. In the case of symmetric sifting (with and without convergence) returns 1 plus the number of symmetric variables, in case of success.]

SideEffects [Changes the variable order for all ZDDs and clears the cache.]

Definition at line 171 of file cuddZddReord.c.

175 {
176  DdHook *hook;
177  int result;
178  unsigned int nextDyn;
179 #ifdef DD_STATS
180  unsigned int initialSize;
181  unsigned int finalSize;
182 #endif
183  long localTime;
184 
185  /* Don't reorder if there are too many dead nodes. */
186  if (table->keysZ - table->deadZ < (unsigned) minsize)
187  return(1);
188 
189  if (heuristic == CUDD_REORDER_SAME) {
190  heuristic = table->autoMethodZ;
191  }
192  if (heuristic == CUDD_REORDER_NONE) {
193  return(1);
194  }
195 
196  /* This call to Cudd_zddReduceHeap does initiate reordering. Therefore
197  ** we count it.
198  */
199  table->reorderings++;
200  empty = table->zero;
201 
202  localTime = util_cpu_time();
203 
204  /* Run the hook functions. */
205  hook = table->preReorderingHook;
206  while (hook != NULL) {
207  int res = (hook->f)(table, "ZDD", (void *)heuristic);
208  if (res == 0) return(0);
209  hook = hook->next;
210  }
211 
212  /* Clear the cache and collect garbage. */
213  zddReorderPreprocess(table);
215 
216 #ifdef DD_STATS
217  initialSize = table->keysZ;
218 
219  switch(heuristic) {
220  case CUDD_REORDER_RANDOM:
222  (void) fprintf(table->out,"#:I_RANDOM ");
223  break;
224  case CUDD_REORDER_SIFT:
228  (void) fprintf(table->out,"#:I_SIFTING ");
229  break;
230  case CUDD_REORDER_LINEAR:
232  (void) fprintf(table->out,"#:I_LINSIFT ");
233  break;
234  default:
235  (void) fprintf(table->err,"Unsupported ZDD reordering method\n");
236  return(0);
237  }
238  (void) fprintf(table->out,"%8d: initial size",initialSize);
239 #endif
240 
241  result = cuddZddTreeSifting(table,heuristic);
242 
243 #ifdef DD_STATS
244  (void) fprintf(table->out,"\n");
245  finalSize = table->keysZ;
246  (void) fprintf(table->out,"#:F_REORDER %8d: final size\n",finalSize);
247  (void) fprintf(table->out,"#:T_REORDER %8g: total time (sec)\n",
248  ((double)(util_cpu_time() - localTime)/1000.0));
249  (void) fprintf(table->out,"#:N_REORDER %8d: total swaps\n",
251 #endif
252 
253  if (result == 0)
254  return(0);
255 
256  if (!zddReorderPostprocess(table))
257  return(0);
258 
259  if (table->realignZ) {
260  if (!cuddBddAlignToZdd(table))
261  return(0);
262  }
263 
264  nextDyn = table->keysZ * DD_DYN_RATIO;
265  if (table->reorderings < 20 || nextDyn > table->nextDyn)
266  table->nextDyn = nextDyn;
267  else
268  table->nextDyn += 20;
269 
270  table->reordered = 1;
271 
272  /* Run hook functions. */
273  hook = table->postReorderingHook;
274  while (hook != NULL) {
275  int res = (hook->f)(table, "ZDD", (void *)localTime);
276  if (res == 0) return(0);
277  hook = hook->next;
278  }
279  /* Update cumulative reordering time. */
280  table->reordTime += util_cpu_time() - localTime;
281 
282  return(result);
283 
284 } /* end of Cudd_zddReduceHeap */
long reordTime
Definition: cuddInt.h:454
unsigned int deadZ
Definition: cuddInt.h:372
DdHook * preReorderingHook
Definition: cuddInt.h:439
static void zddReorderPreprocess(DdManager *table)
DdNode * zero
Definition: cuddInt.h:346
FILE * err
Definition: cuddInt.h:442
Cudd_ReorderingType autoMethodZ
Definition: cuddInt.h:419
#define DD_DYN_RATIO
Definition: cuddInt.h:152
#define util_cpu_time
Definition: util_hack.h:36
DD_HFP f
Definition: cuddInt.h:246
static DdNode * empty
Definition: cuddZddReord.c:112
int reordered
Definition: cuddInt.h:409
unsigned int nextDyn
Definition: cuddInt.h:422
DdHook * postReorderingHook
Definition: cuddInt.h:440
int zddTotalNumberSwapping
Definition: cuddZddReord.c:110
FILE * out
Definition: cuddInt.h:441
int realignZ
Definition: cuddInt.h:421
static int zddReorderPostprocess(DdManager *table)
int reorderings
Definition: cuddInt.h:410
struct DdHook * next
Definition: cuddInt.h:247
int cuddZddTreeSifting(DdManager *table, Cudd_ReorderingType method)
Definition: cuddZddGroup.c:232
static int result
Definition: cuddGenetic.c:125
int cuddBddAlignToZdd(DdManager *table)
Definition: cuddReorder.c:1251
unsigned int keysZ
Definition: cuddInt.h:370
int Cudd_zddShuffleHeap ( DdManager table,
int *  permutation 
)

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

Synopsis [Reorders ZDD variables according to given permutation.]

Description [Reorders ZDD variables according to given permutation. The i-th entry of the permutation array contains the index of the variable that should be brought to the i-th level. The size of the array should be equal or greater to the number of variables currently in use. Returns 1 in case of success; 0 otherwise.]

SideEffects [Changes the ZDD variable order for all diagrams and clears the cache.]

SeeAlso [Cudd_zddReduceHeap]

Definition at line 304 of file cuddZddReord.c.

307 {
308 
309  int result;
310 
311  empty = table->zero;
312  zddReorderPreprocess(table);
313 
314  result = zddShuffle(table,permutation);
315 
316  if (!zddReorderPostprocess(table)) return(0);
317 
318  return(result);
319 
320 } /* end of Cudd_zddShuffleHeap */
static void zddReorderPreprocess(DdManager *table)
DdNode * zero
Definition: cuddInt.h:346
static DdNode * empty
Definition: cuddZddReord.c:112
static int zddReorderPostprocess(DdManager *table)
static int result
Definition: cuddGenetic.c:125
static int zddShuffle(DdManager *table, int *permutation)
DdNode* Cudd_zddSubset0 ( DdManager dd,
DdNode P,
int  var 
)

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

Synopsis [Computes the negative cofactor of a ZDD w.r.t. a variable.]

Description [Computes the negative cofactor of a ZDD w.r.t. a variable. In terms of combinations, the result is the set of all combinations in which the variable is negated. Returns a pointer to the result if successful; NULL otherwise.]

SideEffects [None]

SeeAlso [Cudd_zddSubset1]

Definition at line 362 of file cuddZddSetop.c.

366 {
367  DdNode *r;
368 
369  do {
370  dd->reordered = 0;
371  r = cuddZddSubset0(dd, P, var);
372  } while (dd->reordered == 1);
373 
374  return(r);
375 
376 } /* end of Cudd_zddSubset0 */
Definition: cudd.h:278
int var(Lit p)
Definition: SolverTypes.h:62
DdNode * cuddZddSubset0(DdManager *dd, DdNode *P, int var)
Definition: cuddZddSetop.c:923
int reordered
Definition: cuddInt.h:409
DdNode* Cudd_zddSubset1 ( DdManager dd,
DdNode P,
int  var 
)

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

Synopsis [Computes the positive cofactor of a ZDD w.r.t. a variable.]

Description [Computes the positive cofactor of a ZDD w.r.t. a variable. In terms of combinations, the result is the set of all combinations in which the variable is asserted. Returns a pointer to the result if successful; NULL otherwise.]

SideEffects [None]

SeeAlso [Cudd_zddSubset0]

Definition at line 330 of file cuddZddSetop.c.

334 {
335  DdNode *r;
336 
337  do {
338  dd->reordered = 0;
339  r = cuddZddSubset1(dd, P, var);
340  } while (dd->reordered == 1);
341 
342  return(r);
343 
344 } /* end of Cudd_zddSubset1 */
Definition: cudd.h:278
int var(Lit p)
Definition: SolverTypes.h:62
DdNode * cuddZddSubset1(DdManager *dd, DdNode *P, int var)
Definition: cuddZddSetop.c:874
int reordered
Definition: cuddInt.h:409
void Cudd_zddSymmProfile ( DdManager table,
int  lower,
int  upper 
)

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

Synopsis [Prints statistics on symmetric ZDD variables.]

Description []

SideEffects [None]

SeeAlso []

Definition at line 145 of file cuddZddSymm.c.

149 {
150  int i, x, gbot;
151  int TotalSymm = 0;
152  int TotalSymmGroups = 0;
153 
154  for (i = lower; i < upper; i++) {
155  if (table->subtableZ[i].next != (unsigned) i) {
156  x = i;
157  (void) fprintf(table->out,"Group:");
158  do {
159  (void) fprintf(table->out," %d", table->invpermZ[x]);
160  TotalSymm++;
161  gbot = x;
162  x = table->subtableZ[x].next;
163  } while (x != i);
164  TotalSymmGroups++;
165 #ifdef DD_DEBUG
166  assert(table->subtableZ[gbot].next == (unsigned) i);
167 #endif
168  i = gbot;
169  (void) fprintf(table->out,"\n");
170  }
171  }
172  (void) fprintf(table->out,"Total Symmetric = %d\n", TotalSymm);
173  (void) fprintf(table->out,"Total Groups = %d\n", TotalSymmGroups);
174 
175 } /* end of Cudd_zddSymmProfile */
int * invpermZ
Definition: cuddInt.h:389
FILE * out
Definition: cuddInt.h:441
unsigned int next
Definition: cuddInt.h:333
#define assert(ex)
Definition: util_old.h:213
DdSubtable * subtableZ
Definition: cuddInt.h:366
DdNode* Cudd_zddUnateProduct ( DdManager dd,
DdNode f,
DdNode g 
)

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

Synopsis [Computes the product of two unate covers.]

Description [Computes the product of two unate covers represented as ZDDs. Unate covers use one ZDD variable for each BDD variable. Returns a pointer to the result if successful; NULL otherwise.]

SideEffects [None]

SeeAlso [Cudd_zddProduct]

Definition at line 176 of file cuddZddFuncs.c.

180 {
181  DdNode *res;
182 
183  do {
184  dd->reordered = 0;
185  res = cuddZddUnateProduct(dd, f, g);
186  } while (dd->reordered == 1);
187  return(res);
188 
189 } /* end of Cudd_zddUnateProduct */
Definition: cudd.h:278
DdNode * cuddZddUnateProduct(DdManager *dd, DdNode *f, DdNode *g)
Definition: cuddZddFuncs.c:617
int reordered
Definition: cuddInt.h:409
DdNode* Cudd_zddUnion ( DdManager dd,
DdNode P,
DdNode Q 
)

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

Synopsis [Computes the union of two ZDDs.]

Description [Computes the union of two ZDDs. Returns a pointer to the result if successful; NULL otherwise.]

SideEffects [None]

SeeAlso []

Definition at line 178 of file cuddZddSetop.c.

182 {
183  DdNode *res;
184 
185  do {
186  dd->reordered = 0;
187  res = cuddZddUnion(dd, P, Q);
188  } while (dd->reordered == 1);
189  return(res);
190 
191 } /* end of Cudd_zddUnion */
Definition: cudd.h:278
DdNode * cuddZddUnion(DdManager *zdd, DdNode *P, DdNode *Q)
Definition: cuddZddSetop.c:553
int reordered
Definition: cuddInt.h:409
int Cudd_zddVarsFromBddVars ( DdManager dd,
int  multiplicity 
)

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

Synopsis [Creates one or more ZDD variables for each BDD variable.]

Description [Creates one or more ZDD variables for each BDD variable. If some ZDD variables already exist, only the missing variables are created. Parameter multiplicity allows the caller to control how many variables are created for each BDD variable in existence. For instance, if ZDDs are used to represent covers, two ZDD variables are required for each BDD variable. The order of the BDD variables is transferred to the ZDD variables. If a variable group tree exists for the BDD variables, a corresponding ZDD variable group tree is created by expanding the BDD variable tree. In any case, the ZDD variables derived from the same BDD variable are merged in a ZDD variable group. If a ZDD variable group tree exists, it is freed. Returns 1 if successful; 0 otherwise.]

SideEffects [None]

SeeAlso [Cudd_bddNewVar Cudd_bddIthVar Cudd_bddNewVarAtLevel]

Definition at line 519 of file cuddAPI.c.

522 {
523  int res;
524  int i, j;
525  int allnew;
526  int *permutation;
527 
528  if (multiplicity < 1) return(0);
529  allnew = dd->sizeZ == 0;
530  if (dd->size * multiplicity > dd->sizeZ) {
531  res = cuddResizeTableZdd(dd,dd->size * multiplicity - 1);
532  if (res == 0) return(0);
533  }
534  /* Impose the order of the BDD variables to the ZDD variables. */
535  if (allnew) {
536  for (i = 0; i < dd->size; i++) {
537  for (j = 0; j < multiplicity; j++) {
538  dd->permZ[i * multiplicity + j] =
539  dd->perm[i] * multiplicity + j;
540  dd->invpermZ[dd->permZ[i * multiplicity + j]] =
541  i * multiplicity + j;
542  }
543  }
544  for (i = 0; i < dd->sizeZ; i++) {
545  dd->univ[i]->index = dd->invpermZ[i];
546  }
547  } else {
548  permutation = ABC_ALLOC(int,dd->sizeZ);
549  if (permutation == NULL) {
551  return(0);
552  }
553  for (i = 0; i < dd->size; i++) {
554  for (j = 0; j < multiplicity; j++) {
555  permutation[i * multiplicity + j] =
556  dd->invperm[i] * multiplicity + j;
557  }
558  }
559  for (i = dd->size * multiplicity; i < dd->sizeZ; i++) {
560  permutation[i] = i;
561  }
562  res = Cudd_zddShuffleHeap(dd, permutation);
563  ABC_FREE(permutation);
564  if (res == 0) return(0);
565  }
566  /* Copy and expand the variable group tree if it exists. */
567  if (dd->treeZ != NULL) {
568  Cudd_FreeZddTree(dd);
569  }
570  if (dd->tree != NULL) {
571  dd->treeZ = Mtr_CopyTree(dd->tree, multiplicity);
572  if (dd->treeZ == NULL) return(0);
573  } else if (multiplicity > 1) {
574  dd->treeZ = Mtr_InitGroupTree(0, dd->sizeZ);
575  if (dd->treeZ == NULL) return(0);
576  dd->treeZ->index = dd->invpermZ[0];
577  }
578  /* Create groups for the ZDD variables derived from the same BDD variable.
579  */
580  if (multiplicity > 1) {
581  char *vmask, *lmask;
582 
583  vmask = ABC_ALLOC(char, dd->size);
584  if (vmask == NULL) {
586  return(0);
587  }
588  lmask = ABC_ALLOC(char, dd->size);
589  if (lmask == NULL) {
591  return(0);
592  }
593  for (i = 0; i < dd->size; i++) {
594  vmask[i] = lmask[i] = 0;
595  }
596  res = addMultiplicityGroups(dd,dd->treeZ,multiplicity,vmask,lmask);
597  ABC_FREE(vmask);
598  ABC_FREE(lmask);
599  if (res == 0) return(0);
600  }
601  return(1);
602 
603 } /* end of Cudd_zddVarsFromBddVars */
int * invpermZ
Definition: cuddInt.h:389
int size
Definition: cuddInt.h:361
void Cudd_FreeZddTree(DdManager *dd)
Definition: cuddAPI.c:2252
#define ABC_ALLOC(type, num)
Definition: abc_global.h:229
int * permZ
Definition: cuddInt.h:387
MtrNode * tree
Definition: cuddInt.h:424
MtrHalfWord index
Definition: mtr.h:135
int Cudd_zddShuffleHeap(DdManager *table, int *permutation)
Definition: cuddZddReord.c:304
int cuddResizeTableZdd(DdManager *unique, int index)
Definition: cuddTable.c:2241
static int addMultiplicityGroups(DdManager *dd, MtrNode *treenode, int multiplicity, char *vmask, char *lmask)
Definition: cuddAPI.c:4402
MtrNode * Mtr_InitGroupTree(int lower, int size)
Definition: mtrGroup.c:121
int sizeZ
Definition: cuddInt.h:362
DdHalfWord index
Definition: cudd.h:279
#define ABC_FREE(obj)
Definition: abc_global.h:232
MtrNode * treeZ
Definition: cuddInt.h:425
int * invperm
Definition: cuddInt.h:388
MtrNode * Mtr_CopyTree(MtrNode *node, int expansion)
Definition: mtrBasic.c:215
int * perm
Definition: cuddInt.h:386
Cudd_ErrorType errorCode
Definition: cuddInt.h:447
DdNode ** univ
Definition: cuddInt.h:392
DdNode* Cudd_zddWeakDiv ( DdManager dd,
DdNode f,
DdNode g 
)

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

Synopsis [Applies weak division to two covers.]

Description [Applies weak division to two ZDDs representing two covers. Returns a pointer to the ZDD representing the result if successful; NULL otherwise. The result of weak division depends on the variable order. The covers on which Cudd_zddWeakDiv operates use two ZDD variables for each function variable (one ZDD variable for each literal of the variable). Those two ZDD variables should be adjacent in the order.]

SideEffects [None]

SeeAlso [Cudd_zddDivide]

Definition at line 210 of file cuddZddFuncs.c.

214 {
215  DdNode *res;
216 
217  do {
218  dd->reordered = 0;
219  res = cuddZddWeakDiv(dd, f, g);
220  } while (dd->reordered == 1);
221  return(res);
222 
223 } /* end of Cudd_zddWeakDiv */
Definition: cudd.h:278
int reordered
Definition: cuddInt.h:409
DdNode * cuddZddWeakDiv(DdManager *dd, DdNode *f, DdNode *g)
Definition: cuddZddFuncs.c:761
DdNode* Cudd_zddWeakDivF ( DdManager dd,
DdNode f,
DdNode g 
)

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

Synopsis [Modified version of Cudd_zddWeakDiv.]

Description [Modified version of Cudd_zddWeakDiv. This function may disappear in future releases.]

SideEffects [None]

SeeAlso [Cudd_zddWeakDiv]

Definition at line 270 of file cuddZddFuncs.c.

274 {
275  DdNode *res;
276 
277  do {
278  dd->reordered = 0;
279  res = cuddZddWeakDivF(dd, f, g);
280  } while (dd->reordered == 1);
281  return(res);
282 
283 } /* end of Cudd_zddWeakDivF */
Definition: cudd.h:278
int reordered
Definition: cuddInt.h:409
DdNode * cuddZddWeakDivF(DdManager *dd, DdNode *f, DdNode *g)
Definition: cuddZddFuncs.c:922