basics of logic design: boolean algebra, logic gates ...• we can use transistors to build logic...
TRANSCRIPT
![Page 1: Basics of Logic Design: Boolean Algebra, Logic Gates ...• 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](https://reader036.vdocuments.us/reader036/viewer/2022062509/60f9db28f005e220de347ca8/html5/thumbnails/1.jpg)
ECE/CS 250: Computer Architecture
Basics of Logic Design: Boolean Algebra, Logic Gates
Benjamin Lee
Slides based on those from Alvin Lebeck, Daniel Sorin, Andrew Hilton, Amir Roth,
Gershon Kedem
![Page 2: Basics of Logic Design: Boolean Algebra, Logic Gates ...• 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](https://reader036.vdocuments.us/reader036/viewer/2022062509/60f9db28f005e220de347ca8/html5/thumbnails/2.jpg)
2 © Alvin R. Lebeck from Hilton and Sorin
Admin
• Resource: Pragmatic Logic by William Eccles
− In Sakai Resources and linked off web page. − Skim for what you need, way too much in there
• 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
• Download Logisim before Friday’s recitation
− http://ozark.hendrix.edu/~burch/logisim/download.html
CS/ECE 250
![Page 3: Basics of Logic Design: Boolean Algebra, Logic Gates ...• 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](https://reader036.vdocuments.us/reader036/viewer/2022062509/60f9db28f005e220de347ca8/html5/thumbnails/3.jpg)
3 © Alvin R. Lebeck from Hilton and Sorin CS/ECE 250
What We’ve Done, Where We’re Going
I/O system CPU
Compiler
Operating System
Application
Digital Design Circuit Design
Instruction Set Architecture, Memory, I/O
Firmware
Memory
Software
Hardware
Interface Between HW and SW
Top Down
(Almost) Bottom UP to CPU
![Page 4: Basics of Logic Design: Boolean Algebra, Logic Gates ...• 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](https://reader036.vdocuments.us/reader036/viewer/2022062509/60f9db28f005e220de347ca8/html5/thumbnails/4.jpg)
4 © Alvin R. Lebeck from Hilton and Sorin CS/ECE 250
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
• 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: Basics of Logic Design: Boolean Algebra, Logic Gates ...• 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](https://reader036.vdocuments.us/reader036/viewer/2022062509/60f9db28f005e220de347ca8/html5/thumbnails/5.jpg)
5 © Alvin R. Lebeck from Hilton and Sorin CS/ECE 250
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: Basics of Logic Design: Boolean Algebra, Logic Gates ...• 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](https://reader036.vdocuments.us/reader036/viewer/2022062509/60f9db28f005e220de347ca8/html5/thumbnails/6.jpg)
6 © Alvin R. Lebeck from Hilton and Sorin
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…
CS/ECE 250
![Page 7: Basics of Logic Design: Boolean Algebra, Logic Gates ...• 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](https://reader036.vdocuments.us/reader036/viewer/2022062509/60f9db28f005e220de347ca8/html5/thumbnails/7.jpg)
7 © Alvin R. Lebeck from Hilton and Sorin
You are here:
• Use of abstraction (key to design of any large system) − Put a few (2-8) transistors into a logic gate − Combine gates into logical functions (add, select,….) − Combine adders, muxes, 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…
CS/ECE 250
![Page 8: Basics of Logic Design: Boolean Algebra, Logic Gates ...• 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](https://reader036.vdocuments.us/reader036/viewer/2022062509/60f9db28f005e220de347ca8/html5/thumbnails/8.jpg)
8 © Alvin R. Lebeck from Hilton and Sorin
Boolean Algebra
• First step to logic: Boolean Algebra − Formal apporoach for manipulating of True / False (1/0) − After all: everything is just 1s and 0s
• Boolean Functions: − Given inputs (variables): A, B, C, P, Q… − Compute outputs using logic operators, such as:
• NOT: !A (= ~A = A = A’) • AND: A&B (= A⋅B = A*B = AB = A∧B) = A&&B in C/Java • OR: A | B (= A+B = A ∨ B) = A || B in C/Java • XOR: A ^ B (= A ⊕ B) • NAND, NOR, XNOR, Etc.
CS/ECE 250
![Page 9: Basics of Logic Design: Boolean Algebra, Logic Gates ...• 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](https://reader036.vdocuments.us/reader036/viewer/2022062509/60f9db28f005e220de347ca8/html5/thumbnails/9.jpg)
9 © Alvin R. Lebeck from Hilton and Sorin CS/ECE 250
a NOT(a) 0 1 1 0
Truth Tables
• Can represent as Truth Table: shows outputs for all inputs
![Page 10: Basics of Logic Design: Boolean Algebra, Logic Gates ...• 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](https://reader036.vdocuments.us/reader036/viewer/2022062509/60f9db28f005e220de347ca8/html5/thumbnails/10.jpg)
10 © Alvin R. Lebeck from Hilton and Sorin CS/ECE 250
a NOT(a) 0 1 1 0
a b AND(a,b) 0 0 0 0 1 0 1 0 0 1 1 1
Truth Tables
• Can represent as truth table: shows outputs for all inputs
![Page 11: Basics of Logic Design: Boolean Algebra, Logic Gates ...• 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](https://reader036.vdocuments.us/reader036/viewer/2022062509/60f9db28f005e220de347ca8/html5/thumbnails/11.jpg)
11 © Alvin R. Lebeck from Hilton and Sorin CS/ECE 250
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
Truth Tables
• Can represent as truth table: shows outputs for all inputs
![Page 12: Basics of Logic Design: Boolean Algebra, Logic Gates ...• 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](https://reader036.vdocuments.us/reader036/viewer/2022062509/60f9db28f005e220de347ca8/html5/thumbnails/12.jpg)
12 © Alvin R. Lebeck from Hilton and Sorin CS/ECE 250
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 13: Basics of Logic Design: Boolean Algebra, Logic Gates ...• 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](https://reader036.vdocuments.us/reader036/viewer/2022062509/60f9db28f005e220de347ca8/html5/thumbnails/13.jpg)
13 © Alvin R. Lebeck from Hilton and Sorin CS/ECE 250
a b
AND(a,b) a b
OR(a,b)
XOR(a,b) a b
NAND(a,b) a b
a b
NOR(a,b) XNOR(a,b) a b
a NOT(a)
Boolean Gates (More Later)
• Gates are electronic devices that implement simple Boolean functions (building blocks of hardware)
Examples
![Page 14: Basics of Logic Design: Boolean Algebra, Logic Gates ...• 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](https://reader036.vdocuments.us/reader036/viewer/2022062509/60f9db28f005e220de347ca8/html5/thumbnails/14.jpg)
14 © Alvin R. Lebeck from Hilton and Sorin CS/ECE 250
a b c f1f2 0 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 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 15: Basics of Logic Design: Boolean Algebra, Logic Gates ...• 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](https://reader036.vdocuments.us/reader036/viewer/2022062509/60f9db28f005e220de347ca8/html5/thumbnails/15.jpg)
15 © Alvin R. Lebeck from Hilton and Sorin
Let’s Write a Truth Table for a Function…
• Example: (A & B) | !C
Start with Empty TT Column Per Input Column Per Output
CS/ECE 250
A B C Output
![Page 16: Basics of Logic Design: Boolean Algebra, Logic Gates ...• 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](https://reader036.vdocuments.us/reader036/viewer/2022062509/60f9db28f005e220de347ca8/html5/thumbnails/16.jpg)
16 © Alvin R. Lebeck from Hilton and Sorin
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
CS/ECE 250
A B C Output 0 0 0
![Page 17: Basics of Logic Design: Boolean Algebra, Logic Gates ...• 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](https://reader036.vdocuments.us/reader036/viewer/2022062509/60f9db28f005e220de347ca8/html5/thumbnails/17.jpg)
17 © Alvin R. Lebeck from Hilton and Sorin
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
CS/ECE 250
A B C Output 0 0 0 0 0 1
![Page 18: Basics of Logic Design: Boolean Algebra, Logic Gates ...• 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](https://reader036.vdocuments.us/reader036/viewer/2022062509/60f9db28f005e220de347ca8/html5/thumbnails/18.jpg)
18 © Alvin R. Lebeck from Hilton and Sorin
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 Row per set of input values Counting in Binary
CS/ECE 250
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 19: Basics of Logic Design: Boolean Algebra, Logic Gates ...• 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](https://reader036.vdocuments.us/reader036/viewer/2022062509/60f9db28f005e220de347ca8/html5/thumbnails/19.jpg)
19 © Alvin R. Lebeck from Hilton and Sorin
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 Row per set of input values Counting in Binary
Compute Output for reach row (0 & 0) | !0 = 0 | 1 = 1
CS/ECE 250
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 20: Basics of Logic Design: Boolean Algebra, Logic Gates ...• 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](https://reader036.vdocuments.us/reader036/viewer/2022062509/60f9db28f005e220de347ca8/html5/thumbnails/20.jpg)
20 © Alvin R. Lebeck from Hilton and Sorin
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 Row per set of input values Counting in Binary
Compute Output for each row (0 & 0) | !1 = 0 | 0 = 0
CS/ECE 250
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 21: Basics of Logic Design: Boolean Algebra, Logic Gates ...• 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](https://reader036.vdocuments.us/reader036/viewer/2022062509/60f9db28f005e220de347ca8/html5/thumbnails/21.jpg)
21 © Alvin R. Lebeck from Hilton and Sorin
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 Row per set of input values Counting in Binary
Compute Output for each row (0 & 1) | !0 = 0 | 1 = 1
CS/ECE 250
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 22: Basics of Logic Design: Boolean Algebra, Logic Gates ...• 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](https://reader036.vdocuments.us/reader036/viewer/2022062509/60f9db28f005e220de347ca8/html5/thumbnails/22.jpg)
22 © Alvin R. Lebeck from Hilton and Sorin
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 Row per set of input values Counting in Binary
Compute Output for each row
CS/ECE 250
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
![Page 23: Basics of Logic Design: Boolean Algebra, Logic Gates ...• 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](https://reader036.vdocuments.us/reader036/viewer/2022062509/60f9db28f005e220de347ca8/html5/thumbnails/23.jpg)
23 © Alvin R. Lebeck from Hilton and Sorin
You try one…
• Try one yourself: (!A | B) & !C
CS/ECE 250
![Page 24: Basics of Logic Design: Boolean Algebra, Logic Gates ...• 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](https://reader036.vdocuments.us/reader036/viewer/2022062509/60f9db28f005e220de347ca8/html5/thumbnails/24.jpg)
24 © Alvin R. Lebeck from Hilton and Sorin
You try one…
• Try one yourself: (!A | B) & !C
Answer:
CS/ECE 250
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 0 1 1 0 1 1 1 1 0
![Page 25: Basics of Logic Design: Boolean Algebra, Logic Gates ...• 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](https://reader036.vdocuments.us/reader036/viewer/2022062509/60f9db28f005e220de347ca8/html5/thumbnails/25.jpg)
25 © Alvin R. Lebeck from Hilton and Sorin
Suppose I turn it around…
• Given a Truth Table, find the formula?
Hmmm..
CS/ECE 250
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: Basics of Logic Design: Boolean Algebra, Logic Gates ...• 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](https://reader036.vdocuments.us/reader036/viewer/2022062509/60f9db28f005e220de347ca8/html5/thumbnails/26.jpg)
26 © Alvin R. Lebeck from Hilton and Sorin
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)
CS/ECE 250
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: Basics of Logic Design: Boolean Algebra, Logic Gates ...• 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](https://reader036.vdocuments.us/reader036/viewer/2022062509/60f9db28f005e220de347ca8/html5/thumbnails/27.jpg)
27 © Alvin R. Lebeck from Hilton and Sorin
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)
CS/ECE 250
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: Basics of Logic Design: Boolean Algebra, Logic Gates ...• 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](https://reader036.vdocuments.us/reader036/viewer/2022062509/60f9db28f005e220de347ca8/html5/thumbnails/28.jpg)
28 © Alvin R. Lebeck from Hilton and Sorin
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)
CS/ECE 250
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 29: Basics of Logic Design: Boolean Algebra, Logic Gates ...• 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](https://reader036.vdocuments.us/reader036/viewer/2022062509/60f9db28f005e220de347ca8/html5/thumbnails/29.jpg)
29 © Alvin R. Lebeck from Hilton and Sorin
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)
CS/ECE 250
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 30: Basics of Logic Design: Boolean Algebra, Logic Gates ...• 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](https://reader036.vdocuments.us/reader036/viewer/2022062509/60f9db28f005e220de347ca8/html5/thumbnails/30.jpg)
30 © Alvin R. Lebeck from Hilton and Sorin
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 ?
CS/ECE 250
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 31: Basics of Logic Design: Boolean Algebra, Logic Gates ...• 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](https://reader036.vdocuments.us/reader036/viewer/2022062509/60f9db28f005e220de347ca8/html5/thumbnails/31.jpg)
31 © Alvin R. Lebeck from Hilton and Sorin
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)
CS/ECE 250
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 32: Basics of Logic Design: Boolean Algebra, Logic Gates ...• 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](https://reader036.vdocuments.us/reader036/viewer/2022062509/60f9db28f005e220de347ca8/html5/thumbnails/32.jpg)
32 © Alvin R. Lebeck from Hilton and Sorin
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
CS/ECE 250
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 33: Basics of Logic Design: Boolean Algebra, Logic Gates ...• 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](https://reader036.vdocuments.us/reader036/viewer/2022062509/60f9db28f005e220de347ca8/html5/thumbnails/33.jpg)
33 © Alvin R. Lebeck from Hilton and Sorin
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)
CS/ECE 250
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 34: Basics of Logic Design: Boolean Algebra, Logic Gates ...• 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](https://reader036.vdocuments.us/reader036/viewer/2022062509/60f9db28f005e220de347ca8/html5/thumbnails/34.jpg)
34 © Alvin R. Lebeck from Hilton and Sorin
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?
CS/ECE 250
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 35: Basics of Logic Design: Boolean Algebra, Logic Gates ...• 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](https://reader036.vdocuments.us/reader036/viewer/2022062509/60f9db28f005e220de347ca8/html5/thumbnails/35.jpg)
35 © Alvin R. Lebeck from Hilton and Sorin
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) This has a lot in common: !A & (something)
CS/ECE 250
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 36: Basics of Logic Design: Boolean Algebra, Logic Gates ...• 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](https://reader036.vdocuments.us/reader036/viewer/2022062509/60f9db28f005e220de347ca8/html5/thumbnails/36.jpg)
36 © Alvin R. Lebeck from Hilton and Sorin
Suppose I turn it around…
• This approach: “sum of products” − Works every time − Result is right… − But really ugly
(!A & !(B & C)) | (A & B)
CS/ECE 250
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 37: Basics of Logic Design: Boolean Algebra, Logic Gates ...• 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](https://reader036.vdocuments.us/reader036/viewer/2022062509/60f9db28f005e220de347ca8/html5/thumbnails/37.jpg)
37 © Alvin R. Lebeck from Hilton and Sorin
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
CS/ECE 250
![Page 38: Basics of Logic Design: Boolean Algebra, Logic Gates ...• 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](https://reader036.vdocuments.us/reader036/viewer/2022062509/60f9db28f005e220de347ca8/html5/thumbnails/38.jpg)
38 © Alvin R. Lebeck from Hilton and Sorin CS/ECE 250
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 39: Basics of Logic Design: Boolean Algebra, Logic Gates ...• 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](https://reader036.vdocuments.us/reader036/viewer/2022062509/60f9db28f005e220de347ca8/html5/thumbnails/39.jpg)
39 © Alvin R. Lebeck from Hilton and Sorin
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
CS/ECE 250
![Page 40: Basics of Logic Design: Boolean Algebra, Logic Gates ...• 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](https://reader036.vdocuments.us/reader036/viewer/2022062509/60f9db28f005e220de347ca8/html5/thumbnails/40.jpg)
40 © Alvin R. Lebeck from Hilton and Sorin
Suppose I turn it around…
• One more simplification on early example: (!A & !(B & C)) | (A & B) = (!A & (!B | !C)) | (A & B)
CS/ECE 250
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 41: Basics of Logic Design: Boolean Algebra, Logic Gates ...• 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](https://reader036.vdocuments.us/reader036/viewer/2022062509/60f9db28f005e220de347ca8/html5/thumbnails/41.jpg)
41 © Alvin R. Lebeck from Hilton and Sorin
Another Simplification Example
! (!A | !(A & (B | C)))
CS/ECE 250
![Page 42: Basics of Logic Design: Boolean Algebra, Logic Gates ...• 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](https://reader036.vdocuments.us/reader036/viewer/2022062509/60f9db28f005e220de347ca8/html5/thumbnails/42.jpg)
42 © Alvin R. Lebeck from Hilton and Sorin
Simplification Example:
! (!A | !(A & (B | C))) DeMorgan’s
!!A & !! (A & (B | C))
CS/ECE 250
![Page 43: Basics of Logic Design: Boolean Algebra, Logic Gates ...• 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](https://reader036.vdocuments.us/reader036/viewer/2022062509/60f9db28f005e220de347ca8/html5/thumbnails/43.jpg)
43 © Alvin R. Lebeck from Hilton and Sorin
Simplification Example:
! (!A | !(A & (B | C))) DeMorgan’s
!!A & !! (A & (B | C)) Double Negation Elimination
A & (A & (B | C))
CS/ECE 250
![Page 44: Basics of Logic Design: Boolean Algebra, Logic Gates ...• 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](https://reader036.vdocuments.us/reader036/viewer/2022062509/60f9db28f005e220de347ca8/html5/thumbnails/44.jpg)
44 © Alvin R. Lebeck from Hilton and Sorin
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)
CS/ECE 250
![Page 45: Basics of Logic Design: Boolean Algebra, Logic Gates ...• 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](https://reader036.vdocuments.us/reader036/viewer/2022062509/60f9db28f005e220de347ca8/html5/thumbnails/45.jpg)
45 © Alvin R. Lebeck from Hilton and Sorin
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)
CS/ECE 250
![Page 46: Basics of Logic Design: Boolean Algebra, Logic Gates ...• 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](https://reader036.vdocuments.us/reader036/viewer/2022062509/60f9db28f005e220de347ca8/html5/thumbnails/46.jpg)
46 © Alvin R. Lebeck from Hilton and Sorin
You try this:
Come up with a formula for this Truth Table Simplify as much as possible
CS/ECE 250
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
![Page 47: Basics of Logic Design: Boolean Algebra, Logic Gates ...• 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](https://reader036.vdocuments.us/reader036/viewer/2022062509/60f9db28f005e220de347ca8/html5/thumbnails/47.jpg)
47 © Alvin R. Lebeck from Hilton and Sorin
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)
CS/ECE 250
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
![Page 48: Basics of Logic Design: Boolean Algebra, Logic Gates ...• 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](https://reader036.vdocuments.us/reader036/viewer/2022062509/60f9db28f005e220de347ca8/html5/thumbnails/48.jpg)
48 © Alvin R. Lebeck from Hilton and Sorin
You try this:
Simplify first two terms: (!A & !B & !C) | (!A & B & !C)
CS/ECE 250
![Page 49: Basics of Logic Design: Boolean Algebra, Logic Gates ...• 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](https://reader036.vdocuments.us/reader036/viewer/2022062509/60f9db28f005e220de347ca8/html5/thumbnails/49.jpg)
49 © Alvin R. Lebeck from Hilton and Sorin
You try this:
Simplify: (!A & !B & !C) | (!A & B & !C) Regroup (associative/commutative): ((!A & !C) & !B) | ((!A & !C) & B)
CS/ECE 250
![Page 50: Basics of Logic Design: Boolean Algebra, Logic Gates ...• 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](https://reader036.vdocuments.us/reader036/viewer/2022062509/60f9db28f005e220de347ca8/html5/thumbnails/50.jpg)
50 © Alvin R. Lebeck from Hilton and Sorin
You try this:
Simplify: (!A & !B & !C) | (!A & B & !C) Regroup (associative/commutative): ((!A & !C) & !B) | ((!A & !C) & B) Un-distribute (pull out common factor): (!A & !C) & (!B | B)
CS/ECE 250
![Page 51: Basics of Logic Design: Boolean Algebra, Logic Gates ...• 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](https://reader036.vdocuments.us/reader036/viewer/2022062509/60f9db28f005e220de347ca8/html5/thumbnails/51.jpg)
51 © Alvin R. Lebeck from Hilton and Sorin
You try this:
Simplify: (!A & !B & !C) | (!A & B & !C) Regroup (associative/commutative): ((!A & !C) & !B) | ((!A & !C) & B) Un-distribute: (!A & !C) & (!B | B) OR identities: (!A & !C) & true = (!A & !C)
CS/ECE 250
![Page 52: Basics of Logic Design: Boolean Algebra, Logic Gates ...• 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](https://reader036.vdocuments.us/reader036/viewer/2022062509/60f9db28f005e220de347ca8/html5/thumbnails/52.jpg)
52 © Alvin R. Lebeck from Hilton and Sorin
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)
CS/ECE 250
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
![Page 53: Basics of Logic Design: Boolean Algebra, Logic Gates ...• 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](https://reader036.vdocuments.us/reader036/viewer/2022062509/60f9db28f005e220de347ca8/html5/thumbnails/53.jpg)
53 © Alvin R. Lebeck from Hilton and Sorin
You try this:
Come up with a formula for this Truth Table Simplify as much as possible Sum of Products:
(!A & !C)| (A & C)
CS/ECE 250
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
![Page 54: Basics of Logic Design: Boolean Algebra, Logic Gates ...• 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](https://reader036.vdocuments.us/reader036/viewer/2022062509/60f9db28f005e220de347ca8/html5/thumbnails/54.jpg)
54 © Alvin R. Lebeck from Hilton and Sorin CS/ECE 250
Applying the Theory
• Lots of good theory • Can reason about complex Boolean expressions
− Can design software to minimize • But why is this useful?
![Page 55: Basics of Logic Design: Boolean Algebra, Logic Gates ...• 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](https://reader036.vdocuments.us/reader036/viewer/2022062509/60f9db28f005e220de347ca8/html5/thumbnails/55.jpg)
55 © Alvin R. Lebeck from Hilton and Sorin CS/ECE 250
a b
AND(a,b) a b
OR(a,b)
XOR(a,b) a b
NAND(a,b) a b
a b
NOR(a,b) XNOR(a,b) a b
a NOT(a)
Boolean Gates
• Gates are electronic devices that implement simple Boolean functions (building blocks of hardware)
Examples
![Page 56: Basics of Logic Design: Boolean Algebra, Logic Gates ...• 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](https://reader036.vdocuments.us/reader036/viewer/2022062509/60f9db28f005e220de347ca8/html5/thumbnails/56.jpg)
56 © Alvin R. Lebeck from Hilton and Sorin
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
CS/ECE 250
a a
![Page 57: Basics of Logic Design: Boolean Algebra, Logic Gates ...• 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](https://reader036.vdocuments.us/reader036/viewer/2022062509/60f9db28f005e220de347ca8/html5/thumbnails/57.jpg)
57 © Alvin R. Lebeck from Hilton and Sorin
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
CS/ECE 250
a a
a NOT(a)
Circle = NOT
![Page 58: Basics of Logic Design: Boolean Algebra, Logic Gates ...• 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](https://reader036.vdocuments.us/reader036/viewer/2022062509/60f9db28f005e220de347ca8/html5/thumbnails/58.jpg)
58 © Alvin R. Lebeck from Hilton and Sorin
Brief Interlude: Building An Inverter
CS/ECE 250
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 59: Basics of Logic Design: Boolean Algebra, Logic Gates ...• 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](https://reader036.vdocuments.us/reader036/viewer/2022062509/60f9db28f005e220de347ca8/html5/thumbnails/59.jpg)
59 © Alvin R. Lebeck from Hilton and Sorin
Guide to Remembering Your Gates
• AND Gates have a straight edge, like an A (in AND)
OR Gates have a curved edge, like an O (in OR)
CS/ECE 250
a b
AND(a,b)
Straight like an A
a b
OR(a,b)
Curved, like an O
![Page 60: Basics of Logic Design: Boolean Algebra, Logic Gates ...• 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](https://reader036.vdocuments.us/reader036/viewer/2022062509/60f9db28f005e220de347ca8/html5/thumbnails/60.jpg)
60 © Alvin R. Lebeck from Hilton and Sorin
Guide to Remembering Your Gates
• If we stick a circle on them…
• We get NAND (NOT-AND) and NOR (NOT-OR) − NAND(a,b) = NOT(AND(a,b))
CS/ECE 250
a b
AND(a,b)
a b
OR(a,b)
NAND(a,b) a b
a b
NOR(a,b)
Circle = NOT
![Page 61: Basics of Logic Design: Boolean Algebra, Logic Gates ...• 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](https://reader036.vdocuments.us/reader036/viewer/2022062509/60f9db28f005e220de347ca8/html5/thumbnails/61.jpg)
61 © Alvin R. Lebeck from Hilton and Sorin
Guide to Remembering Your Gates
• XOR looks like OR (curved line) − But has two lines (like an X does)
• Can put a dot for XNOR − XNOR is 1-bit “equals” by the way
CS/ECE 250
XOR(a,b) a b
XNOR(a,b) a b
![Page 62: Basics of Logic Design: Boolean Algebra, Logic Gates ...• 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](https://reader036.vdocuments.us/reader036/viewer/2022062509/60f9db28f005e220de347ca8/html5/thumbnails/62.jpg)
62 © Alvin R. Lebeck from Hilton and Sorin CS/ECE 250
(!A & !C)|(A & C)
A
C Out
Boolean Functions, Gates and Circuits
• Circuits are made from a network of gates.
![Page 63: Basics of Logic Design: Boolean Algebra, Logic Gates ...• 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](https://reader036.vdocuments.us/reader036/viewer/2022062509/60f9db28f005e220de347ca8/html5/thumbnails/63.jpg)
63 © Alvin R. Lebeck from Hilton and Sorin
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)
CS/ECE 250
a b
c d
BAD!
![Page 64: Basics of Logic Design: Boolean Algebra, Logic Gates ...• 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](https://reader036.vdocuments.us/reader036/viewer/2022062509/60f9db28f005e220de347ca8/html5/thumbnails/64.jpg)
64 © Alvin R. Lebeck from Hilton and Sorin
Let’s Make a Useful Circuit
• Pick between 2 inputs (called 2-to-1 MUX) − Short for multiplexor
• What might we do first?
CS/ECE 250
![Page 65: Basics of Logic Design: Boolean Algebra, Logic Gates ...• 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](https://reader036.vdocuments.us/reader036/viewer/2022062509/60f9db28f005e220de347ca8/html5/thumbnails/65.jpg)
65 © Alvin R. Lebeck from Hilton and Sorin
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
CS/ECE 250
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 66: Basics of Logic Design: Boolean Algebra, Logic Gates ...• 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](https://reader036.vdocuments.us/reader036/viewer/2022062509/60f9db28f005e220de347ca8/html5/thumbnails/66.jpg)
66 © Alvin R. Lebeck from Hilton and Sorin
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)
CS/ECE 250
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 67: Basics of Logic Design: Boolean Algebra, Logic Gates ...• 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](https://reader036.vdocuments.us/reader036/viewer/2022062509/60f9db28f005e220de347ca8/html5/thumbnails/67.jpg)
67 © Alvin R. Lebeck from Hilton and Sorin
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 • Simplify
(A & !S) | (B & S)
CS/ECE 250
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 68: Basics of Logic Design: Boolean Algebra, Logic Gates ...• 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](https://reader036.vdocuments.us/reader036/viewer/2022062509/60f9db28f005e220de347ca8/html5/thumbnails/68.jpg)
68 © Alvin R. Lebeck from Hilton and Sorin CS/ECE 250
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:
![Page 69: Basics of Logic Design: Boolean Algebra, Logic Gates ...• 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](https://reader036.vdocuments.us/reader036/viewer/2022062509/60f9db28f005e220de347ca8/html5/thumbnails/69.jpg)
69 © Alvin R. Lebeck from Hilton and Sorin CS/ECE 250
Example 4x1 MUX
3
2
1
0 a
b
c
d
y
S
2
a b
c d
out
s0 s1
The / 2 on the wire means “2 bits”
![Page 70: Basics of Logic Design: Boolean Algebra, Logic Gates ...• 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](https://reader036.vdocuments.us/reader036/viewer/2022062509/60f9db28f005e220de347ca8/html5/thumbnails/70.jpg)
70 © Alvin R. Lebeck from Hilton and Sorin CS/ECE 250
Arithmetic and Logical Operations in ISA
• What operations are there? • How do we implement them?
− Consider a 1-bit Adder
![Page 71: Basics of Logic Design: Boolean Algebra, Logic Gates ...• 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](https://reader036.vdocuments.us/reader036/viewer/2022062509/60f9db28f005e220de347ca8/html5/thumbnails/71.jpg)
71 © Alvin R. Lebeck from Hilton and Sorin CS/ECE 250
Summary
• Boolean Algebra & functions • Logic gates (AND, OR, NOT, etc) • Multiplexors
• Download Logisim for Recitation − http://ozark.hendrix.edu/~burch/logisim/download.html