Computer Architecture: Functional Units Explained
Computer Architecture: Functional Units Explained
Module-4
MODULE-4
Basic Structure of Computers, Instructions and
Programs
4.1 FUNCTIONAL UNITS
A computer consists of five functionally independent main parts:
Input
Memory
Arithmetic logic unit
Output
Control units
• The input unit accepts the coded information from human operators, from electromechanical
devices such as keyboards, or from other computers over digital communication lines
• The information received is either stored in the computer’s memory for later reference or
immediately used by the arithmetic and logic circuitry to perform the desired operations.
• The results are sent back to the outside world through the output unit
• All these actions are coordinated by the control unit
It is convenient to categorize the information handled by the computer as either data or instructions
Instructions or machine instructions are explicit commands that
• Govern the transfer of information within a computer as well as between the computer and its
I/O devices.
• Specify the arithmetic and logic operations to be performed.
arithmetic or logic operation, such as addition, subtraction, multiplication, Division and Comparison of
numbers
Operands (data) are brought from memory into the processor → operation is performed by the
ALU.
Example: Two numbers from memory are added in the ALU → result stored back in memory or
used immediately.
Speed: 20 or more pages per minute, but slower than processor speed.
Some devices perform both input and output functions:
o Graphic displays → show text/graphics and receive touch input.
o Such devices are often called Input/Output (I/O) units due to their dual role.
The program to be executed is stored in memory. Instructions are accessed from memory to the
processor one by one and executed.
STEPS FOR INSTRUCTION EXECUTION
Consider the following instruction
Ex: 1 Add LOCA, R0
With a neat diagram, explain the bus structure of computer and its components
MDR
Memory
23h 5000
23h
43h 5001
78h 5002
65h 5003
CONTROL UNIT
It controls the data transfer operations between memory and the processor.
It controls the data transfer operations between I/O and processor.
It generates control signals for Memory and I/O device
PC (PROGRAM COUNTER)
It is a special purpose register used to hold the address of the next instruction to be
executed.
The contents of PC are incremented by 1 or 2 or 4, during the execution of current
instruction.
The contents of PC are incremented by 1 for 8 bit CPU, 2 for 16 bit CPU and for 4 for 32
bit CPU.
R0
R1
R2
.
Rn-1
IR (INSTRUCTION REGISTER)
The I/O devices, Memory and CPU are connected to this bus is as shown in the figure.
It establishes communication between two devices, at a time.
Features of Single bus organization are
Less Expensive
Flexible to connect I/O devices.
Poor performance due to single bus.
There is a variation in the devices connected to this bus in terms of speed of operation. Few
devices like keyboard, are very slow. Devices like optical disk are faster. Memory and processor
are faster, but all these devices uses the same bus.
Hence to provide the synchronization between two devices, a buffer register is attached to each
device. It holds the data temporarily during the data transfer between two device.
4.4 PERFORMANCE
List the factors affecting the performance of Computer and discuss the methods to improve the
performance of the processor
4.4.1 CACHE MEMORY: It is defined as a fast access memory located in between CPU and
Memory. It is part of the processor as shown in the fig
Fig 4.4 : Processor Cache
The processor needs more time to read the data and instructions from main memory because
main memory is away from the processor as shown in the figure. Hence it slowdown the
performance of the system.
The processor needs less time to read the data and instructions from Cache Memory because it is
part of the processor. Hence it improves the performance of the system.
2. Decode
3. Execute.
The processor uses one clock cycle to perform one operation as shown in the
figure Clock Cycle → T1 T2 T3
Instruction → Fetch Decode Execute
The performance of the processor depends on the length of the clock cycle. To obtain
high performance reduce the length of the clock cycle. Let ‘ P ’ be the number of clock cycles
generated by the Processor and ‘ R ‘ be the Clock rate .
For the programmer the value of T is important. To obtain high performance it is necessary to
reduce the values of N & S and increase the value of R
Performance of a computer can also be measured by using benchmark programs.
SPEC (System Performance Evaluation Corporation) is an non-profitable organization, that
measures performance of computer using SPEC rating. The organization publishes the
application programs and also time taken to execute these programs in standard systems.
𝑆𝑃𝐸𝐶 𝑅𝑢𝑛𝑛𝑖𝑛𝑔
=
𝑅𝑢𝑛𝑛𝑖𝑛𝑔 𝑡𝑖𝑚𝑒 𝑜𝑓 𝑟𝑒𝑓𝑒𝑟𝑒𝑛𝑐𝑒 𝐶𝑜𝑚𝑝𝑢𝑡𝑒𝑟
𝑡𝑖𝑚𝑒 𝑜𝑓 𝑐𝑜𝑚𝑝𝑢𝑡𝑒𝑟 𝑢𝑛𝑑𝑒𝑟 𝑡𝑒𝑠𝑡
• If SPEC rating = 50
• Then the computer under test runs 50 times faster than reference computer.
• The test is repeated for all the programs in the SPEC suite! And geometric mean of the
results is computed.
• SPECi = rating for program i in the suite
n = number of programs in the suite
• Memory is a storage device. It is used to store character operands, data operands and
instructions.
• It consists of number of semiconductor cells and each cell holds 1 bit of information. A
group of 8 bits is called as byte and a group of 16 or 32 or 64 bits is called as word.
What is word length? Explain with neat diagram memory organization of the computer.
World length = 16 for 16 bit CPU and World length = 32 for 32 bit CPU. Word length is
defined as number of bits in a word.
Memory is organized in terms of bytes or words.
The organization of memory for 32 bit processor is as shown in the fig4.5
Fig: 4.5
The contents of memory location can be accessed for read and write operation. The memory is
accessed either by specifying address of the memory location or by name of the memory location.
Address space: It is defined as number of bytes accessible to CPU and it depends on the number
of address lines.
4.5.1 BYTE ADDRESSABILITY
Each byte of the memory are addressed, this addressing used in most computers are called byte
addressability. Hence Byte Addressability is the process of assignment of address to successive
bytes of the memory. The successive bytes have the addresses 1, 2, 3, 4….............2n-1. The
memory is accessed in words.
In a 32 bit machine, each word is 32 bit and the successive addresses are 0,4,8,12,… and so on.
Analyze Big Endian and Little Endian methods of byte addressing with relevant example.
Eg – store a word “JOHNSENA” in memory starting from word 1000, using Big Endian and
Little endian.
Bigendian -
1000 J O H N
1000 1001 1002 1003
1004 S E N A
1004 1005 1006 1007
Little endian -
1000 J O H N
1003 1002 1001 1000
1004 S E N A
1007 1006 1005 1004
It is process of assignment of addresses of two successive words and this address is the number of
bytes in the word is called as Word alignment.
Load Operation
Transfers data from a memory location to the processor.
Memory contents stay unchanged.
Processor sends the memory address → memory reads and sends data.
Store Operation
Transfers data from the processor to a memory location.
Overwrites existing data at that location.
Processor sends address and data → memory writes the data.
Data Transfer Details
One word or one byte can be transferred in a single operation.
Processor registers hold the source or destination data.
Bytes are usually placed in the low-order (rightmost) position of the register during
transfer.
Register transfer notation is used to describe how information is transferred between different
locations in a computer.
Possible locations include:
Memory locations
Processor registers
I/O registers
Each location is identified by a symbolic name representing its hardware address:
Example memory names: LOC, PLACE, A, VAR2.
Example processor register names: R0, R5.
Example I/O register names: DATAIN, OUTSTATUS.
Contents of a location are shown by placing square brackets around its name:
Example:
R1 ← [LOC] → contents of memory location LOC are transferred to processor register R1.
Example of addition operation:
R3 ← [R1] + [R2]
→ adds contents of R1 and R2, and stores the result in R3.
In RTN:
The right-hand side denotes the value being transferred.
The left-hand side denotes the destination location where the value is stored, overwriting
any previous data.
Consider the arithmetic expression Z = A + B, Where A,B,Z are the Memory locations.
Steps for evaluation
1. Access the first memory operand whose symbolic name is given by A.
2. Access the second memory operand whose symbolic name is given by B.
3. Perform the addition operation between two memory operands.
4. Store the result into the 3rd memory location Z.
5. The mathematical representation is Z ←[A] + [B].
a) Three address instruction format : Its format is as follows
opcode Source-1 Source-2 destination
opcode operand
Ex1: LOAD B
This instruction copies the contents of memory location whose symbolic name is given
by ‘B’ into the Accumulator as shown in the figure.
The mathematical representation of this instruction is as follows
ACC ← [B]
Accumulator Memory
Ex2: STORE B
This instruction copies the contents of Accumulator into memory location whose
symbolic name is given by ‘B’ as shown in the figure. The mathematical representation is as
follows
B ← [ACC].
Memory
Accumulator
Ex3: ADD B
This instruction adds the contents of Accumulator with the contents of Memory
location ‘B’ and result is stored in Accumulator.
The mathematical representation of this instruction is as
follows ACC ←[ACC]+ [B]
4.7.4 INSTRUCTION EXECUTION & STRAIGHT-LINE SEQUENCING
4.7.5 BRANCHING
Suppose a list of ‘N’ numbers have to be added. Instead of adding one after the other, the
add statement can be put in a loop. The loop is a straight-line of instructions executed as many
times as needed.
Fig 4.7: Using a loop to add n numbers
The ‘N’ value is copied to R1 and R1 is decremented by 1 each time in loop. In the loop find the
value of next element and add it with Ro.
In conditional branch instruction, the loop continues by coming out of sequence only if
the condition is true. Here the PC value is set to ‘LLOP’ if the condition is true.
The PC value is set to LOOP, if the previous statement value is >0 ie. after decrementing R1
value is greater than 0.
If R1 value is not greater than 0, the PC value is incremented in a mormal sequential way and the
next instruction is executed.
4.7.6 CONDITION CODES
The processor consists of series of flip-flops to store the status information after ALU
operation.
It keeps track of the results of various operations, for subsequent usage.
The series of flip-flip-flops used to store the status and control information of the
processor is called as “Condition Code Register”. It defines 4 flags. The format of condition
code register is as follows
C V Z N
N (NEGATIVE) Flag:
• It is designed to differentiate between positive and negative result.
• It is set 1 if the result is negative, and set to 0 if result is positive.
Z (ZERO) Flag:
It is set to 1 when the result of an ALU operation is found to zero, otherwise it is cleared.
C (CARRY) Flag :
This flag is set to 1 if there is a carry from addition or borrow from subtraction, otherwise it is
cleared.
a) Register Addressing
b) Direct Addressing
c) Immediate Addressing
d) Indirect Addressing
e) Index Addressing
f) Relative Addressing
g) Auto Increment Addressing
h) Auto Decrement Addressing
a. REGISTER ADDRESSING:
In this mode operands are stored in the registers of CPU. The name of the register is directly
specified in the instruction.
Ex: MOVE R1,R2 Where R1 and R2 are the Source and Destination registers respectively. This
instruction transfers 32 bits of data from R1
register into R2 register. This instruction does not
refer memory for operands. The operands are
directly available in the registers.
b. DIRECT ADDRESSING
It is also called as Absolute Addressing Mode. In this addressing mode operands are stored in the
memory locations. The name of the memory location is directly specified in the instruction.
Ex: MOVE LOCA, R1 : Where LOCA is the memory location and R1 is the Register.
This instruction transfers 32 bits of data from memory location X into the General Purpose
Register R1.
c. IMMEDIATE ADDRESSING
In this Addressing Mode operands are directly specified in the instruction. The source field is
used to represent the operands. The operands are represented by # (hash) sign.
d. INDIRECT ADDRESSING
In this Addressing Mode effective address of an operand is stored in the memory location or
General-Purpose Register.
This instruction adds the data from the memory location whose address is stored in R1 with the
contents of R0 Register and the result is stored in R0 register as shown in the fig.
This instruction adds the data from the memory location whose address is stored in ‘X’
memory location with the contents of R0 and result is stored in R0 register.
The diagrammatic representation of this addressing mode is as shown in the fig.
1.
X (Ri) where X is the Constant value and Rj is the GPR.
It can be represented as
EA of an operand = X + (Ri )
2.
(Ri , RJ) Where Ri and Rj are the General Purpose Registers used to store
addresses of an operand and constant value respectively. It can be represented as
The EA of an operand is given by
EA = (Ri) + (Rj)
3.
X (Ri , Rj) Where X is the constant value and RI and RJ are the General Purpose Registers
used to store the addresses of the [Link] can be represented as
The EA of an operand is given
by EA = (Ri) + (Rj) + X
There are two types of Index Addressing Modes
Note : Offset : It is the difference between the starting effective address of the memory
location and the effective address of the operand fetched from memory.
This instruction adds the data from the memory location whose address is given by [1000
+
[R1] with the contents of R2 and result is placed in R2 register.
This instruction adds the contents of memory location whose EA is the sum of contents of
R1 with 20 and with the contents of R2 and result is placed in R2 register. The
diagrammatic representation of this mode is as shown in the fig.
The symbolic representation of this mode is X (PC).Where X is the offset value and PC
is the Program Counter to store the address of the next instruction to be executed.
It can be represented as
EA of an operand = X + (PC).
This Addressing Mode is useful to calculate the EA of the target memory location.
In this Addressing Mode , EA of an operand is stored in the one of the GPR s of the CPU.
This Addressing Mode increment the contents of memory register by 4 memory locations
after operand access.
The symbolic representation is
(RI)+ Where Ri is the one of the
GPR. Ex: MOVE (R1)+ , R2
This instruction transfer’s data from the memory location whose address is stored in R 1
into R3 register and then it increments the contents of R1 by 4 memory locations.
Logic Design and Computer Organization
In this Addressing Mode , EA of an operand is stored in the one of the GPR s of the CPU.
This Addressing Mode decrements the contents of memory register by 4 memory
locations and then transfers the data to destination.