47
Pengantar Organisasi Komputer Single Clock Datapath Hanif Rasyidi

6. Single Clock Datapath

Embed Size (px)

DESCRIPTION

Single Clock Datapath

Citation preview

PengantarOrganisasi Komputer

Single Clock DatapathHanif Rasyidi

Hanif Rasyidi - POK 2014

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

A

BY

I0

I1Y

Mux

S

Multiplexer

Y = S ? I1 : I0

A

B

Y+

A

B

YALU

F

Adder

Y = A + B

Arithmetic/Logic Unit

Y = F(A, B)

AND-gate

Y = A & B

Hanif Rasyidi - POK 2014

Sequential Elements

•Register: stores data in a circuit

• Menggunakan sinyal dari clock untuk menentukan kapanmengupdate nilai yang tersimpan

• Edge-triggered: update ketika Clk berubah dari 0 ke 1

D

Clk

Q

Clk

D

Q

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

D

Clk

Q

Write

Write

D

Q

Clk

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, mux’s, memories, …

Hanif Rasyidi - POK 2014

Membangun Datapath

•Datapath

• Bagian yang memproses data dan alamat yang ada di dalam CPU• Registers, ALUs, mux’s, memories, …

•Kita bahas 3 bagian

• Fetch instruksi• Instruksi R-Format• Percabangan

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 untukinstruksiberikutnya

Hanif Rasyidi - POK 2014

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

Branch Instructions

Justre-routes wires

Sign-bit wire replicated

Hanif Rasyidi - POK 2014

Composing the Elements

•First-cut data path menjalankan sebuah instruksi

dalam satu clock cycle

• Setiap elemen pada datapath hanya bisa menjalankansebuah fungsi

• Maka kita membutuhkan data memory dan instruksimemory 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

0 rs rt rd shamt funct

31:26 5:025:21 20:16 15:11 10:6

35 or 43 rs rt address

31:26 25:21 20:16 15:0

4 rs rt address

31:26 25:21 20:16 15:0

R-type

Load/Store

Branch

opcode always read

read, except for load

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 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

2 address

31:26 25:0

Jump

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