/******************************************************/ /* */ /* this is the main file for my CUDD BDD manipulator */ /* */ /******************************************************/ #include #include #include #include #include /* #include "/usr/local/CUDD/cudd-2.4.0/include/cudd.h" */ #include "/spare/rice/CODE/cudd-2.3.1/include/cudd.h" // /////////////////////////////// // GLOBAL VARIABLES and CONSTANTS // /////////////////////////////// int debug; // stores the debugging flag const int MAXSIZE = 150; // the max num of variables we can deal with DdManager* ddman; // global ddmanager pointer variable DdNode** ddnodearray; // global array of pointers to nodes int numfunctions; // number of functions int numvars; // number of variables in the functions void printStats() { //if (debug) //{ // cout << "Stats from Cudd_PrintInfo: \n\n"; // Cudd_PrintInfo(ddman, stdout); // cout << "End of Stats from Cudd_PrintInfo \n\n"; //} cout << "-----------------------------------------------------------\n"; cout << "num variables in existence: " << Cudd_ReadSize(ddman) << "\n"; cout << "node count: " << Cudd_ReadNodeCount(ddman) << "\n"; cout << "num reorderings: " << Cudd_ReadReorderings(ddman) << "\n"; cout << "memory in use: " << Cudd_ReadMemoryInUse(ddman) << " bytes \n\n"; if (debug) for (int i=0; i> inputs; if (debug) cout << "cube inputs: " << inputs << "\n"; // read the outputs from the file (*infile) >> outputs; if (debug) cout << "cube outputs: " << outputs << "\n"; // ----------------------------------------------- // first build a DD for just this cube, call it cube // ----------------------------------------------- DdNode *cube, *var, *tmp, *tmp2; cube = Cudd_ReadOne(ddman); Cudd_Ref(cube); for (int i=0; iget(ch); while ( (ch!='1') && (ch!='0') && (ch!='-') && (ch!='.') ) infile->get(ch); if (ch=='.') // deal with header/footer stuff { infile->get(ch); infile->get(ch2); // if the character isn't i, o or e then // read over the entire line and discard it if ( (ch!='i') && (ch!='o') & (ch!='e') ) while (ch != '\n') infile->get(ch); if ( (ch=='i') && isspace(ch2) ) { // read the number of inputs (*infile) >> numvars; if (debug) cout << "numvars: " << numvars << "\n"; } else if ( (ch=='o') && isspace(ch2) ) { // read the number of outputs (*infile) >> numfunctions; if (debug) cout << "numfunctions: " << numfunctions << "\n "; // now create the appropriate number of empty dds ddnodearray = (DdNode**)malloc(numfunctions * sizeof(DdNode*)); for (int i=0; iputback(ch); // read a cube and add it to the dds readCube(infile, ordering); } } // end while } int* readOrder(ifstream* infile) { // this routine reads the ordering from the order file // pointed to by f. // the format is expected to be as follows: // 2 1 5 4 3 char ch; int a[MAXSIZE]; int count = 0; infile->get(ch); while(!infile->eof()) { // if the character is a digit, put it back // and read the whole number into the ordering // array, a if (isdigit(ch)) { infile->putback(ch); (*infile) >> a[count]; count++; if (count == MAXSIZE) { cerr << "Exceeded max variables in the orderfile; exiting.\n"; exit(1); } } // read the next char infile->get(ch); } int* ar = (int*)malloc(count*sizeof(int)); for (int i=0; i turn on debugging output\n"; cerr << " -f filename specify file to read\n"; cerr << " file must be in espresso pla format\n"; cerr << " -o orderfile specify file containing order\n"; cerr << " -s use sifting to order\n"; cerr << " -e use exact method for ordering\n"; cerr << " (-s and -e may not be used together)\n\n"; } ifstream* openFile(int pos, char* argv[]) { if (pos == 0) { printusage(); return NULL; } else { ifstream* f = new ifstream(argv[pos]); if (!f) { cerr << "cannot open file " << argv[pos] << "\n"; return NULL; } else return f; } } /******************************************************/ /* MAIN */ /******************************************************/ int main(int argc, char* argv[]) { debug = 0; int fnamepos = 0; char ordermethod = 'n'; int onamepos = 0; for (int i=1; i 0) { if (debug) cout << "opening file " << argv[onamepos] << "\n\n"; ifstream* orderfile = openFile(onamepos, argv); if (orderfile == NULL) return 0; if (debug) cout << "reading file " << argv[onamepos] << "\n\n"; ordering = readOrder(orderfile); } else { if (debug) cout << "creating default ordering \n\n"; for (int i=0; i 0) { // // cout << "\nstatistics after ordering as follows:\n"; // for (int i=0; i