cs-ch02

44
Chapter 2 Data Manipulation © 2007 Pearson Addison-Wesley. All rights reserved

Upload: salman

Post on 25-Dec-2015

216 views

Category:

Documents


1 download

DESCRIPTION

canoe

TRANSCRIPT

Page 1: CS-Ch02

Chapter 2

Data Manipulation

© 2007 Pearson Addison-Wesley.All rights reserved

Page 2: CS-Ch02

© 2007 Pearson Addison-Wesley. All rights reserved 0-2

Chapter 2: Data Manipulation

• 2.1 Computer Architecture

• 2.2 Machine Language

• 2.3 Program Execution

Page 3: CS-Ch02

© 2007 Pearson Addison-Wesley. All rights reserved 0-3

Computer Architecture - Von Neumann architecture

• The von Neumann architecture is a computer design model specifying sequential architectures.

- Use a single storage structure to hold both instructions and data.

- Run any arbitrary (but well-formed) sequence of instructions;

- Have inputs and outputs;

Page 4: CS-Ch02

© 2007 Pearson Addison-Wesley. All rights reserved 0-4

Computer Architecture

• Central Processing Unit (CPU) or processor– Arithmetic/Logic unit

versus Control unit– Registers

• General purpose (Data registers, address registers)

• Special purpose PC, IR

Page 5: CS-Ch02

© 2007 Pearson Addison-Wesley. All rights reserved 0-5

BUS

• Control lines These allow the CPU to control which operations the devices attached should perform, I.E. read or write.

• Address lines Allows the CPU to reference certain (Memory) locations within the device.

• Data lines The meaningful data which is to be sent or retrieved from a device is placed on to these lines.

Page 6: CS-Ch02

© 2007 Pearson Addison-Wesley. All rights reserved 0-6

Figure 2.1 CPU and main memory connected via a bus

Page 7: CS-Ch02

© 2007 Pearson Addison-Wesley. All rights reserved 0-7

Stored Program Concept & CPU Operation

A program can be encoded as bit patterns and stored in main memory. From there, the CPU can then extract the instructions and execute them. In turn, the program to be executed can be altered easily.

Page 8: CS-Ch02

© 2007 Pearson Addison-Wesley. All rights reserved 0-8

Terminology

• Machine instruction: An instruction (or command) encoded as a bit pattern recognizable by the CPU

• Machine language: The set of all instructions recognized by a machine

Page 9: CS-Ch02

© 2007 Pearson Addison-Wesley. All rights reserved 0-9

Machine Language Philosophies

• Reduced Instruction Set Computing (RISC)– Few, simple, efficient, and fast instructions– Example: PowerPC from Apple/IBM/Motorola

• Complex Instruction Set Computing (CISC)– Many, convenient, and powerful instructions– Example: Pentium from Intel

Page 10: CS-Ch02

© 2007 Pearson Addison-Wesley. All rights reserved 0-10

Machine Instruction Types

• Data Transfer: copy data from one location to another

• Arithmetic/Logic: use existing bit patterns to compute a new bit patterns

• Control: direct the execution of the program

Page 11: CS-Ch02

© 2007 Pearson Addison-Wesley. All rights reserved 0-11

Figure 2.2 Adding values stored in memory

Page 12: CS-Ch02

© 2007 Pearson Addison-Wesley. All rights reserved 0-12

Figure 2.3 Dividing values stored in memory

Page 13: CS-Ch02

© 2007 Pearson Addison-Wesley. All rights reserved 0-13

Figure 2.4 The architecture of the machine described in Appendix C

Page 14: CS-Ch02

© 2007 Pearson Addison-Wesley. All rights reserved 0-14

Parts of a Machine Instruction

• Op-code: Specifies which operation to execute

• Operand: Gives more detailed information about the operation– Interpretation of operand varies depending on op-

code

Page 15: CS-Ch02

© 2007 Pearson Addison-Wesley. All rights reserved 0-15

Figure 2.5 The composition of an instruction for the machine in Appendix C

Page 16: CS-Ch02

© 2007 Pearson Addison-Wesley. All rights reserved 0-16

Figure 2.6 Decoding the instruction 35A7

Page 17: CS-Ch02

© 2007 Pearson Addison-Wesley. All rights reserved 0-17

Figure 2.7 An encoded version of the instructions in Figure 2.2

Page 18: CS-Ch02

© 2007 Pearson Addison-Wesley. All rights reserved 0-18

Program Execution

• Controlled by two special-purpose registers– Program counter: address of next instruction– Instruction register: current instruction

• Machine Cycle– Fetch– Decode– Execute

Page 19: CS-Ch02

© 2007 Pearson Addison-Wesley. All rights reserved 0-19

Figure 2.8 The machine cycle

Page 20: CS-Ch02

© 2007 Pearson Addison-Wesley. All rights reserved 0-20

Figure 2.9 Decoding the instruction B258

Page 21: CS-Ch02

© 2007 Pearson Addison-Wesley. All rights reserved 0-21

Figure 2.10 The program from Figure 2.7 stored in main memory ready for execution

Page 22: CS-Ch02

© 2007 Pearson Addison-Wesley. All rights reserved 0-22

Figure 2.11 Performing the fetch step of the machine cycle

Page 23: CS-Ch02

© 2007 Pearson Addison-Wesley. All rights reserved 0-23

Figure 2.11 Performing the fetch step of the machine cycle (cont’d)

Page 24: CS-Ch02

© 2007 Pearson Addison-Wesley. All rights reserved 0-24

Arithmetic/Logic Instructions

1001101011001001 AND10001000

1001101011001001 OR 11011011

1001101011001001XOR 01010011

Page 25: CS-Ch02

© 2007 Pearson Addison-Wesley. All rights reserved 0-25

Figure 2.12 Rotating the bit pattern A3 one bit to the right

1. Circular Shift or RotationRight ShiftLeft Shift

2. Logical Shift

Page 26: CS-Ch02

© 2007 Pearson Addison-Wesley. All rights reserved 0-26

Figure 2.12 Rotating the bit pattern A3 one bit to the right

Page 27: CS-Ch02

© 2007 Pearson Addison-Wesley. All rights reserved 0-27

Controller

Communication between a computer and other devices is normally handled through an intermediary apparatus known as a controller.

The controller connects via cables to peripheral devices within the computer case or perhaps to a connector, called a port.

Page 28: CS-Ch02

© 2007 Pearson Addison-Wesley. All rights reserved 0-28

Controller

A controller translates messages and data back and forth between forms compatible with the internal characteristics of the computer and those of the peripheral device to which it is attached.

Originally, each controller was designed for a particular type of device; thus, purchasing a new peripheral device often required the purchase of a new controller as well.

Page 29: CS-Ch02

© 2007 Pearson Addison-Wesley. All rights reserved 0-29

USB and FireWire

Universal serial bus (USB) and FireWire, by which a single controller is able to handle a variety of devices.

For example, a single USB controller can be used as the interface between a computer and any collection of USB-compatible devices.

Page 30: CS-Ch02

© 2007 Pearson Addison-Wesley. All rights reserved 0-30

USB and FireWire

USB was developed under the lead of Intel. The development of FireWire was led by Apple.

In both cases the underlying theme is for a single controller to provide external ports at which a variety of peripheral devices can be attached. In this setting, the controller translates the internal signal characteristics of the computer to the appropriate USB or FireWire standard signals.

Page 31: CS-Ch02

© 2007 Pearson Addison-Wesley. All rights reserved 0-31

USB and FireWire

FireWire provides faster transfer rate than USB

Page 32: CS-Ch02

© 2007 Pearson Addison-Wesley. All rights reserved 0-32

Direct Memory Access

Controller is attached to a computer's bus, it can carry on its own communication with main memory during those nanoseconds in which the CPU is not using the bus. This ability of a controller to access main memory is known as Direct Memory Access.CPU then starts working on other processes while controller takes care of transfer data requested by the CPU, in this manner CPU’s computing resources are not wasted.

Page 33: CS-Ch02

© 2007 Pearson Addison-Wesley. All rights reserved 0-33

Direct Memory Access

In Von Neumann architecture all the communication is performed through a centralized bus due to which at certain point of time when more data and/or data from multiple storage is transferred to main memory causes impediment, known as Von Neumann bottleneck.

Page 34: CS-Ch02

© 2007 Pearson Addison-Wesley. All rights reserved 0-34

Handshaking

Communication between two devices needs agreement form both the devices. e.g. if we need to transfer data from one device to another then both the devices involved in data transfer should agree about this data transfer. Thus Constant two way dialogue between devices is known as handshaking.

Page 35: CS-Ch02

© 2007 Pearson Addison-Wesley. All rights reserved 0-35

Communication Media

•Parallel •Serial•The transfer of digital data over telephone lines is accomplished by first converting bit patterns into audible tones by means of a modem (short for modulator-demodulator), transferring these tones serially over the telephone system, and then converting the tones back into bits by another modem at the destination.

Page 36: CS-Ch02

© 2007 Pearson Addison-Wesley. All rights reserved 0-36

Communication Media

•DSL (Digital Subscriber Line), which takes advantage of the fact that existing telephone lines are capable of handling a wider frequency range than that used by traditional voice communication. More precisely, DSL uses frequencies above the audible range to transfer digital data while leaving the lower frequency spectrum for voice communication. Other technologies that compete with DSL include cable, as used in cable television systems, and satellite links via radiobroadcast.

Page 37: CS-Ch02

© 2007 Pearson Addison-Wesley. All rights reserved 0-37

Communication Rates

•The rate at which bits are transferred from one computing component to another is measured in bits per second (bps). Common units include

•Kbps (kilo-bps, equal to 1000 bps), Mbps (mega-bps, equal to 1 million bps), •Gbps (giga-bps, equal to1 billion bps). (Note the distinction between bits and bytes-that is, 8 Kbps is equal to 1 KB per second. •In abbreviations, a lowercase b usually means bit whereas an uppercase B means byte.)

Page 38: CS-Ch02

© 2007 Pearson Addison-Wesley. All rights reserved 0-38

Communication Rates

•Multiplexing the encoding or interweaving of data so that a single communication path serves the purpose of multiple paths.•Bandwidth indicates the capacity to carry information or data.

Page 39: CS-Ch02

© 2007 Pearson Addison-Wesley. All rights reserved 0-39

Other Architecture

Pipelining A technique used in advanced microprocessors where the microprocessor begins executing a second instruction before the first has been completed.Pipelining can be viewed as a first step toward parallel processing.

Page 40: CS-Ch02

© 2007 Pearson Addison-Wesley. All rights reserved 0-40

Other Architecture

Instruction 1 Instruction 2

Instruction 3Instruction 4

X X

XX

Four sample instructions, executed linearly

Page 41: CS-Ch02

© 2007 Pearson Addison-Wesley. All rights reserved 0-41

Other Architecture

Four Pipelined Instructions

IF

IF

IF

IF

ID

ID

ID

ID

EX

EX

EX

EX M

M

M

M

W

W

W

W

5

1

1

1

Page 42: CS-Ch02

© 2007 Pearson Addison-Wesley. All rights reserved 0-42

Other Architecture

Multiprocessor

MIMD (multiple-instruction stream, multiple-data stream) SISD (single-instruction stream, single-data stream)

Page 43: CS-Ch02

© 2007 Pearson Addison-Wesley. All rights reserved 0-43

Review

• Concept of instruction

• Basics of computer architecture

- Von Newmann architecture model

- Roles of memory, CPU(control unit, ALU, Registers), Bus, I/O

- Decoding of instructions

- Machine cycle (Control unit performs its job)

Page 44: CS-Ch02

© 2007 Pearson Addison-Wesley. All rights reserved 0-44

Review : Von Neumann architecture model