Anda di halaman 1dari 47

Pengantar

Organisasi Komputer

Single Clock Datapath


Hanif Rasyidi

Pembahasan Bab Ini


CPU Overview
Membangun datapath

Masalah kinerja

Hanif Rasyidi - POK 2014

Introduction
CPU performance factors
Jumlah instruksi
Tergantung arsitektur dan compiler

Cycle per Instruction and Cycle time


Ditentukan hardware

Contoh penggunaan
Memory reference: lw, sw
Arithmetic/logical: add, sub, and, or, slt
Control transfer: beq, j
Hanif Rasyidi - POK 2014

Eksekusi Instruksi
PC memory instruksi, fetch instruksi
Register register file, read registers

Hanif Rasyidi - POK 2014

Eksekusi Instruksi
PC memory instruksi, fetch instruksi
Register register file, read registers

Tergantung instruksi
Penggunaan ALU untuk mendapatkan
Hasil operasi arithmetic
Alamat memory untuk load/store
Alamat percabangan (branch)

Akses memory data untuk load/store


PC PC + 4 atau alamat instruksi
Hanif Rasyidi - POK 2014

CPU Overview

Hanif Rasyidi - POK 2014

CPU Overview

Bukan hanya
sambung kabel

Gunakan multiplexers

Hanif Rasyidi - POK 2014

CPU + MUX + Control

Hanif Rasyidi - POK 2014

Dasar Logic Design


Informasi ter-encode sebagai binary
Low voltage = 0, High voltage = 1
Satu sambungan per bit
Multi-bit data ter-encode pada multi-wire buses

Combinational element
Beroperasi pada data
Output adalah fungsi terhadap input

State (sequential) elements


Menyimpan informasi
Hanif Rasyidi - POK 2014

Combinational Elements

AND-gate

Y=A&B

A
B

Multiplexer

A
+

Y=A+B

Adder

Arithmetic/Logic Unit

Y = F(A, B)

Y = S ? I1 : I0
I0
I1

M
u
x

A
ALU

B
F
Hanif Rasyidi - POK 2014

Sequential Elements
Register: stores data in a circuit
Menggunakan sinyal dari clock untuk menentukan kapan
mengupdate nilai yang tersimpan
Edge-triggered: update ketika Clk berubah dari 0 ke 1

Clk
D

Q
D

Clk

Hanif Rasyidi - POK 2014

Sequential Elements
Register with write control
Hanya melakukan update ketika write control input bernilai 1
Digunakan saat sebuah nilai butuh disimpan dan digunakan di
kemudian waktu
Clk
D
Write
Clk

Write
D

Q
Hanif Rasyidi - POK 2014

Clocking Methodology
Combinational logic mengubah data pada tiap clock
cycles
Di antara tepi tiap clock
Masukan dari sebuah elemen dan keluaran menuju sebuah
elemen
Delay/waktu eksekusi instruksi terpanjang menentukan
periode clock

Hanif Rasyidi - POK 2014

Membangun Datapath
Datapath
Bagian yang memproses data dan alamat yang ada di
dalam CPU
Registers, ALUs, muxs, memories,

Hanif Rasyidi - POK 2014

Membangun Datapath
Datapath
Bagian yang memproses data dan alamat yang ada di
dalam CPU
Registers, ALUs, muxs, memories,

Kita bahas 3 bagian


Fetch instruksi
Instruksi R-Format
Percabangan

Hanif Rasyidi - POK 2014

Instruction Fetch

Program Counter

Instruction Fetch

Program Counter

Instruction Memory

Instruction Fetch

Program Counter

Instruction Memory

ALU / Adder

Instruction Fetch

Instruction Fetch

32-bit
register

Increment 4
untuk
instruksi
berikutnya

R-Format Instructions
Baca 2 register operand
Lakukan operasi arithmetic/logical

Tulis ke register hasil

Hanif Rasyidi - POK 2014

R-Format Instructions
Baca 2 register operand
Lakukan operasi arithmetic/logical

Tulis ke register hasil

Hanif Rasyidi - POK 2014

Load/Store Instructions
Baca register operand
Hitung alamat dengan 16-bit offset
Gunakan ALU, tapi gunakan sign-extend offset

Load: Baca memory dan update register


Store: Tulis nilai register ke memory

Hanif Rasyidi - POK 2014

Load/Store Instructions
Baca register operand
Hitung alamat dengan 16-bit offset
Gunakan ALU, tapi gunakan sign-extend offset

Load: Baca memory dan update register


Store: Tulis nilai register ke memory

Hanif Rasyidi - POK 2014

Branch Instructions
Baca register operands
Bandingkan operands
Gunakan ALU, kurangi dan cek Zero output

Hitung alamat tujuan


Sign-extend displacement
Shift left 2 places (word displacement)
Add to PC + 4
Sudah dilakukan oleh insturction fetch

Hanif Rasyidi - POK 2014

Branch Instructions
Just
re-routes
wires

Sign-bit wire
replicated

Composing the Elements


First-cut data path menjalankan sebuah instruksi
dalam satu clock cycle
Setiap elemen pada datapath hanya bisa menjalankan
sebuah fungsi
Maka kita membutuhkan data memory dan instruksi
memory di tempat terpisah

Gunakan multiplexer untuk memilih memory yang


ingin diakses
Hanif Rasyidi - POK 2014

R-Type/Load/Store Datapath

Hanif Rasyidi - POK 2014

Full Datapath

Hanif Rasyidi - POK 2014

ALU Control
ALU used for
Load/Store: F = add
Branch: F = subtract
R-type: F tergantung dari fungsi yang dibutuhkan
ALU control

Function

0000

AND

0001

OR

0010

add

0110

subtract

0111

set-on-less-than

1100

NOR
Hanif Rasyidi - POK 2014

ALU Control
Asumsikan 2-bit ALUOp dihasilkan dari opcode
Combinational logic menghasilkan ALU control
opcode

ALUOp

Operation

funct

ALU function

ALU control

lw

00

load word

XXXXXX

add

0010

sw

00

store word

XXXXXX

add

0010

beq

01

branch equal

XXXXXX

subtract

0110

R-type

10

add

100000

add

0010

subtract

100010

subtract

0110

AND

100100

AND

0000

OR

100101

OR

0001

set-on-less-than

101010

set-on-less-than

0111

Hanif Rasyidi - POK 2014

The Main Control Unit


Sinyal kontrol dihasilkan oleh instruksi
R-type

rs
31:26

Load/
Store

35 or 43

25:21

rs

31:26
Branch

rt

opcode

20:16

rt
25:21

rs
31:26

rd

always
read

15:11

10:6

funct
5:0

address
20:16

rt
25:21

shamt

15:0

address
20:16

read,
except
for load

15:0
write for
R-type and
load

sign-extend
and add
Hanif Rasyidi - POK 2014

Datapath With Control

Hanif Rasyidi - POK 2014

R-Type Instruction

Hanif Rasyidi - POK 2014

Load Instruction

Hanif Rasyidi - POK 2014

Branch-on-Equal Instruction

Hanif Rasyidi - POK 2014

Mengimplementasi Jumps
Jump

address
31:26

25:0

Jump menggunakan alamat yang dituju


Update PC dengan penggabungan
Top 4 bits of old PC
26-bit jump address
00

Membutuhkan sinyal kontrol extra yang didapatkan

dari opcode
Hanif Rasyidi - POK 2014

Datapath With Jumps Added

Hanif Rasyidi - POK 2014

Hanif Rasyidi - POK 2014

Hanif Rasyidi - POK 2014

Hanif Rasyidi - POK 2014

Hanif Rasyidi - POK 2014

Hanif Rasyidi - POK 2014

Hanif Rasyidi - POK 2014

Hanif Rasyidi - POK 2014

Hanif Rasyidi - POK 2014

Performance Issues
Delay terbesar menentukan periode clock
Critical path: load instruction
Instruction memory register file ALU data memory
register file

Tidak mungkin membedakan periode clock untuk tiap


instruksi HARUS SAMA
Melanggar design principle
Making the common case fast

Performa dapat ditingkatkan dengan pipelining


Hanif Rasyidi - POK 2014

Anda mungkin juga menyukai