Processor Architecture III: Sequential Implementation - Lecture Slides | CSCE 230, Study notes of Computer Architecture and Organization

Material Type: Notes; Class: Computer Organization; Subject: Computer Science and Engineering ; University: University of Nebraska - Lincoln; Term: Unknown 1989;

Typology: Study notes

Pre 2010

Uploaded on 08/31/2009

koofers-user-251
koofers-user-251 🇺🇸

10 documents

1 / 23

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Page 1
Processor Architecture III:
Sequential Implementation
CSCE 230J
Computer Organization
Dr. Steve Goddard
http://cse.unl.edu/~goddard/Courses/CSCE230J
2
Giving credit where credit is due
Most of slides for this lecture are based on
slides created by Dr. Bryant, Carnegie
Mellon University.
I have modified them and added new
slides.
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15
pf16
pf17

Partial preview of the text

Download Processor Architecture III: Sequential Implementation - Lecture Slides | CSCE 230 and more Study notes Computer Architecture and Organization in PDF only on Docsity!

Processor Architecture III:

Sequential Implementation

CSCE 230J

Computer Organization

Dr. Steve Goddard

[email protected]

http://cse.unl.edu/~goddard/Courses/CSCE230J

2

Giving credit where credit is due

 Most of slides for this lecture are based on

slides created by Dr. Bryant, Carnegie

Mellon University.

 I have modified them and added new

slides.

3

Y86 Instruction Set Byte 0 1 2 3 4 5

pushl rA A (^0) rA 8

jXX Dest (^7) fn Dest

popl rA B (^0) rA 8

call Dest (^8 0) Dest

rrmovl rA, rB (^2 0) rA rB irmovl V, rB (^3 0 8) rB V rmmovl rA, D(rB) (^4 0) rA rB D mrmovl D(rB), rA (^5 0) rA rB D OPl rA, rB (^6) fn rA rB

ret 9 0

nop 0 0 halt 1 0

addl 6 0 subl 6 1 andl 6 2 xorl 6 3

jmp 7 0 jle 7 1 jl 7 2 je 7 3 jne 7 4 jge 7 5 jg 7 6

4

Building Blocks

Combinational Logic

 Compute Boolean functions of

inputs

 Continuously respond to input

changes

 Operate on data and implement

control

Storage Elements

 Store bits

 Addressable memories

 Non-addressable registers

 Loaded only as clock rises

Register file

A

B

W (^) dstW

srcA

valA

srcB

valB

valW

Clock

A

L

U

fun

A

B

MUX

Clock

7

SEQ Hardware

Structure

State

 Program counter register (PC)

 Condition code register (CC)

 Register File

 Memories

 Access same memory space  Data: for reading/writing program data  Instruction: for reading instructions

Instruction Flow

 Read instruction at address

specified by PC

 Process through stages

 Update program counter

Instruction Instructionmemorymemory incrementincrement PCPC

CCCC (^) ALUALU

memorymemoryData^ Data

Fetch

Decode

Execute

Memory

Write back

icoderA , rB , ifun valC

RegisterRegister^ A^ filefileB^ M E

Register Register^ A^ filefileB^ M E

PC

valP

srcA, srcBdstA, dstB

valA, valB

aluA, aluB

Bch

valE

Addr, Data

valM

PC

valE, valM

newPC

8

SEQ Stages

Fetch

 Read instruction from instruction

memory

Decode

 Read program registers

Execute

 Compute value or address

Memory

 Read or write data

Write Back

 Write program registers

PC

 Update program counter

Instruction Instructionmemorymemory incrementincrement PCPC

CCCC (^) ALUALU

memorymemoryData^ Data

Fetch

Decode

Execute

Memory

Write back

icoderA , rB , ifun valC

RegisterRegister^ A^ filefileB^ M E

Register Register^ A^ filefileB^ M E

PC

valP

srcA, srcBdstA, dstB

valA, valB

aluA, aluB

Bch

valE

Addr, Data

valM

PC

valE, valM

newPC

9

Instruction Decoding

Instruction Format

 Instruction byte icode:ifun

 Optional register byte rA:rB

 Optional constant word valC

5 0 rA rB D

icode

ifun

rA

rB

valC

Optional Optional

10

Executing Arith./Logical Operation

Fetch

 Read 2 bytes

Decode

 Read operand registers

Execute

 Perform operation

 Set condition codes

Memory

 Do nothing

Write back

 Update register

PC Update

 Increment PC by 2

OPl rA , rB 6 fn (^) rA rB

13

Stage Computation: rmmovl

 Use ALU for address computation

rmmovl rA, D(rB) icode:ifun ←←←← M 1 [PC] rA:rB ←←←← M 1 [PC+1] valC ←←←← M 4 [PC+2] valP ←←←← PC+

Fetch

Read instruction byte Read register byte Read displacement D Compute next PC valA ←←←← R[rA] valB ←←←← R[rB] Decode Read operand A Read operand B valE ←←←← valB + valC Execute Compute effective address

Memory M 4 [valE] ←←←← valA Write value to memory Write back PC update PC ←←←← valP Update PC

14

Executing popl

Fetch

 Read 2 bytes

Decode

 Read stack pointer

Execute

 Increment stack pointer by 4

Memory

 Read from old stack pointer

Write back

 Update stack pointer

 Write result to register

PC Update

 Increment PC by 2

popl rA b (^0) rA 8

15

Stage Computation: popl

 Use ALU to increment stack pointer

 Must update two registers

 Popped value  New stack pointer

popl rA icode:ifun ←←←← M 1 [PC] rA:rB ←←←← M 1 [PC+1]

valP ←←←← PC+

Fetch

Read instruction byte Read register byte

Compute next PC valA ←←←← R[ %esp ] valB ←←←← R [ %esp ] Decode Read stack pointer Read stack pointer valE ←←←← valB + 4 Execute Increment stack pointer

Memory valM ←←←← M 4 [valA] Read from stack R[ %esp ] ←←←← valE R[rA] ←←←← valM

Write back

Update stack pointer Write back result PC update PC ←←←← valP Update PC

16

Executing Jumps

Fetch

 Read 5 bytes

 Increment PC by 5

Decode

 Do nothing

Execute

 Determine whether to take

branch based on jump

condition and condition

codes

Memory

 Do nothing

Write back

 Do nothing

PC Update

 Set PC to Dest if branch

taken or to incremented PC

if not branch

jXX Dest 7 fn Dest fall thru:^ XX^ XX

target:^ XX^ XX

Not taken

Taken

19

Stage Computation: call

 Use ALU to decrement stack pointer

 Store incremented PC

call Dest icode:ifun ←←←← M 1 [PC]

valC ←←←← M 4 [PC+1] valP ←←←← PC+

Fetch

Read instruction byte

Read destination address Compute return point

valB ←←←← R[ %esp ] Decode Read stack pointer valE ←←←← valB + – Execute Decrement stack pointer

Memory M 4 [valE] ←←←← valP Write return value on stack Write R[ %esp ] ←←←← valE back

Update stack pointer

PC update PC ←←←← valC Set PC to destination

20

Executing ret

Fetch

 Read 1 byte

Decode

 Read stack pointer

Execute

 Increment stack pointer by 4

Memory

 Read return address from

old stack pointer

Write back

 Update stack pointer

PC Update

 Set PC to return address

ret 9 0

return:^ XX^ XX

21

Stage Computation: ret

 Use ALU to increment stack pointer

 Read return address from memory

ret icode:ifun ←←←← M 1 [PC] Fetch

Read instruction byte

valA ←←←← R[ %esp ] valB ←←←← R[ %esp ] Decode Read operand stack pointer Read operand stack pointer valE ←←←← valB + 4 Execute Increment stack pointer

Memory valM ←←←← M 4 [valA] Read return address Write R[ %esp ] ←←←← valE back

Update stack pointer

PC update PC ←←←← valM Set PC to return address

22

Computation Steps

 All instructions follow same general pattern

 Differ in what gets computed on each step

OPl rA, rB icode:ifun ←←←← M 1 [PC] rA:rB ←←←← M 1 [PC+1]

valP ←←←← PC+

Fetch

Read instruction byte Read register byte [Read constant word] Compute next PC valA ←←←← R[rA] valB ←←←← R[rB] Decode Read operand A Read operand B valE ←←←← valB OP valA Set CC Execute Perform ALU operation Set condition code register Memory [Memory read/write] Write R[rB] ←←←← valE back

Write back ALU result [Write back memory result] PC update PC ←←←← valP Update PC

icode,ifun rA,rB valC valP valA, srcA valB, srcB valE Cond code valM dstE dstM PC

25

SEQ Hardware

Key

 Blue boxes:

predesigned hardware

blocks

 E.g., memories, ALU

 Gray boxes:

control logic

 Describe in HCL

 White ovals:

labels for signals

 Thick lines:

32-bit word values

 Thin lines:

4-8 bit values

 Dotted lines:

1-bit values

Instruction Instructionmemorymemory incrementincrement PCPC

CCCC ALUALU

memorymemory^ DataData

NewPC

rB

dstE dstM

ALUA ALUB

Mem.control Addr

srcA srcB

read write

ALUfun.

Fetch

Decode

Execute

Memory

Write back

data out

Register Register^ Afile^ fileB^ M E

Register Register^ Afile^ fileB^ M E

Bch

dstE dstM srcA srcB

icode ifun rA

PC

valC valP

valA valB

Data valE

valM

PC

newPC

26

Fetch Logic

Predefined Blocks

 PC: Register containing PC

 Instruction memory: Read 6 bytes (PC to PC+5)

 Split: Divide instruction byte into icode and ifun

 Align: Get fields for rA, rB, and valC

Instruction memory

Instruction memory

PC increment

PC increment

icode ifun rA rB

PC

valC valP

Need regids

Need Instr valC valid

SplitSplit Align Align Byte 0 Bytes 1-

27

Fetch Logic

Control Logic

 Instr. Valid: Is this instruction valid?

 Need regids: Does this instruction have a register

bytes?

 Need valC: Does this instruction have a constant word?

Instruction memory

Instruction memory

PC increment

PC increment

icode ifun rA rB

PC

valC valP

Need regids

Need Instr valC valid

SplitSplit Align Align Byte 0 Bytes 1-

28

Fetch Control

Logic

pushl rA A (^0) rA 8

jXX Dest 7 fn Dest

popl rA B 0 rA 8

call Dest (^8 0) Dest

rrmovl rA, rB (^2 0) rA rB irmovl V, rB 3 0 8 rB V rmmovl rA, D(rB) (^4 0) rA rB D mrmovl D(rB), rA 5 0 rA rB D OPl rA, rB (^6) fn rA rB

ret 9 0

nop 0 0 halt 1 0

pushlpushl rArA AAA (^000) rArArA 888

jXXjXX DestDest 777 fnfnfn DestDest

poplpopl rArA BBB 000 rArArA 888

callcall DestDest (^888 000) DestDest

rrmovlrrmovl rArA,, rBrB (^222 000) rArArA rBrBrB irmovlirmovl VV,, rBrB 333 000 888 rBrBrB VV rmmovlrmmovl rArA,, DD((rBrB)) (^444 000) rArArA rBrBrB DD mrmovlmrmovl DD((rBrB),), rArA 555 000 rArArA rBrBrB DD OPlOPl rArA,, rBrB (^666) fnfnfn rArArA rBrBrB

retret 999 000

nopnop 000 000 halthalt 111 000

bool need_regids = icode in { IRRMOVL, IOPL, IPUSHL, IPOPL, IIRMOVL, IRMMOVL, IMRMOVL };

bool instr_valid = icode in { INOP, IHALT, IRRMOVL, IIRMOVL, IRMMOVL, IMRMOVL, IOPL, IJXX, ICALL, IRET, IPUSHL, IPOPL };

31

E Destination

None

R[ %esp ] ←←←← valE Update stack pointer

None

R[rB] ←←←← valE

OPl rA, rB Write-back rmmovl rA, D(rB)

popl rA

jXX Dest

call Dest

ret

Write-back

Write-back

Write-back

Write-back

Write-back

Write back result

R[ %esp ] ←←←← valE Update stack pointer

R[ %esp ] ←←←← valE Update stack pointer int dstE = [ icode in { IRRMOVL, IIRMOVL, IOPL} : rB; icode in { IPUSHL, IPOPL, ICALL, IRET } : RESP; 1 : RNONE; # Don't need register ];

32

Execute Logic

Units

 ALU

 Implements 4 required functions  Generates condition code values

 CC

 Register with 3 condition code bits

 bcond

 Computes branch flag

Control Logic

 Set CC: Should condition code

register be loaded?

 ALU A: Input A to ALU

 ALU B: Input B to ALU

 ALU fun: What function should

ALU compute?

CC CC ALUALU

ALU A

ALU B

ALU fun.

Bch

icode ifun valC valA valB

valE

Set CC

bcond bcond

33

ALU A Input

valE ←←←← valB + –4 Decrement stack pointer

No operation

valE ←←←← valB + 4 Increment stack pointer

valE ←←←← valB + valC Compute effective address

valE ←←←← valB OP valA Perform ALU operation

OPl rA, rB Execute rmmovl rA, D(rB)

popl rA

jXX Dest

call Dest

ret

Execute

Execute

Execute

Execute

Execute valE ←←←← valB + 4 Increment stack pointer **int aluA = [ icode in { IRRMOVL, IOPL } : valA; icode in { IIRMOVL, IRMMOVL, IMRMOVL } : valC; icode in { ICALL, IPUSHL } : -4; icode in { IRET, IPOPL } : 4;

Other instructions don't need ALU

];**

34

ALU Operation

valE ←←←← valB + –4 Decrement stack pointer

No operation

valE ←←←← valB + 4 Increment stack pointer

valE ←←←← valB + valC Compute effective address

valE ←←←← valB OP valA Perform ALU operation

OPl rA, rB Execute

rmmovl rA, D(rB)

popl rA

jXX Dest

call Dest

ret

Execute

Execute

Execute

Execute

Execute valE ←←←← valB + 4 Increment stack pointer int alufun = [ icode == IOPL : ifun; 1 : ALUADD; ];

37

Memory Read

OPl rA, rB Memory rmmovl rA, D(rB)

popl rA

jXX Dest

call Dest

ret

No operation

Memory M 4 [valE] ←←←← valA Write value to memory

Memory valM ←←←← M 4 [valA] Read from stack

Memory M 4 [valE] ←←←← valP Write return value on stack

Memory valM ←←←← M 4 [valA] Read return address

Memory No operation

bool mem_read = icode in { IMRMOVL, IPOPL, IRET };

38

PC Update Logic

New PC

 Select next value of PC

New PC

icode Bch valC valM valP

PC

39

PC

Update

OPl rA, rB

rmmovl rA, D(rB)

popl rA

jXX Dest

call Dest

ret

PC update PC ←←←← valP Update PC

PC update PC ←←←← valP Update PC

PC update PC ←←←← valP Update PC

PC update PC ←←←← Bch? valC : valP Update PC

PC update PC ←←←← valC Set PC to destination

PC update PC ←←←← valM Set PC to return address int new_pc = [ icode == ICALL : valC; icode == IJXX && Bch : valC; icode == IRET : valM; 1 : valP; ];

40

SEQ Operation

State

 PC register

 Cond. Code register

 Data memory

 Register file

All updated as clock rises

Combinational Logic

 ALU

 Control logic

 Memory reads

 Instruction memory

 Register file

 Data memory

Combinational Logic (^) Data memory

Data memory

Register file

Register file

PC 0x00c

CC CC Read Ports Write Ports

ReadRead WriteWrite