Concept of Embedded Systems Design
Concept of Embedded Systems Design
Embedded Systems
Design
Definition
• Embedded system: any device that includes a
programmable computer but is not itself a
general-purpose computer.
• Take advantage of application characteristics
to optimize the design:
– don’t need all the general-purpose bells and
whistles.
Embedding a computer
output analog
input analog
CPU
mem
embedded
computer
Examples
• Personal digital assistant (PDA).
• Printer.
• Cell phone.
• Automobile: engine, brakes, dash, etc.
• Television.
• Household appliances.
• PC keyboard (scans keys).
Early history
• Late 1940’s: MIT Whirlwind computer for real-
time operations; Originally designed to control an
aircraft simulator.
• First mP was Intel 4004 in early 1970’s.
• HP-35 calculator used several chips to implement
a microprocessor in 1972
• Automobiles used microprocessor-based engine
controllers starting in 1970’s.
– Control fuel/air mixture, engine timing, etc.
– Multiple modes of operations: warm-up, hill climbing..
– Provides lower emissions, better fuel efficiency.
Embedded Computing-5
Microprocessor varieties
• Microcontroller: includes I/O devices, on-
board memory.
• Digital signal processor (DSP): microprocessor
optimized for digital signal processing.
• Typical embedded word sizes: 8-bit, 16-bit, 32-
bit.
Application examples
• Simple control: front panel of microwave
oven, etc.
• Canon EOS 3 has three microprocessors.
– 32-bit RISC CPU runs autofocus and eye control
systems.
• Analog TV: channel selection, etc.
• Digital TV: programmable CPUs + hardwired
logic.
Automotive embedded systems
• High-end automobile may have 100 mPs:
– 4-bit microcontroller checks seat belt;
– microcontrollers run dashboard devices;
– 16/32-bit microprocessor controls engine.
• BMW 850i
– Anti-lock brake system (ABS): pumps brakes to
reduce skidding.
– Automatic stability control (ASC+T): controls
engine to improve stability.
– ABS was introduced first--> ASC+T needs to
interface to existing ABS module.
BMW 850i, cont’d.
sensor sensor
brake brake
hydraulic
ABS
pump
brake brake
sensor sensor
Characteristics of embedded
systems
• Sophisticated functionality.
– Often run sophisticated algo. or multiple algo.
• Cell phone, laser printer.
– Often provide sophisticated user interfaces.
• Real-time operation.
– Must finish operations by deadlines.
• Hard real time: missing deadline causes failure.
• Soft real time: missing deadline results in degraded
performance.
– Many systems are multi-rate: must handle
operations at widely varying rates.
Characteristics of embedded systems
• Low manufacturing cost.
– Many embedded systems are mass-market items
that must have low manufacturing costs.
• Limited memory, microprocessor power, etc.
• Low power.
– Power is critical in battery-powered devices
• Excessive power consumption increases system cost even
in wall-powered devices.
• Designed to tight deadlines by small teams.
– 6 month market window is common.
– E.g., can’t miss back-to-school window for calculator.
Why use microprocessors?
• Alternatives: field-programmable gate arrays
(FPGAs), custom logic, etc.
– Intuition: Microprocessors use much more logic to
implement a function than does custom logic.
• But, microprocessors are often efficient,
because
– can use same logic to perform different functions
– heavily pipelined
– large design teams
– aggressive VLSI technology
• Microprocessors simplify the design of
families of products.
Although power is a concern,
• Custom logic is a clear winner for low power
devices.
• Modern microprocessors offer features to
help control power consumption.
• Software design techniques can help reduce
power consumption.
Challenges in embedded system design
• How much hardware do we need?
– How big is the CPU? Memory?
• How do we meet our deadlines?
– Faster hardware or cleverer software?
• How do we minimize power?
– Turn off unnecessary logic? reduce mem. accesses?
• Does it really work?
– Is the specification correct? Is the spec met?
– How do we test for real-time, real data?
• How do we work on the system?
– Observability, controllability? development platform?
Design methodologies
• A procedure for designing a system.
• Understanding methodology helps you ensure
you didn’t skip anything.
• Compilers, computer-aided design (CAD)
tools, software engineering tools, etc., can be
used to:
– help automate methodology steps;
– keep track of the methodology itself.
Need to consider design goals
• Performance.
– Overall speed, deadlines.
• Functionality and user interface.
• Manufacturing cost.
• Power consumption.
• Other requirements (physical size, etc.)
Work with levels of abstraction
requirements
Top-down
design specification
architecture Bottom-up
design
component
design
Real design uses
both techniques system
integration
Stepwise refinement
• At each level of abstraction, we must:
– analyze the design to determine characteristics of
the current state of the design;
– refine the design to add detail.
Level 1: Requirements
• Plain language description of what the user
wants and expects to get.
• May be developed in several ways:
– talking directly to customers;
– talking to marketing representatives;
– providing prototypes to users for comment.
Functional vs. non-functional
requirements
• Functional requirements:
– output as a function of input.
• Non-functional requirements:
– time required to compute output;
– size, weight, etc.;
– power consumption;
– reliability;
– etc.
requirements form
name
purpose
inputs
outputs
functions
performance
manufacturing cost
power
physical size/weight
Example: GPS moving map
requirements
• Moving map
obtains position
from GPS, paints I-78
map from local
Scotch Road
database.
lat: 40 13 lon: 32 19
GPS moving map needs
• Functionality: For automotive use. Show
major roads and landmarks.
• User interface: At least 400 x 600 pixel screen.
Three buttons max. Pop-up menu.
• Performance: Map scroll smoothly. Less than 1
sec power-up. Lock onto GPS within 15 sec
• Cost: $500 street price = approx. $100 cost of
goods sold.
• Physical size/weight: Should fit in hand.
Embedded Computing-23
user
database interface
GPS moving map hardware
architecture
memory
panel I/O
GPS moving map software
architecture
database pixels
renderer
search
position user
timer
interface
Level 4: HW and SW components
• Must spend time architecting the system
before you start coding.
• Some components are ready-made, some can
be modified from existing designs, others
must be designed from scratch.
Level 5: System integration
• Put together the components.
– Many bugs appear only at this stage.
• Have a plan for integrating components to
uncover bugs quickly, test as much
functionality as early as possible.
System modeling
• Need languages to describe systems:
– useful across several levels of abstraction;
– understandable within and between
organizations.
• Block diagrams are a start, but don’t cover
everything.
Object-oriented design
• Object-oriented (OO) design: A generalization of
object-oriented programming.
• Object = state + methods.
– State provides each object with its own identity.
– Methods provide an abstract interface to the object.
• Class: object type
– Defines the object’s state elements but state values
may change over time.
– Defines the methods used to interact with all objects of
that type.
• Each object has its own state.
OO implementation in C++
class display {
pixels : pixeltype[IMAX,JMAX];
public:
display() { }
pixeltype pixel(int i, int j)
{ return pixels[i,j]; }
void set_pixel(pixeltype val, int i, int j)
{ pixels[i,j] = val; }
}
OO design principles
• Some objects will closely correspond to real-
world objects.
– Some objects may be useful only for description
or implementation.
• Objects provide interfaces to read/write state,
hiding the object’s implementation from the
rest of the system.
UML
• Unified Modeling Language
• Developed by Booch et al.
• Goals:
– object-oriented;
– visual;
– useful at many levels of abstraction;
– usable for all aspects of design.
Embedded Computing-37
UML object
object name
class name
d1: Display
comment
attributes
UML class
• The operations provide the
Display abstract interface between
class the class’s implementation
name and other classes.
pixels
• Operations may have
elements
arguments, return values.
menu_items
• An operation can examine
and/or modify the object’s
mouse_click() state.
draw_box
operations
Relationships between objects and
classes
• Association: objects communicate but one
does not own the other.
• Aggregation: a complex object is made of
several smaller objects.
• Composition: aggregation in which owner
does not allow access to its components.
• Generalization: define one class in terms of
another.
Class derivation
• Define one class in terms of another.
– Derived class inherits attributes, operations of
base class.
Derived_class
UML
generalization
Base_class
Class derivation example
Display
base
pixels class
elements
menu_items
pixel()
derived class set_pixel()
mouse_click()
draw_box
BW_display Color_map_display
Multiple inheritance
base classes
Speaker Display
Multimedia_display
derived class
Association
• Association: describes relationship between
classes.
• Example:
# contained messages # containing message sets
association name
Links
• Link: describes relationships between objects.
• Example: Link defines the contains
relationship
message
msg = msg1 message set
length = 1102
count = 2
message
msg = msg2
length = 2114
Behavioral description
• We have discussed how to specify structure
• Now consider describing behavior of the
system:
– internal view
transition
– external view
• Use state machines a b
leftorright: button
mouse_click(x,y,button)
x, y: position
b
declaration
event description
Types of events
• Call event:
draw_box(10,5,3,2,blue)
c d
tm(time-value)
• Timer event:
e f
Example state machine
start input/output
mouse_click(x,y,button)/ region = menu/
find_region(region) which_menu(i) call_menu(I)
region got menu called
found item menu item
region = drawing/
find_object(objid) highlight(objid)
found object
object highlighted
finish
Sequence diagram
• Shows sequence of operations over time.
• Relates behaviors of multiple objects.
m: Mouse d1: Display u: Menu
mouse_click(x,y,button)
which_menu(x,y,i)
time
call_menu(i)
Model train setup
rcvr motor
power
supply
console
command
:console :train_rcvr
set-inertia
set-speed
• Sequence
diagram set-speed
estop
set-speed
Major subsystem roles
• Console:
– read state of front panel;
– format messages;
– transmit messages.
• Train:
– receive message;
– interpret message;
– control the train.
Console system classes
console
1 1
1 1 1
1
panel formatter transmitter
1 1
1 1
receiver* sender*
Console class roles
• panel: describes analog knobs and interface
hardware.
• formatter: turns knob settings into bit
streams.
• transmitter: sends data on track.
Train system classes
train set
1 1..t
1 1
train
1 1 motor
receiver interface
1 1
1 1 controller 1 1
detector* pulser*
Train class roles
• receiver: digitizes signal from track.
• controller: interprets received commands and
makes control decisions.
• motor interface: generates signals required by
motor.
Detailed specification
• We can now fill in the details of the
conceptual specification:
– more classes;
– behaviors.
• Sketching out the spec first helps us
understand the basic relationships in the
system.
Train speed control
• Motor controlled by pulse width modulation:
duty
cycle +
V
-
Console physical object classes
knobs* pulser*
train-knob: integer pulse-width: unsigned-
speed-knob: integer integer
inertia-knob: unsigned- direction: boolean
integer
emergency-stop: boolean
sender* detector*
control panel-active
train number inertia/estop
update-panel()
T current-train = train-knob
panel*:read-train() update-screen
changed = true
F
T
panel*:read-speed() current-speed = throttle
changed = true
F
... ...
Controller class
controller
current-train: integer
current-speed[ntrains]: integer
current-direction[ntrains]: boolean
current-inertia[ntrains]:
unsigned-integer
operate()
issue-command()
Setting the speed
• Don’t want to change speed instantaneously.
• Controller should change speed gradually by
sending several commands.
Sequence diagram for set-speed
command
:receiver :controller :motor-interface :pulser*
new-cmd
cmd-type
rcv-speed set-speed set-pulse
set-pulse
set-pulse
set-pulse
set-pulse
Controller operate behavior
wait for a
command
from receiver
receive-command()
issue-command()
Refined command classes
command
type: 3-bits
address: 3-bits
parity: 1-bit
made of
Bits stored registers
is the
capacity.
Location Storage
accommodate
bits. location
Address
Volatile Memory Non Volatile Memory
Read Only Memory
Nonvolatile memory
Uses
Store software program for general-purpose
processor program instructions can be one or more
ROM words
Store constant data needed by system
Read Only Memory Internal view
0
3X8
1 Decoder
1 0 1 0
Erasable Programmable Read Only
Memory
Transistor has “floating” gate surrounded by an insulator
(a) Negative charges form a channel between source and
drain storing a logic 1
(b) Large positive voltage at gate causes negative charges
to move out of channel and get trapped in floating gate
storing a logic 0
(c) (Erase) Shining UV rays on surface of floating-gate
causes negative charges to return to channel from floating
gate restoring the logic 1
(d) An EPROM package showing quartz window through
which UV light can pass
Electrically Erasable Programmable Read Only
Memory
Memory
Step 2.
Step 4. Store Decode
Write result to memory Translate
instruction into
Processor commands
ALU Control Unit
Step 3. Execute
Carry out command
Important Consideration of a system designer
to selecting processor:
• Instruction set
• Maximum bits in an operand (8 or 16 or 32).
• Clock Frequency in MHZ and processing
speed in Millions Instruction Per Second
[MIPS].
• Processor ability to solve complex
algorithm.
Design Process for Embedded System
Selection of Processors
• High Clock speed.
• High Computing performance – Pipeline
• Processors with registers - multitasking
• Power – efficient – auto shutdown
• Processors –Burst mode - external memory.
• Processor – Atomic Operation
• Processor – coding – Big Endian, Little Endian
Selection Of Memory Devices
• Actual memory requirement is known only after
coding.
• ROM & RAM allocation for various segments,
data & structures will be available from the
software design.
• Prior estimate of memory type and size can be
made.
Direct Memory Access (DMA)
Least Processor Intervention
• DMA transfer is controlled by a DMA controller, which
request control of the bus from CPU.
A bus with DMA Controller
DMA requires 2 bus signals : (i). Bus Request (ii). Bus Grant
Data transfer occurs between hard disk & system
memory.
• Single Transfer at a time - (bytes transfer) –
release the IO bus hold in each transfer.
• Burst Transfer at a time – (Kilobytes transfer) -
release the IO bus hold in each transfer.
• Bulk Transfer at a time – release the IO bus
hold after transfer is completed.
DMAC is first initialized,
i). Read or write.
ii). Mode of DMA transfer.
iii). Total number of bytes
to be transferred
iv). Starting memory
address.
• 8086, 8085 processors doesn't have DMAC
units.
• 8051 family member 83C152JA & MC68340
microcontroller have two DMA channels on
chip.
Memory Management
• Memory is the important resource, there is a
constant interaction and communication
between the processor.
• Semiconductor memory is the primary
memory
• Hard disk is the secondary memory
• All programs run with the data and code in the
RAM
VIRTUAL MEMORY
• Virtual memory is a concept by which the
application is made to believe that it has much
more memory than in physically available.
• Enlarged Address space which is also a virtual
address space.
Timer and Counting Devices
• Counter / Timer is used for many count based
measurements solutions.
Used for frequency measurements.
Used for edge or event counting.
Used for pulse – width measurement.
Used in event time stamps.
Timing Device or Timer :
Timer device is used to count the regular interval
clock pulses at its input.
Timer is a dedicated hardware for timing events.
• For example 8051 timer register TMOD & TCON.
• In timer count register, a number is loaded and
then the timer is started.
• Count keeps increasing until its reaches the
maximum value.
Counting Device or Counter :
Counting device is used to count the irregular
interval clock pulses at its input.
Watch Dog Timer (WDT)