Chapter 4: The Building Blocks: Binary Numbers, Boolean Logic, and Gates - PowerPoint PPT Presentation

1 / 58
About This Presentation
Title:

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

Description:

Conversion Table. Representing integers. Decimal integers are converted to binary integers ... Truth table captures every input/output possible for circuit ... – PowerPoint PPT presentation

Number of Views:169
Avg rating:3.0/5.0
Slides: 59
Provided by: csg3
Category:

less

Transcript and Presenter's Notes

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


1
Chapter 4 The Building Blocks Binary Numbers,
Boolean Logic, and Gates
  • Invitation to Computer Science,
  • Java Version, Third Edition

2
Objectives
  • In this chapter, you will learn about
  • The binary numbering system
  • Boolean logic and gates
  • Building computer circuits
  • Control circuits

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

4
The Binary Numbering System
  • A computers 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

5
Binary Representation of Numeric and Textual
Information
  • Binary numbering system (Computer)
  • 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 (Daily Life)
  • Base-10
  • Each position is a power of 10
  • 3052 3 x 103 0 x 102 5 x 101 2 x 100

6
  • Figure 4.2
  • Binary-to-Decimal
  • Conversion Table

7
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

8
Binary Representation of Numeric and Textual
Information (continued)
  • How to express signed integer?
  • Sign/Magnitude notation (old computer)
  • Two's complement notation (current computer)

9
Sign/Magnitude notation
  • 1(sign bit) 110001 (total 7 bits, computer A)
  • When it is a signed value, it is -49
  • When it is a unsigned value, it is 113
  • 1(sign bit) 0110001 (total 8 bits, computer B)
  • When it is a signed value, it is -49
  • When it is a unsigned value, it is 177
  • You must tell the computer if it is signed or
    unsigned integer. The number of bit depends on
    computer (8bit, 16bit, 32bit, 64bit)

10
Two's complement notation
  • Why we have this solution?
  • Because of two zeros problem in Sign/Magnitude
    notation 10000, 00000
  • if (a b)
  • do operation 1
  • else
  • do operation 2

11
Two's complement notation
  • If A gt 0
  • then do nothing
  • else
  • get complement value of each bit
  • a lt- a1
  • Eg -3 (3bit) 3 -gt 011 -gt 100 -gt 101
  • -3 (4bit) 3 -gt 0011 -gt 1100 -gt 1101
  • The number of bit depends on computer (8bit,
    16bit, 32bit, 64bit)
  • Easier method Get complement value of each bit
    until first 1
  • Eg -3 (3bit) 3-gt 011 -gt 101
  • -3 (4bit) 3 -gt 0011 -gt 1101
  • No substraction in twos complement notation.
    Convert to complement value.
  • Eg 5 3 5 (-3)

12
Two's complement notation
  • Bit pattern Decimal Value
  • 001 1
  • 010 2
  • 011 3
  • 100 -4
  • 101 -3
  • 110 -2
  • 111 -1

13
Compare value range
  • Suppose we have k bit.
  • Sign/Magnitude notation -(2k-1 1) to (2k-1
    1)
  • Eg 3bit -3 3
  • Two's complement notation -(2k-1) to (2k-1 1)
  • Eg 3bit -4 3
  • Why different?
  • Because Sign/Magnitude notation has two zeros
    while twos complement notation has only one
    zero.
  • Though twos complement notation is difficult to
    human, it much clearer to computer.

14
Binary lt-gt Decimal (Fractional number)
  • Binary -gt Decimal 0.1101 12-1 12-2 02-3
    12-4 0.5 0.25 0 0.0625 0.8125
  • Decimal -gt Binary 0.8125
  • 0.8125 2 1.625 ------ Get 1
  • 0.625 2 1.25 ------ Get 1
  • 0.25 2 0.5 ------ Get 0
  • 0.5 2 1 ------ Get 1
  • Final 0.1101 (Attention compare to integer
    conversion)

15
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

16
Normalization Example
  • Binary Normalization
  • 5.75 101.11 0.10111 23
  • Mantissa and exponent then stored
  • M B E
  • 5.75 101.11 0.010111 24 1.0111 22
  • 0.010111 24 and 1.0111 22 are not
    normalized number

17
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

18
Binary Representation of Sound and Images
  • Multimedia data is sampled to store a digital
    form
  • Representing sound data
  • Sound data must be digitized for storage in a
    computer
  • Digitizing means periodic sampling of amplitude
    values

19
  • Figure 4.5
  • Digitization of an Analog Signal
  • (a) Sampling the Original
  • Signal
  • (b) Recreating the
  • Signal from the Sampled
  • Values

20
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

21
Binary Representation of Sound and Images
(continued)
  • Representing image data
  • Images are sampled by reading color and intensity
    values
  • Each sampled point is a pixel
  • Image quality depends on number of bits at each
    pixel

22
Data Compression
  • Why we need data compression?
  • Because the original data need too much space.
    Eg. 3,000,000 pixels/photograph 24 bits/pixel
    72million bits.
  • Simple compression method run length
    encoding for image compression
  • Eg. (255 255 255), (255, 0, 0), (255, 255, 255),
    (255, 0, 0), (255, 255, 255) ? (255, 4), (0, 2),
    (255, 4), (0, 2), (255, 3)

23
Data Compression
  • Simple compression method - variable length code
    sets - for text compress
  • Letter 4 bit encoding Variable length encoding
  • A 0000 00
  • I 0001 10
  • H 0010 010
  • W 0100 110
  • H A W A I I ? 0010, 0000, 0100, 0000, 0001, 0001
    ? 001, 00, 110, 00, 10, 10

24
Data Compression
  • Compression rate size of the uncompressed data
    / size of the compressed data
  • Lossless compression
  • Lossy compression

25
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

26
Binary Storage Devices
  • 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

27
  • Figure 4.9
  • Using Magnetic Cores to Represent Binary Values

28
Binary Storage Devices (continued)
  • Transistors
  • Solid-state switches either permit or block
    current flow
  • A control input causes state change
  • Constructed from semiconductors

29
  • Figure 4.11
  • Simplified Model of a Transistor

30
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

31
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

32
Boolean Logic (continued)
  • 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

33
Boolean Logic (continued)
  • Example
  • (a AND b) OR ((NOT b) and (NOT a))

34
Gates
  • 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

35
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

36
  • Figure 4.15
  • The Three Basic Gates and Their Symbols

37
Gates (continued)
  • 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

38
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)

39
  • Figure 4.19
  • Diagram of a Typical Computer Circuit

40
A Circuit Construction Algorithm
  • Sum-of-products algorithm is one way to design
    circuits
  • Truth table to Boolean expression to gate layout

41
  • Figure 4.21
  • The Sum-of-Products Circuit Construction Algorithm

42
A Circuit Construction Algorithm (continued)
  • 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

43
Examples of Circuit Design and Construction
  • Compare-for-equality circuit
  • Addition circuit
  • Both circuits can be built using the
    sum-of-products algorithm

44
A Compare-for-Equality Circuit
  • Compare-for-equality circuit
  • CE compares two unsigned binary integers for
    equality
  • Built by combining together 1-bit comparison
    circuits (1-CE)
  • Integers are equal if corresponding bits are
    equal (AND together 1-CD circuits for each pair
    of bits)

45
A Compare-for-Equality Circuit (continued)
  • 1-CE circuit truth table

46
  • Figure 4.22
  • One-Bit Compare-for-Equality Circuit

47
A Compare-for-Equality Circuit (continued)
  • 1-CE Boolean expression
  • First case (NOT a) AND (NOT b)
  • Second case a AND b
  • Combined
  • ((NOT a) AND (NOT b)) OR (a AND b)

48
An Addition Circuit
  • Addition circuit
  • Adds two unsigned binary integers, setting output
    bits and an overflow
  • Built from 1-bit adders (1-ADD)
  • Starting with rightmost bits, each pair produces
  • A value for that order
  • A carry bit for next place to the left

49
An Addition Circuit (continued)
  • 1-ADD truth table
  • Input
  • One bit from each input integer
  • One carry bit (always zero for rightmost bit)
  • Output
  • One bit for output place value
  • One carry bit

50
  • Figure 4.24
  • The 1-ADD Circuit and Truth Table

51
An Addition Circuit (continued)
  • Building the full adder
  • Put rightmost bits into 1-ADD, with zero for the
    input carry
  • Send 1-ADDs output value to output, and put its
    carry value as input to 1-ADD for next bits to
    left
  • Repeat process for all bits

52
Control Circuits
  • Do not perform computations
  • Choose order of operations or select among data
    values
  • Major types of controls circuits
  • Multiplexors
  • Select one of inputs to send to output
  • Decoders
  • Sends a 1 on one output line based on what input
    line indicates

53
Control Circuits (continued)
  • Multiplexor form
  • 2N regular input lines
  • N selector input lines
  • 1 output line
  • Multiplexor purpose
  • Given a code number for some input, selects that
    input to pass along to its output
  • Used to choose the right input value to send to a
    computational circuit

54
  • Figure 4.28
  • A Two-Input Multiplexor Circuit

55
Control Circuits (continued)
  • Decoder
  • Form
  • N input lines
  • 2N output lines
  • N input lines indicate a binary number, which is
    used to select one of the output lines
  • Selected output sends a 1, all others send 0

56
Control Circuits (continued)
  • Decoder purpose
  • Given a number code for some operation, trigger
    just that operation to take place
  • Numbers might be codes for arithmetic (add,
    subtract, and so on)
  • Decoder signals which operation takes place next

57
  • Figure 4.29
  • A 2-to-4 Decoder Circuit

58
Summary
  • Digital computers use binary representations of
    data numbers, text, multimedia
  • Binary values create a bistable environment,
    making computers reliable
  • Boolean logic maps easily onto electronic
    hardware
  • Circuits are constructed using Boolean
    expressions as an abstraction
  • Computational and control circuits can be built
    from Boolean gates
Write a Comment
User Comments (0)
About PowerShow.com