Lecture4.1 Embedded Computer Architecture Bus
Lecture4.1 Embedded Computer Architecture Bus
CPU: Week
ARM Cortex-M 4
Curriculum Memory
and Bus
Week
5-6
Real-time Week
Operating systems 10-12
Project Week
Laboratory for Smart Integrated Systems 15
Objectives
3
Outline
• Busses.
– Basic Concepts
– DMA
– Arbitration
– Multilevel Bus Architectures
• Memory devices.
• Summary
5
Communication Mechanism
Computer system’s
components communicate
through an interconnection
network
Provides the means for data
transfer and
exchange of status and
control information
Interconnection network can
be:
– Direct connections.
– Shared bus
– Network-on-Chip
6
A simple bus
• Wires:
– Uni-directional or bi-directional
– One thick line may represent multiple
wires rd'/wr
Processor Memory
• Bus enable
addr[0-11]
– Set of wires with a single function data[0-7]
• Address bus, data bus
– Or, entire collection of wires bus
bus structure
7
Ports
addr[0-11]
data[0-7]
bus
• Conducting device on periphery
• Connects bus to processor or memory
• Often referred to as a pin
– Actual pins on periphery of IC package that plug into socket on printed-circuit board
– Sometimes metallic balls instead of pins
– Today, metal “pads” connecting processors and memories within single IC
• Single wire or set of wires with single function
– E.g., 12-wire address port
8
BUS
• A bus is, at a minimum, a collection of wires but it
also defines a protocol by which the CPU, memory,
and devices communicate.
• The signals that make up the bus provide the
necessary communication: the data itself, addresses, a
clock, and some control signals.
9
Microprocessor busses
The major components on a typical bus include:
• Clock provides
synchronization.
• R/W’ is true when
reading (R/W’ is
false when reading).
• Address is a-bit
bundle of address
lines.
• Data is n-bit bundle
of data lines.
• Data ready signals
when n-bit data is
ready. 10
Timing Diagrams
13
Basic protocol concepts
• Actor: master initiates, servant (slave) respond
• Direction: sender, receiver
• Addresses: special kind of data
– Specifies a location in memory, a peripheral, or a register within a peripheral
• Time multiplexing
– Share a single set of wires for multiple pieces of data
– Saves wires at expense of time
data(8) addr/data
req req
data 15:8 7:0 addr/data addr data
14
Basic protocol concepts: control methods
Control methods are schemes for initiating and ending the transfer.
ack
data
data
req 1 3
req 1 3
ack 2 4
data 2 4
data
taccess
1. Master asserts req to receive data 1. Master asserts req to receive data
2. Servant puts data on bus within time taccess 2. Servant puts data on bus and asserts ack
3. Master receives data and deasserts req 3. Master receives data and deasserts req
4. Servant ready for next request 4. Servant ready for next request
Simple; Fixed timing More complex; Flexible timing
Slower when response time is known
Strobe protocol Handshake protocol
15
A strobe/handshake compromise
wait
data
req 1 3 req 1 4
wait wait 2 3
data 2 4 data 5
taccess taccess
1. Master asserts req to receive data 1. Master asserts req to receive data
2. Servant puts data on bus within time taccess 2. Servant can't put data within taccess, asserts wait ack
(wait line is unused) 3. Servant puts data on bus and deasserts wait
3. Master receives data and deasserts req 4. Master receives data and deasserts req
4. Servant ready for next request 5. Servant ready for next request
16
QUIZ
Bus multiplexing?
21
Bus multiplexing
adrs
Address
/Data Address Data
Adrs Address
22
Outline
• Busses.
– Basic Concepts
– DMA
– Arbitration
– Multilevel Bus Architectures
• Memory devices.
• Summary
23
DMA
• Direct memory access (DMA) performs data transfers without
executing instructions.
– CPU sets up transfer.
– DMA controller performs read and write operations directly between
devices and memory.
• DMA controller is a separate unit.
– DMA controller can act as a bus master
24
Bus mastership
• By default, CPU is bus master and initiates transfers.
• DMA must become bus master to perform its work.
– CPU can’t use bus while DMA operates.
• Bus mastership protocol:
– Two additional bus signals: Bus request and Bus grant.
– Control method: a four-cycle handshake
25
DMA operation
• The CPU controls the DMA operation through registers in the DMA
controller:
– A starting address register specifies where the transfer is to begin.
– A target address register specifies where the data is transferred to.
– A length register specifies the number of words to be transferred.
– A status register allows the DMA controller to be operated by the CPU.
• The CPU initiates a DMA transfer by
– setting starting address and length registers and target address appropriately.
– Setting “start transfer” bit in DMA’s status register.
• Once DMA is bus master, it transfers automatically.
– May run continuously until complete.
– May use every nth bus cycle.
26
Peripheral to memory transfer with DMA
28
Peripheral to memory transfer with DMA (cont’)
29
Peripheral to memory transfer with DMA (cont’)
30
Peripheral to memory transfer with DMA (cont’)
5: DMA ctrl (a) asserts ack, (b) reads data Program memory μP Data memory
from 0x8000, and (c) writes that data to 0x0000 0x0001
0x0001.
No ISR needed!
System bus
(Meanwhile, processor still executing if not
stalled!)
... Dack
Main program DMA ctrl P1
... Dreq 1
0x0001 ack
100: instruction PC
101: instruction 0x8000 req 0x8000
100
31
Peripheral to memory transfer with DMA (cont’)
... Dack
Main program DMA ctrl P1
... Dreq 0
0 0x0001 ack
100: instruction PC 0x8000 req 0x8000
101: instruction
100
32
Bus transfer sequence diagram
What is the CPU doing during a DMA transfer?
33
Concurrency in DMA operation
• Once DMA is bus master, it may
– Run continuously until complete.
– Use every nth bus cycle to prevent the CPU from idling for too long.
35
Arbitration: Priority arbiter
36
Arbitration using a priority arbiter
Micro-
processor
System bus 7
Inta 5
Priority Peripheral Peripheral
Int arbiter 1 2
3 2 2
Ireq1
Iack1 6
Ireq2
Iack2
• Types of priority
• Fixed priority
– each peripheral has unique rank
– highest rank chosen first with simultaneous requests
– preferred when clear difference in rank between peripherals
• Rotating priority (round-robin)
– priority changed based on history of servicing
– better distribution of servicing especially among peripherals
with similar priority demands
38
Arbitration: Daisy-chain arbitration
Peripheral1 Peripheral2
Inta
Ack_in Ack_out Ack_in Ack_out
Int Req_out Req_in Req_out Req_in 0
39
Arbitration: Daisy-chain arbitration
• Pros/cons
– Easy to add/remove peripheral - no system redesign
needed
– Does not support rotating priority
– One broken peripheral can cause loss of access to other
peripherals
Micro-
P
processor System bus
System bus
Int
a Priority Periphera Periphera Peripheral1 Peripheral2
Int arbiter l1 l2 Inta
Ack_in Ack_out Ack_in Ack_ou
Ireq1 Int Req_o Req_i t
Req_ou Req_i 0
Iack1 ut n t n
Ireq2
Daisy-chain aware peripherals
Iack2
40
Outline
• Busses.
– Basic Concepts
– DMA
– Arbitration
– Multilevel Bus Architectures
• Memory devices.
• Summary
41
Multilevel bus architectures
• Don’t want one bus for all communication
– Peripherals do not need high-speed, processor-specific bus interface
• excess gates, power consumption, and cost; less portable
– Too many peripherals slows down bus
• Processor-local bus Micro- Cache Memory DMA
– High speed, wide, most frequent processor controller controller
communication
– Connects microprocessor, cache, memory
controllers, etc. Processor-local bus
45
Outline
• Busses.
• Memory devices.
• Summary
46