Lecture 20,21 (19CS) CPU
Lecture 20,21 (19CS) CPU
Computer Fundamentals
1
Conten
ts
• What is CPU?
• Components of CPU
• Working of CPU
• Functions of CPU
• Bus
• Clock Cycle
• Instruction Cycle
• Instruction Set
• Single-Core and Multi-Core Processor
2
Central Processing Unit
3
Central Processing Unit
• It implements VLSI (Very Large Scale Integration) and ULSI (Ultra
Large Scale Integration)
• Microprocessor is housed on a chip called as microprocessor chip.
• The CPU is a tiny silicon chip that acts as the brains of a computer
system.
• The chip contains switches and pathways that the CPU turns on and
off according to instructions from computer programs.
• The system clock is an electronic pulse that controls the speed of
the CPU.
• The rate of the pulse is measured in megahertz (MHz).
4
MAJOR COMPONENTS OF CPU
• Storage Components:
• Registers
• Flip-flops
• Transfer Components:
• Bus
• Control Components:
• Control Unit
5
• A group of flip-flop is known as a Register. The n-bit register will
consist of n number of flip-flop and it is capable of storing an n-bit
word. The binary data in a register can be moved within
the register from one flip-flop to another. The registers that allow
such data transfers are called as shift registers.
6
Block Diagram
7
MAJOR COMPONENTS OF CPU
• Central processing unit (CPU)
• A hardware component that performs computing functions utilizing the ALU,
control unit, and registers.
• Arithmetic/logic unit (ALU)
• Performs mathematical calculations and makes logical comparisons.
• It performs both bitwise and mathematical operations on binary numbers and is
the last component to perform calculations in the processor. The ALU uses
operands and code that tells it which operations to perform for input data. After
the information is processed by the ALU, it's sent to the computer's memory.
• In some computer processors, the ALU is divided into an AU and LU. The AU
performs the arithmetic operations, and the LU performs the logical operations.
8
MAJOR COMPONENTS OF CPU
• Control unit
• Sequentially accesses program instructions, decodes them, coordinates flow of
data in/out of ALU, registers, primary and secondary storage, and various output
devices
• This section coordinates all activity within the CPU. It uses programming
instructions to control what actions the CPU performs and when it performs them.
• A control unit or CU is circuitry that directs operations within a computer's
processor. It lets the computer's logic unit, memory, as well as both input and
output devices know how to respond to instructions received from a program.
• Registers
• High-speed storage areas used to temporarily hold small units of program
instructions and data immediately before, during, and after execution by the CPU
• Primary storage
• Holds program instructions and data (a.k.a. main memory)
9
MAJOR COMPONENTS OF CPU
10
Communicating with the CPU
• The control unit reads and interprets program instructions and then changes it into
machine language that the CPU can understand.
• Data is stored in a computer in binary format as a series of 1s and 0s. Every 1 or 0 is a
bit of information.
• Computers use standardized coding systems (such as ASCII) to determine what
character or number is represented by what series of binary digits.
• The ASCII code is a standard code used to represent the alphabet, numbers,
symbols, and punctuation marks.
• Data is stored in a series of 8-bit combinations called a byte. Every character, such as
a letter, number, or punctuation mark, is a byte created from a unique combination
of ones and zeros.
11
Functions of CPU
• The Four Primary Functions of the CPU
• The CPU processes instructions it receives in the process of decoding data. In processing this
data, the CPU performs four basic steps:
• Fetch: Each instruction is stored in memory and has its own address. The processor takes this
address number from the program counter, which is responsible for tracking which
instructions the CPU should execute next.
• Decode: All programs to be executed are translated to into Assembly instructions. Assembly
code must be decoded into binary instructions, which are understandable to your CPU. This
step is called decoding.
• Execute: While executing instructions the CPU can do one of three things: Do calculations
with its ALU, move data from one memory location to another, or jump to a different address.
• Store: The CPU must give feedback after executing an instruction, and the output data is
written to the memory.
12
Functions of CPU (Summary)
• Fetch - Retrieve an instruction from the memory.
• Decode - Translate the retrieved instruction into a series of computer
commands.
• Execute - Execute the computer commands.
• Store - Send and write the results back in memory.
13
Basic Terms
• Pipelining
• A CPU operation in which multiple execution phases are performed in a single machine cycle.
Pipelining allows another instruction to start executing before the last one finished.
• Bus
• Physical wiring connecting computer components
• Bus width
• Number of bits a bus can transfer at one time
• Clock speed
• Predetermined rate a CPU produces a series of electronic pulses.
• When referring to a computer processor or CPU, GHz is a clock frequency, also known as
a clock rate or clock speed, representing a cycle of time.
• "Hz" is an abbreviation of Hertz, and "k" represents Kilo (thousand), "M" represents Mega
(million), and "G" represents Giga (thousand million).
• The first computers processors (CPU's) operated in kHz. Later processors operated in MHz.
• Today's processors operate in the GHz range.
14
BUS
• A collection of wires through which data is transmitted from one part of a
computer to another. You can think of a bus as a highway on which data
travels within a computer.
• When used in reference to personal computers, the term bus usually refers
to internal bus. This is a bus that connects all the internal computer
components to the CPU and main memory.
• There's also an expansion bus that enables expansion boards to access the
CPU and memory.
• All buses consist of two parts -- an address bus and a data bus.
• The data bus transfers actual data whereas the address bus transfers
information about where the data should go.
15
BUS
• The size of a bus, known as its width, is important because it
determines how much data can be transmitted at one time.
• For example, a 16-bit bus can transmit 16 bits of data, whereas a 32-
bit bus can transmit 32 bits of data.
• Every bus has a clock speed measured in MHz. A fast bus allows data
to be transferred faster, which makes applications run faster.
16
Clock Cycle
• The speed of a computer processor, or CPU, is determined by the clock cycle, which is
the amount of time between two pulses of an oscillator.
• The higher number of pulses per second, the faster the computer processor will be
able to process information.
• The clock speed is measured in Hz, typically either megahertz (MHz) or gigahertz (GHz
).
• For example, a 4GHz processor performs 4,000,000,000 clock cycles per second.
• Computer processors can execute one or more instructions per clock cycle, depending
on the type of processor.
• Early computer processors and slower processors can only execute one instruction
per clock cycle, but faster, more advanced processors can execute multiple
instructions per clock cycle, processing data more efficiently.
17
Units
• 1KHz= 1000Hz
• 1MHz= 1,000,000 Hz (One Million)
• 1GHz= 1,000,000,000 Hz (One Thousand Millions)
18
Instruction Cycle
• The Steps required by CPU to fetch and execute an Instruction is called a Instruction Cycle.
• The sequence of operations that the CPU has to carry out while execution is called
instruction cycle.
19
The Instruction Cycle and the
Execution Cycle in RAM
20
The Instruction Cycle and the
Execution Cycle in RAM
21
The Instruction Cycle and the
Execution Cycle in RAM
22
Instruction Set
• The instruction set is part of a computer that pertains to programming, which is
basically machine language.
• The instruction set provides commands to the processor, to tell it what it needs to
do.
• The instruction set consists of addressing modes, instructions, native data types,
registers, memory architecture, interrupt, and exception handling, and external I/O.
24
CISC V/S RISC
25
Core
• A core, or CPU core, is the "brain" of a CPU. It receives instructions,
and performs calculations, or operations, to satisfy those instructions.
A CPU can have multiple cores.
• A processor with two cores is called a dual-core processor; with four
cores, a quad-core; six cores, hexa-core; eight cores, octa-core.
• As of 2019, the majority of consumer CPUs feature between two and
twelve cores. Workstation and server CPUs may feature as many as 48.
• Each core of a CPU can perform operations separately from the others.
Or, multiple cores may work together to perform parallel operations on
a shared set of data in the CPU's memory cache.
26
Core
• A multi-core processor is a computer processor integrated circuit with
two or more separate processing units, called cores, each of which
reads and executes program instructions, as if the computer had
several processors.
• The instructions are ordinary CPU instructions (such as add, move
data, and branch) but the single processor can run instructions on
separate cores at the same time, increasing overall speed for
programs that support multithreading or other parallel computing
techniques.
27
Example
• An Intel Core 2 Duo E6750 dual-core processor.
28
Single-Core v/s Multiple-Core
• A single-core processor is a microprocessor with a single core on a chip,
running a single thread at any one time. The term became common after the
emergence of multi-core processors (which have several
independent processors on a single chip) to distinguish non-multi-
core designs.
• The benefit of having multiple cores is that the system can handle more than
one thread simultaneously. Each core can handle a separate stream of data.
This architecture greatly increases the performance of a system that is
running concurrent applications
• A CPU can contain one or more processing units. ... CPUs with
multiple cores have more power to run multiple programs at the same time.
29
Multithreading
• In computer science, a thread of execution is the smallest sequence
of programmed instructions that can be managed independently by a
scheduler, which is typically a part of the operating system.
30
How to check processor type
and speed on Windows?
• If you are running Microsoft Windows, you can determine the
processor type and speed by pressing the Windows Key and
Pause key at the same time. Doing so opens a System window similar
to one of the examples below.
31
32
• The Windows 8 computer has an "Intel(R) Core(TM) i7-2600 CPU @
3.40 GHz 3.40 GHz." Intel is the brand and company of the processor,
Core i7-2600 is the model of the processor, and 3.40 GHz is the speed
of the processor.
33
Tasks
• What is the max number of cores on a CPU?
• However, it's rare for a consumer PC to need more than one CPU.
Windows 10 can support up to a max of 32 cores for 32-bit Windows
and 256 cores for 64-bit Windows.
• How do I check my CPU cores?
• Press Ctrl + Shift + Esc to open Task Manager. Select the Performance
tab to see how many cores and logical processors your PC has.
34