**Out on:**September 13, 2017**Due by:**never**Collaboration:**open-ended**Grading:**none

Homework is important practice for you, but it’s *not* graded so you don’t have
to submit it.
This particular homework is designed to help you review combinational circuits.

In lecture we mentioned that NAND (and NOR) gates are **universal** in the
sense that **any** combinational circuit can be built **exclusively** out of
NAND (or NOR) gates without any other gates.

For this problem, first show how you can implement the standard AND, OR, and
NOT gates using **only** NAND gates; then show how to do the same thing using
**only** NOR gates.
So you should end up with **six** circuits, three consisting of only NAND
gates, three consisting of only NOR gates.

You should **draw** these circuits and carefully **verify** that their truth
tables agree with those of the AND, OR, and NOT gates they are supposed to
replace.

Below you’ll find the truth tables for XOR and XNOR gates. Show how you can implement XOR and XNOR gates in terms of just AND, OR, and NOT gates.

```
a b | a XOR b a b | a XNOR b
------+--------- ------+----------
0 0 | 0 0 0 | 1
0 1 | 1 0 1 | 0
1 0 | 1 1 0 | 0
1 1 | 0 1 1 | 1
```

You should use the “design process” from lecture:
From the truth tables above, derive a formula for the circuits in either DNF or
CNF (don’t mix normal forms!).
Then **draw** these circuits and carefully **verify** that their truth tables
agree with those given above.
**Do not simplify your circuits, leave them in CNF or DNF!**

Seven-segment displays can be found in a huge number of electronics applications, including on some fancy PC motherboards (where they usually indicate error codes). Everybody knows what they look like, but just in case:

Each of the seven display elements can be switched on and off independently through one of seven pins. The pins are labeled A to G according to the following scheme (forget the decimal point, we won’t use it):

Here is how the hexadecimal digits from 0 to F are usually represented on a seven-segment display:

```
_ _ _ _ _ _ _ _ _ _ _ _
| | | _| _| |_| |_ |_ | |_| |_| |_| |_ | _| |_ |_
|_| | |_ _| | _| |_| | |_| _| | | |_| |_ |_| |_ |
```

For this problem, you have to design a circuit that takes an octal digit 0-7 encoded on three lines and displays it correctly by outputting 0/1 on the pins A-G of the seven-segment display. Your circuit takes the inputs X, Y, and Z on which the digits 0-7 are supplied as follows:

```
Digit | X Y Z
-------+-------
0 | 0 0 0
1 | 0 0 1
2 | 0 1 0
3 | 0 1 1
4 | 1 0 0
5 | 1 0 1
6 | 1 1 0
7 | 1 1 1
```

The outputs of your circuit are A-G connected to the seven-segment display as
shown above.
You should once again use the “design process” from lecture:
From the truth tables (which **you** have to design for this problem!), derive
formulas for the circuit(s) in DNF or CNF (it’s okay to mix normal forms but be
sure to explain why you picked one over the other) and then draw the circuit(s).
**Do not simplify the circuits, leave them in CNF or DNF!**

**Note:** If you’re **really** into circuits, handle 4-bit numbers as well.
But this would be **in addition** to the circuit(s) for 3-bit numbers!

Design a 4-bit ALU that supports the operations AND, OR, NOT, and ADD on two
4-bit inputs; there is a single 4-bit result.
Explain the **structure** of the 4-bit AND, OR, NOT, and ADD circuitry, but
don’t worry about drawing it in detail.
Explain how you combine everything into one ALU using multiplexers.

**You will have to figure out (and should explain in detail!) how you can use
the multiplexers from lecture in parallel to route 4-bit quantities around
your ALU as needed.**

- Please don’t get distracted by folks (online resources or text books) who build their ALUs out of “one bit result slices” or some such thing. The ALU you are asked to design here should consist of 4-bit “units” connected in a suitable way by 4-bit multiplexers.

- You don’t submit homework, so the format in which you draw circuits does not strictly matter. On a project, however, you’d be forced to submit your diagrams in either PDF or ASCII format. For practice, you may want to try doing that.
- If you decide on PDF for circuit diagrams, and if you decide to scan in (or take a picture of) diagrams you made on paper, make sure to check the size of your files. Project submissions cannot be bigger than 2 MB!
- On a project, you must include
**derivations**even for things that seem “obvious” to you; that’s the only way to convince us that you actually did the work. Once again, you may want to get into that habit already.

The “written answers” for the problems above should go into a plain ASCII text
file called `README`

; make sure you explain which notation you’re using for
boolean formulas (the C-type notation is recommended!); make sure to include
explanatory notes that tell us how you solved the problem in question.
If your “diagrams” are in ASCII as well, they can go into the `README`

file;
if your diagrams are in PDF, there should be one file for each problem, so
`problem1.pdf`

, `problem2.pdf`

, and so on.