Computer Architecture Unit 1
Computer Architecture Unit 1
UNIT - I
OVERVIEW AND
INSTRUCTION
COMPUTER ARCHITECTURE
• Computer Architecture deals with designing and implementation of instruction
set, information format and memory addressing techniques of a computer.
• Computer Organization refers to the operational units and their interconnections
that describe the function and design of various units of a computer.
• A Computer Architect performs instruction set design, and memory addressing
modes.
Output Unit
Functional units of a Computer
ALU
Control unit
Overview And Instruction
Arithmetic Unit
Contains the circuitry that is responsible for performing the actual computing
and carrying out the arithmetic calculations (+, -, *, /).
To perform these operations, operands from the main memory is bought into
processor
After performing the operation results are stored in the memory location
It can perform these operations at very high speed.
Logic Unit
It enables the CPU to perform logical operations based on the instructions
provided to it.
Example: Logical comparison between data. ( Logical Operations : =, <, >
conditions)
1.1.1.4 Memory Unit
Memory refers to the electronic holding place for instructions and data.
Memory also stores the intermediate results and output.
Memory is mainly classified into two categories: primary and secondary.
Primary Memory
It is also knows as main memory/ internal memory/ in-built memory.
It stores data and instructions for processing.
It is an integral component of CPU.
It is a fast memory that operates at electronic speeds.
The memory contains large no of semiconductor storage cells.
Each cell carries 1 bit of information.
The Cells are processed in a group of fixed size called Words.
To provide easy access to any word in a memory, a distinct address is
associated with each word location.
Addresses are numbers that identify successive locations.
The number of bits in each word is called the word length.
The word length ranges from 16 to 64 bits.
It can be classified as random access memory (RAM) and Read only memory
(ROM).
Overview and Instruction Computer Architecture
Types The two main types of RAM are The types of ROM include
static RAM and dynamic RAM. PROM, EPROM and EEPROM.
Use RAM allows the computer to ROM stores the program required
read data quickly to run to initially boot the computer.
applications. It allows reading It only allows reading.
and writing.
Secondary Memory
It is also known as auxiliary memory or external memory.
It is used for storing software programs and data.
It is less expensive and stores huge volume of data than primary memory.
The data and instructions stored on such devices are permanent in nature.
It can be removed only if the user wants or if the device is destroyed.
Example: Pen drive, Floppy Disk, Compact Disk, External hard disk, etc.
Overview and Instruction Computer Architecture
Cache memory
Cache is a high speed memory located in between RAM and the CPU.
It increases the speed of processing since it holds the most frequently used data.
It is highly expensive and smaller in size.
It is present in two or three forms in a system – L1, L2 L3 cache memories.
The memory ranges from 256 KB to 2 MB.
Register memory
Registers are special-purpose, high speed temporary memory units
It holds various types of information such as data, instructions, addresses and
the intermediate result of calculations.
It holds the information that the CPU is currently working on.
It is said to be “CPU’s working memory” or an additional storage location
that offers the advantage of speed.
Overview and Instruction Computer Architecture
Registers are of two types: general purpose and special purpose registers.
Control Unit
o Supervises and controls the path of information that runs over the
processor.
o Organizes the various activities of those units that lie inside it.
o Guides the flow of data through the different parts of the computer.
o Interprets the instructions.
o Regulates the time controls of the processor.
o Sends and receives control signals from various peripheral devices.
Operating System
An operating system (OS) is a collection of software that manages
computer hardware resources and provides common services for computer
programs.
The operating system is a vital component of the system software in a
computer system. Application programs require an operating system to
function.
The functions of OS include Disk Access, Memory Management, Task
Scheduling, and User Interfacing.
Provides a software platform on top of which other programs run.
Example: MS –DOS, WINDOWS, LINUX, UNIX.
Device Drivers
These are system programs which are responsible for proper functioning
of devices.
Whenever a new device is added to a computer system the driver must be
installed before the device is used.
It acts as a translator between the device and the program that uses the device.
It is not an independent program; it assists or is assisted by the OS for
proper functioning.
Example: printer, monitor, mouse, keyboard.
Overview and Instruction Computer Architecture
System Utility
These programs perform day-to-day tasks related to the maintenance of the
computer system.
They are used to support, enhance and secure existing programs and data in
the computer system.
They are generally small programs having specific task to perform.
Word Processors
A word processor is software used to compose, format, edit and print
electronic documents.
We can include pictures, graphs, and charts and allows changes in
alignments, margins, font, and color and also allows spell checking.
Example: Microsoft word, word perfect
Spreadsheets
A spreadsheet application is a rectangular grid, which allows text, numbers
and complex functions to be entered into a matrix of thousands of individual
cells.
Applications include payroll processing, financial record maintenance.
Example: Microsoft Excel, Lotus 1-2-3.
Image Editors
Image editor programs are designed specifically for capturing, creating,
editing and manipulating images.
The programs provide a variety of special features for creating and altering
images.
They also enable the user to create and superimpose layers, import and
export graphic files, adjust an image and improve its appearance
Example: Adobe Photoshop, Adobe Corel Draw.
It controls the security and integrity of the database from unauthorized access.
Example: Oracle, FoxPro.
Presentation Applications
A Presentation is a means of assessment, which requires presentation
providers to present their work orally in the presence of an audience.
It combines both visual and verbal elements.
Presentation software allows the user to create presentations by producing
slides/hand-outs for the presentation of projects.
Example: Microsoft PowerPoint.
1.3 PERFORMANCE
The prime factors of the success of a computer are the speed and cost.
Performance depends on how fast machine instructions can be brought into
the processor for execution and how fast they can be executed.
The performance of a computer is dependent on
Overview and Instruction Computer Architecture
Clock
The Processor circuits are controlled by a timing signal called a clock.
Clock Cycle
The clock defines a regular time interval called clock cycle.
Overview and Instruction Computer Architecture
Bandwidth
The amount of data that can be transferred from one point to another in a
given time period is called bandwidth.
It is expressed in bits per second (bps).
Execution of an Instruction
At the start of execution all program instructions and the required data are
stored in the main memory.
As execution proceeds, instructions are fetched one by one over the bus into
the processor, and a copy is placed in the cache.
When the execution of an instruction calls for data located in the main
memory, the data are fetched and a copy is placed in the cache.
A Program will be executed faster if the movement of instruction and data
between the main memory and the processor is minimized, which is achieved
by using the Cache.
To execute a machine instruction, the processor divides the action to be
performed into a sequence of basic steps; each step can be completed in one
clock cycle.
Clock Rate, R =1/P (measured in cycles per second)
where, P Length of one clock cycle
Pipelining
A considerable improvement in performance can be achieved by overlapping the
execution of successive instructions. This technique is called pipelining.
Superscalar Operation
Multiple instruction pipelines can be implemented in the processor that allows several
instructions can be executed in parallel by creating parallel paths. This mode of operation is
called the Superscalar execution.
Clock Rate
There are 2 possibilities to increase the clock rate(R).They are,
Improving the integrated Chip(IC) technology makes logic circuits faster,
which reduces the time needed to complete a basic step. This allows the clock
period, P, to be reduced and the clock rate, R, to be increased.
Reducing the amount of processing done in one basic step also helps to reduce
the clock period P.
Performance Improvement
To maximize the performance, minimize the response time or execution
time for some task.
The performance of the computer is directly related to performance and
execution time for computer, X.
Overview and Instruction Computer Architecture
1
Performance X
Execution T ime X
For two computers X and Y, the performance of X is greater than Y then
we have
PerformanceX PerformanceY
1 1
Execution TimeX Execution TimeY
Example
Time taken to run a program = 10s on A, 15s on B
Relative performance =Execution TimeB / Execution TimeA
=15s/10s
=1.5
So A is 1.5 times faster than B
Measuring Performance
Measured in terms of seconds per program
Defined as the total time taken to complete a task. The task includes
o disk access
o memory access
o I/O activities
o Execution of Instructions
This time taken is known as wall-clock time / response time.
CPU Time
Time the CPU spends computing for particular task and does not include
the time waiting for I/O.
This is also called as CPU execution time
Overview and Instruction Computer Architecture
Formula
Performance Equation I
CPU execution time for a program CPU clock cycles for a program Clock cycle time
Performance Equation II
CPU Execution Time in terms of instruction count, CPI and clock cycle
time
CPU Execution time = Instruction count CPI Clock cycle time
(OR)
Instruction Count
CPU Execution Time CPI Clock
Rate
1.4 INSTRUCTIONS
An instruction is a piece of a program that performs an operation issued
by the computer processor.
Every instruction is defined by the instruction set of the processor.
Format
Disadvantages
o A stack can’t be randomly accessed.
o This makes it hard to generate effective code.
o Since the same stack is used for every operation, it creates a bottleneck.
1 – Operand instruction
These instructions contain one address field.
They are also known as one address instruction or Accumulator
instruction.
Accumulator (ACC) register is used for manipulation of data.
o All the operations are carried out between the accumulator
register and a memory operand.
Syntax
Operation Destination_Location
Example
ADD A is equivalent to ACC ACC + A
Where, A Destination operand
The Arithmetic Operation, C = A + B is performed as,
LOAD A
ADD B
STORE C
Advantage
o The instructions are short.
Disadvantage
o The accumulator is only a temporary storage so memory traffic
is the highest for this approach also.
2 - Operand Instructions
These instructions contain two address fields namely, the source
and the destination.
Each address field specifies either a processor register or a memory.
Overview and Instruction Computer Architecture
Advantage
o Makes code generation easy.
Disadvantage
o All operands must be named leading to longer instructions.
1.4.3 Instruction Execution
The four phases in instruction execution are
Fetch the Instruction from memory - the instruction is fetched from the memory
location whose address is in Program Counter (PC) and is placed in the instruction
register.
Decode the Instruction.
Execute the Instruction - the operands are fetched from the memory or processor
registers, and the operation is performed.
Store the result in the destination location.
o Opcode = 0
o Three register operands: rs, rt, and rd
rs and rt - sources
rd - destination
o shamt field - used only for shifts
o funct field - The ALU function (add, sub, and, or, and slt) and
is decoded by the ALU control design
Overview and Instruction Computer Architecture
000 AND
001 OR
010 Add
110 Subtract
I - Format
o Opcode = 2
o The destination address is computed as
Target address = PC [31-28] (offset address << 2)
Syntax
Operation destination, source1, constant
Example
SLL R1, R2, 10 // Equivalent to R1 = R2 << 10
1.5.7 Shift Right Logical instruction
This instruction has three register operands.
It shifts the specified register value right by the shift amount listed in the
instruction and stores the result in a third register.
Syntax
Operation destination, source1, Constant
Example
SRL R1, R2, 10 // Equivalent to R1 = R2 >> 10
1.5.8 Shift Right Arithmetic instruction
This instruction possesses three register operands.
It shifts a register value right by the shift amount listed in the instruction
and places the result in a third register.
Syntax
Operation destination, source1, Constant
Example
An instruction that directs the computer to another part of the program based on the
results of a comparison is called conditional branching.
1.6.2.1 J Instruction
J stands for jump.
It Jumps to the specified address.
Syntax
Operation offset
Example
J Target_Address;
1.6.2.2 JAL Instruction
JAL stands for Jump and link.
The instruction jumps to the specified address and stores the return address.
Syntax
Operation offset
Example
JAL Target_Address;
1.6.2.3 JR Instruction
JR stands for Jump Register.
It jumps to the address contained in the specified register R.
Syntax
Operation source
Example
JAL R1;
Overview and Instruction Computer Architecture
:
Overview and Instruction Computer Architecture
Example
Direct Addressing: the address is “the immediate”. 32-bit address cannot be embedded in a
32- bit instruction.
Pseudodirect addressing: 26 bits of the address is embedded as the immediate, and is used
as the instruction offset within the current 256MB (64MWord) region defined by the MS 4
bits of the PC.
Example: j Label