// ********************************************************************** // LogicGates.h // // Definitions of functions that emulate elementary logic gates. // // ********************************************************************** // CS251 - Computer Organization // Spring 1997 // Dickinson College // Grant Braught // // ********************************************************************** // // NOTE: // It is possible to add multiple input logic gates too if they // are found to be helpful. However, the gates given below are // sufficient for completion of all of the projects. // #include "Logic.h" #include "LogicGates.h" Bool NOTgate (Bool X) { return(I2B(!X)); } Bool ANDgate (Bool X, Bool Y) { return(I2B(X && Y)); } Bool NANDgate (Bool X, Bool Y) { return(I2B(!(X && Y))); } Bool ORgate (Bool X, Bool Y) { return(I2B(X || Y)); } Bool NORgate (Bool X, Bool Y) { return(I2B(!(X || Y))); } Bool XORgate (Bool X, Bool Y) { return(I2B((X || Y) && (!(X && Y)))); }