CS 404 Embedded Systems
CS 404 Embedded Systems
CS 404 Embedded Systems
Module 1
1. I NTRODUCTION:
First Generation: The early embedded systems built around 8-bit microprocessors
like 8085 and Z80 and 4-bit microcontrollers
EX. stepper motor control units, Digital Telephone Keypads etc.
Third Generation: Embedded Systems built around high performance 16/32 bit
Microprocessors/controllers, Application Specific Instruction set processors like
Digital Signal Processors (DSPs), and Application Specific Integrated Circuits
(ASICs).Theinstruction set is complex and powerful.
EX. Robotics, industrial process control, networking etc
Fourth Generation: Embedded Systems built around System on Chips (SoC’s), Re-
configurable processors and multicore processors. It brings high performance, tight
integration and miniaturization into the embedded device market
EX Smart phone devices, MIDs etc
1
Slightly complex in hardware & firmware requirement.
Built around medium performance & low cost 16 or 32 bit μp/μc.
Usually contain operating system.
Examples: Industrial machines.
(iii)Large-scale Embedded Systems:
Highly complex hardware & firmware.
Built around 32 or 64 bit RISC μp/μc or PLDs or Multicore Processors.
Response is time-critical.
Examples: Mission critical applications.
It is applicable for Real Time systems. The application/task execution behavior for an
embedded system can be either deterministic or non-deterministic
Event Triggered : Activities within the system (e.g., task run-times) are dynamic and
depend upon occurrence of different events .
Time triggered: Activities within the system follow a statically computed schedule
(i.e., they are allocated time slots during which they can take place) and thus by
nature are predictable
2
Key factor Performance is key factor. Application specific requirements are key
factors.
Power More Less
Consumption
Response Not critical Critical for some applications
Time
Execution Need not be deterministic Deterministic for certain types of ES like
‘Hard Real Time’ systems.
A typical embedded system contains a single chip controller, which acts as the master
brain of the system.
Keyboards, push button switches, etc. are examples for common user interface input
devices whereas LEDs, liquid crystal displays, piezoelectric buzzers, etc. are
examples for common user interface output devices for a typical embedded system.
For example, if the embedded system is designed for any handheld application, such
as a mobile handset application, then the system should contain user interfaces like a
keyboard for performing input operations and display unit for providing users the
status of various activities in progress.
3
2. COMPLEX SYSTEM AND MICROPROCESSORS:
“An embedded system is a system that has software embedded into computer-hardware, which makes
a system dedicated for an application (s) or specific part of an application or product or part of a large
system”. Its software usually embeds into a ROM (Read Only Memory) or flash.” It has 3 main
components embedded into it.
Three main tasks or components in embedded system design:
It embeds main application software generally into a flash or ROM and so the
application software performs concurrently the number of tasks.
It embeds a Real Time Operating System, or an RTOS which supervises the application
software. It enables the execution of concurrent tasks. The RTOS, in effect, sets the
framework of rules during the execution of application processes so as to enable
finishing of a process in good time and with the appropriate priority.
Embedded computing system design is a useful skill for many types of product design. Automobiles,
cell phones, and even household appliances make extensive use of microprocessors.
4
2.1 Embedding Computers:
Computers have been embedded into applications since the earliest days of computing
f. Entertainment(Television etc)
h. Automation
i. Navigation
5
f. Power
■Complex algorithms: The operations performed by the microprocessor may be very sophisticated.
For example, the microprocessor that controls an automobile engine must perform complicated
filtering functions to optimize the performance of the car while minimizing pollution and fuel
utilization.
■User interface: Microprocessors are frequently used to control complex user interfaces that may
include multiple menus and many options. The moving maps in Global Positioning System (GPS)
navigation are good examples of sophisticated user interfaces.
To make things more difficult, embedded computing operations must often be performed to meet
deadlines:
■Real time: Many embedded computing systems have to perform in real time—if the data is not
ready by a certain deadline, the system breaks. In some cases, failure to meet a deadline is unsafe and
can even endanger lives
Hard real time: Missing deadline causes failure
Soft real time: Missing deadline causes degraded performances
■Multirate: must handle operation at varying rate
6
a) First, microprocessors execute programs very efficiently. Modern RISC processors can
execute one instruction per clock cycle most of the time and high performance processors can
execute several instructions per cycle.
b) Second, microprocessor manufacturers spend a great deal of money to make their CPUs
run very fast. With the slight changes designer can make the microprocessor to run at the
highest possible speed.
v. Microprocessors are efficient utilizers of logic
vi. Microprocessors can be used for many different algorithms simply by changing the program it
executes.
vii. The microprocessors allows program design to be separated from the design of hardware on
which programs will be running.
External constraints are one important source of difficulty in embedded system design. Let’s consider
some important problems that must be taken into account in embedded system design.
How much hardware do we need?
We have a great deal of control over the amount of computing power we apply to our problem. We
cannot only select the type of microprocessor used, but also select the amount of memory, the
peripheral devices, and more. Since we often must meet both performance deadlines and
manufacturing cost constraints, the choice of hardware is important—too little hardware and the
system fails to meet its deadlines, too much hardware and it becomes too expensive.
How do we meet deadlines?
The brute force way of meeting a deadline is to speed up the hardware so that the program runs faster.
Of course, that makes the system more expensive. It is also entirely possible that increasing the CPU
clock rate may not make enough difference to execution time, since the program’s speed may be
limited by the memory system.
How do we minimize power consumption?
7
In battery-powered applications, power consumption is extremely important. Even in non battery
applications, excessive power consumption can increase heat dissipation. One way to make a digital
system consume less power is to make it run more slowly, slowing down the system can obviously
lead to missed deadlines. Careful design is required to slow down the noncritical parts of the machine
for power consumption while still meeting necessary performance goals.
How do we design for upgradability?
The hardware platform may be used over several product generations or for several different versions
of a product in the same generation, with few or no changes. However, we want to be able to add
features by changing software.
Does it really work?
Reliability is always important when selling products—customers rightly expect that products they
buy will work. Reliability is especially important in some applications. If we wait until we have a
running system and try to eliminate the bugs, we will be too late—we won’t find enough bugs, it will
be too expensive to fix them, and it will take more time.
Let’s consider some ways in which the nature of embedded computing machines makes their design
more difficult.
■Complex testing: Exercising an embedded system is generally more difficult than typing in some
data. We may have to run a real machine in order to generate the proper data. The timing of data is
often important, meaning that we cannot separate the testing of an embedded computer from the
machine in which it is embedded.
■Limited observability and controllability: Embedded computing systems usually do not come with
keyboards and screens. This makes it more difficult to see what is going on and to affect the system’s
operation. We may be forced to watch the values of electrical signals on the microprocessor bus, for
example, to know what is going on inside the system. Moreover, in real-time applications we may not
be able to easily stop the system to see what is going on inside.
■Restricted development environments: The development environments for embedded systems (the
tools used to develop software and hardware) are often much more limited than those available for
PCs and workstations. We generally compile code on one type of machine, such as a PC, and
download it onto the embedded system. To debug the code, we must usually rely on programs that run
on the PC or workstation and then look inside the embedded system.
3. EMBEDDED SYSTEM DESIGN PROCESS:
8
Figure 1.1 summarizes the major steps in the embedded system design process. In this top–down
view, we start from the system requirements. In bottom up approach we start with components.
Specification, we create a more detailed description of what we want. But the specification states only
how the system behaves, not how it is built. The details of the system’s internals begin to take shape
when we develop the architecture, which gives the system structure in terms of large components.
Once we know the components we need, we can design those components, including both software
modules and any specialized hardware we need. Based on those components, we can finally build a
complete system. In this section we will consider design from the top–down—we will begin with the
most abstract description of the system.
The alternative is a bottom–up view in which we start with components to build a system.
Bottom–up design steps are shown in the figure as dashed-line arrows. We need bottom–up design
because we do not have perfect insight into how later stages of the design process will
turn out.
9
Clearly, before we design a system, we must know what we are designing. The initial stages
of the design process capture this information for use in creating the architecture and
components. We generally proceed in two phases:
1. First, we gather an informal description from the customers known as requirements;
2. second we refine the requirements into a specification that contains enough information to
begin designing the system architecture.
Separating out requirements analysis and specification is often necessary because of the large
gap between what the customers can describe about the system they want and what the
architects need to design the system. Requirements may be functional or nonfunctional.
Typical nonfunctional requirements include:
■Performance: The speed of the system is often a major consideration both for the usability of the
system and for its ultimate cost. As we have noted, performance may be a combination of soft
performance metrics such as approximate time to perform a user-level function and hard deadlines by
which a particular operation must be completed.
■Cost: The target cost or purchase price for the system is almost always a consideration. Cost
typically has two major components:
Manufacturing cost includes the cost of components and assembly
Nonrecurring engineering (NRE) costs include the personnel and other costs of designing
the system.
■Physical size and weight: The physical aspects of the final system can vary greatly depending upon
the application. An industrial control system for an assembly line may be designed to fit into a
standard-size rack with no strict limitations on weight. A handheld device typically has tight
requirements on both size and weight that can ripple through the entire system design.
■Power consumption: Power, of course, is important in battery-powered systems and is often
important in other applications as well. Power can be specified in the requirements stage in terms of
battery life.
Validating a set of requirements is ultimately a psychological task since it requires
understanding both what people want and how they communicate those needs. One good way to
refine at least the user interface portion of a system’s requirements is to build a mock-up. The mock-
up may use scanned data to simulate functionality in a restricted demonstration, and it may be
executed on a PC or a workstation.
Requirements analysis for big systems can be complex and time consuming. However,
capturing a relatively small amount of information in a clear, simple format is a good start towards
understanding system requirements. As part of system design to analyze requirements, we will use a
simple requirements methodology. Figure 1.2 shows a sample requirements form that can be filled
out at the start of the project. Let’s consider the entries in the form:
10
Name
Purpose
Inputs
Outputs
Functions
Performance
Manufacturing cost
Power
Physical size and weight
11
■Physical size and weight: You should give some indication of the physical size of the system that
helps to take architectural decisions.
After writing the requirements, you should check them for internal consistency. To practice the
capture of system requirements, Example 1.1 creates the requirements for a GPS moving map system.
Example 1.1
Requirements analysis of a GPS moving map
The moving map is a handheld device that displays for the user a map of the terrain around the user’s
current position; the map display changes as the user and the map device change position. The moving
map obtains its position from the GPS, a satellite-based navigation system. The moving map display
might look something like the following figure.
What requirements might we have for our GPS moving map? Here is an initial list: ■Functionality:
This system is designed for highway driving and similar uses. The system should show major roads
and other landmarks available in standard topographic databases.
■User interface: The screen should have at least 400_600 pixel resolution. The device should be
controlled by no more than three buttons. A menu system should pop up on the screen when buttons
are pressed to allow the user to make selections to control the system.
■Performance: The map should scroll smoothly. Upon power-up, a display should take no more than
one second to appear, and the system should be able to verify its position and display the current map
within 15 sec.
■Cost: The selling cost of the unit should be no more than $100.
■Physical size and weight: The device should fit comfortably in the palm of the hand.
■Power consumption: The device should run for at least eight hours on four batteries.
12
Requirements form for GPS moving map system:
Name GPS moving map
Purpose Consumer-grade moving map for driving use
Inputs Power button, two control buttons
Outputs Back-lit LCD display 400 _ 600
Functions Uses 5-receiver GPS system. Three user-selectable
Resolutions: always display current latitude and l
longitude
Performance Updates screen within 0.25 seconds upon movement
Manufacturing cost $30
Power 100mW
Physical size and weight No more than 2” _ 6,” 12 ounces
The selling price is four to five times the cost of goods sold (the total of all the component costs).
3.2 Specification
The specification is more precise—it serves as the contract between the customer and the
architects.
The specification must be carefully written so that it accurately reflects the customer’s
requirements and that can be clearly followed during design.
The specification should be understandable enough so that someone can verify that it meets
system requirements and overall expectations of the customer.
It should also be unambiguous enough that designers know what they need to build. An unclear
specification leads different types of problems. If the behavior of some feature in a particular
situation is unclear from the specification, the designer may implement the wrong functionality.
The specification form should be correct and complete. If the specifications are wrong or
incomplete, the overall system architecture derived from the specification may be inadequate to
meet the needs of implementation.
A specification of the GPS system would include several components:
■Data received from the GPS satellite constellation.
■Map data.
■ User interface.
■Operations that must be performed to satisfy customer requests.
■Background actions required to keep the system running, such as operating the GPS receiver.
13
The architecture is a plan for the overall structure of the system that will be used later to design the
components that make up the architecture.
To understand what an architectural description is, let’s look at sample architecture for the moving
map of Example 1.1. Fig1.3 shows sample system architecture in the form of a block diagram that
shows major operations and data flows among them.
.
Fig 1.3: Block diagram for the moving map
14
For more implementation details we should refine that system block diagram into two block diagrams:
Hardware block diagram (Hardware architecture)
Software block diagram(Software architecture)
These two more refined block diagrams are hardware and software block diagrams. Figure 1.4 shows
hardware block diagram, we have one central CPU surrounded by memory and I/O devices.
15
3.4 Designing Hardware and Software Components
1. The architectural description tells us what components we need.
2. In general components include both hardware—FPGAs, boards, and so on—and software
modules.
3. Some of the components will be ready-made.
3.5 System Integration
Putting hardware and software components together will give complete working system. Bugs are
typically found during system integration, and good planning can help us to find the bugs quickly. If
we debug only a few modules at a time, we are more likely to uncover the simple bugs and able to
easily recognize them.
System integration is difficult because it usually uncovers problems. It is often hard to
observe the system in sufficient detail to determine exactly what is wrong— the debugging facilities
for embedded systems are usually much more limited than what you would find on desktop systems.
As a result, determining why things do not work correctly and how they can be fixed is a challenge in
itself.
4. FORMALISMS FOR SYSTEM DESIGN
We perform a number of different design tasks at different levels of abstraction: creating requirements
and specifications, architecting the system, designing code, and designing tests. It is often helpful to
conceptualize these tasks in diagrams.
The Unified Modeling Language (UML). UML was designed to be useful at many levels of
abstraction in the design process. UML is an object-oriented modeling language.
The design in terms of actual objects helps us to understand the natural structure of the system.
Object-oriented specification can be seen in two complementary ways:
■Object-oriented specification allows a system to be described in a way that closely models real-
world objects and their interactions.
■Object-oriented specification provides a basic set of primitives that can be used to describe systems
with particular attributes, irrespective of the relationships of those systems’ components to real-world
objects.
What is the relationship between an object-oriented specification and an object oriented programming
language?
A specification language may not be executable. But both object-oriented specification and
programming languages provide similar basic methods for structuring large systems.
4.1 Structural Description
1. By structural description, we mean the basic components of the system .
2. The principal component of an object-oriented design is object.
3. An object includes a set of attributes that define its internal state.
16
4. When implemented in a programming language, these attributes usually become variables or
constants held in a data structure. In some cases, we will add the type of the attribute after the
attribute name for clarity, but we do not always have to specify a type for an attribute.
1. A class is a form of type definition—all objects derived from the same class have the same
characteristics, although their attributes may have different values.
2. A class defines the attributes that an object may have. It also defines the operations that
determine how the object interacts with the rest of the world. In a programming language, the
operations would become pieces of code used to manipulate the object.
The UML description of the Display class is shown in Figure1.7.
A class defines both the interface for a particular type of object and that object’s implementation.
When we use an object, we do not directly manipulate its attributes—we can only read or modify the
object’s state through the operations that define the interface to the object. As long as we do not
17
change the behavior of the object seen at the interface, we can change the implementation as much as
we want.
There are several types of relationships that can exist between objects and classes:
■Association occurs between objects that communicate with each other but have no ownership
relationship between them.
■Aggregation describes a complex object made of smaller objects.
■Composition is a type of aggregation in which the owner does not allow access to the component
objects.
■Generalization allows us to define one class in terms of another (use to represent inheritance
relation)
Unified Modeling Language, like most object-oriented languages, allows us to define one class in
terms of another. An example is shown in Fig1.8, where we derive two particular types of displays.
The first, BW_display, describes a black and- white display. This does not require us to add new
attributes or operations, but we can specialize both to work on one-bit pixels.
18
Fig 1.9: Multiple inheritance in UML
multiple inheritances:
Both BW_display and Color_map_display are specific versions of Display, so Display generalizes
both of them. UML also allows us to define multiple inheritances, in which a class is derived from
more than one base class. (Most object-oriented programming languages support multiple inheritances
as well.) An example of multiple inheritances is shown in Fig1.9; In this case, we have created a
Multimedia_display class by combining the Display class with a Speaker class for sound. The derived
class inherits all the attributes and operations of both its base classes, Display and Speaker.
A link describes a relationship between objects; association is to link as class is to object. Fig1.10
shows an example of links and an association. When we consider the actual objects in the system,
there is a set of messages that keeps track of the current number of active messages (two in this
example) and points to the active messages. In this case, the link defines the contains relation.
When generalized into classes, we define an association between the message set class and the
message class. The association is drawn as a line between the two labeled with the name of the
association, namely, contains. The ball and the number at the message class end indicate that the
message set may include zero or more message objects. We can give these patterns names, which are
called stereotypes in UML. A stereotype name is written in the form <<signal>>.
19
Fig 1.10: Links and associations in UML
We will concentrate on the following three types of events defined by UML, as illustrated in figure
1.12(signal and call event) and figure 1.13(Time out event)
■A signal is an asynchronous occurrence. It is defined in UML by an object that is labeled as a
<<signal>>. The object in the diagram serves as a declaration of the event’s existence. Because it is
an object, a signal may have parameters that are passed to the signal’s receiver.
20
■A call event follows the model of a procedure call in a programming language.
■A time-out event causes the machine to leave a state after a certain amount of time. The label
tm(time-value) on the edge gives the amount of time after which the transition occurs. A time-out is
generally implemented with an external timer.
21
Figure 1.14: State diagram specification for display in moving map
Sequence diagram:
It is sometimes useful to show the sequence of operations over time, particularly when several objects
are involved. In this case, we can create a sequence diagram, like the one for a mouse click scenario
shown in Fig1.15.A sequence diagram is somewhat similar to a hardware timing diagram, although
the time flows vertically in a sequence diagram, whereas time typically flows horizontally in a timing
diagram. The sequence diagram is designed to show a particular scenario or choice of events. In this
case, the sequence shows what happens when a mouse click is on the menu region. Processing
includes three objects shown at the top of the diagram. Extending below each object is its lifeline, a
dashed line that shows how long the object is alive. In this case, all the objects remain alive for the
entire sequence, but in other cases objects may be created or destroyed during processing.
22
23
5 DESIGN EXAMPLE: MODEL TRAIN CONTROLLER
The model train controller, which is shown in the below figure.
1. The user sends messages to the train with the control box attached to the tracks.
2. The control box may have familiar controls such as throttle, emergency stop button and so on.
3. Since train receives its electrical power from the track, the control box can send a signal to the
train over the track by modulating the power supply voltage.
4. As shown Fig1.16, the control panel sends packet over the tracks to the receiver on the train.
Each packet includes an address so that the console can control several trains on the same
track. The packet also includes an error correction code (ECC) to guard against transmission
errors. This is a one-way communication system- the model train cannot send commands
back to the user.
24
Manufacturing cost $50
Power 10W (plugs into walls)
Physical size and weight Console should be comfortable for two hands, approximate
size of standard keyboard. Weight less than 2 pounds
The system console controls the train by sending messages on to the tracks. The transmissions are
packetized: each packet includes an address and a message. A typical sequence of train control
commands is shown as a UML sequence diagram.
Fig 1.17: A UML sequence diagram for a typical sequence of train control commands
The focus of the control bars shows the both the console and receiver run continuously. The packets
can be sent at any time—there is no global clock controlling when the console sends and the train
25
receives, we do not have to worry about detecting collisions among the packets. Set- inertia message
will sent infrequently. Most of the message commands are speed commands. When a train receives
speed command, it will speed up and slow down the train smoothly at rate determined by the set-
inertia command. An emergency stop command may be received, which causes the train receiver to
immediately shut down the train motor.
We can model the commands in UML with two level class hierarchy as shown in the Fig1.18. Here
we have one base class command, there are three sub classes set-speed, set-inertia, Estop, derived
from base class. One for each specific type of command.
We now need to model the train control system itself. There are clearly two major subsystems: the
control-box and the train board component. Each of these subsystems has its own internal structure.
Fig 1.19: Collaboration diagram for major sub systems of the train controller system
The console and receiver are each represented by objects: the console sends a sequence of packets to
the train receiver, as illustrated by the arrow. The notation on the arrow provides both the type of
26
message sent and its sequence in a flow of messages .we have numbered the arrow’s messages as
1…n .
Let’s break down the console and receiver into three major components.
• Console:
• Format messages
• Transmit messages.
• Train receiver:
• receive message
• interpret message
• Panel: Describes the console front panel, which contains analog knobs and interface
hardware to interface to the digital parts of the system.
• Formatter: It knows how to read the panel knobs and creates bit stream for message.
27
Fig 1.21: Train control classes
• Receiver: It knows how to turn the analog signal on the track into digital form.
• Controller: Interprets received commands and figures out how to control the motor.
• Motor interface: Generates the analog signals required to control the motor.
• Detector *: Detect the analog signal on the track and converts them into the digital
commands
• Pulser *: Converts the digital commands into the analog signal required to control the motor.
28
DETAILED SPECIFICATION:
Conceptual specification that defines the basic classes, let’s refine it to create a more detailed
specification. We won’t make a complete specification. But we will add details to the class. We can
now fill in the details of the conceptual specification. Sketching out the spec first helps us understand
the basic relationships in the system.
We need to define the analog components in a little more detail because there characteristics will
strongly influence the formatter and controller. Fig1.22, 23, 24, 25 shows a little more detail than Fig
1.20, Fig1.21. It includes attributes and behavior of these classes. The panel has three knobs:
Fig 1.22: classes describing analog physical objects in the train control system
Fig 1.23: Class diagram for analog physical objects in the train control system
Train number (which train is currently being controlled), speed and inertia. It also has emergency
stop. When we change train number settings, we also want to reset the other controls, so that the
previous train control settings are not used. To do this, Knobs* must provide a set-knobs() , that
allows the rest of the system to modify the knob settings.
29
Fig 1.24: Class diagram for formatter, controller
SEQUENCE DIAGRAM:
30
Fig 1.27: State diagram for the formatter operate behavior
The state diagram for a very simple version of the operator behavior of the formatter class is shown in
Fig1.27. This behavior watches the panel for activity: if the train number changes, it updates the panel
display. Otherwise it sends the required message.
Fig 1.28: Sequence diagram for a set-speed command received by the train
The operation of the controller class during the reception of a set speed command is shown in Fig1.28.
The controller’s operate behavior must execute several behavior to determine the nature of the
message. Once the speed command has been sent, it must send a sequence of commands to the motor
to smoothly change the train speed.
31
Fig1.30: state diagram for the panel-active behavior
32