Spring 2006 Lillevik 437s06- l8 1 University of Portland School of Engineering EE 437 Advanced Computer Architecture Lecture 8 Project 3: memory agent Programmed I/O Direct memory access
Spring 2006
Lillevik 437s06-l8 1University of Portland School of Engineering
EE 437
Advanced ComputerArchitecture
Lecture 8
Project 3: memory agent
Programmed I/O
Direct memory access
Spring 2006
Lillevik 437s06-l8 2University of Portland School of Engineering
EE 437
Project 3 system schematic
Spring 2006
Lillevik 437s06-l8 3University of Portland School of Engineering
EE 437
Project 3 requirements
• Goal: memory bus agent
• Requirements– ROM: 0x00 – 0x1f– RAM: 0x20 – 0xff
• Fully decode: address and control buses
• Assume one master• Must generate ACK (tri-state)
Spring 2006
Lillevik 437s06-l8 4University of Portland School of Engineering
EE 437
Project 3 traces
read ROM read ROM
Spring 2006
Lillevik 437s06-l8 5University of Portland School of Engineering
EE 437
Project 3 traces, continued.
write RAM write RAM
Spring 2006
Lillevik 437s06-l8 6University of Portland School of Engineering
EE 437
Project 3 traces, continued.
read RAM read RAM
Spring 2006
Lillevik 437s06-l8 7University of Portland School of Engineering
EE 437
I/O design
• Separate I/O address space– Instructions for I/O operations: in, out– Address often referred to as a Port
• One address space– Known as “memory-mapped I/O”– All memory reference instructions may operate
on I/O data
Spring 2006
Lillevik 437s06-l8 8University of Portland School of Engineering
EE 437
Memory mapped I/O example
• I/O device: USART
• Receiver– Control register: 0xffff 0000– Data register: 0xffff 0004
• Transmitter– Control register: 0xffff 0008– Data register: 0xffff 000c
Spring 2006
Lillevik 437s06-l8 9University of Portland School of Engineering
EE 437
C8251 block diagram
Spring 2006
Lillevik 437s06-l8 10University of Portland School of Engineering
EE 437
Assembly code
Definitions for memory-mapped devices
Spring 2006
Lillevik 437s06-l8 11University of Portland School of Engineering
EE 437
Assembly code, continued.
Subroutines to read and write a byte
Spring 2006
Lillevik 437s06-l8 12University of Portland School of Engineering
EE 437
Find flowchart for rcvbyte?
Spring 2006
Lillevik 437s06-l8 13University of Portland School of Engineering
EE 437
Wait loop
• Programming technique– CPU continuously reads control register until
non-zero (ready bit set)– CPU reads/writes data to port
• Results in poor system utilization: both memory-mapped or separate I/O addresses
• Known as programmed I/O
Spring 2006
Lillevik 437s06-l8 14University of Portland School of Engineering
EE 437
Disadvantages of programmed I/O?
1. Wasted cycles CPU
2. Not writing to bus if reading it
3. No work done on bus
4.
Spring 2006
Lillevik 437s06-l8 15University of Portland School of Engineering
EE 437
Direct memory access
• Objective: avoid the disadvantages of programmed I/O (eliminate the busy loop)
• Technique– CPU writes to special controller (word count
and memory address)– CPU tells controller to start data transfers– CPU continues with other computing– CPU responds to interrupt from controller: ISR
Spring 2006
Lillevik 437s06-l8 16University of Portland School of Engineering
EE 437
Role of DMA controller
• Accept initialization data from CPU
• Access I/O device and drive bus (master)– Input: read I/O device and write data to
memory– Output: read memory data and write to I/O
device
• Interrupt CPU when transfer complete
Spring 2006
Lillevik 437s06-l8 17University of Portland School of Engineering
EE 437
Programmed I/O
Programmed I/O ties up CPU
Read I/O
Write memory
Spring 2006
Lillevik 437s06-l8 18University of Portland School of Engineering
EE 437
DMA I/O
DMA requires little CPU overhead
Initialize
Multiple
transfers
Spring 2006
Lillevik 437s06-l8 19University of Portland School of Engineering
EE 437
DMA time line
ISR ISR
Interrupt Interrupt
CPU and I/O concurrent in time
Spring 2006
Lillevik 437s06-l8 20University of Portland School of Engineering
EE 437
DMA hardware view
n words n words
adr X
adr X+(n-1)
Memory
I/O device
buffer
System bus adr 0
adr n-1
Spring 2006
Lillevik 437s06-l8 21University of Portland School of Engineering
EE 437
DMA initialization instructions?
1. Memory/destination address
2. How long, or how many
3. Tell it to start
Spring 2006
Lillevik 437s06-l8 22University of Portland School of Engineering
EE 437
DMA controller architecture
Counts up from zero
Counts down to zero Preset counter
Word
Count
Data
Buffer
Memory
Address
Buffer
Address
Control
D
A
C
Xcvr
Xcvr
Xcvr
Spring 2006
Lillevik 437s06-l8 23University of Portland School of Engineering
EE 437
Spring 2006
Lillevik 437s06-l8 24University of Portland School of Engineering
EE 437
Find flowchart for rcvbyte?Push $ra
Get rcv status
Char ready?
Read and echo char
Pop $ra
yes
no
Spring 2006
Lillevik 437s06-l8 25University of Portland School of Engineering
EE 437
Disadvantages of programmed I/O?
1. CPU cycles result in little computing
2. Memory continuously accessed, possible contention with another CPU
3. One I/O access at a time
4. Bus heavily requested
Spring 2006
Lillevik 437s06-l8 26University of Portland School of Engineering
EE 437
DMA initialization instructions?
1. Write start address
2. Write word count (or end address)
3. Write “go” command
Each write is to a specific DMA controller port address