|
| |
Digital Circuits
Due Friday, February 4, at midnight.
- Chapter 13, Exercise 2 in the Omnibus. Prove the laws using the
axioms, but also prove them by writing out the truth tables.
- Chapter 13, Exercise 3.
- Chapter 13, Exercise 4.
- We can simulate digital logic gates in Haskell by using the values
True and False of type Bool, corresponding to the Boolean values 1 and 0, respectively.
Write a Haskell function "nandB" that takes two boolean inputs and
returns their logical "nand", which is the inverse of the "and" of the
two values (i.e. "not and"). Thus "nandB" has type Bool ->
Bool -> Bool.
- Using just "nandB" from the previous exercise (and no
other functions), define Haskell functions "notB", "andB",
"orB", and "xorB" that achieve the functionalities implied by the
names. (If you want, you are allowed to use one of these new functions to define
another of the new functions.)
- Using any of the functions from above, define a Haskell function
"halfAdd" that simulates a half adder, as discussed in class. Its type
should be Bool -> Bool -> (Bool,Bool). Then use this function twice to define
a function "add" of type Bool -> Bool -> Bool -> (Bool,Bool) that
simulates a full adder (having two bits of input, plus a carry in, and generating one bit
output plus a carry out). You are allowed to use one other binary gate in addition
to the two halfAdd'ers.
|