ONES AND ZEROS IEEE Press Understanding Science & Technology Series The IEEE Press Understanding Series treats important topics in science and technology in a simple and easy-to-understand manner. Designed expressly for the nonspecialist engineer, scientist, or technician, as well as the technologically curious-each volume stresses practical information over mathematical theorems and complicated derivations. Books in the Series Blyler, J. and Ray, G., What's Size Got to Do With It? Understanding Computer Rightsizing Deutsch, S., Understanding the Nervous System: An Engineering Perspective Evans, B., Understanding Digital TV: The Route to HDTV Gregg, J., Ones and Zeros: Understanding Boolean Algebra, Digital Circuits, andthe Logic ofSets Hecht, J., Understanding Lasers: An Entry-Level Guide, 2nd Edition Kamm, L., Understanding Electro-Mechanical Engineering: An Introduction to Mechatronics Kartalopoulos, S. V., Understanding Neural Networks and FuzzyLogic: Basic Concepts and Applications Lebow, I., Understanding Digital Transmission and Recording Nellist, J. G., Understanding Telecommunications and Lightwave Systems, 2nd Edition Sigfried, S., Understanding Object-Oriented Software Engineering ONES AND ZEROS Understanding Boolean Algebra, Digital Circuits, and the Logic ofSets John Gregg IEEE Press Understanding Science & Technology Series Dr. Mohamed E. El-Hawary, Series Editor +IEEE TheInstituteofElectricalandElectronics Engineers,lnc.,NewYork ffiWILEY- ~INTERSCIENCE AJOHNWILEY&SONS,INC.,PUBLICATION IEEE Press 445 HoesLane, P.O. Box1331 Piscataway, NJ 08855·1331 IEEE Press Editorial Board RogerF. Hoyt,Editor in Chief J. B. Anderson s. Furui P.Laplante P. M. Anderson A. H.Haddad M. Padgett M. Eden R.Herrick W. D.Reeve M. E.El-Hawary S. Kartalopoulos G.Zobrist D. Kirk KennethMoore,DirectorofIEEE Press JohnGriffin,SeniorAcquisitions Editor LindaMatarazzo,Assistant Editor Denise Phillip, Associate Production Editor Cover design: Caryl Silvers, Silvers Design Technical Reviewers SherifEmbabi, Texas A&M University Starn Kartalopoulos, Lucent Technologies, Bell Labs Innovations RichardS. Muller,University ofCalifornia, Berkeley KevinD.Taylor,Purdue University at Kokomo NealS.Widmer,Purdue University, EETDepartment To Susan, without whom this book would have been finished a lot sooner. <01998THEINSTITUTEOFELECTRICALANDELECTRONICSENGINEERS,INC. 3ParkAvenue,17thFloor,NewYork,NY10016-5997 PublishedbyJohnWiley& Sons,Inc.,Hoboken,NewJersey. Nopartofthispublicationmaybereproduced,storedinaretrievalsystem,or transmittedinanyformorbyanymeans,electronic,mechanical,photocopying, recording,scanning,orotherwise,exceptaspermittedunderSection107or108ofthe 1976UnitedStatesCopyrightAct,withouteitherthepriorwrittenpermissionofthe Publisher,orauthorizationthroughpaymentoftheappropriateper-copyfeetothe CopyrightClearanceCenter,Inc.,222RosewoodDrive,Danvers,MA01923,978-750- 8400,fax978-750-4470,oronthewebatwww.copyright.com.RequeststothePublisher forpermissionshouldbeaddressedtothePermissionsDepartment,JohnWiley& Sons, Inc.,111RiverStreet,Hoboken,NJ07030,(201)748-6011,fax(201)748-6008,e-mail: [email protected]. Forgeneral informationonourotherproductsandservicespleasecontactourCustomer CareDepartmentwithintheU.S.at877-762-2974,outsidetheU.S.at317-572-3993or fax317-572-4002. 10 9 8 7 6 ISBN 0-7803-3426-4 Library ofCongress Cataloging-in-Publication Data Gregg, John. Ones and zeroes :understanding Boolean algebra, digital circuits, and the logic of sets /John Gregg. p. em. Includes bibliographical references and index. ISBN 0-7803-3426-4 1. Electronic digital computers-Circuits-Design. 2. Logic, Symbolic and mathematical. 3. Algebra, Boolean. 4. Set theory. I. Title. TK7888.4.G74 1998 511.3'24-dc21 97-34932 CIP Contents BEFORE WEBEGIN xiii CHAPTER0 NUMBER SYSTEMS ANDCOUNTING 1 O.1 Numbers: Some Background 1 0.2 TheDecimalSystem:A Closer Look 2 0.3 Other Bases 3 0.4 Converting fromBase7 to Base 10 5 0.5 Converting fromBase 10to Base7 7 0.6 Addition inOther Bases 10 0.7 Counting 12 0.8 TheBinaryNumber System 14 0.9 Combinatoric Examples 16 0.9.1 U.S. Presidential Election Example 16 0.9.2 Pizza Example 16 0.9.3 Hypercube Example 17 0.9.4 Binary Trees 19 CHAPTER 1 THE BASIC FUNCTIONS OFBOOLEAN ALGEBRA: AND,OR,ANDNOT 22 1.1 Boolean Functions 24 1.2 AND 25 vii viii Contents 1.2.1 LogicalInterpretationof Bits 2S 1.2.2 TruthTable for AND 26 1.2.3 Numberingof RowsinTruthTables 27 1.2.4 The Principleof Assertion 28 1.2.5 Some NotationalConventions 28 1.2.6 CircuitSymbolfor AND 29 1.3 OR 30 1.3.1 TruthTable forOR 31 1.3.2 CircuitSymbolforOR 31 1.4 NOT 33 1.4.1 TruthTable for NOT 33 1.4.2 CircuitSymbolfor NOT 34 CHAPTER 2 COMBINATIONAL LOGIC 37 2.1 AND andNOT 37 2.2 GroupingwithParentheses 39 2.3 ANDandORwithMoreThan Two Inputs 47 2.4 AlgebraicExamples ofArbitrary-InputANDandOR Functions 48 2.5 Truth Tables forArbitrary-InputANDandOR Functions 48 2.6 Creating Arbitrary-InputANDandORGates from the Old Two-Input Kind 50 2.7 AnArbitrary-InputANDGate 51 2.8 AnArbitrary-InputORGate 53 CHAPTER 3 THE ALGEBRA OF SETS AND VENN DIAGRAMS 59 3.1 The Set 59 3.2 Venn Diagrams 60 3.3 SetComplementation 61 3.4 The NullSet 62 3.5 Subsets andSupersets 62 3.6 Intersection 63 3.7 Union 65 3.8 Example ofUnion andIntersection 66 Contents ix 3.9 Combinatorics ofVenn Diagrams 66 3.10 Numbering Regions inVenn Diagrams 68 3.11 Combinational Logic inVenn Diagrams 70 3.12 SetAlgebraic Interpretation ofCombinational Logic 71 CHAPTER4 OTHER BOOLEANFUNCTIONS 77 4.1 The Constant Functions 0and1 78 4.2 NAND 79 4.3 NOR 81 4.4 XOR 81 4.5 COIN 84 4.5.1 Interesting Properties of XOR and COIN 86 4.6 Implication 88 4.6.1 Arithmetic Interpretation of Implication 90 4.6.2 Algebraic Realization ofImplication 91 4.6.3 Circuit Symbol for Implication 91 4.6.4 Asymmetry ofthe Implication Function 92 4.6.5 Interpreting Implication of Terms ofthe Algebra of Sets 93 4.7 OtherComplete Systems 96 4.7.1 XOR, NOT, and 1asaCompleteSystem 96 4.7.2 NAND as a Complete System 97 CHAPTER 5 REALIZINGANY BOOLEANFUNCTIONWITH AND, OR, AND NOT 101 5.1 Minterms 101 5.1.1 Decoder Example 104 5.2 Realizing AnyBoolean Function Using Minterms 107 5.3 Sum-of-Products Expressions 109 5.3.1 Realization ofAny Boolean Function Using a Decoder 110 5.4 The Seven-SegmentDisplay 111 5.5 Maxterms 117 x Contents 5.6 Realizing AnyBoolean Function withMaxterms 120 5.7 Product-oF-Sums Expressions 122 5.8 The Three-InputMaiorityVoter 123 CHAPTER 6 MOREDIGiTALCIRCUITS 126 6.1 TheMultiplexer: DataVersus Control 126 6.1.1 AND as Controllable Pass-Through Gate 128 6.1.2 Decoder-Based Realization of the Multiplexer 129 6.1.3 Multiplexer with the Decoder Built In 130 6.1.4 Realizing Any Boolean Function with a Multiplexer 131 6.2 Vectors andParallel Operations 134 6.3 The Adder 137 6.3.1 Adding in Base 10 137 6.3.2 Adding in Base 2 138 6.3.3 The Binary Adder Function 139 6.4 The Comparator 142 6.5 The ALU 145 CHAPTER 7 LAWSOFBOOLEANALGEBRA 150 7.1 Sets ofAxioms 151 7.2 Perfect Induction 152 7.2.1 Special Properties of 0 and 1 IS3 7.2.2 The Complementation Laws 154 7.2.3 The Law ofInvolution ISS 7.2.4 Commutative Laws of AND and OR ISS 7.2.5 Distributive Laws of AND and OR IS6 7.3 Deduction 159 7.4 AllowedManipulations ofBoolean Equations 159 7.4.1 Idempotence 160 7.4.2 Absorption Laws 163 7.4.3 Associativity Laws 164 7.4.4 DeMorgan's Laws 16S 7.5 Principle of Duality 169