Computer Organization - PowerPoint PPT Presentation

1 / 260
About This Presentation
Title:

Computer Organization

Description:

Computer Organization It describes the function and design of the various units of digital computers that store and process information. It also deals with the units ... – PowerPoint PPT presentation

Number of Views:3360
Avg rating:3.0/5.0
Slides: 261
Provided by: sni66
Category:

less

Transcript and Presenter's Notes

Title: Computer Organization


1
Computer Organization
  • It describes the function and design of the
    various units of digital computers that store and
    process information.
  • It also deals with the units of computer that
    receive information from external sources and
    send computed results to external destinations

2
Computer Organization Computer Architecture
  • Computer Organization and Computer
    Architecture are the terms used in describing
    digital computer systems.
  • Computer architecture deals with the instruction
    sets, address fields, operation codes, addressing
    modes, effective utilization of I/O mechanisms
    and such other aspects which would interest the
    users of computers.
  • Computer organization include hardware details
    such as generation of control signals, interface
    between the computer and peripherals, memory
    technologies used, modular design, flow of data,
    control mechanisms and so on.
  • In brief, a programmer is generally more
    concerned about the architectural features and a
    designer of computer systems is more concerned
    about the organizational aspects.

3
Computer types
  • Digital computer
  • It is a fast electronic calculating machine that
    accepts digitized input information, processes it
    according to a list of internally stored
    instructions, and produces the resulting output
    information.
  • (1) Personal computer
  • It is the most common form of desktop computers.
  • Desk top computers have processing and storage
    units, visual display and audio output units, and
    a keyboard that can all be located easily on a
    home or office desk. The storage media include
    hard disks, CD-ROMs and diskettes.
  • Portable notebook computers are a compact version
    of the personal computers with all of these
    components packaged into single unit the size of
    a thin briefcase

4
Computer types (contd.,)
  • (2) Workstations
  • Work stations with high resolution graphics
    input/output capability, although still retaining
    the dimensions of desktop computers, have
    significantly more computational power than
    personal computers.
  • Workstations are often used in engineering
    applications, especially for interactive design
    works.
  • (3) Enterprise systems or mainframes
  • These are used for business data processing in
    medium to large corporations that require much
    more computing power and storage capacity than
    workstations can provide.

5
Computer types (contd.,)
  • 4) Servers
  • Servers contain sizable database storage units
    and are capable of handling large volumes of
    requests to access the data.
  • The Internet and its associated servers have
    become a dominant world wide source of all types
    of information.
  • 5) Super Computers
  • Super Computers are used for the large scale
    numerical calculations required in applications
    such as weather forecasting, aircraft design and
    simulation.

6
Functional units
  • A computer consists of five functionally
    independent main parts
  • Input unit
  • Memory unit
  • Arithmetic and logic unit (ALU)
  • Output unit
  • Control unit
  • The structure of a digital computer is shown
    below

7
(No Transcript)
8
Operation of a computer
  • The computer accepts information in the form of
    programs and data through an input unit and
    stores it in the memory.
  • Information stored in the memory is fetched,
    under program control, into an arithmetic and
    logic unit, where it is processed.
  • Processed information leaves through an output.
  • All activities inside the machine are directed by
    the control unit.

9
Input unit
  • Computers accept coded information through input
    units.
  • The most well known input device is key board.
  • Whenever a key is pressed, the corresponding
    letter or digit is automatically translated into
    its corresponding binary code and transmitted
    over a cable to either the memory or the
    processor.

10
Memory unit
  • The function of the memory is to store programs
    and data.
  • There are two classes of storage, called primary
    and secondary.
  • Primary storage is a fast memory that operates at
    electronic speeds.
  • Programs must stay in memory while they
    are being executed.
  • The memory contains a large number of
    semiconductor storage cells, each capable of
    storing one bit of information.
  • Random access memory Memory in which any
    location can be reached in a short and fixed
    amount of time after specifying its address is
    called random access memory (RAM).

11
Memory unit (Contd.,)
  • The time required to access one word is called
    the memory access time.
  • Cache memory The small, fast, Ram units are
    called caches.
  • They are tightly coupled with the
    processor and are often contained on the same
    integrated circuit chip to achieve high
    performance.
  • Main memory The largest and slowest unit is
    referred to as the main memory.

12
Memory unit (Contd.,)
  • Secondary storage
  • Although primary storage is essential, it tends
    to be expensive.
  • Thus additional, cheaper, secondary storage is
    used when large amounts of data and many programs
    have to be stored, particularly for information
    that is accessed infrequently.
  • A wide selection of secondary storage devices is
    available, including magnetic disks,tapes and
    optical disks (CD-ROMs)

13
Arithmetic and logic unit (ALU)
  • Most computer operations are executed in in the
    arithmetic and logic unit (ALU) of the processor.
  • For example, Suppose two numbers are to be added.
  • They are brought into the processor, and the
    actual addition is carried out by the ALU.
  • The sum may then be stored in the memory or
    retained in the processor for immediate use.
  • When operands are brought into the processor,
    they are stored in high-speed storage elements
    called registers.

14
Output unit
  • The output unit is the counterpart of input unit.
  • Its function is to send processed results to the
    outside world.
  • The most familiar example of such a device is a
    printer.
  • Some units, such as graphic displays, provide an
    input function and an output function. The dual
    role of such units is the reason for using the
    single name I/O unit in many cases.

15
Control unit
  • The memory, arithmetic and logic, and I/O units
    store and process information and perform input
    and output operations.
  • The operations of these units are coordinated by
    control unit.
  • The control unit is effectively the nerve center
    that sends control signals to other units and
    senses their states.

16
Basic operational concepts
  • To perform a given task, an appropriate program
    consisting of a list of instructions is stored in
    the memory.
  • Individual instructions are brought from the
    memory into the processor, which execute the
    specified operations.
  • Data to be used as operands are also stored
    in the memory

17
Basic operational concepts (Contd.,)
  • Consider, the two instruction sequence
  • Load LOCA, R1
  • Add R1, R0
  • The first of these instructions transfers the
    contents of memory location LOCA into processor
    register R1, and second instruction adds the
    contents of register R1 as well as those of R0
    and places the sum into R0.
  • Note that this destroys the former contents of R1
    as well as R0, where as the original contents of
    memory location LOCA are preserved.

18
Connections between the processor and the
memory
Memory
Processor
19
Instruction register (IR)
  • The instruction register holds the instruction
    that is currently being executed.
  • Its output is available to the control circuits,
    which generate the timing signals that control
    the various processing elements involved in
    executing the instruction

20
Program counter (PC)
  • The program counter is another specialized
    register.
  • It keeps track of the execution of a program.
  • It contains the memory address of the next
    instruction to be fetched and executed.
  • During the execution of an instruction, the
    contents of of the PC are updated to correspond
    to the address of the next instruction to be
    executed.
  • It is customary to say that PC points to the next
    instruction that is to be fetched from the
    memory.

21
Memory address register (MAR) Memory data
register (MDR)
  • These two registers facilitate communication with
    the memory.
  • The MAR holds the address of the location to be
    accessed.
  • The MDR contains the data to be written into or
    read out of the addressed location.

22
Operating steps for Program execution
  • Programs are stored in the memory through the
    input unit.
  • Execution of the program starts when the PC is
    set to point to the first instruction of the
    program.
  • The contents of the PC are transferred to the MAR
    and a Read control signal is sent to the memory.
  • After the time required to access the memory
    elapses, the addressed word (in this case, the
    first instruction of the program) is read out of
    the memory and loaded into the MDR.

23
Operating steps for Program execution (Contd.,)
  • Next, the contents of the MDR are transferred to
    the IR .
  • At this point, the instruction is ready to be
    decoded and executed.
  • If the instruction involves an operation to be
    performed by the ALU, it is necessary to obtain
    the required operands.
  • If an operand resides in memory ( it could also
    be in a general-purpose register in the
    processor), it has to be fetched by sending its
    address to the MAR and initiating a Read cycle.

24
Operating steps for Program execution (Contd.,)
  • When the operand has been read from the memory
    into the MDR, it is is transferred from the MDR
    to the ALU.
  • After one or more operands are fetched in this
    way, the ALU can perform the desired operation.
  • If the result of the operation is to be stored in
    the memory, then the result is sent to the MDR.
  • The address of the location where the result is
    to be stored is sent to the MAR, and a write
    cycle is initiated.

25
Operating steps for Program execution (Contd.,)
  • At some point during the execution of the current
    instruction, the contents of the PC are
    incremented so that the PC points to the next
    instruction to be executed.
  • Thus, as soon as the execution of the current
    instruction is completed, a new instruction fetch
    may be started.
  • In addition to transferring data between the
    memory and the processor, the computer accepts
    data from input devices and sends data to output
    devices. Thus, some machine instructions with the
    ability to handle I/O transfers are provided.

26
Interrupt service routine
  • Normal execution of a programs may be preempted
    if some device requires urgent servicing.
  • For example, a monitoring device in a
    computer-controlled industrial process may detect
    a dangerous condition.
  • In order to deal with the situation
    immediately, the normal execution of the current
    program must be interrupted.
  • To do this, the device raises an interrupt
    signal.
  • An interrupt is a request from an I/O device for
    service by the processor.
  • The processor provides the requested
    service by executing an appropriate
    interrupt-service routine.

27
Interrupt service routine (contd.,)
  • Because such diversions may alter the internal
    state of the processor, its state must be saved
    in the memory locations before servicing the
    interrupt.
  • Normally, the contents of the PC, the general
    registers, and some control information are
    stored in memory.
  • When the interrupt service routine is completed,
    the state of the processor is restored so that
    the interrupted program may continue.

28
Bus structures
  • A group of lines(wires) that serves as a
    connecting path for several devices of a computer
    is called a bus.
  • In addition to the lines that carry the data, the
    bus must have lines for address and control
    purposes.
  • The simplest way to interconnect functional units
    is to use a single bus, as shown below

processor
input
output
memory
29
Bus structures (contd.,)
  • All units are connected to this bus. Because the
    bus can be used for only one transfer at a time,
    only two units can actively use the bus at any
    given time.
  • Bus control lines are used to arbitrate multiple
    requests for use of the bus.
  • The main virtue of the single-bus structure is
    its low cost and its flexibility for attaching
    peripheral devices.
  • Systems that contain multiple buses achieve more
    concurrency in operations by allowing two or more
    transfers to be carried out at the same time.This
    leads to better performance but at an increased
    cost.

30
Explain how timing differences are smoothed out
among processors, memories and I/O devices.
  • The devices connected to a bus vary widely in
    their speed of operation.
  • Electro mechanical devices such as key
    board and printers are relatively slow.
  • Others like magnetic or optical disks, are
    considerably faster.
  • Memory and processor units operate at
    electronic speeds.
  • A common approach to smooth out the timing
    differences is to include buffer registers with
    the devices to hold the information during
    transfers.
  • They prevent a high speed processor from being
    locked to a slow I/O device during a sequence of
    data transfers.

31
Contd.,
  • This allows the processor to switch rapidly from
    one device to another, interweaving its process
    activity with data transfers involving several
    I/O devices.
  • Thus, buffer registers smooth out timing
    differences among processors, memories and I/O
    devices.

32
Software
  • Explain the role of system software in a
    computer.
  • System software is responsible for the
    coordination of all activities in a computing
    system.
  • System software is a collection of programs that
    are executed as needed to perform functions such
    as
  • 1) Receiving and interpreting user
    commands.
  • 2) Entering and editing application programs
    and storing them as files in secondary storage
    devices.
  • 3) Managing the storage and retrieval of
    files in secondary storage devices.

33
Contd.,
  • 4) Running standard application programs such
    as word processors, spread sheets, or games, with
    data supplied by the user.
  • 5) Controlling I/O units to receive input
    information and produce output results.
  • 6) Translating programs from high level
    language to low level language.
  • 7) Linking and running user-written application
    programs with existing standard library routines,
    such as numerical computation packages.

34
Explain various components of system software.
  • Compiler A system software program which
    translates the high-level language program into a
    suitable machine language program.
  • Text editor Another important system program
    that all programmers use is a text editor.
  • It is used for entering and editing application
    programs.
  • The user of this program interactively execute
    commands that allow statements of a source
    program entered at a keyboard to be accumulated
    in a file.

35
Contd.,
  • Operating system (OS)
  • It is a key system software component.
  • This is a large program, or actually a collection
    of routines , that is used to control the sharing
    of and interaction among various computer units
    as they execute application programs.
  • The OS routines perform the tasks required to
    assign computer resources to individual
    application programs.
  • These tasks include assigning memory to program
    and data files, moving data between memory and
    disk units, and handling I/O operations.

36
Performance
  • Discuss various parameters for improving the
    performance of a computer.
  • The most important measure of the performance of
    a computer is how quickly it can execute a
    programs.
  • The speed with which a computer executes programs
    is affected by the design of its hardware and its
    machine language instructions.
  • Elapsed time The total time required to execute
    a program .
  • This elapsed time is a measure of the performance
    of the entire computer system.
  • It is affected by the speed of the processor, the
    disk and the printer.

37
Contd.,
  • Processor time
  • Here we have to consider only those periods of
    the elapsed time, during which the processor is
    active.
  • The sum of these periods is called processor
    time.
  • The processor time depends on the hardware
    involved in the execution of individual machine
    instructions.
  • Cache memory
  • The processor and a relatively small cache memory
    can be fabricated on a single IC chip.
  • The internal speed of performing the basic steps
    of instruction processing on such chips is very
    high and considerably faster than the speed at
    which instructions and data can be fetched from
    the main memory.

38
Contd.,
  • A program will be executed faster if the movement
    of instructions and data between the main memory
    and processor is minimized, which is achieved by
    using the cache.

Processor
Main memory
Cache memory
Bus
39
Processor clock
  • Processor circuits are controlled by a timing
    signal called a clock .
  • The clock defines regular time intervals, called
    clock cycles.
  • To execute a machine instruction, the processor
    divides the action to be performed into a
    sequence of basic steps, such that each step can
    be completed in one clock cycle.
  • The length P of one clock cycle is an important
    parameter that affects processor performance.
  • Its inverse is the clock rate, R 1/P , which is
    measured in cycles per second .
  • If the clock rate is 500 million cycles per
    second, then the corresponding clock period is 2
    nanoseconds.

40
Basic performance equation
  • Let T be the processor time required to execute
    a program that has been prepared in some high
    level language.
  • Assume that the complete execution of the program
    requires the execution of N machine language
    instructions.
  • Suppose that the average number of basic steps
    needed to execute one machine instruction is S.
  • If the clock rate is R cycles per second, the
    program execution time is given by
  • T N . S
  • R
  • This is often referred to as the basic
    performance equation.

41
Pipelining and Super scalar operation
  • A substantial improvement in performance can be
    achieved by overlapping the execution of
    successive instructions, using a technique called
    pipelining .
  • Consider the instruction
  • Add R1, R2, R3
  • Which adds the contents of registers R1 and R2,
    and places the sum into R3.
  • The contents of R1 and R2 are first transferred
    to the inputs of the ALU.
  • After the add operation is performed, the sum is
    transferred to R3.
  • Processor can read the next instruction from the
    memory while the addition operation is being
    performed.

42
Pipelining (contd.,)
  • Then, if that instruction also uses the ALU, its
    operands can be transferred to the ALU inputs at
    the same time that the result of Add instruction
    is being transferred to R3.
  • Thus, pipelining increases the rate of executing
    instructions significantly and cause the
    effective value of S to approach 1.

43
Super scalar operation
  • A higher degree of concurrency can be achieved if
    multiple instruction pipelines are implemented in
    the processor.
  • This means that multiple function units are used,
    creating parallel paths through which different
    instructions can be executed in parallel.
  • With such an arrangement, it becomes possible to
    start the execution of several instructions in
    every clock cycle.
  • This mode of execution is called Super scalar
    operation

44
Clock rate
  • There are two possibilities for increasing the
    clock rate, R.
  • First, improving the IC technology makes logic
    circuit faster, which reduces the the needed to
    complete a basic step. This allows the clock
    period, P, to be reduced and the clock rate, R,
    to be increased.
  • Second, reducing the amount of processing done in
    one basic step also makes it possible to reduce
    the clock period , P.

45
Instruction set CISC and RISC
  • The terms CISC and RISC refer to design
    principles and techniques.
  • RISC Reduced instruction set computers
  • Simple instructions require a small number of
    basic steps to execute.
  • For a processor that has only simple
    instructions, a large number of instructions may
    be needed to perform a given programming task.
  • This could lead to a large value of N and a
    small value for S.
  • It is much easier to implement efficient
    pipelining in processors with simple instruction
    sets.

46
Instruction set CISC and RISC (contd.,)
  • CISC Complex instruction set computers.
  • Complex instructions involve a large number of
    steps.
  • If individual instructions perform more complex
    operations, fewer instructions will be needed,
    leading to a lower value of N and a larger value
    of S.
  • Complex instructions combined with pipelining
    would achieve good performance.

47
Compiler
  • A compiler translates a high-level language
    program into a sequence of machine instructions
  • To reduce N, we need to have a suitable machine
    instruction set and a compiler that makes good
    use of it.
  • An optimizing compiler takes advantage of various
    features of the target processor to reduce the
    product N.S .
  • The compiler may rearrange program instructions
    to achieve better performance.

48
Performance measurement
  • SPEC rating.
  • A non profit organization called System
    Performance Evaluation Corporation (SPEC)
    selects and publishes representative application
    programs for different application domains.
  • The SPEC rating is computed as follows
  • SPEC rating Running time on the
    reference computer
  • Running time on
    the computer under test
  • Thus SPEC rating of 50 means that the computer
    under test is 50 times faster than the reference
    computer for this particular benchmark.

49
Contd.,
  • The test is repeated for all the programs in the
    SPEC suite, and the geometric mean of the results
    is computed.
  • Let SPECi be the rating for program i in the
    suite.
  • The overall SPEC rating for the computer is
    given by
  • SPEC rating ? ( SPECi )
  • where n is the number of programs in the
    suite.

n
i1
50
Multiprocessors
  • Large computer systems may contain a number of
    processor units, in which case they are called
    multiprocessor systems.
  • These systems either execute a number of
    different application tasks in parallel, or they
    execute subtasks of a single large task in
    parallel.
  • All processors usually have access to all of the
    memory in such systems, and the term
    shared-memory multiprocessor systems is often
    used to make this clear.

51
Multiprocessors (contd.,)
  • The high performance of these systems comes with
    much increased complexity and cost.
  • In addition to multiple processors and
    memory units, cost is increased because of the
    need for more complex interconnection networks.

52
Multi-computers
  • In contrast to multiprocessor systems, it is
    possible to use an interconnected group of
    complete computers to achieve high total
    computational power.
  • The computers normally have access only to their
    own memory units.
  • When the tasks they are executing need to
    communicate data, they do so by exchanging
    messages over a communication network.
  • This property distinguishes them from
    shared-memory multiprocessors, leading to the
    name message-passing multi- computers.

53
(No Transcript)
54
Data Representation
  • 3-1 Data Types
  • Binary information is stored in memory or
    processor registers
  • Registers contain either data or control
    information
  • Data are numbers and other binary-coded
    information
  • Control information is a bit or a group of bits
    used to specify the sequence of command signals
  • Data types found in the registers of digital
    computers
  • Numbers used in arithmetic computations
  • Letters of the alphabet used in data processing
  • Other discrete symbols used for specific purpose
  • ?? Number ? Letter ?? ??, ?) gray code, error
    detection code,
  • Number Systems
  • Base or Radix r system uses distinct symbols
    for r digits
  • Most common number system Decimal, Binary,
    Octal, Hexadecimal
  • Positional-value(weight) System r2 r 1r0.r-1
    r-2 r-3
  • Multiply each digit by an integer power of r and
    then form he sum of all weighted digits

55
  • Decimal System/Base-10 System
  • Composed of 10 symbols or numerals(0, 1, 2, 3, 4,
    5, 6, 7, 8, 9, 0)
  • Binary System/Base-2 System
  • Composed of 10 symbols or numerals(0, 1)
  • Bit Binary digit
  • Hexadecimal System/Base-16 System Tab. 3-2
  • Composed of 16 symbols or numerals(0, 1, 2, 3, 4,
    5, 6, 7, 8, 9, A, B, C, D, E, F)
  • Binary-to-Decimal Conversions
  • 1011.1012 (1 x 23) (0 x
    22) (1 x 21) (1 x 2o) (1 x 2-1) (0 x 2-2)
    (1 x 2-3)
  • 810 0 210 110
    0.510 0 0.12510
  • 11.62510
  • Decimal-to-Binary Conversions
  • Repeated division(See p. 69, Fig. 3-1)
  • 37 / 2 18 remainder 1 (binary number
    will end with 1) LSB
  • 18 / 2 9
    remainder 0
  • 9 / 2 4 remainder 1
  • 4 / 2 2
    remainder 0
  • 2 / 2 1
    remainder 0
  • 1 / 2 0
    remainder 1 (binary number will start with 1)
    MSB

??? ?? 0.375 x 2 0.750 integer
0 MSB 0.750 x 2 1.500 integer 1
. 0.500 x 2 1.000 integer 1 LSB
Read the result downward .37510 .0112
56
  • Hex-to-Decimal Conversion
  • 2AF16 (2 x 162) (10 x 161)
    (15 x 16o)
  • 51210 16010
    1510
  • 68710
  • Decimal-to-Hex Conversion
  • 42310 / 16 26 remainder 7
    (Hex number will end with 7) LSB
  • 2610 / 16 1 remainder
    10
  • 110 / 16 0 remainder
    1 (Hex number will start with 1) MSB
  • Read the result upward to give an answer
    of 42310 1A716
  • Hex-to-Binary Conversion
  • 9F216 9 F
    2
  • 1001 1111 0010
  • 1001111100102

Table 3-2 Hex Binary Decimal 0 0000
0 1 0001 1 2 0010 2 3 0011 3 4
0100 4 5 0101 5 6 0110
6 7 0111 7 8 1000 8 9 1001
9 A 1010 10 B 1011 11 C 1100
12 D 1101 13 E 1110 14 F 1111 15
  • Binary-to-Hex Conversion
  • 1 1 1 0 1 0 0 1 1 02 0 0 1 1 1 0 1 0
    0 1 1 0
  • 3
    A 6
  • 3A616

57
  • Binary-Coded-Decimal Code
  • Each digit of a decimal number is represented by
    its binary equivalent
  • 8 7 4
    (Decimal)
  • 1000 0111 0100
    (BCD)
  • Only the four bit binary numbers from 0000
    through 1001 are used
  • Comparison of BCD and Binary
  • 13710 100010012
    (Binary) - require only 8 bits
  • 13710 0001 0011
    0111BCD (BCD) - require 12 bits
  • Alphanumeric Representation
  • Alphanumeric character set(Tab. 3-4)
  • 10 decimal digits, 26 letters, special
    character(, , ,.)
  • A complete list of ASCII p. 384, Tab. 11-1
  • ASCII(American Standard Code for Information
    Interchange)
  • Standard alphanumeric binary code uses seven bits
    to code 128 characters

58
  • 3-2 Complements
  • Complements are used in digital computers for
    simplifying the subtraction operation and for
    logical manipulation
  • There are two types of complements for base r
    system
  • 1) rs complement 2) (r-1)s
    complement
  • Binary number 2s or 1s complement
  • Decimal number 10s or 9s complement
  • (r-1)s Complement
  • (r-1)s Complement of N (rn-1)-N
  • 9s complement of N546700
  • (106-1)-546700 (1000000-1)-546700
    999999-546700
  • 453299
  • 1s complement of N101101
  • (26-1)-101101 (1000000-1)-101101 111111-101101
  • 010010
  • rs Complement
  • rs Complement of N rn-N
  • 10s complement of 2389 76101 7611
  • 2s complement of 1101100 00100111 0010100

N given number r base n digit number
546700(N) 453299(9s com) 999999
101101(N) 010010(1s com) 111111
rs Complement (r-1)s Complement 1
(rn-1)-N1 rn-N
59
  • Subtraction of Unsigned Numbers
  • 1) M (rn-N)
  • 2) M ? N Discard end carry, Result M-N
  • 3) M ? N No end carry, Result - rs
    complement of (N-M)
  • Decimal Example)
  • 72532(M) - 13250(N) 59282
  • 72532
  • 86750 (10s complement of 13250)
  • 1 59282
  • Result 59282
  • Binary Example)
  • 1010100(X) - 1000011(Y) 0010001
  • 1010100
  • 0111101 (2s complement of 1000011)
  • 1 0010001
  • Result 0010001

(M-N), N?0
  • 13250(M) - 72532(N) -59282
  • 13250
  • 27468 (10s complement of 72532)
  • 0 40718
  • Result -(10s complement of 40718)
  • -(592811) -59282

M ? N
M ? N
Discard End Cary
No End Carry
  • 1000011(X) - 1010100(Y) -0010001
  • 1000011
  • 0101100 (2s complement of 1010100)
  • 0 1101111
  • Result -(2s complement of 1101111)
  • -(00100001) -0010001

X ? Y
X ? Y
60
Numeric Data 1) Fixed Point 2) Floating Point
32.25 1) 0.25, 2) 32.0, 3) 32.25
  • 3-3 Fixed-Point Representation
  • Computers must represent everything with 1s and
    0s, including the sign of a number and
    fixed/floating point number
  • Binary/Decimal Point
  • The position of the binary/decimal point is
    needed to represent fractions, integers, or mixed
    integer-fraction number
  • Two ways of specifying the position of the binary
    point in a register
  • 1) Fixed Point the binary point is always fixed
    in one position
  • A binary point in the extreme left of the
    register(Fraction 0.xxxxx)
  • A binary point in the extreme right of the
    register(Integer xxxxx.0)
  • The binary point is not actually present, but the
    number stored in the register is treated as a
    fraction or as an integer
  • 2) Floating Point the second register is used
    to designate the position of the
  • binary point in
    the first register(refer to 3-4)
  • Integer Representation
  • Signed-magnitude representation
  • Signed-1s complement representation
  • Signed-2s complement representation

MSB for Sign 0 is plus 1 is minus
-
14 -14 0 0001110
1 0001110 0 0001110 1 1110001
0 0001110 1 1110010
Most Common
61
(-12) (-13) -25 (12) (13) 25
(25) (-37) 37 - 25 -12
  • Arithmetic Addition
  • Addition Rules of Ordinary Arithmetic
  • The signs are same sign common sign, result
    add
  • The signs are different sign larger sign,
    result larger-smaller
  • Addition Rules of the signed 2s complement
  • Add the two numbers including their sign bits
  • Discard any carry out of the sign bit position
  • Arithmetic Subtraction
  • Subtraction is changed to an Addition
  • ( A) - ( B) ( A) (- B)
  • ( A) - ( - B) ( A) ( B)
  • Overflow
  • Two numbers of n digits each are added and the
    sum occupies n1 digits
  • n 1 bit cannot be accommodated in a register
    with a standard length of n bits(many computer
    detect the occurrence of an overflow, and a
    corresponding F/F is set)

Addition Exam) 6 00000110 - 6
11111010 13 00001101 13 00001101
19 00010011 7 00000111 6
00000110 - 6 11111010 - 13
11110011 - 13 11110011 - 7
11111001 - 19 11101101
Subtraction Exam) (- 6) - ( - 13)
7 11111010 - 11110011 11111010 2s comp of
11110011
11111010 00001101
1 00000111 7
Discard End Carry
62
  • Overflow
  • An overflow may occur if the two numbers added
    are both positive or both negative
  • When two unsigned numbers are added
  • an overflow is detected from the end carry out of
    the MSB position
  • When two signed numbers are added
  • the MSB always represents the sign
  • - the sign bit is treated as part of the
    number
  • - the end carry does not indicate an
    overflow

Overflow Exam) out in
out in carries 0 1
carries 1 0 70 0 1000110 - 70
1 0111010 80 0 1010000 - 80
1 0110000 150 1 0010110 - 150 0
1101010
  • Overflow Detection
  • Detected by observing the carry into the sign bit
    position and the carry out of the sign bit
    position
  • If these two carries are not equal, an overflow
  • condition is produced(Exclusive-OR gate 1)
  • Decimal Fixed-Point Representation
  • A 4 bit decimal code requires four F/Fs
  • for each decimal digit
  • The representation of 4385 in BCD requires 16
    F/Fs (0100 0011 1000 0101)
  • The representation in decimal is wasting a
    considerable amount of storage space and the
    circuits required to perform decimal arithmetic
    are more complex

Decimal Exam) (375) (-240) 375 (10s comp
of 240) 375 760 0 375 (0000 0011 0111
0101) 9 760 (1001 0111 0110 0000) 0 135
(0000 0001 0011 0101)
Advantage Computer I/O data are generated by
people who use the decimal system
63
Decimal 6132.789 Fraction
Exponent 0.6132789 4
  • 3-4 Floating-Point Representation
  • The floating-point representation of a number has
    two parts
  • 1) Mantissa signed, fixed-point number
  • 2) Exponent position of binary(decimal) point
  • Scientific notation m x re (0.6132789 x 104)
  • m mantissa, r radix, e exponent
  • Example m x 2e (.1001110)2 x 24
  • Normalization
  • Most significant digit of mantissa is nonzero
  • 3-5 Other Binary Codes
  • Gray Code
  • Gray code changes by only one bit (Tab. 3-5
    4-bit Gray Code )
  • ??
  • The data must be converted into digital form
    before they can be used by a digital
    computer(Analog to Digital Converter)
  • The analog data are represented by the continuous
    change of a shaft position(Rotary Encoder of
    Motor)

Fraction Exponent 01001110
000100
64
  • Other Decimal Codes
  • Binary codes for decimal digits require four
    bits. A few possibilities are shown in Tab. 3-6
  • Excess-3 Gray Code
  • Gray code? BCD ?? ?, 9 ?? 0 ?? ??? 1101?? 0000??
    ?? 3 ??? ??? ???? Tab. 3-5 ?? 3 ?? 12?? ???? 0010
    ?? 1010?? 1??? ??.
  • Self-Complementing excess-3 code
  • 9s complement of a decimal number is easily
    obtained by 1s complement(changing 1s to 0s
    and 0s to 1s)
  • Weighted Code 2421 code
  • The bits are multiplied by the weights, and the
    sum
  • of the weighted bits gives the decimal digit
  • Other Alphanumeric Codes
  • ASCII Code?? Tab. 3-4 ?? p. 384, Tab. 11-1
  • Format effector Functional characters for
    controlling the layout of printing or display
    devices(carriage return-CR, line feed-LF,
    horizontal tab-HT,)
  • Data communication flow control(acknowledge-ACK,
    escape-ESC, synchronous-SYN,)
  • EBCDIC(Extended BCD Interchange Code)
  • Used in IBM equipment(?? ??? ?? ??)

Self-Complement Exam) 410 0111 (3-excess)
1000 ( 1s comp) 510 (3-excess
in Tab. 3-6) 510( 9s comp of 4)
65
  • 3-6 Error Detection Codes
  • Binary information transmitted through some form
    of communication medium is subject to external
    noise
  • Parity Bit
  • An extra bit included with a binary message to
    make the total number of 1s either odd or
    even(Tab. 3-7)
  • Even-parity method
  • The value of the parity bit is chosen so that the
    total number of 1s (including the parity bit) is
    an even number
  • 1 1 0 0 0 0 1 1
  • Odd-parity method
  • Exactly the same way except that the total number
    of 1s is an odd number
  • 1 1 0 0 0 0 0 1

Added parity bit
Added parity bit
66
1 1 0 0 0 0 1 1 C 1
1 0 0 0 0 1 0 B (Even-parity Generator)
(Even-parity Checker)
  • Parity Generator/Checker
  • At the sending end, the message is applied to a
    parity generator
  • At the receiving end, all the incoming bits are
    applied to a parity checker
  • Can not tell which bit in error
  • Can detect only single bit error(odd number of
    errors)
  • 3 bit data line example Fig. 3-3
  • 4 bit data line example

67
  • Odd Parity Generator/Checker
  • Truth Table

68
Chapter 2 Data Representation
CS140 Computer Organization
These slides are derived from those of Null
Lobur the work of others.
69
Chapter 2 Objectives
  • Understand the fundamentals of numerical data
    representation and manipulation in digital
    computers both integer and floating point.
  • Master the skill of converting between various
    radix systems.
  • Understand how errors can occur in computations
    because of overflow and truncation.
  • Gain familiarity with the most popular character
    codes.
  • Understand the concepts of error detecting and
    correcting codes.

70
2.1 Introduction
  • REVIEW
  • A bit is the most basic unit of information in a
    computer.
  • It is a state of on or off in a digital
    circuit.
  • Sometimes these states are high or low
    voltage instead of on or off..
  • A byte is a group of eight bits.
  • A byte is the smallest possible addressable (can
    be found via its location) unit of computer
    storage.
  • A word is a contiguous group of bytes.
  • Words can be any number of bits (16, 32, 64 bits
    are common).
  • A group of four bits is called a nibble (or
    nybble).
  • Bytes, therefore, consist of two nibbles a
    high-order nibble, and a low-order nibble.

71
2.2 Positional Numbering Systems
  • Bytes store numbers using the position of each
    bit to represent a power of 2.
  • The binary system is also called the base-2
    system.
  • Our decimal system is the base-10 system. It
    uses powers of 10 for each position in a number.
  • Any integer quantity can be represented exactly
    using any base (or radix).
  • The decimal number 947 in powers of 10 is
  • The decimal number 5836.47 in powers of 10 is

9 ? 10 2 4 ? 10 1 7 ? 10 0
5 ? 10 3 8 ? 10 2 3 ? 10 1 6 ? 10 0
4 ? 10 -1 7 ? 10 -2
72
2.2 Positional Numbering Systems
  • Binary works the same as decimal
  • The binary number 11001 in powers of 2 is
  • When the radix of a number is something other
    than 10, the base is denoted by a subscript.
  • Sometimes, the subscript 10 is added for
    emphasis
  • 110012 2510

1 ? 2 4 1 ? 2 3 0 ? 2 2 0 ? 2 1 1 ?
2 0 16 8 0
0 1 25
73
2.3 Decimal to Binary Conversions
Subtraction Method
  • Suppose we want to convert the decimal number 190
    to base 3.
  • We know that 3 5 243 so our result will be
    less than six digits wide. The largest power of
    3 that we need is therefore 3 4 81, and
    81 ? 2 162.
  • Write down the 2 and subtract 162 from 190,
    giving 28.

Note The book also talks about the Division
Method which you may prefer.
74
2.3 Decimal to Binary Conversions
Subtraction Method
  • Converting 190 to base 3...
  • The next power of 3 is 3 3 27.
    Well need one of these, so we subtract 27 and
    write down the numeral 1 in our result.
  • The next power of 3, 3 2 9, is too large, but
    we have to assign a placeholder of zero and carry
    down the 1.

75
2.3 Decimal to Binary Conversions
Subtraction Method
  • Converting 190 to base 3...
  • 3 1 3 is again too large, so we assign a zero
    placeholder.
  • The last power of 3, 3 0 1, is our last
    choice, and it gives us a difference of zero.
  • Our result, reading from top to bottom is
  • 19010 210013

76
2.3 Decimal to Binary Conversions
  • Fractional values can be approximated in all base
    systems.
  • Fractions do not necessarily have exact
    representations under all radices.
  • The quantity ½ is exactly representable in
    binary and decimal, but not in the ternary (base
    3) numbering system.
  • Fractional decimal values have nonzero digits to
    the right of the decimal point.
  • Fractional values of other radix systems have
    nonzero digits to the right of the radix point.

0.4710 4 ? 10 -1 7 ? 10 -2 0.112 1 ? 2
-1 1 ? 2 -2 ½ ¼
0.5 0.25 0.75
77
2.3 Decimal to Binary Conversions
Subtraction Method
  • This shows the subtraction method to convert the
    decimal 0.8125 to binary.
  • Our result, reading from top to bottom is
  • 0.812510 0.11012
  • This method works with any base, not just binary.

Note The book also talks about the
Multiplication Method which you may prefer.
78
2.3 Decimal to Binary Conversions
HEX
  • The binary numbering system is the most important
    radix system for digital computers.
  • But, its difficult to read long strings of
    binary numbers-- and even a modest decimal number
    becomes a very long binary number.
  • For example 110101000110112 1359510
  • For compactness and ease of reading, binary
    values are usually expressed using the
    hexadecimal, or base-16, numbering system.
  • The hexadecimal numbering system uses the
    numerals 0 through 9 and the letters A through F.
  • The decimal number 12 is C16.
  • The decimal number 26 is 1A16.
  • It is easy to convert between base 16 and base 2,
    because 16 24.
  • Thus, to convert from binary to hexadecimal, all
    we need to do is group the binary digits into
    groups of four.

A group of four binary digits is called a hextet
79
2.3 Decimal to Binary Conversions
HEX
  • Using groups of hextets, the binary number
    110101000110112 ( 1359510) in hexadecimal is
  • Practice Convert 100010 to Hex

In hexadecimal, we cant write numbers 10-16 as
single digits, so we use the letters A F. The
number FA316 is F (15) in the 162 column, A (10)
in the 161 column and 3 in the 160 column
80
2.4 Signed Integer Representation
  • To represent negative values, computer systems
    allocate the high-order bit to indicate the sign
    of a value.
  • The high-order bit is the leftmost bit in a byte.
    Its also called the most significant bit.
  • The remaining bits contain the value of the
    number.
  • There are three ways in which signed binary
    numbers may be expressed
  • Signed magnitude,
  • Ones complement ? we wont do much with this
    here
  • Twos complement.

81
2.4 Signed Integer Representation
  • In an 8-bit word, signed magnitude representation
    places the absolute value of the number in the 7
    bits to the right of the sign bit.
  • In 8-bit signed magnitude,
  • Positive 3 is 00000011
  • Negative 3 is 10000011
  • Computers perform arithmetic operations on signed
    magnitude numbers the same way as humans do
    pencil and paper arithmetic.
  • Humans ignore the signs of the operands while
    doing a calculation, applying the appropriate
    sign at the end.

82
2.4 Signed Integer Representation
  • Binary addition is as easy as it gets. You need
    to know only four rules
  • 0 0 0 0 1 1
  • 1 0 1 1 1 10
  • The simplicity of this system makes it possible
    for digital circuits to carry out arithmetic
    operations.
  • We will describe these circuits in Chapter 3.

Lets see how the addition rules work with signed
magnitude numbers . . .
83
2.4 Signed Integer Representation
  • Example
  • Using signed magnitude binary arithmetic, find
    the sum of 75 and 46.
  • Convert 75 and 46 to binary, and arrange as a
    sum. Separate the (positive) sign bits from the
    magnitude bits.
  • As in decimal arithmetic, find the sum starting
    with the rightmost bit and work left.
  • In the second bit, we have a carry, so we note it
    above the third bit.

84
2.4 Signed Integer Representation
  • Example
  • Using signed magnitude binary arithmetic, find
    the sum of 75 and 46.
  • The third and fourth bits also give us carries.
  • Once we have worked our way through all eight
    bits, we are done.

In this example, we were careful to pick two
values whose sum would fit into seven bits. If
thats not the case, we have a problem.
  • Example
  • Using signed magnitude binary arithmetic, find
    the sum of 107 and 46.
  • The carry from the seventh bit overflows and is
    discarded, giving us the erroneous result 107
    46 25.

85
2.4 Signed Integer Representation
  • The signs in signed magnitude representation work
    just like the signs in pencil and paper
    arithmetic.
  • Example Using signed magnitude binary
    arithmetic, find the sum of -46 and -25.

Because the signs are the same, all we do is add
the numbers and supply the negative sign when we
are done.
  • Mixed sign addition (or subtraction) is done the
    same way.
  • Example Using signed magnitude binary
    arithmetic, find the sum of 46 and -25.

The sign of the result gets the sign of the
number that is larger. Note the borrows from
the second and sixth bits.
86
2.4 Signed Integer Representation
  • Signed magnitude representation is easy for
    people to understand, but needs complicated
    computer hardware.
  • Another disadvantage it allows two different
    representations for zero positive zero and
    negative zero.
  • So computers systems employ complement systems
    for numeric value representation.

4-bit Binary Decimal 1000
-8 1001 -7 1010 -6
1011 -5 1100 -4 1101
-3 1110 -2 1111
-1 0000 0 0001 1 0010
2 0011 3 0100
4 0101 5 0110 6 0111
7
87
2.4 Signed Integer Representation
  • To express a value in twos complement
  • If the number is positive, just convert it to
    binary and youre done.
  • If the number is negative, find the ones
    complement (change each of the bits) of the
    number and then add 1.
  • Example
  • In 8-bit ones complement, positive 3 is
  • 00000011
  • Negative 3 in ones complement is
  • 11111100
  • Adding 1 gives us -3 in twos complement form
  • 11111101.

88
2.4 Signed Integer Representation
  • With twos complement arithmetic, all we do is
    add our two binary numbers. Just discard any
    carries emitting from the high order bit.

Example Using twos complement binary
arithmetic, find the sum of 48 and - 19.
We note that 19 in ones complement is
00010011, so -19 in ones complement is
11101100, and -19 in twos complement is
11101101.
89
2.4 Signed Integer Representation
  • When we use any finite number of bits to
    represent a number, we run the risk of the result
    of calculations being too large to be stored in
    the computer.
  • While we cant always prevent overflow, we can
    always detect overflow.

Example Using twos complement binary
arithmetic, find the sum of 107 and 46 (we did
this before in slide 17) We see that the nonzero
carry from the seventh bit overflows into the
sign bit, giving us the erroneous result 107
46 -103.
Rule for detecting signed twos complement
overflow When the carry in and the carry
out of the sign bit differ, overflow has
occurred.
90
2.4 Signed Integer Representation
  • Signed and unsigned numbers are both useful.
  • For example, memory addresses are always
    unsigned.
  • Using the same number of bits, unsigned integers
    can express twice as many values as signed
    numbers.
  • Trouble arises if an unsigned value wraps
    around.
  • In four bits 1111 1 0000.
  • Good programmers stay alert for this kind of
    problem.

91
2.4 Signed Integer Representation
  • There are a number of algorithms that improve the
    performance of computer arithmetic.
  • Booths algorithm as discussed in the book is one
    of these enhancements.
  • Many of these methods are based on the fact that
    multiplication is HARD for a computer, but
    addition and shifting is SIMPLE. So techniques
    that optimize the simple operations make
    hardware, firmware, software go faster.

92
2.5 Floating-Point Representation
  • Integer formats are not useful in scientific or
    business applications that deal with real number
    values.
  • Floating-point representation solves this
    problem.
  • Most of todays computers are equipped with
    specialized hardware that performs floating-point
    arithmetic with no special programming required.

93
2.5 Floating-Point Representation
  • Detour on biased notation.

Excess-8 Notation 0000 -8 0001 -7 0010 -6
0011 -5 0100 -4 0101 -3 0110 -2 0111 -1
1000 0 1001 1 1010 2 1011 3 1100 4 1101
5 1110 6 1111 7
  • Use unsigned magnitude to represent both positive
    and negative numbers by using a bias, or excess,
    representation
  • The entire numbering system is shifted up some
    positive amount.
  • To convert a number from excess-8 to decimal.
  • For a number in excess-8, we subtract 8 from the
    number to get the real value (1001 in excess-8 is
    1001 1000 00012 1)
  • To convert a number from decimal to excess-8.
  • 6 01102. Add on the bias like this 0110
    1000 1110 ? the is the excess-8 number.
  • To use the representation
  • numbers have to be shifted, then stored, and then
    shifted back when retrieved
  • Unnecessarily complicated for regular use.
  • Useful to represent exponents in our floating
    point representation (shown next)

94
2.5 Floating-Point Representation
  • Floating-point numbers allow an arbitrary
Write a Comment
User Comments (0)
About PowerShow.com