Ch-3. Computer Architecture
Ch-3. Computer Architecture
Computer Architecture
Input Unit:
It Performs following functions:
• Accepts instruction and data from
used
• Converts in to computer understandable
form
• Supplies converted data and instruction to
CPU
Output Unit:
It performs following functions:
Page 2
Functions of CPU:
• It transfers instructions and input data from main memory to registers.
• Then executes the instruction in stored sequence.
• Then transfers output data from registers to main memory.
Page 3
• CPU controls all the internal and external devices and performs arithmetic and
logic operations.
Control Unit:
• The control unit of a computer does not do any actual processing of data.
• It organises the processing of data and instructions.
• It controls and coordinates the activity of the other units of computer.
• CU coordinates the input and output devices of a computer.
fi
fi
fi
Page 4
Registers:
• Registers are high-speed storage areas within the CPU, but have the least storage
capacity.
• Registers are not referenced by their address, but are directly accessed and
manipulated by the CPU during instruction execution.
• Registers store data, instructions, addresses and intermediate results of
processing.
• Registers are often referred to as the CPU’s working memory.
• The data and instructions that require processing must be brought in the registers
of CPU before they can be processed. For example, if two numbers are to be
added, both numbers are brought in the registers, added and the result is also
placed in a register.
• Registers are used for different purposes, with each register serving a speci c
purpose.
• Registers are primarily made up of ip- ops, which are electronic circuits
capable of storing a single bit of information.
• A 4-bit register would consist of four ip- ops, each capable of storing one bit of
data.
fl
fl
fl
fl
fi
Page 5
• 32-bit processor and 64-bit processor are the terms used to refer to the size of the
registers.
• Other factors remaining the same, a 64-bit processor can process the data twice
as fast as one with 32-bit processor.
Memory Unit:
Its function is to hold data and instructions. It consists of:
1. Primary Memory :
A. Volatile Memory (Eg. RAM, Cache Memory)
B. No Volatile Memory ( Eg. ROM, PROM, EPROM, EEPROM)
2. Secondary Memory: ( Eg. Hard Disk, SSD, CD ROM, Pen Drive, Floppy
Disk, DVD)
1. Primary Memory :
Primary memory is the main memory of computer and it can be accessed directly by
the processor.
Types of RAM:
Dynamic Random Access Memory (DRAM)
• It needs to periodically refresh in a few milliseconds to retain data.
• DRAM is made up of capacitors and transistors and electric charge leaks from
capacitors and DRAM needs to be charged periodically.
• DRAM is widely used in home PCs and servers as it is cheaper than SRAM.
• Advantage: Low manufacturing cost, greater memory capacity
• Disadvantage : Slow access speed, high power consumption.
• DDR2 and DDR3 SDRAM are upgraded version with 240 pins with higher
clock speed and lower power consumption ( 1.8V, 1.5V).
• DDR4 SDRAM uses a 288-pin con guration and 1.2 V.
Types of ROM:
ROM can be broadly classi ed into 4 types based on their behaviour:
• MROM: Masked ROM is hardwired and pre-programmed ROM. Any
content that is once written cannot be altered anyhow.
• PROM: Programmable ROM can be modi ed once by the user. The user buys
a blank PROM and writes the desired content but once written content cannot
be altered.
• EPROM: Erasable and Programmable ROM Content can be changed by
erasing the initial content which can be done by exposing EPROM to UV
radiation. This exposure to ultra-violet light dissipates the charge on ROM and
content can be rewritten on it. These were widely used as BIOS (Basic Input
Output System) chips on motherboard.
fi
fi
fi
fi
Page 10
Cache Memory
• The data and instructions that are required during the processing of data are
brought from the secondary storage devices and stored in the RAM. For
processing, it is required that the data and instructions are accessed from the RAM
and stored in the registers. The time taken to move the data between RAM and
CPU registers is large. This affects the speed of processing of computer, and
results in decreasing the performance of CPU.
• Cache memory is a very high speed memory placed in between RAM and CPU
which increases the speed of processing.
• Cache memory is a storage buffer that stores the data that is used more often,
temporarily, and makes them available to CPU at a fast rate.
• During processing, CPU rst checks cache for the required data. If data is not
found in cache, then it looks in the RAM for data.
• To access the cache memory, CPU does not have to use the motherboard’s system
bus for data transfer.
• Cache memory is built into the processor, and may also be located next to it on a
separate chip between the CPU and RAM.
• Cache built into the CPU is faster than separate cache.
• The CPU has a built-in Level 1 (L1) cache and Level2 (L2) cache.
• In addition to the built-in L1 and L2 cache, some CPUs have a separate cache chip
on the motherboard. This cache on the motherboard is called Level 3 (L3) cache.
• Nowadays, high-end processor comes with built-in L3 cache, like in Intel core i7.
fi
Page 11
• The L1, L2 and L3 cache store the most recently run instructions, the next ones
and the possible ones, respectively.
• Typically, CPUs have cache size varying from 256KB (L1), 6 MB (L2), to 12MB
(L3) cache.
• Cache memory is very expensive, so it is smaller in size.
• Generally, computers have cache memory of sizes 256 KB to 2 MB.
Working Principle:
It works on the principle of Locality of Reference i.e. the tendency of processor to
access the same memory locations repetitively over a short period of time. It Stores
data from some frequently used addresses of main memory.
Types of Locality:
1. Temporal Locality: Data that has been recently accessed is likely to be
accessed again soon.
2. Spatial Locality: Data located near each other in memory is likely to be
accessed together.
• Cache hit: Data found in cache. Results in data transfer at maximum speed.
• Cache miss: Data not found in cache. Processor loads data from RAM and
copies into cache. This results in extra delay, called miss penalty.
Cache Line/Block:
Cache is partitioned into lines also called blocks. Each line has 4-64 bytes in it.
During data transfer, a whole line is read or written. Each line has a tag that indicates
the address in RAM from which the line has been coped.
fi
Page 12
Types of Cache:
1. Fully Associative Cache:
In a cache with complete associativity, any memory
address may be stored in just about any cache line. This
memory type considerably reduces the number of
cache-line misses and is considered a complicated
implementation of cache memory.
2. Direct-Mapped Cache:
A given memory block can be mapped into one and only cache line.
• Write through:
Data is written to both the cache and main
memory at the same time.
• Write through:
Initially, writing is done only to the cache. The write to the RAM is postponed
until the modi ed content is about to be replaced by another cache block.
• Split Cache:
In split cache, code and data are placed separately on two different cache
portions. In this cache, the size of code and data portion is not exible and can
not be changed according to the situation. In this cache, all the load requests of
data come to data cache portion and all the fetch requests of the code come to
code cache portion. It is very effective pipe-lining. This is also known as I&D
cache.
fi
fi
fi
fi
fi
fl
Page 14
Cache controller
Cache controller handles the data requests and controls data transfer between Cache
and Processor & Cache and Memory. When processor requests a data element, cache
controller checks for that element in Cache, and provides it to processor if present. In
case, the required data element is not present in cache, the cache controller requests
that data from memory. The read and write requests to memory are handled by the
memory controller.
2. Secondary Memory:
• It is a non-volatile memory which is also called Auxiliary Memory.
• CPU cannot access the data directly from the secondary memory.
• Data is rst loaded in primary memory and then accessed by CPU.
• There are 3 main types of Secondary Storage:
1. Flash Memory (SSD’s):
• SSDs use Flash Technology i.e. NAND Flash, which is a non-volatile ash
memory.
• These ash chips use Floating Gate Transistors to store 1 bit of data.
• Eg. USB drives (Pen Drives), Memory Cards (SD-Secure Digital, Micro
SD), Solid-State Drives (SSDs), Smartphones, tablets, BIOS Chips.
fl
fi
fl
Page 15
• Blu-ray Disc: is an optical disc format like CD and DVD. Blu-ray discs
can hold more information than other optical media, because of the blue
lasers that the disc drives use. A single Blu-ray disc can hold up to 25GB to
50GB of data.
Key Functions:
• The BIOS performs a series of diagnostic tests to ensure that the hardware
components are functioning correctly before the operating system is loaded.
• This is called POST (Power On Self Test)
• The BIOS initialises and con gures the computer's hardware, including the
CPU, memory, storage devices, and peripherals.
• After POST, the BIOS locates and loads the bootstrap loader, which is a small
program that initiates the operating system.
• Then Bootstrap Loader loads the Operating System into RAM.
• The BIOS also provides access to a setup utility (often accessed by pressing a keys
like F2 or DEL during startup) where users can con gure hardware settings, such
as boot order, set Boot drives, enable or disable system components.
Booting:
• Booting is the process of starting a computer, or restarting it i.e the sequence of
loading the OS to main memory.
fi
fl
fi
fi
fi
fi
fi
Page 18
• Sequence: Activate BIOS > Perform POST > Invoke Bootstrap Loader > Load
O.S. > Check con guration setting
Cold Booting:
• A cold boot starts a computer from a completely powered-off state.
• Requires the computer to initialise all hardware and software components from
scratch.
• It is initiated by pressing power button and takes longer than Warm Boot.
Warm Booting:
• A warm boot restarts a computer without fully powering it off.
• The computer's hardware remains powered on while the operating system is
reloaded.
• Faster than colder boot and is initiated by restart command or shortcuts like
Ctrl+Alt+ Del.
CMOS Chip:
• CMOS (Complimentary Metal Oxide Semiconductor) Chip is a kind of memory
technology present on motherboard .
• It is powered by a small battery.
• It stores information like system date, time, boot order, essential system settings.
fi
Page 19
Paging:
• Paging is a storage mechanism used in OS to retrieve processes from secondary
storage to the main memory as pages.
• The primary concept behind paging is to break each process into individual pages.
Thus the primary memory would also be separated into frames.
• One page of the process must be saved in one of
the given memory frames.
• Process pages are usually only brought into the
main memory when they are needed; else, they
are stored in the secondary storage.
• The frame sizes may vary depending on the
OS.
• Each frame must be of the same size.
• “frames" are physical units of main memory used by the computer's hardware.
• A process's logical memory is divided into equally sized blocks called "pages," .
• Paging is a process of loading small pages of a process into frames (hardware
memory blocks).
• It is used in active processes.
Features:
Page 20
Memory Management:
Paging is a fundamental part of how operating systems manage memory, enabling
processes to run even when there isn't enough physical memory (RAM) available to
hold them all at once.
Fixed-Size Blocks:
Both physical memory (frames) and logical memory (pages) are divided into
equal-sized blocks, which simpli es memory allocation and deallocation.
Non-contiguous Allocation:
Paging allows processes to reside in non-contiguous memory locations, meaning
that the pages of a process don't have to be stored next to each other in physical
memory.
Page Table:
It is a data structure used by virtual memory system to map virtual addresses into
physical addresses.
Demand Paging:
• It means keeping those pages of the process in RAM, that are required.
• When referred page is not available in RAM, it is called Page Fault.
• Due to high page fault CPU need to read data from secondary memory, which is
called thrashing.
Causes of Thrashing:
• Insuf cient RAM: If the physical memory is too small to hold all the active pages
of the running processes, thrashing can occur.
• Poor Memory Management: If the OS is not ef ciently managing memory
allocation and swapping, it can lead to thrashing.
• Too many processes: If there are too many processes running simultaneously,
each requiring a large amount of memory, thrashing can occur.
fi
fi
fi
Page 21
Swapping:
When a process needs more memory than is currently available, the operating
system can swap pages out to secondary storage (like a hard drive) and swap pages
back in from secondary storage as needed.
Virtual Memory:
Paging is a key component of virtual memory, which allows a computer to run
programs that are larger than the available physical memory(RAM). This extra space
created due to swapping with secondary memory is called virtual memory.
• This address generated by CPU for the process is called Logical Address.
______________________________________________________________________
Page 22
Microprocessor
Instruction Set:
• CPU has built-in ability to execute a particular set of machine instructions, called
its instruction set.
• The instructions in the instruction set are the language that a processor
understands.
• All programs have to communicate with the processor using these instructions.
• An instruction in the instruction set involves a series of logical operations (may be
thousands) that are performed to complete each task.
• The instruction set is embedded in the processor (hardwired), which determines
the machine language for the processor.
• All programs written in a high-level language are compiled and translated into
machine code before execution, which is understood by the processor for which
the program has been coded.
• Most CPUs have 200 or more instructions (such as add, subtract, compare, store
etc.) in their instruction set.
• CPUs made by different manufacturers have different instruction sets.
• Manufacturers tend to group their CPUs into “families” having similar instruction
sets.
• New CPU whose instruction set includes instruction set of its predecessor CPU is
said to be backward compatible with its predecessor.
• Two processors are different if they have different instruction sets.
• A program run on one computer may not run on another computer having a
different processor.
• Two processors are compatible if the same machine level program can run on both
the processors.
Page 23
INSTRUCTION CYCLE
The primary responsibility of a computer processor is to execute a sequential set of
instructions that constitute a program.
CPU executes each instruction in a series of steps, called instruction cycle.
An instruction cycle involves four steps:
• Fetching: The processor fetches the instruction from the memory. The fetched
instruction is placed in the Instruction Register. Program Counter holds the
address of next instruction to be fetched and is incremented after each fetch.
• Decoding: The instruction that is fetched is broken down into parts or decoded.
The instruction is translated into commands so that they correspond to those in the
CPU’s instruction set. The instruction set architecture of the CPU de nes the way
in which an instruction is decoded.
• Executing: The decoded instruction or the command is executed. CPU performs
the operation implied by the program instruction. For example, if it is an ADD
instruction, addition is performed.
• Storing: CPU writes back the results of execution, to the computer’s memory.
Microarchitecture:
• Microarchitecture is the processor design technique used for implementing the
Instruction Set.
• Computers having different microarchitecture can have a common Instruction Set.
• Pentium and Athlon CPU chips implement the x86 instruction set, but have
different internal designs.
Instructions are of different categories. Eg.
• Memory access or transfer of data between registers.
• Arithmetic operations like addition and subtraction.
• Logic operations such as AND, OR and NOT.
• Control the sequence, conditional connections, etc.
fi
Page 24
Processor Speed:
➡A CPU performance is measured by the number of instructions it executes in a
second, i.e., MIPS (million instructions per second), or BIPS (billion instructions
per second).
➡Computer has a built-in system clock that emits millions of regularly spaced electric
pulses per second (known as clock cycles)
✓It takes one cycle to perform a basic operation.
✓Normally, several clock cycles are required to fetch, decode, and execute a single
program instruction.
✓Hence, shorter the clock cycle, faster the processor
✓Clock speed (number of clock cycles per second) is measured in Megahertz (106
cycles/sec) or Gigahertz (109 cycles/sec)
Microprocessor:
A processor’s instruction set is a determining factor in its architecture. On the basis of
the instruction set, microprocessors are classi ed as—Reduced Instruction Set
Computer (RISC), and Complex Instruction Set Computer (CISC).
Pipelining
It improves instruction execution speed by putting the execution steps into parallel. A
CPU can receive a single instruction, begin executing it, and receive another
instruction before it has completed the rst. It is also called instruction prefetch.
Parallel Processing
It is the simultaneous execution of instructions from the same program on different
processors. A program is divided into multiple processes that are handled in parallel
in order to reduce execution time.
fi