Starting out slow The CPU ’ s workhorse o Logical operations are easiest, because they map Constructing a basic ALU directly onto the hardware. o Of course we will need to CS240 Computer Organization array this to a full 32- Department of Computer Science bits. Wellesley College ALU 14-2 Addition is next CarryOut a b CarryIn Sum CarryOut a b CarryIn Sum CarryOut 0 0 0 0 0 0 0 0 0 0 1 0 0 1 1 0 0 1 0 0 1 0 1 0 0 1 1 0 1 1 0 1 1 0 0 1 0 0 1 0 1 0 1 1 0 1 0 1 1 1 0 1 1 0 0 1 1 1 1 1 1 1 1 1 *A CarryOut occurs as either as CarryGenerate + CarryProprogate. ALU 14-3 ALU 14-4 1
2-bits, 4-bits, 6-bits, a dollar The ripple carry adder o We have a 1-bit ALU that performs AND, OR, and addition. o We create a full 32-bit adder by arraying the results. ALU 14-5 ALU 14-6 Adding subtraction NOR and NAND o Subtraction is the same as adding the negative version of o A MIPS ALU also needs a NOR function. We implement an operand. This is how adders perform subtraction and this by noting that (a + b) = a b. why twos-complement is so very nice. ALU 14-7 ALU 14-8 2
We ’ re getting there . . . Top 1-bit ALU o . . . but we ’ re not home yet. o One instruction that still needs support is the set on less than ( slt ) instruction which produces 1 if a < b. o We start by expanding the input to the mux for Less . ALU 14-9 ALU 14-10 32-bit ALU Finally (Illustrates what we (Adds support do with that blasted for MIPS Set out and how the branch if equal Less values get set.) and branch if not equal by testing whether result of operation equals zero.) ALU 14-11 ALU 14-12 3
Black box representing ALU Carry lookahead Carry generate o gi = ai bi. Carry propagate o pi = ai + bi. Using these define o ci+1 = gi + pi (ci). Now unwind the o recursion to get a sequence of equations only four gates deep. ALU 14-13 ALU 14-14 4
Recommend
More recommend