// ********************************************************************** // Logic.h // // Definitions of types that are used for Boolean logic // and bit representation. // // ********************************************************************** // CS251 - Computer Organization // Spring 1997 // Dickinson College // Grant Braught // // ********************************************************************** // #ifndef LOGIC #define LOGIC #include #include "SysSpecs.h" // // Enumerated types for logic. // enum Bool { TRUE=1, HIGH=1, ON=1, FALSE=0, LOW=0, OFF=0}; enum Boolc { TRUEC='1', HIGHC='1', ONC='1', FALSEC='0', LOWC='0', OFFC='0'}; // // Typedefs for info manipulations // // Represent a string of bits that is up to one word long. // NOTE: Any BitString must to be null terminated. typedef char BitString[8 * WORD_SIZE + 1]; // Hold a the value of a word. // NOTE: If a word is longer than 2 bytes the DecValue type // needs to be redefined. #if (WORD_SIZE <= 2) typedef int DecValue; #else @@@@ DecValue needs redefined for WORD_SIZE > 16 bits. #endif // // Functions for converting from # to char logic levels. // inline char B2C(Bool theLevel) { return (theLevel ? TRUEC : FALSEC); } inline Bool C2B(char theLevel) { return(theLevel == TRUEC ? TRUE : FALSE); } inline Bool I2B(int theLevel) { return(theLevel ? TRUE : FALSE); } inline int B2I(Bool theLevel) { return(theLevel ? 1:0); } // Overloaded output function for Boolean types. inline ostream& operator << (ostream& theStream, Bool theBool) { return (theStream << B2I(theBool)); } #endif