// hw3ex.ccp // // An example of a few functions in C++ // // // Inputs: N (specifies number of variables) // // Outputs: The One (1), Zero(0), or Mask(-) // bits for a fixed SOP term. // // Example Input: // 8 // done // // Example Output: // 0101---- // // To compile: // g++ -o hw3ex hw3ex.cpp // // Prof. John W Lockwood // Washington University // February 26, 2001 // CoE460 // http://www.arl.wustl.edu/~lockwood/class/coe460/ // #include #include #define DEBUG(x) // Define DEBUG(x) x // For verbose output #define MaxLineSize 200 int n; // Number of variables in function char linebuffer[MaxLineSize]; // Buffer to hold input class sop_term { public: unsigned int value; // up to 32-bits: 0=false, 1=true unsigned int mask; // up to 32-bits: 0=Care, 1=DontCare public: void sop_term::display_var(int i); void sop_term::display(int start_bit); }; void sop_term::display_var(int i) { if (( (1< 0) display(start_bit - 1); else return; } int read_num() { int number; scanf("%d\n",&number); return number; } main() { n=read_num(); printf("Function has %d variables\n",n); sop_term myterm; myterm.value = 0x55; // 0000 .. 01010101 in binary myterm.mask = 0x0F; // 0000 .. 00001111 in binary printf("SOP_Term Contains: \n"); myterm.display(n-1); }