1 / 92

Chapter 4: The Building Blocks: Binary Numbers, Boolean Logic, and Gates

Learn about Boolean logic and gates, the binary numbering system, building computer circuits, and control circuits in this chapter.

jlint
Download Presentation

Chapter 4: The Building Blocks: Binary Numbers, Boolean Logic, and Gates

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Chapter 4: The Building Blocks: Binary Numbers, Boolean Logic, and Gates Invitation to Computer Science, C++ Version, Third Edition

  2. Objectives In this chapter, you will learn about: • Boolean logic and gates • The binary numbering system • Building computer circuits • Control circuits Invitation to Computer Science, C++ Version, Third Edition

  3. Introduction • Chapter 4 focuses on hardware design (also called logic design) • How to represent and store information inside a computer • How to use the principles of symbolic logic to design gates • How to use gates to construct circuits that perform operations such as adding and comparing numbers, and fetching instructions Invitation to Computer Science, C++ Version, Third Edition

  4. The Reliability of Binary Representation Sec 4.2.3 • Electronic devices are most reliable in a bistable environment • Bistable environment • Distinguishes only two electronic states • Current flowing or not • Direction of flow • Easiest way to make computers reliable was to use a two-state design. Hence they are designed to store and process binary information. Invitation to Computer Science, C++ Version, Third Edition

  5. Binary Storage Devices Sec 4.2.4 • 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 Invitation to Computer Science, C++ Version, Third Edition

  6. Sec 4.2.4 Figure 4.9 Using Magnetic Cores to Represent Binary Values Invitation to Computer Science, C++ Version, Third Edition

  7. Binary Storage Devices (continued) Sec 4.2.4 • Transistors • Solid-state switches: either permits or blocks current flow • A control input causes state change • Constructed from semiconductors Invitation to Computer Science, C++ Version, Third Edition

  8. Sec 4.2.4 Figure 4.11 Simplified Model of a Transistor Invitation to Computer Science, C++ Version, Third Edition

  9. Sec 4.2.4 Invitation to Computer Science, C++ Version, Third Edition

  10. Sec 4.2.4 Invitation to Computer Science, C++ Version, Third Edition

  11. Boolean Logic and Gates: Boolean Logic Sec 4.3.1 • Boolean logic is a branch of mathematics which describes operations on objects with two possible values, True or False • True/False values map easily onto a two-state electronic environment. • Boolean logic operations may be performed on electronic signals using devices built out of transistors and other electronic devices. Invitation to Computer Science, C++ Version, Third Edition

  12. Boolean Logic (continued) Sec 4.3.1 • Let a and b represent objects with two possible values, true and false • Boolean logic operations • a AND b • True only when a is true and b is true • a OR b • True when either a is true or b is true, or both are true • NOT a • True when a is false, and vice versa Invitation to Computer Science, C++ Version, Third Edition

  13. Boolean Logic (continued) Sec 4.3.1 • 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 Invitation to Computer Science, C++ Version, Third Edition

  14. Boolean Logic (continued) Sec 4.3.1 • Example:(a AND b) OR ((NOT b) and (NOT a))_ _alternate expression (a ∙ b) + ( b ∙ a ) Invitation to Computer Science, C++ Version, Third Edition

  15. Gates Sec 4.3.2 • Gates • Hardware devices built from transistors to mimic Boolean logical operations on digital electrical signals • AND gate • Two input lines, one output line • Outputs a 1 when both inputs are 1 Invitation to Computer Science, C++ Version, Third Edition

  16. Gates (continued) Sec 4.3.2 • 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, Third Edition

  17. Sec 4.3.1 Figure 4.15 The Three Basic Gates and Their Symbols Invitation to Computer Science, C++ Version, Third Edition

  18. Sec 4.3.2 NAND gate AND gate Invitation to Computer Science, C++ Version, Third Edition

  19. Sec 4.3.2 NOR gate OR gate Invitation to Computer Science, C++ Version, Third Edition

  20. Gates (continued) Sec 4.3.2 • Abstraction in hardware design • Transform hardware devices to Boolean logical descriptions • Design more complex devices in terms of logic, not electronics • Conversion from logic to hardware design may be automated Invitation to Computer Science, C++ Version, Third Edition

  21. Sec 4.4.1 Figure 4.19 Diagram of a Typical Computer Circuit Invitation to Computer Science, C++ Version, Third Edition

  22. Building Computer Circuits: Introduction Sec 4.4.1 • 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, Third Edition

  23. Invitation to Computer Science, C++ Version, Third Edition

  24. Invitation to Computer Science, C++ Version, Third Edition

  25. Building Computer Circuits: Intro Cont’d. Sec 4.4.1 We want a 1 only when both inputs are 0. Is there a gate which will do this? An AND gate gives a 1 only when both inputs are 1. An OR gate gives a 1 whenever at least one input is 1 Could we use an AND gate or an OR gate somehow? Invitation to Computer Science, C++ Version, Third Edition

  26. A Circuit Construction Algorithm Sec 4.4.2 • Sum-of-products algorithm is one way to design circuits: • Truth table to Boolean expression to gate layout Invitation to Computer Science, C++ Version, Third Edition

  27. Sec 4.4.2 Figure 4.21 The Sum-of-Products Circuit Construction Algorithm Invitation to Computer Science, C++ Version, Third Edition

  28. A Circuit Construction Algorithm (continued) Sec 4.4.2 • 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 Invitation to Computer Science, C++ Version, Third Edition

  29. The Binary Numbering System • A computer’s internal storage techniques are different from the way people represent information in daily lives • Information inside a digital computer is stored as a collection of binary data Invitation to Computer Science, C++ Version, Third Edition

  30. Binary Representation of Numeric and Textual Information • Binary numbering system • Base-2 • Built from ones and zeros • Each position is a power of 2 1101 = 1 x 23 + 1 x 22 + 0 x 21 + 1 x 20 • Decimal numbering system • Base-10 • Each position is a power of 10 3052 = 3 x 103 + 0 x 102 + 5 x 101 + 2 x 100 Invitation to Computer Science, C++ Version, Third Edition

  31. Figure 4.2 Binary-to-Decimal Conversion Table Invitation to Computer Science, C++ Version, Third Edition

  32. Taxonomy of Integers Invitation to Computer Science, C++ Version, Third Edition

  33. Binary Representation of Numeric and Textual Information (continued) • Representing integers • Decimal integers are converted to binary integers • Given k bits, the largest unsigned integer is 2k - 1 • Given 4 bits, the largest is 24-1 = 15 • Signed integers must also represent the sign (positive or negative) Invitation to Computer Science, C++ Version, Third Edition

  34. Binary to Decimal Conversion Invitation to Computer Science, C++ Version, Third Edition

  35. Decimal to Binary Conversion Invitation to Computer Science, C++ Version, Third Edition

  36. Two’s Complement Representation of Signed Integers • Used by almost all computers today • All places hold the value they would in binary except for the leftmost place which is negative • 8 bit integer: -128 64 32 16 8 4 2 1 • Range: [-128,127] • If last bit (leftmost) • is 0, then positive  looks just as before • is 1, then negative add values for first 7 digits and then subtract 128 • 1000 1101 = 1+4+8-128 = -115 Invitation to Computer Science, C++ Version, Third Edition

  37. Two’s Complement Representation of Signed Integers • Converting from decimal to 2’s complement • For positive numbers: find the binary representation • For negative numbers: • Find the binary representation for its positive equivalent • Flip all bits • Add a 1 • 43 • 43 = 0010 1011 • -43 • 43 = 0010 1011  1101 0100  1101 0101 • 1101 0101 = -128+64+16+4+1 = -43 • We can use the usual laws of binary addition Invitation to Computer Science, C++ Version, Third Edition

  38. Two’s Complement Representation • 125 - 19 = 106 • 0111 1101 1110 1101 ------------- 0110 1010 = 106 ! • What happened to the one that we carried at the end? • Got lost but still we got the right answer! • We carried into and carried out of the leftmost column Invitation to Computer Science, C++ Version, Third Edition

  39. Binary Representation of Numeric and Textual Information (continued) • Representing real numbers • Real numbers may be put into binary scientific notation: a x 2b • Example: 101.11 x 20 • Number then normalized so that first significant digit is immediately to the right of the binary point • Example: .10111 x 23 • Mantissa and exponent then stored Invitation to Computer Science, C++ Version, Third Edition

  40. Binary Representation of Numeric and Textual Information (continued) Invitation to Computer Science, C++ Version, Third Edition

  41. Converting Decimal Fractions To Binary Invitation to Computer Science, C++ Version, Third Edition

  42. Converting Decimal Fractions To Binary • Note that the binary representation of 0.410 is a repeating base two fraction, .01102 • This just says that 0.4 cannot be exactly represented as a sum of inverse powers of two. • .875 = • .400 = Invitation to Computer Science, C++ Version, Third Edition

  43. Binary Representation of Textual Information • Many transformations exist and all are arbitrary • Two popular • EBCDIC (Extended Binary Coded Decimal Interchange Code) by IBM • ASCII (American Standard Code for Information Interchange) by American National Standards Institute (ANSI) • Most widely used • Every letter/symbol is represented by 7 bits • How many letters/symbols do we have in total? • A-Z (26) , a-z (26) , 0-9 (10), symbols (33), control characters (33) • If using 1 byte/character  we have one extra bit • Extended ASCII-8 (more mathematical and graphical symbols or phonetic marks) --- 256 Invitation to Computer Science, C++ Version, Third Edition

  44. Binary Representation of Numeric and Textual Information (continued) • 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 Invitation to Computer Science, C++ Version, Third Edition

  45. Invitation to Computer Science, C++ Version, Third Edition

  46. Binary Representation of Images • 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 Invitation to Computer Science, C++ Version, Third Edition

  47. Binary Representation of Images • Divide the screen into a grid of cells each referred to as a pixel 512*256 image grid has 512 columns and 256 rows • Pixel values and sizes depend on the type of the image • For black & white images, we can use 1 bit for every pixel such that 1  black and 0  white • For grayscale images, we use 1 byte where 255  black and 0  white and anything in between is gray (higher/lower values are closer to black/white) • For color images, we need three values per pixel (depends on the color scheme used): • Red/Green/Blue • We need 1 byte per value  3 bytes per pixel • For an 512x256 image • 512x256x3 = 384K bytes Invitation to Computer Science, C++ Version, Third Edition

  48. Invitation to Computer Science, C++ Version, Third Edition

  49. Invitation to Computer Science, C++ Version, Third Edition

  50. Invitation to Computer Science, C++ Version, Third Edition

More Related