Introduction to Computers
COMPUTER
ARCHITECTURE
Major Components of a
Computer System
■ Processor (CPU)
■ Runs program instructions
■ Main Memory
■ Storage for running programs and current data
■ Secondary Storage
■ Long-term program & data storage (hard disk, CD, etc)
■ Input Devices
■ Communication from the user to the computer(e.g. keyboard,
mouse)
■ Output Devices
■ Communication from the computer to the user (e.g. monitor,
printer, speakers)
Major Components of a Computer
System
Computer Systems
System Unit Output device
Output device
Output device
Input device
Input device
The Processor
▪ The Processor (CPU) is the "brain" of the computer
system.
▪The processor used in Microcomputers is Microprocessor.
▪Performs all operations on data according to program
instructions
▪Executes program instructions and tells other parts of
computer what to do.
▪CPU fetches program instructions from main memory and
executes them one by one.
▪Speed of CPU is measured in Mega Hertz (MHz) or Giga
Hertz (GHz)
Multi-Core Processor
■ Dual Core Processor
■ Quad Core Processor
http://www.cse.wustl.edu/~jain/cse567-11/ftp/multcore/
Types of Processors
■ Two designs of CPU are as follows:
■ CISC
■ RISC
CISC
■ Complex Instruction Set Computing
■ Supports a large number of instructions
■ Executes complex instruction more quickly
■ Mostly used in PC and conventional mainframe
computers
RISC
■ Reduced Instruction Set Computing
■ Reduces the instructions to only those used more
frequently
■ Executes simple instruction more quickly than CISC
CPU
■ Mostly used in workstations
■ Workstations can work up to 10 times faster than
most PCs due to RISC
Instruction Set
■ A set of instructions that can be performed by the
CPU is called instruction set
■ Arithmetic Instructions
■ Logical Instructions
■ Data Transfer Instructions
■ Control Transfer Instructions
Pipelining
■ In some computer, the control unit completes all four
stages of the machine cycle before beginning work on
the next instruction
■ Most of the modern PCs support a concept called
pipelining
■ Parallel work known as pipelining
■ Pipelining is a technique used to improve the
execution throughput of a CPU by using the processor
resources in a more efficient manner.
Pipelining
http://www.digitalinternals.com/hardware/how-pipelining-improves-cpu-performance/113/
Coprocessor
■ Special Additional Processor Chip
■ Helps main processor to perform specific tasks
■ Increase the performance of a computer
■ A type of co-processor is known as floating-point co
processor or math coprocessor
Component Interaction
The CPU controls all of the other resources within the system,
in order to accomplish a task.
The CPU
■The Processor (CPU) is a silicon chip that
contains millions of tiny electrical components.
■The CPU’s three main parts are:
■ Control Unit
■ Arithmetic Logic Unit (ALU)
■ Registers
Central Processing Unit (CPU)
Performs calculations
Arithmetic / Logic Unit
and decisions
Coordinates
Control Unit processing steps
Small, fast
Registers storage areas for
instructions and
data
Arithmetic & Logic Unit (ALU)
■ Performs all the arithmetic operations
on data (Addition, Subtraction,
Multiplication, Division)
■ Performs all the logical operations on
data
(Less than, Greater than, equal to etc.)
Control Unit (CU)
■ Controls and coordinates the activities of
all other units of computer.
■ CU also controls the execution of
instructions given to the computer.
■ Machine Cycle is coordinated by the CU.
Registers
▪ Registers are small but very fast storage area within
the CPU that hold data and instructions temporarily.
▪ Size of registers – word size of computer
(e.g. 16, 32, 64 bits)
▪ Different registers hold different things
▪ instructions and addresses of instructions
▪ data (operands)
▪ results of operations
Types of Registers
■ Memory Address Register (MAR):
Holds addresses of memory location that CPU
wants to read from or write on.
■ Memory Buffer Register (MBR):
Holds the contents of data or the instruction
currently being processed.
■ Instruction Register (IR) :
Holds the current instruction being executed.
■ Instruction Pointer Register (IP):
Also called Program Counter (PC). It holds the
address of the next instruction/data that is to be
fetched.
■ Accumulator Register:
Its located inside the ALU. It holds the initial data to
be operated upon, the intermediate results, and the
final results.
■ Input/Output Register (I/O):
It is used to communicate with I/O devices. It holds
the data and instructions from the input/output
devices.
■ Stack Control Register:
Stack represents a set of memory blocks; data is
stored in and retrieved from these blocks in an
order LIFO (Last In First Out). Stack control
register is used to manage the stacks in memory.
■ Flag Register:
It is used to indicate the occurrence of certain
condition during an operation of the CPU. Each
bit of Flag Register constitutes a flag, that it
indicates if a specified condition was
encountered during execution of an instruction.
Memory
■ Memory is used to store data and
instructions that are currently in use.
■ Primary/Main memory/RAM consists
of cells, each with unique memory
address.
■ It is volatile memory.
■ More the size of RAM, increases the
processing speed of computer.
Memory
Storage is usually too large to be expressed in
bytes or words. Instead we use:
■ Kilobyte (KB) = 1024 bytes (210 bytes)
■ Megabyte (MB) = 1024 x 1024 bytes or
one million bytes (220 bytes)
■ Gigabyte (GB) = 1024 x 1024 x 1024 bytes or
one trillion bytes (230 bytes)
■ Terabyte (TB) = 1024 x 1024 x 1024 x 1024 bytes or
one quadrillion bytes (240 bytes)
Main Memory
■ Each computer has a specific word size
■ Word sizes vary from computer to computer.
■ Word size is an even multiple of a bytes.
■ Each word within memory can hold either
■ data or
■ program instructions
Main Memory
Each memory cell 5248 Each memory cell stores a
has a numeric set number of bits (some
address, which 5249 10011010 computers use 8 bits/one
uniquely identifies its 5250 byte, others use words)
location
5251
A word is stored in
5252 consecutive
5253 memory bytes.
5254
5255
5256
CPU and Memory
■ CPU can interact with main memory in two ways:
■ It can write a byte/word to a given memory location.
■ The previous bits that were in that location are destroyed
■ The new bits are saved for future use.
■ It can read a byte/word from a given memory location.
■ The CPU copies the bits stored at that location and stores
them in a CPU register
■ The contents of the memory location are NOT changed.
Types of RAM
■ Dynamic Random Access Memory (DRAM):
In order to store data in DRAM chip, the chip is
refreshed frequently; during which the CPU has
to wait to read & write data to DRAM. That’s
why DRAM decreases processing speed of
computer.
■ Static Random Access Memory (SRAM):
It is faster than DRAM because it doesn’t have
to be refreshed frequently and CPU does not
have to wait. But it is expensive than DRAM.
Read Only Memory (ROM)
■ Contains the permanent data and instructions.
■ Burned at the time of manufacturing these chips.
■ Programs stored in ROM are called firmware.
■ ROM also contains BIOS (Basic Input Output
System)
■ Computer uses the instructions of ROM at the
time of booting (checking different units of
computer, loading the OS into the memory etc.)
■ Many devices (e.g. Printer) also use ROM chips.
Types of ROM
Programmable Read Only Memory (PROM):
Is a blank chip on which user can write his own
program instructions but only once.
Erasable Programmable Read Only Memory (EPROM):
Its contents can be erased or changed but when its in
use it can only be read.
Electrically Erasable Programmable Read Only Memory
(EEPROM):
Its contents can be changed or altered electrically.
Main Memory Characteristics
▪ Very closely connected to the CPU.
▪ Contents are quickly and easily changed.
▪ Holds the programs and data that the processor is
actively working with.
▪ Interacts with the processor millions of times per
second.
▪ Nothing permanent is kept in main memory.
Secondary Storage Characteristics
▪ Connected to main memory through a bus and a
device controller.
▪ Contents are easily changed, but access is very
slow compared to main memory.
▪ Only occasionally interacts with CPU.
▪ Used for long-term storage of programs and
data.
▪ Much larger than main memory (GBs vs. MBs).
Access to Instructions
The hard disk is too slow to provide instructions to the CPU.
So programs are first loaded into main memory, which is much faster.
The CPU can then access the instructions more quickly.
Cache Memory
■ But as CPU speeds became faster, the main
memory couldn’t provide the CPU with the
instructions at a fast enough rate.
■ So even faster memory ( cache memory) is
now placed between the CPU and main
memory to provide the instructions at an
quicker rate to the CPU.
Cache Memory
When an instruction or data is accessed from main memory, it is placed in
the cache. Second and subsequent use of the same instruction/data will
then be faster, since it is accessed directly from the cache.
Instructions
■ An instruction is a sequence of bits.
■ A simple instruction format may consist
of an operation code (op code) and an
address or operands.
Op Code Operands / Address
■ Instructions tell the computer’s CPU what to do.
MACHINE CYCLE
■ For every instruction a processor repeats a set of
four basic operations, which is called as Machine
Cycle.
■ 1- FETCH
■ 2- DECODE
■ 3- EXECUTE
■ 4- STORE
MACHINE CYCLE
THE MACHINE CYCLE
FETCH Get an instruction from Main Memory
DECODE Translate it into computer commands
EXECUTE Actually process the command
STORE Write the result to Main Memory
Fetch-Decode-Execute Cycle
■ During the fetch part, the CPU fetches the next
instruction from the address contained in the
Instruction Pointer and places the instruction in
the Instruction Register.
■ When a program starts, the program counter
contains 0, so the instruction at address 0 is
fetched.
■ As soon as an instruction is fetched, the CPU
adds 1 word to the contents of the Program
Counter, so that it will contain the address of the
next sequential instruction.
Fetch-Decode-Execute Cycle
■ The decode unit within the CPU deciphers the
instruction in the Instruction Register and
determines what operations need to be done and
what type of operands will be used (decode
part).
■ During the execution part, the specified
operation is performed (add, compare, etc).
■ After execution of the instruction, the results of
the execution are stored in main memory (if
required), once the execution has been
completed the cycle starts all over again (unless
the instruction terminates the program).
Clocks
▪ Computer systems have an internal clock, which
is used to synchronize their activities.
▪ Processors run at a particular clock speed.
▪ Clock speed is measured in Hertz
▪ One Hertz is one clock tick per second.
▪ MHz means mega Hertz
▪One MHz is one million clock ticks per
second. (One million instructions
manipulated per second)
▪ The clock speed determines how fast
instructions can run.
Let’s call it a day ☺