Central Processing Unit

Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 21

CENTRAL PROCESSING UNIT

 A computer system is a set of equipment that works together to help you do useful work. A computer system can be drawn as a

simple diagram.

 A computer system must always have input devices. Input devices allow you to put data into your computer.

A keyboard is an input device.

 A computer system has output devices. Output devices let you see the results of your work on the computer. A computer screen is an

output device. Output Hardware: To translate and display the result of the data processing . Example: Monitor Screen, Printer etc

 A computer system has storage devices. You use storage devices to save your work

 Processing and Memory Hardware: Where data and information are processed and manipulated to perform the task at hand. It is

also the workspace of the computer, where it temporarily stores data(R.A.M). Examples: Central Processing Unit (CPU), Read

Only Memory (ROM)

 Secondary Storage Hardware: Where the computer system stores data permanently. Example: Harddisk, Pendrive etc
CENTRAL PROCESSING UNIT

Central Processing Unit (CPU ) this is another name of the microprocessor at the core of your
computer system. The C.P.U has the characteristics.
 IT is considered as the brain of the computer.

 CPU performs all types of data processing operation.

 It stores data ,results and Instructions(Programs)

 The CPU has three main Components .

 Memory or the storage Unit.

 The control Unit.

 ALU(Arithmetic Logic Unit.)


Control Unit
The CU provides several functions:
 it fetches, decodes and executes instructions
 it issues control signals that control hardware
 it moves data around the system
Arithmetic logic unit
 The ALU has two main functions:
 It performs arithmetic and logical operations (decisions). The ALU is where calculations are done and where decisions
are made.
 It acts as a gateway between primary memory and secondary storage . Data transferred between them passes through
the ALU.
Registers
Registers are very fast access memory locations in the CPU. There are a number of registers that are temporary data stores
in the CPU, which Include the:
 Accumulator stores the results of any calculations made by the arithmetic and logic unit (ALU).
 Program counter keeps track of the memory location for the next instruction to be dealt with.
 Memory address register stores the location in memory to be used, i.e. Where to locate data it needs to fetch or where to
send data it needs to store.
 Memory data register is used to store any data fetched from memory or any data that is to be transferred to and stored
in memory
Buses
A bus is a high-speed internal connection. Buses are used to send control signals and data between the processor and other
components.
Three types of bus are used:
 Address bus - carries memory addresses from the processor to other components such as primary memory and input/output
devices.
 Data bus - carries the actual data between the processor and other components.
 Control bus - carries control signals from the processor to other components. The control bus also carries the clock's pulses.
Cache
Having more and faster cache memory will provide the CPU with faster access to data
 Cache is a small amount of high-speed random access memory (RAM) built directly within the processor.
 It is used to temporarily hold data and instructions that the processor is likely to reuse.
 This allows for faster processing as the processor does not have to wait for the data and instructions to be fetched from the
RAM.
Clock
The more instructions that can be completed per second, the faster the data can be processed.
The number of cores
 If a processor has multiple cores, each core can fetch, decode and execute instructions at the same time and can handle more
instructions simultaneously. For example, a multi-core processor can run more than one program at the same time.
 A dual core processor has two cores and quad core, four, so the more cores the faster the CPU can process instructions.
 A typical quad-core processor will have L1, L2 and L3 cache. L1 and L2 cache will be provided for each core and L3 cache will
be shared.
Processor Registers
A processor has five special registers which it uses for processing:
a. Program counter (PC) - holds the memory address of the next instruction to be fetched from main memory.
b. Memory address register (MAR) - holds the address of the current instruction that is to be fetched from memory, or the
address in memory to which data is to be transferred.
c. Memory buffer register (MBR) - holds the contents found at the address held in the MAR, or data which is to be transferred
to main memory. It is also referred to as the memory data register (MDR).
d. Current instruction register (CIR) - holds the instruction that is currently being decoded and executed.
e. Accumulator (ACC) - holds the data being processed and the results of processing.
How the C.P.U Works
 Since creation and development, improvement of the CPU, Fetch, Decode and Execute are the fundamental functions of the
CPU.
The fetch-execute cycle
 The fetch-execute cycle (also known as fetch-decode-execute cycle) is followed by a processor to process an instruction. The

cycle consists of several stages .


1. The memory address held in the program counter is copied into
the MAR.
2. The address in the program counter is then incremented - increased -
by one. The program counter now holds the address of the next
instruction to be fetched.
3. The processor sends a signal along the address bus to the memory
address held in the MAR.
4. The instruction/data held in that memory address is sent along the
data bus to the MBR/MDR.
5. The instruction/data held in the MBR/MDR is copied into the CIR.
6. The instruction/data held in the CIR is decoded and then executed.
Results of processing are stored in the ACC.
7. The cycle then returns to step one.
Factors affecting CPU performance
Even though today's processors are tremendously fast, their performance can be affected by a number of factors like.:

 Clock speed
CPU clocks can sometimes be sped up slightly by the user. This process is known as overclocking. The more pulses per second, the more fetch-
decode-execute cycles that can be performed and the more instructions that are processed in a given space of time. Overclocking can cause long
term damage to the CPU as it is working harder and producing more heat.

 Cache size
>>The bigger its cache, the less time a processor has to wait for instructions to be fetched.

 Number of cores
A processing unit within a CPU is known as a core. Each core is capable of fetching, decoding and executing its own instructions.
The more cores a CPU has, the greater the number of instructions it can process in a given space of time. Many modern CPUs are dual (two) or
quad (four) core processors. This provides vastly superior processing power compared to CPUs with a single core.
Memory and secondary storage
For a computer system to be useful it needs storage: main memory for data and programs that are currently in use and secondary

storage for data and programs that can be accessed when required.

Memory
A computer system needs to have memory for any data that it needs to access quickly. This includes the start-up instructions, the

operating system, programs that are running and any associated data.

The memory in a computer is made up of main memory, cache memory and registers.

Cache memory and registers have already been discussed. They are small but have the fastest access times Main memory is

directly accessible by the CPU. There are two main types of main memory: RAM and ROM.
Random access memory (RAM)
• RAM is required to hold the operating system, applications that are running and any associated data while the computer is on
and in use.
• When a program is loaded it is copied from secondary storage, such as a hard disk drive (HDD), into RAM.
• Any data associated with the program will also be stored in RAM so that the CPU can access both the data and the
instructions. Data is transferred into RAM because accessing data in secondary storage is very slow compared to accessing
data in RAM.
• With more RAM available, more data and applications can be stored in it. Because RAM has fast data access times this leads to
better performance of the system. In practice, a system with more RAM can have more programs open at the same time
without any noticeable decrease in performance. A typical laptop will now have around 8GB of RAM available.
• RAM is volatile, meaning it needs electrical power to operate. Any data stored in RAM is lost when the power is turned off.
• RAM is read/write, which means it can be read from or written to by the computer

Read-only memory (ROM)


• In a typical computer system, ROM stores a small program and all the data needed to get the system up and running,
ready to load the operating system from the secondary storage.
• This special program stored on ROM is called the Bootstrap Loader and we say the process ‘boots’ the computer – this
means that it starts it from scratch. Computers would not be so useful if they had to be switched on all the time.
• ROM is non-volatile memory and does not require power to maintain its contents.
• ROM is read-only. This means that the data stored in ROM is fixed and cannot be overwritten once it is created.
• The content is written to ROM either at the manufacturing stage or through a special process that can write to these
devices.
The differences between RAM and ROM
Example
Here is a worked example created using python.

Answer=2+3

To carry out this instruction the computer has to complete at least one fetch execute cycle.

 Fetch : The control unit fetches the instruction “Add” and the data value (2,3) from RAM.

 Decode: The control unit decode s the instruction, and send the signal to ALU, telling it to add the numbers together.

 Execute : The ALU carries out the instructions, and add the two numbers together.

 Save: The ALU send back the result of the addition to the RAM, the result is saved in the memory location with the label

answer.
TOPICAL QUIZ

1) What is the difference between memory and storage?


__________________________________________________________________________
__________________________________________________________________________
2) List the four stages of the fetch , execute cycle.
__________________________________________________________________________
__________________________________________________________________________
3) Describe what happen during the “ execute “ stage of the fetch –execute cycle and
where it happens.
__________________________________________________________________________
__________________________________________________________________________
4) Explain why a computer with lots of RAM (memory )will generally go faster than a
similar computer with less RAM.
__________________________________________________________________________
__________________________________________________________________________
Arithmetic and Logic
What is Logic?
a proper or reasonable way of thinking about or understanding something.

 There are two possible conditions , the statement can either be “True ” or “False” .Logical statements can be

used to tell or to say if something is true or false

“The key can open a padlock”= (true or false)

“ it is raining ” logical statement


Logic And ALU
 The computer is a digital device ,A computer processor is made up of tiny electrical switches

 The electrical switches in a computer can either ne On or Off(1 or 0) and that is why we can say a computer is a two state

device.
 Logic also has two states and the states are true and False.

 A computer’s ALU can process logical statements because both logics and computers uses two states.

 In a computer we use binary to show the state of a switch a’1’ is used to say switch is `on’ and a `0’ to say a switch is `off’

 We can also use binary to show the state of a logical statement. A “1 ” is used to show a statement is `true’ and a “0 ” to

show it is `false’.
Linking Logic statement……….
 Logic is not just saying whether the statement is true or false. Logical statement can also be used to draw conclusion from data and make
decisions.
 To use logic to draw conclusion , you must be able to combine logical statements.

 The word ‘THEN’ is “used” to combine logical statement.

Examples of two logical statements about computer games.

>> Player has no lives.


>>Game is Over.
// Each of the two statements can either be True or False , you can link two logical statements using the word “THEN”
>>> Player has no lives THEN Game is Over.

>>When the two statements are linked they can be used to draw conclusion.. We can say:

>>> Player has no lives is True THEN Game is Over. Is also true

>>> Player has no lives ‘ is false THEN Game is Over’ is also false
Part of a logical Statement
 Logical statement has two parts , In this case we can say ,in a logical statement , everything to the left of “THEN ” is called Propositions. And every

thing to the right of “THEN ” is called Conclusion.

 The whole statement “Proposition “Then” Conclusion is call logical argument.

Proposition Conclusion

Player has no lives THEN Game is Over


Using AND to link Logical Statement
The following are steps to follow when writing a complex logical statement , using AND to link them,:
 Write the outer argument: first identify the conclusion, there is only over one conclusion in a logical argument. The conclusion
is the desired outcome.”e.g. the club signs the player”
once you have identified the conclusion , any other part of the statement is the proposition. E.g. ; The player is left footed; ,
Player scored 30 goals. The statement in the proposition can be joined using AND or OR, if both statements must be true join
them with AND.
 Create the Column Heading: create the table with three columns, and the conclusion must always go to the column on the far
right of the table.
Player is left footed Player scored 30 goals Club signs player

 Add a row for every possible response to the proposition: A two-part statement always need the four responses , in the table
below read them carefully.

Player is left footed Player scored 30 goals Club signs player


 Complete the conclusion column: The two parts of the proposition are joined by AND .This means that the conclusions
will be true only if both parts of the proposition are true.
Player is left footed Player scored 30 goals Club signs player
1 0 0
0 1 0
0 0 0
1 1 1
Player is left footed Player scored 30 goals Club signs player
1 0
0 1
1 0
0 0

NB: Using AND , Then the Conclusion is True only if both parts of the proposition is True(x)
 OR =The conclusion is True .if One of the statement(part of proposition is True)(+)

You might also like