ece/cs 250 computer architecture fall 2021
TRANSCRIPT
![Page 1: ECE/CS 250 Computer Architecture Fall 2021](https://reader030.vdocuments.us/reader030/viewer/2022012804/61bd25d861276e740b0fd932/html5/thumbnails/1.jpg)
ECE/CS 250Computer Architecture
Fall 2021
Basics of Logic Design: Boolean Algebra, Logic Gates, and the ALU
(Combinational Logic)
Tyler Bletsch
Duke University
Slides are derived from work byDaniel J. Sorin (Duke), Alvy Lebeck (Duke), and Drew Hilton (Duke)
![Page 2: ECE/CS 250 Computer Architecture Fall 2021](https://reader030.vdocuments.us/reader030/viewer/2022012804/61bd25d861276e740b0fd932/html5/thumbnails/2.jpg)
2
Reading
• Appendix B (parts 1,2,3,5,6,7,8,9,10)
• This material is covered in MUCH greater depth in ECE/CS 350 – please take ECE/CS 350 if you want to learn enough digital design to build your own processor
![Page 3: ECE/CS 250 Computer Architecture Fall 2021](https://reader030.vdocuments.us/reader030/viewer/2022012804/61bd25d861276e740b0fd932/html5/thumbnails/3.jpg)
3
What We’ve Done, Where We’re Going
I/O systemCPU
Compiler
OperatingSystem
Application
Digital Design
Circuit Design
Instruction SetArchitecture, Memory, I/O
Firmware
Memory
Software
Hardware
Interface BetweenHW and SW
Top Down
(Almost) Bottom UP to CPU
![Page 4: ECE/CS 250 Computer Architecture Fall 2021](https://reader030.vdocuments.us/reader030/viewer/2022012804/61bd25d861276e740b0fd932/html5/thumbnails/4.jpg)
4
Computer = Machine That Manipulates Bits
• Everything is in binary (bunches of 0s and 1s)
• Instructions, numbers, memory locations, etc.
• Computer is a machine that operates on bits
• Executing instructions operating on bits
• Computers physically made of transistors
• Electrically controlled switches
• We can use transistors to build logic
• E.g., if this bit is a 0 and that bit is a 1, then set some other bit to be a 1
• E.g., if the first 5 bits of the instruction are 10010 then set this other bit to 1 (to tell the adder to subtract instead of add)
![Page 5: ECE/CS 250 Computer Architecture Fall 2021](https://reader030.vdocuments.us/reader030/viewer/2022012804/61bd25d861276e740b0fd932/html5/thumbnails/5.jpg)
5
How Many Transistors Are We Talking About?
Pentium III
• Processor Core 9.5 Million Transistors
• Total: 28 Million Transistors
Pentium 4
• Total: 42 Million Transistors
Core2 Duo (two processor cores)
• Total: 290 Million Transistors
Core2 Duo Extreme (4 processor cores, 8MB cache)
• Total: 590 Million Transistors
Core i7 with 6-cores
• Total: 2.27 Billion Transistors
How do they design such a thing? Carefully!
![Page 6: ECE/CS 250 Computer Architecture Fall 2021](https://reader030.vdocuments.us/reader030/viewer/2022012804/61bd25d861276e740b0fd932/html5/thumbnails/6.jpg)
6
Abstraction!
• Use of abstraction (key to design of any large system)
• Put a few (2-8) transistors into a logic gate (or, and, xor, …)
• Combine gates into logical functions (add, select,….)
• Combine adders, shifters, etc., together into modules
Units with well-defined interfaces for large tasks: e.g., decode
• Combine a dozen of those into a core…
• Stick 4 cores on a chip…
![Page 7: ECE/CS 250 Computer Architecture Fall 2021](https://reader030.vdocuments.us/reader030/viewer/2022012804/61bd25d861276e740b0fd932/html5/thumbnails/7.jpg)
7
Boolean Algebra
• First step to logic: Boolean Algebra
• Manipulation of True / False (1/0)
• After all: everything is just 1s and 0s
• Given inputs (variables): A, B, C, P, Q…
• Compute outputs using logical operators, such as:
• NOT: !A (= ~A = A)
• AND: A&B (= AB = A*B = AB = AB) = A&&B in C/C++
• OR: A | B (= A+B = A B) = A || B in C/C++
• XOR: A ^ B (= A B)
• NAND, NOR, XNOR, Etc.
![Page 8: ECE/CS 250 Computer Architecture Fall 2021](https://reader030.vdocuments.us/reader030/viewer/2022012804/61bd25d861276e740b0fd932/html5/thumbnails/8.jpg)
8
a NOT(a)
0 1
1 0
a b AND(a,b)
0 0 0
0 1 0
1 0 0
1 1 1
a b OR(a,b)
0 0 0
0 1 1
1 0 1
1 1 1
a b XOR(a,b)
0 0 0
0 1 1
1 0 1
1 1 0
a b XNOR(a,b)
0 0 1
0 1 0
1 0 0
1 1 1
a b NOR(a,b)
0 0 1
0 1 0
1 0 0
1 1 0
Truth Tables
• Can represent as truth table: shows outputs for all inputs
![Page 9: ECE/CS 250 Computer Architecture Fall 2021](https://reader030.vdocuments.us/reader030/viewer/2022012804/61bd25d861276e740b0fd932/html5/thumbnails/9.jpg)
10
a b c f1f20 0 0 0 1
0 0 1 1 1
0 1 0 1 0
0 1 1 0 0
1 0 0 1 0
1 0 1 1 0
1 1 0 0 1
1 1 1 1 1
Any Inputs, Any Outputs
• Can have any # of inputs, any # of outputs
• Can have arbitrary functions:
![Page 10: ECE/CS 250 Computer Architecture Fall 2021](https://reader030.vdocuments.us/reader030/viewer/2022012804/61bd25d861276e740b0fd932/html5/thumbnails/10.jpg)
11
Let’s Write a Truth Table for a Function…
• Example:
(A & B) | !C
Start with Empty TT
Column Per Input
Column Per Output
A B C Output
![Page 11: ECE/CS 250 Computer Architecture Fall 2021](https://reader030.vdocuments.us/reader030/viewer/2022012804/61bd25d861276e740b0fd932/html5/thumbnails/11.jpg)
12
Let’s write a Truth Table for a function…
• Example:
(A & B) | !C
Start with Empty TT
Column Per Input
Column Per Output
Fill in Inputs
Counting in Binary
A B C Output
0 0 0
![Page 12: ECE/CS 250 Computer Architecture Fall 2021](https://reader030.vdocuments.us/reader030/viewer/2022012804/61bd25d861276e740b0fd932/html5/thumbnails/12.jpg)
13
Let’s write a Truth Table for a function…
• Example:
(A & B) | !C
Start with Empty TT
Column Per Input
Column Per Output
Fill in Inputs
Counting in Binary
A B C Output
0 0 0
0 0 1
![Page 13: ECE/CS 250 Computer Architecture Fall 2021](https://reader030.vdocuments.us/reader030/viewer/2022012804/61bd25d861276e740b0fd932/html5/thumbnails/13.jpg)
14
Let’s write a Truth Table for a function…
• Example:
(A & B) | !C
Start with Empty TT
Column Per Input
Column Per Output
Fill in Inputs
Counting in Binary
A B C Output
0 0 0
0 0 1
0 1 0
0 1 1
1 0 0
1 0 1
1 1 0
1 1 1
![Page 14: ECE/CS 250 Computer Architecture Fall 2021](https://reader030.vdocuments.us/reader030/viewer/2022012804/61bd25d861276e740b0fd932/html5/thumbnails/14.jpg)
15
Let’s write a Truth Table for a function…
• Example:
(A & B) | !C
Start with Empty TT
Column Per Input
Column Per Output
Fill in Inputs
Counting in Binary
Compute Output
(0 & 0) | !0 = 0 | 1 = 1
A B C Output
0 0 0 1
0 0 1
0 1 0
0 1 1
1 0 0
1 0 1
1 1 0
1 1 1
![Page 15: ECE/CS 250 Computer Architecture Fall 2021](https://reader030.vdocuments.us/reader030/viewer/2022012804/61bd25d861276e740b0fd932/html5/thumbnails/15.jpg)
16
Let’s write a Truth Table for a function…
• Example:
(A & B) | !C
Start with Empty TT
Column Per Input
Column Per Output
Fill in Inputs
Counting in Binary
Compute Output
(0 & 0) | !1 = 0 | 0 = 0
A B C Output
0 0 0 1
0 0 1 0
0 1 0
0 1 1
1 0 0
1 0 1
1 1 0
1 1 1
![Page 16: ECE/CS 250 Computer Architecture Fall 2021](https://reader030.vdocuments.us/reader030/viewer/2022012804/61bd25d861276e740b0fd932/html5/thumbnails/16.jpg)
17
Let’s write a Truth Table for a function…
• Example:
(A & B) | !C
Start with Empty TT
Column Per Input
Column Per Output
Fill in Inputs
Counting in Binary
Compute Output
(0 & 1) | !0 = 0 | 1 = 1
A B C Output
0 0 0 1
0 0 1 0
0 1 0 1
0 1 1
1 0 0
1 0 1
1 1 0
1 1 1
![Page 17: ECE/CS 250 Computer Architecture Fall 2021](https://reader030.vdocuments.us/reader030/viewer/2022012804/61bd25d861276e740b0fd932/html5/thumbnails/17.jpg)
18
Let’s write a Truth Table for a function…
• Example:
(A & B) | !C
Start with Empty TT
Column Per Input
Column Per Output
Fill in Inputs
Counting in Binary
Compute Output
A B C Output
0 0 0 1
0 0 1 0
0 1 0 1
0 1 1 0
1 0 0 1
1 0 1 0
1 1 0 1
1 1 1 1
Logisim example
basic_logic.circ : example1
![Page 18: ECE/CS 250 Computer Architecture Fall 2021](https://reader030.vdocuments.us/reader030/viewer/2022012804/61bd25d861276e740b0fd932/html5/thumbnails/18.jpg)
20
Suppose I turn it around…
• Given a Truth Table, find the formula?
Hmmm.. A B C Output
0 0 0 1
0 0 1 1
0 1 0 1
0 1 1 0
1 0 0 0
1 0 1 0
1 1 0 1
1 1 1 1
![Page 19: ECE/CS 250 Computer Architecture Fall 2021](https://reader030.vdocuments.us/reader030/viewer/2022012804/61bd25d861276e740b0fd932/html5/thumbnails/19.jpg)
21
Suppose I turn it around…
• Given a Truth Table, find the formula?
Hmmm …
Could write down every “true” case
Then OR together:
(!A & !B & !C) |
(!A & !B & C) |
(!A & B & !C) |
(A & B &!C) |
(A & B &C)
A B C Output
0 0 0 1
0 0 1 1
0 1 0 1
0 1 1 0
1 0 0 0
1 0 1 0
1 1 0 1
1 1 1 1
![Page 20: ECE/CS 250 Computer Architecture Fall 2021](https://reader030.vdocuments.us/reader030/viewer/2022012804/61bd25d861276e740b0fd932/html5/thumbnails/20.jpg)
22
Suppose I turn it around…
• Given a Truth Table, find the formula?
Hmmm..
Could write down every “true” case
Then OR together:
(!A & !B & !C) |
(!A & !B & C) |
(!A & B & !C) |
(A & B &!C) |
(A & B &C)
A B C Output
0 0 0 1
0 0 1 1
0 1 0 1
0 1 1 0
1 0 0 0
1 0 1 0
1 1 0 1
1 1 1 1
![Page 21: ECE/CS 250 Computer Architecture Fall 2021](https://reader030.vdocuments.us/reader030/viewer/2022012804/61bd25d861276e740b0fd932/html5/thumbnails/21.jpg)
23
Suppose I turn it around…
• Given a Truth Table, find the formula?
Hmmm..
Could write down every “true” case
Then OR together:
(!A & !B & !C) |
(!A & !B & C) |
(!A & B & !C) |
(A & B &!C) |
(A & B &C)
A B C Output
0 0 0 1
0 0 1 1
0 1 0 1
0 1 1 0
1 0 0 0
1 0 1 0
1 1 0 1
1 1 1 1
![Page 22: ECE/CS 250 Computer Architecture Fall 2021](https://reader030.vdocuments.us/reader030/viewer/2022012804/61bd25d861276e740b0fd932/html5/thumbnails/22.jpg)
24
Suppose I turn it around…
• This approach: “sum of products”
• Works every time
• Result is right…
• But really ugly
(!A & !B & !C) |
(!A & !B & C) |
(!A & B & !C) |
(A & B &!C) |
(A & B &C)
A B C Output
0 0 0 1
0 0 1 1
0 1 0 1
0 1 1 0
1 0 0 0
1 0 1 0
1 1 0 1
1 1 1 1
![Page 23: ECE/CS 250 Computer Architecture Fall 2021](https://reader030.vdocuments.us/reader030/viewer/2022012804/61bd25d861276e740b0fd932/html5/thumbnails/23.jpg)
25
Suppose I turn it around…
• This approach: “sum of products”
• Works every time
• Result is right…
• But really ugly
(!A & !B & !C) |
(!A & !B & C) |
(!A & B & !C) |
(A & B &!C) |
(A & B &C)
Could just be (A & B) here ?
A B C Output
0 0 0 1
0 0 1 1
0 1 0 1
0 1 1 0
1 0 0 0
1 0 1 0
1 1 0 1
1 1 1 1
![Page 24: ECE/CS 250 Computer Architecture Fall 2021](https://reader030.vdocuments.us/reader030/viewer/2022012804/61bd25d861276e740b0fd932/html5/thumbnails/24.jpg)
26
Suppose I turn it around…
• This approach: “sum of products”
• Works every time
• Result is right…
• But really ugly
(!A & !B & !C) |
(!A & !B & C) |
(!A & B & !C) |
(A&B)
A B C Output
0 0 0 1
0 0 1 1
0 1 0 1
0 1 1 0
1 0 0 0
1 0 1 0
1 1 0 1
1 1 1 1
![Page 25: ECE/CS 250 Computer Architecture Fall 2021](https://reader030.vdocuments.us/reader030/viewer/2022012804/61bd25d861276e740b0fd932/html5/thumbnails/25.jpg)
27
Suppose I turn it around…
• This approach: “sum of products”
• Works every time
• Result is right…
• But really ugly
(!A & !B & !C) |
(!A & !B & C) |
(!A & B & !C) |
(A&B)
Could just be (!A & !B) here
A B C Output
0 0 0 1
0 0 1 1
0 1 0 1
0 1 1 0
1 0 0 0
1 0 1 0
1 1 0 1
1 1 1 1
![Page 26: ECE/CS 250 Computer Architecture Fall 2021](https://reader030.vdocuments.us/reader030/viewer/2022012804/61bd25d861276e740b0fd932/html5/thumbnails/26.jpg)
28
Suppose I turn it around…
• This approach: “sum of products”
• Works every time
• Result is right…
• But really ugly
(!A & !B) |
(!A & B & !C) |
(A&B)
Could just be (!A & !B) here
A B C Output
0 0 0 1
0 0 1 1
0 1 0 1
0 1 1 0
1 0 0 0
1 0 1 0
1 1 0 1
1 1 1 1
![Page 27: ECE/CS 250 Computer Architecture Fall 2021](https://reader030.vdocuments.us/reader030/viewer/2022012804/61bd25d861276e740b0fd932/html5/thumbnails/27.jpg)
29
Suppose I turn it around…
• This approach: “sum of products”
• Works every time
• Result is right…
• But really ugly
(!A & !B) |
(!A & B & !C) |
(A&B)
Looks nicer…
Can we do better?
A B C Output
0 0 0 1
0 0 1 1
0 1 0 1
0 1 1 0
1 0 0 0
1 0 1 0
1 1 0 1
1 1 1 1
![Page 28: ECE/CS 250 Computer Architecture Fall 2021](https://reader030.vdocuments.us/reader030/viewer/2022012804/61bd25d861276e740b0fd932/html5/thumbnails/28.jpg)
32
Just did some of these by intuition.. but
• Somewhat intuitive approach to simplifying
• This is math, so there are formal rules
• Just like “regular” algebra
![Page 29: ECE/CS 250 Computer Architecture Fall 2021](https://reader030.vdocuments.us/reader030/viewer/2022012804/61bd25d861276e740b0fd932/html5/thumbnails/29.jpg)
33
Boolean Function Simplification
• Boolean expressions can be simplified by using the following rules (bitwise logical):• A & A = A A | A = A
• A & 0 = 0 A | 0 = A
• A & 1 = A A | 1 = 1
• A & !A = 0 A | !A = 1
• !!A = A
• & and | are both commutative and associative
• & and | can be distributed: A & (B | C) = (A & B) | (A & C)
• & and | can be subsumed: A | (A & B) = A
![Page 30: ECE/CS 250 Computer Architecture Fall 2021](https://reader030.vdocuments.us/reader030/viewer/2022012804/61bd25d861276e740b0fd932/html5/thumbnails/30.jpg)
34
DeMorgan’s Laws
• Two (less obvious) Laws of Boolean Algebra:
• Let’s push negations inside, flipping & and |
!(A & B) = (!A) | (!B)
!(A | B) = (!A) & (!B)
• You should try this at home – build truth tables for both the left and right sides and see that they’re the same
![Page 31: ECE/CS 250 Computer Architecture Fall 2021](https://reader030.vdocuments.us/reader030/viewer/2022012804/61bd25d861276e740b0fd932/html5/thumbnails/31.jpg)
35
Summary of all Boolean axioms
Name AND form OR form
Identity law 1 & A = A 0 | A = A
Null law 0 & A = 0 1 | A = 1
Idempotent law A & A = A A | A = A
Inverse law A & !A = 0 A | !A = 1
Commutative law A & B = B & A A | B = B | A
Associative law (A&B) & C = A & (B&C) (A|B) | C = A | (B|C)
Distributive law A | (B&C) = (A|B) & (A|C) A & (B|C) = (A&B) | (A&C)
Absorption law A & (A|B) = A A | (A&B) = A
De Morgan’s law !(A&B) = !A | !B !(A|B) = !A & !B
Double negation law !!A = A
Adapted from http://studytronics.weebly.com/boolean-algebra.html
![Page 32: ECE/CS 250 Computer Architecture Fall 2021](https://reader030.vdocuments.us/reader030/viewer/2022012804/61bd25d861276e740b0fd932/html5/thumbnails/32.jpg)
37
Simplification Example:
! (!A | !(A & (B | C)))
DeMorgan’s
!!A & !! (A & (B | C))
Double Negation Elimination
A & (A & (B | C))
Associativity of &
(A & A) & (B | C)
A & A = A
A & (B | C)
![Page 33: ECE/CS 250 Computer Architecture Fall 2021](https://reader030.vdocuments.us/reader030/viewer/2022012804/61bd25d861276e740b0fd932/html5/thumbnails/33.jpg)
38
You try this:
Come up with a formula for this Truth Table
Simplify as much as possible
Sum of Products:
(!A & !B & !C) |
(!A & B & !C) |
(A & !B & C) |
(A & B & C)
A B C Output
0 0 0 1
0 0 1 0
0 1 0 1
0 1 1 0
1 0 0 0
1 0 1 1
1 1 0 0
1 1 1 1
Simplify this part
![Page 34: ECE/CS 250 Computer Architecture Fall 2021](https://reader030.vdocuments.us/reader030/viewer/2022012804/61bd25d861276e740b0fd932/html5/thumbnails/34.jpg)
39
You try this:
Simplify:
(!A & !B & !C) | (!A & B & !C)
Regroup (associative/commutative):
((!A & !C) & !B) | ((!A & !C) & B)
Un-distribute (factor):
(!A & !C) & (!B | B)
OR identities:
(!A & !C) & true = (!A & !C)
![Page 35: ECE/CS 250 Computer Architecture Fall 2021](https://reader030.vdocuments.us/reader030/viewer/2022012804/61bd25d861276e740b0fd932/html5/thumbnails/35.jpg)
40
You try this:
Come up with a formula for this Truth Table
Simplify as much as possible
Sum of Products:
(!A & !C) |
(A & !B & C) |
(A & B & C)
A B C Output
0 0 0 1
0 0 1 0
0 1 0 1
0 1 1 0
1 0 0 0
1 0 1 1
1 1 0 0
1 1 1 1
Result of simplifying
You can simplify this
part in the same way…
![Page 36: ECE/CS 250 Computer Architecture Fall 2021](https://reader030.vdocuments.us/reader030/viewer/2022012804/61bd25d861276e740b0fd932/html5/thumbnails/36.jpg)
41
You try this:
A B C Output
0 0 0 1
0 0 1 0
0 1 0 1
0 1 1 0
1 0 0 0
1 0 1 1
1 1 0 0
1 1 1 1
Come up with a formula for this Truth Table
Simplify as much as possible
Sum of Products:
(!A & !C) |
(A & C)
Logisim example
basic_logic.circ : example4
![Page 37: ECE/CS 250 Computer Architecture Fall 2021](https://reader030.vdocuments.us/reader030/viewer/2022012804/61bd25d861276e740b0fd932/html5/thumbnails/37.jpg)
42
Applying the Theory
• Lots of good theory
• Can reason about complex Boolean expressions
• But why is this useful?
![Page 38: ECE/CS 250 Computer Architecture Fall 2021](https://reader030.vdocuments.us/reader030/viewer/2022012804/61bd25d861276e740b0fd932/html5/thumbnails/38.jpg)
43
a
b
AND(a,b) a
b
OR(a,b)
a NOT(a)
Boolean Gates
• Gates are electronic devices that implement simple Boolean functions (building blocks of hardware)
XOR(a,b)a
b
a
b
NAND(a,b) a
b
NOR(a,b) XNOR(a,b)a
b
![Page 39: ECE/CS 250 Computer Architecture Fall 2021](https://reader030.vdocuments.us/reader030/viewer/2022012804/61bd25d861276e740b0fd932/html5/thumbnails/39.jpg)
44
Guide to Remembering your Gates
• This one looks like it just points its input where to go
• It just produces its input as its output
• Called a buffer
• A circle always means negate (invert)
a a
a NOT(a)
Circle = NOT
![Page 40: ECE/CS 250 Computer Architecture Fall 2021](https://reader030.vdocuments.us/reader030/viewer/2022012804/61bd25d861276e740b0fd932/html5/thumbnails/40.jpg)
45
a
b
AND(a,b) a
b
OR(a,b)
Guide to Remembering your Gates
XOR(a,b)a
b
Straight like an A Curved, like an OXOR looks like OR (curved line),
but has two lines (like an X does)
XNOR(a,b)
a NOT(a)
a
b
NAND(a,b) a
b
NOR(a,b) a
b
Circle means NOT
(XNOR is 1-bit “equals” by the way)
![Page 41: ECE/CS 250 Computer Architecture Fall 2021](https://reader030.vdocuments.us/reader030/viewer/2022012804/61bd25d861276e740b0fd932/html5/thumbnails/41.jpg)
46
Brief Interlude: Building An Inverter
a NOT(a)
ground= 0
Vdd = power = 1
a NOT(a)
P-type: switch is
“on” if input is 0
N-type: switch is
“on” if input is 1
![Page 42: ECE/CS 250 Computer Architecture Fall 2021](https://reader030.vdocuments.us/reader030/viewer/2022012804/61bd25d861276e740b0fd932/html5/thumbnails/42.jpg)
47
(!A & !C)|(A & C)
Boolean Functions, Gates and Circuits
• Circuits are made from a network of gates.
A
C
Out
Logisim example
basic_logic.circ : example5
![Page 43: ECE/CS 250 Computer Architecture Fall 2021](https://reader030.vdocuments.us/reader030/viewer/2022012804/61bd25d861276e740b0fd932/html5/thumbnails/43.jpg)
48
A few more words about gates
• Gates have inputs and outputs
• If you try to hook up two outputs, bad things happen
(your processor catches fire)
• If you don’t hook up an input, it behaves kind of randomly
(also not good, but not set-your-chip-on-fire bad)
ab
c
d
BAD!
![Page 44: ECE/CS 250 Computer Architecture Fall 2021](https://reader030.vdocuments.us/reader030/viewer/2022012804/61bd25d861276e740b0fd932/html5/thumbnails/44.jpg)
49
Introducing the Multiplexer (“mux”)
Input AInput B
Output
Selector
(S)
“B”“A”
![Page 45: ECE/CS 250 Computer Architecture Fall 2021](https://reader030.vdocuments.us/reader030/viewer/2022012804/61bd25d861276e740b0fd932/html5/thumbnails/45.jpg)
50
Introducing the Multiplexer (“mux”)
mux
1
1 0
0
Input A
Selector (S)
Input B
Output
“A”
![Page 46: ECE/CS 250 Computer Architecture Fall 2021](https://reader030.vdocuments.us/reader030/viewer/2022012804/61bd25d861276e740b0fd932/html5/thumbnails/46.jpg)
51
Introducing the Multiplexer (“mux”)
mux
0
0
1
Selector (S)
Input B
Output
“B”
1Input A
![Page 47: ECE/CS 250 Computer Architecture Fall 2021](https://reader030.vdocuments.us/reader030/viewer/2022012804/61bd25d861276e740b0fd932/html5/thumbnails/47.jpg)
52
Introducing the Multiplexer (“mux”)
mux
1
1
1
Selector (S)
Input B
Output
“B”
1Input A
![Page 48: ECE/CS 250 Computer Architecture Fall 2021](https://reader030.vdocuments.us/reader030/viewer/2022012804/61bd25d861276e740b0fd932/html5/thumbnails/48.jpg)
53
Let’s Make a Useful Circuit
• Pick between 2 inputs (called 2-to-1 MUX)
• Short for multiplexor
• What might we do first?
• Make a truth table?
• S is selector:
• S=0, pick A
• S=1, pick B
• Next: sum-of-products
(!A & B & S) |
(A & !B & !S) |
(A & B & !S ) |
(A & B & S)
• Simplify(A & !S) | (B & S)
A B S Output
0 0 0 0
0 0 1 0
0 1 0 0
0 1 1 1
1 0 0 1
1 0 1 0
1 1 0 1
1 1 1 1
![Page 49: ECE/CS 250 Computer Architecture Fall 2021](https://reader030.vdocuments.us/reader030/viewer/2022012804/61bd25d861276e740b0fd932/html5/thumbnails/49.jpg)
54
s
a
b
output
Circuit Example: 2x1 MUX
MUX(A, B, S) = (A & !S) | (B & S)
Draw it in gates:
output
A
B
S
OR
AND
AND
So common, we give it
its own symbol:
Logisim example
basic_logic.circ : mux-2x1
![Page 50: ECE/CS 250 Computer Architecture Fall 2021](https://reader030.vdocuments.us/reader030/viewer/2022012804/61bd25d861276e740b0fd932/html5/thumbnails/50.jpg)
55
Example 4x1 MUX
3
2
1
0a
b
c
d
y
S
2
a
b
c
d
out
s0 s1
The / 2 on the wire means “2 bits”
Logisim example
basic_logic.circ : mux-4x1
![Page 51: ECE/CS 250 Computer Architecture Fall 2021](https://reader030.vdocuments.us/reader030/viewer/2022012804/61bd25d861276e740b0fd932/html5/thumbnails/51.jpg)
56
Arithmetic and Logical Operations in ISA
• What operations are there?
• How do we implement them?• Consider a 1-bit Adder
![Page 52: ECE/CS 250 Computer Architecture Fall 2021](https://reader030.vdocuments.us/reader030/viewer/2022012804/61bd25d861276e740b0fd932/html5/thumbnails/52.jpg)
57
Designing a 1-bit adder
• What boolean function describes the low bit?
• XOR
• What boolean function describes the high bit?
• AND
0 + 0 = 00
0 + 1 = 01
1 + 0 = 01
1 + 1 = 10
![Page 53: ECE/CS 250 Computer Architecture Fall 2021](https://reader030.vdocuments.us/reader030/viewer/2022012804/61bd25d861276e740b0fd932/html5/thumbnails/53.jpg)
58
Designing a 1-bit adder
• Remember how we did binary addition:
• Add the two bits
• Do we have a carry-in for this bit?
• Do we have to carry-out to the next bit?
01101100
01101101
+00101100
10011001
![Page 54: ECE/CS 250 Computer Architecture Fall 2021](https://reader030.vdocuments.us/reader030/viewer/2022012804/61bd25d861276e740b0fd932/html5/thumbnails/54.jpg)
59
Designing a 1-bit adder
• So we’ll need to add three bits (including carry-in)
• Two-bit output is the carry-out and the sum
a b Cin0 + 0 + 0 = 00
0 + 0 + 1 = 01
0 + 1 + 0 = 01
0 + 1 + 1 = 10
1 + 0 + 0 = 01
1 + 0 + 1 = 10
1 + 1 + 0 = 10
1 + 1 + 1 = 11Turn into expression,
simplify,
circuit-ify,
yadda yadda yadda…
![Page 55: ECE/CS 250 Computer Architecture Fall 2021](https://reader030.vdocuments.us/reader030/viewer/2022012804/61bd25d861276e740b0fd932/html5/thumbnails/55.jpg)
60
A 1-bit Full Adder
a b Cin Sum Cout0 0 0 0 0
0 0 1 1 0
0 1 0 1 0
0 1 1 0 1
1 0 0 1 0
1 0 1 0 1
1 1 0 0 1
1 1 1 1 1
01101100
01101101
+00101100
10011001
a
b
Cin
Cout
Sum
Logisim example
basic_logic.circ : full-adder
![Page 56: ECE/CS 250 Computer Architecture Fall 2021](https://reader030.vdocuments.us/reader030/viewer/2022012804/61bd25d861276e740b0fd932/html5/thumbnails/56.jpg)
61
b0b1b2b3 a0a1a2a3
Cout
S0S1S2S3
Full AdderFull AdderFull AdderFull Adder
Example: 4-bit adder
Logisim example
basic_logic.circ : 4bit-adder
![Page 57: ECE/CS 250 Computer Architecture Fall 2021](https://reader030.vdocuments.us/reader030/viewer/2022012804/61bd25d861276e740b0fd932/html5/thumbnails/57.jpg)
62
Subtraction
• How do we perform integer subtraction?
• What is the hardware?
• Recall: hardware was why 2’s complement was good idea
• Remember: Subtraction is just addition
X – Y =
X + (-Y) =
X + (~Y +1)
![Page 58: ECE/CS 250 Computer Architecture Fall 2021](https://reader030.vdocuments.us/reader030/viewer/2022012804/61bd25d861276e740b0fd932/html5/thumbnails/58.jpg)
63
Full AdderFull AdderFull AdderFull Adder
b0b1b2b3 a0a1a2a3
Cout
S0S1S2S3
Add/Sub
Example: Adder/Subtractor
Logisim example
basic_logic.circ : 4bit-addsub
![Page 59: ECE/CS 250 Computer Architecture Fall 2021](https://reader030.vdocuments.us/reader030/viewer/2022012804/61bd25d861276e740b0fd932/html5/thumbnails/59.jpg)
64
Overflow
• We can detect unsigned overflow by looking at CO
• How would we detect signed overflow?
• If adding positive numbers and result “is” negative
• If adding negative numbers and result “is” positive
• At most significant bit of adder, check if CI != CO
• Can check with XOR gate
![Page 60: ECE/CS 250 Computer Architecture Fall 2021](https://reader030.vdocuments.us/reader030/viewer/2022012804/61bd25d861276e740b0fd932/html5/thumbnails/60.jpg)
65
Add/Subtract With Overflow Detection
Full AdderFull AdderFull AdderFull Adder
S0S1Sn- 2Sn- 1
Signed Overflow
b0b1 a0a1bn- 2an- 2bn- 1an- 1
Unsigned
Overflow
Add/Sub
Logisim example
basic_logic.circ : 4bit-addsub2
![Page 61: ECE/CS 250 Computer Architecture Fall 2021](https://reader030.vdocuments.us/reader030/viewer/2022012804/61bd25d861276e740b0fd932/html5/thumbnails/61.jpg)
66
Add/sub
Cin
Cout
Add/sub F
2
0
1
2
3a
bQ
A F Q
0 0 a + b
1 0 a - b
- 1 NOT b
- 2 a OR b
- 3 a AND b
ALU Slice
Logisim example
basic_logic.circ : alu-slice
![Page 62: ECE/CS 250 Computer Architecture Fall 2021](https://reader030.vdocuments.us/reader030/viewer/2022012804/61bd25d861276e740b0fd932/html5/thumbnails/62.jpg)
67
The ALU
ALU SliceALU SliceALU SliceALU Slice
ALU control
a0b0a1b1an-2bn-2an-1bn-1
Q0Q1Qn-2Qn-1
Overflow Is non-zero?
Logisim example
basic_logic.circ : alu
![Page 63: ECE/CS 250 Computer Architecture Fall 2021](https://reader030.vdocuments.us/reader030/viewer/2022012804/61bd25d861276e740b0fd932/html5/thumbnails/63.jpg)
68
Alternate ALU design
• Previous design did ALU stuff for each bit, then chained them.
• Can also do each word-size operation and mux the resulting words.
ALU SliceALU SliceALU SliceALU Slice
ALU control
a0
b0
a1
b1
an-2
bn-2
an-1
bn-1
Q0
Q1
Qn-2
Qn-1
Overflow Is non-zero?
16-bit
Add/sub
Cout
Add/sub F
20
1
2
3a
bQ
16
16
16
16-bit
16-bit
16-bit
![Page 64: ECE/CS 250 Computer Architecture Fall 2021](https://reader030.vdocuments.us/reader030/viewer/2022012804/61bd25d861276e740b0fd932/html5/thumbnails/64.jpg)
69
Abstraction: The ALU
• General structure
• Two operand inputs
• Control inputs
• We can buildcircuits for
• Multiplication
• Division
• They are more complex
Input A
Input B
Carry Out
ALU Operation
Result
Overflow?
Zero?
ALU
n
n
n
log2(num_of_operations_supported)
![Page 65: ECE/CS 250 Computer Architecture Fall 2021](https://reader030.vdocuments.us/reader030/viewer/2022012804/61bd25d861276e740b0fd932/html5/thumbnails/65.jpg)
70
Another Operations We Might Want: Shift
• Remember the << and >> operations?
• Shift left/shift right?
• How would we implement these?
• Suppose you have an 8-bit number
b7b6b5b4b3b2b1b0
• And you can shift it left by a 3-bit number
s2s1s0
• Option 1: Truth Table?
• 211 = 2048 rows? Yuck.
…but you can do it. Truth table gives this expression for output bit 0:( b0 & !b1 & !b2 & !b3 & !b4 & !b5 & !b6 & !b7 & !s0 & !s1 & !s2) | ( b0 & b1 & !b2 & !b3 & !b4 & !b5 & !b6 & !b7 & !s0 & !s1 & !s2) | ( b0 & !b1 & b2 & !b3 & !b4 & !b5 & !b6 & !b7 & !s0 & !s1 & !s2) | ( b0 & b1 & b2 & !b3 & !b4 & !b5 & !b6 & !b7 & !s0 & !s1 & !s2) | ( b0 & !b1 & !b2 & b3 & !b4 & !b5 & !b6 & !b7 & !s0 & !s1 & !s2) | ( b0 & b1 & !b2 & b3 & !b4 & !b5 & !b6 & !b7 & !s0 & !s1 & !s2) | ( b0 & !b1 & b2 & b3 & !b4 & !b5 & !b6 & !b7 & !s0 & !s1 & !s2) | ( b0 & b1 & b2 & b3 & !b4 & !b5 & !b6 & !b7 & !s0 & !s1 & !s2) | ( b0 & !b1 & !b2 & !b3 & b4 & !b5 & !b6 & !b7 & !s0 & !s1 & !s2) | ( b0 & b1 & !b2 & !b3 & b4 & !b5 & !b6 & !b7 & !s0 & !s1 & !s2) | ( b0 & !b1 & b2 & !b3 & b4 & !b5 & !b6 & !b7 & !s0 & !s1 & !s2) | ( b0 & b1 & b2 & !b3 & b4 & !b5 & !b6 & !b7 & !s0 & !s1 & !s2) | ( b0 & !b1 & !b2 & b3 & b4 & !b5 & !b6 & !b7 & !s0 & !s1 & !s2) | ( b0 & b1 & !b2 & b3 & b4 & !b5 & !b6 & !b7 & !s0 & !s1 & !s2) | ( b0 & !b1 & b2 & b3 & b4 & !b5 & !b6 & !b7 & !s0 & !s1 & !s2) | ( b0 & b1 & b2 & b3 & b4 & !b5 & !b6 & !b7 & !s0 & !s1 & !s2) | ( b0 & !b1 & !b2 & !b3 & !b4 & b5 & !b6 & !b7 & !s0 & !s1 & !s2) | ( b0 & b1 & !b2 & !b3 & !b4 & b5 & !b6 & !b7 & !s0 & !s1 & !s2) | ( b0 & !b1 & b2 & !b3 & !b4 & b5 & !b6 & !b7 & !s0 & !s1 & !s2) | ( b0 & b1 & b2 & !b3 & !b4 & b5 & !b6 & !b7 & !s0 & !s1 & !s2) | ( b0 & !b1 & !b2 & b3 & !b4 & b5 & !b6 & !b7 & !s0 & !s1 & !s2) | ( b0 & b1 & !b2 & b3 & !b4 & b5 & !b6 & !b7 & !s0 & !s1 & !s2) | ( b0 & !b1 & b2 & b3 & !b4 & b5 & !b6 & !b7 & !s0 & !s1 & !s2) | ( b0 & b1 & b2 & b3 & !b4 & b5 & !b6 & !b7 & !s0 & !s1 & !s2) | ( b0 & !b1 & !b2 & !b3 & b4 & b5 & !b6 & !b7 & !s0 & !s1 & !s2) | ( b0 & b1 & !b2 & !b3 & b4 & b5 & !b6 & !b7 & !s0 & !s1 & !s2) | ( b0 & !b1 & b2 & !b3 & b4 & b5 & !b6 & !b7 & !s0 & !s1 & !s2) | ( b0 & b1 & b2 & !b3 & b4 & b5 & !b6 & !b7 & !s0 & !s1 & !s2) | ( b0 & !b1 & !b2 & b3 & b4 & b5 & !b6 & !b7 & !s0 & !s1 & !s2) | ( b0 & b1 & !b2 & b3 & b4 & b5 & !b6 & !b7 & !s0 & !s1 & !s2) | ( b0 & !b1 & b2 & b3 & b4 & b5 & !b6 & !b7 & !s0 & !s1 & !s2) | ( b0 & b1 & b2 & b3 & b4 & b5 & !b6 & !b7 & !s0 & !s1 & !s2) | ( b0 & !b1 & !b2 & !b3 & !b4 & !b5 & b6 & !b7 & !s0 & !s1 & !s2) | ( b0 & b1 & !b2 & !b3 & !b4 & !b5 & b6 & !b7 & !s0 & !s1 & !s2) | ( b0 & !b1 & b2 & !b3 & !b4 & !b5 & b6 & !b7 & !s0 & !s1 & !s2) | ( b0 & b1 & b2 & !b3 & !b4 & !b5 & b6 & !b7 & !s0 & !s1 & !s2) | ( b0 & !b1 & !b2 & b3 & !b4 & !b5 & b6 & !b7 & !s0 & !s1 & !s2) | ( b0 & b1 & !b2 & b3 & !b4 & !b5 & b6 & !b7 & !s0 & !s1 & !s2) | ( b0 & !b1 & b2 & b3 & !b4 & !b5 & b6 & !b7 & !s0 & !s1 & !s2) | ( b0 & b1 & b2 & b3 & !b4 & !b5 & b6 & !b7 & !s0 & !s1 & !s2) | ( b0 & !b1 & !b2 & !b3 & b4 & !b5 & b6 & !b7 & !s0 & !s1 & !s2) | ( b0 & b1 & !b2 & !b3 & b4 & !b5 & b6 & !b7 & !s0 & !s1 & !s2) | ( b0 & !b1 & b2 & !b3 & b4 & !b5 & b6 & !b7 & !s0 & !s1 & !s2) | ( b0 & b1 & b2 & !b3 & b4 & !b5 & b6 & !b7 & !s0 & !s1 & !s2) | ( b0 & !b1 & !b2 & b3 & b4 & !b5 & b6 & !b7 & !s0 & !s1 & !s2) | ( b0 & b1 & !b2 & b3 & b4 & !b5 & b6 & !b7 & !s0 & !s1 & !s2) | ( b0 & !b1 & b2 & b3 & b4 & !b5 & b6 & !b7 & !s0 & !s1 & !s2) | ( b0 & b1 & b2 & b3 & b4 & !b5 & b6 & !b7 & !s0 & !s1 & !s2) | ( b0 & !b1 & !b2 & !b3 & !b4 & b5 & b6 & !b7 & !s0 & !s1 & !s2) | ( b0 & b1 & !b2 & !b3 & !b4 & b5 & b6 & !b7 & !s0 & !s1 & !s2) | ( b0 & !b1 & b2 & !b3 & !b4 & b5 & b6 & !b7 & !s0 & !s1 & !s2) | ( b0 & b1 & b2 & !b3 & !b4 & b5 & b6 & !b7 & !s0 & !s1 & !s2) | ( b0 & !b1 & !b2 & b3 & !b4 & b5 & b6 & !b7 & !s0 & !s1 & !s2) | ( b0 & b1 & !b2 & b3 & !b4 & b5 & b6 & !b7 & !s0 & !s1 & !s2) | ( b0 & !b1 & b2 & b3 & !b4 & b5 & b6 & !b7 & !s0 & !s1 & !s2) | ( b0 & b1 & b2 & b3 & !b4 & b5 & b6 & !b7 & !s0 & !s1 & !s2) | ( b0 & !b1 & !b2 & !b3 & b4 & b5 & b6 & !b7 & !s0 & !s1 & !s2) | ( b0 & b1 & !b2 & !b3 & b4 & b5 & b6 & !b7 & !s0 & !s1 & !s2) | ( b0 & !b1 & b2 & !b3 & b4 & b5 & b6 & !b7 & !s0 & !s1 & !s2) | ( b0 & b1 & b2 & !b3 & b4 & b5 & b6 & !b7 & !s0 & !s1 & !s2) | ( b0 & !b1 & !b2 & b3 & b4 & b5 & b6 & !b7 & !s0 & !s1 & !s2) | ( b0 & b1 & !b2 & b3 & b4 & b5 & b6 & !b7 & !s0 & !s1 & !s2) | ( b0 & !b1 & b2 & b3 & b4 & b5 & b6 & !b7 & !s0 & !s1 & !s2) | ( b0 & b1 & b2 & b3 & b4 & b5 & b6 & !b7 & !s0 & !s1 & !s2) | ( b0 & !b1 & !b2 & !b3 & !b4 & !b5 & !b6 & b7 & !s0 & !s1 & !s2) | ( b0 & b1 & !b2 & !b3 & !b4 & !b5 & !b6 & b7 & !s0 & !s1 & !s2) | ( b0 & !b1 & b2 & !b3 & !b4 & !b5 & !b6 & b7 & !s0 & !s1 & !s2) | ( b0 & b1 & b2 & !b3 & !b4 & !b5 & !b6 & b7 & !s0 & !s1 & !s2) | ( b0 & !b1 & !b2 & b3 & !b4 & !b5 & !b6 & b7 & !s0 & !s1 & !s2) | ( b0 & b1 & !b2 & b3 & !b4 & !b5 & !b6 & b7 & !s0 & !s1 & !s2) | ( b0 & !b1 & b2 & b3 & !b4 & !b5 & !b6 & b7 & !s0 & !s1 & !s2) | ( b0 & b1 & b2 & b3 & !b4 & !b5 & !b6 & b7 & !s0 & !s1 & !s2) | ( b0 & !b1 & !b2 & !b3 & b4 & !b5 & !b6 & b7 & !s0 & !s1 & !s2) | ( b0 & b1 & !b2 & !b3 & b4 & !b5 & !b6 & b7 & !s0 & !s1 & !s2) | ( b0 & !b1 & b2 & !b3 & b4 & !b5 & !b6 & b7 & !s0 & !s1 & !s2) | ( b0 & b1 & b2 & !b3 & b4 & !b5 & !b6 & b7 & !s0 & !s1 & !s2) | ( b0 & !b1 & !b2 & b3 & b4 & !b5 & !b6 & b7 & !s0 & !s1 & !s2) | ( b0 & b1 & !b2 & b3 & b4 & !b5 & !b6 & b7 & !s0 & !s1 & !s2) | ( b0 & !b1 & b2 & b3 & b4 & !b5 & !b6 & b7 & !s0 & !s1 & !s2) | ( b0 & b1 & b2 & b3 & b4 & !b5 & !b6 & b7 & !s0 & !s1 & !s2) | ( b0 & !b1 & !b2 & !b3 & !b4 & b5 & !b6 & b7 & !s0 & !s1 & !s2) | ( b0 & b1 & !b2 & !b3 & !b4 & b5 & !b6 & b7 & !s0 & !s1 & !s2) | ( b0 & !b1 & b2 & !b3 & !b4 & b5 & !b6 & b7 & !s0 & !s1 & !s2) | ( b0 & b1 & b2 & !b3 & !b4 & b5 & !b6 & b7 & !s0 & !s1 & !s2) | ( b0 & !b1 & !b2 & b3 & !b4 & b5 & !b6 & b7 & !s0 & !s1 & !s2) | ( b0 & b1 & !b2 & b3 & !b4 & b5 & !b6 & b7 & !s0 & !s1 & !s2) | ( b0 & !b1 & b2 & b3 & !b4 & b5 & !b6 & b7 & !s0 & !s1 & !s2) | ( b0 & b1 & b2 & b3 & !b4 & b5 & !b6 & b7 & !s0 & !s1 & !s2) | ( b0 & !b1 & !b2 & !b3 & b4 & b5 & !b6 & b7 & !s0 & !s1 & !s2) | ( b0 & b1 & !b2 & !b3 & b4 & b5 & !b6 & b7 & !s0 & !s1 & !s2) | ( b0 & !b1 & b2 & !b3 & b4 & b5 & !b6 & b7 & !s0 & !s1 & !s2) | ( b0 & b1 & b2 & !b3 & b4 & b5 & !b6 & b7 & !s0 & !s1 & !s2) | ( b0 & !b1 & !b2 & b3 & b4 & b5 & !b6 & b7 & !s0 & !s1 & !s2) | ( b0 & b1 & !b2 & b3 & b4 & b5 & !b6 & b7 & !s0 & !s1 & !s2) | ( b0 & !b1 & b2 & b3 & b4 & b5 & !b6 & b7 & !s0 & !s1 & !s2) | ( b0 & b1 & b2 & b3 & b4 & b5 & !b6 & b7 & !s0 & !s1 & !s2) | ( b0 & !b1 & !b2 & !b3 & !b4 & !b5 & b6 & b7 & !s0 & !s1 & !s2) | ( b0 & b1 & !b2 & !b3 & !b4 & !b5 & b6 & b7 & !s0 & !s1 & !s2) | ( b0 & !b1 & b2 & !b3 & !b4 & !b5 & b6 & b7 & !s0 & !s1 & !s2) | ( b0 & b1 & b2 & !b3 & !b4 & !b5 & b6 & b7 & !s0 & !s1 & !s2) | ( b0 & !b1 & !b2 & b3 & !b4 & !b5 & b6 & b7 & !s0 & !s1 & !s2) | ( b0 & b1 & !b2 & b3 & !b4 & !b5 & b6 & b7 & !s0 & !s1 & !s2) | ( b0 & !b1 & b2 & b3 & !b4 & !b5 & b6 & b7 & !s0 & !s1 & !s2) | ( b0 & b1 & b2 & b3 & !b4 & !b5 & b6 & b7 & !s0 & !s1 & !s2) | ( b0 & !b1 & !b2 & !b3 & b4 & !b5 & b6 & b7 & !s0 & !s1 & !s2) | ( b0 & b1 & !b2 & !b3 & b4 & !b5 & b6 & b7 & !s0 & !s1 & !s2) | ( b0 & !b1 & b2 & !b3 & b4 & !b5 & b6 & b7 & !s0 & !s1 & !s2) | ( b0 & b1 & b2 & !b3 & b4 & !b5 & b6 & b7 & !s0 & !s1 & !s2) | ( b0 & !b1 & !b2 & b3 & b4 & !b5 & b6 & b7 & !s0 & !s1 & !s2) | ( b0 & b1 & !b2 & b3 & b4 & !b5 & b6 & b7 & !s0 & !s1 & !s2) | ( b0 & !b1 & b2 & b3 & b4 & !b5 & b6 & b7 & !s0 & !s1 & !s2) | ( b0 & b1 & b2 & b3 & b4 & !b5 & b6 & b7 & !s0 & !s1 & !s2) | ( b0 & !b1 & !b2 & !b3 & !b4 & b5 & b6 & b7 & !s0 & !s1 & !s2) | ( b0 & b1 & !b2 & !b3 & !b4 & b5 & b6 & b7 & !s0 & !s1 & !s2) | ( b0 & !b1 & b2 & !b3 & !b4 & b5 & b6 & b7 & !s0 & !s1 & !s2) | ( b0 & b1 & b2 & !b3 & !b4 & b5 & b6 & b7 & !s0 & !s1 & !s2) | ( b0 & !b1 & !b2 & b3 & !b4 & b5 & b6 & b7 & !s0 & !s1 & !s2) | ( b0 & b1 & !b2 & b3 & !b4 & b5 & b6 & b7 & !s0 & !s1 & !s2) | ( b0 & !b1 & b2 & b3 & !b4 & b5 & b6 & b7 & !s0 & !s1 & !s2) | ( b0 & b1 & b2 & b3 & !b4 & b5 & b6 & b7 & !s0 & !s1 & !s2) | ( b0 & !b1 & !b2 & !b3 & b4 & b5 & b6 & b7 & !s0 & !s1 & !s2) | ( b0 & b1 & !b2 & !b3 & b4 & b5 & b6 & b7 & !s0 & !s1 & !s2) | ( b0 & !b1 & b2 & !b3 & b4 & b5 & b6 & b7 & !s0 & !s1 & !s2) | ( b0 & b1 & b2 & !b3 & b4 & b5 & b6 & b7 & !s0 & !s1 & !s2) | ( b0 & !b1 & !b2 & b3 & b4 & b5 & b6 & b7 & !s0 & !s1 & !s2) | ( b0 & b1 & !b2 & b3 & b4 & b5 & b6 & b7 & !s0 & !s1 & !s2) | ( b0 & !b1 & b2 & b3 & b4 & b5 & b6 & b7 & !s0 & !s1 & !s2) | ( b0 & b1 & b2 & b3 & b4 & b5 & b6 & b7 & !s0 & !s1 & !s2)
![Page 66: ECE/CS 250 Computer Architecture Fall 2021](https://reader030.vdocuments.us/reader030/viewer/2022012804/61bd25d861276e740b0fd932/html5/thumbnails/66.jpg)
71
Building a bit shifter
• Simpler problem: A shift-by-one circuit, all controlled by the same 1 bit input (s0)
b0
b1
b2
b3
b4
b7
b6
b5
Literal
0out0
out1
out2
out3
out4
out5
out6
out7s0
s0
s0
s0
s0
s0
s0
s0
![Page 67: ECE/CS 250 Computer Architecture Fall 2021](https://reader030.vdocuments.us/reader030/viewer/2022012804/61bd25d861276e740b0fd932/html5/thumbnails/67.jpg)
72
Building a bit shifter
• Simpler problem: A shift-by-two circuit, all controlled by the same 1 bit input (s1)
b0
b1
b2
b3
b4
b7
b6
b5
Literal
0out0
out1
out2
out3
out4
out5
out6
out7s1
s1
s1
s1
s1
s1
s1
s1
![Page 68: ECE/CS 250 Computer Architecture Fall 2021](https://reader030.vdocuments.us/reader030/viewer/2022012804/61bd25d861276e740b0fd932/html5/thumbnails/68.jpg)
73
Building a bit shifter
• Simpler problem: A shift-by-four circuit, all controlled by the same 1 bit input (s2)
b0
b1
b2
b3
b4
b7
b6
b5
Literal
0 out0
out1
out2
out3
out4
out5
out6
out7s2
s2
s2
s2
s2
s2
s2
s2
![Page 69: ECE/CS 250 Computer Architecture Fall 2021](https://reader030.vdocuments.us/reader030/viewer/2022012804/61bd25d861276e740b0fd932/html5/thumbnails/69.jpg)
74
Now shifted by 3-bit number
• Full problem: stick them all together, controlled by 3-bit value s2:0
Literal
0out0
out1
out2
out3
out4
out5
out6
out7s2
s2
s2
s2
s2
s2
s2
s2
s1
s1
s1
s1
s1
s1
s1
s1
s0
s0
s0
s0
s0
s0
s0
s0
b0
b1
b2
b3
b4
b7
b6
b5
![Page 70: ECE/CS 250 Computer Architecture Fall 2021](https://reader030.vdocuments.us/reader030/viewer/2022012804/61bd25d861276e740b0fd932/html5/thumbnails/70.jpg)
75
Now shifted by 3-bit number
• Example: shift by 000
Literal
0out0
out1
out2
out3
out4
out5
out6
out7s2
s2
s2
s2
s2
s2
s2
s2
s1
s1
s1
s1
s1
s1
s1
s1
s0
s0
s0
s0
s0
s0
s0
s0
b0
b1
b2
b3
b4
b7
b6
b5
![Page 71: ECE/CS 250 Computer Architecture Fall 2021](https://reader030.vdocuments.us/reader030/viewer/2022012804/61bd25d861276e740b0fd932/html5/thumbnails/71.jpg)
76
Now shifted by 3-bit number
• Example: shift by 011
Literal
0out0
out1
out2
out3
out4
out5
out6
out7s2
s2
s2
s2
s2
s2
s2
s2
s1
s1
s1
s1
s1
s1
s1
s1
s0
s0
s0
s0
s0
s0
s0
s0
b0
b1
b2
b3
b4
b7
b6
b5
![Page 72: ECE/CS 250 Computer Architecture Fall 2021](https://reader030.vdocuments.us/reader030/viewer/2022012804/61bd25d861276e740b0fd932/html5/thumbnails/72.jpg)
77
Summary
• Boolean Algebra & functions
• Logic gates (AND, OR, NOT, etc)
• Multiplexors
• Adder
• Arithmetic Logic Unit (ALU)
• Bit shifting