digital logic - cs.wellesley.educs240/f18/slides/gates.pdf · solid-state physics e digital logic...
TRANSCRIPT
![Page 1: Digital Logic - cs.wellesley.educs240/f18/slides/gates.pdf · Solid-State Physics e Digital Logic Microarchitecture Instruction Set Architecture Operating System Programming Language](https://reader030.vdocument.in/reader030/viewer/2022040716/5e204eb3235cfb0604450e55/html5/thumbnails/1.jpg)
WELLESLEY CSCS 240, Fall 2014
Digital Logic
Gateway to computer science
![Page 2: Digital Logic - cs.wellesley.educs240/f18/slides/gates.pdf · Solid-State Physics e Digital Logic Microarchitecture Instruction Set Architecture Operating System Programming Language](https://reader030.vdocument.in/reader030/viewer/2022040716/5e204eb3235cfb0604450e55/html5/thumbnails/2.jpg)
WELLESLEY CSCS 240, Fall 2014
Devices (transistors, etc.)
Solid-State Physics
Hard
war
e
Digital LogicMicroarchitecture
Instruction Set Architecture
Operating System
Programming Language
Compiler/Interpreter
Program, ApplicationSo
ftwar
e
![Page 3: Digital Logic - cs.wellesley.educs240/f18/slides/gates.pdf · Solid-State Physics e Digital Logic Microarchitecture Instruction Set Architecture Operating System Programming Language](https://reader030.vdocument.in/reader030/viewer/2022040716/5e204eb3235cfb0604450e55/html5/thumbnails/3.jpg)
WELLESLEY CSCS 240, Fall 2014
Digital data/computation = Boolean
Boolean value (bit): 0 or 1Boolean functions (AND, OR, NOT, …)Electronically:
bit = high voltage vs. low voltage
Boolean functions = logic gates, built from transistors0.0V0.5V
2.8V3.3V
0 1 0
3
Abstraction!
![Page 4: Digital Logic - cs.wellesley.educs240/f18/slides/gates.pdf · Solid-State Physics e Digital Logic Microarchitecture Instruction Set Architecture Operating System Programming Language](https://reader030.vdocument.in/reader030/viewer/2022040716/5e204eb3235cfb0604450e55/html5/thumbnails/4.jpg)
WELLESLEY CSCS 240, Fall 2014
Truth table
Transistors (more in lab)
Base
Collector
Emitter
If Base voltage is high:Current may flow freelyfrom Collector to Emitter.
If Base voltage is low:Current may not flowfrom Collector to Emitter.
Vin Vout
low highhigh low
in out0 11 0
in outF TT F
==
NOT gate
Abstraction!
+Vcc (SupplyVoltage)
(Ground)
resistor
Vin
Vout
![Page 5: Digital Logic - cs.wellesley.educs240/f18/slides/gates.pdf · Solid-State Physics e Digital Logic Microarchitecture Instruction Set Architecture Operating System Programming Language](https://reader030.vdocument.in/reader030/viewer/2022040716/5e204eb3235cfb0604450e55/html5/thumbnails/5.jpg)
WELLESLEY CSCS 240, Fall 2014
Tiny electronic devices that compute basic Boolean functions.
Digital Logic Gates
NAND
Vin
+Vcc
Vout
V1
+Vcc
Vout
V2
Abstraction! ex
NOT
Vin Vout
0 11 0
0 101
V1
V2
![Page 6: Digital Logic - cs.wellesley.educs240/f18/slides/gates.pdf · Solid-State Physics e Digital Logic Microarchitecture Instruction Set Architecture Operating System Programming Language](https://reader030.vdocument.in/reader030/viewer/2022040716/5e204eb3235cfb0604450e55/html5/thumbnails/6.jpg)
WELLESLEY CSCS 240, Fall 2014
Integrated Circuits (1950s - )
Wafer
Chip
Small integrated circuit
Early (first?) transistor
![Page 7: Digital Logic - cs.wellesley.educs240/f18/slides/gates.pdf · Solid-State Physics e Digital Logic Microarchitecture Instruction Set Architecture Operating System Programming Language](https://reader030.vdocument.in/reader030/viewer/2022040716/5e204eb3235cfb0604450e55/html5/thumbnails/7.jpg)
WELLESLEY CSCS 240, Fall 2014
Five basic gates: define with truth tables
NOT NAND NOR
AND OR
0 11 0
0 10 1 11 1 0
0 101
0 101
0 101
ex
![Page 8: Digital Logic - cs.wellesley.educs240/f18/slides/gates.pdf · Solid-State Physics e Digital Logic Microarchitecture Instruction Set Architecture Operating System Programming Language](https://reader030.vdocument.in/reader030/viewer/2022040716/5e204eb3235cfb0604450e55/html5/thumbnails/8.jpg)
WELLESLEY CSCS 240, Fall 2014
Boolean Algebrafor combinational logic
A
B A B(A · B)
A
B A + B
A A A A
inputs = variableswires = expressionsgates = operators/functionscircuits = functions
AND = Boolean product OR = Boolean sum
NOT = inverse or complement wire = identity
· 0 10 0 01 0 1
+ 0 10 0 11 1 1
0 11 0
0 01 1
![Page 9: Digital Logic - cs.wellesley.educs240/f18/slides/gates.pdf · Solid-State Physics e Digital Logic Microarchitecture Instruction Set Architecture Operating System Programming Language](https://reader030.vdocument.in/reader030/viewer/2022040716/5e204eb3235cfb0604450e55/html5/thumbnails/9.jpg)
WELLESLEY CSCS 240, Fall 2014
CircuitsConnect inputs and outputs of gates with wires.Crossed wires touch only if there is a dot.
What is the output if A=1, B=0, C=1?What is the truth table of this circuit?What is an equivalent Boolean expression?
ex
=
ABC
![Page 10: Digital Logic - cs.wellesley.educs240/f18/slides/gates.pdf · Solid-State Physics e Digital Logic Microarchitecture Instruction Set Architecture Operating System Programming Language](https://reader030.vdocument.in/reader030/viewer/2022040716/5e204eb3235cfb0604450e55/html5/thumbnails/10.jpg)
WELLESLEY CSCS 240, Fall 2014
TranslationConnect gates to implement these functions. Check with truth tables.Use a direct translation -- it is straightforward and bidirectional.F = (AB + C)D
Z = W + (X + WY)
ex
![Page 11: Digital Logic - cs.wellesley.educs240/f18/slides/gates.pdf · Solid-State Physics e Digital Logic Microarchitecture Instruction Set Architecture Operating System Programming Language](https://reader030.vdocument.in/reader030/viewer/2022040716/5e204eb3235cfb0604450e55/html5/thumbnails/11.jpg)
WELLESLEY CSCS 240, Fall 2014
Identity law, inverse law
AB =
AB
A + B
0
A A A
A + B
0 + A=
A
A A= A
0
Note on notation: bubble = inverse/complement
![Page 12: Digital Logic - cs.wellesley.educs240/f18/slides/gates.pdf · Solid-State Physics e Digital Logic Microarchitecture Instruction Set Architecture Operating System Programming Language](https://reader030.vdocument.in/reader030/viewer/2022040716/5e204eb3235cfb0604450e55/html5/thumbnails/12.jpg)
WELLESLEY CSCS 240, Fall 2014
Commutativity, Associativity
AB =
=
A + BBA
B + A
ABC
(AB)CAB A
BC
A(BC)
BC
![Page 13: Digital Logic - cs.wellesley.educs240/f18/slides/gates.pdf · Solid-State Physics e Digital Logic Microarchitecture Instruction Set Architecture Operating System Programming Language](https://reader030.vdocument.in/reader030/viewer/2022040716/5e204eb3235cfb0604450e55/html5/thumbnails/13.jpg)
WELLESLEY CSCS 240, Fall 2014
Idempotent law, Null/Zero law
0
A
A A
0 A=
A
A0
A + A =
![Page 14: Digital Logic - cs.wellesley.educs240/f18/slides/gates.pdf · Solid-State Physics e Digital Logic Microarchitecture Instruction Set Architecture Operating System Programming Language](https://reader030.vdocument.in/reader030/viewer/2022040716/5e204eb3235cfb0604450e55/html5/thumbnails/14.jpg)
WELLESLEY CSCS 240, Fall 2014
DeMorgan's Law(double bubble, toil and trouble, in Randy's words...)
A A + B
B
AB
=
AB A B=
AB A + B =
A + B
Note on notation: bubble = inverse/complement
![Page 15: Digital Logic - cs.wellesley.educs240/f18/slides/gates.pdf · Solid-State Physics e Digital Logic Microarchitecture Instruction Set Architecture Operating System Programming Language](https://reader030.vdocument.in/reader030/viewer/2022040716/5e204eb3235cfb0604450e55/html5/thumbnails/15.jpg)
WELLESLEY CSCS 240, Fall 2014
One law, Absorption lawWrite truth tables. Do they correspond to simpler circuits?
A
1
A + 1 =
A A + AB
B
=
AB
ex
![Page 16: Digital Logic - cs.wellesley.educs240/f18/slides/gates.pdf · Solid-State Physics e Digital Logic Microarchitecture Instruction Set Architecture Operating System Programming Language](https://reader030.vdocument.in/reader030/viewer/2022040716/5e204eb3235cfb0604450e55/html5/thumbnails/16.jpg)
WELLESLEY CSCS 240, Fall 2014
NAND is universal.
All Boolean functions can be implemented using only NANDs.Build NOT, AND, OR, NOR, using only NAND gates.
ex
![Page 17: Digital Logic - cs.wellesley.educs240/f18/slides/gates.pdf · Solid-State Physics e Digital Logic Microarchitecture Instruction Set Architecture Operating System Programming Language](https://reader030.vdocument.in/reader030/viewer/2022040716/5e204eb3235cfb0604450e55/html5/thumbnails/17.jpg)
WELLESLEY CSCS 240, Fall 2014
XOR: Exclusive OR
Output = 1 if exactly one input = 1.
Truth table: Build from earlier gates:
Often used as a one-bit comparator.
Video game designers, Halloween costumers extraordinaire, sci-fi/fantasy screenwriters,I have an idea…
ex
![Page 18: Digital Logic - cs.wellesley.educs240/f18/slides/gates.pdf · Solid-State Physics e Digital Logic Microarchitecture Instruction Set Architecture Operating System Programming Language](https://reader030.vdocument.in/reader030/viewer/2022040716/5e204eb3235cfb0604450e55/html5/thumbnails/18.jpg)
WELLESLEY CSCS 240, Fall 2014
Gates of XOR
Exclusive preview or something.© 2015 Ben Wood
![Page 19: Digital Logic - cs.wellesley.educs240/f18/slides/gates.pdf · Solid-State Physics e Digital Logic Microarchitecture Instruction Set Architecture Operating System Programming Language](https://reader030.vdocument.in/reader030/viewer/2022040716/5e204eb3235cfb0604450e55/html5/thumbnails/19.jpg)
WELLESLEY CSCS 240, Fall 2014
Larger gatesBuild a 4-input AND gate using any number of 2-input gates.
ex
![Page 20: Digital Logic - cs.wellesley.educs240/f18/slides/gates.pdf · Solid-State Physics e Digital Logic Microarchitecture Instruction Set Architecture Operating System Programming Language](https://reader030.vdocument.in/reader030/viewer/2022040716/5e204eb3235cfb0604450e55/html5/thumbnails/20.jpg)
WELLESLEY CSCS 240, Fall 2014
Circuit simplificationIs there a simpler circuit that performs the same function?
Start with an equivalent Boolean expression, then simplify with algebra.F(A, B, C) =
Why simplify?Smaller = cheaper, faster, cooler,
easier to design/build.
Check the answer with a truth table.
ex
![Page 21: Digital Logic - cs.wellesley.educs240/f18/slides/gates.pdf · Solid-State Physics e Digital Logic Microarchitecture Instruction Set Architecture Operating System Programming Language](https://reader030.vdocument.in/reader030/viewer/2022040716/5e204eb3235cfb0604450e55/html5/thumbnails/21.jpg)
WELLESLEY CSCS 240, Fall 2014
Circuit derivation: code detectorsAND gate + NOT gates = code detector, recognizes exactly one input code.
Design a 4-input code detector to output 1 if ABCD = 1001, and 0 otherwise.
Design a 4-input code detector to accept two codes (ABCD=1001, ABCD=1111) and reject all others. (accept = 1, reject = 0)
ABCD
ex
![Page 22: Digital Logic - cs.wellesley.educs240/f18/slides/gates.pdf · Solid-State Physics e Digital Logic Microarchitecture Instruction Set Architecture Operating System Programming Language](https://reader030.vdocument.in/reader030/viewer/2022040716/5e204eb3235cfb0604450e55/html5/thumbnails/22.jpg)
WELLESLEY CSCS 240, Fall 2014
Circuit derivation: sum-of-products form
logical sum (OR)of products (AND)of inputs or their complements (NOT)
Draw the truth table and design a sum-of-products circuit for a 4-input code detector to accept two codes (ABCD=1001, ABCD=1111) and reject all others. How are the truth table and the sum-of-products circuit related?
ex
![Page 23: Digital Logic - cs.wellesley.educs240/f18/slides/gates.pdf · Solid-State Physics e Digital Logic Microarchitecture Instruction Set Architecture Operating System Programming Language](https://reader030.vdocument.in/reader030/viewer/2022040716/5e204eb3235cfb0604450e55/html5/thumbnails/23.jpg)
WELLESLEY CSCS 240, Fall 2014
Voting machinesA majority circuit outputs 1 if and only if a majority of its inputs equal 1.Design a majority circuit for three inputs. Use a sum of products.
A B C Majority0 0 0 00 0 1 00 1 0 00 1 1 11 0 0 01 0 1 11 1 0 11 1 1 1
ex
Triply redundant computers in spacecraft• Space program also hastened Integrated Circuits.
![Page 24: Digital Logic - cs.wellesley.educs240/f18/slides/gates.pdf · Solid-State Physics e Digital Logic Microarchitecture Instruction Set Architecture Operating System Programming Language](https://reader030.vdocument.in/reader030/viewer/2022040716/5e204eb3235cfb0604450e55/html5/thumbnails/24.jpg)
WELLESLEY CSCS 240, Fall 2014
Katherine Johnsonl Supported Mercury, Apollo, Space
Shuttle, ...
Dorothy Vaughnl First black supervisor within NACAl Early self-taught FORTRAN
programmer for NASA move to digital computers.
Computers
l Manual calculationsl powered all early
US space missions.l Facilitated transition to
digital computers.
Mary Jackson
![Page 25: Digital Logic - cs.wellesley.educs240/f18/slides/gates.pdf · Solid-State Physics e Digital Logic Microarchitecture Instruction Set Architecture Operating System Programming Language](https://reader030.vdocument.in/reader030/viewer/2022040716/5e204eb3235cfb0604450e55/html5/thumbnails/25.jpg)
WELLESLEY CSCS 240, Fall 2014
Early pioneers in reliable computingApollo 11 code print-out
Katherine Johnsonl Calculated first US human space flight
trajectoriesl Mercury, Apollo 11, Space Shuttle, …l Reputation for accuracy in manual
calculations, verified early codel Called to verify results of code for launch
calculations for first US human in orbitl Backup calculations helped save Apollo 13l Presidential Medal of Freedom 2015
Margaret Hamiltonl Led software team for Apollo 11
Guidance Computer, averted mission abort on first moon landing.
l Coined “software engineering”, developed techniques for correctness and reliability.
l Presidential Medal of Freedom 2016