1 / 63

Invitation to Computer Science 5 th Edition

Invitation to Computer Science 5 th Edition. Chapter 4 The Building Blocks: Binary Numbers, Boolean Logic, and Gates. Objectives. In this chapter, you will learn about: The binary numbering system Boolean logic and gates Building computer circuits Control circuits. Introduction.

Download Presentation

Invitation to Computer Science 5 th Edition

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. Invitation to Computer Science 5thEdition Chapter 4 The Building Blocks: Binary Numbers, Boolean Logic, and Gates

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

  3. Introduction • Computing agent • Abstract concept representing any object capable of understanding and executing our instructions • Fundamental building blocks of all computer systems • Binary representation • Boolean logic • Gates • Circuits Invitation to Computer Science, 5th Edition 3

  4. The Binary Numbering System • Binary representation of numeric and textual information • Two types of information representation • External representation • Internal representation • Binary is a base-2 positional numbering system Invitation to Computer Science, 5th Edition 4

  5. Figure 4.1 Distinction Between External Memory and Internal Representation of Information Invitation to Computer Science, 5th Edition

  6. Binary Representation of Numeric and Textual Information • Binary-to-decimal algorithm • Whenever there is a 1 in a column, add the positional value of that column to a running sum • Whenever there is a 0 in a column, add nothing • The final sum is the decimal value of this binary number Invitation to Computer Science, 5th Edition

  7. Figure 4.2 Binary-to-Decimal Conversion Table Invitation to Computer Science, 5th Edition

  8. Binary Representation of Numeric and Textual Information (continued) • To convert a decimal value into its binary equivalent • Use the decimal-to-binary algorithm • Maximum number of binary digits that can be used to store an integer: 16, 32, or 64 bits • Arithmetic overflow • Operation that produces an unsigned value greater than 65,535 Invitation to Computer Science, 5th Edition

  9. Signed Numbers • Sign/magnitude notation • One of a number of different techniques for representing positive and negative whole numbers • Not used often in real computer systems • Two’s complement representation • Total number of values that can be represented with n bits is 2n Invitation to Computer Science, 5th Edition

  10. Fractional Numbers • Fractional numbers (12.34 and –0.001275) • Can be represented in binary by using signed-integer techniques • Scientific notation • ±M x B±E • M is the mantissa, B is the exponent base (usually 2), and E is the exponent • Normalize the number • First significant digit is immediately to the right of the binary point Invitation to Computer Science, 5th Edition

  11. Textual Information • Code mapping • Assigning each printable letter or symbol in our alphabet a unique number • ASCII • International standard for representing textual information in the majority of computers • Uses 8 bits to represent each character • UNICODE • Uses a 16-bit representation for characters rather than the 8-bit format of ASCII Invitation to Computer Science, 5th Edition

  12. Figure 4.3 ASCII Conversion Table Invitation to Computer Science, 5th Edition

  13. Binary Representation of Sound and Images • Digitalrepresentation • Values for a given object are drawn from a finite set • Analogrepresentation • Objects can take on any value • Figure 4.4 • Amplitude of the wave: measure of its loudness • Period of the wave (T): time it takes for the wave to make one complete cycle • Frequency f: total number of cycles per unit time Invitation to Computer Science, 5th Edition

  14. Figure 4.4 Example of Sound Represented as a Waveform Invitation to Computer Science, 5th Edition

  15. Binary Representation of Sound and Images (continued) • Sampling rate • Measures how many times per second we sample the amplitude of the sound wave • Bit depth • Number of bits used to encode each sample • MP3 • Most popular and widely used digital audio format • Scanning • Measuring the intensity values of distinct points located at regular intervals across the image’s surface Invitation to Computer Science, 5th Edition

  16. Figure 4.5 Digitization of an Analog Signal (a) Sampling the Original Signal (b) Re-creating the Signal from the Sampled Values Invitation to Computer Science, 5th Edition

  17. Binary Representation of Sound and Images (continued) • Raster graphics • Each pixel is encoded as an unsigned binary value representing its gray scale intensity • RGB encoding scheme • Most common format for storing color images • True Color • 24-bit color-encoding scheme • Data compression algorithms • Attempt to represent information in ways that preserve accuracy while using significantly less space Invitation to Computer Science, 5th Edition

  18. Binary Representation of Sound and Images (continued) • Run-length encoding • Replaces a sequence of identical values v1, v2, . . ., vn by a pair of values (v, n) • Compression ratio • Measures how much compression schemes reduce storage requirements of data • Variable length code sets • Often used to compress text • Can also be used with other forms of data Invitation to Computer Science, 5th Edition

  19. Figure 4.8 Using Variable Length Code Sets (a) Fixed Length (b) Variable Length Invitation to Computer Science, 5th Edition

  20. Binary Representation of Sound and Images (continued) • Lossless compressionschemes • No information is lost in the compression • It is possible to exactly reproduce the original data • Lossy compressionschemes • Do not guarantee that all of the information in the original data can be fully and completely recreated Invitation to Computer Science, 5th Edition

  21. The Reliability of Binary Representation • Computers use binary representation for reasons of reliability • Building a base-10 “decimal computer” • Requires finding a device with 10 distinct and stable energy states that can be used to represent the 10 unique digits (0, 1, . . . , 9) of the decimal system • Bistable environment • Only two (rather than 10) stable states separated by a huge energy barrier Invitation to Computer Science, 5th Edition

  22. Binary Storage Devices • Magnetic cores • Used to construct computer memories • Core • Small, magnetizable, iron oxide-coated “doughnut,” about 1/50 of an inch in inner diameter, with wires strung through its center hole Invitation to Computer Science, 5th Edition

  23. Figure 4.9 Using Magnetic Cores to Represent Binary Values Invitation to Computer Science, 5th Edition

  24. Binary Storage Devices (continued) • Transistor • Solid-state device that has no mechanical or moving parts • Constructed from semiconductors • Can be printed photographically on a wafer of silicon to produce a device known as an integrated circuit • Circuit board • Interconnects all the different chips needed to run a computer system Invitation to Computer Science, 5th Edition

  25. Figure 4.10 Relationships Among Transistors, Chips, and Circuit Boards Invitation to Computer Science, 5th Edition

  26. Binary Storage Devices (continued) • Mask • Can be used to produce a virtually unlimited number of copies of a chip • Figure 4.11 • Control (base): used to open or close the switch inside the transistor • ON state: current coming from the In line (Collector) can flow directly to the Out line (Emitter), and the associated voltage can be detected by a measuring device Invitation to Computer Science, 5th Edition

  27. Figure 4.11 Simplified Model of a Transistor Invitation to Computer Science, 5th Edition

  28. Boolean Logic • Boolean logic • Construction of computer circuits is based on this • Boolean expression • Any expression that evaluates to either true or false • Truth table • Can express the idea that the AND operation produces the value true if and only if both of its components are true Invitation to Computer Science, 5th Edition

  29. Figure 4.12 Truth Table for the AND Operation Invitation to Computer Science, 5th Edition

  30. Boolean Logic (continued) • Boolean operations • AND, OR, NOT • Binary operators • Require two operands • Unary operator • Requires only one operand • NOT operation • Reverses, or complements, the value of a Boolean expression Invitation to Computer Science, 5th Edition

  31. Figure 4.13 Truth Table for the OR Operation Invitation to Computer Science, 5th Edition

  32. Figure 4.14 Truth Table for the NOT Operation Invitation to Computer Science, 5th Edition

  33. Gates • Gate • Electronic device that operates on a collection of binary inputs to produce a binary output • Transforms a set of (0,1) input values into a single (0,1) output value • NOT gate • Can be constructed from a single transistor • To construct an AND gate • Connect two transistors in series with the collector line of transistor 1 connected to the power supply (logical-1) and the emitter line of transistor 2 connected to ground (logical-0) Invitation to Computer Science, 5th Edition

  34. Figure 4.15 The Three Basic Gates and Their Symbols Invitation to Computer Science, 5th Edition

  35. Figure 4.16 Construction of a NOT Gate Invitation to Computer Science, 5th Edition

  36. Figure 4.17 Construction of NAND and AND Gates (a) A Two-transistor NAND Gate (b) A Three-transistor AND Gate Invitation to Computer Science, 5th Edition

  37. Gates (continued) • NAND (acronym for NOT AND) • Produces the complement of the AND operation • To construct an OR gate • Start with two transistors • Transistors are connected in parallel Invitation to Computer Science, 5th Edition

  38. Figure 4.18 Construction of NOR and OR Gates (a) A Two-transistor NOR Gate (b) A Three-transistor OR Gate Invitation to Computer Science, 5th Edition

  39. Building Computer Circuits • Introduction • Circuit:collection of logic gates that transforms a set of binary inputs into a set of binary outputs • Every Boolean expression: • Can be represented pictorially as a circuit diagram • Every output value in a circuit diagram: • Can be written as a Boolean expression Invitation to Computer Science, 5th Edition

  40. Figure 4.19 Diagram of a Typical Computer Circuit Invitation to Computer Science, 5th Edition

  41. A Circuit Construction Algorithm • Step 1: Truth Table Construction • Determine how the circuit should behave under all possible circumstances • If a circuit has N input lines and if each input line can be either a 0 or a 1, then: • There are 2Ncombinations of input values, and the truth table has 2Nrows Invitation to Computer Science, 5th Edition

  42. A Truth Table for a Circuit with 8 Input Combinations Invitation to Computer Science, 5th Edition

  43. A Circuit Construction Algorithm (continued) • Step 2: Subexpression Construction Using AND and NOT Gates • Choose any one output column of the truth table built in step 1, and scan down that column • Every place that you find a 1 in that output column, you build a Boolean subexpression that produces the value 1 for exactly that combination of input values and no other Invitation to Computer Science, 5th Edition

  44. Output Column Labeled Output-1 from the Previous Truth Table Invitation to Computer Science, 5th Edition

  45. Taking Snapshots • Step 3: Subexpression Combination Using OR Gates • Take each of the subexpressions produced in step 2 and combine them, two at a time, using OR gates • Step 4: Circuit Diagram Production • Construct the final circuit diagram • Algorithms for circuit optimization • Reduce the number of gates needed to implement a circuit Invitation to Computer Science, 5th Edition

  46. Figure 4.20 Circuit Diagram for the Output Labeled Output-1 Invitation to Computer Science, 5th Edition

  47. Figure 4.21 The Sum-of-Products Circuit Construction Algorithm Invitation to Computer Science, 5th Edition

  48. Examples of Circuit Design and Construction • A Compare-For-Equality Circuit • Tests two unsigned binary numbers for exact equality • Produces the value 1 (true) if the two numbers are equal and the value 0 ( false) if they are not Invitation to Computer Science, 5th Edition

  49. Figure 4.22 One-Bit Compare for Equality Circuit Invitation to Computer Science, 5th Edition

  50. Figure 4.23 N-Bit Compare for Equality Circuit Invitation to Computer Science, 5th Edition

More Related