0% found this document useful (0 votes)
48 views

Theory Assambl

Udhenerir rhr
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
48 views

Theory Assambl

Udhenerir rhr
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 48

A computer is an electronic device that can process and store

information. It can perform calculations, manipulate data, and execute


instructions to accomplish specific tasks. The basic components of a
computer include the central processing unit (CPU), memory (RAM),
storage (hard drive or solid-state drive), input devices (keyboard,
mouse, etc.), output devices (monitor, printer, etc.), and various
peripheral devices (such as USB drives or external hard drives).
What is CPU?
The CPU is often considered the brain of the computer, as it performs
most of the processing and calculations required for a computer to
function. RAM is the temporary memory that stores data and
instructions while the computer is running, while storage is the long-
term memory where data is stored even when the computer is turned
off.
Input devices allow users to input data or commands into the
computer, while output devices display the results of the computer’s
processing. Peripheral devices are additional components that can be
added to a computer to enhance its functionality.
A computer is an electronic device that can perform tasks based on
instructions provided to it. It consists of hardware components such as
the central processing unit (CPU), memory, input/output devices, and
storage devices.
The CPU is the brain of the computer and performs the bulk of the
processing tasks. Memory, also known as RAM, is where data and
instructions are temporarily stored while the computer is running.
Input/output devices, such as a keyboard, mouse, and monitor, allow
users to interact with the computer and receive information from it.
Storage devices, such as a hard drive or solid-state drive, store data and
programs permanently on the computer.
Computers can run different types of software, including operating
systems, applications, and games. They can also be connected to the
internet and used to access online services, communicate with other
people, and share information.
Overall, computers are incredibly versatile machines that have become
an integral part of modern life, used for work, entertainment, education,
and many other purposes.
Computer
The computer is a device that makes our work easy. The computer is a
device that helps us to complete our tasks easily and speedily.
Computer doesn’t have a brain like human beings. We have to give
them instructions on what to do when a particular situation arises. We
have to tell them everything from what to expect for data(what type of
data), how to process it(how to perform calculations) to where to store
the data. We humans understand language that is composed of words
which further is composed of letters. But, the computers don’t
understand our language nor the words like “hello, good morning,
discipline, etc”. They only understand binary language whose
vocabulary contains only two letters or states or symbols i.e. 0 and 1,
True and False, On and Off. To maintain the state transistors are used.
 Transistors are tiny devices that are used to store 2 values 1 and 0 or
on and off.
 If the transistor is on we say that it has a value of 1, and if it is off the
value is 0.
For example, a memory chip contains hundreds of millions or even
billions of transistors, each of which can be switched on or off
individually. As a transistor can store 2 distinct values, we can have
millions of different values stored on a memory chip consisting entirely
of 0’s and 1s. But how does a transistor get its value? When a very
little amount of electric current passes through the transistor it
maintains the state of 1 and when there is no electric current then the
transistor has the state of 0.
Then how it’s all connected to the computer?
These 0’s and 1’s form the building block of a computer. With the
combinations of 0 and 1, we create a whole new language For example,
0 can be written as 0,
1 as 1
2 as 10
3 as 11
4 as 100
5 as 101
a as 01100001
A as 01000001
s as 01110011
U as 01010101
Hello as,
01001000 01100101 01101100 01101100 01101111
Hello World! as,
01001000 01100101 01101100 01101100 01101111
00100000 01010111 01101111 01110010 01101100 01100100
00100001
And so on… So now the question arises how can a human remember
this code?
It seems impossible!
Well, we humans can do everything that we desire and this code can be
remembered very easily but we don’t have to remember. We just have
to use our language and the software (also built by humans) converts
our normal letters into binary language.
What is software?
Software is a set of instructions that tells the computer what to do,
when to do, and how to do it. Examples are, the paint that we use in
Microsoft, WhatsApp, and games, all are types of different software.
Suppose we want to add 2 numbers and want to know what 2 + 2 is 4.
Then we must give the computer instructions,
 Step-1: take 2 values.
 Step-2: a store that 2 value
 Step-3: add 2 value by using + operator
 Step-4: save the answer
Separate instructions are provided for the + operator so the computer
knows how to do addition when it encounters the + sign. So who
converts this code? Instead of who we can ask what converts the code.
And answer to that question is a software called interpreter that
interprets our language code into binary code. The interpreter converts
our code into machine language that can be understood by the
computer.
Now the question is how we give our input.
We give our input with the use of hardware for example like scanner,
keyboard, and mouse(not the one that eats cheese). When we give
input through hardware, the software interprets it into machine
language and then it is processed and our output is shown.
Process: If we want to display the letter ‘A’ on the screen we first will
open the notepad. Then we will press the Capslock key or shift key to
make the letter capital, after that, we will press the letter ‘a’. And our
screen will show the letter ‘A’.
Under the hood process: When we pressed the capslock or shift key
the software tells us that whatever follows this should be printed on the
screen and after we have pressed the letter a which is a small letter, the
software first converts it into binary like it had converted the shift or
capslock key and then after the computer understands it prints A on the
screen.
Related Concepts of Simple Understanding
Some related concepts that can help in understanding computers
include:
 Binary code: Computers communicate and process information
using a binary code, which is a system of ones and zeroes. Each
binary digit (or bit) represents a simple “on” or “off” state, and
combinations of bits can represent more complex information.
 Algorithms: An algorithm is a set of instructions or steps that a
computer program follows to solve a problem or complete a task.
Algorithms are used to perform a wide range of tasks, from sorting
data to searching for patterns.
 Programming languages: Programming languages are used to
write computer programs. There are many different programming
languages, each with its own syntax and set of rules.
 Hardware vs. software: Hardware refers to the physical
components of a computer, such as the CPU, memory, and storage
devices. Software, on the other hand, refers to the programs and
instructions that tell the hardware what to do.
 Networks: Computers can be connected together in networks,
which allows them to communicate and share resources. Networks
can be wired or wireless and can be used for tasks such as sharing
files, accessing the internet, or playing multiplayer games.
 User interfaces: User interfaces are the means by which humans
interact with computers. They can be graphical, such as a desktop or
mobile operating system, or text-based, such as a command line
interface.
Types of simple understanding of Computers
 Personal computers (PCs): These are the most common type of
computer and are designed for personal use. PCs include desktops,
laptops, and tablets.
 Servers: Servers are designed to manage and distribute resources
and data to multiple users or devices. They are often used in
businesses or organizations to store and share data and run
applications.
 Mainframes: Mainframe computers are large, powerful machines
that are designed to handle massive amounts of data and perform
complex operations. They are often used in large corporations or
government agencies.
 Supercomputers: Supercomputers are extremely powerful
computers that are designed to process data at extremely high
speeds. They are often used for scientific research and other
specialized applications.
 Embedded systems: Embedded systems are small computers that
are built into other devices, such as appliances, cars, and medical
devices. They are designed to perform specific functions and operate
without human intervention.
 Wearable computers: Wearable computers are small, portable
devices that are worn on the body, such as smartwatches or fitness
trackers. They are designed to track data and provide information on
the go.
Features of a computer include
 Processor: The processor is the brain of the computer, and it carries
out all the instructions and calculations required by the system.
 Memory: The memory or RAM (Random Access Memory) stores
data temporarily for the processor to access quickly.
 Storage: Storage devices like hard disks, solid-state drives, or
external drives provide long-term storage for data and files.
 Input devices: Input devices like keyboards, mice, scanners, and
cameras enable the user to provide data and instructions to the
computer.
 Output devices: Output devices like monitors, printers, and speakers
display the results of the computer’s processing.
 Operating System: The operating system manages the computer’s
resources, controls the hardware, and runs application programs.
 Networking: Networking capabilities allow computers to
communicate and share resources with other computers and devices.
 Software: Software is the set of instructions that tell the computer
what to do, and it can range from simple applications to complex
programs.
 Graphics and Sound: Graphics and sound capabilities enable the
computer to display and manipulate images and play sounds and
videos.
 Connectivity: Connectivity features like USB, Wi-Fi, Bluetooth, and
Ethernet enable the computer to connect to other devices and the
internet.
Advantages of computers
 Increased efficiency and productivity: Computers can perform
tasks much faster and more accurately than humans, allowing for
increased efficiency and productivity in various industries.
 Storage and organization of information: Computers can store
large amounts of data and organize it in a way that is easily
accessible and searchable.
 Improved communication: Computers enable people to
communicate easily and instantly with others, regardless of their
location.
 Access to information and resources: The internet provides access
to a vast amount of information and resources that would otherwise
be difficult or impossible to obtain.
 Automation of repetitive tasks: Computers can automate
repetitive and mundane tasks, freeing up time and resources for
more important work.
Disadvantages of computers
 Dependence on technology: Over-reliance on computers can lead
to problems if they break down or malfunction, leading to loss of
productivity and data.
 Security risks: Computers can be vulnerable to viruses, malware,
and hacking, leading to data breaches and other security risks.
 Social isolation: The overuse of computers can lead to social
isolation and reduced face-to-face interaction, leading to social and
emotional problems.
 Environmental impact: The production and disposal of computers
can have a negative impact on the environment due to the use of
resources and the creation of electronic waste.
 Job displacement: Automation and the use of computers can lead
to job displacement in certain industries, requiring workers to adapt
to new skill sets or find new employment.
Frequently Asked Questions
Q.1: What is a computer?
Answer:
A computer is an electronic device that can perform various operations
and tasks based on a set of instructions, known as programs. It is capable
of processing, storing, and retrieving data, as well as executing complex
calculations and logical operations. Computers consist of hardware
components, such as the central processing unit (CPU), memory, storage
devices, input/output devices, and software that controls and manages
their operations.

Q.2: What are the primary components of a computer?


Answer:
The primary components of a computer include:
Central Processing Unit (CPU): It is the “brain” of the computer
responsible for executing instructions and performing calculations.
Memory: It stores data and instructions that the CPU can quickly access
during processing. This includes Random Access Memory (RAM) for
temporary storage and cache memory for faster access to frequently used
data.
Storage Devices: These devices provide long-term storage for data,
programs, and files. Examples include hard disk drives (HDD), solid-state
drives (SSD), and optical drives.
Input Devices: These devices allow users to input data or commands into
the computer, such as keyboards, mice, touchscreens, scanners, and
microphones.
Output Devices: These devices display or provide output from the
computer, including monitors, printers, speakers, and headphones.
Motherboard: It is the main circuit board that connects and allows
communication between various components of the computer.

Q.3: What are the different types of computers?


Answer:
There are various types of computers, including:
Personal Computers (PCs): These are general-purpose computers
designed for individual users. They include desktop computers, laptops,
and tablets.
Servers: Servers are computers designed to provide resources and
services to other computers or devices on a network. They often handle
tasks such as data storage, file sharing, or running web applications.
Mainframes: Mainframe computers are powerful systems capable of
handling large-scale processing and data storage. They are commonly
used by large organizations for critical business applications.
Supercomputers: Supercomputers are highly advanced and powerful
computers designed to handle complex scientific calculations,
simulations, and data analysis.
Embedded Systems: Embedded systems are specialized computers
integrated into other devices or systems to perform specific functions.
They can be found in appliances, vehicles, medical devices, and industrial
equipment.

Q.4: What is the role of software in a computer?


Answer:
Software refers to the programs, applications, and operating systems that
run on a computer. It provides instructions and enables the computer
hardware to perform specific tasks and operations. Software can be
classified into two main types:
System Software: This includes the operating system, device drivers, and
utility programs that manage and control the computer’s hardware,
memory, and other system resources.
Application Software: Application software consists of programs designed
to perform specific tasks or applications for users. Examples include word
processors, web browsers, graphics editors, and database management
systems.

Q.5: How does a computer process data?


Answer:
Computers process data through a series of steps:
Input: Data is entered into the computer using input devices such as
keyboards, mice, or sensors. It can be in the form of text, numbers,
images, or any other digital format.
Processing: The computer’s CPU performs calculations, manipulates data,
and executes instructions based on the input received. It follows the
instructions provided by software programs.
Storage: Data that needs to be retained for future use is stored in
memory or secondary storage devices, such as hard drives or solid-state
drives. Memory holds temporary data during processing, while storage
devices provide long-term storage.
Output: The processed data is presented to the user through output
devices, such as monitors, printers, or speakers. It can be in the form of
text, images, sound, or any other format based on the nature of the
output device.

1. Assembly level language :


It is a low-level language that allows users to write a program using
alphanumeric mnemonic codes, instead of numeric code for a set of
instructions examples of large assembly language programs from this
time are IBM PC DOS.
2. High-level language :
It is a machine-independent language. It enables a user to write a
program in a language that resembles English words and familiar
mathematical symbols, COBOL was the first high-level language.
Examples of high-level language are python,c#, etc.
Difference between assembly language and high-level language :

ASSEMBLY LEVEL
HIGH-LEVEL LANGUAGE
LANGUAGE

 It needs an assembler for  It needs a compiler/interpreter for


conversion conversion

 In this, we convert an  In this, we convert a high-level


Assembly level language language to Assembly level language
to machine level language to machine level language
 It is machine dependent  It is machine-independent

 In this mnemonics, codes


 In this English statement is used
are used

 It supports low-level  It does not support low-level


operation language

 In this, it is easy to access  In this, it is difficult to access hardware


hardware component component

 In this more compact


 No compactness
code

Addressing Modes
Last Updated : 14 Feb, 2023


Addressing Modes– The term addressing modes refers to the way in


which the operand of an instruction is specified. The addressing mode
specifies a rule for interpreting or modifying the address field of the
instruction before the operand is actually executed.
Addressing modes for 8086 instructions are divided into two
categories:
1) Addressing modes for data
2) Addressing modes for branch
The 8086 memory addressing modes provide flexible access to memory,
allowing you to easily access variables, arrays, records, pointers, and
other complex data types. The key to good assembly language
programming is the proper use of memory addressing modes.
An assembly language program instruction consists of two parts
The memory address of an operand consists of two components:
IMPORTANT TERMS
 Starting address of memory segment.
 Effective address or Offset: An offset is determined by adding any
combination of three address elements: displacement, base and
index.
o Displacement: It is an 8 bit or 16 bit immediate value given
in the instruction.
o Base: Contents of base register, BX or BP.
o Index: Content of index register SI or DI.
According to different ways of specifying an operand by 8086
microprocessor, different addressing modes are used by 8086.
Addressing modes used by 8086 microprocessor are discussed below:
 Implied mode:: In implied addressing the operand is specified in the
instruction itself. In this mode the data is 8 bits or 16 bits long and
data is the part of instruction.Zero address instruction are designed
with implied addressing mode.

Example: CLC (used to reset Carry flag to 0)


 Immediate addressing mode (symbol #):In this mode data is
present in address field of instruction .Designed like one address
instruction format.
Note:Limitation in the immediate mode is that the range of constants
are restricted by size of address field.

Example: MOV AL, 35H (move the data 35H into AL register)
 Register mode: In register addressing the operand is placed in one of
8 bit or 16 bit general purpose registers. The data is in the register
that is specified by the instruction.
Here one register reference is required to access the data.

Example: MOV AX,CX (move the contents of CX register to AX


register)
 Register Indirect mode: In this addressing the operand’s offset is
placed in any one of the registers BX,BP,SI,DI as specified in the
instruction. The effective address of the data is in the base register or
an index register that is specified by the instruction.
Here two register reference is required to access the data.

The 8086 CPUs let you access memory indirectly through a register
using the register indirect addressing modes.
 MOV AX, [BX](move the contents of memory location s
addressed by the register BX to the register AX)
Von-Neumann computer architecture:
Von-Neumann computer architecture design was proposed in 1945.It
was later known as Von-Neumann architecture.
Historically there have been 2 types of Computers:
1. Fixed Program Computers – Their function is very specific and they
couldn’t be reprogrammed, e.g. Calculators.
2. Stored Program Computers – These can be programmed to carry
out many different tasks, applications are stored on them, hence the
name.
Modern computers are based on a stored-program concept introduced
by John Von Neumann. In this stored-program concept, programs and
data are stored in the same memory. This novel idea meant that a
computer built with this architecture would be much easier to
reprogram.
The basic structure is like this,
It is also known as ISA (Instruction set architecture) computer and is
having three basic units:

1. The Central Processing Unit (CPU)


2. The Main Memory Unit
3. The Input/Output Device Let’s consider them in detail.
1. Central Processing Unit-
The central processing unit is defined as the it is an electric
circuit used for the executing the instruction of computer program.
It has following major components:
1.Control Unit(CU)
2.Arithmetic and Logic Unit(ALU)
3.variety of Registers
 Control Unit –
A control unit (CU) handles all processor control signals. It directs all
input and output flow, fetches code for instructions, and controls
how data moves around the system.
 Arithmetic and Logic Unit (ALU) –
The arithmetic logic unit is that part of the CPU that handles all the
calculations the CPU may need, e.g. Addition, Subtraction,
Comparisons. It performs Logical Operations, Bit Shifting Operations,
and Arithmetic operations.
Figure – Basic CPU structure, illustrating ALU
 Registers – Registers refer to high-speed storage areas in the CPU.
The data processed by the CPU are fetched from the registers. There
are different types of registers used in architecture :-
1. Accumulator: Stores the results of calculations made by ALU. It
holds the intermediate of arithmetic and logical operatoins.it act
as a temporary storage location or device.
2. Program Counter (PC): Keeps track of the memory location of
the next instructions to be dealt with. The PC then passes this next
address to the Memory Address Register (MAR).
3. Memory Address Register (MAR): It stores the memory
locations of instructions that need to be fetched from memory or
stored in memory.
4. Memory Data Register (MDR): It stores instructions fetched
from memory or any data that is to be transferred to, and stored
in, memory.
5. Current Instruction Register (CIR): It stores the most recently
fetched instructions while it is waiting to be coded and executed.
6. Instruction Buffer Register (IBR): The instruction that is not to
be executed immediately is placed in the instruction buffer
register IBR.

 Buses – Data is transmitted from one part of a computer to another,


connecting all major internal components to the CPU and memory,
by the means of Buses. Types:
1. Data Bus: It carries data among the memory unit, the I/O devices,
and the processor.
2. Address Bus: It carries the address of data (not the actual data)
between memory and processor.
3. Control Bus: It carries control commands from the CPU (and
status signals from other devices) in order to control and
coordinate all the activities within the computer.
 Input/Output Devices – Program or data is read into main memory
from the input device or secondary storage under the control of CPU
input instruction. Output devices are used to output information from
a computer. If some results are evaluated by the computer and it is
stored in the computer, then with the help of output devices, we can
present them to the user.
These are various registers required for the execution of instruction:
Program Counter (PC), Instruction Register (IR), Memory Buffer (or Data)
Register (MBR or MDR), and Memory Address Register (MAR).
These are explained as follows below.

1. Program Counter (PC) :


It contains the address of an instruction to be executed next. The PC
is updated by the CPU after each instruction is executed so that it
always points to the next instruction to be executed. A branch or skip
instruction will also modify the content of the PC.
2. Instruction Register (IR) :
It contains the instruction most recently fetched or executed. The
fetched instruction is loaded into an IR, where the opcode and
operand specifier is analyzed.
3. Memory Buffer (or Data) Register (MBR or MDR) :
It contains a word of data to be written to memory or the words
most recently read. Contents of MBR are directly connected to the
data bus.
4. Memory Address Register (MAR) :
It contains the address of a location of main memory from where
information has to be fetched for information has to be stored.
Contents of MAR are directly connected to the address bus. Apart
from these registers, we may use other registers which may be
invisible to the user, e.g., temporary Buffering registers.

5. Memory Data Register (MDR):


Holds the data being accessed or stored in memory.
Used to transfer data between the processor and memory.

6. Accumulator (ACC):
Holds the intermediate results of computations.
Used for arithmetic and logical operations.

7. Status Register (SR):


Holds status information about the processor and the current
instruction.
Used to indicate whether an operation was successful, to set and
clear flags, and to store error information.

8. Index Registers (IX):


Holds an offset value to be added to a memory address.
Used to access data structures or arrays.
9. Stack Pointer (SP):
Holds the memory address of the last item placed on the stack.
Used for managing the program stack during function calls and
returns.
Advantages of Zero-Address, One-Address, Two-Address and
Three-Address Instructions
Zero-address instructions
 Stack-based Operations: In stack-based architectures, where
operations implicitly employ the top items of the stack, zero-address
instructions are commonly used.
 Reduced Instruction Set: It reduces the complexity of the CPU
design by streamlining the instruction set, which may boost
reliability.
 Less Decoding Complexity: Especially helpful for recursive or
nested processes, which are frequently used in function calls and
mathematical computations.
 Efficient in Nested Operations: Less bits are required to specify
operands, which simplifies the logic involved in decoding
instructions.
 Compiler Optimization: Because stacks are based on stacks, several
algorithms can take use of this to improve the order of operations.
One-address instructions
 Intermediate Complexity: Strikes a balance between versatility and
simplicity, making it more adaptable than zero-address instructions
yet simpler to implement than multi-address instructions.
 Reduced Operand Handling: Compared to multi-address
instructions, operand fetching is made simpler by just needing to
handle a single explicit operand.
 Implicit Accumulator: Often makes use of an implicit accumulator
register, which can expedite up some operations’ execution and
simplify designs in other situations.
 Code Density: Smaller code in comparison to two- and three-
address instructions, which may result in more efficient use of
memory and the instruction cache.
 Efficient Use of Addressing Modes: Can make use of different
addressing modes (such indexed, direct, and indirect) to improve
flexibility without adding a lot of complexity.
Two-address instructions
 Improved Efficiency: Allows for the execution of operations directly
on memory or registers, which reduces the amount of instructions
required for certain activities.
 Flexible Operand Use: Increases programming variety by offering
more options for operand selection and addressing modes.
 Intermediate Data Storage: May directly store interim results,
increasing some algorithms’ and calculations’ efficiency.
 Enhanced Code Readability: Produces code that is frequently easier
to read and comprehend than one-address instructions, which is
beneficial for maintenance and troubleshooting.
 Better Performance: Better overall performance can result from
these instructions because they minimize the amount of memory
accesses required for certain processes.
Three-address instructions
 Direct Representation of Expressions: Reduces the need for
temporary variables and extra instructions by enabling the direct
representation of complicated expressions.
 Parallelism: Allows for the simultaneous fetching and processing of
several operands, which facilitates parallelism in CPU architecture.
 Compiler Optimization: Makes it possible for more complex
compiler optimizations to be implemented, which improve execution
efficiency by scheduling and reordering instructions.
 Reduced Instruction Count: May increase execution performance
even with bigger instruction sizes by perhaps lowering the overall
number of instructions required for complicated processes.
 Improved Pipeline Utilization: More information in each instruction
allows CPU pipelines to be used more efficiently, increasing
throughput overall.
 Better Register Allocation: Permits direct manipulation of several
registers inside a single instruction, enabling more effective usage of
registers.
Disadvantages of Zero-Address, One-Address, Two-Address and
Three-Address Instructions
Zero-address instructions
 Stack Dependency: In contrast to register-based architectures, zero-
address instructions might result in inefficiencies when it comes to
operand access because of their heavy reliance on the stack.
 Overhead of Stack Operations: Performance might be negatively
impacted by the frequent push and pop actions needed to maintain
the stack.
 Limited Addressing Capability: The processing of intricate data
structures may become more difficult since they do not directly
support accessing memory regions or registers.
 Difficult to Optimize: Because operand access is implied in stack-
based designs, code optimization might be more difficult.
 Harder to Debug: When compared to register-based operations,
stack-based operations might be less obvious and more difficult to
debug.
One-address instructions
 Accumulator Bottleneck: Often uses an accumulator, which can act
as a bottleneck and reduce efficiency and parallelism.
 Increased Instruction Count: Multiple instructions may be needed
for complex processes, which would increase the overall number of
instructions and code size.
 Less Efficient Operand Access: There is just one operand that is
specifically addressed, which might result in inefficient access
patterns and extra data management instructions.
 Complex Addressing Modes: The instruction set and decoding
procedure get more complicated when several addressing modes are
supported.
 Data Movement Overhead: Moving data between memory and the
accumulator could need more instructions, which would increase
overhead.
Two-address instructions
 Operand Overwriting: Usually, the result overwrites one of the
source operands, which might lead to an increase in the number of
instructions needed to maintain data.
 Larger Instruction Size: Because two-address instructions are
bigger than zero- and one-address instructions, the memory
footprint may be increased.
 Intermediate Results Handling: It is frequently necessary to handle
intermediate outcomes carefully, which can make programming
more difficult and result in inefficiencies.
 Decoding Complexity: The design and performance of the CPU may
be impacted by the greater complexity involved in decoding two
addresses.
 Inefficient for Some Operations: The two-address style could still
be inefficient for some tasks, needing more instructions to get the
desired outcome.
Three-address instructions
 Largest Instruction Size: Has the highest memory requirements per
instruction, which can put strain on the instruction cache and
increase code size.
 Complex Instruction Decoding: Three addresses to decode adds
complexity to the CPU architecture, which might affect power
consumption and performance.
 Increased Operand Fetch Time: Each instruction may execute more
slowly if obtaining three operands takes a long period.
 Higher Hardware Requirements: Has the potential to raise cost
and power consumption since it requires more advanced hardware
to handle the higher operand handling and addressing capabilities.
 Power Consumption: Higher power consumption is a crucial factor
for devices that run on batteries since it can be caused by more
complicated instructions and increased memory utilization.

Introduction of ALU and Data Path



Representing and storing numbers were the basic operations of the


computers of earlier times. The real go came when computation,
manipulating numbers like adding and multiplying came into the picture.
These operations are handled by the computer’s arithmetic logic unit
(ALU). The ALU is the mathematical brain of a computer. The first ALU
(Arithmetic Logic Unit) was indeed the INTEL 74181, which was
implemented as part of the 7400 series TTL (Transistor-Transistor Logic)
integrated circuits. It was released by Intel in 1970.
What is ALU?
ALU is a digital circuit that provides arithmetic and logic operations. It is
the fundamental building block of the central processing unit of a
computer. A modern central processing unit(CPU) has a very powerful
ALU and it is complex in design. In addition to ALU modern CPU contains
a control unit and a set of registers. Most of the operations are
performed by one or more ALUs, which load data from the input
register. Registers are a small amount of storage available to the CPU.
These registers can be accessed very fast. The control unit tells ALU what
operation to perform on the available data. After
calculation/manipulation, the ALU stores the output in an output
register.
The CPU can be divided into two sections: the data section and
the control section. The data section is also known as the data path.
BUS
In early computers BUS were parallel electrical wires with multiple
hardware connections. Therefore a bus is a communication system that
transfers data between components inside a computer, or between
computers. It includes hardware components like wires, optical fibers, etc
and software, including communication protocols. The Registers, ALU,
and the interconnecting BUS are collectively referred to as data paths.

Types of the bus

There are mainly three type of bus:-


1. Address bus: Transfers memory addresses from the processor to
components like storage and input/output devices. It’s one-way
communication.
2. Data bus: carries the data between the processor and other
components. The data bus is bidirectional.
3. Control bus: carries control signals from the processor to other
components. The control bus also carries the clock’s pulses. The
control bus is unidirectional.
The bus can be dedicated, i.e., it can be used for a single purpose or it
can be multiplexed, i.e., it can be used for multiple purposes. when we
would have different kinds of buses, different types of bus organizations
will take place.
Registers
In Computer Architecture, the Registers are very fast computer memory
which is used to execute programs and operations efficiently. but In that
scenario, registers serve as gates, sending signals to various components
to carry out little tasks. Register signals are directed by the control unit,
which also operates the registers.
The following list of five registers for in-out signal data storage:
1. Program Counter
A program counter (PC) is a CPU register in the computer processor
which has the address of the next instruction to be executed
from memory. As each instruction gets fetched, the program counter
increases its stored value by 1. It is a digital counter needed for faster
execution of tasks as well as for tracking the current execution point.
2. Instruction Register
In computing, an instruction register (IR) is the part of a CPU’s control
unit that holds the instruction currently being executed or decoded.
The instruction register specifically holds the instruction and provides
it to the instruction decoder circuit.
3. Memory Address Register
The Memory Address Register (MAR) is the CPU register that either
stores the memory address from which data will be fetched from the
CPU, or the address to which data will be sent and stored. It is a
temporary storage component in the CPU(central processing unit)
that temporarily stores the address (location) of the data sent by the
memory unit until the instruction for the particular data is executed.
4. Memory Data Register
The memory data register (MDR) is the register in a computer’s
processor, or central processing unit, CPU, that stores the data being
transferred to and from the immediate access storage. Memory data
register (MDR) is also known as memory buffer register (MBR).
5. General Purpose Register
General-purpose registers are used to store temporary data within
the microprocessor. It is a multipurpose register. They can be used
either by a programmer or by a user.
What is Data Path?
Suppose that the CPU needs to carry out any data processing action,
such as copying data from memory to a register and vice versa, moving
register content from one register to another, or adding two numbers in
the ALU. Therefore, whenever a data processing action takes place in the
CPU, the data involved for that operation follows a particular path, or
data path.
Data paths are made up of various functional components, such as
multipliers or arithmetic logic units. Data path is is required to do data
processing operations.
One Bus Organization

In one bus organization, a single bus is used for multiple purposes. A set
of general-purpose registers, program counters, instruction registers,
memory address registers (MAR), memory data registers (MDR) are
connected with the single bus. Memory read/write can be done with
MAR and MDR. The program counterpoints to the memory location from
where the next instruction is to be fetched. Instruction register is that
very register will hold the copy of the current instruction. In the case of
one bus organization, at a time only one operand can be read from the
bus.
As a result, if the requirement is to read two operands for the operation
then the read operation needs to be carried twice. So that’s why it is
making the process a little longer. One of the advantages of one bus
organization is that it is one of the simplest and also this is very cheap to
implement. At the same time a disadvantage lies that it has only one bus
and this “one bus” is accessed by all general-purpose registers, program
counter, instruction register, MAR, MDR making each and every
operation sequential. No one recommends this architecture nowadays.
Two Bus Organization
To overcome the disadvantage of one bus organization another
architecture was developed known as two bus organization. In two bus
organizations, there are two buses. The general-purpose register can
read/write from both the buses. In this case, two operands can be
fetched at the same time because of the two buses. One bus fetch
operand for ALU and another bus fetch for register. The situation arises
when both buses are busy fetching operands, the output can be stored
in a temporary register and when the buses are free, the particular
output can be dumped on the buses.
There are two versions of two bus organizations, i.e., in-bus and out-bus.
From in-bus, the general-purpose register can read data and to the out
bus, the general-purpose registers can write data. Here buses get
dedicated.
Three Bus Organization
In three bus organizations we have three buses, OUT bus1, OUT bus2,
and an IN bus. From the out buses, we can get the operand which can
come from the general-purpose register and evaluated in ALU and the
output is dropped on In Bus so it can be sent to respective registers. This
implementation is a bit complex but faster in nature because in parallel
two operands can flow into ALU and out of ALU. It was developed to
overcome the busy waiting problem of two bus organizations. In this
structure after execution, the output can be dropped on the bus without
waiting because of the presence of an extra bus. The structure is given
below in the figure.
The main advantages of multiple bus organizations over the single bus
are as given below.
1. Increase in size of the registers.
2. Reduction in the number of cycles for execution.
3. Increases the speed of execution or we can say faster execution.

Microarchitecture and Instruction Set Architecture


Last Updated : 21 Jan, 2022


In this article, we look at what an Instruction Set Architecture (ISA) is and


what is the difference between an ‘ISA’ and Microarchitecture. An ISA is
defined as the design of a computer from the Programmer’s Perspective.
This basically means that an ISA describes the design of a Computer in
terms of the basic operations it must support. The ISA is not concerned
with the implementation-specific details of a computer. It is only
concerned with the set or collection of basic operations the computer
must support. For example, the AMD Athlon and the Core 2 Duo
processors have entirely different implementations but they support
more or less the same set of basic operations as defined in the x86
Instruction Set.
Let us try to understand the Objectives of an ISA by taking the example
of the MIPS ISA. MIPS is one of the most widely used ISAs in education
due to its simplicity.

1. The ISA defines the types of instructions to be supported by the


processor.
Based on the type of operations they perform MIPS Instructions are
classified into 3 types:
 Arithmetic/Logic Instructions:
These Instructions perform various Arithmetic & Logical operations
on one or more operands.
 Data Transfer Instructions:
These instructions are responsible for the transfer of instructions
from memory to the processor registers and vice versa.
 Branch and Jump Instructions:
These instructions are responsible for breaking the sequential flow
of instructions and jumping to instructions at various other
locations, this is necessary for the implementation
of functions and conditional statements.

2. The ISA defines the maximum length of each type of instruction.


Since the MIPS is a 32 bit ISA, each instruction must be
accommodated within 32 bits.

3. The ISA defines the Instruction Format of each type of instruction.


The Instruction Format determines how the entire instruction is
encoded within 32 bits
There are 3 types of Instruction Formats in the MIPS ISA:
 R-Instruction Format
 I-Instruction Format
 J-Instruction Format
If we look at the Abstraction Hierarchy:

Figure – The Abstraction Hierarchy


We note that the Microarchitectural level lies just below the ISA level
and hence is concerned with the implementation of the basic operations
to be supported by the Computer as defined by the ISA. Therefore we
can say that the AMD Athlon and Core 2 Duo processors are based on
the same ISA but have different microarchitectures with different
performance and efficiencies.
Now one may ask the need to distinguish
between Microarchitecture and ISA?
The answer to this lies in the need to standardize and maintain the
compatibility of programs across different hardware implementations
based on the same ISA. Making different machines compatible with the
same set of basic instructions (The ISA) allows the same program to run
smoothly on many different machines thereby making it easier for the
programmers to document and maintain code for many different
machines simultaneously and efficiently.
This Flexibility is the reason we first define an ISA and then design
different microarchitectures complying with this ISA for implementing
the machine. The design of a lower-level ISA is one of the major tasks in
the study of Computer Architecture.

Instruction Set Architecture Microarchitecture

The ISA is responsible for The Microarchitecture is more


defining the set of concerned with the lower level
instructions to be supported implementation of how the instructions
by the processor. For are going to be executed and deals with
example, some of the concepts like Instruction Pipelining,
instructions defined by the Branch Prediction, Out of Order
ARMv7 ISA are given below. Execution.

Introduction to memory and memory units


Last Updated : 22 Apr, 2024


In order to save data and instructions, memory is required. Memory is


divided into cells, and they are stored in the storage space present in the
computer. Every cell has its unique location/address. Memory is very
essential for a computer as this is the way it becomes somewhat more
similar to a human brain.
What is Memory?
Memory devices are digital systems that store data either temporarily or
for a long term. Digital computers to hard disks have built-in memory
devices that can store the data of users or manufacturers. The data either
be in the form of control programs or programs that boot the system.
Hence, to store such a huge amount of data the memory devices must
have enormous capacity. The challenge is to build memory devices that
have large capacities but are cost-effective. The memory devices must be
capable of storing both permanent data and instantaneous data.
Memories are made up of registers. Each register in the memory is one
storage location. The storage location is also called a memory location.
Memory locations are identified using Address. The total number of bits
a memory can store is its capacity. A storage element is called a Cell.
Each register is made up of a storage element in which one bit of data is
stored. The data in a memory are stored and retrieved by the process
called writing and reading respectively.

A word is a group of bits where a memory unit stores binary information.


A word with a group of 8 bits is called a byte.
A memory unit consists of data lines, address selection lines, and control
lines that specify the direction of transfer.
The block diagram of a memory unit is shown below:

Data lines provide the information to be stored in memory. The control


inputs specify the direct transfer. The k-address lines specify the word
chosen.
When there are k address lines, 2k memory words can be accessed.
Types of Computer Memory
 Cache memory. This temporary storage area, known as a cache, is
more readily available to the processor than the computer’s main
memory source. It is also called CPU memory because it is typically
integrated directly into the CPU chip or placed on a separate chip
with a bus interconnect with the CPU.
 RAM. It is one of the parts of the Main memory, also famously
known as Read Write Memory. Random Access memory is present on
the motherboard and the computer’s data is temporarily stored in
RAM. As the name says, RAM can help in both Read and write.
 D RAM (Dynamic RAM): D RAM uses capacitors and transistors and
stores the data as a charge on the capacitors. They contain thousands
of memory cells. It needs refreshing of charge on capacitor after a few
milliseconds. This memory is slower than S RAM.
 S RAM (Static RAM): S RAM uses transistors and the circuits of this
memory are capable of retaining their state as long as the power is
applied. This memory consists of the number of flip flops with each
flip flop storing 1 bit. It has less access time and hence, it is faster.
 ROM: ROM full form is Read Only Memory. ROM is a non volatile
memory and it is used to store important information which is used to
operate the system. We can only read the programs and data stored
on it and can not modify of delete it.
 MROM(Masked ROM): Hard-wired devices with a pre-programmed
collection of data or instructions were the first ROMs. Masked ROMs
are a type of low-cost ROM that works in this way.
 PROM (Programmable Read Only Memory): This read-only
memory is modifiable once by the user. The user purchases a blank
PROM and uses a PROM program to put the required contents into
the PROM. Its content can’t be erased once written.
 EPROM (Erasable Programmable Read Only Memory): EPROM is
an extension to PROM where you can erase the content of ROM by
exposing it to Ultraviolet rays for nearly 40 minutes.
 EEPROM (Electrically Erasable Programmable Read Only
Memory): Here the written contents can be erased electrically. You
can delete and reprogramme EEPROM up to 10,000 times. Erasing
and programming take very little time, i.e., nearly 4 -10
ms(milliseconds). Any area in an EEPROM can be wiped and
programmed selectively.
 Virtual memory. A memory management technique where
secondary memory can be used as if it were a part of the main
memory. Virtual memory uses hardware and software to enable a
computer to compensate for physical memory shortages by
temporarily transferring data from RAM to disk storage.
Units of Memory
Memory units are used to measure the size and represent data. Some of
the commonly used memory units are:
1. Bit
The first memory location in a computer is bit. The smallest
measurement unit for data held in primary memory and storage
devices is a bit. Out of the binary values 0 and 1, a bit can only have one.
 The smallest measurement unit for data in primary memory and
storage devices.
 Represents binary values 0 and 1.
2. Nibble
 It means the group of 4 bits.
3. Word
It is a fixed number of bits, it is different from computer to computer, but
the same for each device. Compute store information in the form of
words.
 A fixed number of bits that varies across computers but remains
consistent within each device.
 Used to store information in computers.
4. Bytes
The fundamental unit used to measure data is the byte. It has 8 bits in it.
A byte can therefore represent 2 * 8 or 256 values. They determine the
size of files, documents, photos, and other kinds of data.
 The fundamental unit for measuring data, consisting of 8 bits.
 Represents 256 values and determines file, document, photo, and
data sizes.
5. Kilobyte
1024 bytes is equal to one kilobyte. It is widely used to denote small file
sizes and data storage capacities. One kilobyte can hold a small image or
around 1024 characters of text. It frequently shows up in text
documents, spreadsheets, and small image files.
 Equal to 1024 bytes.
 Denotes small file sizes and storage capacities.
 Can hold small images or around 1024 characters of text.
6. Meghabyte
A megabyte is 1024 kilobytes in size. It contains more info as compared
to a kilobyte. A megabyte can hold longer texts, high-resolution images,
and short audio clips. It is used to calculate the size of files comprising
music and short films, software packages, and documents. Megabytes
are still important and frequently used, even though larger units of
measurement are being used more frequently as a result of the growing
number of data files.
 Comprising 1024 kilobytes.
 Contains more information compared to a kilobyte.
 Holds longer texts, high-resolution images, and short audio clips.
 Measures file sizes of music, short films, software packages, and
documents.
7. Gigabyte
1024 megabytes is equal to one gigabyte. It has a substantial amount of
data storage space. Larger files, such full photo albums, high-definition
movies, and software programs can fit within a gigabit. The storage
capabilities of hard drives, solid-state drives, and other forms of data
storage devices are routinely assessed utilizing this technique.
 Equal to 1024 megabytes.
 Offers substantial data storage space.
 Suitable for larger files, such as full photo albums, high-definition
movies, and software programs.
8. Terabyte
A terabyte is made up of 1024 gigabytes. It has a substantial amount of
data storing capacity. A terabyte can hold a lot of data in large
databases, massive media collections, and enterprise-level storage
systems. It is frequently used by data centers, cloud storage services, and
external hard drives with large storage capacities. As the demand for
large-scale data processing and storage grows, terabytes are becoming
more and more important.
 Comprising 1024 gigabytes.
 Provides substantial data storing capacity.
 Holds large databases, media collections, and enterprise-level storage
systems.
9. Petabyte
A petabyte is a colossal unit of data storage capacity. A petabyte may
hold massive amounts of data, including significant video libraries,
sizable databases, and sizable collections of high-resolution pictures. It is
often used in data centers, cloud storage, and scientific research that
uses a lot of data.
 A colossal unit of data storage capacity.
 Stores massive data quantities, like video libraries and large
databases.
10. Exabyte (1024 petabytes)
An exabyte is equal to one EB. It has a substantial amount of data
storage space. Exabytes can store vast film archives, massive data
warehouses, and global internet traffic. It is extensively used in large-
scale scientific simulations, cloud computing infrastructures, and
enterprise-level storage systems.
 Equal to 1024 petabytes.
 Holds vast film archives, data warehouses, and global internet traffic.
11. Zettabyte (1024 exabytes)
A zettabyte. It represents a capacity for data storage that is almost
unimaginable. Zettabytes have the capacity to store unfathomably large
amounts of data, including worldwide internet content, long-term
archival storage, and in-depth global data analysis.
 Represents an almost unimaginable data storage capacity.
 Stores worldwide internet content, long-term archival data, and
extensive global analysis.
12. Yottabyte
1024 zettabytes make up a yottabyte (abbreviated YB). It stands for an
incredible amount of data storage. Unimaginable amounts of data, such
as the equivalent of storing all of the material on the internet numerous
times or tracking vast amounts, may be stored in yottabytes.
 Comprising 1024 zettabytes.
 Stands for an incredible amount of data storage.
 Can hold vast amounts equivalent to storing internet content
numerous times.

Memory Hierarchy Design and its Characteristics


Last Updated : 19 Jun, 2023


In the Computer System Design, Memory Hierarchy is an enhancement


to organize the memory such that it can minimize the access time. The
Memory Hierarchy was developed based on a program behavior known
as locality of references. The figure below clearly demonstrates the
different levels of the memory hierarchy.
Why Memory Hierarchy is Required in the System?
Memory Hierarchy is one of the most required things in Computer
Memory as it helps in optimizing the memory available in the computer.
There are multiple levels present in the memory, each one having a
different size, different cost, etc. Some types of memory like cache, and
main memory are faster as compared to other types of memory but they
are having a little less size and are also costly whereas some memory has
a little higher storage value, but they are a little slower. Accessing of data
is not similar in all types of memory, some have faster access whereas
some have slower access.
Types of Memory Hierarchy
This Memory Hierarchy Design is divided into 2 main types:
 External Memory or Secondary Memory: Comprising of Magnetic
Disk, Optical Disk, and Magnetic Tape i.e. peripheral storage devices
which are accessible by the processor via an I/O Module.
 Internal Memory or Primary Memory: Comprising of Main Memory,
Cache Memory & CPU registers. This is directly accessible by the
processor.

Memory Hierarchy Design

Memory Hierarchy Design

1. Registers

Registers are small, high-speed memory units located in the CPU. They
are used to store the most frequently used data and instructions.
Registers have the fastest access time and the smallest storage capacity,
typically ranging from 16 to 64 bits.

2. Cache Memory

Cache memory is a small, fast memory unit located close to the CPU. It
stores frequently used data and instructions that have been recently
accessed from the main memory. Cache memory is designed to minimize
the time it takes to access data by providing the CPU with quick access
to frequently used data.
3. Main Memory
Main memory, also known as RAM (Random Access Memory), is the
primary memory of a computer system. It has a larger storage capacity
than cache memory, but it is slower. Main memory is used to store data
and instructions that are currently in use by the CPU.
Types of Main Memory
 Static RAM: Static RAM stores the binary information in flip flops and
information remains valid until power is supplied. It has a faster access
time and is used in implementing cache memory.
 Dynamic RAM: It stores the binary information as a charge on the
capacitor. It requires refreshing circuitry to maintain the charge on the
capacitors after a few milliseconds. It contains more memory cells per
unit area as compared to SRAM.

4. Secondary Storage

Secondary storage, such as hard disk drives (HDD) and solid-state drives
(SSD), is a non-volatile memory unit that has a larger storage capacity
than main memory. It is used to store data and instructions that are not
currently in use by the CPU. Secondary storage has the slowest access
time and is typically the least expensive type of memory in the memory
hierarchy.

5. Magnetic Disk
Magnetic Disks are simply circular plates that are fabricated with either a
metal or a plastic or a magnetized material. The Magnetic disks work at a
high speed inside the computer and these are frequently used.

6. Magnetic Tape

Magnetic Tape is simply a magnetic recording device that is covered


with a plastic film. It is generally used for the backup of data. In the case
of a magnetic tape, the access time for a computer is a little slower and
therefore, it requires some amount of time for accessing the strip.
Characteristics of Memory Hierarchy
 Capacity: It is the global volume of information the memory can
store. As we move from top to bottom in the Hierarchy, the capacity
increases.
 Access Time: It is the time interval between the read/write request
and the availability of the data. As we move from top to bottom in the
Hierarchy, the access time increases.
 Performance: Earlier when the computer system was designed
without a Memory Hierarchy design, the speed gap increased
between the CPU registers and Main Memory due to a large
difference in access time. This results in lower performance of the
system and thus, enhancement was required. This enhancement was
made in the form of Memory Hierarchy Design because of which the
performance of the system increases. One of the most significant
ways to increase system performance is minimizing how far down the
memory hierarchy one has to go to manipulate data.
 Cost Per Bit: As we move from bottom to top in the Hierarchy, the
cost per bit increases i.e. Internal Memory is costlier than External
Memory.
Advantages of Memory Hierarchy
 It helps in removing some destruction, and managing the memory in
a better way.
 It helps in spreading the data all over the computer system.
 It saves the consumer’s price and time.

Cache Memory
Last Updated : 05 Jun, 2024


Cache memory is a special type of high-speed memory located close to


the CPU in a computer. It stores frequently used data and instructions,
So that the CPU can access them quickly, improving the overall speed
and efficiency of the computer.
It is a faster and smaller segment of memory whose access time is as
close as registers. In a hierarchy of memory, cache memory has access
time lesser than primary memory. Generally, cache memory is used as a
buffer.
In this article we will see cache memory in detail.
What is Cache Memory?
Data in primary memory can be accessed faster than secondary memory
but still, access times of primary memory are generally in a few
microseconds, whereas the CPU is capable of performing operations in
nanoseconds. Due to the time lag between accessing data and acting on
data performance of the system decreases as the CPU is not utilized
properly, it may remain idle for some time. In order to minimize this time
gap new segment of memory is Introduced known as Cache Memory.
It is based on principle of locality of reference, which refers to the
observation that program tries to access a relatively small portion of
their address space at any given time, and repeatedly tries to access
some portion of the memory. For ex: In fees department of your college,
transactions are accessed frequently to check on the dues.
Key Features of Cache Memory
1. Speed: Faster than the main memory (RAM), which helps the CPU
retrieve data more quickly.
2. Proximity: Located very close to the CPU, often on the CPU chip
itself, reducing data access time.
3. Function: Temporarily holds data and instructions that the CPU is
likely to use again soon, minimizing the need to access the slower
main memory.
Role of Cache Memory
The role of cache memory is explained below,
 Cache memory plays a crucial role in computer systems.
 It provide faster access.
 It acts buffer between CPU and main memory(RAM).
 Primary role of it is to reduce average time taken to access data,
thereby improving overall system performance.
Benefits of Cache Memory
Various benefits of the cache memory are,
1. Faster access: Faster than main memory. It resides closer to CPU ,
typically on same chip or in close proximity. Cache stores subset of
data and instruction.
2. Reducing memory latency: Memory access latency refers to time
taken for processes to retrieve data from memory. Caches are
designed to exploit principle of locality.
3. Lowering bus traffic: Accessing data from main memory involves
transferring it over system bus. Bus is shared resource and excessive
traffic can lead to congestion and slower data transfers. By utilizing
cache memory , processor can reduce frequency of accessing main
memory resulting in less bus traffic and improves system efficiency.
4. Increasing effective CPU utilization: Cache memory allows CPU to
operate at a higher effective speed. CPU can spend more time
executing instruction rather than waiting for memory access. This
leads to better utilization of CPU’s processing capabilities and higher
overall system performance.
5. Enhancing system scalability: Cache memory helps improve system
scalability by reducing impact of memory latency on overall system
performance.
Working of Cache Memory
In order to understand the working of cache we must understand few
points:
 Cache memory is faster, they can be accessed very fast
 Cache memory is smaller, a large amount of data cannot be stored
Whenever CPU needs any data it searches for corresponding data in the
cache (fast process) if data is found, it processes the data according to
instructions, however, if data is not found in the cache CPU search for
that data in primary memory(slower process) and loads it into the cache.
This ensures frequently accessed data are always found in the cache and
hence minimizes the time required to access the data.
How does Cache Memory Improve CPU Performance?
Cache memory improves CPU performance by reducing the time it takes
for the CPU to access data. By storing frequently accessed data closer to
the CPU, it minimizes the need for the CPU to fetch data from the slower
main memory.
What is a Cache Hit and a Cache Miss?
Computer Organization and Architecture | Pipelining | Set 1
(Execution, Stages and Throughput)
Last Updated : 09 Aug, 2023


To improve the performance of a CPU we have two options: 1) Improve


the hardware by introducing faster circuits. 2) Arrange the hardware such
that more than one operation can be performed at the same time. Since
there is a limit on the speed of hardware and the cost of faster circuits is
quite high, we have to adopt the 2nd option.
Pipelining is a process of arrangement of hardware elements of the CPU
such that its overall performance is increased. Simultaneous execution of
more than one instruction takes place in a pipelined processor. Let us
see a real-life example that works on the concept of pipelined operation.
Consider a water bottle packaging plant. Let there be 3 stages that a
bottle should pass through, Inserting the bottle(I), Filling water in the
bottle(F), and Sealing the bottle(S). Let us consider these stages as stage
1, stage 2, and stage 3 respectively. Let each stage take 1 minute to
complete its operation. Now, in a non-pipelined operation, a bottle is
first inserted in the plant, after 1 minute it is moved to stage 2 where
water is filled. Now, in stage 1 nothing is happening. Similarly, when the
bottle moves to stage 3, both stage 1 and stage 2 are idle. But in
pipelined operation, when the bottle is in stage 2, another bottle can be
loaded at stage 1. Similarly, when the bottle is in stage 3, there can be
one bottle each in stage 1 and stage 2. So, after each minute, we get a
new bottle at the end of stage 3. Hence, the average time taken to
manufacture 1 bottle is:
Without pipelining = 9/3 minutes = 3m
IFS||||||
|||IFS|||
| | | | | | I F S (9 minutes)
With pipelining = 5/3 minutes = 1.67m
IFS||
|IFS|
| | I F S (5 minutes)
Thus, pipelined operation increases the efficiency of a system.
Design of a basic pipeline
 In a pipelined processor, a pipeline has two ends, the input end and
the output end. Between these ends, there are multiple
stages/segments such that the output of one stage is connected to
the input of the next stage and each stage performs a specific
operation.
 Interface registers are used to hold the intermediate output between
two stages. These interface registers are also called latch or buffer.
 All the stages in the pipeline along with the interface registers are
controlled by a common clock.
Execution in a pipelined processor Execution sequence of instructions
in a pipelined processor can be visualized using a space-time diagram.
For example, consider a processor having 4 stages and let there be 2
instructions to be executed. We can visualize the execution sequence
through the following space-time diagrams:
Non-overlapped execution:
Stage / Cycle 1 2 3 4 5 6 7 8

S1 I1 I2

S2 I1 I2

S3 I1 I2

S4 I1 I2
Stage / Cycle 1 2 3 4 5 6 7 8

Total time = 8 Cycle


Overlapped execution:
Stage /
Cycle 1 2 3 4 5

S1 I1 I2

S2 I1 I2

S3 I1 I2

S4 I1 I2

Total time = 5 Cycle Pipeline Stages RISC processor has 5 stage


instruction pipeline to execute all the instructions in the RISC instruction
set. Following are the 5 stages of the RISC pipeline with their respective
operations:
 Stage 1 (Instruction Fetch) In this stage the CPU reads instructions
from the address in the memory whose value is present in the
program counter.
 Stage 2 (Instruction Decode) In this stage, instruction is decoded
and the register file is accessed to get the values from the registers
used in the instruction.
 Stage 3 (Instruction Execute) In this stage, ALU operations are
performed.
 Stage 4 (Memory Access) In this stage, memory operands are read
and written from/to the memory that is present in the instruction.
 Stage 5 (Write Back) In this stage, computed/fetched value is written
back to the register present in the instructions.
Performance of a pipelined processor Consider a ‘k’ segment pipeline
with clock cycle time as ‘Tp’. Let there be ‘n’ tasks to be completed in the
pipelined processor. Now, the first instruction is going to take ‘k’ cycles
to come out of the pipeline but the other ‘n – 1’ instructions will take
only ‘1’ cycle each, i.e, a total of ‘n – 1’ cycles. So, time taken to execute
‘n’ instructions in a pipelined processor:

You might also like