Chapter 4: The Embedded Computing Platform

Download Report

Transcript Chapter 4: The Embedded Computing Platform

Chapter 4:
The Embedded Computing
Platform
Computer as Components
Embedded Systems Laboratory
Dept. of Computer Science & Engineering
National Sun Yat-Sen University
Presenter: Chung-Fu Kao
Chapter view


CPU bus, I/O devices, and interfacing
The CPU system as a framework for
understanding design methodology

Development environments and debugging

An alarm clock design
2
4/9/2002
The Embedded Computing System© C.-F. Kao
Typical PC hardware platform
CPU
CPU bus
intr
ctrl
DMA
controller
bus
interface
memory
device
high-speed bus
timers
bus
interface
low-speed bus
device
3
4/9/2002
The Embedded Computing System© C.-F. Kao
Introduction

Computer platform
 Microprocessors
 I/O devices
 Memory

How to interconnect microprocessors and devices using
the CPU bus
CPU
4
4/9/2002
?
device
keyboard
device
display
device
memory
The Embedded Computing System© C.-F. Kao
The CPU bus

Wire vs. bus
 Wire: a 1-bit line between two devices
wire
n
bus
 Bus: a collection of wires with a protocol
5
4/9/2002
The Embedded Computing System© C.-F. Kao
Bus protocol

The simplest bus protocol is the four-cycle
handshake
enq
1
3
2
ack
data
Action
time
6
4/9/2002
4
The Embedded Computing System© C.-F. Kao
Typical bus signals

Clock
 provides synchronization to the bus components

R/W’
 true when bus is reading

Address
 a n1-bit bundle

Data
 a n2-bit bundle

Data ready’
7
4/9/2002
The Embedded Computing System© C.-F. Kao
A typical microprocessor bus

the CPU can read/write devices or memory, bus
devices of memory cannot initiate a transfer
Device 1
Device 1
clock
R/W’
data rdy’
address
data
CPU
memory
8
4/9/2002
The Embedded Computing System© C.-F. Kao
Timing diagrams
one
A
B
rising
zero
falling
10 ns
changing
stable
Timing
constraint
C
time
9
4/9/2002
The Embedded Computing System© C.-F. Kao
A simple transfer example
10
4/9/2002
The Embedded Computing System© C.-F. Kao
Transfer with ‘wait’ states
11
4/9/2002
The Embedded Computing System© C.-F. Kao
State diagrams for the bus read
transaction
Get
data
Done
Address
See ack
(start here)
Send
data
ack
Address
(start here)
Wait
Wait
CPU
Device
12
4/9/2002
Release
ack
The Embedded Computing System© C.-F. Kao
Bus read state diagram
Get
data
Done
one data send/receive
per transfer cycle
See ack
Address
(start here)
How to speedup
the transfer ?
Wait
13
4/9/2002
The Embedded Computing System© C.-F. Kao
Burst transfer
14
4/9/2002
The Embedded Computing System© C.-F. Kao
Bus architectures: Tri-state design

1-bit tri-state design
enable
data_out
tri_out
data_in

System tri-state bus
…
…
15
4/9/2002
The Embedded Computing System© C.-F. Kao
…
Bus architectures: Multiplexing design
Master(s)
AGNTx1
AREQx1
AREQx2
AREQx3
BLOK
Data (W)
MUX
Data (R)
MUX
AGNTx2
ASB
Arbiter
BWAIT
BnRES/
BCLK
AGNTx3
select
Address bus
Data bus
DSEL 1
BA[31:0
DSEL 2
BWRITE
Address
MUX
Response
MUX
Control
MUX
BSIZE[1:0]
BPROT[1:0]
BnRES/
BCLK
ASB
Decoder
DSEL n
BWAIT
BERROR
BLAST
Select-1
Select-2
[31:28]
Decoder
Slave(s)
Control (write, transfer type, size)
Response (wait, last, error)
End of Chapter 4.2.1
16
4/9/2002
BTRAN[1:0]
The Embedded Computing System© C.-F. Kao
I/O techniques

Programmed I/O
 data are exchanged between CPU and I/O
 CPU must wait until the I/O operation is complete

Interrupt-driven I/O
 CPU can continues to execute other instructions
before I/O operation has completed

Direct Memory Access (DMA)
 CPU does not involve the I/O transfer
17
4/9/2002
The Embedded Computing System© C.-F. Kao
DMA: Direct Memory Access

The DMA controller includes 3 registers
 a starting address register
 a length register
Data count
 a status register
Data register
Address register

Cycle stealing
DMA REQ
DMA ACK
INTR
Read
Write
18
4/9/2002
The Embedded Computing System© C.-F. Kao
Control Logic
Possible DMA configuration
CPU
DMA
module
. . .
I/O
I/O
MEM
(a) Single-Bus, Detached DMA
CPU
DMA
DMA
module
MEM
module
I/O
I/O
I/O
(b) Single-Bus, Integrated DMA-I/O
System bus
CPU
DMA
module
MEM
I/O bus
I/O
19
4/9/2002
I/O
The Embedded
Computing
System© C.-F. Kao
(c) I/O
bus
I/O
Bus example: ARM bus

ARM supports an on-chip bus: AMBA
 Advanced Microcontroller Bus Architecture
Arbiter
BIU: Bus Interface Unit
CPU
……
Master BIU
Master N
Other
APB slaves
Timer
Master BIU
Slave BIU
Slave BIU
APB
Bridge
AHB/ASB BUS
Decoder
20
4/9/2002
On-chip
RAM
Slave BIU
The Embedded Computing System© C.-F. Kao
APB BUS
Interrupt
Controller
LED
Slave BIU
AMBA features

Pipelining
 only AHB or ASB

Burst transfers
 1, 4, 8, 16-beat transfer

Split transactions
 release the current transfer

Multiple bus masters
21
4/9/2002
The Embedded Computing System© C.-F. Kao
Bus components devices
Arbiter
BIU: Bus Interface Unit
CPU
……
Master BIU
Master N
Other
APB slaves
Timer
Master BIU
Slave BIU
Slave BIU
APB
Bridge
AHB/ASB BUS
Decoder
On-chip
RAM
Slave BIU
22
4/9/2002
The Embedded Computing System© C.-F. Kao
APB BUS
Interrupt
Controller
LED
Slave BIU
Memory device organization


The most basic way to characterize a memory is
by its capacity
A 4-Mbit memory aspect ratio :
20
 as a 1M x 4-bit array, MAX of 2
different
addresses
22
 as a 4M x 1-bit array, MAX of 2 different
addresses
23
4/9/2002
The Embedded Computing System© C.-F. Kao
Random-Access Memories (RAMs)

There are two major categories of RAM:
 static RAM (SRAM)
 dynamic RAM (DRAM)

The differences between SRAM and DRAM
 SRAM is faster than DRAM
 SRAM consumes more power than DRAM
 more DRAM can be put on a single chip
 DRAM values must be periodically refreshed
24
4/9/2002
The Embedded Computing System© C.-F. Kao
SRAM


SRAM doesn’t need CLOCK signal
Block diagram
15
address
SRAM
chip select
8
output enable
write enable

Timing diagram
Data_in
8
32K x 8
CS’
R/W’
Adrs
Data
From SRAM
25
4/9/2002
The Embedded Computing System© C.-F. Kao
From CPU
Data_out
DRAM

Single transistor and capacitor per bit
address
chip select
output enable
15
DRAM
8
write enable
Data_in 8



CPU address bus is split into a row and a column
address
NO clock
Refreshed
 CAS-before-RAS refresh
26
4/9/2002
The Embedded Computing System© C.-F. Kao
Data_out
Other DRAMs

FPM DRAM
 fast page mode switch (burst)

EDO DRAM
 extended data out

SDRAM
 synchronous DRAM
27
4/9/2002
The Embedded Computing System© C.-F. Kao
Read-Only Memories (ROMs)



Read only, cannot write any data to ROMs
ROMs can store data without any power
ROM size
 height: n input line, consists 2 addressable
n
entries
 width: the number of bits in each addressable
entry

A ROM can encode a collection of logic functions
directly from the truth table
28
4/9/2002
The Embedded Computing System© C.-F. Kao
ROMs


Mask ROM
Programmable ROM (PROM)
 write once

Erasable Programmable ROM (EPROM)
 can be erased using UV light and then
reprogrammed

Electrically Erasable Programmable ROM
 using high voltages for erasure and
reprogramming

Flash ROM
29
4/9/2002
The Embedded Computing System© C.-F. Kao
I/O devices






Timers / counters
A/D and D/A converters
Keyboards
LEDs
Displays
Touchscreens
30
4/9/2002
The Embedded Computing System© C.-F. Kao
Timers and counters

Very similar:
 a timer is incremented by a periodic signal
 a counter is incremented by an asynchronous,
occasional signal

Rollover causes interrupt
31
4/9/2002
The Embedded Computing System© C.-F. Kao
Watchdog timer


Watchdog timer is periodically reset by system
timer
If watchdog is not reset, it generates an
interrupt to reset the host (CPU)
reset
CPU
time-out
Watchdog
Timer
32
4/9/2002
The Embedded Computing System© C.-F. Kao
A/D and D/A converters



Analog/digital (A/D) or digital/analog (D/A)
converters (ADC/DAC)
To interface non-digital devices to embedded
systems
A typical A/D interface has two major digital
inputs
 a data port
 a clock input
33
4/9/2002
The Embedded Computing System© C.-F. Kao
DAC
34
4/9/2002
The Embedded Computing System© C.-F. Kao
ADC
35
4/9/2002
The Embedded Computing System© C.-F. Kao
Keyboards

Switch de-bouncing

Encoded keyboard
 An array of switches is read by an encoder
row
36
4/9/2002
The Embedded Computing System© C.-F. Kao
LEDs

Light-emitting diodes (LEDs)
+
+5 V
Anode (+)
Cathode (-)
37
4/9/2002
The Embedded Computing System© C.-F. Kao
Displays

Common use: 7-segment LCD display

Other high-resolution displays
 cathode ray tube (CRT)
 liquid crystal display (LCD)
• passive matrix
• active matrix
38
4/9/2002
The Embedded Computing System© C.-F. Kao
Touchscreens

Includes input and output device

Input device is a two-dimensional voltmeter
X
39
4/9/2002
The Embedded Computing System© C.-F. Kao
Touchscreen position sensing
Push
↓
ADC
conductive sheets
voltage
spacer ball
end of chapter 4.5
40
4/9/2002
The Embedded Computing System© C.-F. Kao
Design with microprocessors

System architecture

Hardware design

The PC as a platform

Debugging

Manufacturing testing
41
4/9/2002
The Embedded Computing System© C.-F. Kao
System architecture – Hardware

Hardware elements
 CPU
 bus
 memory
 I/O devices: networking, sensors, etc.
42
4/9/2002
The Embedded Computing System© C.-F. Kao
System architecture – Software

Functional description must be broken into
pieces:
 conceptual organization
 performance
 testability
 maintenance

Consider the H/W-S/W trade-off
 using DMA to move data rather than a
programmed loop
43
4/9/2002
The Embedded Computing System© C.-F. Kao
Hardware design


Hardware: evaluation board
Software:
 cross compiler:
• compiles code on host for target system.
 cross debugger:
• displays target state, allows target system to be controlled.
target
system
44
4/9/2002
host system
serial line
The Embedded Computing System© C.-F. Kao
Evaluation board
45
4/9/2002
The Embedded Computing System© C.-F. Kao
The PC as a platform

Advantages:
 cheap and easy to get
 rich and familiar software environment

Disadvantages:
 requires a lot of hardware resources
 not well-adapted to real-time
 high power consumption
46
4/9/2002
The Embedded Computing System© C.-F. Kao
Typical PC hardware platform
CPU
CPU bus
intr
ctrl
DMA
controller
bus
interface
memory
device
high-speed bus
timers
bus
interface
low-speed bus
device
47
4/9/2002
The Embedded Computing System© C.-F. Kao
Typical busses

ISA (Industry Standard Architecture)
 original IBM PC bus, low-speed by today’s
standard.

PCI (Peripheral Component Interconnect)
 standard for high-speed interfacing
 33 or 66 MHz.


USB (Universal Serial Bus),
IEEE 1394 (Firewire)
 relatively low-cost serial interface with high speed.
48
4/9/2002
The Embedded Computing System© C.-F. Kao
Software elements

IBM PC uses BIOS (Basic I/O System) to
implement low-level functions:
 boot-up
 minimal device drivers

BIOS has become a generic term for the lowestlevel system software
49
4/9/2002
The Embedded Computing System© C.-F. Kao
Debugging embedded systems

Challenges:
 target system may be hard to observe
 target may be hard to control
 may be hard to generate realistic inputs
 setup sequence may be complex
50
4/9/2002
The Embedded Computing System© C.-F. Kao
Software debuggers



A monitor program residing on the target
provides basic debugger functions
Debugger should have a minimal footprint in
memory
User program must be careful not to destroy
debugger program, but , should be able to
recover from some damage caused by user code
51
4/9/2002
The Embedded Computing System© C.-F. Kao
Breakpoints


A breakpoint allows the user to stop execution,
examine system state, and change state
Replace the breakpointed instruction with a
subroutine call to the monitor program
52
4/9/2002
The Embedded Computing System© C.-F. Kao
ARM breakpoints
0x400
0x404
0x408
0x40c
MUL r4,r6,r6
ADD r2,r2,r4
ADD r0,r0,#1
B loop
uninstrumented code
0x400
0x404
0x408
0x40c
code with breakpoint
53
4/9/2002
MUL r4,r6,r6
ADD r2,r2,r4
ADD r0,r0,#1
BL bkpoint
The Embedded Computing System© C.-F. Kao
Breakpoint handler actions



Save registers
Allow user to examine machine
Before returning, restore system state
 safest way to execute the instruction is to replace
it and execute in place
 put another breakpoint after the replaced
breakpoint to allow restoring the original
breakpoint (pp. 222-223)
54
4/9/2002
The Embedded Computing System© C.-F. Kao
In-circuit emulators


A microprocessor in-circuit emulator is a
specially-instrumented microprocessor
Allows you to stop execution, examine CPU state,
modify registers
55
4/9/2002
The Embedded Computing System© C.-F. Kao
Logic analyzers

A logic analyzer is an array of low-grade
oscilloscopes:
56
4/9/2002
The Embedded Computing System© C.-F. Kao
Manufacturing testing


Goal: ensure that manufacturing produces
defect-free copies of the design
Can test by comparing unit being tested to the
expected behavior
 but running tests is expensive

Maximize confidence while minimizing testing
cost
57
4/9/2002
The Embedded Computing System© C.-F. Kao
Testing concepts

Yield: proportion of manufactured systems that
work
 proper manufacturing maximizes yield
 proper testing accurately estimates yield

Field return: defective unit that leaves the
factory.
58
4/9/2002
The Embedded Computing System© C.-F. Kao
Faults



Manufacturing problems can be caused by many
thing
Fault model: model that predicts effects of a
particular type of fault
Fault coverage: proportion of possible faults
found by a set of test
 having a fault model allows us to determine fault
coverage
59
4/9/2002
The Embedded Computing System© C.-F. Kao
Software vs. hardware testing

When testing code, we have no fault model
 we verify the implementation, not the
manufacturing
 simple tests work well to verify software
manufacturing

Hardware requires manufacturing tests in
addition to implementation verification
60
4/9/2002
The Embedded Computing System© C.-F. Kao
Hardware fault models

Stuck-at 0/1 fault model:
 output of gate is always 0/1
01
0
61
4/9/2002
The Embedded Computing System© C.-F. Kao
Combinational testing


Every gate can be stuck-at-0, stuck-at-1
Usually test for single stuck-at-faults
 one fault at a time
 multiple faults can mask each other

We can generate a test for a gate by:
 controlling the gate’s input
 observing the gate’s output through other gates
62
4/9/2002
The Embedded Computing System© C.-F. Kao
Sequential testing


A state machine is combinational logic +
registers
Sequential testing is considerably harder
 a single stuck-at fault affects the machine on
every cycle
 fault behavior on one cycle can be masked by
same fault on other cycles
63
4/9/2002
The Embedded Computing System© C.-F. Kao
Scan chains

A scannable register operates in two modes:
 normal
 scan
• forms an element in a shift register
64
4/9/2002
The Embedded Computing System© C.-F. Kao
Scan chain cell
Scan
output
Input pin
EXTEST
INTEST
SEL
MUX
scan
SEL
BSR
MUX
Scan input
Shift
clock
PDR
Update
clock
65
4/9/2002
The Embedded Computing System© C.-F. Kao
Input signal
to logic
Boundary scan

IEEE Std. 1149.1 JTAG boundary scan
Serial
data in
Serial
data out
Serial test interconnect
System interconnect
66
4/9/2002
The Embedded Computing System© C.-F. Kao
Embedded ICE
Microprocessor Core
mode
external
debug
clock
address
data
Interface
ICE
breakpoint
Breakpoint
Scan Register
BDU
Bypass Register
Select Unit
TDI
TMS
TCK
Instruction
Register
Decode
Logic
TAP
Controller
67
4/9/2002
The Embedded Computing System© C.-F. Kao
MUX
TDO