Computer Organization and Architecture by William Stallings
Computer Organization and Architecture by William Stallings
Computer Organization and Architecture by William Stallings
ORGANIZATION AND
ARCHITECTURE
www.EngineeringPdfBook.com
UNIT-I INTRODUCTION
www.EngineeringPdfBook.com
INTRODUCTION
This chapter discusses the computer hardware,
software and their interconnection, and it also
discusses concepts like computer types,
evolution of computers, functional units, basic
operations, RISC and CISC systems.
www.EngineeringPdfBook.com
Brief History of Computer
Evolution
Two phases:
VLSI = Very Large
1. before VLSI 1945 – 1978 Scale Integration
• ENIAC
• IAS
• IBM
• PDP‐8
2. VLSI 1978 Æ present day
• microprocessors !
www.EngineeringPdfBook.com
Evolution of Computers
FIRST GENERATION (1945 –
1955)
• Program and data reside in the same memory
(stored program concepts – John von Neumann)
• ALP was made used to write programs
• Vacuum tubes were used to implement the functions
(ALU & CU design)
• Magnetic core and magnetic tape storage devices are
used
• Using electronic vacuum tubes, as the switching
components
www.EngineeringPdfBook.com
SECOND GENERATION
(1955 – 1965)
• Transistor were used to design ALU & CU
• HLL is used (FORTRAN)
• To convert HLL to MLL compiler were used
• Separate I/O processor were developed to operate in
parallel with CPU, thus improving the performance
• Invention of the transistor which was faster, smaller
and required considerably less power to operate
www.EngineeringPdfBook.com
THIRD GENERATION
(1965‐1975)
• IC technology improved
• Improved IC technology helped in designing low cost, high
speed processor and memory modules
• Multiprogramming, pipelining concepts were incorporated
• DOS allowed efficient and coordinate operation of computer
system with multiple users
• Cache and virtual memory concepts were developed
• More than one circuit on a single silicon chip became
available
www.EngineeringPdfBook.com
FOURTH GENERATION
(1975‐1985)
• CPU – Termed as microprocessor
• INTEL, MOTOROLA, TEXAS,NATIONAL
semiconductors started developing microprocessor
• Workstations, microprocessor (PC) & Notebook
computers were developed
• Interconnection of different computer for better
communication LAN,MAN,WAN
• Computational speed increased by 1000 times
• Specialized processors like Digital Signal Processor
were also developed
www.EngineeringPdfBook.com
BEYOND THE FOURTH GENERATION
(1985 – TILL DATE)
• E‐Commerce, E‐ banking, home office
• ARM, AMD, INTEL, MOTOROLA
• High speed processor ‐ GHz speed
• Because of submicron IC technology lot of
added features in small size
www.EngineeringPdfBook.com
COMPUTER TYPES
Computers are classified based on the
parameters like
• Speed of operation
• Cost
• Computational power
• Type of application
www.EngineeringPdfBook.com
DESK TOP COMPUTER
• Processing &storage units, visual display &audio uits,
keyboards
• Storage media‐Hard disks, CD‐ROMs
• Eg: Personal computers which is used in homes and offices
• Advantage: Cost effective, easy to operate, suitable for general
purpose educational or business application
NOTEBOOK COMPUTER
• Compact form of personal computer (laptop)
• Advantage is portability
www.EngineeringPdfBook.com
WORK STATIONS
• More computational power than PC
•Costlier
•Used to solve complex problems which arises in
engineering application (graphics, CAD/CAM etc)
www.EngineeringPdfBook.com
SERVER SYSTEM
SUPER COMPUTERS
www.EngineeringPdfBook.com
Basic Terminology
• Computer • Software
– A device that accepts input, – A computer program that tells
processes data, stores data, and the computer how to perform
produces output, all according to particular tasks.
a series of stored instructions.
• Network
• Hardware – Two or more computers and
– Includes the electronic and other devices that are
mechanical devices that process connected, for the purpose of
the data; refers to the computer sharing data and programs.
as well as peripheral devices.
• Peripheral devices
– Used to expand the computer’s
input, output and storage
capabilities.
www.EngineeringPdfBook.com
Basic Terminology
• Input
– Whatever is put into a computer system.
• Data
– Refers to the symbols that represent facts, objects, or ideas.
• Information
– The results of the computer storing data as bits and bytes; the words,
numbers, sounds, and graphics.
• Output
– Consists of the processing results produced by a computer.
• Processing
– Manipulation of the data in many ways.
• Memory
– Area of the computer that temporarily holds data waiting to be processed,
stored, or output.
• Storage
– Area of the computer that holds data on a permanent basis when it is not
immediately needed for processing.
www.EngineeringPdfBook.com
Basic Terminology
www.EngineeringPdfBook.com
Computing Systems
Computers have two kinds of components:
• Hardware, consisting of its physical devices
(CPU, memory, bus, storage devices, ...)
• Software, consisting of the programs it has
(Operating system, applications, utilities, ...)
Calvin College
www.EngineeringPdfBook.com
FUNCTIONAL UNITS OF
COMPUTER
• Input Unit
• Output Unit
• Central processing Unit (ALU and Control Units)
• Memory
• Bus Structure
www.EngineeringPdfBook.com
The Big Picture
Processor
Input
Control
Memory
ALU
Output
Since 1946 all computers have had 5 components!!!
www.EngineeringPdfBook.com
IMPORTANT
Function SLIDE !
• ALL computer functions are:
– Data PROCESSING
– Data STORAGE Data = Information
– Data MOVEMENT
– CONTROL Coordinates How
Information is Used
• NOTHING ELSE!
www.EngineeringPdfBook.com
INPUT UNIT:
OUTPUT UNIT:
T1 Enable R1
T2 Enable R2
T4
www.EngineeringPdfBook.com
•Control unit works with
a reference signal called
T1 processor clock
R1 R2
R2
www.EngineeringPdfBook.com
MEMORY
•Two types are RAM or R/W memory and ROM read only memory
www.EngineeringPdfBook.com
Basic Operational Concepts
Basic Function of Computer
• To Execute a given task as per the appropriate program
• Program consists of list of instructions stored in
memory
www.EngineeringPdfBook.com
Interconnection between Processor and Memory
www.EngineeringPdfBook.com
Registers
Registers are fast stand-alone storage locations that hold data
temporarily. Multiple registers are needed to facilitate the
operation of the CPU. Some of these registers are
• An interrupt is a request from I/O device for
service by processor
• Processor provides requested service by
executing interrupt service routine (ISR)
• Contents of PC, general registers, and some
control information are stored in memory .
• When ISR completed, processor restored, so
that interrupted program may continue
www.EngineeringPdfBook.com
BUS STRUCTURE
Connecting CPU and memory
The CPU and memory are normally connected by three
groups of connections, each called a bus: data bus, address
bus and control bus
www.EngineeringPdfBook.com
BUS STRUCTURE
•Group of wires which carries information form CPU to peripherals or
vice – versa
• To
improve performance multibus structure can be
used
www.EngineeringPdfBook.com
A2 A1 A0 Selected
CONTROL BUS location
0 0 0 0th Location
0 0 1 1st Location
0 1 0
W/R
CS RD 0 1 1
A0 PROCESSOR
A1 1 0 0
A2
1 0 1
ADDRESS BUS
1 1 0
D7 D0
D0 D7
1 1 1
DATA BUS
www.EngineeringPdfBook.com
Cont:-
www.EngineeringPdfBook.com
Cont:-
www.EngineeringPdfBook.com
www.EngineeringPdfBook.com
PERFORMANCE
•Clock speed
Example 2
A computer has 128 MB of memory. Each word in this computer
is eight bytes. How many bits are needed to address any single
word in memory?
Solution
The memory address space is 128 MB, which means 227.
However, each word is eight (23) bytes, which means that we
have 224 words. This means that we need log2 224, or 24 bits, to
address each word.
www.EngineeringPdfBook.com
Assignment of byte addresses
• Little Endian (e.g., in DEC, Intel)
» low order byte stored at lowest address
» byte0 byte1 byte2 byte3
• Eg: 46,78,96,54 (32 bit data)
• H BYTE L BYTE
• 8000 54
• 8001 96
• 8002 78
• 8003
46
• 8004
|
www.EngineeringPdfBook.com
Big Endian
• Big Endian (e.g., in IBM, Motorolla, Sun, HP)
» high order byte stored at lowest address
» byte3 byte2 byte1 byte0
• Programmers/protocols should be careful
when transferring binary data between Big
Endian and Little Endian machines
www.EngineeringPdfBook.com
• In case of 16 bit data, aligned words begin at
byte addresses of 0,2,4,………………………….
• In case of 32 bit data, aligned words begin at
byte address of 0,4,8,………………………….
• In case of 64 bit data, aligned words begin at
byte addresses of 0,8,16,………………………..
• In some cases words can start at an arbitrary
byte address also then, we say that word
locations are unaligned
www.EngineeringPdfBook.com
MEMORY OPERATIONS
• Today, general‐purpose computers use a set of instructions called a
program to process data.
• A computer executes the program to create output data from input
data
• Both program instructions and data operands are stored in memory
• Two basic operations requires in memory access
• Load operation (Read or Fetch)‐Contents of specified
memory location are read by processor
• Store operation (Write)‐ Data from the processor is stored in
specified memory location
www.EngineeringPdfBook.com
• INSTRUCTION SET ARCHITECTURE:‐Complete
instruction set of the processor
• BASIC 4 TYPES OF OPERATION:‐
• Data transfer between memory and
processor register
• Arithmetic and logic operation
• Program sequencing and control
• I/O transfer
www.EngineeringPdfBook.com
Register transfer notation (RTN)
Transfer between processor registers & memory, between
processor register & I/O devices
Memory locations, registers and I/O register names are
identified by a symbolic name in uppercase alphabets
• LOC,PLACE,MEM are the address of memory location
• R1 , R2,… are processor registers
• DATA_IN, DATA_OUT are I/O registers
www.EngineeringPdfBook.com
•Contents of location is indicated by using square
brackets [ ]
• R2 [LOCN]
• R4 [R3] +[R2]
www.EngineeringPdfBook.com
ASSEMBLY LANGUAGE
NOTATION (ALN)
• RTN is easy to understand and but cannot be
used to represent machine instructions
• Mnemonics can be converted to machine
language, which processor understands
using assembler
Eg:
1. MOVE LOCN, R2
2. ADD R3, R2, R4
www.EngineeringPdfBook.com
TYPE OF INSTRUCTION
¾Three address instruction
www.EngineeringPdfBook.com
TWO ADDRESS INSTRUCTION
•Syntax : Operation source, destination
www.EngineeringPdfBook.com
Zero address
instruction
• Location of all operands are defined implicitly
• Operands are stored in a structure called
pushdown stack
www.EngineeringPdfBook.com
Continued
¾ If processor supports ALU operations one data in memory and
other in register then the instruction sequence is
• MOVE D, Ri
• ADD E, Ri
• MOVE Ri, F
¾ If processor supports ALU operations only with registers then
one has to follow the instruction sequence given below
• LOAD D, Ri
• LOAD E, Rj
• ADD Ri, Rj
• MOVE Rj, F
www.EngineeringPdfBook.com
Basic Instruction Cycle
• Basic computer operation cycle
– Fetch the instruction from memory into a control
register (PC)
– Decode the instruction
– Locate the operands used by the instruction
– Fetch operands from memory (if necessary)
– Execute the operation in processor registers
– Store the results in the proper place
– Go back to step 1 to fetch the next instruction
www.EngineeringPdfBook.com
INSTRUCTION EXECUTION & STRIAGHT LINE
SEQUENCING
Address Contents
}
Begin execution here i Move A,R0
i+4 Add B,R0
3-instruction program
i+8 Move R0,C
. segment
.
.
A
.
.
.
C
www.EngineeringPdfBook.com
• PC – Program counter: hold the address of the next
instruction to be executed
• Straight line sequencing: If fetching and executing of
instructions is carried out one by one from
successive addresses of memory, it is called straight
line sequencing.
• Major two phase of instruction execution
• Instruction fetch phase: Instruction is fetched form
memory and is placed in instruction register IR
• Instruction execute phase: Contents of IR is decoded
and processor carries out the operation either by
reading data from memory or registers.
www.EngineeringPdfBook.com
BRANCHING
• Sequence can be changed either conditionally or
unconditionally.
• Accordingly we have conditional branch instructions
and unconditional branch instruction.
• Conditional branch instruction changes the sequence
only when certain conditions are met.
• Unconditional branch instruction changes the
sequence of execution irrespective of condition of
the results.
www.EngineeringPdfBook.com
CONDITION CODES
¾ CONDITIONAL CODE FLAGS: The processor keeps track of
information about the results of various operations for
use by subsequent conditional branch instructions
• N – Negative 1 if results are Negative
0 if results are Positive
• Z – Zero 1 if results are Zero
0 if results are Non zero
• V – Overflow 1 if arithmetic overflow occurs
0 non overflow occurs
• C – Carry 1 if carry and from MSB bit
0 if there is no carry from MSB bit
www.EngineeringPdfBook.com
Figure Format and different instruction types
www.EngineeringPdfBook.com
Processing the instructions
Simple computer, like most computers, uses machine cycles.
During the execute phase, the instruction is executed and the results are
placed in the appropriate memory location or the register.
Once the third phase is completed, the control unit starts the cycle again,
but now the PC is pointing to the next instruction.
The process continues until the CPU reaches a HALT instruction.
www.EngineeringPdfBook.com
Types of Addressing Modes
The different ways in which the location of the operand is
specified in an instruction are referred to as addressing
modes
• Immediate Addressing
• Direct Addressing
• Indirect Addressing
• Register Addressing
• Register Indirect Addressing
• Relative Addressing
• Indexed Addressing
www.EngineeringPdfBook.com
Immediate Addressing
• Operand is given explicitly in the instruction
• Operand = Value
• e.g. ADD 5
– Add 5 to contents of accumulator
– 5 is operand
• No memory reference to fetch data
• Fast
• Limited range
Instruction
opcode
operand
www.EngineeringPdfBook.com
Direct Addressing
• Address field contains address of operand
• Effective address (EA) = address field (A)
• e.g. ADD A
– Add contents of cell A to accumulator
– Look in memory at address A for operand
• Single memory reference to access data
• No additional calculations to work out effective address
• Limited address space
www.EngineeringPdfBook.com
Direct Addressing Diagram
Instruction
Opcode Address A
Memory
Operand
www.EngineeringPdfBook.com
Indirect Addressing (1)
• Memory cell pointed to by address field
contains the address of (pointer to) the
operand
• EA = [A]
– Look in A, find address (A) and look there for
operand
• e.g. ADD (A)
– Add contents of cell pointed to by contents of A to
accumulator
www.EngineeringPdfBook.com
Indirect Addressing (2)
• Large address space
• 2n where n = word length
• May be nested, multilevel, cascaded
– e.g. EA = (((A)))
• Draw the diagram yourself
• Multiple memory accesses to find operand
• Hence slower
www.EngineeringPdfBook.com
Indirect Addressing Diagram
Instruction
Opcode Address A
Memory
Pointer to operand
Operand
www.EngineeringPdfBook.com
Register Addressing (1)
• Operand is held in register named in address
field
• EA = R
• Limited number of registers
• Very small address field needed
– Shorter instructions
– Faster instruction fetch
www.EngineeringPdfBook.com
Register Addressing (2)
• No memory access
• Very fast execution
• Very limited address space
• Multiple registers helps performance
– Requires good assembly programming or compiler
writing
www.EngineeringPdfBook.com
Register Addressing Diagram
Instruction
Opcode Register Address R
Registers
Operand
www.EngineeringPdfBook.com
Register Indirect
Addressing
• C.f. indirect addressing
• EA = [R]
• Operand is in memory cell pointed to by
contents of register R
• Large address space (2n)
• One fewer memory access than indirect
addressing
www.EngineeringPdfBook.com
Register Indirect
Addressing Diagram
Instruction
Opcode Register Address R
Memory
Registers
www.EngineeringPdfBook.com
Indexed Addressing
• EA = X + [R]
• Address field hold two values
– X = constant value (offset)
– R = register that holds address of memory
locations
– or vice versa
`(Offset given as constant or in the index register)
Add 20(R1),R2 or Add 1000(R1),R2
www.EngineeringPdfBook.com
Indexed Addressing Diagram
Instruction
Opcode Register R Constant Value
Memory
Registers
www.EngineeringPdfBook.com
Relative Addressing
• A version of displacement addressing
• R = Program counter, PC
• EA = X + (PC)
• i.e. get operand from X bytes away from
current location pointed to by PC
• c.f locality of reference & cache usage
www.EngineeringPdfBook.com
Auto increment mode
• The effective address of the operand is the
contents of a register specified in the instruction.
• After accessing the operand, the contents of this
register are automatically incremented to point
to the next item in the list
• EA=[Ri]; Increment Ri ‐‐‐‐ (Ri)+
Eg: Add (R2)+,R0
www.EngineeringPdfBook.com
Auto decrement mode
• The contents of a register specified in the
instruction are first automatically
decremented and are then used as the
effective address of the operand
• Decrement Ri; EA= [Ri] ‐‐‐‐‐ ‐(Ri)
www.EngineeringPdfBook.com
Addressing Architecture
• Memory‐to‐Memory architecture
– All of the access of addressing ‐> Memory
– Have only control registers such PC
– Too many memory accesses
• Register‐to‐Register architecture
– Allow only one memory address
• “load”, “store” instructions
• Register‐to‐Memory architecture
– Program lengths and # of memory accesses tend to be intermediate
between the above two architectures
• Single accumulator architecture
– Have no register profile
– Too many memory accesses
• Stack architecture
– Data manipulation instructions use no address.
– Too many memory (stack) accesses
– Useful for rapid interpretation of high‐level lang. programs in which the
intermediate code representation uses stack operations.
www.EngineeringPdfBook.com
Addressing Modes
• Implied mode
– The operand is specified implicitly in the definition
of the opcode.
• Immediate mode
– The actual operand is specified in the instruction
itself.
www.EngineeringPdfBook.com
Addressing Modes (Summary)
www.EngineeringPdfBook.com
Instruction Set Architecture
• RISC (Reduced Instruction Set Computer) Architectures
– Memory accesses are restricted to load and store instruction, and data
manipulation instructions are register to register.
– Addressing modes are limited in number.
– Instruction formats are all of the same length.
– Instructions perform elementary operations
• CISC (Complex Instruction Set Computer) Architectures
– Memory access is directly available to most types of instruction.
– Addressing mode are substantial in number.
– Instruction formats are of different lengths.
– Instructions perform both elementary and complex operations.
www.EngineeringPdfBook.com
Instruction Set Architecture
• RISC (Reduced Instruction Set Computer)
Architectures
– Large register file
– Control unit: simple and hardwired
– pipelining
• CISC (Complex Instruction Set Computer)
Architectures
– Register file: smaller than in a RISC
– Control unit: often micro‐programmed
– Current trend
• CISC operation Æ a sequence of RISC‐like operations
www.EngineeringPdfBook.com
CISC Examples
• Examples of CISC processors are the
– System/360(excluding the 'scientific' Model 44),
– VAX,
– PDP‐11,
– Motorola 68000 family
– Intel x86 architecture based processors.
www.EngineeringPdfBook.com
Pro’s
• Emphasis on hardware
• Includes multi-clock complex
instructions
• Memory-to-memory:
"LOAD" and "STORE"
incorporated in instructions
• Small code sizes,
high cycles per second
• Transistors used for storing
complex instructions
www.EngineeringPdfBook.com
Con’s
• That is, the incorporation of older instruction sets
into new generations of processors tended to force
growing complexity.
• Many specialized CISC instructions were not used
frequently enough to justify their existence.
• Because each CISC command must be translated by
the processor into tens or even hundreds of lines of
microcode, it tends to run slower than an equivalent
series of simpler commands that do not require so
much translation.
www.EngineeringPdfBook.com
RISC Examples
• Apple iPods (custom ARM7TDMI SoC)
• Apple iPhone (Samsung ARM1176JZF)
• Palm and PocketPC PDAs and smartphones (Intel
XScale family, Samsung SC32442 ‐ ARM9)
• Nintendo Game Boy Advance (ARM7)
• Nintendo DS (ARM7, ARM9)
• Sony Network Walkman (Sony in‐house ARM based
chip)
• Some Nokia and Sony Ericsson mobile phones
www.EngineeringPdfBook.com
Pro’s
• Emphasis on software
• Single-clock,
reduced instruction only
• Register to register:
"LOAD" and "STORE"
are independent instructions
• Low cycles per second,
large code sizes
• Spends more transistors
on memory registers
www.EngineeringPdfBook.com
Performance
www.EngineeringPdfBook.com
Characteristics of RISC Vs CISC
processors
No RISC CISC
1 Simple instructions taking one Complex instructions taking
cycle multiple cycles
2 Instructions are executed by Instructions are executed by
hardwired control unit microprogramed control unit
3 Few instructions Many instructions
Computer components and its function
Evolution and types of computer
Instruction and instruction sequencing
Addressing modes
RISC Vs CISC
www.EngineeringPdfBook.com
REFERENCES
• Carl Hammacher,”Computer
Organization,”Fifth Edition,McGrawHill
International Edition,2002
• P.Pal Chaudhuri,”Compter Organization and
Design”,2nd Edition ,PHI,2003
• William Stallings,”Computer organization and
Architecture‐Designing for
Performance”,PHI,2004
www.EngineeringPdfBook.com