Chapter 4: The Building Blocks: Binary Numbers, Boolean Logic, and Gates Invitation to Computer Science, C++ Version, Fourth Edition
Invitation to Computer Science, C++ Version, Fourth Edition 2 Objectives In this chapter, you will learn about The binary numbering system Boolean logic and gates Building computer circuits
Invitation to Computer Science, C++ Version, Fourth Edition 3
Learn 3 basic circuit symbols to design simple circuits. bols.html bols.html Invitation to Computer Science, C++ Version, Fourth Edition 4
You should be able to design this. Invitation to Computer Science, C++ Version, Fourth Edition 5
We will learn binary numbering system. Why does the computer use binary digit (0 and 1)? Homework assignment: Read the book to find out why (Section 4.2.3). Invitation to Computer Science, C++ Version, Fourth Edition 6
7 How to convert a decimal to a binary number? 5 10 = = 111 2
Invitation to Computer Science, C++ Version, Fourth Edition 8 Quiz 9 10 = ______ = _____ = _____ 2
Invitation to Computer Science, C++ Version, Fourth Edition 9 How to convert a binary to a decimal number? = ans: 1* * * * 20 = = 10
Invitation to Computer Science, C++ Version, Fourth Edition = ans: 1* * * * 20 = = 14
Invitation to Computer Science, C++ Version, Fourth Edition 11 Quiz = _______________ = ___________ = ___________ 10
Invitation to Computer Science, C++ Version, Fourth Edition 12 Binary Addition
Invitation to Computer Science, C++ Version, Fourth Edition 13 ASCII Table: 8-bit Decimal Octal Hex Binary Value A B C D E F G H I What is the binary representation of the character string “BAD”?
Book Exercises P Do 3a 3b. 4a. 4b. 7. 9a Invitation to Computer Science, C++ Version, Fourth Edition 14
Invitation to Computer Science, C++ Version, Fourth Edition 15 AND Truth Table T AND T is T T AND F is F F AND F is F F AND T is F _____(T/F) Assume that a=1, b=2, and c=3. The value of the following Boolean expression is TRUE. (a > 1) AND ( b > c)
Invitation to Computer Science, C++ Version, Fourth Edition 16 Quiz _____(T/F) Assume that a=1, b=2, and c=3. The value of the following Boolean expression is TRUE. (a c) _____(T/F) Assume that a=1, b=2, and c=3. The value of the following Boolean expression is TRUE. (a > 1) AND ( b < c)
Invitation to Computer Science, C++ Version, Fourth Edition 17 Circuit Symbol AND gate. If A is True and B is False, then what is output? ________
Invitation to Computer Science, C++ Version, Fourth Edition 18 If A is False and B is False, then what is output of C? ________
Invitation to Computer Science, C++ Version, Fourth Edition 19 OR truth table T OR T is T T OR F is T F OR F is F F OR T is T Assume that a=2, b=3, and c=5. What is the value of each of the following Boolean expressions?______ (a> 1) OR (b = 3)
Invitation to Computer Science, C++ Version, Fourth Edition 20 Circuit Symbol OR gate. Apply the OR truth table What is the output of C if A is True and B is false? _____
Invitation to Computer Science, C++ Version, Fourth Edition 21 What is the output of C if A is True and B is false? _____
Invitation to Computer Science, C++ Version, Fourth Edition 22 NOT truth table NOT T is F NOT F is T 1. Assume that a=2, b=3, and c=5. What is the value of each of the following Boolean expressions? 2. NOT (a > 1)
Invitation to Computer Science, C++ Version, Fourth Edition Assume that a=2, b=3, and c=5. What is the value of each of the following Boolean expressions? 2. NOT [(a > 1) AND (b < 3)] 3. (a > 1) AND [NOT (b < 3)]
Invitation to Computer Science, C++ Version, Fourth Edition 24 What is the output of C if A is False and B is False?______
Book Exercises. P.184. Do 15a, 15b, 15c, 15d 17. Invitation to Computer Science, C++ Version, Fourth Edition 25
Invitation to Computer Science, C++ Version, Fourth Edition 26 How to use sum-of-product algorithm to design a combinational circuit for a given truth table? Step 1. Given Mysterious Truth Table: AB Output 110 000 101 011 Step 2. Write a sum-of-product Boolean Expression _ _ A.B + A. B _ Note: The ‘.’ of the expression A. B means A and B. _ The bar A means A is fed to a gate with a false value, The ‘+’ of the expression X + Y means X and Y are fed to the OR Gate
Invitation to Computer Science, C++ Version, Fourth Edition 27 step 3: Draw a combinational circuit.
Invitation to Computer Science, C++ Version, Fourth Edition 28 Quiz: Given Mysterious Truth Table: AB Output Write the sum-of-product Boolean expression: Draw the combinational circuit diagram:
Invitation to Computer Science, C++ Version, Fourth Edition 29 Characters are mapped onto binary numbers ASCII code set 8 bits per character; 256 character codes UNICODE code set 16 bits per character; 65,536 character codes Text strings are sequences of characters in some encoding Binary Representation of Numeric and Textual Information (continued)
Invitation to Computer Science, C++ Version, Fourth Edition 30 Binary Representation of Sound and Images Multimedia data is sampled to store a digital form with or without detectable differences Representing sound data Sound data must be digitized for storage in a computer Digitizing means periodic sampling of amplitude values
Invitation to Computer Science, C++ Version, Fourth Edition 31 Binary Representation of Sound and Images (continued) From samples, original sound can be approximated To improve the approximation Sample more frequently Use more bits for each sample value
Invitation to Computer Science, C++ Version, Fourth Edition 32 Figure 4.5 Digitization of an Analog Signal (a) Sampling the Original Signal (b) Recreating the Signal from the Sampled Values
Invitation to Computer Science, C++ Version, Fourth Edition 33 Representing image data Images are sampled by reading color and intensity values at even intervals across the image Each sampled point is a pixel Image quality depends on number of bits at each pixel Binary Representation of Sound and Images (continued)
Invitation to Computer Science, C++ Version, Fourth Edition 34 The Reliability of Binary Representation Electronic devices are most reliable in a bistable environment Bistable environment Distinguishing only two electronic states Current flowing or not Direction of flow Computers are bistable: binary representations
Invitation to Computer Science, C++ Version, Fourth Edition 35 Magnetic core Historic device for computer memory Tiny magnetized rings; flow of current sets the direction of magnetic field Binary values 0 and 1 are represented using the direction of the magnetic field Binary Storage Devices
Invitation to Computer Science, C++ Version, Fourth Edition 36 Figure 4.9 Using Magnetic Cores to Represent Binary Values
Invitation to Computer Science, C++ Version, Fourth Edition 37 Transistors Solid-state switches; either permit or block current flow A control input causes state change Constructed from semiconductors Binary Storage Devices (continued)
Invitation to Computer Science, C++ Version, Fourth Edition 38 Figure 4.11 Simplified Model of a Transistor
Invitation to Computer Science, C++ Version, Fourth Edition 39 Boolean Logic and Gates: Boolean Logic Boolean logic describes operations on true/false values True/false maps easily onto bistable environment Boolean logic operations on electronic signals can be built out of transistors and other electronic devices
Invitation to Computer Science, C++ Version, Fourth Edition 40 Boolean Logic (continued) Boolean operations a AND b True only when a is true and b is true a OR b True when a is true, b is true, or both are true NOT a True when a is false and vice versa
Invitation to Computer Science, C++ Version, Fourth Edition 41 Boolean expressions Constructed by combining together Boolean operations Example: (a AND b) OR ((NOT b) AND (NOT a)) Truth tables capture the output/value of a Boolean expression A column for each input plus the output A row for each combination of input values Boolean Logic (continued)
Invitation to Computer Science, C++ Version, Fourth Edition 42 abValue Example: (a AND b) OR ((NOT b) and (NOT a)) Boolean Logic (continued)
Invitation to Computer Science, C++ Version, Fourth Edition 43 Gates Hardware devices built from transistors to mimic Boolean logic AND gate Two input lines, one output line Outputs a 1 when both inputs are 1
Invitation to Computer Science, C++ Version, Fourth Edition 44 Gates (continued) OR gate Two input lines, one output line Outputs a 1 when either input is 1 NOT gate One input line, one output line Outputs a 1 when input is 0 and vice versa
Invitation to Computer Science, C++ Version, Fourth Edition 45 Figure 4.15 The Three Basic Gates and Their Symbols
Invitation to Computer Science, C++ Version, Fourth Edition 46 Abstraction in hardware design Map hardware devices to Boolean logic Design more complex devices in terms of logic, not electronics Conversion from logic to hardware design can be automated Gates (continued)
Invitation to Computer Science, C++ Version, Fourth Edition 47 Building Computer Circuits: Introduction A circuit is a collection of logic gates Transforms a set of binary inputs into a set of binary outputs Values of the outputs depend only on the current values of the inputs Combinational circuits have no cycles in them (no outputs feed back into their own inputs)
Invitation to Computer Science, C++ Version, Fourth Edition 48 Figure 4.19 Diagram of a Typical Computer Circuit
Invitation to Computer Science, C++ Version, Fourth Edition 49 A Circuit Construction Algorithm Sum-of-products algorithm is one way to design circuits Truth table to Boolean expression to gate layout
Invitation to Computer Science, C++ Version, Fourth Edition 50 Figure 4.21 The Sum-of-Products Circuit Construction Algorithm
Invitation to Computer Science, C++ Version, Fourth Edition 51 Sum-of-products algorithm Truth table captures every input/output possible for circuit Repeat process for each output line Build a Boolean expression using AND and NOT for each 1 of the output line Combine together all the expressions with ORs Build circuit from whole Boolean expression A Circuit Construction Algorithm (continued)