cs-ch02
DESCRIPTION
canoeTRANSCRIPT
Chapter 2
Data Manipulation
© 2007 Pearson Addison-Wesley.All rights reserved
© 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
© 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;
© 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
© 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.
© 2007 Pearson Addison-Wesley. All rights reserved 0-6
Figure 2.1 CPU and main memory connected via a bus
© 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.
© 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
© 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
© 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
© 2007 Pearson Addison-Wesley. All rights reserved 0-11
Figure 2.2 Adding values stored in memory
© 2007 Pearson Addison-Wesley. All rights reserved 0-12
Figure 2.3 Dividing values stored in memory
© 2007 Pearson Addison-Wesley. All rights reserved 0-13
Figure 2.4 The architecture of the machine described in Appendix C
© 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
© 2007 Pearson Addison-Wesley. All rights reserved 0-15
Figure 2.5 The composition of an instruction for the machine in Appendix C
© 2007 Pearson Addison-Wesley. All rights reserved 0-16
Figure 2.6 Decoding the instruction 35A7
© 2007 Pearson Addison-Wesley. All rights reserved 0-17
Figure 2.7 An encoded version of the instructions in Figure 2.2
© 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
© 2007 Pearson Addison-Wesley. All rights reserved 0-19
Figure 2.8 The machine cycle
© 2007 Pearson Addison-Wesley. All rights reserved 0-20
Figure 2.9 Decoding the instruction B258
© 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
© 2007 Pearson Addison-Wesley. All rights reserved 0-22
Figure 2.11 Performing the fetch step of the machine cycle
© 2007 Pearson Addison-Wesley. All rights reserved 0-23
Figure 2.11 Performing the fetch step of the machine cycle (cont’d)
© 2007 Pearson Addison-Wesley. All rights reserved 0-24
Arithmetic/Logic Instructions
1001101011001001 AND10001000
1001101011001001 OR 11011011
1001101011001001XOR 01010011
© 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
© 2007 Pearson Addison-Wesley. All rights reserved 0-26
Figure 2.12 Rotating the bit pattern A3 one bit to the right
© 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.
© 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.
© 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.
© 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.
© 2007 Pearson Addison-Wesley. All rights reserved 0-31
USB and FireWire
FireWire provides faster transfer rate than USB
© 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.
© 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.
© 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.
© 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.
© 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.
© 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.)
© 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.
© 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.
© 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
© 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
© 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)
© 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)
© 2007 Pearson Addison-Wesley. All rights reserved 0-44
Review : Von Neumann architecture model