Combinational Logic Blocks
Data Multiplexors
Multiple MUX can be combined together to get more way selection.
a --
+--MUX----
b -- | |
--- +--MUX--e
c -- | | |
+--MUX---- |
d -- | | |
+-- |
S0 S1
Arithmetic Logic Unit (ALU)
Most processors contain a special logic block called "Arithmetic Logic Unit" (ALU).
A simple version that does ADD, SUB, bitwise AND (&
), bitwise OR (|
)
A B
| |
/32 /32
| | when S=00, R=A+B
__v__ __v__ when S=01, R=A-B
\ V / when S=10, R=A&B
\ ALU /<---/---S when S=11, R=A|B
\_____/ 2
|
/32
|
v
R
Implementation
A B
| |
/ 32 / 32
| |
--------------+--------------
| ------|-----+-------|------
| | | | | |
+-----------+ +-------+ +-------+
S0>| ADD/SUB | | AND | | O R |
+-|---|-----+ +---|---+ +---|---+
| | / 32 / 32
| ----- | |
| | ----- -----
v | | |
overflow | __v_____v__
| \ 0 MUX 1 /<----S0
/ 32 \_______/
| |
| -----------
| |
__v_____v__
\ 0 MUX 1 /<-----------------S1
\_______/
|
/ 32
|
v
R
- All operations done altogether
- Let MUX choose which one to output
Adder
Full Adder (Alternative Implementation)
is the majority operator, where
Multibit Adder
Cascading n instances of 1-bit Full Adder
- Unsigned: Last carry
is overflow bit - Signed:
is overflow bit - No overflow: Last bit
or - Overflow: Either
or is 1
- No overflow: Last bit
Subtractor
- XOR serve as conditional inverter
- x = 0, XOR(x, y) = y
- x = 1, XOR(x, y) = -y
- One bit carry input into the LSB as
Final design: