Chapter 4 - Central Processing Unit

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 43

CHAPTER 4

THE PROCESSING UNIT

1 Computer System Architecture


Understand the Central Processing Unit (CPU)

Definition of CPU

•Central Processing Unit is referred as CPU, defined to be, sets of


electronic circuitry that executes stored program instructions.

•In simple word, CPU is the hardware component of the computer


that does most of the work in executing a program.

•It is the control center that converts data in to information.

•Intel and AMD are the two most popular CPU


manufacturers for desktops, laptops, and servers, while
Apple, NVIDIA, and Qualcomm are big smartphone and
tablet CPU makers.

2 Computer System Architecture


CPU history
The CPU was first developed at Intel with the help of Ted
Hoff and others in the early 1970's. The first processor
released by Intel was the 4004 processor.

3 Computer System Architecture


What does the CPU do?

• The CPU's main function is to take input from a peripheral


(keyboard, mouse, printer, etc) or computer program,
interpret what it needs, and then either output information
to your monitor, or perform the peripheral's requested task.

The CPU is made up from THREE (3) major parts which is:
• register set
• arithmetic-logic unit (ALU)
• control unit

4 Computer System Architecture


CPU diagram Register store
intermediate data
Register Set used during the
execution of the
Control Unit
instructions.
Arithmetic
Logic Unit
(ALU)

supervises (all activities) the transfer of


information among the register and instruct Performs arithmetic
the ALU to perform operation. In other operations (+, - , x , ÷) &
word, control the operation in CPU & logical operations (not,
communicates with other parts of the and, or, <=,>=, etc)
hardware
Clock Unit
The clock unit controls the speed of the computer.
54 Computer System Architecture
Types of instruction cycle

65 Computer System Architecture


Step 1 - Fetch the instruction from memory
→CU fetches an instruction from memory and puts it into a register

Step 2 - Decode the instruction


→CU decodes the instruction and determines the memory location of
the data required
→CU notifies the appropriate part of hardware to take action
→Control is transferred to the appropriate part of hardware

Step 3 - Execute the instruction


→CU moves the data from memory to registers in theALU
→ALU is given control and executes the instruction
→Control returns to the CU

Step 4 – Store
→CU stores the result of the operation in memory or in a register

77 Computer System Architecture


Definition of interrupt
• The concept of program interrupt is used to handle a variety
problem that arises out of the normal program sequence.

• In system programming, an interrupt is a signal to the


processor emitted by hardware or software indicating an
event that needs immediate attention. An interrupt alerts
the processor to a high-priority condition requiring the
interruption of the current code the processor is executing.

Computer System Architecture


8
Types of Interrupts
Types of interrupts can be classified as:

External/ Hardware Interrupt comes from input-output (I/O) devices, from


a timing device, from a circuit monitoring the power, or from any other external
source.

Internal Interrupt (also called TRAPS) are generated by the CPU itself to
indicate that some error or condition occured for which assistance from
the operating system is needed. Example; register overflow, attempt to divide
byzero, invalidoperation, stack overflow.

Software Interrupt is initiated by executing an instruction. Software interrupt


is a special call of instruction that behaves like an interrupt rather than subroutine
call. It can be used by programmer to initiate an interrupt procedure at any desired
point in the program.

9 Computer System Architecture


Interrupts are important because they give the user better control
over the computer. Without interrupts, a user may have to wait
for a given application to have a higher priority over the CPU to
be ran. This ensures that the CPU will deal with the process
immediately.

How Interrupt affect on the computer performance?

Interrupt can cause a break in normal execution of a program.

10 Computer System Architecture


STACK
Stack Data Structure
• A list where only the most recent item is accessible.
• This structure is Linear - Sequential Access : "Last-in-First-out" access

11
Computer System Architecture
Understand STACK organization
• Auseful feature that is included in the CPU of most computers is a stackor last- in,
first-out (LIFO) list.
• Stack is a storage device that store information in such a manner that the item
stored (in) last, is the first item retrieved (out).

The TWO (2) operation of a stack are:

• Insertion of item (called PUSHor push-down) because it can be thought of as the


result of pushing new item on top.

• Deletion of item (called POPor pop-up) because it can be thought of as the


result of removing one item so that the stack pops up.

• These operations are stimulated by incrementing or decrementing the stack pointer


register. (because nothing is pushed or popped in a computer stack)
12
Computer System Architecture
Simple representation of a stack runtime with push and pop
operations

Computer System Architecture


• Stack is essential in a memory unit with an address register that
can count only (after an initial value is loaded into it).

• The register that holds the address for the stack is called a stack
pointer (SP) because its value always point at the top item in
the stack.

Note!
The operation of the stack can be compared to a stack of tray.
The last tray placed on the top is the first taken off.

14 Computer System Architecture


Function of register and memory stack.

I. Register Stack
Astack can be placed in a portion of a large memory or it can be
organized as a collection of a finite number of memory words or
registers. The stack pointer register (SP) contains a binary number
whose value is equal to the address of the word/register that is
currently on top of the stack.

II. Memory Stack


Astack can exist as a stand-alone unit or can be implemented in a
random-access memory attached to a CPU.The implementation of a
stack in the CPU is done by assigning a portion of memory to a stack
operation and using a processor register as a stackpointer.

15 Computer System Architecture


Computer Memory with program, data and stack
segment
The three registers are connected M e m o r y Unit
to a common address bus, and PC
1000
Program
either one can provide an address (Instructions)
for memory.
2000
AR Data
PC is used during the fetch phase (Operands)
to read instruction
3000
Stack
AR is used during the execute
phase to read an operand SP
3997
3998
3999
SPis used to push or pop item 4000
into or from the stack. SPpoints 4001

at the tops of the stack DR

16 Computer System Architecture


Stack Limit

Most computers do not provide hardware to check for stackoverflow


(full stack) or underflow (empty stack).

The stack limits can be check using two processor register; one to
hold the upper limit, and the other to hold the lower limit.

After a push operation, SPis compared with the upper-limit register


and after a pop, SPis compared with the lower unit register.

Example of stack limit:


Refer to the computer memory diagram from previous slide.
The upper limit: 3000
The lower limit: 4001
17 Computer System Architecture
REVERSE POLISH
NOTATION

18 Computer System
Architecture
Describe the use of Reverse PolishNotation

• The Polish mathematician Lukasiewicz show that arithmetic


expression can be represented in prefix notation.

• This representation often referred to as Polishnotation; place the


operator before the operand.

• The postfix notation, referred to as reversePolishnotation (RPN),


places the operator after the operand.

19 Computer System Architecture


The following examples demonstrate the three
representations:
A + B Infix notation
+ AB Prefix or Polishnotation
AB + Postfix or reversePolishnotation
The reverse Polish notation is in a form suitable for stack
manipulation.The expression,
A* B+ C* D
Is written in reverse Polish Notation as,
AB* CD* +

20 Computer System Architecture


Conversion to RPN (reverse Polish notation)
• The conversion from infix notation to reverse Polish notation
must take into consideration the operation hierarchy adopted for
infix notation.
• Perform all arithmetic form innermost to outermost parentheses
and brackets.
• Do multiplication and division operation
• Then, finish the addition and subtraction operations
Consider the expression,
(A + B) * [C * (D + E) + F]
• The expression can be converted to reverse Polish notation,
without the use of parentheses, by taking the consideration of
operation hierarchy.
• The converted expression is:
AB + DE + C * F + *
21 Computer System Architecture
Conversion to RPN (reverse Polish notation) cont..
Proceeding from left to right, we first add Aand B, then add D and
E. At this point we are left with:

(A + B)(D + E)C * F+ *

Where (A+ B)and (D + E)are each a single number obtained from


the sum.The two operand for next * are Cand (D + E).These two
numbers are multiplied and the product added to F.The final *
cause the multiplications of the two terms.

22 Computer System Architecture


Some examples of infix expressions and their Reverse
Polish Notation equivalents

23 Computer System Architecture


Exercise 1: Write the expression in
RPN.
(8+2x5)/(1+3x2-4)

→ RPN : 8 2 5 x + 1 3 2 x + 4 - /

Exercise 2: Write the expression in


RPN.
12+3 (9−6)
+ 62
6∗7+3

→ RPN : 12 3 + 9 6 - * 6 7 * 3 + / 62 +
24 Computer System Architecture
Show Stack Organization
To Complete
Reverse Polish Notation

25 Computer System
Architecture
Computer System Architecture
Illustrate the stack of RPN to solve the problem in
exercise 1:

27 Computer System
Architecture
Illustrate the stack of RPN to solve the problem in
exercise 2:

28 Computer System
Architecture
ILLUSTRATE
BINARY TREE
TO PRODUCE
REVERSE POLISH NOTATION

29 Computer System
Architecture
30 Computer System
Architecture
31 Computer System
Architecture
32 Computer System
Architecture
33 Computer System
Architecture
34 Computer System
Architecture
35 Computer System
Architecture
36 Computer System
Architecture
Question: Find the reverse polish notation from the node of tree.

+
359+2*+
3 *

+ 2

5 9

37 Computer System
Architecture
Instruction Sets
CISCTechnology
Complex Instruction Set Computing
Conventional computers
Many of the instructions are not used

RISCTechnology
Reduced Instruction Set Computing
Small subset of instructions
Increases speed
Programs with few complex instructions
Graphics
Engineering

38 Computer System Architecture


Complex Instruction Set Computers (CISC)

Complex Instruction Set Computer (or CISC) is a computer with a


larger number of instruction. It is developed by Intel and is the
earliest computer architecture.

The major characteristic of CISC:


• Large number of instruction from 100 to 250 instructions.
• Some instruction that perform specialized task and are used
infrequently.
• Larger variety of addressing modes – typically from 5 to 20
different modes.
• Variable-length instruction formats
• Instruction that manipulates operands in memory.

39
20 Computer System Architecture
Reduced Instruction Set Computer (RISC)
In the early 1980s, a number of computerdesignerrecommended that
computers uses fewer instructions with simple constructs, so they can be
executed much faster within the CPU without having to use memory
often.This type of computer is classified as reduced instruction set
computer or RISC

The major characteristic of RISC:


• Relatively few instruction &few addressing modes
• Executing all instruction done in one cycle machine.
• Memory access limited to load and storeinstructions only
• All operation done within the register of the CPU
• Fixed-length, easily decoded instruction format

40
21 Computer System Architecture
Types of Processing
A typical modern computer runs dozens to
hundreds of tasks at any given time; however,
each core is only working on one process at
once. The processor constantly jumps between
the different processing "threads" or "instruction
streams" to run several concurrent programs
under a real-time illusion called concurrency. The
computer ends up wasting processor cycles while
switching between jobs and doesn't run at
optimal efficiency when multitasking.
Computer System Architecture
41
Serial processing
Execute one instruction at a time
Fetch, decode, execute,store

Parallel Processing
Multiple processors used at the same time
Can perform trillions of floating-point instructions per second
(teraflops)
Ex: network servers, supercomputers

42 Computer System
Architecture
Types of Processing

Pipelining
Instruction’s action need not be complete before the next
begins
Fetch instruction 1, begin to decode and fetch instruction 2

43
23 Computer System Architecture

You might also like