79 #define DBL_MAX_EXP 1024
144 #pragma pointer_size save
145 #pragma pointer_size short
162 #pragma pointer_size restore
171 static char rcsid[]
DD_UNUSED =
"$Id: cuddApprox.c,v 1.27 2009/02/19 16:16:51 fabio Exp $";
524 fprintf(dd->
err,
"Cannot subset, nil object\n");
535 (void) fprintf(dd->
err,
"Out-of-memory; Cannot subset\n");
541 result =
UAmarkNodes(dd, f, info, threshold, safe, quality);
543 (void) fprintf(dd->
err,
"Out-of-memory; Cannot subset\n");
555 (void) fprintf(dd->
err,
"Wrong prediction: %d versus actual %d\n",
563 if (subset != NULL) {
570 (void) fprintf(dd->
err,
"Wrong subset\n");
613 fprintf(dd->
err,
"Cannot subset, nil object\n");
625 (void) fprintf(dd->
err,
"Out-of-memory; Cannot subset\n");
631 result =
RAmarkNodes(dd, f, info, threshold, quality);
633 (void) fprintf(dd->
err,
"Out-of-memory; Cannot subset\n");
645 (void) fprintf(dd->
err,
"Wrong prediction: %d versus actual %d\n",
653 if (subset != NULL) {
660 (void) fprintf(dd->
err,
"Wrong subset\n");
706 fprintf(dd->
err,
"Cannot subset, nil object\n");
718 (void) fprintf(dd->
err,
"Out-of-memory; Cannot subset\n");
726 (void) fprintf(dd->
err,
"Out-of-memory; Cannot subset\n");
737 result =
BAmarkNodes(dd, f, info, threshold, quality1, quality0);
739 (void) fprintf(dd->
err,
"Out-of-memory; Cannot subset\n");
751 (void) fprintf(dd->
err,
"Wrong prediction: %d versus actual %d\n",
759 if (subset != NULL) {
766 (void) fprintf(dd->
err,
"Wrong subset\n");
803 if (!
st__lookup(info->
table, (
const char *)node, (
char **)&infoN))
return;
804 if ((infoN->
parity & newparity) != 0)
return;
805 infoN->
parity |= (short) newparity;
861 if (infoT == NULL)
return(NULL);
863 if (infoE == NULL)
return(NULL);
930 info->
max = pow(2.0,(
double) numVars);
940 if (info->
page == NULL) {
947 if (info->
table == NULL) {
966 if (infoTop == NULL) {
1023 item->
localRef = infoN->functionRef;
1026 while (queue->
first != NULL) {
1030 if (node == skip)
continue;
1032 if (item->
localRef != infoN->functionRef) {
1040 if (item == NULL)
return(0);
1046 if (item == NULL)
return(0);
1093 infoN->functionRef = 0;
1100 infoN->functionRef++;
1104 while (queue->
first != NULL) {
1109 if (infoN->functionRef != 0) {
1117 if (item == NULL)
return(0);
1119 infoN->functionRef--;
1124 if (item == NULL)
return(0);
1126 infoN->functionRef--;
1166 double impactP, impactN;
1170 (void) printf(
"initial size = %d initial minterms = %g\n",
1174 if (queue == NULL) {
1179 if (localQueue == NULL) {
1197 while (queue->
first != NULL) {
1199 if (info->
size <= threshold)
1205 if (safe && infoN->parity == 3) {
1211 numOnset = infoN->mintermsP * impactP + infoN->mintermsN * impactN;
1220 (void) printf(
"node %p: impact = %g/%g numOnset = %g savings %d\n",
1221 node, impactP, impactN, numOnset, savings);
1223 if ((1 - numOnset / info->
minterms) >
1224 quality * (1 - (double) savings / info->
size)) {
1225 infoN->replace =
TRUE;
1226 info->
size -= savings;
1229 (void) printf(
"replace: new size = %d new minterms = %g\n",
1232 savings -=
updateRefs(dd,node,NULL,info,localQueue);
1282 DdNode *Nt, *Ne, *N, *t, *e, *r;
1304 (void) fprintf(dd->
err,
1305 "Something is wrong, ought to be in info table\n");
1385 double impact, impactP, impactN;
1391 (void) fprintf(dd->
out,
"initial size = %d initial minterms = %g\n",
1395 if (queue == NULL) {
1400 if (localQueue == NULL) {
1424 while (queue->
first != NULL) {
1426 if (info->
size <= threshold)
1444 if (infoN->
parity == 3) {
1464 if (infoN->
parity == 1) {
1466 minterms = infoE->mintermsP/2.0 - infoT->mintermsP/2.0;
1483 minterms = infoT->mintermsN/2.0 - infoE->mintermsN/2.0;
1502 if (infoN->
parity == 1) {
1504 minterms = infoT->mintermsP/2.0 -
1505 ((E == Ereg) ? infoE->mintermsP : infoE->mintermsN)/2.0;
1522 minterms = ((E == Ereg) ? infoE->mintermsN :
1523 infoE->mintermsP)/2.0 - infoT->mintermsN/2.0;
1556 if (shared != NULL) {
1560 numOnset -= (infoS->
mintermsN * impactP +
1563 numOnset -= (infoS->
mintermsP * impactP +
1573 (void) printf(
"node %p: impact = %g numOnset = %g savings %d\n",
1574 node, impact, numOnset, savings);
1576 (
void) printf(
"node %p: impact = %g/%g numOnset = %g savings %d\n",
1577 node, impactP, impactN, numOnset, savings);
1579 if ((1 - numOnset / info->
minterms) >
1580 quality * (1 - (
double) savings / info->
size)) {
1581 infoN->
replace = (char) replace;
1582 info->
size -= savings;
1585 (void) printf(
"remap(%d): new size = %d new minterms = %g\n",
1589 savings -=
updateRefs(dd,node,NULL,info,localQueue);
1591 savings -=
updateRefs(dd,node,E,info,localQueue);
1593 savings -=
updateRefs(dd,node,T,info,localQueue);
1598 savings -=
updateRefs(dd,node,shared,info,localQueue) - 1;
1688 double impact, impactP, impactN;
1695 (void) fprintf(dd->
out,
"initial size = %d initial minterms = %g\n",
1699 if (queue == NULL) {
1704 if (localQueue == NULL) {
1728 while (queue->
first != NULL) {
1730 if (info->
size <= threshold)
1745 quality = infoN->
care ? quality1 : quality0;
1749 if (infoN->
parity == 3) {
1769 if (infoN->
parity == 1) {
1771 minterms = infoE->mintermsP/2.0 - infoT->mintermsP/2.0;
1788 minterms = infoT->mintermsN/2.0 - infoE->mintermsN/2.0;
1807 if (infoN->
parity == 1) {
1809 minterms = infoT->mintermsP/2.0 -
1810 ((E == Ereg) ? infoE->mintermsP : infoE->mintermsN)/2.0;
1827 minterms = ((E == Ereg) ? infoE->mintermsN :
1828 infoE->mintermsP)/2.0 - infoT->mintermsN/2.0;
1861 if (shared != NULL) {
1865 numOnset -= (infoS->
mintermsN * impactP +
1868 numOnset -= (infoS->
mintermsP * impactP +
1878 (void) printf(
"node %p: impact = %g numOnset = %g savings %d\n",
1879 node, impact, numOnset, savings);
1881 (
void) printf(
"node %p: impact = %g/%g numOnset = %g savings %d\n",
1882 node, impactP, impactN, numOnset, savings);
1884 if ((1 - numOnset / info->
minterms) >
1885 quality * (1 - (
double) savings / info->
size)) {
1886 infoN->
replace = (char) replace;
1887 info->
size -= savings;
1890 (void) printf(
"remap(%d): new size = %d new minterms = %g\n",
1894 savings -=
updateRefs(dd,node,NULL,info,localQueue);
1896 savings -=
updateRefs(dd,node,E,info,localQueue);
1898 savings -=
updateRefs(dd,node,T,info,localQueue);
1903 savings -=
updateRefs(dd,node,shared,info,localQueue) - 1;
1995 DdNode *Nt, *Ne, *N, *t, *e, *r;
2027 int index =
cuddT(N)->index;
2055 int index =
cuddT(N)->index;
2073 (void) fprintf(dd->
err,
2074 "Something is wrong, ought to be in info table\n");
2146 DdNode *Ft, *Fe, *B, *Bt, *Be;
2147 unsigned int topf, topb;
2157 if (b == zero)
return(infoF->
care);
2162 if (res->
ref == 0) {
2166 return(infoF->
care);
2207 return(infoF->
care);
void st__free_table(st__table *table)
void cuddLevelQueueDequeue(DdLevelQueue *queue, int level)
static int UAmarkNodes(DdManager *dd, DdNode *f, ApproxInfo *info, int threshold, int safe, double quality)
struct LocalQueueItem LocalQueueItem
static int updateRefs(DdManager *dd, DdNode *f, DdNode *skip, ApproxInfo *info, DdLevelQueue *queue)
void Cudd_RecursiveDeref(DdManager *table, DdNode *n)
static int BAapplyBias(DdManager *dd, DdNode *f, DdNode *b, ApproxInfo *info, DdHashTable *cache)
static int computeSavings(DdManager *dd, DdNode *f, DdNode *skip, ApproxInfo *info, DdLevelQueue *queue)
static NodeData * gatherInfoAux(DdNode *node, ApproxInfo *info, int parity)
DdNode * Cudd_BiasedUnderApprox(DdManager *dd, DdNode *f, DdNode *b, int numVars, int threshold, double quality1, double quality0)
DdNode * cuddUnderApprox(DdManager *dd, DdNode *f, int numVars, int threshold, int safe, double quality)
int st__insert(st__table *table, const char *key, char *value)
DdNode * Cudd_UnderApprox(DdManager *dd, DdNode *f, int numVars, int threshold, int safe, double quality)
#define Cudd_IsConstant(node)
#define Cudd_Regular(node)
struct GlobalQueueItem * cnext
int st__ptrcmp(const char *, const char *)
static DdNode * UAbuildSubset(DdManager *dd, DdNode *node, ApproxInfo *info)
struct ApproxInfo ApproxInfo
#define ABC_ALLOC(type, num)
void cuddLevelQueueQuit(DdLevelQueue *queue)
static ApproxInfo * gatherInfo(DdManager *dd, DdNode *node, int numVars, int parity)
st__table * st__init_table(st__compare_func_type compare, st__hash_func_type hash)
void * cuddLevelQueueEnqueue(DdLevelQueue *queue, void *key, int level)
DdNode * cuddBiasedUnderApprox(DdManager *dd, DdNode *f, DdNode *b, int numVars, int threshold, double quality1, double quality0)
DdLevelQueue * cuddLevelQueueInit(int levels, int itemSize, int numBuckets)
struct GlobalQueueItem GlobalQueueItem
#define Cudd_IsComplement(node)
DdNode * Cudd_RemapUnderApprox(DdManager *dd, DdNode *f, int numVars, int threshold, double quality)
DdNode * cuddRemapUnderApprox(DdManager *dd, DdNode *f, int numVars, int threshold, double quality)
DdNode * Cudd_OverApprox(DdManager *dd, DdNode *f, int numVars, int threshold, int safe, double quality)
#define ABC_NAMESPACE_IMPL_END
#define cuddIsConstant(node)
static int BAmarkNodes(DdManager *dd, DdNode *f, ApproxInfo *info, int threshold, double quality1, double quality0)
int Cudd_DebugCheck(DdManager *table)
struct LocalQueueItem * cnext
void cuddHashTableQuit(DdHashTable *hash)
int cuddHashTableInsert2(DdHashTable *hash, DdNode *f, DdNode *g, DdNode *value, ptrint count)
static char rcsid[] DD_UNUSED
#define ABC_NAMESPACE_IMPL_START
static int RAmarkNodes(DdManager *dd, DdNode *f, ApproxInfo *info, int threshold, double quality)
int Cudd_bddLeq(DdManager *dd, DdNode *f, DdNode *g)
int st__lookup(st__table *table, const char *key, char **value)
struct GlobalQueueItem * next
DdNode * Cudd_RemapOverApprox(DdManager *dd, DdNode *f, int numVars, int threshold, double quality)
struct LocalQueueItem * next
DdNode * Cudd_BiasedOverApprox(DdManager *dd, DdNode *f, DdNode *b, int numVars, int threshold, double quality1, double quality0)
DdNode * cuddHashTableLookup2(DdHashTable *hash, DdNode *f, DdNode *g)
int Cudd_CheckKeys(DdManager *table)
static DdNode * RAbuildSubset(DdManager *dd, DdNode *node, ApproxInfo *info)
#define Cudd_NotCond(node, c)
static void updateParity(DdNode *node, ApproxInfo *info, int newparity)
DdHashTable * cuddHashTableInit(DdManager *manager, unsigned int keySize, unsigned int initSize)
int st__ptrhash(const char *, int)
DdNode * cuddUniqueInter(DdManager *unique, int index, DdNode *T, DdNode *E)
int Cudd_DagSize(DdNode *node)