CSE140: Components and Design Techniques for Digital Systems Introduction Tajana Simunic Rosing 1 Welcome to CSE 140! • • • • • • • • Course time: T/Th 2-3:20pm, WLH 2205 Discussion session: M 11-11:50pm 11-11:50pm, WLH 2205 Instructor: Tajana Simunic Rosing • Email: tajana@ucsd.edu; please put CSE140 in the subject line • Ph. 858 534-4868 • Office Hours: Tu/Th 1-2pm, 1-2pm CSE 2118 Instructor’s Assistant: Sheila Manalo – Email: shmanalo@ucsd.edu – Phone: (858) 534-8873 TA: Raid Ayoub – Email: rayoub@cs.ucsd.edu – Office hours: WF: 10:00am-12:00pm TA: Chun Chen Liu – Email: chl084@ucsd.edu chl084@ucsd edu – Office hours: TBA Class Website: – http://www.cse.ucsd.edu/classes/sp08/cse140/ Grades: http://webct.ucsd.edu http://webct ucsd edu 2 Course Description p • Prerequisites: – CSE 20 or Math 15A, and CSE 30. – CSE 140L must be taken concurrently • Objective: – Introduce digital components and system design concepts • Grading – Homeworks (~8): 15% • Lowest grade on the HW will be dropped • HW picked up at beginning of the class, 0 pts if late – Two midterms: 25% each • No makeup exams; exceptions only for – Documented illness (signed doctor’s statement), death in the family – Final exam: 35% • Regrade g requests: q turn in a written request q at the end of the class where your work (HW or exam) is returned 3 Textbook and Recommended Readings g • Required textbook: – Contemporary Logic Design by R. Katz & G. Borriello • Recommended textbook: – Digital Design by F. Vahid • Lecture slides are derived from the slides designed for both books 4 Whyy Studyy Digital g Design? g • Look “under the hood” of computers – Become a better p programmer g when aware of hardware resource issues • Everyday devices becoming digital – Enables: • Better devices: Better sound recorders, cameras, cars, cell phones, medical devices,... • New devices: Video games, PDAs, ... – Known as “embedded systems” • Thousands of new devices every year • Designers needed: Potential career Satellites DVD players Portable music players Cell phones 1995 1999 1997 Video recorders Cameras 2001 2003 Musical instruments TVs 2005 2007 ??? 5 Implementing Digital Systems: Programming Microprocessors Vs Vs. Designing Digital Circuits Desired motion-at-night detector I0 I1 I2 I3 I4 I5 I6 I7 Programmed Custom designed microprocessor digital circuit P0 P1 P2 P3 P4 P5 P6 P7 6 Digital Design: When Microprocessors Aren’t Good Enough Execution time • With microprocessors so easy, cheap, and available, why design a digital circuit? – Microprocessor may be too slow – Or too big, power hungry, or costly Sample digital camera task execution times (in seconds) on a microprocessor versus a digital circuit: Task Microprocessor 5 0.1 Compress 8 0.5 1 (a) Memory Image Sensor 0.8 Microp processor (Read, Compress, and Store) Read circuit Compress circuit (b) Store circuit Memory Custom Digital Circuit Read Store Image Sensor Image Sensor (c) Memory Read i it circuit Compress circuit i it Microprocessor (Store) 7 What will we learn in this class? • The language of logic design – Boolean algebra, algebra logic minimization, minimization state state, timing timing, CAD tools • The concept of state in digital systems – analogous to variables and program counters in software systems • How to specify/simulate/compile/realize our designs (140L) – – – – hardware description languages tools to simulate the workings of our designs logic compilers to synthesize the hardware blocks of our designs mapping onto programmable hardware • Contrast with software design – sequential and parallel implementations – specify algorithm as well as computing/storage resources it will use 8 A qquick historyy lesson • 1850: George Boole invents Boolean algebra – maps logical propositions to symbols – permits manipulation of logic statements using mathematics • 1938: Claude Shannon links Boolean algebra to switches – his Masters’ Masters thesis • 1945: John von Neumann develops the first stored program computer – its switching elements are vacuum tubes (a big advance from relays) • 1946: ENIAC . . . The world’s first completely electronic computer – 18,000 vacuum tubes – several hundred multiplications per minute • 1947: Shockley, Brittain, and Bardeen invent the transistor – replaces vacuum tubes – enable integration of multiple devices into one package – gateway to modern electronics 9 What is logic g design? g • What is design? • What is logic design? 10 Computation: p abstract vs. implementation p • • • • Up to now, computation has been abstract (paper, programs) This class is about physically implementing computation using physical devices that use voltages to represent digital values Basic units of computation: – Representation: 0, 1 – Assignment x=y – Data operations x+y-5 – Control • Sequential statements a;b;c • Conditionals if x==1 then y • Loops for (i=1; i<10; i++) • Procedures a; proc (…); b; We will study how each of these can be implemented in hardware 11 Outline • What we will cover in the next few lectures: – Number representations • Analog vs. vs Digital • Digital representations: – Binary – Hexadecimal – Octal O t l • Binary addition and subtraction • Binary multiplication, division – Switches, MOS transistors, Logic gates • • • • What is a switch How a transistor operates Building logic gates out of transistors Building larger functions from logic gates – Boolean algebra • Properties • How Boolean algebra can be used to design logic circuits 12 CSE140: Components and Design Techniques for Digital Systems Number representations & Binary arithmetic Tajana Simunic Rosing 13 What Does “Digital” g Mean? • Analog signal • Digital signal – Infinite possible values • E Ex: voltage l on a wire i created by microphone – Finite possible values • E Ex: button b tt pressed d on a keypad Sound waves move the th membrane, 1 which moves the magnet, microphone i h 2 3 4 2 digital signal valuee which creates current in the nearby wire Possible values: 1 00 11.01, 1.00, 01 22.0000009, 0000009 ... infinite possibilities time valuee analog signal 4 3 2 1 0 Possible values: 0 1, 0, 1 2, 2 3, 3 or 4. 4 That’s it. time 14 Digital g Signals g with Onlyy Two Values: Binaryy One Binary digIT is a BIT Popular because it is easy storing a single bit, and simple to operate using two values (0,1) with transistors valuee • Binary digital signal -- only two possible values 1 0 time 15 Digitized version enables near-perfect save/cpy/trn. – “Sample” voltage at particular rate, save sample using bit encoding – Voltage levels still not kept perfectly – But we can distinguish 0s from 1s Let bit encoding be: 1 V: “01” Digitized signal not 2 V: “10” perfect re-creation, but higher sampling 3 V: “11” rate t andd more bits bit per encoding brings closer. time a2d 1 digitized signal 0 time 01 10 11 10 11 3 2 1 received signal 0 time How fix -- higher, g lower, ? 01 10 11 10 11 Volts • original signal lengthy traansmission (e.g, celll phone) – Voltage levels not saved/copied/transmitted perfectly 3 2 1 0 lengthy trransmission (e.g, ceell phone) Analog signal (e.g., audio) may lose quality V Volts • Volts Example p of Digitization g Benefit 1 0 time Can fix -- easily distinguish 0s and 1s, restore d2a 3 2 1 0 time 16 Digitized g Audio: Compression p Benefit • Digitized audio can be compressed – e.g., MP3s – A CD can hold about 20 songs g uncompressed, p but about 200 compressed Example compression scheme: 00 --> 0000000000 01 --> > 1111111111 1X --> X 0000000000 0000000000 0000001111 1111111111 • Compression also done on digitized pictures (jpeg), movies (mpeg), and more • Digitization has many other benefits too 17 How Do We Encode Data as Binary for Our Digital System? analog phenomena button • sensors and other inputs electric digital signal data A2D digital data – Button: not pressed (0), pressed (1) • digital data D2A electric signal actuators and other outputs Some inputs inherently digital – Just need encoding in binary – e.g., multi-button lti b tt input: i t encode red=001, blue=010, ... Digital System digital data Some inputs inherently binary • Some inputs analog – Need analog-to-digital conversion 0 red 1 blue green black 0 0 0 red blue green black 0 0 1 red blue green black 0 1 0 air 33 degrees temperature sensor 0 0 1 0 0 0 0 1 18 How to Encode Text: ASCII, Unicode • ASCII: 7- (or 8-) bit g of each letter,, encoding number, or symbol • Unicode: Increasingly pop lar 16 popular 16-bit bit bit encoding – Encodes characters from various world languages Symbol Encoding Symbol Encoding R S T L N E 0 1010010 1010011 1010100 1001100 1001110 1000101 0110000 0101110 0001001 r s t l n e 9 1110010 1110011 1110100 1101100 1101110 1100101 0111001 0100001 0100000 . <tab> ! <space> What does this ASCII bit sequence represent? 1010010 1000101 1010011 1010100 19 How to Encode Numbers: Binaryy Numbers • Each position represents a quantity; symbol in position means how many of that quantity – Base ten (decimal) • Ten symbols: 0, 1, 2, ..., 8, and 9 • More than 9 -- next position 5 2 3 104 103 102 101 100 – So each position power of 10 • N Nothing thi special i l about b tb base 10 -used because we have 10 fingers – Base two ((binary) y) • Two symbols: 0 and 1 • More than 1 -- next position 24 23 1 0 1 22 21 20 – So each position power of 2 20 How to Encode Numbers: Binaryy Numbers • Working with binary numbers – In base ten, helps to know powers of 10 • one, ten, hundred, thousand, ten th thousand, d ... 29 28 27 26 25 24 23 22 21 20 512 256 128 64 32 16 8 4 2 1 – In base two, helps to know powers of 2 21 Converting from Decimal to Binary Numbers: Subtraction Method (Easy for Humans) • Goal – Get the binary weights to add up to the decimal quantity • Work from left to right • 32 16 8 4 2 1 Subtraction method: – To make the job easier, we just subtract a selected binary weight from the (remaining) quantity • Then Then, we have a new remaining quantity, and we start again (from the present binary position) • Stop when remaining quantity is 0 22 Converting from Decimal to Binary Numbers: Division Method (Good for Computers) • Divide decimal number by 2 and insert remainder into new binary number. – Continue dividing quotient by 2 until the quotient is 0. • Example: Convert decimal number 12 to binary Decimal ec a Number u be Binary a y Number u be 23 Bases Sixteen & Eight g 164 163 • 8 A F 162 161 160 8 A F 1000 1010 1111 hex binary hex bina ry 0 1 2 3 4 5 6 7 0000 0001 0010 0011 0100 0101 0110 0111 8 9 A B C D E F 1000 1001 1010 1011 1100 1101 1110 1111 • Base sixteen – nice because each position represents four base two positions – Used as compact means to write binary numbers – Basic digits: 0-9, A-F – Known as hexadecimal, or just hex Base eight – Used in some digital designs – Each position represents three base two positions iti – Basic digits: 0-7 Write 11110000 in hex Write 11110000 in octal 24 Sign g and magnitude g • One bit dedicate to sign (positive or negative) – sign: 0 = positive (or zero), 1 = negative • Rest represent the absolute value or magnitude – three low order bits: 0 (000) thru 7 (111) • Range for n bits –7 – +/– 2n–1 –1 (two representations for 0) • Cumbersome addition/subtraction – mustt compare magnitudes it d to determine sign of result –6 –5 +0 +1 1111 0000 1110 0001 1101 0010 +2 –4 1100 0011 +3 –3 1011 0100 +4 0101 +5 –2 1010 1001 0110 +6 –1 1000 0111 0 –0 +7 25 1s complement p • • • If N is a positive number, then the negative of N (its 1s complement or N' ) is N' = (2n– 1) – N (n= total # bits); higher order -> sign bit • Shortcut: bit wise complement (7->-7 0111->1000 Subtraction implemented by 1s complement and then addition Problem: two representations p of zero –0 –1 2 –2 +0 +1 1111 0000 1110 0001 1101 0010 +2 –3 1100 0011 +3 1011 0100 +4 –4 –5 1010 0101 1001 0110 1000 0111 +6 –6 –7 +7 +5 26 2s complement p • 1s complement with negative numbers shifted one position clockwise – only one representation for 0, high-order bit -> sign bit, more negative #s • If N iis a positive iti number, b th then th the negative ti off N (it (its 2s 2 complement l t or N* ) is N* = 2n – N – Shortcut: bit-wise complement plus 1 – 7 -> > -7 7 : 0111 -> > 1000 + 1 = 1001 ((-7) 7) – -7 -> 7: 1001 -> 0110 + 1 = 0111 (7) –1 –2 –3 +0 +1 1111 0000 1110 0001 1101 0010 +2 –4 1100 0011 +3 –5 1011 0100 +4 –6 1010 0101 1001 0110 1000 0111 +6 –7 –8 +5 +7 27 2s complement p addition and subtraction • Simple addition and subtraction – makes 2s complement the unanimous choice for integers in computers • Check overflow conditions: – Add two positive numbers and get a negative, or two negative and get positive 4 –4 +3 + (– 3) 7 –7 4 –4 –3 +3 1 –1 28 Overflow • Sometimes result can’t be represented with given number of bits – Either too large magnitude of positive or negative – e.g., 4-bit two’s complement addition of 0111+0001 (7+1=8). But 4-bit 4 bit two’s two s complement can can’tt represent number >7 • 0111+0001 = 1000 WRONG answer, 1000 in two’s complement is 8, not +8 – Adder/subtractor should indicate when overflow has occurred occurred, so result can be discarded 29 Detectingg Overflow: Method 1 • Assuming 4-bit two’s complement numbers, can detect overflow by detecting when the two numbers’ sign bits are the same but are different from the result’s result s sign bit – If the two numbers’ sign bits are different, overflow is impossible • Adding a positive and negative can’t exceed largest magnitude positive or negative • Simple circuit – overflow = a3’b3’s3 + a3b3s3’ – Include “overflow” output bit on adder/subtractor sign bits 0 1 1 1 1 1 1 1 1 0 0 0 +0 0 0 1 +1 0 0 0 +0 1 1 1 1 0 0 0 overflow (a) 0 1 1 1 overflow (b) 1 1 1 1 no overflow (c) If the numbers’ sign bits have the same value, which differs from the result’s sign bit, overflow has occurred. 30 Detectingg Overflow: Method 2 • • Even simpler method: Detect difference between carry-in to sign bit and carry-out from sign bit Yields simpler circ circuit: it o overflow erflo = c3 xor or c4 1 1 1 0 1 1 1 0 0 0 1 1 1 1 0 0 0 1 0 0 0 +0 0 0 1 +1 0 0 0 +0 1 1 1 0 1 0 0 0 10 1 1 1 01 1 1 1 overflow ((a)) overflow ((b)) no overflow ((c)) If the carry into the sign bit column differs from the carry out of that column, overflow has occurred. 31 Multiplication p • Generalized representation of multiplication by hand 32 Division • Repeated subtraction – Set quotient to 0 – Repeat while dividend >= divisor • Subtract divisor from dividend • Add 1 to quotient – When dividend < divisor: • Reminder = dividend • Quotient is correct Example: • Dividend: 101; Divisor: 10 Dividend 101 - Quotient 0 + 10 1 11 - 1 + 10 1 1 10 33 Summaryy of number representation p • Conversion between basis – – – – • Decimal Bi Binary Octal Hex Addition & subtraction in binary – Overflow detection • Multiplication – Partial products • For demo see: http://courses.cs.vt.edu/~cs1104/BuildingBlocks/multiply.010.html • Division – Repeated subtraction • For demo see: http://courses.cs.vt.edu/~cs1104/BuildingBlocks/Binary.Divide.html 34 CSE140: Components and Design Techniques for Digital Systems Combinational circuit building blocks: Switches and gates Tajana Simunic Rosing 35 Combinational Circuit Introduction Digital g circuit • We’ll start with a simple form of circuit: – Combinational circuit • A digital circ circuit it whose hose o outputs tp ts depend solel solely on the present combination of the circuit inputs’ values • Built out of simple components: switches and gates 1 a b Combinational 0 1 F digital circuit 1 a b Sequential 0 ? F g circuit digital 36 Switches • Electronic switches are the basis of g circuits binaryy digital – Electrical terminology • Voltage: Difference in electric potential between two p points – 45A 4.5 9V 4.5 A + – Analogous to water pressure • Current: Flow of charged particles 2 ohms – Analogous to water flow • Resistance: Tendency of wire to resist current flow – Analogous to water pipe diameter 9V 0V 4.5 A • V = I * R (Oh (Ohm’s ’ L Law)) 37 Switches • A switch has three parts control input – Source input, and output “off” • Current wants to flow from source input to output source input – Control input • Voltage that controls whether that current can flow • The amazing shrinking switch – – – – output control input source input 1930s: Relays 1940s: Vacuum tubes 1950s: Discrete transistor 1960s: Integrated circuits (ICs) “ ” “on” output (b) • Initially just a few transistors on IC • Then tens, hundreds, thousands... relay discrete transistor vacuum tube IC quarter (to see the relative size) 38 The CMOS Circuit • CMOS circuit – Consists of N and PMOS transistors – Both N and PMOS are similar to basic switches – Rp ~ 3 Rn => PMOS in series is much slower than NMOS A positive voltage here here... ...attracts electrons here, turning the channel between source and drain into a conductor. nMOS gate 1 0 gate oxide source IC package drain conducts does not conduct 1 0 pMOS (a) IC gate Silicon -- not quite a conductor or insulator: Semiconductor does not conduct conducts 39 MOS networks X what is the relationship between x and y? 3v x Y 0v y 0 volts 3 volts 3 volts 0 volts 40 Two input p networks X Y 3 3v Z1 0v what is the relationship between x, y and z? x X Y y z1 z2 l 0 volts 0 volts 0 volts 3 volts 3v 3 volts 0 volts Z2 3 volts 3 volts 0v 41 Relatingg Boolean Algebra g to Digital g Design g Boolean algebra (mid-1800s) Boole’s intent: formalize human thought For telephone Switches (1930s) switching and other NOT Symbol F x 0 1 Shannon (1938) x F y F 1 0 x 0 0 1 1 electronic uses Showed application of Boolean algebra to design of switchbased circuits AND x x Truth table OR 1 y 0 1 0 1 F 0 1 1 1 x 0 0 1 1 Digital design x F = x’ F’ F= x or y 0 x y 0 1 1 Implement logic operators using transistors F 0 0 0 1 1 0 • y 0 1 0 1 1 y Transistor x circuit i it F y y x – Call those implementations logic gates F=x & y F’ y 0 x 0 42 NOT/OR/AND Logic g Gate Timingg Diagrams g 1 1 1 x x 0 1 x 0 y y 1 0 1 0 1 F 0 F time 0 1 F 0 0 time time 43 More Gates NAND NOR XOR x x F y 1 NAND y F x 0 0 1 1 • • • • y 0 1 0 1 F 1 1 1 0 x 0 0 1 1 y 0 1 0 1 F 1 0 0 0 x 0 0 1 1 y 0 1 0 1 F 0 1 1 0 x 0 0 1 1 y 0 1 0 1 F 1 0 0 1 NOR x y x F y 1 XNOR F x y x y 0 0 NAND: Opposite of AND (“NOT AND”) NOR: Opposite of OR (“NOT ( NOT OR OR”)) XOR: Exactly 1 input is 1, for 2-input XOR. (For more inputs -- odd number of 1s) XNOR: Opposite of XOR (“NOT XOR”) 44 CMOS Example • The rules: – NMOS connects to GND,, PMOS to power p supply pp y Vdd – Duality of NMOS and PMOS – Rp ~ 3 Rn => PMOS in series is much slower than NMOS in series • Implement Z using sing CMOS CMOS: Z = (A + BC)’ 45 Another CMOS Example • Implement F using CMOS: F=A*(B+C) 46 Completeness p of NAND • Any logic function can be implemented using just NAND gates. Likewise for NOR. Why? g y – Need AND, OR and NOT 47 Buildingg Circuits Usingg Gates • Motion-in-dark example 48 Example: Converting a Logic Equation to a Circuit of Logic Gates • Convert the following equation to logic gates: F = a AND NOT( b OR NOT(c) ) 49 Another example • More than one way to map expressions to gates g , Z = A’ • B’ • ((C + D)) = ((A’ • ((B’ • ((C + D))) ))) e.g., – Use only two input gates, or using also three input gates 50 Waveform view of logic g functions • Just a sideways truth table – but note how edges g don’t line up p exactly y – it takes time for a gate to switch its output! time change in Y takes time to "propagate" through gates 51 Example: p Seat Belt Warningg Light g System y • • Design circuit for warning light S Sensors – s=1: seat belt fastened – k=1: key inserted – p=1: person in the seat • Capture logic equation – What are conditions for warning light g t to go o on? • Convert equation to circuit 52 Convertingg to Logic g Equations q a • Q1. A fire sprinkler system should spray water if high y is set to enabled. heat is sensed and the system – Let variable h represent “high heat is sensed,” e represent “enabled,” and F represent “spraying water.” – Answer: F = • Q2. A car alarm should sound if the alarm is enabled, and either the car is shaken or the door is opened. – Let a represent “alarm is enabled,” s represent “car is shaken,” d represent “door is opened,” and F represent “alarm sounds.” – Answer: F = 53 CSE140: Components and Design Techniques for Digital Systems Boolean algebra Tajana Simunic Rosing 54 Boolean Algebra g and its Relation to Digital g Circuits • • • To understand the benefits of “logic gates” vs. switches, we should first understand Boolean algebra “Traditional” algebra – Variable represent real numbers – Operators p operate p on variables,, return real numbers An algebraic structure consists of – a set of elements B – binary operations { + , • } – and a unary operation { ’ } – such that the following axioms hold: 1. the set B contains at least two elements: a, b 2. closure: a + b is in B a • b is in B 3. commutativity: a + b = b + a a•b=b•a 4. associativity: a + (b + c) = (a + b) + c a • (b • c) = (a • b) • c 5. identity: a+0=a a•1=a 6. distributivity: a + (b • c) = (a + b) • (a + c) a • (b + c) = (a • b) + (a • c) 55 7. complementarity: a + a’ = 1 a • a’ = 0 Boolean algebra g • Boolean Algebra – – – – B = {{0,, 1}} Variables represent 0 or 1 only Operators return 0 or 1 only Basic operators a 0 0 1 1 b 0 1 0 1 AND 0 0 0 1 a 0 0 1 1 • • is logical AND: a AND b returns 1 only when both a=1 and b=1 • + is logical OR: a OR b returns 1 if either (or both) a=1 or b=1 • ’ is logical NOT: NOT a returns the opposite of a (1 if a=0 a=0, 0 if a=1) – All algebraic axioms hold a 0 1 b 0 1 0 1 NOT 1 0 56 OR 0 1 1 1 Axioms and theorems of Boolean algebra g • • • • • • • identity 1. X + 0 = X null 2. X + 1 = 1 idempotency: 3. X + X = X involution: 4. (X’)’ = X complementarity: 5. X + X’ = 1 commutativity: y 6. X + Y = Y + X associativity: 7. ((X + Y)) + Z = X + ((Y + Z)) 1D. X • 1 = X 2D. X • 0 = 0 3D. X • X = X 5D. X • X’ = 0 6D. X • Y = Y • X 7D. ((X • Y)) • Z = X • ((Y • Z)) 57 Axioms and theorems of Boolean algebra (cont’d) • • • • • distributivity: 8. X • (Y + Z) = (X • Y) + (X • Z) Z) uniting: 9. X • Y + X • Y’ = X absorption: 10. X + X • Y = X 11. (X + Y’) • Y = X • Y factoring: 12. (X + Y) • (X’ + Z) = X • Z + X’ • Y concensus: 13. (X • Y) + (Y • Z) + (X’ • Z) = X • Y + X’ • Z 8D. X + (Y • Z) = (X + Y) • (X + 9D. (X + Y) • (X + Y’) = X 10D. X • (X + Y) = X 11D. (X • Y’) + Y = X + Y 12D. X • Y + X’ • Z = (X + Z) • (X’ + Y) 13D. (X + Y) • (Y + Z) • (X’ + Z) = (X + Y) • (X’ + Z) 58 Axioms and theorems of Boolean algebra (cont’d) • de Morgan’s: g 14. (X + Y + ...)’ = X’ • Y’ • ...14D. (X • Y • ...)’ = X’ + Y’ + ... • generalized li d d de M Morgan’s: ’ 15. f’(X1,X2,...,Xn,0,1,+,•) = f(X1’,X2’,...,Xn’,1,0,•,+) • establishes relationship between • and + 59 Axioms and theorems of Boolean algebra (cont’d) • Duality – a dual of a Boolean expression is derived by replacing • by +, + by •, 0 by 1, and 1 by 0, and leaving variables unchanged – any theorem that can be proven is thus also proven for its dual! – a meta-theorem (a theorem about theorems) • duality: 16. X + Y + ... ⇔ X • Y • ... • generalized duality: 17. f (X1,X2,...,Xn,0,1,+,•) ⇔ f(X1,X2,...,Xn,1,0,•,+) • Different Diff t th than d deMorgan’s M ’ L Law – this is a statement about theorems – this is not a way to manipulate (re-write) expressions 60 Provingg theorems • Using the axioms of Boolean algebra: – e.g., g , prove p the theorem: distributivity (8) p y (5) ( ) complementarity identity (1D) – e.g., prove the theorem: identity (1D) distributivity (8) identity (2) identity (1D) X • Y + X • Y’ = X X • Y + X • Y’ X • (Y ( + Y’)) X • (1) X+X•Y X X X X + X•Y •1 + X•Y • (1 + Y) • (1) = X • (Y + Y’) = X • ((1)) = X9 = X = = = = X X X X •1 + X•Y • (1 + Y) • (1) 9 61 Provingg theorems example p • Prove the following using the laws of Boolean algebra: – ((X • Y)) + (Y ( • Z)) + (X’ ( • Z)) = X • Y + X’ • Z (X • Y) + (Y • Z) + (X’ • Z) identity (X • Y) + (1) • (Y • Z) + (X’ • Z) complementarity (X • Y) + (X’ + X) • (Y • Z) + (X’ • Z) distributivity (X • Y) + (X’ • Y • Z) + (X • Y • Z) + (X’ • Z) commutativity (X • Y) + (X • Y • Z) + (X’ • Y • Z) + (X’ • Z) factoring (X • Y) • (1 + Z) + (X’ • Z) • (1 + Y) null (X • Y) • (1) + (X’ • Z) • (1) identity (X • Y) + (X’ • Z) 9 62 Provingg theorems (p (perfect induction)) • Using perfect induction (complete truth table): – e.g., g , de Morgan’s: g (X + Y)’ = X’ • Y’ NOR is equivalent to AND with inputs complemented X 0 0 1 1 Y 0 1 0 1 X X’ 1 1 0 0 Y Y’ 1 0 1 0 (X + Y) Y)’ X X’ • Y Y’ (X • Y)’ = X’ + Y’ NAND is equivalent to OR with inputs complemented X 0 0 1 1 Y 0 1 0 1 X’ 1 1 0 0 Y’ 1 0 1 0 (X • Y)’ X’ + Y’ 63 A simple p example: p 1-bit binaryy adder Cout Cin • Inputs: A, B, Carry-in • Outputs: Sum, Sum Carry-out Carry out A 0 0 0 0 1 1 1 1 B 0 0 1 1 0 0 1 1 Cin Cout S 0 1 0 1 0 1 0 1 A B Cin A B A B A B A B A B S S S S S S Cout 64 Boolean Algebra g Operator p Precedence • Evaluate the following Boolean equations, assuming a=1, b=1, c=0, d=1. – Q1. F = a * b + c. • Answer: F = – Q2. F = ab + c. • Answer: F = – Q3. F = ab’. a • Answer: F = – Q4. F = (ac)’. • Answer: F = – Q5. F = (a + b b’)) * c + d d’.. • Answer: F = 65 Example p that Applies pp Boolean Algebra g Properties p • Want automatic door opener circuit (e.g., for grocery store) – Output: f=1 opens door – Inputs: • Found inexpensive chip that computes: • f = c’hp + c’hp’ + c’h’p – Can we use it? • p=1: person detected • h=1: h 1 switch it h fforcing i h hold ld open • c=1: key forcing closed – Want open door when • h=1 and c=0,, or • h=0 and p=1 and c=0 66 Boolean Algebra: g Additional Properties p Aircraft lavatory sign example • Behavior • • • Three lavatories, each with sensor (a, b, c), equals 1 if door locked Light “Available” sign (S) if any lavatory available • Alternative: • Instead of lighting “Available “Available,”” light “Occupied” Equation and circuit 67 Summaryy • What we covered thus far: – – – – Number representations p Switches, MOS transistors, Logic gates Boolean algebra Supplement: NMOS and PMOS transistor characteristics • What is next: – Combinatorial logic: • Representations • Minimization • Implementations 68