======== START LECTURE #9 ========

Implementing Addition and Subtraction

We wish to augment the ALU so that we can perform subtraction (as well as addition, AND, and OR).

A 1-bit ALU with ADD, SUB, AND, OR is shown on the right.

  1. To implement addition we use opcode 10 as before and de-assert both b-invert and Cin.
  2. To implement subtraction we still use opcode 10 but we assert both b-invert and Cin.











32-bit version is simply a bunch of these.

(More or less) all ALUs do AND, OR, ADD, SUB. Now we want to customize our ALU for the MIPS architecture, which has a few extra requirements.

  1. slt set-less-than
  2. Overflows
  3. Zero Detect

Implementing SLT

This is fairly clever as we shall see.









Homework: figure out correct rule, i.e. prob 4.23. Hint: when an overflow occurs the sign bit is definitely wrong (so the complement of the sign bit is right).




Implementing Overflow Detection














Simpler Overflow Detection

Recall the simpler overflow detection: An overflow occurs if and only if the carry in to the HOB differs from the carry out of the HOB.

Implementing Zero Detection


Observation: The CarryIn to the LOB and Binvert to all the 1-bit ALUs are always the same. So the 32-bit ALU has just one input called Bnegate, which is sent to the appropriate inputs in the 1-bit ALUs.

The Final Result is

The symbol used for an ALU is on the right

What are the control lines?

What functions can we perform?

What (3-bit) values for the control lines do we need for each function? The control lines are Bnegate (1-bit) and Operation (2-bits)
and 0 00
or 0 01
add 0 10
sub 1 10
slt 1 11