Anda di halaman 1dari 51

CHAPTER 4

THE PROCESSING UNIT

CLO1 : Explain effectively computer function, input,


output and central processing unit in computer
system. (C2, PLO1)
4.1 Understand the Central Processing Unit (CPU).
4.1.1 Define the CPU.
4.1.2 Draw the CPU diagram.
4.1.3 Describe types of instruction cycle: Fetch cycle, Decode
cycle and Execute cycle.

(CLO1,PLO1,LD1,C2)
*LD 1- Knowledge
C2- Comprehension
UNDERSTAND THE CENTRAL PROCESSING UNIT (CPU)
Definition of CPU.

Central Processing Unit is referred as CPU, defined to be, the


part of the computer that do bulk of data-processing operations.

In simple word, CPU is the hardware component of the


computer that does most of the work in executing a program.

The CPU is made up from THREE (3) major parts which is:

Register set

Arithmetic-Logic Unit (ALU)

Control Unit
Final questions sample

Select two typical component of CPU

A. Cache and hard disk

B. Register and memory

C. CD Drive and DVD drive

D. Arithmetic logic unit (ALU) and control unit (CU)


• Komputer mempunyai unit melaksana arahan yang diberi dengan
memproses data-data. Proses yang dilakukan adalah dengan menerima
dan menyimpan data dari peranti input kemudian diproses mengikut
arahan dan dihantar hasilnya kepada peranti output.

• Ia dilakukan oleh Unit Pemprosesan Pusat atau CPU yang berfungsi


untuk memproses arahan, melaksanakan pengiraan dan menguruskan
laluan infomasi menerusi sistem computer ALU.

• Unit atau peranti pemprosesan juga akan berkomunikasi dengan


peranti input, output dan storan bagi melaksanakan arahan-arahan
berkaitan yang diperlukan.

• Data yang telah diproses akan dipindahkan ke dalam storan. Storan


adalah tempat untuk menyimpan data, arahan serta maklumat untuk
kegunaan pada masa hadapan. Komputer menggunakan storan untuk
menyimpan perisian system dan perisian aplikasi. Ia terdiri daripada
storan utama dan storan kedua
• Arahan dan data dimasukkan (input) ke dalam computer
menerusi peranti input tertentu seperti papan kekunci, tetikus
dan sebagainya.

• Kemudian arahan dan data tersebut dipindahkan ke dalam CPU


untuk diproses. CPU berfungsi untuk mengawal semua aktiviti
di dalam system computer menerusi arahan-arahannya.

• CPU terdiri daripada aritmatik logic unit (ALU) yang


melaksanakan pengiraan Matematik dan unit kawalan yang
mencapai arahandari ingatan utama, menerima pengiraan dari
ALU dan melaksanakan arahan.

• Untuk setiap arahan yang diberikan, Unit Kawalan (Control)


dalam CPU akan melakukan 4 oeprasi asas yang dipanggil
arahan kitaran mesin (instruction machine cycle) Angkut
(Fetch) – Terjemah (Decode) - Laksana (Execute) - Simpan
(Store)
Clock Unit
The clock unit controls the speed of the computer.
Types of instruction cycle
The control unit of a computer is designed to go through an instruction cycle that is
divided into THREE (3) major phases. Step 1 - Fetch the instruction from
memory
2 Program Counter (PC)
Unit keeps(control
kawalan track of the
unit)
instructionsakaninmengangkut
the program(fetch)
stored in
Decode memory. Program
arahancounter holds
program
of the instruction ingatan
dan
to be executed
thedata
address
dari
next and is
utama (RAM)
incremented each time an instruction is
fetch from memory

Step 2 - Decode the instruction


1
3 The decoding is done (control
Unit kawalan to determine the
unit) akan
operation tomenterjemah
be performed, the addressing
(decode) arahan
Fetch Execute mode of the instruction, and the data
dan pindahkan location
yangof the
diperlukan dari memorioperands.
ke ALU

Step 3 - Execute the instruction


The computerALU
thenakan melaksanakan
executes the instruction
and menterjemah
return to step (execute)
1 to fetcharahan
the next
4 aritmetik dan logik
instruction in sequence.
Kitar Ambil (Fetch Cycle)
• Unit kawalan terima arahan daripada memori dan
increment.
• Penunjuk arahan menunjuk kepada arahan berikutnya.
• Arahan perlaksanaan dan datanya diletakkan di pendaftar.
• Unit kawalan isyarat kepada ALU undtuk laksana arahan.

Kitar Pelaksanaan (Execute Cycle)


• ALU akan ambil data perlaksanaan daripada pendaftar.
• Arahan dibuat (di dalam litar)
• Hasil perlaksanaan diletak ke dalam pendaftar, atau control
unit.
Proses kitaran pemprosesan ini berterusan satu demi satu
sehinggalah arahan terakhir program tersebut dilaksanakan.
Final questions sample

Select the types of instruction cycle that is include in Control unit.


i. Decode
ii. Calculate
iii. Fetch
iv. Execute

A. I, ii, and iii

B. Ii, iii, and iv

C. I, ii and iv

D. I, iii and iv
4.2 Understand stack organisation.

4.2.1 Describe the basic organisation of the stack in


computer system.
4.2.2 Describe the function of register stack and memory stack.
4.2.3 Describe the use of Reverse Polish Notation.

(CLO1,PLO1,LD1,C2)
*LD 1- Knowledge
C2- Comprehension
Stack pada umumnya digunakan untuk menyimpan data atau operasi aritmatik
Stack adalah satu teknik bagaimana sesuatu penyimpanan atau menganbil (fetch) data dari
memori berlaku.
Understand stack organization
Stack is a storage device that store information in such a manner that the
item stored (in) last, is the first item retrieved (out).

Also called last-in, first-out (LIFO) list.

The TWO (2) operation of a stack are:


1. Insertion of item (called push or push-down) because it can be thought of
as the result of pushing new item on top.
2. Deletion of item (called pop or 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)
Understand stack organization
• In general, stacks ... • can be located anywhere in
memory • can use any register as the stack pointer •
can grow as long as there is space in memory
• Stack is essential in a memory unit with an address
register that can count only (after an initial value is
loaded into it).

• Stack Pointer (SP) : A register that holds the address


for the stack 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
10
first taken off. (LIFO)
Function of register and memory stack
i.Register Stack
A stack 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 Register adalah sebahagian
value is equal to the address of the word/register kecil memori yang
that is currently on top of the stack. mempunayi kecekapan
akses yang cukup tinggi
kerana terletak pada CPU.
ii.Memory Stack Register digunakan untuk
A stack can exist as a stand-alone unit or can be menyimpan data dan
arahan yang sedang
implemented in a random-access memory attached to a diproses, menetara data
CPU.The implementation of a stack in the CPU is done dan arahan lain menunggu
by assigning a portion of memory to a stack operation giliran utk diproses yang
masih tersimpan didalam
and using a processor register as a stack pointer. memori.
Computer Memory with program, data & stack
segment
The three registers are connected
M em o ry U n it
to a common address bus, and PC Program 1000
either one can provide an address (Instructions)

for memory.
AR Data 2000
(Operands)
PC is used during the fetch phase
to read instruction. Merupakan
Stack 3000
register yang menunjuk ke
arahan berikutnya yang harus
3997
dilaksanakan SP
3998
3999
AR is used during the execute After a push 4000
operation, SP is
phase to read an operand compared with the
4001

upper-limit register DR
SP is used to push or pop item and after a pop, SP is
Example of stack limit:
into or from the stack. SP points compared with the
lower unit register. The upper limit: 3000
at the tops of the stack The lower limit: 4001
Stack Limit
Most computers do not provide hardware to check for
stack overflow
(full stack. Try to push too many onto the stack) or
underflow (empty stack. Try to pop too many off the
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.
Describe the use of Reverse Polish Notation

• The Polish mathematician Lukasiewicz show that arithmetic


expression can be represented in prefix notation.

• This representation often referred to as Polish notation;


place the operator before the operand. (Prefix)

• The postfix notation, referred to as Reverse Polish


notation (RPN),places the operator after the operand.
(Postfix)
Describe the use of Reverse Polish Notation
The following examples demonstrate the three
representations:
A + B Infix notation
+ AB Prefix or Polish notation
AB + Postfix or reverse Polish notation

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 * +
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 + *
Conversion to RPN (reverse Polish notation) cont..
Proceeding from left to right, we first add A and 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 C and (D + E).These two
numbers are multiplied and the product added to F.The final *
cause the multiplications of the two terms.
Final questions sample

Given an expression A*B+C*D. Choose the correct Reverse


Polish Notation for that expression

A. AB*CD*+

B. A*BCD*+

C. AB*CD+*

D. A*B*CD+
[(3+6)+1 * 4 + (2*5)] * (8+7)
5 + ((1 + 2) × 4) − 3 convert to RPN
Evaluation of Arithmetic Expressions
Reverse Polish notation, combined with a stack arrangement of register, is the
most efficient way known for evaluation the arithmetic expression.
- This procedure employed by some electronic calculators and also in some
computer.

Reason why, the combination of stack and reverse polish notation


is the most efficient way
1.Stack
Particularly, useful for handling long, complex problem involving chain
calculation.
2.Reverse Polish Notation.
Any arithmetic expression can be expressed in parentheses-free Polish
notation. Conversion of arithmetic expression into Polish notation is the most
efficient method for translating arithmetic into machine language instruction.
How to implement arithmetic in stack methods

Example: 4(A + B)

This uses the infix notation. Then, converting it to reverse


Polish notation gives 4AB+*

I. Sort value into LIFO order


II. Remove the two top items from the stack
III. Do the expression given by the operand
IV. Return the result to the stack.
Evaluation of Arithmetic Expressions
The procedure consist,
1.Converting arithmetic expression into its equivalent reverse Polish notation.
2.Reverse Polish Notation.

2.The operand is pushed into the stack in the order in which they appear.
(a)The two top most operands in the stack are used for the operation.
(b)The stack is popped the result of the operation replace the lower operand.
Evaluation of Arithmetic Expressions
(3*4) + (5*6)
Expression: (3+10)*5
4.3 Understand Complex Instruction Set Computers (CISC) and Reduced
Instruction Set Computer (RISC)

4.3.1 Describe Reduced Instruction Set Architecture.


4.3.2 Differentiate the characteristics between Reduced Instruction
Set Computer (RISC) and Complex Instruction Set Computers.
(CISC).
4.3.3 Describe RISC pipelining.

(CLO1,PLO1,LD1,C2)
*LD 1- Knowledge
C2- Comprehension
Complex Instruction Set Computers (CISC)
CISC atau Complex Instruction-Set Computer berarti “kumpulan arahan pengiraan
kompleks". CISC adalah sebuah arkitektur dari set arahan dimana setiap
arahan akan menjalankan beberapa operasi tingkat rendah, seperti pengambilan
dari memory, operasi aritmetika, dan penyimpanan ke dalam memory, semuanya
sekaligus hanya di dalam sebuah arahan. Karakter CISC dapat dikatakan berhubung kait
dengan dengan RISC.

Konsep CISC menjadikan mesin mudah untuk diprogram dalam bahasa aras rendah,
tetapi konsep ini menyulitkan dalam penyusunan kompiler bahasa aras tinggi. Dalam CISC
banyak terdapat perintah bahasa mesin.

Ciri-ciri Prosesor CISC :


a. Jumlah arahan yang banyak dan arahan yang lebih kompleks.
b. CISC hanya menghasilkan program yang lebih kecil dan lebih cepat.
c. Ukuran program-program yang dihasilkan akan menjadi relatif lebih kecil, dan
penggunaan memory akan semakin berkurang.

Contoh-contoh prosesor CISC adalah System/360, VAX, PDP-11,


varian Motorola 68000 , dan CPU AMD dan Intel x86.
Reduced Instruction Set Computer (RISC)
RISC berarti " kumpulan arahan yang diringkaskan". RISC
merupakan sebuah arkitektur komputer moden dengan arahan-arahan dan jenis
arithmatik yang paling ringkas.
RISC singkatan dari Reduced Instruction Set Computer. Merupakan bahagian dari arkitektur
mikroprosessor, berbentuk kecil dan berfungsi untuk mengatur arahan dalam komunikasi
diantara komponen yang lain. RISC atau Reduced Instruction Set Computing
pertama kali digagas oleh John Cocke, seorang
peneliti dari IBM di Yorktown, New York pada tahun 1974.
Komputer pertama yang menggunakan
konsep RISC ini adalah IBM PC/XT pada era 1980-an. Istilah RISC sendiri pertama
kali dipopulerkan oleh David Patterson, pengajar pada University of California di
Berkely.
The major characteristic of RISC:
• Limited and simple instruction set
• Relatively few addressing modes
• Memory access limited to load and store instructions
• All operation done within the register of the CPU
• Fixed-length, easily decoded instruction format
• Single-cycle instruction execution
• Hardwired rather that micro-programmed control.
What are Reduced Instruction Set Computer (RISC)
In the early 1980s, a number of computer designer recommended 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 RISC architectures is an attempt to produce more CPU power by


simplifying the instruction set of the CPU.

CISC Complex Instruction Set


Computer sedangkan RISC
merupakan kesenambungan dari
Reduced Instruction Set Computer.
Chip RISC dibangun pada
pertengahan tahun 1980 sebagai
pengganti chip CISC.
BAGAIMANA REGISTER BERFUNGSI DI DALAM CPU?
Register merupakan alat penyimpanan kecil yang
mempunyai kecepatan akses cukup tinggi, yang
digunakan untuk menyimpan data dan/atau arahan
yang sedang diproses. Memori ini bersifat
sementara, biasanya digunakan untuk menyimpan
data semasa di lakukan ataupun data untuk arahan
selanjutnya. Secara analogik, register ini dapat
diibaratkan sebagai ingatan di dalam otak apabila
kita melakukan perlaksanaan data secara manual,
yg dapat diibaratkan sebagai CPU, yang berisi
ingatan-ingatan. Otak dapat mengatur seluruh
kegiatan tubuh dan mempunyai tempat untuk
melakukan pengiraan dan perbandingan logik.
Extra....
Register Array part.1
A register is a memory location within the CPU itself, designed to be
quickly accessed for purposes of fast data retrieval. Processors normally
contain a register array, which houses many such registers. These
contain instructions, data and other values that may need to be quickly
accessed during the execution of a program. Many different types of
registers are common between most microprocessor designs. These
are:
1. Program Counter (PC)
This register is used to hold the memory address of the next instruction
that has to executed in a program. This is to ensure the CPU knows at
all times where it has reached, that is able to resume following an
execution at the correct point, and that the program is executed
correctly. (adalah daftar prosesor yang menunjukkan tempat komputer
dalam urutan arahan secara berturutan)
Register Array part.2

2. Instruction Register (IR)


This is used to hold the current instruction in the processor while it is
being decoded and executed, in order for the speed of the whole
execution process to be reduced. This is because the time needed to
access the instruction register is much less than continual checking of
the memory location itself. (Instruction Register (IR) digunakan untuk
menyimpan arahan yang sedang diproses)

3. Accumulator (A, or ACC)


The accumulator is used to hold the result of operations performed by
the arithmetic and logic unit, as covered in the section on the ALU.
Register Array part.3
4. Memory Address Register (MAR)
Used for storage of memory addresses, usually the addresses involved in the
instructions held in the instruction register. The control unit then checks this register
when needing to know which memory address to check or obtain data from. (Register
penunjuk alamat memori merupakan register yang menampung alamat data atau
arahan pada main memory yang akan diakses. Register yang berisi alamat yang mana
alamat tersebut adalah alamat dari sel memory. Alamat data atau memory akan di salin
(COPY) ke dalam MAR, Kemudian alamat tersebut akan dicari didalam memory.
Setelah ditemukan, data atau arahan akan di masukkan ke dalam MBR.

5. Memory Buffer Register (MBR)


When an instruction or data is obtained from the memory (MAR) or elsewhere, it is
first placed in the memory buffer register. The next action to take is then determined
and carried out, and the data is moved on to the desired location. (Suatu register yang
berfungsi untuk memuat isi maklumat yang akan dituliskan ke memori atau baru saja
dibaca dari memori yang ditunjukkan pada alamat (MAR) . Berperanan dalam proses
mengakses memori dalam proses read/write dari atau ke memori.
Register Array part.4
6. Flag register / status flags
The flag register is specially designed to contain all the appropriate 1-bit status
flags, which are changed as a result of operations involving the arithmetic and
logic unit. Further information can be found in the section on the ALU. (Sesuai
dengan namanya Flags (bendera), register ini menunjukkan keadaaan dari suatu
keadaan (YA atau TIDAK). Setiap keadaan hanya dapat digunakan 1 bit saja,
sehingga jumlah bitnya Flags Register 16 keadaan. Kod yang menggambarkan
hasil operasi sebelumnya).

7. Other general purpose registers


These registers have no specific purpose, but are generally used for the quick
storage of pieces of data that are required later in the program execution.
• Digunakan untuk mode address dan data.
• Akumulator ( aritmatika, Shift, Rotate)
• Base Register (Rotate,Shift, aritmatik)
• Counter Register ( Looping)
• Data Register (menyimpan alamat I/O device).
Rumusan beberapa jenis register adalah:
1. Program Counter (PC), merupakan register yang menunjuk ke
arahan berikutnya yang harus diambil dan dijalankan.
2. Instruction Register (IR), merupakan register yang menyimpan
arahan yang sedang dijalankan.
3. General Purpose Register, merupakan register yang memiliki
kegunaaan umum yang berhubungan dengan data yang
diproses.
4. Memory Data Register (MDR), merupakan register yang
digunakan untuk menampung data atau arahan hasil
pengiriman dari memori utama ke CPU atau menampung data
yang akan dicopy ke memori utama dari hasil pengolahan oleh
CPU.
5. Memory address register (MAR), merupakan register yang
digunakan untuk menampung alamat data atau alamat pada
memori utama yang akan diambil atau yang akan diletakkan.
• Sebagian besar komputer memiliki beberapa register lain, ia
Register ini digunakan oleh UNIT CONTROL untuk mengawal
operasi CPU oleh program system operasi dan mengawal
perlaksanaan program

Anda mungkin juga menyukai