Vahid, Givargis Vahid, Givargis
Interfacing
Interfacing
Introduction
Introduction
Addressing
Addressing
Interrupt
Interrupt
DMA
DMA
Arbitration
Arbitration
Advanced communication architectures
Advanced communication architectures
Introduction
Introduction
Embedded system functionality aspects
Processing
Transformation of data
Implemented using processors
Storage
Retention of data
Implemented using memory
Communication
Transfer of data between processors and memories
Implemented using buses
Vahid, Givargis
Vahid, Givargis --33-
-A simple bus
A simple bus
Wires:
Uni-directional or bi-directional
One line may represent multiple wires
Bus
Sets of wires with a single function
Address bus, data bus, control bus
Single set of wires collecting all functions
cpu
rd'/wrmemory
enable
addr[0:15]
data[0:7]
Vahid, Givargis
Vahid, Givargis --44-
-Timing Diagrams
Timing Diagrams
Common method for describing a protocol
Time proceeds to the right on the x axis
Control signal:
Active high: wr
Asserted when 1
Active low: wr
Asserted when 0
Data signal:
Valid:
Data on the bus can be read/written
Not valid
Vahid, Givargis
Vahid, Givargis --55-
-Timing Diagrams
Timing Diagrams
Protocol:
Defines how communication takes place
May have subprotocols
Bus cycles
Each bus cycle may be several clock cycles
Timing Diagrams: Read example
Timing Diagrams: Read example
rd'/wr
enable
addr
data
Tsetup Tread
rd'asserted
starts read bus cycle address placed onaddr
address must be stable at least Tsetupbefore enableasserted enableasserted
Triggers memory to place data on datawires Not later than after the time delay Tread
data ready on datawires
1
1
2
3
4
2
3
Vahid, Givargis
Vahid, Givargis --77-
-Timing Diagrams: Write example
Timing Diagrams: Write example
rd'/wr
enable
addr
data
Tsetup Twrite
wrasserted
starts write bus cycle address placed onaddr
address must be stable at least Tsetupbefore enableasserted
data placed on datawires
data must be stable at leastTsetupbefore enableasserted enableasserted
triggers memory save data found on datawires must remain asserted for at least Twrite
1
1
2
3
4
2
3
4
Vahid, Givargis
Vahid, Givargis --88-
-Basic protocol concepts
Basic protocol concepts
Actor
Master: initiates the communication
Slave: responds to master
Direction
Sender: Data source
Receiver: Data destination
Time multiplexing
Share a single set of wires for multiple pieces of data
Subsequent bytes of a word
Data/Address
Vahid, Givargis
Vahid, Givargis --99-
-Time multiplexing
Time multiplexing
master
reqslave
d[0:7]
mux data[0:15]
demux data[0:15]
master
reqslave
d[0:15]
mux data
demux
addr data addr
req
d
req
d
data[8:15] data[0:7] addr[0:15] data[0:15]
Strobe protocol
Strobe protocol
master
reqslave
d[0:7]
req
data
1 2 3 4
Master asserts reqto receive data
Slave puts data on bus Within Ta
Master receives data Master deasserts req
Slave ready for next request
1
2
2 3
3
4
Vahid, Givargis
Vahid, Givargis --1111-
-Handshake protocol
Handshake protocol
master
reqslave
d[0:7]
req
ack
1 2 3 4
Master asserts reqto receive data
Slave puts data on bus
Slave asserts ack
Master receives data
Master deasserts req
Slave deasserts ack
Slave ready for next request
1
2
3
4
4
ack
data
5
3
5
Vahid, Givargis
Vahid, Givargis --1212-
-Strobe/handshake protocol: Fast
Strobe/handshake protocol: Fast
master
reqslave
d[0:7]
req
wait
1 2 3
wait
data
4
Master asserts reqto receive data
Slave puts data on bus Within Ta
The waitline is unused
Master receives data Master deasserts req
Slave ready for next request
1
2
2 3
3
4
Vahid, Givargis
Vahid, Givargis --1313-
-Strobe/handshake protocol: Slow
Strobe/handshake protocol: Slow
master
reqslave
d[0:7] wait
Master asserts reqto receive data
Slave can't put data on bus within Ta
Slave asserts wait
Slave puts data on bus
Slave deassertswait
Master receives data Master deasserts req
Slave ready for next request
1
2
4
5
5
req
wait
1 2 4
data
6
Ta
3 5
3
4
6
I/O Addressing
I/O Addressing
CPU communicates using some of its pins
Port-based I/O or parallel I/O
CPU has one or more n-bit ports
Software reads and writes a port just like a register
Bus-based I/O
CPU has address, data and control ports
cpu
port 0port 1
port k
bus
Vahid, Givargis
Vahid, Givargis --1515-
-I/O Addressing
I/O Addressing
Parallel I/O peripheral (PIO)
Processor only supports bus-based I/O
… But parallel I/O needed
Ports are managed by a dedicated peripheral
cpu
port 0port 1
port k
bus
memory
PIO
Vahid, Givargis
Vahid, Givargis --1616-
-I/O Addressing
I/O Addressing
Extended parallel I/O
Processor supports port-based I/O
… But more ports needed
One or more PIO extending total number of ports
cpu
port 0port 1
port k
bus
memory
PIO
port k+1 port k+2Vahid, Givargis
Vahid, Givargis --1717-
-Memory mapped and Standard I/O
Memory mapped and Standard I/O
Processor uses the same bus to talk to
Memory
Peripherals
There are two main ways to communicate
Memory-mapped I/O
Standard I/O
Memory mapped I/O
Memory mapped I/O
Peripheral registers occupy addresses in same
address space as memory
E.g. Bus has 16-bit address
Lower 32K map to memory
Upper 32k map to peripherals
Requires no special instructions
Assembly instructions involving memory work with
peripherals as well
E.g.
MOV
,
LOAD
,
STORE
,
ADD
, …
Standard I/O requires special instructions to move
data between peripheral registers and memory
Vahid, Givargis
Vahid, Givargis --1919-
-Standard I/O
Standard I/O
No loss of memory addresses to peripherals
E.g. Bus has 16-bit address
All 64K map to memory when
M/IO
set to 0
all 64K map to peripherals when
M/IO
set to 1
Simpler address decoding logic in peripherals
When the number of peripherals much smaller than
address space, high-order address bits are ignored
Smaller and/or faster comparators
Additional pin on bus indicates whether a memory or
peripheral access
M/IO
Vahid, Givargis
Vahid, Givargis --2020-
-Interrupts
Interrupts
Suppose a peripheral intermittently receives data,
which must be serviced by the processor
Processor can poll the peripheral regularly
To see if data has arrived
Wastes a lot of time
Peripheral can interrupt the processor when ready
Requires one or more extra pin or pins
Interrupt pins: INT0, INT1, …
If INT is 1
Processor suspends current program
Vahid, Givargis
Vahid, Givargis --2121-
-Interrupts
Interrupts
Different interrupt signals (INT0, INT1, …) have
different service routines (ISR0, ISR1, …)
What is the address of the correct ISR?
Fixed interrupt
Address built into microprocessor, cannot be changed
Either ISR or jump to actual ISR stored at address
Vectored interrupt
Peripheral must provide the address
Common when microprocessor has multiple peripherals
connected by a system bus
Compromise: interrupt address table
Fixed ISR location
Fixed ISR location
[1A]CPU is executing its main program [1B]P1 receives input data in a register with address 0x8000
[2] P1 asserts INT to request servicing by the microprocessor
[3] After completing instruction at 100, CPU sees INT asserted, saves the PC’s value of 100, and sets PC to the ISR fixed location of 16
[4A]The ISR reads data from 0x8000, modifies the data, and writes the resulting data to 0x8001
[5] The ISR returns, thus restoring PC to 100+1=101, where CPU resumes executing
Vahid, Givargis
Vahid, Givargis --2323-
-Fixed ISR location
Fixed ISR location
Program memory
ISR:
16: MOV R0, 0x8000 17: INCR R0 18: MOV 0x8001, R0 19: RETI
… MAIN:
…
100: # instruction 101: # instruction 102: # instruction
CPU
PC=100
LR=---P1: 0x8000 P2: 0x8001
1612 INT
Data Memory
[1A]CPU is executing its main program [1B]P1 receives input data in a register with address 0x8000
R0=---Vahid, Givargis
Vahid, Givargis --2424-
-Fixed ISR location
Fixed ISR location
Program memory
ISR:
16: MOV R0, 0x8000 17: INCR R0 18: MOV 0x8001, R0 19: RETI
… MAIN:
…
100: # instruction 101: # instruction 102: # instruction
CPU
PC=100
LR=---P1: 0x8000 P2: 0x8001
1612 INT
Data Memory
[2] P1 asserts INT to request servicing by the microprocessor
R0=---Vahid, Givargis
Vahid, Givargis --2525-
-Fixed ISR location
Fixed ISR location
Program memory
ISR:
16: MOV R0, 0x8000 17: INCR R0 18: MOV 0x8001, R0 19: RETI
… MAIN:
…
100: # instruction 101: # instruction 102: # instruction
CPU
PC=100 LR=100
P1: 0x8000 P2: 0x8001
1612 INT
Data Memory
[3] After completing instruction at 100, CPU sees INT asserted, saves the PC’s value of 100, and sets PC to the ISR fixed location of 16
R0=---Fixed ISR location
Fixed ISR location
Program memory
ISR:
16: MOV R0, 0x8000 17: INCR R0 18: MOV 0x8001, R0 19: RETI
… MAIN:
…
100: # instruction 101: # instruction 102: # instruction
CPU
PC=16 LR=100
P1: 0x8000 P2: 0x8001
1612 INT
Data Memory
[3] After completing instruction at 100, CPU sees INT asserted, saves the PC’s value of 100, and sets PC to the ISR fixed location of 16
R0=---Vahid, Givargis
Vahid, Givargis --2727-
-Fixed ISR location
Fixed ISR location
Program memory
ISR:
16: MOV R0, 0x8000 17: INCR R0 18: MOV 0x8001, R0 19: RETI
… MAIN:
…
100: # instruction 101: # instruction 102: # instruction
CPU
PC=16 LR=100
P1: 0x8000 P2: 0x8001
1612 INT
Data Memory
[4A]The ISR reads data from 0x8000, modifies the data, and writes the resulting data to 0x800
R0=1612
[4B]After being read, P1 de-asserts INT
Vahid, Givargis
Vahid, Givargis --2828-
-Fixed ISR location
Fixed ISR location
Program memory
ISR:
16: MOV R0, 0x8000 17: INCR R0 18: MOV 0x8001, R0 19: RETI
… MAIN:
…
100: # instruction 101: # instruction 102: # instruction
CPU
PC=17 LR=100
P1: 0x8000 P2: 0x8001
1612 INT
Data Memory
[4A]The ISR reads data from 0x8000, modifies the data, and writes the resulting data to 0x8001
Vahid, Givargis
Vahid, Givargis --2929-
-Fixed ISR location
Fixed ISR location
Program memory
ISR:
16: MOV R0, 0x8000 17: INCR R0 18: MOV 0x8001, R0 19: RETI
… MAIN:
…
100: # instruction 101: # instruction 102: # instruction
CPU
PC=18 LR=100
P1: 0x8000 P2: 0x8001
1612 1613
INT
Data Memory
[4A]The ISR reads data from 0x8000, modifies the data, and writes the resulting data to 0x8001
R0=1613
Fixed ISR location
Fixed ISR location
Program memory
ISR:
16: MOV R0, 0x8000 17: INCR R0 18: MOV 0x8001, R0 19: RETI
… MAIN:
…
100: # instruction 101: # instruction 102: # instruction
CPU
PC=101 LR=100
P1: 0x8000 P2: 0x8001
1612 1613
INT
Data Memory
R0=1613
Vahid, Givargis
Vahid, Givargis --3131-
-Fixed ISR location
Fixed ISR location
Program memory
ISR:
16: MOV R0, 0x8000 17: INCR R0 18: MOV 0x8001, R0 19: RETI
… MAIN:
…
100: # instruction 101: # instruction 102: # instruction
CPU
PC=101 LR=100
P1: 0x8000 P2: 0x8001
1612 1613
INT
Data Memory
R0=1613
[5] The ISR returns, thus restoring PC to 100+1=101, where CPU resumes executing
Vahid, Givargis
Vahid, Givargis --3232-
-Vectored interrupt
Vectored interrupt
[1A]CPU is executing its main program [1B]P1 receives input data in a register with address 0x8000
[2] P1 asserts INT to request servicing by the microprocessor
[3] After completing instruction at 100, CPU sees INT asserted, saves the PC’s value of 100, and asserts INTA
[5A]CPU jumps to the address on the bus (16). The ISR reads data from 0x8000, modifies the data, and writes the resulting data to 0x8001
[6] The ISR returns, thus restoring PC to 100+1=101, deassrts INTA and CPU resumes executing
[4] P1 detects INTA and puts interrupt address vector 16 on the data bus
Vahid, Givargis
Vahid, Givargis --3333-
-Vectored interrupt
Vectored interrupt
Program memory
ISR:
16: MOV R0, 0x8000 17: INCR R0 18: MOV 0x8001, R0 19: RETI
… MAIN:
…
100: # instruction 101: # instruction 102: # instruction
CPU
PC=100
LR=---P1: 0x8000 P2: 0x8001
1612 INT
Data Memory
[1A]CPU is executing its main program [1B]P1 receives input data in a register with address 0x8000
R0=---INTA
16
---Vectored interrupt
Vectored interrupt
Program memory
ISR:
16: MOV R0, 0x8000 17: INCR R0 18: MOV 0x8001, R0 19: RETI
… MAIN:
…
100: # instruction 101: # instruction 102: # instruction
CPU
PC=100
LR=---P1: 0x8000 P2: 0x8001
1612 INT
Data Memory
[2] P1 asserts INT to request servicing by the microprocessor
R0=---INTA
---Vahid, Givargis
Vahid, Givargis --3535-
-Vectored interrupt
Vectored interrupt
Program memory
ISR:
16: MOV R0, 0x8000 17: INCR R0 18: MOV 0x8001, R0 19: RETI
… MAIN:
…
100: # instruction 101: # instruction 102: # instruction
CPU
PC=100 LR=100
P1: 0x8000 P2: 0x8001
1612 INT
Data Memory
[3] After completing instruction at 100, CPU sees INT asserted, saves the PC’s value of 100, and asserts INTA
R0=---INTA
16
---Vahid, Givargis
Vahid, Givargis --3636-
-Vectored interrupt
Vectored interrupt
Program memory
ISR:
16: MOV R0, 0x8000 17: INCR R0 18: MOV 0x8001, R0 19: RETI
… MAIN:
…
100: # instruction 101: # instruction 102: # instruction
CPU
PC=100 LR=100
P1: 0x8000 P2: 0x8001
1612 INT
Data Memory
R0=---INTA
16
[4] P1 detects INTA and puts interrupt address vector 16 on the data bus
Vahid, Givargis
Vahid, Givargis --3737-
-Vectored interrupt
Vectored interrupt
Program memory
ISR:
16: MOV R0, 0x8000 17: INCR R0 18: MOV 0x8001, R0 19: RETI
… MAIN:
…
100: # instruction 101: # instruction 102: # instruction
CPU
PC=16 LR=100
P1: 0x8000 P2: 0x8001
1612 INT
Data Memory
R0=---INTA
16
[5A]CPU jumps to the address on the bus (16). The ISR reads data from 0x8000, modifies the data, and writes the resulting data to 0x8001
16
Vectored interrupt
Vectored interrupt
Program memory
ISR:
16: MOV R0, 0x8000 17: INCR R0 18: MOV 0x8001, R0 19: RETI
… MAIN:
…
100: # instruction 101: # instruction 102: # instruction
CPU
PC=16 LR=100
P1: 0x8000 P2: 0x8001
1612 INT
Data Memory
R0=1612 INTA
16
[5A]CPU jumps to the address on the bus (16). The ISR reads data from 0x8000, modifies the data, and writes the resulting data to 0x8001
Vahid, Givargis
Vahid, Givargis --3939-
-Vectored interrupt
Vectored interrupt
Program memory
ISR:
16: MOV R0, 0x8000 17: INCR R0 18: MOV 0x8001, R0 19: RETI
… MAIN:
…
100: # instruction 101: # instruction 102: # instruction
CPU
PC=17 LR=100
P1: 0x8000 P2: 0x8001
1612 INT
Data Memory
R0=1613 INTA
16 16
[5A]CPU jumps to the address on the bus (16). The ISR reads data from 0x8000, modifies the data, and writes the resulting data to 0x8001
Vahid, Givargis
Vahid, Givargis --4040-
-Vectored interrupt
Vectored interrupt
Program memory
ISR:
16: MOV R0, 0x8000 17: INCR R0 18: MOV 0x8001, R0 19: RETI
… MAIN:
…
100: # instruction 101: # instruction 102: # instruction
CPU
PC=18 LR=100
P1: 0x8000 P2: 0x8001
1612 1613
INT
Data Memory
R0=1613 INTA
16
[5A]CPU jumps to the address on the bus (16). The ISR reads data from 0x8000, modifies the data, and writes the resulting data to 0x8001
Vahid, Givargis
Vahid, Givargis --4141-
-Vectored interrupt
Vectored interrupt
Program memory
ISR:
16: MOV R0, 0x8000 17: INCR R0 18: MOV 0x8001, R0 19: RETI
… MAIN:
…
100: # instruction 101: # instruction 102: # instruction
CPU
PC=18 LR=100
P1: 0x8000 P2: 0x8001
1612 1613
INT
Data Memory
R0=1613 INTA
16
[5B]After being read, P1 de-asserts INT
16
Vectored interrupt
Vectored interrupt
Program memory
ISR:
16: MOV R0, 0x8000 17: INCR R0 18: MOV 0x8001, R0 19: RETI
… MAIN:
…
100: # instruction 101: # instruction 102: # instruction
CPU
PC=101 LR=100
P1: 0x8000 P2: 0x8001
1612 1613
INT
Data Memory
R0=1613
[6] The ISR returns, thus restoring PC to 100+1=101, deassrts INTA and CPU resumes executing
INTA
Vahid, Givargis
Vahid, Givargis --4343-
-Vectored interrupt
Vectored interrupt
Program memory
ISR:
16: MOV R0, 0x8000 17: INCR R0 18: MOV 0x8001, R0 19: RETI
… MAIN:
…
100: # instruction 101: # instruction 102: # instruction
CPU
PC=101 LR=100
P1: 0x8000 P2: 0x8001
1612 1613
INT
Data Memory
R0=1613 INTA
16 16
[6] The ISR returns, thus restoring PC to 100+1=101, deassrts INTA and CPU resumes executing
Vahid, Givargis
Vahid, Givargis --4444-
-Interrupt address table
Interrupt address table
Compromise between fixed and vectored interrupts
One interrupt pin
Table in memory holding ISR addresses
Maybe 256 words
Peripheral doesn’t provide ISR address
… But rather index into table
Fewer bits are sent by the peripheral
Vahid, Givargis
Vahid, Givargis --4545-
-Additional interrupt issues
Additional interrupt issues
Maskable (MI) vs. Non-Maskable (NMI) interrupts
Maskable
Programmer can set bit that causes processor to
ignore interrupt
Important when in the middle of time-critical code
Non-maskable
A separate interrupt pin that can’t be masked
Typically reserved for drastic situations, like power
failure requiring immediate backup of data to
non-volatile memory
Additional interrupt issues
Additional interrupt issues
Jump to ISR
Some microprocessors treat jump same as call
of any subroutine
Complete state saved (PC, registers)
May take hundreds of cycles
Others only save partial state
PC only
ISR must not modify registers
Or else must save them first
Vahid, Givargis
Vahid, Givargis --4747-
-Direct memory access
Direct memory access
Buffering
Temporarily storing data in memory before processing
Data accumulated in peripherals commonly buffered
Microprocessor could handle this with ISR
Storing and restoring microprocessor state inefficient
Regular program must wait
DMA (Direct Memory Access) controller is more
efficient
Vahid, Givargis
Vahid, Givargis --4848-
-Direct memory access
Direct memory access
Separate single-purpose processor
CPU leaves control of system bus to DMA controller
CPU can meanwhile execute its regular program
No inefficient storing and restoring state due to
interrupt service routine call
Regular program need not wait unless it requires the
system bus
For Harvard archictectures
Processor can fetch and execute instructions as long as
they don’t access data memory
Vahid, Givargis
Vahid, Givargis --4949-
-Peripheral to memory transfer
Peripheral to memory transfer
with vectored interrupt
with vectored interrupt
[1A]CPU is executing its main program [1B]P1 receives input data in a register with address 0x8000
[2] P1 asserts INT to request servicing by the microprocessor
[3] After completing instruction at 100, CPU sees INT asserted, saves the PC’s value of 100, and asserts INTA
[5A]CPU jumps to the address on the bus (16). The ISR reads data from 0x8000 and writes it to 0x0001
[6] The ISR returns, thus restoring PC to 100+1=101, deassrts INTA and CPU resumes executing
[4] P1 detects INTA and puts interrupt address vector 16 on the data bus
[5B]After being read, P1 de-asserts INT
Peripheral to memory transfer
Peripheral to memory transfer
with vectored interrupt
with vectored interrupt
Program memory
ISR:
16: MOV R0, 0x8000 18: MOV 0x0001, R0 19: RETI
…
MAIN: …
100: # instruction 101: # instruction 102: # instruction
CPU
PC=100
LR=---P1: 0x8000 P2: 0x8001
1612 INT
Data Memory
[1A]CPU is executing its main program [1B]P1 receives input data in a register with address 0x8000
R0=---Vahid, Givargis
Vahid, Givargis --5151-
-Program memory
ISR:
16: MOV R0, 0x8000 18: MOV 0x0001, R0 19: RETI
…
MAIN: …
100: # instruction 101: # instruction 102: # instruction
Peripheral to memory transfer
Peripheral to memory transfer
with vectored interrupt
with vectored interrupt
CPU
PC=100
LR=---P1: 0x8000 P2: 0x8001
1612 INT
[2] P1 asserts INT to request servicing by the microprocessor
R0=---INTA
16
---Data Memory
---Vahid, Givargis
Vahid, Givargis --5252-
-Program memory
ISR:
16: MOV R0, 0x8000 18: MOV 0x0001, R0 19: RETI
…
MAIN: …
100: # instruction 101: # instruction 102: # instruction
Peripheral to memory transfer
Peripheral to memory transfer
with vectored interrupt
with vectored interrupt
CPU
PC=100 LR=100
P1: 0x8000 P2: 0x8001
1612 INT
[3] After completing instruction at 100, CPU sees INT asserted, saves the PC’s value of 100, and asserts INTA
R0=---INTA
16
---Vahid, Givargis
Vahid, Givargis --5353-
-Program memory
ISR:
16: MOV R0, 0x8000 18: MOV 0x0001, R0 19: RETI
…
MAIN: …
100: # instruction 101: # instruction 102: # instruction
Peripheral to memory transfer
Peripheral to memory transfer
with vectored interrupt
with vectored interrupt
CPU
PC=100 LR=100
P1: 0x8000 P2: 0x8001
1612 INT
R0=---INTA
16
[4] P1 detects INTA and puts interrupt address vector 16 on the data bus
16
Data Memory
---Program memory
ISR:
16: MOV R0, 0x8000 18: MOV 0x0001, R0 19: RETI
…
MAIN: …
100: # instruction 101: # instruction 102: # instruction
Peripheral to memory transfer
Peripheral to memory transfer
with vectored interrupt
with vectored interrupt
CPU
PC=16 LR=100
P1: 0x8000 P2: 0x8001
1612 INT
R0=---INTA
16
[5A]CPU jumps to the address on the bus (16). The ISR reads data from 0x8000 and writes it to 0x0001
16
---Vahid, Givargis
Vahid, Givargis --5555-
-Program memory
ISR:
16: MOV R0, 0x8000 18: MOV 0x0001, R0 19: RETI
…
MAIN: …
100: # instruction 101: # instruction 102: # instruction
Peripheral to memory transfer
Peripheral to memory transfer
with vectored interrupt
with vectored interrupt
CPU
PC=16 LR=100
P1: 0x8000 P2: 0x8001
1612 INT
R0=1612 INTA
16
[5A]CPU jumps to the address on the bus (16). The ISR reads data from 0x8000 and writes it to 0x0001
16
Data Memory
---Vahid, Givargis
Vahid, Givargis --5656-
-Program memory
ISR:
16: MOV R0, 0x8000 18: MOV 0x0001, R0 19: RETI
…
MAIN: …
100: # instruction 101: # instruction 102: # instruction
Peripheral to memory transfer
Peripheral to memory transfer
with vectored interrupt
with vectored interrupt
CPU
PC=17 LR=100
P1: 0x8000 P2: 0x8001
1612
[5A]CPU jumps to the address on the bus (16). The ISR reads data from 0x8000 and writes it to 0x0001
Data Memory 0x0000
1612
Vahid, Givargis
Vahid, Givargis --5757-
-Program memory
ISR:
16: MOV R0, 0x8000 18: MOV 0x0001, R0 19: RETI
…
MAIN: …
100: # instruction 101: # instruction 102: # instruction
Peripheral to memory transfer
Peripheral to memory transfer
with vectored interrupt
with vectored interrupt
CPU
PC=18 LR=100
P1: 0x8000 P2: 0x8001
1612 INT
R0=1612 INTA
16
[5B]After being read, P1 de-asserts INT
1612
Data Memory
---Program memory
ISR:
16: MOV R0, 0x8000 18: MOV 0x0001, R0 19: RETI
…
MAIN: …
100: # instruction 101: # instruction 102: # instruction
Peripheral to memory transfer
Peripheral to memory transfer
with vectored interrupt
with vectored interrupt
CPU
PC=101 LR=100
P1: 0x8000 P2: 0x8001
1612 INT
R0=1612
[6] The ISR returns, thus restoring PC to 100+1=101, deassrts INTA and CPU resumes executing
INTA
16 1612
---Vahid, Givargis
Vahid, Givargis --5959-
-Program memory
ISR:
16: MOV R0, 0x8000 18: MOV 0x0001, R0 19: RETI
…
MAIN: …
100: # instruction 101: # instruction 102: # instruction
Peripheral to memory transfer
Peripheral to memory transfer
with vectored interrupt
with vectored interrupt
CPU
PC=101 LR=100
P1: 0x8000 P2: 0x8001
1612
[6] The ISR returns, thus restoring PC to 100+1=101, deassrts INTA and CPU resumes executing
Data Memory
---Vahid, Givargis
Vahid, Givargis --6060-
-Peripheral to memory transfer
Peripheral to memory transfer
with DMA
with DMA
[1A]CPU is executing its main program. It has already configured the DMA ctrl registers
[1B] P1 receives input data in a register with address 0x8000.
[2] P1 asserts REQ to request servicing by DMA ctrl
[7B] P1 deasserts REQ [3] DMA ctrl asserts
DREQ to request control of system bus
[4] After executing instruction 100, the CPU sees DREQ asserted, releases the system bus, asserts DACK, and resumes execution. CPU stalls only if it needs the
system bus to continue executing [5] DMA ctrl asserts ACK, reads data from 0x8000 and writes it to 0x0001
[6] DMA deasserts DREQ and ACK completing handshake with P1
Vahid, Givargis
Vahid, Givargis --6161-
-Peripheral to memory transfer
Peripheral to memory transfer
with DMA
with DMA
Program memory
#
100: # instruction 101: # instruction 102: # instruction
CPU
PC=100
LR=---DMA ctrl P1: 0x8000
0x0001 1612
DREQ
Data Memory
[1A]CPU is executing its main program. It has already configured the DMA ctrl registers
[1B] P1 receives input data in a register with address 0x8000.
Peripheral to memory transfer
Peripheral to memory transfer
with DMA
with DMA
Program memory
#
100: # instruction 101: # instruction 102: # instruction
CPU
PC=100
LR=---DMA ctrl P1: 0x8000
0x0001 1612
DREQ
Data Memory
R0=---[2] P1 asserts REQ to request servicing by DMA ctrl
Vahid, Givargis
Vahid, Givargis --6363-
-Peripheral to memory transfer
Peripheral to memory transfer
with DMA
with DMA
Program memory
#
100: # instruction 101: # instruction 102: # instruction
CPU
PC=100
LR=---DMA ctrl P1: 0x8000
0x0001 1612
DREQ
Data Memory
R0=---[4] After executing instruction 100, the CPU sees DREQ asserted, releases the system bus, asserts DACK, and resumes execution. CPU stalls only if it needs the system bus to continue executing
Vahid, Givargis
Vahid, Givargis --6464-
-Peripheral to memory transfer
Peripheral to memory transfer
with DMA
with DMA
Program memory
#
100: # instruction 101: # instruction 102: # instruction
CPU
PC=101
LR=---DMA ctrl P1: 0x8000
0x0001 1612
DREQ
Data Memory
Vahid, Givargis
Vahid, Givargis --6565-
-Peripheral to memory transfer
Peripheral to memory transfer
with DMA
with DMA
Program memory
#
100: # instruction 101: # instruction 102: # instruction
CPU
PC=102
LR=---DMA ctrl P1: 0x8000
0x0001 1612
DREQ
Data Memory
R0=---[5] DMA ctrl asserts ACK, reads data from 0x8000 and writes it to 0x0001
[4] After executing instruction 100, the CPU sees DREQ asserted, releases the system bus, asserts DACK, and resumes execution. CPU stalls only if it needs the system bus to continue executing
Peripheral to memory transfer
Peripheral to memory transfer
with DMA
with DMA
Program memory
#
100: # instruction 101: # instruction 102: # instruction
CPU
PC=102
LR=---DMA ctrl P1: 0x8000
0x0001 1612
DREQ
Data Memory
Vahid, Givargis
Vahid, Givargis --6767-
-Peripheral to memory transfer
Peripheral to memory transfer
with DMA
with DMA
Program memory
#
# No ISR needed!! #
…
MAIN: …
100: # instruction 101: # instruction 102: # instruction
CPU
PC=102
LR=---DMA ctrl P1: 0x8000
0x0001 1612
DREQ
Data Memory
R0=---DACK
0x8000
---0x0000
1612 0x0001
---0x7FFF
REQ ACK
[7B] P1 deasserts REQ
[7A]CPU deasserts DACK and resumes control of the bus
Vahid, Givargis
Vahid, Givargis --6868-
-Arbitration
Arbitration
Multiple peripherals may request services from
single resource simultaneously
Microprocessor, DMA controller, …
Who is served first?
Need an arbiter mechanism
Different approaches
Vahid, Givargis
Vahid, Givargis --6969-
-Arbitration using a priority arbiter
Arbitration using a priority arbiter
Single-purpose processor
Peripherals make requests to arbiter
Arbiter makes requests to resource
Arbiter is connected to system bus
For configuration purposes only
CPU
INT
INTA Priority Arbiter
IACK1 IREQ1
IACKn IREQn
P1 Pn
Arbitration using a priority arbiter
Arbitration using a priority arbiter
1. Microprocessor is executing its program
2. Peripheral P1 needs servicing so asserts IREQ1; peripheral Pn also needs servicing so asserts IREQn 3. Priority arbiter sees at least one IREQ input asserted, so asserts INT
4. Microprocessor stops executing its program and stores its state 5. Microprocessor asserts INTA
6. Priority arbiter asserts IACK1 to acknowledge peripheral P1 7. Peripheral P1 puts its interrupt address vector on the system bus
8. Microprocessor jumps to the address of ISR read from data bus, ISR executes and returns and completes handshake with arbiter
9. Microprocessor resumes executing its program
CPU
INT
INTA Priority Arbiter
IACK1 IREQ1
IACKn IREQn
P1 Pn
1
2
2 3
4 5
6
7
program ISR
Vahid, Givargis
Vahid, Givargis --7171-
-Arbitration using a priority arbiter
Arbitration using a priority arbiter
Different types of priority
Fixed priority
Each peripheral has unique rank
Highest rank is chosen first with simultaneous request
Preferred when there is a clear difference in rank
between peripherals
Rotating priority (round-robin)
Priority is changed based on history of servicing
Better distribution of servicing
Especially among peripherals with similar
priority demands
Vahid, Givargis
Vahid, Givargis --7272-
-Arbitration using daisy
Arbitration using daisy
-
-
chain
chain
Arbitration done by peripherals
Built into peripheral or external logic added
REQ input and ACK output added to each peripheral
Peripherals connected to each other
One peripheral connected to resource
All others connected “upstream”
Peripheral’s REQ flows “downstream” to resource
Resource’s ACK flows “upstream” to requesting
peripheral
Vahid, Givargis
Vahid, Givargis --7373-
-Arbitration using daisy
Arbitration using daisy
-
-
chain
chain
Advantages
Easy to add/remove peripheral
No system redesign needed
Disadvantages
Does not support rotating priority
One broken peripheral causes loss of access to others
CPU
INT INTA
P1
REQIN ACKIN REQOUT
ACKOUT
P2
REQIN ACKIN REQOUT
ACKOUT
P2
REQIN ACKIN REQOUT
ACKOUT 0
Network
Network
-
-
oriented arbitration
oriented arbitration
When multiple microprocessors share a bus,
sometimes called a network
Arbitration typically built into bus protocol
Separate processors may try to write simultaneously
This can cause collisions
Data must be resent
Don’t want to start sending again at same time, so
statistical methods are used to reduce chances
Vahid, Givargis
Vahid, Givargis --7575-
-Multilevel bus architectures
Multilevel bus architectures
Don’t want one bus for all communication
Some peripherals need
High-speed bus interface
Processor-specific bus interface
Too many peripherals slows down bus
A solution consists in using a multilevel bus
architecture consisting of
Processor-local bus
Peripheral bus
Bridge
Vahid, Givargis
Vahid, Givargis --7676-
-Multilevel bus architectures
Multilevel bus architectures
Processor-local bus
High speed and wide
Used for most frequent communication
Connects microprocessor, cache, memory controllers
Peripheral bus
Lower speed, narrower
Used for less frequent communication
Typically industry standard bus for portability
ISA, PCI, SCSI
Bridge
Vahid, Givargis
Vahid, Givargis --7777-
-Multilevel bus architectures
Multilevel bus architectures
CPU
Processor Local Bus
Cache controller
Memory controller
DMA controller Main
Memory L2 Cache
Peripheral Bus 1
P1.1 P1.N Bridge 1