λ CS 251 Fall 2019 CS 240 Spring 2020 Principles of Programming Languages Foundations of Computer Systems Ben Wood Ben Wood Digital Logic Gate way to computer science transistors, gates, circuits, Boolean algebra https://cs.wellesley.edu/~cs240/s20/ Digital Logic 1
Program, Application Software Programming Language Compiler/Interpreter Operating System Instruction Set Architecture Microarchitecture Hardware Digital Logic Devices (transistors, etc.) Solid-State Physics Digital Logic 2
Digital data/computation = Boolean ! n o i t c a r Boolean value ( bit ): 0 or 1 t s b A Boolean functions (AND, OR, NOT, …) Electronically: bit = high voltage vs. low voltage 0 1 0 3.3V 2.8V 0.5V 0.0V Boolean functions = logic gates, built from transistors Digital Logic 3
Transistors (more in lab) +V cc (Supply Voltage) If Base voltage is high: resistor Current may flow freely V out from Collector to Emitter . Collector V in Base If Base voltage is low: Emitter Current may not flow from Collector to Emitter . (Ground) Truth table NOT gate in out V in V out in out = = low high 0 1 F T high low 1 0 T F ! n o i t c a r t s b A Digital Logic 4
ex ! n o Digital Logic Gates i t c a r t s b A Tiny electronic devices that compute basic Boolean functions. NOT NAND V 2 V in V out 0 1 + V cc 0 1 0 V 1 1 0 1 + V cc V out V 1 V out V 2 V in Digital Logic 5
Integrated Circuits (1950s - ) Early (first?) transistor Chip Wafer Small integrated circuit Digital Logic 6
ex Five basic gates: define with truth tables 0 1 0 1 NOT NAND NOR 0 1 0 1 1 0 1 0 1 1 0 1 0 1 0 1 AND OR 0 0 1 1 Digital Logic 7
inputs = variables Boolean Algebra wires = expressions gates = operators/functions for combinational logic circuits = functions A A A + B A B B B (A · B) AND = Boolean product OR = Boolean sum · 0 1 + 0 1 0 0 0 0 0 1 1 0 1 1 1 1 A A A A NOT = inverse or complement wire = identity 0 1 0 0 1 0 1 1 Digital Logic 8
ex Circuits Connect inputs and outputs of gates with wires. Crossed wires touch only if there is a dot. A B = C 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? Digital Logic 9
ex Translation Connect 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) Digital Logic 10
Note on notation: bubble = inverse/complement A + B A + B A A = B B Identity law, inverse law 0 0 + A = A A A A A 0 = A A Digital Logic 11
Commutativity, Associativity A B A + B B + A = B A AB A(BC) A A (AB)C B BC = B C C Digital Logic 12
Idempotent law, Null/Zero law A + A A = A A 0 0 A 0 = A A Digital Logic 13
Note on notation: bubble = inverse/complement A A A + B = A + B B B DeMorgan's Law ( double bubble , toil and trouble, in Randy's words...) AB 0 1 A = 0 1 1 A B B 1 1 0 A+B 0 1 A A + B = 0 1 0 B 1 0 0 Digital Logic 14
One law, Absorption law ex Write truth tables. Do they correspond to simpler circuits? A A + 1 = 1 A + AB A = B AB Digital Logic 15
ex NAND is universal . All Boolean functions can be implemented using only NANDs. Build NOT, AND, OR, NOR, using only NAND gates. Digital Logic 16
ex XOR: Exclusive OR Output = 1 if exactly one input = 1. Truth table: Build from earlier gates: Often used as a one-bit comparator. Digital Logic 17
ex Larger gates Build a 4-input AND gate using any number of 2-input gates. Digital Logic 19
Why simplify? ex Circuit simplification Smaller = cheaper, faster, cooler, easier to design/build. Is there a simpler circuit that performs the same function? Start with an equivalent Boolean expression, then simplify with algebra. F(A, B, C) = Check the answer with a truth table. Digital Logic 20
ex Circuit derivation: code detectors AND 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. A B C D Design a 4-input code detector to accept two codes (ABCD=1001, ABCD=1111) and reject all others. (accept = 1, reject = 0) Digital Logic 21
ex 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? Digital Logic 22
ex Voting machines A 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 Majority 0 0 0 0 0 0 1 0 0 1 0 0 0 1 1 1 1 0 0 0 1 0 1 1 1 1 0 1 1 1 1 1 Triply redundant computers in spacecraft Space program also hastened Integrated Circuits. • Digital Logic 23
Computers l Manual calculations l powered all early US space missions. l Facilitated transition to digital computers. Katherine Johnson Mary Jackson l Supported Mercury, Apollo, Space Shuttle, ... Dorothy Vaughn l First black supervisor within NACA l Early self-taught FORTRAN programmer for NASA move to digital computers. Digital Logic 24
Early pioneers in reliable computing Apollo 11 code print-out Katherine Johnson l Calculated first US human space flight trajectories l Mercury, Apollo 11, Space Shuttle, … l Reputation for accuracy in manual calculations, verified early code l Called to verify results of code for launch calculations for first US human in orbit l Backup calculations helped save Apollo 13 l Presidential Medal of Freedom 2015 Margaret Hamilton l 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. Digital Logic 25 l Presidential Medal of Freedom 2016
Recommend
More recommend