HI22-13 And/Or Function
XCSB      20 points
OEES 215

Back to Main Page
 
Write an And/Or function and a main prog that will operate as follows:

AndOr Function
  • Three numbers will be sent to the AndOr function. The first two numbers will be the bits to be either ANDed  or ORed. The third number will determine if the bits are to be ANDed or ORed. If this third number is a 1, the bits are to be ANDed. If the number is a 0, the bits are to be ORed.
  • The function will return the result of the ANDin or ORing.
Examples
  • If in0 = 0, in1 = 1, and in2 = 1, and the function call is AndOr(in0, in1, in2), the function will return a 0. This is because in2 is a 1, which means that in0 and in1 are to be ANDed.
  • If in0 = 0, in1 = 1, and in2 = 0, and the function call is AndOr(in0, in1, in2), the function will return a 1. This is because in2 is a 0, which means that in0 and in1 are to be ORed.
Main Program
Get in0, in1, and in2 from the switches as you did for the three-input AND gate. Call the AndOr function and display the number it returns in LED 0.
 
Back to Main Page