πŸ“… Friday, April 26th, 2024

The secret of success is constancy to purpose.

β€” Benjamin Disraeli

ECS154A Lecture: 8-op ALU design

Design an ALU, given the following operations: add, sub, mul2 (multiply by 2), not, xor, and, or.

Notice how we can implement add & sub & mul2 together, and implement not & xor together, so only four mux inputs are needed

0add000x000x0
1sub001x00111
2mul2010x00100
3-011xxxxxx
4not100111xxx
5xor101011xxx
6and110x01xxx
7or111x10xxx

Note that for subtraction, we are taking the two’s complement of B, but we don’t add 1 to the ~B immediately; we add the one as a carry-in () in the full adder.

Now that we’re done with the actual calculation, we need to design the ALU controller.

ECS154A Discussion: 8-op ALU controller

K-map for :

\ 00011110
0xxxx
110xx

We can make a group of four (column 00 and column 10) thanks to the three don’t cares which we can pretend are just ones.


K-map for

\ 00011110
000x0
11101
We can’t really simplify much here. We can go with a two-element group that wraps around (op = 100, 110), and then overlap that with another two-element group (op = 100, 101).

K-map for

\ 00011110
000x0
11110

K-map for

\ 00011110
001x1
1xxxx

Using the don’t cares, we can form two four-element groups (columns 01 & 11, and columns 11 & 10).


K-map for

\ 00011110
0x1x0
1xxxx

K-map for

\ 00011110
001x0
1xxxx

It turns out that:



We need to find a way to save the ALU flags and prevent some of them from changing when they are not supposed to (e.g., the carry flag shouldn’t be changed on any logic operation). In other words, we need to decide, using , if we want to pass the new flags into the actual flag registers.

0add0001111
1sub0011111
2mul20101111
3-011xxxx
4not1000011
5xor1010011
6and1100011
7or1110011

Note that and . We can define . When , we want to prevent V & C from being saved; otherwise, we want to pass them to the actual registers. For now, saving to registers won’t be shown here (registers are covered next week). I think we need a slightly different design of the circuit when actual registers are involved, e.g., for a D flip-flop, we can use a mux that takes in and as inputs and as the select bit.

Expect around 6 operations for an ALU design question on the exam.

SOC001 Discussion: no notes

MGT011A Discussion: no notes