I'm using Cudd package http://vlsi.colorado.edu/~fabio/CUDD/ First I got an error states "dead count != deleted" so I started debugging and I encounter a problem that I can't understand.
The following code takes as input a decimal value and it should return the corresponding BDD to this decimal value using variables in the nodes_vector.
DdNode * convert_decimal_to_BDD(unsigned int decimal_value, DdManager * manager, vector<DdNode *> nodes_vector){
DdNode * tmp3;
int nodes_vector_size = nodes_vector.size();
vector<bool> binary = get_binary_representation(decimal_value, nodes_vector_size);
DdNode * result = Cudd_ReadOne(manager);
Cudd_Ref(result);
for (int i = 0; i < nodes_vector_size; i++){
if(binary[i] == 1){
tmp3 = Cudd_bddAnd(manager,result,nodes_vector[i]);
}
else{
tmp3 = Cudd_bddAnd(manager,result,Cudd_Not(nodes_vector[i]));
}
if(tmp3 == NULL){
printf("convert_decimal_to_BDD: Error 1\n");
exit(1);
}
Cudd_Ref(tmp3);
printf("convert_decimal_to_BDD: tmp->ref %hu\n", tmp3->ref);
Cudd_RecursiveDeref(manager,result);
result = tmp3;
printf("convert_decimal_to_BDD: result->ref %hu\n", result->ref);
}
printf("NFAOBDD::convert_decimal_to_BDD: result->ref %hu\n", result->ref);
return result;
}
For some cases I get the reference value for the result node and the tmp3 node equal to zero, but I can't understand how can this happen after I call "Cudd_ref(tmp3)"
I would appreciate any explanation to this and why may I get "dead count != deleted" error within a loop although I didn't get the "dead count != deleted" error on the first iterations of that loop.