You are on page 1of 40

O

How
The Processor
Processes
Stage

Internation Computing for lower secondary


About the CPU

At the center of all of


the technologies we use
today is a device
known as the Centeral
Processing Unit (CPU) .
About the CPU

Computer program can be written in


It is the electronic Hight level language (HLL). These are
circuity inside the easy for the programmer to understand
but processing time need to be spent
CPU which is used
translating these instruction into a
to execute format that the Processor can
programs on the understand.

electronic device.
About the CPU
Program can also be written
in low-level language (LLL)
The specification of the
such as assembly language or CPU can have an impact
machine code . on the cost of a computer .
Assembly language programs The higher the
are designed specifically for
specification the more
expensive the device will
each type of processor and be.
less translation is needed.
Inside a digital Device

Any processing by a digital device is carried out


by a part of the device known as the central
processing unit (CPU).

The CPU is connected to a special circuit board.


The Circuit borad where the CPU is located is
called the motherboard and the CPU is attached
to the motherboard via a special socket
Inside a digital Device

Most digital device have CPU .eg


mobile phone , a washing machine ,
micorwave and computer.

The CPU is the component inside a


digital device that does all of the work.

The motherboard is used to provide


power to the CPU and all of the other
component inisde the digital device.
Inside a digital Device

The CPU carries out all of the instruction inside a digital device ,
such as :
Controlling the operation of other part of digital device.
Fetching instructions.
Carrying out instructions in computer programs.
Carrying out arithmetic and logic operations.
Managing the input and output of data.
The main role of the CPU is
to run a set of stored
instructions knowns as
The main role computer program. The CPU
of coordinates all of the other
parts of computer when it is
CPU executing a program. It does
this using a device called the
internal clock or system
clock.
a l c l o c k o r s y s t
er n e m
int cl
e oc
Th k
The internal clock help the CPU manage the
execution of each instruction in a program.
CPU need a certain number of clock ticks to carry
out each instruction.
The number of ticks carried out per second in a
modern CPU is mesured in MHZ or GHZ.
The more clock ticks there are every second ,the more
Back to Overview
instructions the process can carry out in one second

1 MHz equal one million clock ticks per second. 1GHz equals one billion clock ticks per second.
3 factor increase processig speed

Including more than one core Increasing the amount of Increasing the amount of
in the CPU cache memory random access memory
(RAM)

Cache memory is located on the RAM is used to temporily store progams


A single core can process an
same chip as the CPU, and can be and data currently being used by the
instruction or program on its
accessed very quicklay . processor.
own. CPU can have more With more cache memory available RAM is placed close to the CPU.
than one core so that more more instructions can be accessed The more data that can be stored in
than one program can be very quickly, which improves the RAM , the faster it can be accessed by
carried out at the same time. speed of the computer the CPU and the faster an instruction
can be carried out
Inside the CPU
Arithmetic logic Unit (ALU)
Carries out all of the calculations needed during
the execuation of program.

Control Unit
Issues commands to all of the other hardware
components to help ensure programs are carried
out correctly.

Registers
Store data about memory location, instructions
and data use during execuation of an instruction.
Register
Accumulator (ACC)
A register used by the ALU to store the
intermediate result of processing carried out
by the ALU.

Program Counter (PC)


Store the address of the next instruction
waiting to be executed by the CPU

Current Instruction Register (CIR)


Store the instruction currently being
exexuted by the CPU.

Memory Address Register (MAR)


Holds the address of the memory location being
accessed either to read data form

Memory Data register (MDR)


Any Data of or instruction that pass into or
out of main memory must pass through the
MDR WHELTON SCHOOL OF MARKETING | SESSION 1
Main Memory
Main memory is another name for
RAM , Which is used to store
programs and data currently beign
operated on by the CPU.

Buses are sets of wires which can be


used to carry a number of different
signals around a digital device .

These include;
data bus
address bus
control bus
High- and low-level languages
The instructions to be carried out by a computer are provided by a computer program.
Program developers use high-level languages such as JavaScript, Python or Scratch to
write computer programs.
Before the processor can carry out these instructions they need to be converted into a
pattern of 1s and 0s (binary) that the CPU understands.
Every CPU has its own set of binary instructions it understands.This is called its
instruction set. The instruction set of a CPU is written in binary (also known as
machine code) and is an example of a low-level language.
High- and low-level languages
HLLs can be said to provide an abstract representation of how
the CPU operates.
This means that the programmer does not
need to understand what is happening inside the CPU when
they are writing their HLL program; instead, they can focus on
writing a program to solve a problem.
It also means that each
HLL instruction will require more than one LLL instruction before
it can be carried out successfully. Since one HLL instruction can
represent more than one LLL, the programmer cannot always
make the most efficient use of the hardware of the CPU. This
means HLL instructions take longer for the CPU to process.
Experienced programmers can make use of a less abstract
version of machine code, called assembly language.
High- and low-level Each assembly language instruction corresponds to one
machine code instruction in the CPU’s instruction set.
languages
The difference is that assembly language uses a set of
codes or symbols to represent each instruction rather than
a group of 1s and 0s.
The assembly language instructions are easier for human programmers to
understand.
for example, to output the word ‘Hi’ to a computer screen:
High- and low-level languages

Each machine code instruction is made up


of an opcode (the instruction to be carried
out) and an operand (the data to be operated
on or a location in memory where the data is
stored).
Introduction fetch-decode-execute
When executing computer programs the CPU will carry out many
instructions every second by going through a set of steps known as the
instruction cycle.

An instruction cycle carried out by a processor works in three stages.


Fetch – the CPU fetches an instruction from a location in memory.
Decode – the CPU needs to work out what the instruction means, i.e. what
is it telling the CPU to do.
Execute – once the CPU has figured out what it has to do it can then carry
out that instruction.

This cycle is also known as the fetch–decode–execute cyc


Practice 1
This table is an instruction reference table. It contains a made-up assembly language
instruction set for a basic calculator CPU.
Practice 1
This table contains a set of memory locations with a short program (written
using the made-up assembly language instruction for the calculator).

The lines of code really only carried out the


following high-level language instruction:
About Assembly language
The previous practice task is converting a coded set of instructions into a
format that was more easily recognisable to us as humans.
The assembly language instruction set used by a CPU is a little
more complicated. A more realistic set of assembly language
instructions for your calculator could include the followi
All about the accumulator

The accumulator acts almost like a short-term


memory for
the CPU.
When it is adding two numbers together, the
CPU
will hold the first number in the accumulator,
then add the
second number to the accumulator before, for
example,
storing or printing the result.
How the content of Accumulator
change after each instruction

After executing the first instruction LDA 10 (load the contents of location 10 into the accumulator),
the accumulator holds the number 45.
How the content of Accumulator
change after each instruction

After executing the second instruction ADD 11 (add the contents of location 11 to the value
already stored in the accumulator), the accumulator now holds the result of the ADD
calculation.
Practice 2

Test your code using a simulator called the Little


Man Computer (LMC).
➤ Open an internet browser,
➤ Enter the URL
https://peterhigginson.co.uk/lmc
➤ Enter your code into the coding window.

GO
A detailed look: fetch–decode–
execute
Fetch

The program counter contains the number 0 as


this is the memory location of the first
instruction to be executed.
This means that the MAR will point to location
0.

This address in the MAR is located via the


address bus.
A detailed look: fetch–decode–
execute
Fetch

There is currently nothing in the MDR, CIR or


ACC.

The contents of memory location 0 are read


from main memory and sent via the data bus to
the MDR.
A detailed look: fetch–decode–
execute
Fetch

Since this was an instruction it can now be


copied into the CIR.

The instruction has now been fetched so the


PC can be increased (incremented)

so that it points to the next instruction which


is to be executed.
A detailed look: fetch–decode–
execute
Decode
The CIR passes the instruction to the control unit (not shown
in diagram) which can now decode the instruction (convert
it into machine code) so that it can then be executed by
the CPU.

The instruction in the CIR has two parts.


1. The command, in this example this is LDA.
2. The address or the data the command will use: in this case it is a memory
location, location 9.
A detailed look: fetch–
decode–execute
Execute
The data needed to execute this
instruction is in location 9 so
9 is loaded into the MAR.
The address in the MAR
(address location 9) is now
located
via the address bus.
A detailed look: fetch–
decode–execute
Execute
The contents of location 9
are read from Main
Memory
and sent via the data bus
to the MDR, replacing
what was
previously stored in the
MDR.
A detailed look: fetch–
decode–execute
Execute
The MDR now contains
the number 8. The control
unit
previously decoded the
instruction which was
LDA 9.
The contents of the MDR
are now passed to the ACC
(accumulator).
Logic gates
How it all happens, part 1
c r e a te d the
o c e s s o r is h ow
re a p r to s h o w
Befo ia g ra m s
e r w i ll u se d
design b ec o m b in ed .
s a re t o
logic gate
Digital devices process data using logic gates. d iff e r ent
t e s p e rf o rm
e n t lo g i c ga
Differ n s.
p e r a ti o
Logic types of o
t e d u s in g
gates are electronic circuits that have one or more i s re p r es en
h lo g ic g ate e s c a lle d
inputs which are processed to produce outputs which ea c ec ia l ta b l
y m bo l, s p te
its ow n s ea ch g a
represent the values TRUE or FALSE. s h o w h o w
h ta b l e s to
tru t
operates.
Input into a logic gate is in the form of an electrical signal
represent by 1 or 0.
Understanding AND Gates

The symbol for an AND gate is A truth table : the combinations of inputs and outputs of
an AND gate

Hint: Butter toast


Understanding OR gates

The symbol for an OR gate is The truth table for OR gate

hint : meeting her friend for lunch.


UNDERSTANDING NOT GATES

The symbol for an Not gate is The truth table for Not gate

hint: A home owner needs to decide if he should turn


the heating system on in his home.
Understanding XOR
(Exclusive OR) gates

The truth table for


The symbol for an XOR gate is
AI, VR and Logic gates

Logic gates form the basis of all computer systems including artificial intelligence (AI) and
virtual reality (VR) systems.
As we continue to harness more and more technologies the more essential technology
developed which use logic gates becomes to our everyday activities.
However, computer devices are not accessible to everyone. This uneven distribution of
access to technology is called the digital divide
Despite the digital divide, emerging technologies which combine the main features of AI and
VR have the potential to have a dramatic impact on our everyday lives, offering advantages
beyond any expectations.
Practice 3
Practice 4

You might also like