computer organization lecture 21

31
Fall 2006 Lillevik 333f06- l21 1 University of Portland School of Engineering EE 333 Computer Organization Lecture 21 Subroutines, stack Interrupts, service routines Input and output, buses

Upload: shalom

Post on 12-Jan-2016

69 views

Category:

Documents


0 download

DESCRIPTION

Computer Organization Lecture 21. Subroutines, stack Interrupts, service routines Input and output, buses. Instruction flow. Most of the time: program executes sequentially unless a branch or jump requested Sometimes Programmer wishes to execute a subroutine, function, or method - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: Computer Organization Lecture 21

Fall 2006

Lillevik 333f06-l21 1University of Portland School of Engineering

EE 333

Computer OrganizationLecture 21

Subroutines, stackInterrupts, service routines

Input and output, buses

Page 2: Computer Organization Lecture 21

Fall 2006

Lillevik 333f06-l21 2University of Portland School of Engineering

EE 333

Instruction flow

• Most of the time: program executes sequentially unless a branch or jump requested

• Sometimes– Programmer wishes to execute a subroutine,

function, or method– An unusual event occurs internally or

externally and the program needs to respond to it

Page 3: Computer Organization Lecture 21

Fall 2006

Lillevik 333f06-l21 3University of Portland School of Engineering

EE 333

Subroutine flow control

1. Program prior to sub call2. Caller transfers control to Callee3. Callee transfers control to Caller4. Program after sub call

Caller Callee

12

34

May be nested

Page 4: Computer Organization Lecture 21

Fall 2006

Lillevik 333f06-l21 4University of Portland School of Engineering

EE 333

Hardware for subroutines

• Goal– Jump to some memory location– Return back to next instruction after jump (PC-

next)

• Requirements– Save the value of the PC-next– Modify the PC, do the jump– Restore the value of PC to PC-next

Page 5: Computer Organization Lecture 21

Fall 2006

Lillevik 333f06-l21 5University of Portland School of Engineering

EE 333

MIPS subroutines

• Jump-and-link: jal– Saves PC-next in $ra– Jumps to subroutine address

• Jump register: jr– Jumps to address in register– jr $ra will perform return

• Use these to access subroutines

Page 6: Computer Organization Lecture 21

Fall 2006

Lillevik 333f06-l21 6University of Portland School of Engineering

EE 333

Subroutine programming

CallCall-next

subreturn

CallCall-next

PC = Call

$ra = xx

PC = sub

$ra = Call-next

PC = Call-next

$ra = Call-next

jal sub

jr $ra

memory memory memory

Page 7: Computer Organization Lecture 21

Fall 2006

Lillevik 333f06-l21 7University of Portland School of Engineering

EE 333

How do we nest subroutines?

Page 8: Computer Organization Lecture 21

Fall 2006

Lillevik 333f06-l21 8University of Portland School of Engineering

EE 333

Stack memory usage

Push onto stack Pop from stack

$sp points to top of stack

Page 9: Computer Organization Lecture 21

Fall 2006

Lillevik 333f06-l21 9University of Portland School of Engineering

EE 333

Stack operations

• Pushsub $sp, $sp, 4 # push $ra on stack

sw $ra, ($sp)

• Poplw $ra, ($sp) # pop $ra from stack

add $sp, $sp, 4

Same operations to save registers

Page 10: Computer Organization Lecture 21

Fall 2006

Lillevik 333f06-l21 10University of Portland School of Engineering

EE 333

Unusual events

• Three types: all require immediate action

– Internal to computer• Hardware generated

• Software generated (OS requests)

– External to computer: only hardware generated

• Notation– MIPS: exception = internal, interrupt = external

– Common: everything is an interrupt

Page 11: Computer Organization Lecture 21

Fall 2006

Lillevik 333f06-l21 11University of Portland School of Engineering

EE 333

Identify possible events?

Page 12: Computer Organization Lecture 21

Fall 2006

Lillevik 333f06-l21 12University of Portland School of Engineering

EE 333

Hardware for interrupts

• Enable/disable: turns interrupts on and off

• Controller changes and response– Finish instructions (flush pipeline)– Disable interrupts– Record type of event (Cause register)– Save return address (EPC register)– Branch (vector) to specific address (0x8000 0180)

• Mechanism nearly identical to jal

Page 13: Computer Organization Lecture 21

Fall 2006

Lillevik 333f06-l21 13University of Portland School of Engineering

EE 333

MIPS controller state diagram• Two sources: bad

opcode, overflow

• Cause register written

• EPC written

• PC written

Page 14: Computer Organization Lecture 21

Fall 2006

Lillevik 333f06-l21 14University of Portland School of Engineering

EE 333

Interrupt request map

Page 15: Computer Organization Lecture 21

Fall 2006

Lillevik 333f06-l21 15University of Portland School of Engineering

EE 333

Interrupt service routine

• Save any registers used: save state on stack

• Perform required action• Restore registers used: restore state from stack

• Enable interrupts– May be done after registers saved– Provides for nested interrupts

• Return

Page 16: Computer Organization Lecture 21

Fall 2006

Lillevik 333f06-l21 16University of Portland School of Engineering

EE 333

Major computer components

Five classic computer components

Page 17: Computer Organization Lecture 21

Fall 2006

Lillevik 333f06-l21 17University of Portland School of Engineering

EE 333

Computer components

• Input: receives information from external world

• Output: transmits information to external world

• Memory: holds programs and data

• Data path: physical route that carries info

• Control: coordinates overall flow of info

Page 18: Computer Organization Lecture 21

Fall 2006

Lillevik 333f06-l21 18University of Portland School of Engineering

EE 333

System bus

Bus interconnects system agents

Page 19: Computer Organization Lecture 21

Fall 2006

Lillevik 333f06-l21 19University of Portland School of Engineering

EE 333

MDP16 busesAdr, Data,

Control

Page 20: Computer Organization Lecture 21

Fall 2006

Lillevik 333f06-l21 20University of Portland School of Engineering

EE 333

Early PC busesHigh speed

Med speed

Slow speed

CPU’s

8080 – 80486

vintage

Page 21: Computer Organization Lecture 21

Fall 2006

Lillevik 333f06-l21 21University of Portland School of Engineering

EE 333

Pentium 4 buses

82850

82801

300/400 MHzRDRAM DIMMS

6 Slots

100 Mbit

North bridge

South bridge

Page 22: Computer Organization Lecture 21

Fall 2006

Lillevik 333f06-l21 22University of Portland School of Engineering

EE 333

System view of a computer

One Agent at-a-time owns the bus

···

Signal 0

Signal n

Agent 0 Agent n···

BusSignal 1

Page 23: Computer Organization Lecture 21

Fall 2006

Lillevik 333f06-l21 23University of Portland School of Engineering

EE 333

Example buses?

Page 24: Computer Organization Lecture 21

Fall 2006

Lillevik 333f06-l21 24University of Portland School of Engineering

EE 333

Bus properties

• Agents– Master: owns bus, issues requests– Slave: responds to requests from a master

• Interconnections– Parallel, serial– Point-to-point, distributed– Single- and multi-master

Page 25: Computer Organization Lecture 21

Fall 2006

Lillevik 333f06-l21 25University of Portland School of Engineering

EE 333

Bus properties, continued.

• Electrical– Clocking: synchronous, asynchronous– Logic families: setup, hold, propagation– Physical: impedance, length, speed

• Performance– Bandwidth or data rate, B/s– Turn-around time to change masters, t

Page 26: Computer Organization Lecture 21

Fall 2006

Lillevik 333f06-l21 26University of Portland School of Engineering

EE 333

Find B/W of MDP16 memory?

CLK = 200 ns, Width = 16-bits

Page 27: Computer Organization Lecture 21

Fall 2006

Lillevik 333f06-l21 27University of Portland School of Engineering

EE 333

Page 28: Computer Organization Lecture 21

Fall 2006

Lillevik 333f06-l21 28University of Portland School of Engineering

EE 333

How do we nest subroutines?

• Use stack pointer register ($sp)

• Push $ra onto stack upon subroutine entry

• Execute body of subroutine, may call other subroutines

• Pop $ra from stack just before subroutine exit

• Return from subroutine

Page 29: Computer Organization Lecture 21

Fall 2006

Lillevik 333f06-l21 29University of Portland School of Engineering

EE 333

Identify possible events?

• Overflow, underflow, divide-by-zero, parity or CRC error, illegal instruction

• Memory or file protection (write to read-only, page fault)

• Real time clock, OS request

• Disk drive, CD, E-net: data transfer ready, or complete

Page 30: Computer Organization Lecture 21

Fall 2006

Lillevik 333f06-l21 30University of Portland School of Engineering

EE 333

Example buses?

• Uart

• I/O

• Address

• PCI

• ISA

• S-ATA

• USB

http://en.wikipedia.org/wiki/Computer_bus

Page 31: Computer Organization Lecture 21

Fall 2006

Lillevik 333f06-l21 31University of Portland School of Engineering

EE 333

Find B/W of MDP16 memory?

CLK = 200 ns, Width = 16-bits

snsclkTlw

0.120055

sMBs

bytes

s

bitsBW 0.2

10

2

0.1

166