Professional Documents
Culture Documents
Software Concepts
Introduction to Computer Architecture
1
Course Objective
ER/CORP/CRS/OS09/003
Copyright © 2004, 2
Infosys Technologies Ltd Version No: 2.0
NOTE:
This course does not cover
• Technologies used to fabricate CPU, memory etc.
• Design and implementation of compilers, linkers, loaders etc.
• No particular OS whether at the command level or internals
• No particular protocol such as TCP/IP
• No day to day software Internet, Netscape etc.
2
References
ER/CORP/CRS/OS09/003
Copyright © 2004, 3
Infosys Technologies Ltd Version No: 2.0
3
Session Plan
Day 1
– Create a background
Day 2
– Introduce System Software
ER/CORP/CRS/OS09/003
Copyright © 2004, 4
Infosys Technologies Ltd Version No: 2.0
•Day 1
•Create a background
•Just to warm up everybody, and avoid an abrupt start, we are going to set up a background.
Here we will be discussing very trivial/obvious questions and answers.
•Main components of computer architecture
•To discuss about the following
•CPU
•Main Memory
•Input/Output Devices
•Bus
•Different Addressing modes
•To discuss about the following
•Implied Addressing
•Immediate Addressing
•Direct Addressing
•Relative Addressing
•Indexed Addressing
•Indirect Addressing
•Day2
•Introduce System Software
•To discuss about the following
•Assemblers
•Loaders
•Linkers
•Compilers
•To introduce Operating Systems/Memory Management
•To discuss about the following
•Operating System
•Functions of Operating System
•Memory Management
•Memory Management Schemes
4
Session Plan
Day 3
– Introduce Process Management
Day 4
– Introduce Device Management
ER/CORP/CRS/OS09/003
Copyright © 2004, 5
Infosys Technologies Ltd Version No: 2.0
•Day 3
•To introduce Device Management
•To discuss about the following
•I/O Channels, interrupts and interrupt handling
•Structure of an I/O System
•Allocation Policy
•To introduce Computer Networks
•Computer Networks – what and why
•Network Topology
•The OSI model: layered approach
•Communication methods: Circuit, Packet and Message Switching
•Important Routing Devices
•Day 4
5
Background
What is a Computer?
What is a Program?
– Software
– Firmware
ER/CORP/CRS/OS09/003
Copyright © 2004, 6
Infosys Technologies Ltd Version No: 2.0
A Program is a sequence of statements/steps stating how to perform a task. For each step
an arithmetic and logical operation is done. For each operation a different set of control
signals is needed – i.e. an instruction. An instruction can be machine language instructions
or assembly language instructions or even high level language instructions.
A hardware is something that is tangible. For e.g. CPU, Memory, I/O devices, Bus etc.
A software is a collection of programs. Trigger the question to identify the differences
between software, program, function/procedure etc.
Software is mainly of two types – system software and application software. Programs such
as compilers, linkers, loaders, assemblers are known as system software. Application
software provides a solution to user application by making use of system software. E.g.
banking software, payroll software.
6
Computer Architecture
is concerned with the structure and behavior of the computer as seen by the
user/programmer. It includes attributes such as
– Instruction Formats
– Addressing Modes
– Instruction Sets
– I/O Mechanisms
ER/CORP/CRS/OS09/003
Copyright © 2004, 7
Infosys Technologies Ltd Version No: 2.0
Computer Organization is how features are implemented, typically hidden from the
programmer. E.g. control signals, interfaces, memory technology etc. It is basically
concerned with the way the hardware components operate and the way they are connected
together to form the computer system.
An instruction consists of an opcode always, along with some additional information such as
where the operands come from and where the final results go to etc. Thus, there can be
zero, one, two or three addresses present.
Addressing basically refers to the way in which the operands are specified in an instruction.
There are different ways in which the bits of an address field can be interpreted to find the
operand. Addressing modes refer to these different ways.
7
Computer Architecture
ER/CORP/CRS/OS09/003
Copyright © 2004, 8
Infosys Technologies Ltd Version No: 2.0
Rather, we will study what are the components of a computer, what are their characteristics
and functions.
8
Main components of a computer system
Main Memory
Bus
ER/CORP/CRS/OS09/003
Copyright © 2004, 9
Infosys Technologies Ltd Version No: 2.0
9
CPU (Processor)
What is it?
Function
– Fetch instructions from memory
– Examine
– Execute
ER/CORP/CRS/OS09/003
Copyright © 2004, 10
Infosys Technologies Ltd Version No: 2.0
CPU is the part of the computer that performs the bulk of the data processing operations. Its
main function is to execute programs stored in the main memory by fetching the instructions,
examining them and executing them.
10
Examples of CPU (Processor)
Intel Processors
Motorola Processors
8088
68000
80286 68020
80386 68030
80486
Pentium
ER/CORP/CRS/OS09/003
Copyright © 2004, 11
Infosys Technologies Ltd Version No: 2.0
11
Parts of CPU
Control Unit ( CU )
Registers
ER/CORP/CRS/OS09/003
Copyright © 2004, 12
Infosys Technologies Ltd Version No: 2.0
12
Control Unit
ER/CORP/CRS/OS09/003
Copyright © 2004, 13
Infosys Technologies Ltd Version No: 2.0
The control unit fetches program instructions from main memory, decodes these instructions
and sends control signals to other units of a computer system. The execution of a
machine instruction consists of a sequence of steps by accessing the main memory as
and when necessary to read data.
13
Arithmetic and logic unit
– comparison (logical)
ER/CORP/CRS/OS09/003
Copyright © 2004, 14
Infosys Technologies Ltd Version No: 2.0
The ALU performs the required micro operations for executing the instructions. It performs
both arithmetic and logic operations.
14
Registers
Examples
– Program Counter (PC)
– Accumulator (A)
ER/CORP/CRS/OS09/003
Copyright © 2004, 15
Infosys Technologies Ltd Version No: 2.0
The registers store intermediate data used during the execution of the instructions.
We know that memory locations are needed for storing pointers, counters, return addresses,
temporary results, partial products etc. But having to refer to memory locations for
applications is time consuming as memory access is very time consuming. It is more
convenient and more efficient to store these intermediate values in registers inside the
processor. When a large no. of registers are included in the CPU, it is efficient to connect
them through a common bus system.
Program Counter (PC) – Points to the address of the next instruction to be executed
Instruction Register (IR) – Holds the instruction currently being executed
Memory Address Register (MAR) – Holds the address for either the instruction or the data
required for the instruction
Memory Buffer Register (MBR) – Holds the contents of the location that has been read or
that is to be written in
Accumulator (A) – A Processor register which serves as both the input and output for lots of
operations. It basically stores the intermediate results of most of the operations.
15
Von Neumann architecture - characteristics
Registers
Input local
A B
registers in ALU
ALU
Output local
A+B registers in ALU
ER/CORP/CRS/OS09/003
Copyright © 2004, 16
Infosys Technologies Ltd Version No: 2.0
This architecture was first suggested by Von Neumann. It consists of a data path, registers
and the ALU. The registers feed into two ALU registers labeled A and B. These registers
hold the ALU input while the ALU is computing. The ALU itself performs addition, subtraction
and other simple operations on its inputs. The result is stored in the output local register.
The output register can be stored back into one of the registers.
16
Von Neumann architecture - characteristics
One processor
Use of stored programs
Sequential processing of instructions
Single Instruction, Single Data stream (SISD) mode
ER/CORP/CRS/OS09/003
Copyright © 2004, 17
Infosys Technologies Ltd Version No: 2.0
17
Fetch-decode-execute cycle
memory B memory
memory
address unit buffer
register register
(MAR) (MBR)
D
A instruction register (IR)
R
prpgram counter (PC)
instruction decoder
PC contains address of next instruction
to be executed which is moved to MAR
clock
control unit
ER/CORP/CRS/OS09/003
Copyright © 2004, 18
Infosys Technologies Ltd Version No: 2.0
A block diagram of the CPU with all the interconnections are shown in the diagram above.
The sequence of steps for executing an instruction follow a cycle known as fetch-decode-
execute cycle.
18
Fetch-decode-execute cycle
Fetch Phase
Decode Phase
Execute Phase
ER/CORP/CRS/OS09/003
Copyright © 2004, 19
Infosys Technologies Ltd Version No: 2.0
19
Fetch phase
Contents of PC are transferred to MAR
Main memory is accessed and current instruction is fetched into MBR
Instruction is transferred from MBR to IR
ER/CORP/CRS/OS09/003
Copyright © 2004, 20
Infosys Technologies Ltd Version No: 2.0
20
Decode phase
ER/CORP/CRS/OS09/003
Copyright © 2004, 21
Infosys Technologies Ltd Version No: 2.0
21
Execute phase
Store the results in the proper place (go to the fetch phase to begin executing
the next instruction)
ER/CORP/CRS/OS09/003
Copyright © 2004, 22
Infosys Technologies Ltd Version No: 2.0
The instruction is executed and the results are stored in the required register and the control
goes back to the fetch cycle again.
22
Instruction categories
Arithmetic Instructions
Logical instructions
I/O instructions
ER/CORP/CRS/OS09/003
Copyright © 2004, 23
Infosys Technologies Ltd Version No: 2.0
Arithmetic instructions operate on numerical data. For e.g. addition, subtraction etc.
Logical instructions perform boolean operations. For e.g. <, > etc.
Program Control instructions are those instructions which change the sequence of
execution. For e.g. jump, procedure call and return etc.
I/O instructions are those instructions which are responsible for transfer of information
between CPU or memory to and from I/O devices.
Data Transfer instructions perform operations involving register and memory viz.,
•Register-Memory/Memory-Register: allows memory words to be fetched into registers
where they can be used as ALU inputs for subsequent instructions and vice-versa
to store the register contents into the main memory.
•Register – Register: fetches two operands from the registers, brings them to the ALU input
registers and performs some operation on them.
•Memory - Memory: This happens in two stages. A memory to register data transfer and
register to memory data transfer. This mode of data transfer fetches its operands from
memory into the ALU input registers, performs the operations and writes the data back into
the memory.
23
Measures of CPU performance
MIPS
Clock Speed
FLOPS
ER/CORP/CRS/OS09/003
Copyright © 2004, 24
Infosys Technologies Ltd Version No: 2.0
MIPS (Millions Instructions Per Second) – is a measure of the speed of the processor. The
time taken for executing different instructions is not the same. Hence, a mix of different
instructions are taken to find out how many instructions on an average a computer can
execute in a second.
FLOPS( Floating Point Operations Per Second) – is a measure of the speed of the Floating
Point Unit (FPU) which is a co-processor unit. It is similar to MIPS except that the former is
for non-floating operations where as this is for floating point operations.
24
Memory
Categories
– Primary Memory
– Secondary Memory
– Internal Memory
ER/CORP/CRS/OS09/003
Copyright © 2004, 25
Infosys Technologies Ltd Version No: 2.0
Primary Memory:
•Implemented in high speed devices located outside CPU
•Costly and volatile
•Holds program contents currently being executed & small amount of data
•Example
•RAM
Secondary Memory:
•Low speed
•Non-volatile
•Holds program not currently being executed
•Holds large data
•Examples
•Disk
•Tape
•Cartridge
Internal Memory:
•Implemented in very high-speed devices located within CPU
•Holds currently execution instructions and few data related items
•Very expensive
•Examples
•Registers
•Cache
25
I/O devices
Why needed?
Examples
– Keyboard
– Printer
– Monitor
– Joystick
ER/CORP/CRS/OS09/003
Copyright © 2004, 26
Infosys Technologies Ltd Version No: 2.0
Most of the computations involve CPU and memory. However, other components are
required to feed information for computation and these components are known as I/O
devices. The purpose of the I/O devices is to transfer information between CPU and the
outside world.
26
Bus
Unidirectional or bi-directional
Major Categories
– Data bus
– Address bus
– Control bus
ER/CORP/CRS/OS09/003
Copyright © 2004, 27
Infosys Technologies Ltd Version No: 2.0
A bus is a ribbon like set of parallel wires that can carry several bits at the same time.
Data Bus: This transfers the data along both the directions. Hence, known as a bi-directional
bus.
Address Bus: This carries the address of the memory location which carries the program.
Hence, known as a uni-directional bus.
Control Bus: This transfers the control signals like READ, WRITE necessary to fetch and
execute any program.
27
Addressing
A way of accessing memory locations which contain the data for processing
Modes of addressing
– Implied Addressing
– Immediate Addressing
– Relative Addressing
– Indirect addressing
ER/CORP/CRS/OS09/003
Copyright © 2004, 28
Infosys Technologies Ltd Version No: 2.0
Addressing can also be defined as the way in which the operand is specified in an
instruction. A number of strategies have been developed and implemented for determining
a specific memory location. Based on the different strategies, there are different addressing
modes as mentioned in the slide above.
28
Implied Addressing
Example
– DEX (Decrement X register)
– RLC
– RRC
ER/CORP/CRS/OS09/003
Copyright © 2004, 29
Infosys Technologies Ltd Version No: 2.0
29
Immediate addressing
Data is the operand byte immediately following the instruction in the memory
Opcode and Operand are stored in the same word and fetched at the same
time
Program Counter (PC) contains the address of the data
Program Counter is incremented to point to the instruction after the data
Example
– MVI A, 01
ER/CORP/CRS/OS09/003
Copyright © 2004, 30
Infosys Technologies Ltd Version No: 2.0
MVI A, 01 – MVI stands for Move Immediate. This basically implies move 01 to A.
30
Direct (Absolute ) addressing
Disadvantage
– Suffers from the problem of relocation of the program
ER/CORP/CRS/OS09/003
Copyright © 2004, 31
Infosys Technologies Ltd Version No: 2.0
31
Direct (Absolute ) addressing (Example)
Location 0000 /
~ ~
4000 / beginning of the program
~ ~
4005 / load data from 4099
~ ~
4010 /
~ ~
4099 / ( data for load instruction
at 4005)
4100 / end of program
ER/CORP/CRS/OS09/003
Copyright © 2004, 32
Infosys Technologies Ltd Version No: 2.0
Suppose in a piece of code as shown in the slide above, location 4000 is the first line of the
program. Load instruction in 4005 directs that the data is to be located from address 4099.
32
Direct (Absolute ) addressing (Change of program
location to 5000)
Location 0000 /
~ ~
4000 /
~ ~
4010 /
~ ~
4099 /
~ ~
~ ~
5010 /
~ ~
at 5005)
ER/CORP/CRS/OS09/003
Copyright © 2004, 33
Infosys Technologies Ltd Version No: 2.0
Let us assume that for some reason, the program is moved to location 5000. The load
instruction of the program moves to 5005 but the operand of the instruction still indicates
4099 which is no longer inside the program. In such cases, the program does not access
correct data.
Thus, direct addressing suffers from the problem of relocation of the program.
33
Relative addressing
Specifies memory locations in relation to, or relative to, the current value of the
[PC]
ER/CORP/CRS/OS09/003
Copyright © 2004, 34
Infosys Technologies Ltd Version No: 2.0
34
Relative addressing (Example)
Location 0000 /
~ ~
4000 /
~ ~
4010 /
~ ~
4099 /
~ ~
~ ~
5010 /
~ ~
at 5005)
ER/CORP/CRS/OS09/003
Copyright © 2004, 35
Infosys Technologies Ltd Version No: 2.0
In the above set of instruction, when the load data instruction at location 5005 is taken for
execution, the contents of PC will be automatically incremented to 5006 and hence the
effective address will be 5006+93 which is 5099.
35
Indirect Addressing
The address field of the instruction gives the address where the effective
address is stored in the memory
Control fetches the instruction from the memory and uses its address part to
access the memory again to read the effective address
ER/CORP/CRS/OS09/003
Copyright © 2004, 36
Infosys Technologies Ltd Version No: 2.0
36
Summary
Background
Memory
I/O devices
Bus
Addressing Modes
ER/CORP/CRS/OS09/003
Copyright © 2004, 37
Infosys Technologies Ltd Version No: 2.0
37
Thank You!
ER/CORP/CRS/OS09/003
Copyright © 2004, 38
Infosys Technologies Ltd Version No: 2.0
38