# Lab 5 - Building a 12-bit ALU

### Goal 1 - build an 8-bit ALU

Review the ALU in fig 3-19 and 3-20 in the text. See problem 16 in Chapter 3. Our goal is to build a single slice of the ALU, and then save as a sub-circuit.

Create the single bit circuit as a new circuit, and test it. Then create a new 8-bit ALU with 8 of these devices (as in figure 3-20). Connect to inputs and outputs, and test each function.

Recall that in two's-compliment:
-A = INV(A) + 1
B - A = B + (-A)

(Hint - the A can be negated by inverting it and adding one).

(Another hint - you can force a carry in of the lowest bit to cause the ALU add a 1 to a sum between A and B)

###### To Do

1. Create a single slice of the ALU from the text as a sub-circuit. Combine 8 to make a 8-bit ALU.
2. Add a diagram of the slice, and of the complete 8-bit ALU, to the lab report.
3. Set up the ALU to do a subtraction of 12 - 7.
4. Take a screen shot of the subtraction, add to lab report.

### Goal 2 - Create an enhanced 12-bit ALU

Now we want to take a different approach to building an ALU using the capability of multi-line wide components. Rather than create 12 ALU slices and assembling them, we will create an ALU by designing it as a single circuit that 12 bits wide.

We wish to create an ALU with the following functions: The three function bits should cause the 12-bit ALU to do the following operations:

### ALU Functions

Bits Operation
000 ACC
001 Reg
010 ACC'
011 Reg ^ ACC
100 Reg V ACC
101 Reg + ACC + Cin
110 -Reg
111 ACC-Reg

Note that A+ Cin and B + Cin give us multiple functions. If Cin is 0, the A or B inputs is simply passed through. Otherwise the value is incremented.

Thus the ALU should have the following inputs and outputs:

• 2 x 12-bit inputs (A and B)
• 12 bits of output
• a single carry in
• a single carry out
• a Z bit out, which is 1 if the output is zero
• a N bit out, which is 1 if the output is negative (top bit is 1)
• 3 function bits.
The technique will be as following. Start with a single 3x8 decoder. This will be used to select which 12-bit function the data will flow through.

Below is the high level view the desired ALU in use. Note it is using function 3 (011), and is thus performing A+B+Cin.

###### Decoder and tri-state buffers

A multi-bit input can be put into multiple nulti-bit functions:

Note that the AND, OR, Adder, and not are all 4 bits wide. Thus we are computing all 4 functions at a time. (The Cin and Cout in a multibit adder work correctly, that in Cin goes to the low bit in, and Cout come from the high bit out).

What we would like is to pick the output. This can be done with a decoder and tri-state buffers. A tri-state buffers only puts a signal if enabled. A decoder can select which output is enabled. The beauty of a decoder is that only ONE output will ever be enabled at a time. (It's an error to have two enabled outputs connected)

Below is a simple 4 function ALU using this technique. Included also is a downloadable version of this circuit:

(The Cout is being ignored in this example)

One thing remains. How can we get the N and Z bits? The Z bit is merely the NOR of all the data bits (if any bits are 1, it is non-zero). The N bit is simply the top bit (in two-complement the alll negitive numbers have 1 in the top bit). To do these functions we need to use a splitter:

Simple4BitALU.circ: Simple 4-Bit ALU

###### To Do

1. Create a 12-bit ALU using the method above. You may download the attached machine, and expand, or start from scratch.
2. Add a single V bit output. The V bit is a two's-complement oVerflow bit. It should be 1 if the signs of the inputs are the same, but the sign of the output is different. How can you do this?
3. A a Cout to the overal circuit. This should be the carry out of ONLY the highest bit. How can we do this in this kind of multibit circuit? (Hint: you will need to embed a circuit lots of carryout's into another circuit with only one carry out)
4. Test out the ALU.
5. Make the ALU a sub-circuit. Make a test circuit like the first diagram above to test it as a sub-circuit.
6. Take a screen shot of all circuits, add to lab report.
7. What did you learn from this lab?
8. What did you find the most difficult? Was any part unclear?
Topic attachments
I Attachment Action Size Date Who Comment
png 12BitALUExample.png manage 3.1 K 2014-09-15 - 12:17 JimSkon
png ALU8.png manage 24.5 K 2014-09-30 - 17:35 JimSkon
png ALUFunctions.png manage 24.7 K 2014-10-05 - 00:21 JimSkon
png Multioperations.png manage 4.3 K 2014-09-15 - 13:13 JimSkon
circ Simple4BitALU.circ manage 13.6 K 2014-09-15 - 13:09 JimSkon
png Simple4BitALU.png manage 4.9 K 2014-09-15 - 13:10 JimSkon
png Simple5BitALUNZ.png manage 6.3 K 2014-09-15 - 13:10 JimSkon
png alu1.png manage 38.6 K 2014-09-30 - 17:31 JimSkon
Topic revision: r8 - 2014-11-04 - JimSkon

TWiki

* Webs

Copyright &© by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback