You are on page 1of 81

Embedded Computing Systems

Unit 1
Text Books:
1. Wayne Wolf: Computers as Components, Principles of Embedded Computing Systems Design,
2nd Edition, Elsevier, 2008.
2. Shibu K V: Introduction to Embedded Systems, Tata McGraw Hill, 2009 (Chapters 10, 13)
Reference Books:
1. James K. Peckol: Embedded Systems, Acontemporary Design Tool, Wiley India, 2008
2. Tammy Neorgaard: Embedded Systems Architecture, Elsevier, 2005
By
Dr. K Satyanarayan Reddy
CiTECH, BLore 36.
UNIT 1: Embedded Computing (6 Hrs.)
Introduction, Complex Systems
and Microprocessors,
Embedded Systems Design
Process, Formalism for
System design Design
Example: Model Train
Controller.
August 6, 2014 ECS Lecture Notes: 7th Sem. CSE (VTU) By Dr. K. Satyanarayan Reddy 2
Introduction
COMPLEX SYSTEMS AND MICROPROCESSORS:
What is an Embedded Computer System?
it is any device that includes a Programmable
Computer but is not itself intended to be a
general-purpose computer.
Thus, a PC is not itself an Embedded Computing
System, although PCs are often used to build
embedded computing systems.
e.g. A Fax Machine or a Clock built from a
microprocessor is an embedded computing
system.
August 6, 2014 ECS Lecture Notes: 7th Sem. CSE (VTU) By Dr. K. Satyanarayan Reddy 3
Challenges: Many of the challenges encountered in the
design of an embedded computing system are not
related to Computer Engineering.
e.g.: The problems may be related to the field of
Mechanical or analog Electrical Engineering.
Embedding Computers: Computers have been
embedded into applications since the earliest days of
computing.
e.g.: Whirlwind, a computer designed at MIT in the late
1940s and early 1950s.
Whirlwind was also the first computer designed to
support Real-time operation and was originally
conceived as a mechanism for controlling an aircraft
simulator.
August 6, 2014 ECS Lecture Notes: 7th Sem. CSE (VTU) By Dr. K. Satyanarayan Reddy 4
Introduction contd.
A Microprocessor is a single-chip CPU. Very large scale
integration (VLSI).
The first microprocessor, the Intel 4004, was designed
for an embedded application, namely, a Calculator.
The Calculator was not a general-purpose computerit
merely provided basic arithmetic functions.
The HP-35 was the first handheld calculator to perform
transcendental (Trigonometric) functions.
It was introduced in 1972, and it used several chips to
implement the CPU, rather than a single-chip
microprocessor.
August 6, 2014 ECS Lecture Notes: 7th Sem. CSE (VTU) By Dr. K. Satyanarayan Reddy 5
Introduction contd.
Automobile designers started making use of the
microprocessor soon after single-chip CPUs became
available.
The most important use of microprocessors in automobiles
was to control the engine; determining when spark plugs
fire, controlling the fuel/air mixture, and so on.
Microprocessors are usually classified by their word size.
An 8-bit microcontroller is designed for low-cost
applications and includes on-board memory and I/O
devices;
A 16-bit microcontroller is often used for more
sophisticated applications that may require either longer
word lengths or off-chip I/O and memory; and
A 32-bit RISC microprocessor offers very high performance
for computation-intensive applications.
August 6, 2014 ECS Lecture Notes: 7th Sem. CSE (VTU) By Dr. K. Satyanarayan Reddy 6
Introduction contd.
There are many household uses of microprocessors.
The typical microwave oven has at least one
microprocessor to control oven operation.
Many houses have advanced Thermostat Systems,
which change the temperature level at various
times during the day.
The modern camera is a prime example of the
powerful features that can be added under
microprocessor control.
Digital television makes extensive use of embedded
processors.
August 6, 2014 ECS Lecture Notes: 7th Sem. CSE (VTU) By Dr. K. Satyanarayan Reddy 7
Introduction contd.
Application Example: BMW 850i brake and stability
control system.
The BMW 850i was introduced with a sophisticated
system for controlling the wheels of the car.
An antilock brake system (ABS) reduces skidding by
pumping the brakes.
August 6, 2014 ECS Lecture Notes: 7th Sem. CSE (VTU) By Dr. K. Satyanarayan Reddy 8
Introduction contd.
An Automatic Stability Control (ASC
T) system intervenes with the
engine during maneuvering to
improve the cars stability.
These systems actively control
critical systems of the car; as control
systems, they require inputs from
and output to the automobile.
Characteristics of Embedded Computing Applications
Functionality is important in both general-purpose computing and
embedded computing, but Embedded Applications must meet
many other constraints as well.
Embedded Computing Systems have to provide sophisticated
functionality:
Complex Algorithms: The operations performed by the
microprocessor may be very sophisticated.
e.g.: 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.
e.g.: The moving maps in Global Positioning System (GPS)
navigation are good examples of sophisticated user interfaces.
August 6, 2014 ECS Lecture Notes: 7th Sem. CSE (VTU) By Dr. K. Satyanarayan Reddy 9
The 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.
In other cases, missing a deadline does not create safety problems but does
create unhappy customers.
e.g.: Missed deadlines in printers, can result in scrambled pages.
Multirate: Not only must operations be completed by deadlines, but many
embedded computing systems have several real-time activities going on
simultaneously.
They may simultaneously control some operations that run at slow rates and
others that run at high rates.
e.g. Multimedia applications are prime examples of multirate behavior.
The audio and video portions of a multimedia stream run at very different rates,
but they must remain closely synchronized.
Failure to meet a deadline on either the audio or video portions spoils the
perception of the entire presentation.
August 6, 2014 ECS Lecture Notes: 7th Sem. CSE (VTU) By Dr. K. Satyanarayan Reddy 10
Characteristics of Embedded Computing Applications contd.
Costs of various sorts are also very important:
Manufacturing Cost: The total cost of building the
system is very important in many cases.
Manufacturing cost is determined by many factors,
including the type of microprocessor used, the
amount of memory required, and the types of I/O
devices.
Power and Energy: Power consumption directly
affects the cost of the hardware, since a larger power
supply may be necessary.
Energy consumption affects battery life, which is
important in many applications, as well as heat
consumption, which can be important even in
desktop applications.
August 6, 2014 ECS Lecture Notes: 7th Sem. CSE (VTU) By Dr. K. Satyanarayan Reddy 11
Characteristics of Embedded Computing Applications contd.
Why Use Microprocessors?
There are many ways to design a digital system:
custom logic, Field Programmable Gate Arrays
(FPGAs), and so on.
Why use microprocessors? There are two reasons:
Microprocessors are a very efficient way to
implement digital systems.
Microprocessors make it easier to design families
of products that can be built to provide various
feature sets at different price points and can be
extended to provide new features to keep up with
rapidly changing markets.
August 6, 2014 ECS Lecture Notes: 7th Sem. CSE (VTU) By Dr. K. Satyanarayan Reddy 12
There are two factors that work together to make
microprocessor-based designs fast.
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.
The overhead of interpreting instructions, can often be
hidden by clever utilization of parallelism within the CPU.
Second: Microprocessor manufacturers spend a great deal of
money to make their CPUs run very fast.
Large teams of designers are hired to tweak every aspect of
the microprocessor to make it run at the highest possible
speed.
August 6, 2014 ECS Lecture Notes: 7th Sem. CSE (VTU) By Dr. K. Satyanarayan Reddy 13
Why Use Microprocessors? Contd.
A microprocessor, can be used for many different
algorithms simply by changing the program it
executes.
Since so many modern systems make use of complex
algorithms and user interfaces.
To implement all the required functionality many
different custom logic blocks have to be designed.
Many of those blocks will often sit idle.
e.g.: The Processing Logic may sit idle when user
interface functions are performed.
Implementing several functions on a single processor
often makes much better use of the available
hardware budget.
August 6, 2014 ECS Lecture Notes: 7th Sem. CSE (VTU) By Dr. K. Satyanarayan Reddy 14
Why Use Microprocessors? Contd.
The programmability of microprocessors can be a substantial benefit
during the design process.
It allows program design to be from design of the hardware on
which programs will be run.
While one team is designing the board that contains the
microprocessor, I/O devices, memory etc., other teams can be
writing programs at the same time.
Equally important, programmability makes it easier to design
families of products.
In many cases, high-end products can be created simply by adding
code without changing the hardware.
This practice substantially reduces manufacturing costs. Even when
hardware must be redesigned for next-generation products, it may
be possible to reuse software, reducing development time and
cost.
August 6, 2014 ECS Lecture Notes: 7th Sem. CSE (VTU) By Dr. K. Satyanarayan Reddy 15
Why Use Microprocessors? Contd.
Challenges in Embedded Computing System Design
External constraints are the important source of
difficulty in Embedded System Design.
1. How much Hardware is needed?
Concern: There is a great deal of control over the
amount of computing power that needs to be applied
to the problem.
Besides the selection of the type of microprocessor
used, the amount of memory, the peripheral devices,
and more also has to be selected.
Since both the performance deadlines and
manufacturing cost constraints are to be met, 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.
August 6, 2014 ECS Lecture Notes: 7th Sem. CSE (VTU) By Dr. K. Satyanarayan Reddy 16
2. How are the Deadlines to be met?
The brute force way of meeting a deadline is to
speed up the hardware so that the program runs
faster. But this 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 programs speed may be
limited by the memory of the system.
August 6, 2014 ECS Lecture Notes: 7th Sem. CSE (VTU) By Dr. K. Satyanarayan Reddy 17
Challenges in Embedded Computing System Design contd.
How the Power Consumption is to be minimized?
In battery-powered applications, power consumption is
extremely important.
Even in nonbattery 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, but naively 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.
August 6, 2014 ECS Lecture Notes: 7th Sem. CSE (VTU) By Dr. K. Satyanarayan Reddy 18
Challenges in Embedded Computing System Design contd.
How to 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, it is desirable to be able to add features by
changing software. How can a machine be
designed which will provide the required
performance for software that havent yet been
written?
August 6, 2014 ECS Lecture Notes: 7th Sem. CSE (VTU) By Dr. K. Satyanarayan Reddy 19
Challenges in Embedded Computing System Design contd.
Does it really work?
Reliability is especially important in some applications, such as
safety-critical systems.
Another set of challenges comes from the characteristics of
the components and systems themselves.
Following are some of the 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.
A real machine may have to be run in order to
generate the proper data.
The timing of data is often important, meaning that the
testing of an embedded computer cannot be separated
from the machine in which it is embedded.
August 6, 2014 ECS Lecture Notes: 7th Sem. CSE (VTU) By Dr. K. Satyanarayan Reddy 20
Challenges in Embedded Computing System Design contd.
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 systems
operation.
One is forced to watch the values of electrical signals on the microprocessor bus
e.g.: To know what is going on inside the system.
Moreover, in real-time applications, it may not be easy to 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.
Generally code is compiled on one type of machine, such as a PC, and ported
onto the embedded system.
To debug the code, one has to rely on the programs that run on the PC or
workstation and then look inside the embedded system.
August 6, 2014 ECS Lecture Notes: 7th Sem. CSE (VTU) By Dr. K. Satyanarayan Reddy 21
Challenges in Embedded Computing System Design contd.
Performance in Embedded Computing
Embedded system designers, have a very clear
performance goal in mind: their program must meet
its Deadline.
At the heart of embedded computing, there is Real-
time Computing, which is the science and art of
programming to deadlines.
The program receives its input data; the deadline is the
time at which a computation must be finished.
If the program does not produce the required output
by the deadline, then the program does not work,
even if the output that it eventually produces is
functionally correct.
August 6, 2014 ECS Lecture Notes: 7th Sem. CSE (VTU) By Dr. K. Satyanarayan Reddy 22
In order to understand the Real-time behavior of an
embedded computing system, the system has to be
analyzed at several different levels of abstraction(Layers).
The system is seen as layers as follows:
CPU: The CPU clearly influences the behavior of the
program, particularly when the CPU is a pipelined
processor with a cache.
Platform: The platform includes the bus and I/O devices.
The platform components that surround the CPU are
responsible for feeding the CPU and can dramatically affect
its performance.
Program: Programs are very large and the CPU sees only a
small window of the program at a time. The structure of
the entire program must consider to determine its overall
behavior.
August 6, 2014 ECS Lecture Notes: 7th Sem. CSE (VTU) By Dr. K. Satyanarayan Reddy 23
Performance in Embedded Computing contd.
Task: Generally several programs are run
simultaneously on a CPU, creating a Multitasking
system.
The tasks interact with each other in ways that
have profound implications for performance.
Multiprocessor: Many embedded systems have
more than one processor; they may include
multiple programmable CPUs as well as
accelerators.
Once again, the interaction between these
processors also add more complexity to the
analysis of overall system performance.
August 6, 2014 ECS Lecture Notes: 7th Sem. CSE (VTU) By Dr. K. Satyanarayan Reddy 24
Performance in Embedded Computing contd.
2. THE EMBEDDED SYSTEM DESIGN PROCESS
Following figure summarizes the major steps in the
embedded system design process.
In this top-down view, the system Requirements are
considered.
August 6, 2014 ECS Lecture Notes: 7th Sem. CSE (VTU) By Dr. K. Satyanarayan Reddy 25
Major levels of Abstraction in the Design Process.
Specification: It comprises of creating a more detailed
description of what is needed.
Architecture: The specification states only how the
system behaves, not how it is built. The details of the
systems internals begin to take shape when the
architecture is developed, which gives the system
structure in terms of large components.
Components: Once the needed components are known,
these components can be designed, including both
software modules and any specialized hardware that is
needed.
Integration: Based on those components, a complete
system can finally be built.
The major goals of the design also need to be
considered :
Manufacturing Cost;
Performance (both overall speed and deadlines);
Power Consumption.
Also the tasks needed to be performed at every step in
the design process are to be considered.
At each step in the design, following details are added:
Analyze the design at each step to determine how the
specifications can be met.
Then Refine the design to add detail.
Verify the design to ensure that it still meets all system
goals, such as cost, speed, and so on.
August 6, 2014 ECS Lecture Notes: 7th Sem. CSE (VTU) By Dr. K. Satyanarayan Reddy 26
THE EMBEDDED SYSTEM DESIGN PROCESS contd.
Requirements
The initial stages of the design process capture this
information for use in creating the architecture and
components. There are two phases:
First: Gather an informal description from the
customers known as requirements, and
Second: Refine the requirements into a specification
that contains enough information to begin designing
the system architecture.
Requirements may be Functional or Nonfunctional.
The basic functionality of the embedded system must
be captured, but functional description is often not
sufficient.
August 6, 2014 ECS Lecture Notes: 7th Sem. CSE (VTU) By Dr. K. Satyanarayan Reddy 27
Typical Non Functional 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.
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.
e.g.: A handheld device typically has tight requirements on both size and
weight that can ripple through the entire system design.
Power Consumption: Power is important aspect 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;
the customer is unlikely to be able to describe the allowable wattage.
August 6, 2014 ECS Lecture Notes: 7th Sem. CSE (VTU) By Dr. K. Satyanarayan Reddy 28
Requirements contd.
Sample Requirements Form
Type of Requirements Interpretation
Name Giving a simple name to the project simplifies talking about it to other people also it
crystallize the purpose of the machine.
Purpose This should be a brief one- or two-line description of what the system is supposed to
do in short it is the essence of the system.
Inputs Inputs & Outputs are more complex. The inputs and outputs to the system may
contain the details such as:
Types of data: Analog electronic signals? Digital data? Mechanical inputs?
Data characteristics: Periodically arriving data, such as digital audio samples?
Occasional user inputs? How many bits per data element?
Types of I/O devices: Buttons? Analog/digital converters? Video displays?
Outputs
Functions When the system receives an input, what does it do? How do user interface inputs
affect these functions? How do different functions interact?
Performance The computations must be performed within a certain time frame. It is essential that
the performance requirements be identified early to ensure that the system works
properly.
Manufacturing Cost This includes primarily the cost of the hardware components.
Power
It depends on whether the machine will be battery powered or plugged into the
wall. Battery-powered machines must be much more careful about how energy is
spent?
Physical size and Weight The physical size of the system helps in guiding certain architectural decisions.
August 6, 2014 ECS Lecture Notes: 7th Sem. CSE (VTU) By Dr. K. Satyanarayan Reddy 29
e.g.: Requirements analysis of a GPS moving map
August 6, 2014 ECS Lecture Notes: 7th Sem. CSE (VTU) By Dr. K. Satyanarayan Reddy 30
Specification
Specification serves as the contract between the
customer and the architects.
The Specification must be carefully written so that it
accurately reflects the CUSTOMERS REQUIREMENTS
so that it 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.
Designers can run into several different types of
problems caused by unclear specifications.
August 6, 2014 ECS Lecture Notes: 7th Sem. CSE (VTU) By Dr. K. Satyanarayan Reddy 31
e.g. Specification
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.
August 6, 2014 ECS Lecture Notes: 7th Sem. CSE (VTU) By Dr. K. Satyanarayan Reddy 32
Architecture Design
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.
The creation of the architecture is the first phase of
what many designers think of as design.
August 6, 2014 ECS Lecture Notes: 7th Sem. CSE (VTU) By Dr. K. Satyanarayan Reddy 33
e.g. Block Diagram for the Moving Map.
The diagram below describes how to implement the functions
described in the specification.
Wherein we need to search the topographic database and to
render (i.e., draw) the results for the display.
These functions are chosen to be separate so that they can be
executed in parallel; performing rendering separately from
searching the database may help us update the screen more
fluidly.
August 6, 2014 ECS Lecture Notes: 7th Sem. CSE (VTU) By Dr. K. Satyanarayan Reddy 34
After an INITIAL ARCHITECTURE design which does not contain too many
implementation details, the system block diagram is refined into two block
diagrams: 1. HARDWARE and 2. SOFTWARE as shown in figure below.
The HARDWARE BLOCK DIAGRAM clearly shows that there is one central CPU
surrounded by memory and I/O devices.
In particular, there are 2 memories: a FRAME BUFFER for the pixels to be displayed
and a separate PROGRAM / DATA MEMORY for general use by the CPU.
August 6, 2014 ECS Lecture Notes: 7th Sem. CSE (VTU) By Dr. K. Satyanarayan Reddy 35
In the SOFTWARE BLOCK DIAGRAM a TIMER
is added to control the buttons on the user
interface are read and data onto the screen
is rendered.
More detail are required, such as where
units in the software block diagram will be
executed in the hardware block diagram and
when operations will be performed in time.
Architecture Design contd.
Note: Architectural descriptions must be designed to
satisfy both Functional and
Nonfunctional requirements.
Designing Hardware and Software Components
The architectural description gives information about
components that are need.
In general the components will include both
HARDWAREFPGAs (Field Programmable Gate
Array), Boards, and so on and SOFTWARE modules.
Some of the components will be ready-made like the
CPU, memory chips and many other components.
Some components will have to be designed from
scratch by the Engineers, and a lot of custom
programming has to be done to ensure that the
system runs properly in real time and that it does not
take up more memory space than allowed.
August 6, 2014 ECS Lecture Notes: 7th Sem. CSE (VTU) By Dr. K. Satyanarayan Reddy 36
In the moving map, the GPS receiver is a good example of a specialized component
that will nonetheless be a predesigned, standard component.
Standard software modules can also be used.
One good example is the Topographic Database. Standard topographic databases
exist, also standard routines can also be used to access the database; not only
the data is in a predefined format, but it is in a highly compressed form to save
storage.
Using standard software for these access functions not only saves the design time,
but it may give a faster implementation for specialized functions such as the
Data Decompression phase.
e.g. of Custom made H/W & S/W: The power consumption of the Moving Map
Software. To develop S/W to minimize power when data is read from and
written onto memory.
Since memory accesses are a major source of power consumption, memory
transactions must be carefully planned to avoid reading the same data several
times.
August 6, 2014 ECS Lecture Notes: 7th Sem. CSE (VTU) By Dr. K. Satyanarayan Reddy 37
e.g. Designing Hardware and Software Components
System Integration
Usually this phase consists of a lot more than just plugging all the
components together and relax.
Bugs are found during system integration, and good planning helps to
find the bugs quickly.
By building up the system in phases and running properly chosen tests,
bugs can be found more easily.
If only a few modules are debugged at a time, the simple bugs are more
likely to be uncovered and can be easily recognized.
To uncover the more complex or obscure bugs that can be identified
only a hard workout has to be given to the system.
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 compared to the desktop systems.
Bugs are to be eliminated during design phase.
August 6, 2014 ECS Lecture Notes: 7th Sem. CSE (VTU) By Dr. K. Satyanarayan Reddy 38
FORMALISMS FOR SYSTEM DESIGN
For creating Requirements and Specifications, the
system Architecture, designing code, and designing
tests; It is often helpful to conceptualize these tasks
through diagrams.
There is a visual language that can be used for capturing
all these design tasks it is called as Unified Modeling
Language (UML) [Boo99,Pil05].
UML was designed to be useful at many levels of
abstraction in the design process.
UML is useful because it encourages design by
successive refinement and progressively adding detail
to the design.
UML is an object-oriented modeling language.
August 6, 2014 ECS Lecture Notes: 7th Sem. CSE (VTU) By Dr. K. Satyanarayan Reddy 39
Two important features of the Object Oriented Design
are:
It encourages the design to be described as a number of
interacting objects, rather than a few large monolithic
blocks of code.
At least some of those objects will correspond to real
pieces of software or hardware in the system.
OBJECT ORIENTED (often abbreviated OO) 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.
August 6, 2014 ECS Lecture Notes: 7th Sem. CSE (VTU) By Dr. K. Satyanarayan Reddy 40
FORMALISMS FOR SYSTEM DESIGN contd.
Structural Description
Structural Description means the basic
components of the system.
The principal component of an Object Oriented
Design is the OBJECT.
An OBJECT includes a set of Attributes that
define its internal state.
These Attributes, usually become variables or
constants held in a data structure, on their
implementation through a programming
Language.
August 6, 2014 ECS Lecture Notes: 7th Sem. CSE (VTU) By Dr. K. Satyanarayan Reddy 41
An object describing a display (such as a CRT screen) is shown in UML notation
in Figure below.
The text in the folded-corner page icon is a NOTE; it DOES NOT correspond to
an object in the system and only serves as a comment.
The attribute is, in this case, an array of pixels that holds the contents of the
display.
The object is identified in two ways: It has a unique name, and it is a member of
a class.
The name is underlined to show that this is a description of an object and not of
a class.
August 6, 2014 ECS Lecture Notes: 7th Sem. CSE (VTU) By Dr. K. Satyanarayan Reddy 42
Structural Description contd.
Comment
A class is a form of type definitionall objects derived from the same
class have the same characteristics, although their attributes may
have different values.
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.
August 6, 2014 ECS Lecture Notes: 7th Sem. CSE (VTU) By Dr. K. Satyanarayan Reddy 43
Structural Description contd.
Comment
A class defines both the Interface for a particular
type of object and that objects
Implementation.
When an object is used, its attributes can not be
directly manipulatedthe objects state can
only be read or modified through the
operations that define the interface to the
object.
The proper interface must provide ways to access
the objects state as well as ways to update the
state.
The objects interface need to be general enough
for making full use of its capabilities.
August 6, 2014 ECS Lecture Notes: 7th Sem. CSE (VTU) By Dr. K. Satyanarayan Reddy 44
Structural Description contd.
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 one to define one class in terms
of another.
August 6, 2014 ECS Lecture Notes: 7th Sem. CSE (VTU) By Dr. K. Satyanarayan Reddy 45
Structural Description contd.
Unified Modeling Language, allows
one class to be defined in terms
of another.
An example is shown in adjacent
Figure, where two particular types
of displays have been derived.
The first, BW_display, describes a
blackand-white display.
This does not requires one to add
new attributes or operations, but
both can be specialized to work
on one-bit pixels.
The second, Color_map_display, uses
a graphic device known as a color
map to allow the user to select
from a large number of available
colors even with a small number
of bits per pixel.
August 6, 2014 ECS Lecture Notes: 7th Sem. CSE (VTU) By Dr. K. Satyanarayan Reddy 46
Structural Description contd.
Derived classes as a form
of generalization in UML
A derived class inherits all the attributes and
operations from its base class.
In this class, Display is the base class for the two
derived classes.
A derived class is defined to include all the
attributes of its base class.
This relation is transitive if Display were derived
from another class, both BW_display and
Color_map_display would inherit all the attributes
and operations of Displays base class as well.
August 6, 2014 ECS Lecture Notes: 7th Sem. CSE (VTU) By Dr. K. Satyanarayan Reddy 47
Structural Description contd.
Unified Modeling Language
considers inheritance to be
one form of generalization.
A generalization relationship is
shown in a UML diagram as
an arrow with an open
(unfilled) arrowhead.
Both BW_display and
Color_map_display are
specific versions of Display,
so Display generalizes both
of them.
UML also allows Multiple
Inheritance to be defined, in
which a class is derived from
more than one base class.
An example of multiple
inheritance is shown in
Figure below:
August 6, 2014 ECS Lecture Notes: 7th Sem. CSE (VTU) By Dr. K. Satyanarayan Reddy 48
Structural Description contd.
Multiple Inheritance in UML
A LINK describes a
relationship between
objects; ASSOCIATION is
to link as class is to
object.
Links are needed
because objects often
do not stand alone;
associations let us
capture type
information about these
links.
Adjacent Figure shows
examples of links and an
association.
August 6, 2014 ECS Lecture Notes: 7th Sem. CSE (VTU) By Dr. K. Satyanarayan Reddy
49
Structural Description
contd.
Links and Association.
When the actual objects in the system are
considered, there is a set of messages which keep
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.
Typically, when a certain
combination of elements
are used in an object or
class many times then
these patterns can be
given names, which are
called stereotypes in UML.
A stereotype name is written
in the form <<signal>>.
Adjacent Figure shows a
stereotype for a signal,
which is a communication
mechanism.
August 6, 2014 ECS Lecture Notes: 7th Sem. CSE (VTU) By Dr. K. Satyanarayan Reddy 50
Structural Description contd.
Signal, call, and time-out
events in UML
One way to specify the
behavior of an operation is a
State Machine.
Adjacent Figure shows UML
states; the transition
between two states is shown
by a skeleton arrow.
These state machines will not
rely on the operation of a
clock, as in hardware; rather,
changes from one state to
another are triggered by the
occurrence of events.
An event is some type of action.
The event may originate
outside the system, such as a
user pressing a button.
It may also originate inside, such
as when one routine finishes
its computation and passes the
result on to another routine.
August 6, 2014 ECS Lecture Notes: 7th Sem. CSE (VTU) By Dr. K. Satyanarayan Reddy 51
Behavioral Description
A state and transition in UML
There are three types of events defined by
UML, as illustrated in adjacent Figure.
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 events existence.
Because it is an object, a signal may have
parameters that are passed to the signals
receiver.
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
implemented with an external timer.
August 6, 2014
ECS Lecture Notes: 7th Sem. CSE (VTU) By Dr. K. Satyanarayan Reddy
52
Behavioral Description contd.
Signal, Call, and Time-out events in UML
Consider a simple STATE
MACHINE specification to
understand the semantics
of UML state machines.
A State Machine for an
operation of the display is
shown in adjacent Figure.
The start and stop states are
special states that help us
to organize the flow of the
state machine. The states
in the state machine
represent different
conceptual operations.
August 6, 2014 ECS Lecture Notes: 7th Sem. CSE (VTU) By Dr. K. Satyanarayan Reddy 53
Behavioral Description contd.
A state machine specification in UML
A sequence diagram can be
created, like the one for a
mouse click scenario shown in
adjacent Figure.
A Sequence Diagram is 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.
Note: It is not convenient for
showing a number of mutually
exclusive possibilities.
August 6, 2014 ECS Lecture Notes: 7th Sem. CSE (VTU) By Dr. K. Satyanarayan Reddy 54
Behavioral Description contd.
A Sequence Diagram in UML
August 6, 2014 ECS Lecture Notes: 7th Sem. CSE (VTU) By Dr. K. Satyanarayan Reddy 55
Case Study : MODEL TRAIN CONTROLLER
Consider a simple system, a Model Train
Controller, which is illustrated in adjacent Figure .
The user sends messages to the train with a
control box attached to the tracks. The control
box has controls such as a Throttle, Emergency
Stop button, and so on.
Since the train receives its electrical power from
the two rails of the track, the control box can
send signals to the train over the tracks by
modulating the power supply voltage.
The control panel sends packets over the tracks to
the receiver on the train.
The train includes analog electronics to sense the
bits being transmitted and a control system to set
the train motors speed and direction based on
those commands. 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.
Analyzing the Requirements for the Train Control System
Here is a basic set of requirements for the system:
The console shall be able to control up to eight trains on a single track.
The speed of each train shall be controllable by a Throttle to at least 63 different
levels in each direction (forward and reverse).
There shall be an inertia control that shall allow the user to adjust the
responsiveness of the train to commanded changes in speed.
Higher inertia means that the train responds more slowly to a change in the
throttle, simulating the inertia of a large train. The inertia control will provide at
least eight different levels.
There shall be an emergency stop button.
An Error Detection Scheme will be used to transmit messages.
August 6, 2014 ECS Lecture Notes: 7th Sem. CSE (VTU) By Dr. K. Satyanarayan Reddy 56
Digital Command Control (DCC)
The DCC standard is given in two documents:
Standard S-9.1, the DCC Electrical Standard, defines how
bits are encoded on the rails for transmission.
Standard S-9.2, the DCC Communication Standard, defines
the packets that carry information.
The DCC standard does not specify many aspects of a
DCC train system.
It doesnt define the control panel, the type of
microprocessor used, the programming language to
be used, or many other aspects of a real model train
system.
The standard concentrates on those aspects of system
design that are necessary for INTEROPERABILITY.
August 6, 2014 ECS Lecture Notes: 7th Sem. CSE (VTU) By Dr. K. Satyanarayan Reddy 57
The Electrical Standard deals with Voltages and Currents on the track.
The Signal Encoding System should not interfere with power transmission either to
DCC or non-DCC locomotives.
A key requirement is that the data signal should not change the DC value of the
rails.
The data signal swings between two voltages around the power supply voltage.
As shown in Figure 1.15, bits are encoded in the time between transitions, not by
voltage levels. A 0 is at least 100 s while a 1 is nominally 58 s.
The durations of the high (above nominal voltage) and low (below nominal voltage)
parts of a bit are equal to keep the DC value constant.
The specification also gives the allowable variations in bit times that a conforming
DCC receiver must be able to tolerate.
August 6, 2014 ECS Lecture Notes: 7th Sem. CSE (VTU) By Dr. K. Satyanarayan Reddy 58
Digital Command Control (DCC) contd.
Bit encoding in DCC
The DCC Communication Standard describes how
bits are combined into packets and the meaning
of some important packets.
Some packet types are left undefined in the
standard but typical uses are given in
Recommended Practices documents.
The basic packet format can be written as a regular
expression:
PSA(sD) + E (1.1)
August 6, 2014 ECS Lecture Notes: 7th Sem. CSE (VTU) By Dr. K. Satyanarayan Reddy 59
Digital Command Control (DCC) contd.
In this regular expression:
P is the preamble, which is a sequence of at least 10, 1 bits.
The command station should send at least 14 of these 1 bits, some of
which may be corrupted during transmission.
S is the packet start bit. It is a 0 bit.
A is an address data byte that gives the address of the unit, with the
most significant bit of the address transmitted first.
An address is eight bits long.
The addresses 00000000, 11111110, and 11111111 are reserved.
s is the data byte start bit, which, like the packet start bit, is a 0.
D is the data byte, which includes eight bits.
A data byte may contain an address, instruction, data, or error
correction information.
E is a packet end bit, which is a 1 bit.
A packet includes one or more data byte start bit/data byte
combinations.
Note: The address data byte is a specific type of data byte.
August 6, 2014 ECS Lecture Notes: 7th Sem. CSE (VTU) By Dr. K. Satyanarayan Reddy 60
Digital Command Control (DCC) contd.
A BASELINE packet is the minimum packet that must be accepted by all DCC
implementations.
A BASELINE packet has three data bytes:
An address data byte that gives the intended receiver of the packet;
The instruction data byte provides a basic instruction; and
An error correction data byte is used to detect and correct transmission
errors.
The instruction data byte carries several pieces of information.
Bits 03 provide a 4-bit speed value.
Bit 4 has an additional speed bit, which is interpreted as the least significant speed
bit.
Bit 5 gives direction, with 1 for forward and 0 for reverse.
Bits 78 are set at 01 to indicate that this instruction provides speed and direction.
The error correction data byte is the bitwise exclusive OR of the address and
instruction data bytes.
The standard says that the command unit should send packets frequently since a
packet may be corrupted. Packets should be separated by at least 5 ms.
August 6, 2014 ECS Lecture Notes: 7th Sem. CSE (VTU) By Dr. K. Satyanarayan Reddy 61
Digital Command Control (DCC) contd.
Conceptual Specification
A Conceptual Specification allows one to understand
the system a better way.
This specification is simple and allows to cover some
basic concepts in system design.
A Train Control System turns Commands into Packets.
A Command comes from the command unit while a
packet is transmitted over the rails.
Commands and packets may not be generated in a 1-to-
1 ratio.
As per the DCC standard; Command units should resend
packets in case a packet is dropped during
transmission.
August 6, 2014 ECS Lecture Notes: 7th Sem. CSE (VTU) By Dr. K. Satyanarayan Reddy 62
There are 2 major subsystems:
The Command unit and
the Train Board Component
as shown in Figure 1.
Each of these subsystems has
its own internal structure.
The basic relationship between
them is illustrated in Figure
2.
This figure shows a UML
Collaboration Diagram;
August 6, 2014 ECS Lecture Notes: 7th Sem. CSE (VTU) By Dr. K. Satyanarayan Reddy 63
Conceptual Specification contd.
Class diagram for the Train Controller Messages
Figure 1
UML collaboration diagram for major
subsystems of the train controller system
Figure 2
The Command unit and Receiver are each
represented by OBJECTS; the command unit sends
a sequence of packets to the trains receiver, as
illustrated by the arrow.
The notation on the arrow provides both the type of
message sent and its sequence in a flow of
messages; since the console sends all the
messages, the arrows messages have been
numbered as 1..n.
Those messages are carried over the track.
Since the track is not a computer component and is
purely passive, it does not appear in the diagram.
August 6, 2014 ECS Lecture Notes: 7th Sem. CSE (VTU) By Dr. K. Satyanarayan Reddy 64
Conceptual Specification contd.
Next Step of Design
Now break down the Command Unit and Receiver into their major components.
The console needs to perform three functions:
- read the state of the front panel on the command unit,
- format messages, and
- transmit messages.
The train receiver must also perform three major functions:
- receive the message,
- interpret the message (taking into account the current speed, inertia setting, etc.),and
- actually control the motor.
The UML class diagram is shown in Figure in next slide.
It shows the console class using 3 classes, one for each of its major components.
These classes must define some behaviors, and the basic characteristics of these classes are:
The Console class describes the command units front panel, which contains the
analog knobs and hardware to interface to the digital parts of the system.
The Formatter class includes behaviors that know how to read the panel knobs and
creates a bit stream for the required message.
The Transmitter class interfaces to analog electronics to send the message along the
track.
August 6, 2014 ECS Lecture Notes: 7th Sem. CSE (VTU) By Dr. K. Satyanarayan Reddy 65
A UML Class Diagram for the Train Controller showing the composition of the subsystems
August 6, 2014 ECS Lecture Notes: 7th Sem. CSE (VTU) By Dr. K. Satyanarayan Reddy 66
Next Step of Design contd.
There will be one instance of the Console class and one instance of each of the component
classes, as shown by the numeric values at each end of the relationship links.
Some special classes which represent Analog Components, ending the name of each with an
asterisk:
Knobs* describes the actual analog knobs, buttons, and levers on the control panel.
Sender* describes the analog electronics that send bits along the track.
Likewise, the Train makes use of three other classes that define its components:
The Receiver class knows how to turn the analog signals on the track into digital form.
The Controller class includes behaviors that interpret the commands and figures out
how to control the motor.
The Motor interface class defines how to generate the analog signals required to
control the motor.
Two classes are defined to represent Analog Components:
Detector* detects analog signals on the track and converts them into digital form.
Pulser* turns digital commands into the analog signals required to control the motor
speed.
August 6, 2014 ECS Lecture Notes: 7th Sem. CSE (VTU) By Dr. K. Satyanarayan Reddy 67
Next Step of Design contd.
Detailed Specification
At this point, the analog components need to be defined in more
detail because their characteristics will strongly influence the
Formatter and Controller.
Figure below shows a class diagram for these classes; it includes
attributes and behaviors of these classes.
The Panel has three knobs: train number (which train is currently
being controlled), speed (which can be positive or negative), and
inertia. It also has one button for emergency-stop.
August 6, 2014 ECS Lecture Notes: 7th Sem. CSE (VTU) By Dr. K. Satyanarayan Reddy 68
Classes describing analog physical
objects in the Train Control System
When the train number settings are changed, the other
controls are also to be reset to the proper values for
that train so that the previous trains control settings
are not used to change the current trains settings.
To do this, Knobs* must provide a set-knobs behavior
that allows the rest of the system to modify the knob
settings.
The motor system takes its motor commands in two
parts.
The Sender and Detector classes are relatively simple:
They simply put out and pick up a bit, respectively.
August 6, 2014 ECS Lecture Notes: 7th Sem. CSE (VTU) By Dr. K. Satyanarayan Reddy 69
Detailed Specification contd.
To understand the Pulser class, refer Figure below, wherein the speed of
electric motors is commonly controlled using pulse-width modulation:
Power is applied in a pulse for a fraction of some fixed interval, with
the fraction of the time that power is applied determining the speed.
The digital interface to the motor system specifies that pulse width as an
integer, with the maximum value being maximum engine speed.
A separate binary value controls direction.
Note: The motor control takes an unsigned speed with a separate
direction, while the panel specifies speed as a signed integer, with
negative speeds corresponding to reverse direction.
August 6, 2014 ECS Lecture Notes: 7th Sem. CSE (VTU) By Dr. K. Satyanarayan Reddy 70
Detailed Specification contd.
Figure below shows the classes for the panel and motor interfaces.
These classes form the software interfaces to their respective physical devices.
The Panel class defines a behavior for each of the controls on the panel;
NOTE: An internal variable for each control have not been defined since their values
can be read directly from the physical device, but a given implementation may
choose to use internal variables.
The New-settings behavior uses the set-knobs behavior of the Knobs* class to
change the knobs settings whenever the train number setting is changed.
The MOTOR-INTERFACE defines an attribute for speed that can be set by other
classes.
The Controllers job is to incrementally adjust the motors speed to provide smooth
acceleration and deceleration.
August 6, 2014 ECS Lecture Notes: 7th Sem. CSE (VTU) By Dr. K. Satyanarayan Reddy 71
Detailed Specification contd.
Class diagram for the Panel
and Motor interface.
The Transmitter and Receiver classes are shown in Figure below.
They provide the software interface to the physical devices that send
and receive bits along the track.
The Transmitter provides a distinct behavior for each type of message
that can be sent; it internally takes care of formatting the message.
The Receiver class provides a read-cmd behavior to read a message
off the tracks.
August 6, 2014 ECS Lecture Notes: 7th Sem. CSE (VTU) By Dr. K. Satyanarayan Reddy 72
Detailed Specification contd.
The Formatter class is shown in Figure below. The formatter holds the current
control settings for all of the trains.
The send-command method is a utility function that serves as the interface to the
transmitter.
The Operate function performs the basic actions for the object.
At this point, only a simple specification is needed, which states that the formatter
repeatedly reads the panel, determines whether any settings have changed, and
sends out the appropriate messages.
The panel-active behavior returns true whenever the panels values do not
correspond to the current values.
August 6, 2014 ECS Lecture Notes: 7th Sem. CSE (VTU) By Dr. K. Satyanarayan Reddy 73
Detailed Specification contd.
Class diagram for the Formatter class
The role of the formatter during the panels operation is illustrated by
the sequence diagram of Figure below.
The figure shows two changes to the knob settings: 1
st
to the
Throttle, Inertia, or Emergency Stop; 2
nd
to the Train Number.
August 6, 2014 ECS Lecture Notes: 7th Sem. CSE (VTU) By Dr. K. Satyanarayan Reddy 74
Detailed Specification contd.
Sequences diagram for transmitting a control input
The panel is called periodically by the Formatter to
determine if any control settings have changed.
If a setting has changed for the current train, the
formatter decides to send a command, issuing a
Send-command behavior to cause the transmitter to
send the bits.
Because transmission is serial, it takes a noticeable
amount of time for the Transmitter to finish a
command; in the meantime, the Formatter continues
to check the panels control settings.
If the train number has changed, the formatter must
cause the knob settings to be reset to the proper
values for the new train.
August 6, 2014 ECS Lecture Notes: 7th Sem. CSE (VTU) By Dr. K. Satyanarayan Reddy 75
Detailed Specification contd.
The state diagram for a very simple version of the operate behavior of
the Formatter class is shown in Figure below.
This behavior watches the panel for activity: If the train number
changes, it updates the panel display; otherwise, it causes the
required message to be sent.
August 6, 2014 ECS Lecture Notes: 7th Sem. CSE (VTU) By Dr. K. Satyanarayan Reddy 76
Detailed Specification contd.
State diagram for the Formatter operate behavior
The Adjacent Figure
shows a state diagram
for the panel-active
behavior.
August 6, 2014 ECS Lecture Notes: 7th Sem. CSE (VTU) By Dr. K. Satyanarayan Reddy 77
Detailed Specification contd.
The definition of the trains
Controller class is shown in
Figure 1.
The Operate behavior is called
by the receiver when it gets
a new command; operate
looks at the contents of the
message and uses the issue-
command behavior to
change the speed, direction,
and inertia settings as
necessary.
A specification for operate is
shown in Figure 2.
August 6, 2014 ECS Lecture Notes: 7th Sem. CSE (VTU) By Dr. K. Satyanarayan Reddy 78
Class diagram for the Controller class
State diagram for the Controller operate behavior
Figure 1
Figure 2
Detailed Specification contd.
The operation of the
Controller class during the
reception of a set-speed
command is illustrated in
Adjacent Figure.
The Controllers operate
behavior must execute
several behaviors to
determine the nature of
the message.
Once the speed command
has been parsed, it must
send a sequence of
commands to the motor to
smoothly change the
trains speed.
August 6,
2014
ECS Lecture Notes: 7th Sem. CSE (VTU) By Dr. K. Satyanarayan Reddy
79
There are three important issues.
First, the number of bits used need to be specified to determine the message type.
three bits are chosen, since that gives five unused message codes.
Second, An information about the length of the data fields needs to be included, which is
determined by the resolution for speeds and inertia set by the requirements.
Third, the error correction mechanism needs to be specified; a single-parity bit is chosen for
being used.
The classes can be updated to provide this extra information as shown in Figure below.
August 6, 2014 ECS Lecture Notes: 7th Sem. CSE (VTU) By Dr. K. Satyanarayan Reddy 80
Detailed Specification contd.
Refined class diagram for the Train
Controller commands
THANK YOU
August 6, 2014 ECS Lecture Notes: 7th Sem. CSE (VTU) By Dr. K. Satyanarayan Reddy 81

You might also like