EC8791-Embedded and Real Time Systems UNITS NOTES
EC8791-Embedded and Real Time Systems UNITS NOTES
com
om
Objectives:
To Understand the concept of embedded system design and analysis.
To learn the architecture of ARM processor.
To learn the Programming of ARM processor
To Expose the basic concepts of embedded programming.
.c
To Learn real time operating systems
UNIT I INTRODUCTION TO EMBEDDED SYSTEM DESIGN
Complex systems and microprocessors– Embedded system design process –Design example:
ul
Model train controller- Design methodologies- Design flows - Requirement Analysis –
Specifications-System analysis and architecture design – Quality Assurance techniques -
Designing with computing platforms – consumer electronics architecture – platform-level
performance analysis. pa
UNIT II ARM PROCESSOR AND PERIPHERALS
ARM Architecture Versions – ARM Architecture – Instruction Set – Stacks and Subroutines –
Features of the LPC 214X Family – Peripherals – The Timer Unit – Pulse Width Modulation
Unit – UART – Block Diagram of ARM9 and ARM Cortex M3 MCU.
jin
UNIT III EMBEDDED PROGRAMMING
Components for embedded programs- Models of programs- Assembly, linking and loading –
compilation techniques- Program level performance analysis – Software performance
optimization – Program level energy and power analysis and optimization – Analysis and
.re
Course Outcomes:
om
Summarize Architecture and programming of ARM processor.
Applying the concepts of embedded systems and its features.
Analyze various Real Time Operating system is used in Embedded System.
Design the flow &Techniques to develop Software for embedded system networks.
Analyze Real-time applications using embedded System Products.
.c
TEXT BOOK:
ul
(UNIT I, II, III, V)
2. Jane W.S.Liu,‖ Real Time Systems‖, Pearson Education, Third Indian Reprint, 2003.(UNIT
IV) pa
REFERENCES:
1. Lyla B.Das, ―Embedded Systems : An Integrated Approach‖ Pearson Education, 2013.
2. Jonathan W.Valvano, “Embedded Microcomputer Systems Real Time Interfacing”, Third
Edition Cengage Learning, 2012.
3. David. E. Simon, “An Embedded Software Primer”, 1st Edition, Fifth Impression, Addison-
jin
Wesley Professional, 2007.
4. Raymond J.A. Buhr, Donald L.Bailey, “An Introduction to Real-Time Systems- From Design
to Networking with C/C++”, Prentice Hall, 1999.
5. C.M. Krishna, Kang G. Shin, “Real-Time Systems”, International Editions, Mc Graw Hill 1997
6. K.V.K.K.Prasad, “Embedded Real-Time Systems: Concepts, Design & Programming”, Dream
.re
om
.c
ul
pa
1. Wayne Wolf, “Computers as Components – Principles of
jin
Embedded Computing System Design”, Third Edition “Morgan
Kaufmann Publisher (An imprint from Elsevier), 2012.
.re
w
w
w
www.rejinpaul.com
om
.c
UNIT I
ul
INTRODUCTION TO EMBEDDEDSYSTEM DESIGN
pa
Complex systems and microprocessors– Embedded system design process
–Design example: Model train controller- Design methodologies- Design
jin
flows - Requirement Analysis – Specifications-System analysis and
architecture design – Quality Assurance techniques - Designing with
computing platforms – consumer electronics architecture – platform-
.re
level performance analysis.
w
w
w
www.rejinpaul.com
om
Introduction--Embedded Systems
Introduction
An Embedded system is an electronic system that has a software and is
.c
embedded in computer hardware.
It is a system which has collection of components used to execute a task
ul
according to a program or commands given to it.
pa
Examples Microwave ovens, Washing machine, Telephone answering
machine system, Elevator controller system, Printers, Automobiles,
Cameras, etc.
jin
.re
w
w
w
www.rejinpaul.com
om
.c
ul
pa
jin
.re
w
w
w
www.rejinpaul.com
om
Components of Embedded system
Microprocessor
.c
Memory Unit(RAM,ROM)
ul
Input unit(Keyboard,mouse,scanner)
Output unit(pinters,video monitor)
pa
Networking unit(Ethernet card)
I/O units(modem)
jin
.re
w
w
w
www.rejinpaul.com
om
Real-Time Operating System (RTOS) is an operating system (OS)
intended to serve real-time applications that process data as it comes
.c
in, typically without buffer delays.
It schedules their working and execution by following a plan to control
ul
the latencies and to meet the dead lines.
pa
Modeling and evaluation of a real-time scheduling system concern is
on the analysis of the algorithm capability to meet a process deadline.
A deadline is defined as the time required for a task to be processed.
jin
.re
w
w
w
www.rejinpaul.com
om
Classification of Embedded system
1. Small scale Embedded system(8/16bit microcontroller)
.c
2. Medium Scale Embedded system (16/32bit microcontroller,
more tools like simulator, debugger)
ul
3. Sophisticated Embedded system (configurable processor and PAL)
pa
Embedded designer-
designer-skills
jin
Designer has a knowledge in the followings field,
Microcontrollers, Data comm., motors, sensors, measurements ,C
.re
programming, RTOS programming.
w
w
w
www.rejinpaul.com
om
1) COMPLEX SYSTEMS AND MICROPROCESSORS
Embedded(+)computer system
.c
Embedded system is a complex system
ul
It is any device that includes a programmable computer but is not
itself intended to be a general-purpose computer.
pa
jin
.re
w
w
w
www.rejinpaul.com
om
Computers have been embedded into applications since the earliest days of
computing.
.c
In 1940s and 1950sWhirlwind, designed a first computer to support real-time
operation for controlling an aircraft simulator.
ul
In 1970s The first microprocessor( Intel 4004) was designed for an embedded
application (Calculator), provided basic arithmetic functions.
pa
In 1972s The first handheld calculator (HP-35 ) was to perform
transcendental functions , so it used several chips to implement the CPU,
rather than a single-chip microprocessor.
jin
Designer faced critical problems to design a digital circuits to perform
operations like trigonometric functions using calculator.
But ,Automobile designers started making use of the microprocessor for to
.re
control the engine by determining when spark plugs fire, controlling the
fuel/air mixture
w
w
w
www.rejinpaul.com
om
Levels of Microprocessor
1. 8-bit microcontroller for low-cost applications and includes on-board
memory and I/O devices.
.c
2. 16-bit microcontroller used for more sophisticated applications that may
require either longer word lengths or off-chip I/O and memory.
ul
3. 32-bit RISC microprocessor offers very high performance for
computation-intensive applications.
pa
Microprocessor Uses/Applications
Microwave oven has at least one microprocessor to control oven operation
jin
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
.re
added under microprocessor control.
Digital television makes extensive use of embedded processors.
w
w
w
www.rejinpaul.com
om
Embedded Computing Applications
Ex
ExBMW 850i Brake and Stability Control System
The BMW 850i was introduced with a sophisticated system for controlling the
.c
wheels of the car.
Which uses An antilock brake system (ABS) and An automatic stability
ul
control (ASC +T) system.
pa
jin
.re
w
w
w
www.rejinpaul.com
om
1. An antilock brake system (ABS)
Reduces skidding by pumping the brakes.
.c
It is used to temporarily release the brake on a wheel when it rotates
too slowly—when a wheel stops turning, the car starts skidding and
ul
becomes hard to control.
It sits between the hydraulic pump, which provides power to the
pa
brakes.
It uses sensors on each wheel to measure the speed of the wheel.
The wheel speeds are used by the ABS system to determine how to vary
jin
the hydraulic fluid pressure to prevent the wheels from skidding.
.re
w
w
w
www.rejinpaul.com
om
2. An automatic stability control (ASC +T) system
It is used to control the engine power and the brake to improve the car’s
stability during maneuvers.
It controls four different systems: throttle, ignition timing, differential
.c
brake, and (on automatic transmission cars) gear shifting.
ul
It can be turned off by the driver, which can be important when
operating with tire snow chains.
pa
It has control unit has two microprocessors , one of which concentrates
on logic-relevant components and the other on performance-specific
components.
jin
The ABS and ASC+ T must clearly communicate because the ASC+ T
interacts with the brake system.
.re
w
w
w
www.rejinpaul.com
Characteristics of Embedded Computing
om
Applications
1. Complex algorithms-The microprocessor that controls an automobile engine
.c
must perform complicated filtering functions to optimize the performance of
the car while minimizing pollution and fuel utilization.
ul
2. User interface-The moving maps in Global Positioning System (GPS)
navigation are good examples of user interfaces.
pa
3. Real time-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 or missing a deadline does not create safety problems but
jin
does create unhappy customers
4. Multirate-Multimedia applications are examples of multirate behavior.
The audio and video portions of a multimedia stream run at very different
.re
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.
w
w
w
www.rejinpaul.com
om
5. Manufacturing cost- It is depends on the type of microprocessor used, the
amount of memory required, and the types of I/O devices.
.c
6. Power and energy-Power consumption directly affects the cost of the
hardware, since a larger power supply may be necessary.
ul
7. Energy consumption affects battery life, which is important in many
applications, as well as heat consumption, which can be important even in
pa
desktop applications.
jin
.re
w
w
w
www.rejinpaul.com
om
Microprocessors are a very efficient way to implement digital systems.
.c
It make it easier to design families of products with various feature at
different price points
ul
It can be extended to provide new features to keep up with rapidly
changing markets.
pa
It executes program very efficiently
It make their CPU run very fast
jin
Implementing several function on a single processor
.re
w
w
w
www.rejinpaul.com
om
computing?
.c
Real time performance is very less in PC because of
different architecture.
ul
It increases the complexity and price of components due to
pa
broad mix of computing requirements.
jin
.re
w
w
w
www.rejinpaul.com
om
Challenges in Embedded Computing System Design
1. How much hardware do we need?
To meet performance deadlines and manufacturing cost constraints, the choice of
.c
Hardware is important.
Too much hardware and it becomes too expensive.
ul
2. How do we meet deadlines?
pa
To speed up the hardware so that the program runs faster. But the system more
expensive.
It is also entirely possible that increasing the CPU clock rate may not make
jin
enough difference to execution time, since the program’s speed may be limited by
the memory system.
3. How do we minimize power consumption?
.re
In battery-powered applications, power consumption is extremely important.
In non-battery applications, excessive power consumption can increase heat
dissipation.
w
Careful design is required to slow down the noncritical parts of the machine for
power consumption while still meeting necessary performance goals.
w
w
www.rejinpaul.com
om
4) How do we design for upgradability?
The hardware platform may be used over several product generations,or for
.c
several different versions ,able to add features by changing software.
4.1) Complex testing: Run a real machine in order to generate the proper data.
ul
Testing of an embedded computer from the machine in which it is embedded.
4.2) Limited observability and controllabilityNo keyboard and screens, in real-
pa
time applications we may not be able to easily stop the system to see what is
going on inside and to affect the system’s operation.
4.3) Restricted development environments:
jin
We generally compile code on one type of machine, such as a PC, and
download it onto the embedded system.
.re
To debug the code, we must usually rely on programs that run on the PC or
workstation and then look inside the embedded system.
w
w
w
www.rejinpaul.com
om
Embedded system designers have to set their goal —their program must meet its
deadline.
.c
Performance Analysis
1. CPU: The CPU clearly influences the behavior of the program, particularly when
ul
the CPU is a pipelined processor with a cache.
2. Platform: The platform includes the bus and I/O devices. The platform
pa
components that surround the CPU are responsible for feeding the CPU and can
dramatically affect its performance.
3. Program: Programs are very large and the CPU sees only a small window of the
jin
program at a time. We must consider the structure of the entire program to
determine its overall behavior.
4. Task: We generally run several programs simultaneously on a CPU, creating a
.re
multitasking system. The tasks interact with each other in ways that have profound
implications for performance.
5. Multiprocessor: Many embedded systems have more than one processor—they
w
may include multiple programmable CPUs as well as accelerators. Once again, the
interaction between these processors adds yet more complexity to the analysis of
w
om
2)EMBEDDED SYSTEM DESIGN PROCESS
Design process has two objectives as follows.
.c
1. It will give us an introduction to the various steps in embedded system
ul
design.
2. Design methodology
pa
I. Design to ensure that we have done everything we need to do, such as
optimizing performance or performing functional tests.
II. It allows us to develop computer-aided design tools.
jin
III. A design methodology makes it much easier for members of a design
team to communicate.
.re
w
w
w
www.rejinpaul.com
om
Levels of abstraction in the design process.
1)Requirements
•It can be classified in to functional or nonfunctional
.c
1.1)Functional Requirements
•Gather an informal description from the customers.
ul
•Refine the requirements into a specification that contains
enough information to design the system architecture.
pa
•Ex:Sample Requirements form
•NameGiving a name to the project
PurposeBrief one- or two-line description of what the system
is supposed to do.
Mechanical inputs?
jin
•Inputs& Outputs Analog electronic signals? Digital data?
of the system
w
www.rejinpaul.com
om
1.2) Non-Functional Requirements
Performance depends upon approximate time to perform a user-
level function and also operation must be completed within deadline.
.c
CostManufacturing cost includes the cost of components and
assembly.
ul
• Nonrecurring engineering (NRE) costs include the personnel and other
costs of designing the
pa
system
Physical Size and WeightThe final system can vary depending upon
jin
the application.
Power ConsumptionPower can be specified in the requirements stage
in terms of battery life.
.re
w
w
w
www.rejinpaul.com
om
2)SPECIFICATION
The specification must be carefully written so that it accurately reflects the
customer’s requirements.
.c
It can be clearly followed during design.
3) Architecture Design
ul
The architecture is a plan for the overall structure of the system.
It is in the form block diagram that shows a major operation and data flow.
pa
4) Designing Hardware and Software Components
The architectural description tells us what components we need include both
jin
hardware—FPGAs, boards & software modules
5)System Integration
.re
Only after the components are built, putting them together and seeing a
working system.
Bugs are found during system integration, and good planning can help us find
w
om
Embedded system Design Example
GPS moving map
.c
ul
pa
jin
.re
w
w
w
www.rejinpaul.com
om
1. Requirements analysis of a GPS moving map
The moving map is a handheld device that displays for the user a map of the
.c
terrain around the user’s current position.
The map display changes as the user and the map device change position.
ul
The moving map obtains its position from the GPS, a satellite-based navigation
system.
pa
Name GPS moving map
Purpose Consumer-grade moving map for driving use
jin
Inputs Power button, two control buttons
Outputs Back-lit LCD display 400 600
Functions Uses 5-receiver GPS system; three user-selectable
.re
resolutions;always displays current latitude and
longitude
Performance Updates screen within 0.25 seconds upon movement
w
om
Design Process Steps
2) FunctionalityThis system is designed for highway driving and similar uses.
.c
The system should show major roads and other landmarks available in
standard topographic databases.
ul
3)User interfaceThe screen should have at least 400X600 pixel resolution. The
device should be controlled by no more than 3 buttons.
pa
A menu system should pop up on the screen when buttons are
pressed to allow the user to make selections to control the system.
jin
Upon power-up, a display should take no more than 1sec to appear.
The system should be able to verify its position and display the
current map within 15 s.
.re
5)Cost The selling cost of the unit should be no more than $100.
w
6)Physical size and weightThe device should fit comfortably in the palm of the
hand.
w
om
8) specification
1. Data received from the GPS satellite constellation.
2. Map data.
.c
3. User interface.
ul
4. Operations that must be performed to satisfy customer requests.
5. Background actions required to keep the system running, such as
pa
operating the GPS receiver.
jin
.re
w
w
w
www.rejinpaul.com
om
Block Diagram
.c
ul
pa
jin
.re
w
w
w
www.rejinpaul.com
om
Hardware architecture
•one central CPU surrounded by
memory and I/O devices.
.c
• It used two memories: a frame buffer
for the pixels to be displayed and a
separate program/data memory for
ul
general use by the CPU.
pa
Software architecture
•Timer to control when we read the buttons
on the user interface and render data onto
jin
the screen.
•Units in the software block diagram will be
executed in the hardware block diagram and
.re
when operations will be performed in time.
w
w
w
www.rejinpaul.com
om
3)FORMALISM FOR SYSTEM DESIGN
.c
UML(Unified Modeling Language) is an object-oriented modeling language
used to capture all these design tasks.
ul
It encourages the design to be described as a number of interacting objects,
rather than blocks of code.
pa
objects will correspond to real pieces of software or hardware in the system.
It allows a system to be described in a way that closely models real-world
objects and their interactions.
jin
Classification of descriptor
3.1)Structural Description
.re
3.2)Behavioral Description
w
w
w
www.rejinpaul.com
3.1)Structural Description
om
It gives basic components of the system and designers can learn how to
describe these components in terms of object.
.c
3.1.1) OBJECT in UML NOTATION
An object includes a set of attributes that define its internal state.
ul
An object describing a display (CRT screen) is shown in UML notation in
Figure.
pa
The object has a unique name, and a member of a class.
The name is underlined to show that this is a description of an object and not
of a class.
jin
The text in the folded-corner page icon is a note.
.re
w
om
3.1.2)CLASS IN UML NOTATION
All objects derived from the same
class have the same characteristics,
.c
but attributes may have different
values.
ul
It also defines the operations that
determine how the object interacts
pa
with the rest of the world.
It defines both the interface for a
particular type of object and that
jin
object’s implementation.
.re
w
w
w
www.rejinpaul.com
om
Relationships between objects and classes
1. Association occurs between objects that communicate with each other but
.c
have no ownership relationship between them.
2. Aggregation describes a complex object made of smaller objects.
ul
3. Composition It is a type of aggregation in which the owner does not allow
access to the component objects.
pa
4. Generalization allows us to define one class in terms of another.
jin
.re
w
w
w
www.rejinpaul.com
om
Derived classes as a form of generalization in UML
.c
•A derived class is defined to include all the
attributes of its base class.
• Display is the base class and BW display and
ul
color map display are the two derived classes.
•BW display represents black and white display.
pa
jin
.re
w
w
w
www.rejinpaul.com
om
•UML allows to define multiple inheritance, in which a class is derived from more
than one base class.
.c
•Multimedia display class by combining the Display class with a Speaker class for
sound.
ul
•The derived class inherits all the attributes and operations of both its base classes,
Display and Speaker.
pa
•
jin
.re
w
w
w
www.rejinpaul.com
Links and Association
om
.c
ul
pa
jin
A link describes a relationship between objects and association is to
.re
link as class is to object.
Links used to make to stand associations capture type information
about these links.
w
The association is drawn as a line between the two labeled with the
name of the association, namely, contains.
w
w
www.rejinpaul.com
3.2)Behavioral Description
om
Behavior of an operation is specified by a state machine.
.c
ul
pa
These state machines will not rely on the operation of a clock.
Changes from one state to another are triggered by the occurrence of
jin
events.
The event may generated from the outside or inside of the system.
.re
w
w
w
www.rejinpaul.com
om
Signal, call, and time-out events in UML.
.c
ul
pa
jin
.re
w
w
w
www.rejinpaul.com
om
Signal is an asynchronous occurrence.
It is defined in UML by an object that is labeled as a <<signal>>.
Signal may have parameters that are passed to the signal’s receiver.
.c
Call event follows the model of a procedure call in a programming
language.
ul
Time-out event causes the machine to leave a state after a certain
amount of time.
pa
The label tm(time-value) on the edge gives the amount of time after
which the transition occurs.
jin
It is implemented with an external timer.
.re
w
w
w
www.rejinpaul.com
om
State Machine specification in UML
The start and stop states are special states which organize the flow of the state
machine.
.c
The states in the state machine represent different operations.
ul
Conditional transitions out of states based on inputs or results of some
computation.
pa
An unconditional transition to the next state.
jin
.re
w
w
w
www.rejinpaul.com
om
Sequence diagram in UML
Sequence diagram is similar to a hardware timing diagram, although the time
flows vertically in a sequence diagram, whereas time typically flows horizontally
.c
in a timing diagram.
It is designed to show particular choice of events—it is not convenient for
ul
showing a number of mutually exclusive possibilities.
pa
jin
.re
w
w
w
www.rejinpaul.com
om
4) Design:Model Train Controller
In order to learn how to use UML to model systems specify a simple system
.c
(Ex: model train controller)
The user sends messages to the train with a control box attached to the tracks.
ul
The control box may have controls such as a throttle, emergency stop button,
and so on.
pa
The train Rx its electrical power from the two rails of the track.
CONSOLE
Each packet includes an address so that the console can control several trains
on the same track.
jin
The packet also includes an error correction code (ECC) to guard against
.re
transmission errors.
This is a one-way communication system—the model train cannot send
commands back to the user.
w
w
w
www.rejinpaul.com
om
.c
ul
pa
jin
.re
w
w
w
www.rejinpaul.com
om
REQUIREMENTS
The console shall be able to control up to eight trains on a single track.
.c
The speed of each train controllable by a throttle to at least 63 different
levels in each direction (forward and reverse).
ul
There shall be an inertia control to adjust the speed of train.
pa
There shall be an emergency stop button.
An error detection scheme will be used to transmit messages.
jin
.re
w
w
w
www.rejinpaul.com
om
Requirements:Chart Format
.c
Name Model train controller
Purpose Control speed of up to eight model trains
Inputs Throttle, inertia setting, emergency stop, train
ul
number
Outputs Train control signals
pa
Functions Set engine speed based upon inertia settings;
respond
jin
Performance Can update train speed at least 10 times per second
Manufacturing cost $50
Power 10W
.re
Physical size and weight Console should be comfortable for two
hands,approximatesize of standard
keyboard;
weight 2 pounds
w
w
w
www.rejinpaul.com
om
Standard S-9.1 how bits are encoded on the rails for transmission.
Standard S-9.2 defines the packets that carry information.
.c
The signal encoding system should not interfere with power transmission
Data signal should not change the DC value of the rails.
ul
Bits are encoded in the time between transitions.
Bit 0 is at least 100 s while bit 1 is nominally 58 s.
pa
jin
.re
w
w
w
www.rejinpaul.com
Packet Formation in DCC
om
The basic packet format is given by
.c
P preamble, which is a sequence of at least 10 1 bits.
ul
S packet start bit. It is a 0 bit.
A address is 8 bits long. The addresses 00000000, 11111110, and 11111111 are
pa
reserved.
s data byte start bit, which, like the packet start bit, is a 0.
D data byte includes 8 bits. A data byte may contain an address, instruction,
jin
data, or error correction information.
E packet end bit, which is a 1 bit.
.re
w
w
w
www.rejinpaul.com
om
Baseline packet
The minimum packet that must be accepted by all DCC implementations.
.c
It has three data bytes.
Address data byte gives the intended receiver of the packet
ul
Instruction data byte provides a basic instruction
Error correction data byte is used to detect and correct transmission errors.
pa
Date byte
Bits 0–3 provide a 4-bit speed value.
jin
Bit 4 has an additional speed bit.
Bit 5 gives direction, with 1 for forward and 0 for reverse.
Bits 6-7 are set at 01 provides speed and direction.
.re
w
w
w
www.rejinpaul.com
Conceptual Specification
om
Conceptual specification allows us to understand the system a little better.
A train control system turns commands into packets.
.c
A command comes from the command unit while a packet is transmitted over the
rails.
ul
Commands and packets may not be generated in a 1-to-1 ratio
pa
jin
.re
w
w
w
www.rejinpaul.com
om
controller system
.c
The command unit and receiver are each represented by objects.
The command unit sends a sequence of packets to the train’s receiver, as
illustrated by the arrow messages as 1..n.
ul
Those messages are of course carried over the track.
pa
jin
.re
w
w
w
www.rejinpaul.com
om
UML class diagram for the train controller
.c
ul
pa
jin
.re
w
w
w
www.rejinpaul.com
om
Basic characteristics of UML classes
Console class describes the command unit’s front panel, which contains
.c
the analog knobs and hardware to interface to the digital parts of the system.
Formatter class includes behaviors that know how to read the panel knobs and creates a
bit stream for the required message.
ul
Transmitter class interfaces to analog electronics to send the message along the track
Knobs* describes the actual analog knobs, buttons, and levers on the control panel.
pa
Sender* describes the analog electronics that send bits along the track.
Receiver class knows how to turn the analog signals on the track into digital form.
Controller class includes behaviors that interpret the commands and figures out how to
jin
control the motor.
Motor interface class defines how to generate the analog signals required to control the
motor.
.re
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.
w
w
w
www.rejinpaul.com
Detailed Specification
om
•The Panel has three knobs
• train number (which train is currently
.c
being controlled).
•speed (which can be positive or negative),
and inertia.
ul
•It also has one button for emergency-
stop.
pa
•When we change the train number
setting, to reset the other controls to the
proper values for that train.
• so that the previous train’s control
jin
settings are not used to change the current
train’s settings.
.re
w
w
w
www.rejinpaul.com
om
.c
ul
pa
jin
•The Panel class defines a behavior for each of the controls on the panel.
• The new-settings behavior uses the set-knobs behavior of the Knobs*
.re
•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.
w
.
w
w
www.rejinpaul.com
om
Class diagram for the Transmitter and Receiver
.c
ul
pa
jin
.re
•They provide the software interface to the physical devices that send
and receive bits along the track.
•The Transmitter provides a behavior message that can be sent
w
om
Class diagram for Formatter
.c
ul
pa
jin
The formatter holds the current control settings for all of the trains.
.re
The send-command serves as the interface to the transmitter.
The operate function performs the basic actions for the object.
The panel-active behavior returns true whenever the panel’s values do not
w
om
.c
ul
pa
jin
.re
•The Controller’s 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
w
om
control input
.c
Sequence diagram
specify the interface
between more than one
ul
classes.
Its detailed operations
pa
and what ways its going
to operate
jin
.re
w
w
w
www.rejinpaul.com
om
1.4DESIGN METHODOLOGIES
Design of Embedded system is not an easy task.
The main goal of a design process is to create a product that does something useful.
.c
Typical specifications for a product are functionality , manufacturing cost, performance and
power consumption.
ul
Design process has several important goals as follows
Time-to-market
pa
Customers always want new features.
The product that comes out first can win the market, even setting customer preferences for
future generations of the product.
jin
Design cost
Consumer products are very cost sensitive, and it is distinct from manufacturing cost.
Design costs can dominate manufacturing costs.
.re
Design costs can also be important for high-volume consumer devices when time-to-market
pressures cause teams to swell in size.
Quality
w
om
1.5Design flows
A design flow is a sequence of steps to be followed during a design.
.c
Some of the steps can be performed by tools and other steps can be performed by hand.
Types of Software development models
ul
1. Waterfall model
2. Spiral model
pa
3. Successive refinement development model
4. Hierarchical design model
jin
.re
w
w
w
www.rejinpaul.com
1.5.1)Waterfall model
om
The waterfall development model consists of five major phases.
Requirements analysis determines the basic characteristics of the system.
.c
Architecture designIt decomposes the functionality into major components
CodingIt implements the pieces and integrates them.
ul
TestingIt detemines bugs.
Maintenance It entails deployment in the field, bug fixes,and upgrades.
pa
The waterfall model makes work flow information from higher levels of abstraction to
more detailed design steps.
jin
.re
w
w
w
www.rejinpaul.com
1.5.2)Spiral model
om
The spiral model assumes that several versions of the
system will be built.
.c
Each level of design, the designers go through
requirements,construction,and testing phases.
At later stages when more complete versions of the
ul
system are constructed.
Each phase requires more work, widening the design
pa
spiral.
The first cycles at the top of the spiral are very small
and short.
jin
The final cycles at the spiral’s bottom add detail
learned from the earlier cycles of the spiral.
The spiral model is more realistic than the waterfall
.re
model because multiple iterations needed to
complete a design.
But too many spirals may take long time required for
design.
w
w
w
www.rejinpaul.com
om
In this approach, the system is built several times.
A first system is used as a rough prototype.
.c
Embedded computing systems are involved the design of hardware/software project.
Front-end activities are specification and architecture and also includes hardware and
software aspects.
ul
Back-end activities includes integration and testing.
Middle activitiesincludes hardware and software development.
pa
jin
.re
w
w
w
www.rejinpaul.com
om
1.5.4)Hierarchical design flow
Many complex embedded systems are built of smaller designs.
.c
The complete system may require the design of significant software
components.
ul
It has many levels of abstraction to design flows for individual components.
The implementation phase contains a complete flow from specification
pa
through testing.
Each flow will probably be handled by separate people or teams.
The teams must rely on each other’s results.
jin
The component teams take their requirements from team handling the next
higher level of abstraction.
The higher-level team relies on the quality of design and testing performed by
.re
the component team.
w
w
w
www.rejinpaul.com
om
.c
ul
pa
jin
.re
w
w
w
www.rejinpaul.com
om
1.5.5) Concurrent engineering
Reduced design time is an important goal for concurrent engineering.
It eliminate “over-the-wall” design steps, one designer performs an isolated task and then
.c
throws the result to the next designer.
Concurrent engineering efforts are comprised of several elements.
ul
Cross-functional teams include members from various disciplines ( manufacturing,
hardware and software design, marketing)
Concurrent product realize the process activities .
pa
Designing various subsystems simultaneously, is reducing design time.
Integrated project managementensures that someone is responsible for the entire project.
Early and continual supplier make the best use of suppliers’ capabilities.
jin
Early and continual customer ensure that the product meets customers’ needs.
.re
w
w
w
www.rejinpaul.com
om
Concurrent Engineering Applied to Telephone Systems
.c
ul
pa
jin
.re
w
w
w
www.rejinpaul.com
om
1. Benchmarking They compared themselves to competitors and found that it took
them 30% longer to introduce a new product than their best competitors.
2. Breakthrough improvement.
.c
Increased partnership between design and manufacturing.
Continued existence of the basic organization of design labs and manufacturing.
ul
Support of managers at least two levels above the working level.
3. Characterization of the current process.
pa
Too many design and manufacturing tasks were performed sequentially.
4. Create the target process The core team created a model for the new development
process.
5. Verify the new process test the new process.
6.
jin
Implement across the product lineThis activity required training of personnel,
documentation of the new standards and procedures, and improvements to information
systems.
.re
7. Measure results and improvePerformance of the new design was measured.
w
w
w
www.rejinpaul.com
om
1.6REQUIREMENTS ANALYSIS
RequirementsIt is a informal descriptions of what the customer wants.
A functional requirement states what the system must do.
.c
A nonfunctional requirementIt can be physical size, cost, power consumption, design
time, reliability, and so on.
ul
Requirements of tests
CorrectnessRequirements should not mistakenly describe what the customer wants.
pa
UnambiguousnessRequirements document should be clear and have only one plain
language interpretation.
Completeness Requirements all should be included.
jin
Verifiability cost-effective way to ensure that each requirement is satisfied in the final
product.
ConsistencyOne requirement should not contradict another requirement.
.re
ModifiabilityThe requirements document should be structured so that it can be
modified to meet changing requirements without losing consistency.
TraceabilityAble to trace forward /backward from the requirements.
w
w
w
www.rejinpaul.com
om
1.7)SPECIFICATIONS
.c
SpecificationsIt is a detailed
descriptions of the system that can
be used to create the architecture.
ul
Control-oriented specification languages
SDL specifications include states,
pa
actions, and both conditional and
unconditional transitions between
states.
jin
SDL is an event-oriented state
machine model.
State chart has some important
.re
concepts.
State charts allow states to be
grouped together to show common
functionality.
w
w
w
www.rejinpaul.com
om
Basic groupings(OR)
State machine specifies that the machine goes to state s4 from any of s1, s2, or s3 when
they receive the input i2.
The State chart denotes this commonality by drawing an OR state around s1, s2, and s3 .
.c
Single transition out of the OR state s123 specifies that the machine goes to s4 when it
receives the i2 input while in any state included in s123.
ul
Multiple ways to get into s123 (via s1 or s2), and transitions between states within the OR
state (from s1 to s3 or s2 to s3).
The OR state is simply a tool for specifying some of the transitions relating to these
pa
states.
jin
.re
w
w
w
www.rejinpaul.com
om
Basic groupings(AND)
In the State chart, the AND state sab is decomposed into two components, sa and sb.
When the machine enters the AND state, it simultaneously inhabits the state s1 of
component sa and the state s3 of component sb.
.c
When it enters sab, the complete state of the machine requires examining both sa and sb.
State s1-3 in the State chart machine having its sa component in s1 and its sb component in
ul
s3.
When exit from cluster states go to s5 only when in the traditional specification, we are in
state s2-4 and receive input r.
pa
jin
.re
w
w
w
www.rejinpaul.com
1.7.1)Advanced specifications
om
It ensure the correctness and safety of this system.
Ex Traffic Alert and Collision Avoidance System(TCAS)
.c
It is a collision avoidance system for aircraft.
TCAS unit in an aircraft keeps track of the position of other nearby aircraft.
ul
It uses pre-recorded voice (“DESCEND!) commands for mid-air collision.
TCAS makes sophisticated decisions in real time and is clearly safety critical.
pa
It must detect as many potential collision events as possible .
It must generate a few false alarms ,at extreme maneuvers in potentially dangerous.
TCAS-II specification(RSML Language) Transition states
jin
.re
w
w
w
www.rejinpaul.com
om
Collision Avoidance system
The system has Power-off and Power-on states .
In the power on state, the system may be in Standby or Fully operational mode.
.c
In the Fully operational mode, three components are operating in parallel, as specified
by the AND state.
The own aircraft subsystem to keep track of up to 30 other aircraft.
ul
Subsystem to keep track of up to 15 Mode S ground stations, which provide radar
information.
pa
jin
.re
w
w
w
www.rejinpaul.com
om
1.8SYSTEM ANALYSIS AND ARCHITECTURE DESIGN
The CRC card methodology analyze and understanding the overall structure of a complex
system.
CRC cards
.c
Classes define the logical groupings of data and functionality.
Responsibilities describe what the classes do.
ul
Collaborators are the other classes with which a given class works.
It has space to write down the class name, its responsibilities and collaborators, and other
pa
information.
Layout of CRC card
jin
.re
w
w
w
www.rejinpaul.com
om
A class may represent a real-world object of the system.
A class has both an internal state and a functional interface.
The functional interface describes the class’s capabilities.
The responsibility set is describing that functional interface.
.c
The collaborators of a class are simply the classes that it talks or calls upon to help it do its
work.
ul
CRC card Analysis Process
1. Develop an initial list of classesWrite down the class name and functions of it.
pa
2. Write an initial list of responsibilities and collaborators.
3. Create some usage scenariosdescribe what the system does.
4. Walk through the scenariosEach person on the team represents one or more classes.
jin
5. Refine the classes, responsibilities, and collaborators make changes to the CRC cards.
6. Add class relationships subclass and super-class can be added to the cards.
.re
w
w
w
www.rejinpaul.com
om
Ex:Elevator system
1. One passenger requests a car on a floor, gets in the car when it arrives, requests
.c
another floor, and gets out when the car reaches that floor.
2. One passenger requests a car on a floor, gets in the car when it arrives, and
ul
requests the floor that the car is currently on.
3. A second passenger requests a car while another passenger is riding in the
pa
elevator.
4. Two people push floor buttons on different floors at the same time.
5. Two people push car control buttons in different cars at the same time.
jin
.re
w
w
w
www.rejinpaul.com
om
.c
ul
pa
jin
.re
w
w
w
www.rejinpaul.com
om
1.9) Quality Assurance techniques(QA
techniques(QA))
The quality assurance (QA) process is vital for the delivery of a satisfactory system.
.c
International Standards Organization (ISO) has created a set of quality standards known as
ISO 9000.
ul
It was created to apply to a broad range of industries, including limited to embedded
hardware and software.
ISO 9000 quality management parameters
pa
Process is crucialKnowing what steps are to be followed to create a high-quality product.
Documentation is importanthelps internal quality monitoring groups to ensure that the
required processes and helps outside groups understand the processes and how they are
jin
being implemented.
Communication is important people should understand not only their specific tasks but
also how their jobs can affect overall system quality.
.re
w
w
w
www.rejinpaul.com
om
Capability Maturity Model (CMM)
It is used to measuring the quality of an organization’s software development.
.c
1. InitialA poorly organized process, with very few well-defined processes.
Success of a project depends on the efforts of individuals, not the organization
ul
itself.
2. Repeatable provides basic tracking mechanisms to understand cost,
pa
scheduling .
3. DefinedThe management and engineering processes are documented and
standardized.
jin
4. Manageddetailed measurements of the development process and product
quality.
5. Optimizingfeedback from detailed measurements is used to continually
.re
improve the organization’s processes.
w
w
w
www.rejinpaul.com
om
Verifying the specificationDiscovering bugs early is crucial because it prevents bugs
from being released to customers, minimizes design costs, and reduces design time.
Validation of specificationscreating the requirements, including correctness,
.c
completeness, consistency, and so on
Design reviews
ul
The review leader coordinates the pre-meeting activities, the design review itself,
and the post-meeting follow-up.
pa
The reviewer records the minutes of the meeting so that designers and others know
which problems need to be fixed.
The review audience studies the component.
jin
.re
w
w
w
www.rejinpaul.com
om
1.10 DESIGNING WITH COMPUTING PLATFORM
1.10.1 System Architecture
.c
The architecture of an embedded computing system includes both hardware
ul
and software elements
HARDWARE
pa
CPU The choice of the CPU is one of the most important, but it can be
considered the software that will execute on the machine.
Bus The choice of a bus is closely tied to that of a CPU,bus can handle the
jin
traffic.
MemorySelection depends total size and speed of the memory will play a
large part in determining system performance.
.re
Input and output devices Dependig upon the system requirements
w
w
w
www.rejinpaul.com
om
SOFTWARE
Run Time components
It is a critical part of the platform.
.c
An operating system is required to control CPU and its multiple
processes .
ul
A file system is used in many embedded systems to organize internal
pa
data and interface with other systems
Support components
It is a complex hardware platform.
jin
Without proper code development and operating system, the hardware
itself is useless.
.re
w
w
w
www.rejinpaul.com
om
.c
ul
pa
jin
.re
w
w
w
www.rejinpaul.com
1.10.2)The PC as a Platform
om
.c
ul
pa
jin
.re
w
w
w
www.rejinpaul.com
om
CPU provides basic computational facilities.
RAM is used for program storage.
.c
ROMholds the boot program.
ul
DMAcontroller provides DMA capabilities.
Timers used by the operating system for a variety of purposes.
pa
High-speed busconnected to the CPU bus through a bridge, allows
fast devices to communicate with the rest of the system.
low-speed bus provides an inexpensive way to connect simpler
devices.
jin
.re
w
w
w
www.rejinpaul.com
om
Development process used to make a complete design
of the system.
.c
It guides the developers how to design a system .
ul
An embedded computing system has CPU ,memory, I/O
devices.
pa
Development of embedded system have both hardware&
software.
The software development on a PC or workstation known
as a host.
jin
•The host and target are frequently connected by a USB link.
.re
•The target must include a small amount of software to talk to the host
system.
w
w
w
www.rejinpaul.com
om
Functions of Host system
Load programs into the target
Start and stop program execution on the target
.c
Examine memory and CPU registers.
Cross-Compiler
ul
Compiler kind of software that translate one form of pgm to another form of
pgm.
pa
Cross Compileris a compiler that runs on one type of machine but generates
code for another
jin
After compilation, the executable code is downloaded to the embedded system
by a serial link.
A PC or workstation offers a programming environment .
.re
But one problem with this approach emerges when debugging code talks to I/O
devices.
Testbench program can be built to help debug the embedded code.
w
It may also take the output values and compare them against expected values.
w
w
www.rejinpaul.com
om
1.10.4Debugging Techniques
It is the process of checking errors and correcting those errors.
.c
It can be done by compiling and executing the code on a PC or workstation.
It can be performed by both H/W and S/W sides.
ul
Software debugging tools
1. Serial Port tool
pa
It will perform the debugging process from the initial state of embedded system
design.
It can be used not only for development debugging but also for diagnosing
problems in the field.
2. Breakpoints tool
jin
.re
user to specify an address at which the program’s execution is to break.
When the PC reaches that address, control is returned to the monitor program.
From the monitor program, the user can examine and/or modify CPU registers,
w
om
Breakpoint is a location in memory at which a program stops executing and
returns to the debugging tool or monitor program.
.c
To establish a breakpoint at location 0x40c in some ARM code, replaced the branch
(B) instruction with a subroutine call (BL) to the breakpoint handling routine
ul
pa
jin
.re
w
w
w
www.rejinpaul.com
om
Hardware debugging tools
Hardware can be deployed to give a clearer view on what is happening when the
system is running.
.c
1. Microprocessor In-Circuit Emulator (ICE)
It is a specialized hardware tool that can help debug software in a working
ul
embedded system.
In-circuit emulator is a special version of the microprocessor that allows its
pa
internal registers to be read out when it is stopped
2. Logic Analyer
The analyzer can sample many different signals simultaneously but can display
jin
only 0, 1, or changing values for each.
The logic analyzer records the values on the signals into an internal memory
and then displays the results on a display once the memory is full.
.re
w
w
w
www.rejinpaul.com
om
.c
ul
pa
jin
.re
w
w
w
www.rejinpaul.com
om
Data modes of logic analyzer
State modes
.c
State mode represent different ways of sampling the values.
It uses the own clock to control sampling
ul
It samples each signal only one per clock cycle.
It has less memory to store a given number of system clock.
pa
Timing modes
Timing mode uses an internal clock that is fast enough to take several samples
per clock period in a typical system.
jin
.re
w
w
w
www.rejinpaul.com
om
1.10.5)Debugging Challenges
.c
Logical errors in software can be hard to track down and it will create
many problems in real time code.
ul
Real-time programs are required to finish their work within a certain
amount of time.
pa
Run time pgm run too long, they can create very unexpected behavior.
Missing of Deadline makes debugging process as difficult.
jin
.re
w
w
w
www.rejinpaul.com
om
1.11 Consumer Electronic Architecture
Consumer electronic refers to any device containing an electronic circuit board
that is intended for eneryday use by individuals.
.c
EgTV,cameras,digital cameras,calculators,DVDs,audio devices,smart phones
etc..,
ul
1.11..1)Functional Requirements
1. Multimedia
pa
The media may be audio, still images, or video.
These multimedia objects are generally stored in compressed form and must be
uncompressed to be played .
jin
Eg multimedia compression standards (MP3,Dolby Digital(TM))
audio; JPEG for still images; MPEG-2, MPEG-4, H.264, etc. for video.
.re
2. Data storage and management People want to select what multimedia objects
they save or play, data storage goes hand-in-hand with multimedia capture and
display. Many devices provide PC-compatible file systems so that data can be
w
om
1.11.2)Non-Functional Requirements
Many devices are battery-operated, which means that they must operate under
strict energy budgets.
.c
Battery(75mW) support not only the processors but also the display, radio,
etc.
ul
Consumer electronics must also be very inexpensive but provide very high
performance.
pa
jin
.re
w
w
w
www.rejinpaul.com
om
use case for selecting and playing a multimedia object (audio clip, a picture,etc.).
.c
Selecting an object makes use of both the user interface and the file system.
Playing also makes use of the file system as well as the decoding subsystem and
ul
I/O subsystem.
pa
jin
.re
w
w
w
www.rejinpaul.com
om
system
.c
use case for connecting to a client.
The connection may be either over a local connection like USB or over the
ul
Internet.
Some operations may be performed locally on the client device
pa
most of the work is done on the host system while the connection is
established
jin
.re
w
w
w
www.rejinpaul.com
om
1.11.3)Functional architecture of
Consumer Electronics Device(CED)
.c
ul
pa
jin
.re
w
w
w
www.rejinpaul.com
om
It is a two-processor architecture.
If more computation is required, more DSPs and CPUs may be added.
.c
The RISC-CPU runs the operating system, runs the user interface, maintains
the file system, etc.
ul
DSP it is a programmable one, which performs signal processing.
Operating system runs on the CPU must maintain processes and the file
pa
system.
Depending on the complexity of the device, the operating system may not need
to create tasks dynamically.
jin
If all tasks can be created using initialization code, the operating system can be
made smaller and simpler.
.re
w
w
w
www.rejinpaul.com
om
1.11.4 Flash File Systems
Many consumer electronics devices use flash memory for mass storage.
.c
Flash memory is a type of semiconductor memory ,unlike DRAM or
SRAM, provides permanent storage.
ul
Values are stored in the flash memory cell as electric charge using a
specialized capacitor that can store the charge for years.
pa
The file system of a device is typically shared with a PC.
Standard file systemhas two layers.bottom layer handles physical
jin
reads and writes on the storage device and the top layer provides a
logical view of the file system.
Flash file systemimposes an intermediate layer that allows the logical-
.re
to-physical mapping of files to be changed.
w
w
w
www.rejinpaul.com
om
1.12 Platform-
Platform-Level Performance Analysis
.c
System-Level Performance involves much more than the CPU.
To move data from memory to the CPU to process it. To get the data from
memory to the CPU we must.
ul
1. Read from the memory.
pa
2. Transfer over the bus to the cache.
3. Transfer from the cache to the CPU.
jin
.re
w
w
w
www.rejinpaul.com
om
The performance of the system based on Bandwidth of the system.
We can increase bandwidth in two ways:
.c
1) By increasing the clock rate of the bus
2) By increasing the amount of data transferred per clock cycle.
ul
For example, bus to carry four bytes or 32 bits per transfer, we would reduce
pa
the transfer time to 0.058 s. If we also increase the bus clock rate to 2 MHz,
then we would reduce the transfer time to 0.029 s ,which is within our time
budget for the transfer.
jin t=TP
.re
tbus cycle counts
Tbus cycles.
pbus clock period
w
w
w
www.rejinpaul.com
1.12.1Parallelism
om
Direct memory access is a example of parallelism.
DMA was designed to off-load memory transfers from the CPU.
.c
The CPU can do other useful work while the DMA transfer is running.
ul
pa
jin
.re
w
w
w
www.rejinpaul.com
om
.c
ul
pa
jin
.re
w
w
w
www.rejinpaul.com
om
UNIT II
.c
ul
ARM PROCESSOR AND PERIPHERALS
pa
ARM Architecture Versions – ARM Architecture – Instruction Set
– Stacks and Subroutines – Features of the LPC 214X Family –
jin
Peripherals – The Timer Unit – Pulse Width Modulation Unit –
UART – Block Diagram of ARM9 and ARM Cortex M3 MCU.
.re
w
w
w
www.rejinpaul.com
om
2.1 ARM Architecture Versions
The ARM processor is a Reduced Instruction Set
.c
Computer (RISC).
ul
The first ARM processor was developed at Acorn
Computers Limited, of Cambridge, England, between
pa
October 1983 and April 1985. It is very simple
architecture.
jin
At that time, and until the formation of Advanced
RISC Machines Limited (which later was renamed
.re
simply ARM Limited) in 1990, ARM stood for Acorn
RISC Machine
w
w
w
www.rejinpaul.com
om
Second, both ARM ISA and pipeline design are aimed
to minimize the energy consumption.
.c
Third, the ARM architecture is highly modular only
mandatory component of ARM processor is the integer
ul
pipeline, others are optional. This gives more
pa
flexibility in application dependent architecture
jin
.re
w
w
w
www.rejinpaul.com
om
Revision Example core ISA Enhancement
implementation
ARM v1 ARM1 •First ARM Processor
•26bit addressing
.c
ARMv2 ARM2 •32bit multiplier
•32bit coprocessor
ul
support
ARMv2a ARM3 •On chip cache
pa
•Atomic swap instruction
•Coprocessor 15 for cache
management
ARMv3
jin
ARM6 and ARM7DI •32 bit addressing
•Separate cpsr (current
Program status
.re
register)and spsr
(Saved program status
register)
w
•MMU support(Memory
Management Unit)
w
www.rejinpaul.com
om
ARMv3M ARM7M Signed and un signed
long multiply
instruction
.c
ARMv4 Strong ARM •load store instructions
for signed half
ul
words/bytes
•Reserve SWI(software
interrupt) space fro
pa
architecturally define
operations.
•26 bit addressing mode
jin
no longer supported
ARMv4T ARM7TDMI and ARM9T •Thumb
.re
ARMV5TE ARM9E AND ARM10E •Superset of ARM
•Enhanced multiply
instructions
•Extra DSP type
w
instruction
•Faster multiply
w
instruction
w
www.rejinpaul.com
om
ARM V5tej ARM7EJ & ARM926EJ Java Acceleration
ARMv6 ARM11 •Improved Multiprocessor
instructions
.c
•Unaligned and Mixed
endian data handling
ul
pa
jin
.re
w
w
w
www.rejinpaul.com
om
ARM processor Features
.c
Terms Extention
X Family or series
ul
Y Memory Management
pa
Z Cache
T 16bit thumb decoder
D Jtag Debugger
M
I jin Fast multiplier
Embedded In circuit Emulator
.re
E Enhanced Instruction for DSP
J Jazelle
w
ARM 7family
om
ARM7 core has a von neumann style architecture
.c
ARM7 TDMI is first processor introduced in 1995 by
ul
ARM
pa
It provide a very good performance to power ratio
ARM7TDMI-S has the synthesizable
jin
ARM720T is the most fexible member of ARM7 family
because it include MMU. MMU handle both platforms
.re
Linux and windows
It having unified 8k cache and vector table are
w
om
ARM7EJS processor, also synthesizable. Its having five
stage pipeline and execute ARMv5TEJ instruction
.c
This version only support java acceleration.
ul
pa
jin
.re
w
w
w
www.rejinpaul.com
om
ARM9 family
The ARM9 family was announced in 1997
.c
ARM9 has five stage pipeline and high clock
ul
frequencies
Memory have been redesign Harvard architecture
pa
ARM9 process includes cache and MMU
jin
Operating system requiring virtual memory support
ETM (Embedded Trace Macrocell) which allows a
.re
developer to trace instruction and data execution in
real time operation. So that debugging is done during
the critical time segments.
w
w
w
www.rejinpaul.com
om
ARM946E-S include TCM, cache and MPU. The size
of the TCM and cache are configurable
.c
The processor is designed for the embedded control
ul
application that require deterministic real time
response
pa
ARM926EJ-S synthesizable processor core, announced
in 2000
jin
It a java enable device such as 3G phones and personal
digital assistant
.re
w
w
w
www.rejinpaul.com
om
ARM10 FAMILY
.c
The ARM10 announced in 1997 was designed for
performance
ul
It extended version of 6 stage pipeline
pa
Vector floating point unit which adds a seventh stage
to the ARM10 pipeline
jin
VFP combined with IEEE 754.1985 floating point
ARM1020 E it includes E instruction. it having cache,
.re
VFP and MMU
ARM1026EJ-S is similar to ARM926EJ-S . But ARM10 is
w
om
ARM11
ARM1136J-S, announced in 2003 was designed for high
.c
performance and power efficient applications
ul
ARM1136J-S was the first processor to execute
architecture ARMv6 instructions
pa
It has eight pipeline stages with load and store
arithmetic pipeline.
jin
ARMv6 instruction are single instruction with
multiple data extensions for media processing.
.re
w
w
w
www.rejinpaul.com
om
2.2 ARM PROCESSORS
ARM Processor can be divided into three types
.c
ARM classic processor
ul
ARM Embedded Processor
pa
ARM Application processor
jin
.re
w
w
w
www.rejinpaul.com
om
ARM classic processor
.c
ul
pa
jin
.re
w
w
w
www.rejinpaul.com
om
ARM Embedded Processor
.c
ul
pa
jin
.re
w
w
w
www.rejinpaul.com
om
.c
ul
pa
jin
.re
w
w
w
www.rejinpaul.com
om
2.3 ARM ARCHITECTURE
.c
The architecture has evolved over time, and starting
ul
with cortex series of cores, three profiles are,
pa
Application Profile Cortex- A series
Real time profile- Cortex- R series
jin
Microcontroller profile-Cortex –M series
2.3.1 Arm Features
.re
A load-store architecture,
Fixed-length 32-bit instructions
w
om
.c
ul
pa
jin
.re
w
w
w
www.rejinpaul.com
om
It has 32 bit architecture but it supports to 16bit and 8
bit data types also
.c
A wide choice of development tools and simulation
models for leading EDA (Electronic Design
ul
Automation) environments and excellent debug
pa
support
ARM uses a Intelligent Memory Manager (IEM). It
jin
implements advanced algorithms to optimally balance
processor workload and power consumption.IEM work
.re
with operating system and mobile OS
ARM uses AHB (AMBA Advanced High performance
w
w
www.rejinpaul.com
om
Byte organizations with an ARM word
.c
ul
pa
jin
.re
w
w
w
www.rejinpaul.com
om
2.3.2 ARM ARCHITECTURE
.c
ARM core is functional units connected by data buses.
ul
Arrow represents the flow of data.
pa
Lines represent buses.
Boxes represent either operation unit or storage area
jin
Design of ARM is simple and Programmer’s design.
Power Saving design module.
.re
Flexible design for different application with simple
changes
w
om
ARM instructions have two registers:
Rm, Rn- source register
.c
Rd-destination register.
ul
Address bus line A(31:0) and data in lines DATA (31:0)
to store the data into the register.
pa
Address Register holds the address of next instruction
/ data to be fetched
jin
Address Incrementer the address register value to
appropriate amount to point the next instruction/ data
.re
It contains 31 Register bank, each register are 32 bit
registers and also contains 6 status registers each of 32
w
bits
w
w
www.rejinpaul.com
om
2.3.3CPU Modes of ARM:
User mode: It is used for programs and applications.
.c
It is a only non privileged mode.
System Mode: It is a special version of user mode. It
ul
allows the full read write access to the CPSR.
pa
Supervisor Mode: it is privileged mode it enters
whenever the processor get reset or SWI instruction is
jin
executed. In this mode OS kernel operates in.
Abort Mode: It occurs when there is a failed attempt
.re
to access the memory. This mode is entered when
prefetch abort and data abort exception occurs.
w
w
w
www.rejinpaul.com
om
Undefined mode: it is used when the processor
encountered an instruction that is undefined or not
supported by the implementation. It is a privileged
.c
mode.
ul
Interrupt Mode : It is a privileged mode. When the
processor accepts the IRQ it occurs.
pa
Fast Interrupt Mode : It is a privileged mode. When
the processor accepts the IRQ it occurs.
jin
HYP Mode: This mode introduced in the ARMV-7A
fir cortex- A15 processor to providing hardware
.re
virtualization support.
w
w
w
www.rejinpaul.com
om
Register (CPSR)
.c
It gives the status of ALU result for every execution
ul
The CPSR is used in user-level programs to store the
pa
condition code bits.
Example, to record the result of a comparison
jin
operation and to control whether or not a conditional
branch is taken
.re
w
w
w
www.rejinpaul.com
om
.c
N: Negative; the last ALU operation which changed the
ul
flags produced a negative result
pa
Z: Zero; the last ALU operation which changed the flags
produced a zero result (every bit of the 32-bit result was
jin
zero).
C: Carry; the last ALU operation which changed the flags
.re
generated a carry-out, either as a result of an arithmetic
operation in the ALU or from the shifter.
w
bit.
w
www.rejinpaul.com
om
ARM Data Instruction
.c
ul
pa
jin
.re
w
w
w
www.rejinpaul.com
om
.c
ul
pa
jin
.re
w
w
w
www.rejinpaul.com
om
.c
ul
pa
jin
.re
w
w
w
www.rejinpaul.com
om
.c
Example Program:
ul
int a,b,c, X;
pa
X= a+b-c;
jin
.re
w
w
w
www.rejinpaul.com
om
.c
ul
pa
jin
.re
w
w
w
www.rejinpaul.com
om
.c
ul
pa
2.4 ARM INSTRUCTION SET
jin
.re
w
w
w
www.rejinpaul.com
om
Types of instruction set
.c
Data Processing Instructions
ul
Branch Instructions
pa
Load Store Instructions
Software interrupt Instructions
jin
Program Status Register Instructions
.re
w
w
w
www.rejinpaul.com
om
DATA PROCESSING INSTRUCTIONS:
Move instruction
.c
Arithmetic instruction
ul
Logical instruction
pa
Comparison instruction
Multiply instruction
jin
.re
w
w
w
www.rejinpaul.com
om
Move instruction
.c
MOV operand2
ul
MVN NOT operand2
pa
MOVS – Update In Status Reg
Syntax:
jin
<Operation>{<cond>}{S} Rd, Operand2
Examples:
.re
MOV r0, r1
MOVS r2, #10
w
w
w
www.rejinpaul.com
om
The Barrel Shifter
.c
The ARM doesn’t have actual shift instructions.
ul
Instead it has a barrel shifter which provides a
pa
mechanism to carry out shifts as part of other
instructions.
jin
Barrel Shifter - Left Shift
Shifts left by the specified amount (multiplies by
.re
powers of two)
e.g.
w
LSL #5 = multiply by 32
w
w
www.rejinpaul.com
om
Barrel Shifter - Left Shift
.c
ul
pa
jin
Logical Shift Left (LSL)
.re
CF Destination 0
w
w
w
www.rejinpaul.com
om
Barrel Shifter - Right Shifts
.c
Logical Shift Right
Logical Shift Right
ul
•Shifts right by the
specified amount (divides ...0 Destination CF
pa
by powers of two) e.g.
LSR #5 = divide by 32
ASR #5 = divide by 32
w
www.rejinpaul.com
om
Barrel Shifter - Rotations
Rotate Right (ROR)
.c
Rotate Right
• Similar to an ASR but the
bits wrap around as they
ul
leave the LSB and appear as Destination CF
the MSB.
pa
e.g. ROR #5
• Note the last bit rotated is
jin
also used as the Carry Out.
.re
Rotate Right Extended Rotate Right through Carry
(RRX)
• This operation uses the
Destination
w
CF
CPSR C flag as a 33rd bit.
• Rotates right by 1 bit.
w
om
Arithmetic instruction
.c
ul
pa
jin
.re
w
w
w
www.rejinpaul.com
om
example
.c
ul
ADD r0, r1, r2
pa
R0 = R1 + R2
SUB r5, r3, #10
R5 = R3 − 10
jin
RSB r2, r5, #0xFF00
.re
R2 = 0xFF00 − R5
w
w
w
www.rejinpaul.com
om
Logical instruction
.c
ul
pa
jin
.re
w
w
w
www.rejinpaul.com
om
Comparison instruction
.c
ul
pa
jin
.re
w
w
w
www.rejinpaul.com
om
Multiply instruction
.c
ul
pa
jin
.re
w
w
w
www.rejinpaul.com
om
2. Branch Instructions
.c
ul
pa
jin
.re
w
w
w
www.rejinpaul.com
om
3.Load Store Instructions
Single register transfer
.c
ul
pa
jin
.re
w
w
w
www.rejinpaul.com
om
.c
ul
pa
jin
.re
w
w
w
www.rejinpaul.com
om
addressing mode
.c
ul
pa
jin
.re
w
w
w
www.rejinpaul.com
om
Multiple Register Transfer
.c
ul
pa
jin
.re
w
w
w
www.rejinpaul.com
om
Swap instruction
.c
ul
pa
jin
.re
w
w
w
www.rejinpaul.com
om
Software interrupt Instructions
.c
ul
pa
jin
.re
w
w
w
www.rejinpaul.com
om
Instructions
.c
ul
pa
jin
.re
w
w
w
www.rejinpaul.com
om
Coprocessor Instruction
.c
ul
pa
jin
.re
w
w
w
www.rejinpaul.com
om
.c
ul
pa
2.5 Stack and subroutine
jin
.re
w
w
w
www.rejinpaul.com
om
Stack and subroutine
.c
ul
pa
jin
.re
w
w
w
www.rejinpaul.com
om
.c
ul
pa
jin
.re
w
w
w
www.rejinpaul.com
om
Calling A subroutine
Parameter passing
.c
Software delay
ul
pa
jin
.re
w
w
w
www.rejinpaul.com
om
.c
ul
pa
2.6 Features of the LPC 214x family
jin
.re
w
w
w
www.rejinpaul.com
om
.c
The LPC2148 is a 16 bit or 32 bit ARM7 family based
microcontroller and available in a small LQFP64
ul
package.
pa
ISP (in system programming) or IAP (in application
programming) using on-chip boot loader software.
jin
On-chip static RAM is 8 kB-40 kB, on-chip flash
memory is 32 kB-512 kB, the wide interface is 128 bit,
.re
or accelerator allows 60 MHz high-speed operation.
It takes 400 milliseconds time for erasing the data in
w
om
Embedded Trace interfaces and Embedded ICE RT
offers real-time debugging with high-speed tracing of
.c
instruction execution and on-chip Real Monitor
software.
ul
It has 2 kB of endpoint RAM and USB 2.0 full speed
pa
device controller. Furthermore, this microcontroller
offers 8kB on-chip RAM nearby to USB with DMA.
jin
One or two 10-bit ADCs offer 6 or 14 analogs i/ps with
low conversion time as 2.44 μs/ channel.
.re
Only 10 bit DAC offers changeable analog o/p.
External event counter/32 bit timers-2, PWM unit, &
w
watchdog.
w
om
Several serial interfaces like two 16C550 UARTs, two
I2C-buses with 400 kbit/s speed.5 volts tolerant quick
general purpose Input/output pins in a small LQFP64
.c
package.
ul
Outside interrupt pins-21.60 MHz of utmost CPU
CLK-clock obtainable from the programmable-on-chip
pa
phase locked loop by resolving time is 100 μs.
The incorporated oscillator on the chip will work by an
jin
exterior crystal that ranges from 1 MHz-25 MHz
.re
The modes for power-conserving mainly comprise idle
& power down.
For extra power optimization, there are individual
w
om
.c
ul
pa
2.7 PERIPHERALS:
jin
.re
w
w
w
www.rejinpaul.com
om
Embedded systems that interacts with the outside
world, needs some peripheral device. A peripheral
device performs input and output functions for the
.c
chip by connecting to other devices or sensors that are
ul
off chip.
Each peripheral device performs one function from
pa
outside of chip. Peripheral range is from simple serial
communication to complex 802.11 wireless devices.
jin
All ARM peripherals are memory mapped. It has set of
addressed registers. This address registers used to
.re
select the exact peripheral device address
w
w
w
www.rejinpaul.com
om
Controllers-Specialized peripherals for higher level functionality. Its two
types are,
Memory controllers.
.c
Interrupt controllers.
Memory controllers:
ul
Connect different types of memory to the processor bus.
On- power-up a memory controller is configured in hardware to allow
pa
the certain memory devices to be active.
Some memory devices must be set up by software.
jin
Interrupt controllers:
When a peripheral device requires a attention it raises the interrupt to
.re
the processor.
The interrupt controller provides the programmable governing policy
that allows the software to determine which peripheral device can
w
om
Two types of interrupt controllers for ARM:
The Standard interrupt controller.
.c
The Vector interrupt controller (VIC).
The Standard interrupt controller:
ul
It sends the interrupt signal to the processor core, when an external
pa
device requests servicing.
It can be programmed to ignore or mask other individual device or set
of devices.
jin
The interrupt handler determines which device requires to servicing by
reading a device bitmap register in the interrupt controller.
.re
The Vector interrupt controller (VIC):
It is powerful than Standard interrupt controller. It has prioritizes
interrupts. So determination of which device caused the interrupt is
w
simple.
The VIC only allows an interrupt signal to the core if the new higher
w
om
.c
ul
pa
jin
.re
w
w
w
www.rejinpaul.com
om
executing on hardware
.c
ul
pa
jin
.re
w
w
w
www.rejinpaul.com
om
.c
ul
pa
2.9 The Timer Unit
jin
.re
w
w
w
www.rejinpaul.com
om
in LPC2148
.c
Prescale register (PR)
ul
Prescaler Counter register (PC)
pa
Timer counter register(TC)
Ttimer control register(TCR)
jin
Conter control register(CTCR)
Match control Register (MCR)
.re
Interrupt Register(IR)
w
w
w
www.rejinpaul.com
om
Timer 0 register
.c
1. T0IR(Timer 0 interrupt Register)
1.
ul
pa
2.T0TCR(Timer 0 Timer Control Register)
jin
.re
3.T0CTCR(Timer 0 counter control register)
w
w
w
www.rejinpaul.com
om
4. T0TC(Timer 0 Timer Counter)
5.T0PR(Timer 0 Prescale Register)
.c
6.T0PC(Timer 0 prescale counter register)
ul
7.T0MR0-T0MR3(Timer0 Match Register)
pa
8.T0MCR(Timer0 Match Control Register)
jin
.re
w
w
w
www.rejinpaul.com
om
.c
ul
pa
2.10 UART
jin
.re
w
w
w
www.rejinpaul.com
om
UART
Universal Asynchronous Receiver/Transmitter
.c
ul
pa
jin
.re
w
w
w
www.rejinpaul.com
om
UART in LPC2148 ARM 7 Micro controller
.c
ul
pa
jin
.re
w
w
w
www.rejinpaul.com
om
in LPC2148
.c
UART0 Receiver Buffer Register(U0RBR)
ul
UART0 Transmit Holding Register(U0THR)
pa
UART0 Divisor Latch Register (U0DLL and U0DLM)
Determine the baud rate generator (U0DLL /
jin
U0DLM). (0x00:00x01)
UART0 Fractional divider register (U0FDR)
.re
It is used for prescale for the baud rate
Both Multiply and Division can be done in prescale
w
om
UART0 Interrupt Enable Register(U0IER)
0 bit- RBR (Receiver buffer Register)interrupt
.c
1 bit- Interrupt enable register
ul
2 bit- Rx line status register
pa
8 bit – End of auto baud rate interrupt
9 bit- auto baud time out interrupt
jin
U0LCR (UART0 Line Control Register)
Bit 1:0 - Word Length Select
.re
00 = 5-bit character length
01 = 6-bit character length
10 = 7-bit character length
w
om
Bit 2 - Number of Stop Bits
0 = 1 stop bit
1 = 2 stop bits
.c
Bit 3 - Parity Enable
0 = Disable parity generation and checking
ul
1 = Enable parity generation and checking
pa
Bit 5:4 - Parity Select
00 = Odd Parity
01 = Even Parity
jin
10 = Forced “1” Stick Parity
11 = Forced “0” Stick Parity
Bit 6 - Break Control
.re
0= Disable break transmission
1 = Enable break transmission
Bit 7 - Divisor Latch Access Bit (DLAB)
w
0 = Disable access to Divisor Latches
w
om
Register)
It provides status information on UART0 RX and TX blocks.
.c
Bit 0 - Receiver Data Ready
0 = U0RBR is empty
ul
1 = U0RBR contains valid data
pa
Bit 1 - Overrun Error
0 = Overrun error status inactive
1 = Overrun error status active
jin
This bit is cleared when U0LSR is read.
Bit 2 - Parity Error
0 = Parity error status inactive
.re
1 = Parity error status active
This bit is cleared when U0LSR is read.
w
w
w
www.rejinpaul.com
om
Bit 3 - Framing Error
0 = Framing error status inactive
1 = Framing error status active
.c
This bit is cleared when U0LSR is read.
Bit 4 - Break Interrupt
ul
0 = Break interrupt status inactive
1 = Break interrupt status active
pa
This bit is cleared when U0LSR is read.
Bit 5 - Transmitter Holding Register Empty
0 = U0THR has valid data
jin
1 = U0THR empty
Bit 6 - Transmitter Empty
.re
0 = U0THR and/or U0TSR contains valid data
1 = U0THR and U0TSR empty
Bit 7 - Error in RX FIFO (RXFE)
w
om
Register)
.c
The U0TER enables implementation of software flow control. When
TXEn=1, UART0 transmitter will keep sending data as long as they are
ul
available. As soon as TXEn becomes 0, UART0 transmission will stop.
Software implementing software-handshaking can clear this bit when
pa
it receives an XOFF character (DC3). Software can set this bit again
when it receives an XON (DC1) character.
Bit 7 : TXEN
jin
0 = Transmission disabled
1 = Transmission enabled
.re
If this bit is cleared to 0 while a character is being sent, the
transmission of that character is completed, but no further characters
are sent until this bit is set again
w
w
w
www.rejinpaul.com
om
.c
ul
2.11 Block Diagram of ARM9
pa
jin
.re
w
w
w
www.rejinpaul.com
om
.c
ul
pa
jin
.re
w
w
w
www.rejinpaul.com
om
.c
ul
pa
jin
.re
w
w
w
www.rejinpaul.com
om
ARM9TDMI
.c
ul
pa
ARM940T Cached Processor
jin
.re
w
w
w
www.rejinpaul.com
om
ARM7TDMI
.c
ul
pa
jin
.re
w
w
w
www.rejinpaul.com
om
Pipeline Process
.c
ul
pa
jin
.re
w
w
w
www.rejinpaul.com
om
DATA FLOW
.c
ul
pa
jin
.re
w
w
w
www.rejinpaul.com
om
COMPARISION SUMMARY
.c
ul
pa
jin
.re
w
w
w
www.rejinpaul.com
om
.c
ul
2.9 Pulse Width Modulation(PWM)
pa
jin
.re
w
w
w
www.rejinpaul.com
om
.c
ul
pa
jin
.re
w
w
w
www.rejinpaul.com
om
.c
ul
pa
jin
.re
w
w
w
www.rejinpaul.com
om
LPC 2148
.c
It consist of 32 timer /counter ie PWMTC
ul
Counter count the cycles of peripheral clock(PCLK)
pa
It having 32bit prescale register (PWMPR)
It having 7 matching register (PWMR0-PWMR06)
jin
6 different pwm signal in single edge controlled pwm
or 3 different pwm signal in double edge controlled
.re
pwm
Match register will match and then it will reset the
w
timer/counter or stop.
w
w
www.rejinpaul.com
om
.c
ul
pa
jin
.re
w
w
w
www.rejinpaul.com
om
.c
ul
pa
jin
.re
w
w
w
www.rejinpaul.com
om
.c
ul
pa
jin
.re
w
w
w
www.rejinpaul.com
om
PWM Registers
1.PWMIR (PWM Interrupt Register)
.c
ul
pa
•It has 7 interrupt bits corresponding to the 7 PWM match registers.
•If an interrupt is generated, then the corresponding bit in this register becomes HIGH.
jin
•Otherwise the bit will be LOW.
•Writing a 1 to a bit in this register clears that interrupt.
•Writing a 0 has no effect.
.re
w
w
w
www.rejinpaul.com
om
2. PWMTCR (PWM Timer Control Register)
.c
It is an 8-bit register.
ul
It is used to control the operation of the PWM Timer Counter.
Bit 0 – Counter Enable
pa
When 1, PWM Timer Counter and Prescale Counter are enabled.
When 0, the counters are disabled.
Bit 1 – Counter Reset
jin
When 1, the PWM Timer Counter and PWM Prescale Counter are synchronously
reset on next positive edge of PCLK.
Counter remains reset until this bit is returned to 0.
.re
Bit 3 – PWM Enable
This bit always needs to be 1 for PWM operation. Otherwise PWM will operate as a
normal timer.
w
When 1, PWM mode is enabled and the shadow registers operate along with match
registers.
w
om
3. PWMTC (PWM Timer Counter)
It is a 32-bit register.
.c
It is incremented when the PWM Prescale Counter (PWMPC) reaches
its terminal count.
ul
4. PWMPR (PWM Prescale Register)
pa
It is a 32-bit register.
It holds the maximum value of the Prescale Counter.
5. PWMPC (PWM Prescale Counter)
It is a 32-bit register.
jin
It controls the division of PCLK by some constant value before it is
.re
applied to the PWM Timer Counter.
It is incremented on every PCLK.
When it reaches the value in PWM Prescale Register, the PWM Timer
w
PCLK.
w
www.rejinpaul.com
om
6. PWMMR0-PWMMR6 (PWM Match Registers)
These are 32-bit registers.
.c
The values stored in these registers are continuously
ul
compared with the PWM Timer Counter value.
pa
When the two values are equal, the timer can be reset
or stop or an interrupt may be generated.
jin
The PWMMCR controls what action should be taken
on a match.
.re
7. PWMMCR (PWM Match Control Register)
It is a 32-bit register.
w
Counter.
w
www.rejinpaul.com
om
.c
ul
pa
Bit 0 – PWMMR0I (PWM Match register 0 interrupt)
0 = This interrupt is disabled
jin
1 = Interrupt on PWMMR0. An interrupt is generated when PWMMR0 matches the value
in PWMTC
Bit 1 – PWMMR0R (PWM Match register 0 reset)
.re
0 = This feature is disabled
1 = Reset on PWMMR0. The PWMTC will be reset if PWMMR0 matches it
Bit 2 – PWMMR0S (PWM Match register 0 stop)
w
om
Bit 2 – PWMSEL2
0 = Single edge controlled mode for PWM2
.c
1 = Double edge controlled mode for PWM2
ul
pa
All other PWMSEL bits have similar operation as
PWMSEL2 above.
jin
.re
Bit 10 – PWMENA2
0 = PWM2 output disabled
1 = PWM2 output enabled
w
PWMENA2 above.
w
www.rejinpaul.com
om
9. PWMLER (PWM Latch Enable Register)
It is an 8-bit register.
.c
ul
It is used to control the update of the PWM Match Registers when they
pa
are used for PWM generation.
When a value is written to a PWM Match Register while the timer is in
PWM mode, the value is held in the shadow register. The contents of
jin
the shadow register are transferred to the PWM Match Register when
the timer resets (PWM Match 0 event occurs) and if the corresponding
.re
bit in PWMLER is set.
Bit 6 – Enable PWM Match 6 Latch
Writing a 1 to this bit allows the last written value to PWMMR6 to
w
become effective when timer next is reset by the PWM match event.
Similar description as that of Bit 6 for the remaining bits.
w
w
www.rejinpaul.com
om
Reset and disable PWM counter using PWMTCR
Load prescale value according to need of application in the PWMPR
.c
Load PWMMR0 with a value corresponding to the time period of your
PWM wave
ul
Load any one of the remaining six match registers (two of the
remaining six match registers for double edge controlled PWM) with
pa
the ON duration of the PWM cycle. (PWM will be generated on PWM
pin corresponding to the match register you load the value with).
jin
Load PWMMCR with a value based on the action to be taken in the
event of a match between match register and PWM timer counter.
Enable PWM match latch for the match registers used with the help of
.re
PWMLER
Select the type of PWM wave (single edge or double edge controlled)
and which PWMs to be enabled using PWMPCR
w
om
.c
ul
2.12 Block diagram of ARM CORTEX M3 MCU
pa
jin
.re
w
w
w
www.rejinpaul.com
om
.c
ul
pa
jin
.re
w
w
w
www.rejinpaul.com
om
INTNMI- Non-maskable interrupt
.c
INTISR[239:0]- External interrupt signals
SLEEPING- Indicates that the Cortex-M3 clock can be
ul
stopped.
pa
SLEEPDEEP - Indicates that the Cortex-M3 clock can be
stopped
jin
WIC - Wake-up Interrupt Controller
NVIC- Nested Vectored Interrupt Controller
.re
ETM- Embedded Trace Macrocell
The ETM is an optional debug component that enables
w
om
MPU- Memory Protection Unit
The MPU provides full support for:
.c
protection regions
ul
overlapping protection regions, with ascending
region priority:
pa
— 7 = highest priority
— 0 = lowest priority.
jin
access permissions
.re
exporting memory attributes to the system.
w
w
w
www.rejinpaul.com
om
FPB-Flash Patch and Breakpoint
unit to implement breakpoints and code patches.
DWT -Data Watchpoint and Trace () unit to
.c
implement watchpoints, trigger resources, and system
ul
profiling.
ITM- Instrumentation Trace Macrocell for application-
pa
driven trace source that supports printf style
debugging.
jin
TPIU- Trace Port Interface Unit
it is an optional component that acts as a bridge
.re
between the on-chip trace data from the Embedded
Trace Macrocell (ETM) and the Instrumentation Trace
w
om
SW/SWJ-DP - SW-DP or SWJ-DP debug port
interfaces.
.c
The debug port provides debug access to all registers
and memory in the system, including the processor
ul
registers.
pa
The SW/SWJ-DP might not be present in the
production device if no debug functionality is present
in the implementation.
jin
.re
w
w
w
www.rejinpaul.com
om
.c
ul
UNIT III
pa
EMBEDDED PROGRAMMING
jin
.re
w
w
w
www.rejinpaul.com
Syllabus
om
.c
Components for embedded programs- Models of
programs- Assembly, linking and loading –
ul
compilation techniques- Program level performance
pa
analysis – Software performance optimization –
Program level energy and power analysis and
jin
optimization – Analysis and optimization of program
.re
size- Program validation and testing
w
w
w
www.rejinpaul.com
om
1. COMPONENTS FOR EMBEDDED PROGRAMS
• Embedded components are given by State machine, Circular buffer, and the
.c
Queue.
ul
1.1)STATE MACHINE
• The reaction of most systems can be characterized in terms of the input received
pa
and the current state of the system.
• The finite-state machine style of describing the reactive system’s behavior..
•
jin
Finite-state machines are usually first encountered in the context of hardware
design.
.re
w
w
w
www.rejinpaul.com
om
software state machine
.c
ul
pa
jin
.re
w
w
w
www.rejinpaul.com
seat, belt, timer
om
case BELTED:
#define IDLE 0 if (!seat) state = IDLE; /* person left */
#define SEATED 1
else if (!belt) state = SEATED; /* person
#define BELTED 2
.c
still
#define BUZZER 3
switch (state) { /* check the current state in seat */
ul
*/ break;
case IDLE: case BUZZER:
pa
if (seat) { state = SEATED;
if (belt) state = BELTED; /* belt is on—
timer_on = TRUE; }
turn off
/* default case is self-loop */
break;
case SEATED: jin buzzer */
else if (!seat) state = IDLE; /* no one in
if (belt) state = BELTED; /* won't hear the seat—turn off buzzer */
.re
buzzer */ break;
else if (timer) state = BUZZER; /* didn't
put on }
w
belt in time */
/* default is self-loop */
w
break;
w
www.rejinpaul.com
1.2)Stream-Oriented Programming and Circular Buffers
om
• The circular buffer is a data structure that handle streaming
data in an efficient way.
.c
• Size of the window does not change.
ul
• Fixed-size buffer to hold the current data.
• To avoid constantly copying data within the buffer, move the
pa
head of the buffer in time.
• The buffer points to the location at which the next sample will
be placed. jin
.re
• Every time add a sample, automatically overwrite the oldest
sample, which is the one that needs to be thrown out.
w
• When the pointer gets to the end of the buffer, it wraps around
to the top.
w
w
www.rejinpaul.com
Circular buffer for streaming data.
om
.c
ul
pa
jin
.re
w
w
w
www.rejinpaul.com
om
1.3 QUEUES
• Queues are also used in signal processing and event
.c
processing.
ul
• Queues are used whenever data may arrive and depart at
somewhat unpredictable times or when variable amounts of
pa
data may arrive.
• A queue is often referred to as an Elastic buffer.
jin
.re
w
w
w
www.rejinpaul.com
2.MODELS OF PROGRAMS
om
• Programs are collection of instructions to execute a specified
.c
task.
ul
• Models for programs are more general than source code.
• source code can’t be used directly because of different type s
pa
such as assembly language,C code.
• Single model to describe all of them.
jin
• control/data flow graph (CDFG)it is the fundamental model
.re
for programs
w
w
w
www.rejinpaul.com
om
2.1 DATA FLOW GRAPH
• A data flow graph is a model of a program with no conditionals.
• In a high-level programming language, a code segment with no
.c
conditionals have only one entry and exit point—is known as a basic
ul
block.
A basic block in C
pa
jin
.re
w
w
w
www.rejinpaul.com
An extended data flow graph for our sample basic block
om
•The basic block in single-assignment form
.c
ul
pa
•Round nodesdenote operators
•Square nodesdenote values.
jin
.re
•The value nodes may be either inputs(a,b)
or variables(w,x1).
w
w
w
www.rejinpaul.com
Standard data flow graph for our sample basic
om
block
.c
ul
pa
jin
.re
w
w
w
www.rejinpaul.com
om
2.2. Control/Data Flow Graphs(CDFG)
• A CDFG uses a data flow graph as an element,adding
.c
constructs to describe control.
ul
CDFG having following two types of nodes.
pa
1. Decision nodesused to describe the control in a sequential
program
jin
• Data flow nodes encapsulates a complete data flow graph
.re
to represent a data.
w
w
w
www.rejinpaul.com
C code and its CDFG
om
if (cond1)
basic_block_1( );
.c
else
basic_block_2();
ul
basic_block_3( );
pa
switch (test1) {
case c1: basic_block_4( ); break;
case c2: basic_block_5( ); break;
jin
case c3: basic_block_6( ): break;
}
.re
•Rectangular nodesrepresent the basic blocks.
•Diamond-shaped nodes represent the conditionals.
•Label node’s condition
w
om
CDFG for a while loop
.c
while (a < b) {
ul
a5proc1(a,b);
pa
b5proc2(a,b);
}
jin
.re
w
w
w
www.rejinpaul.com
om
CDFG for a while loop
.c
while (a < b) {
ul
a5proc1(a,b);
pa
b5proc2(a,b);
}
jin
.re
w
w
w
www.rejinpaul.com
3. ASSEMBLY, LINKING AND LOADING
om
•Assembly and linking last steps in the compilation process
•They convert list of instructions into an image of the program’s
.c
bits in memory.
ul
•Loading puts the program in memory so that it can be
executed.
pa
jin
.re
w
w
w
www.rejinpaul.com
om
• Compilers used to create the instruction-level program in to
assembly language code.
.c
• Assembler’s used to translate symbolic assembly language
statements into bit-level representations of instructions known
ul
as object code and also translating labels into addresses.
pa
• Linker determining the addresses of instructions.
• Loader load the program into memory for execution.
jin
• Absolute addresses Assembler assumes that the starting
address of the ALP has been specified by the programmer.
.re
• Relative addresses specifying at the start of the file address
is to be computed later.
w
w
w
www.rejinpaul.com
om
3.1 Assemblers
• Assembler Translating assembly code into object code also
.c
assembler must translate opcodes and format the bits in each
ul
instruction, and translate labels into addresses.
• Labels it is an abstraction provided by the assembler.
pa
• Labelsknow the locations of instructions and data.
Label processing requires making two passes
jin
1. first pass scans the code to determine the address of each label.
.re
2. second pass assembles the instructions using the label values
computed in the first pass.
w
w
w
www.rejinpaul.com
EXAMPLE
om
CODE SYMBOL TABLE
.c
ul
pa
jin
.re
w
w
w
www.rejinpaul.com
om
3.2)LINKING
.c
• A linker allows a program to be stitched together out of several smaller
pieces.
ul
• The linker operates on the object files and links between files.
• Some labels will be both defined and used in the same file.
pa
• Other labels will be defined in a single file but used elsewhere .
• The place in the file where a label is defined is known as an entry point.
jin
• The place in the file where the label is used is called an external reference.
Phases of linker
.re
• First Phaseit determines the address of the start of each object file
• Second Phasethe loader merges all symbol tables from the object files
w
om
• The techniques we use to analyze program execution time are
also helpful in analyzing properties such as power consumption.
.c
• The CPU executes the entire program at the rate we desire.
ul
• The execution time of a program often varies with the input data
pa
values.
• The cache has a major effect on program performance.
jin
• Cache’s behavior depends in part on the data values input to the
program.
.re
• The execution time of an instruction in a pipeline depends not
only on that instruction but on the instructions around it in the
w
pipeline.
w
w
www.rejinpaul.com
Execution time of a program
om
.c
ul
pa
jin
.re
w
w
w
www.rejinpaul.com
4.1. Program Performance Measuring techniques
om
1. Simulator
• It runs on a PC, takes as input an executable for the
.c
microprocessor along with input data, and simulates the program.
ul
2. Timer
• It is can be used to measure performance of executing sections of
pa
code.
• The length of the program that can be measured is limited by the
jin
accuracy of the timer.
3. Logic analyzer
.re
• It is used to measure the start and stop times of a code segment.
• The length of code that can be measured is limited by the size of
w
om
1. Average-case execution time
• This is the typical execution time we would expect for typical data.
.c
2. Worst-case execution time
• The longest time that the program can spend on any input sequence is
ul
clearly important for systems that must meet deadlines.
pa
3. Best-case execution time
• This measure can be important in multi-rate real-time systems.
jin
4.3) Elements of Program Performance
•Execution time =Program path +Instruction timing
.re
•Program path It is the sequence of instructions executed by the program.
•Instruction timingIt is determined based on the sequence of instructions
w
om
• To measure the program’s performance need CPU or its simulator .
• Measuring program performance combination of determination of
.c
the execution path and the timing of that path.
ul
• program trace record of the execution path of a program.
pa
Cycle-Accurate Simulator
• It can determine the exact number of clock cycles required for
execution.
jin
• It is built with detailed knowledge of how the processor works .
• It is slower than the processor itself, but a variety of techniques can
.re
be used to make them surprisingly fast.
• It has a complete model of the processor, including the cache.
w
• It can provide information about why the program runs too slowly.
w
w
www.rejinpaul.com
5. SOFTWARE PERFORMANCE OPTIMIZATION
om
5.1)Loop Optimizations-Loops are important targets for optimization
because programs with loops tend to spend a lot of time executing
.c
those loops.
•
ul
Code motion
• Induction variable elimination
pa
• Strength reduction
Code motion
jin
• It can move unnecessary code out of a loop.
• If a computation’s result does not depend on operations performed
.re
in the loop body,thenwe can safely move it out of the loop.
for (i = 0; i < N*M; i++)
w
{
w
}
www.rejinpaul.com
Code motion in a loop
om
.c
ul
pa
jin
.re
•The loop bound computation is performed on every iteration during
w
om
• It is a variable whose value is derived from the loop iteration variable’s value.
• The compiler often introduces induction variables to help it implement the
.c
loop.
• Properly transformed able to eliminate some variables and apply strength
ul
reduction to others.
•
pa
A nested loop is a good example of the use of induction variables.
for (i = 0; i < N; i++)
for (j = 0; j < M; j++)
•
z[i][j] = b[i][j];
jin
The compiler uses induction variables to help it address the arrays. Let us
.re
rewrite the loop in C using induction variables and pointers
for (i = 0; i < N; i++)
w
}
www.rejinpaul.com
om
Strength reduction
• It reduce the cost of a loop iteration.
.c
Consider the following assignment
y = x * 2;
ul
• In integer arithmetic, we can use a left shift rather than a
pa
multiplication by 2
• If the shift is faster than the multiply, then perform the substitution.
• This optimization can often be used with induction variables because
jin
loops are often indexed with simple expressions.
.re
w
w
w
www.rejinpaul.com
om
5.2 Cache Optimizations
• A loop nest is a set of loops, one inside the other.
• Loop nests occur when we process arrays.
.c
• A large body of techniques has been developed for optimizing loop
ul
nests.
• Rewriting a loop nest changes the order in which array elements are
pa
accessed.
• This can expose new parallelism opportunities that can be exploited
jin
by later stages of the compiler, and it can also improve cache
performance.
.re
w
w
w
www.rejinpaul.com
6. PROGRAM-LEVEL ENERGY AND POWER
om
ANALYSIS AND OPTIMIZATION
.c
• Power consumption is a important design metric for battery-
powered systems.
ul
• It is increasingly important in systems that run off the power grid.
pa
• Fast chips run hot, and controlling power consumption is an
important element of increasing reliability and reducing system cost.
jin
Power consumption reduction techniques.
• To replace the algorithms with others that consume less power.
.re
• By optimizing memory accesses ,able to significantly reduce power.
• To turn off the subsystems of CPU, chips in the system, in order to
w
save power.
w
w
www.rejinpaul.com
Measuring energy consumption for a piece of code
om
Program’s energy consumption how
much energy the program consumes.
.c
To measure power consumption for an
instruction or a small code fragment.
ul
It is used to executes the code under test
pa
over and over in a loop.
By measuring the current flowing into the
CPU,we are measuring the power
jin
consumption of the complete loop,
including both the body and other code.
.re
By separately measuring the power
consumption of a loop with no body.
we can calculate the power consumption
w
om
List of the factors contribution for energy consumption of the
program.
• Energy consumption varies somewhat from instruction to instruction.
.c
• The sequence of instructions has some influence.
• The opcode and the locations of the operands also matter.
ul
Steps to Improve Energy Consumption
pa
• Try to use registers efficiently(r4)
• Analyze cache behavior to find major cache conflicts.
•
•
jin
Make use of page mode accesses in the memory system whenever possible.
Moderate loop unrolling eliminates some loop control overhead. when the
.re
loop is unrolled too much, power increases.
• Software pipelining reducing the average energy per instruction.
• Eliminating recursive procedure calls where possible saves power by getting
w
om
7. ANALYSIS AND OPTIMIZATION OF PROGRAM SIZE
• Memory size of a program is determined by the size of its data and instructions.
• Both must be considered to minimize program size.
.c
• Data provide an opportunity to minimizing the size of program.
ul
• Data buffers can be reused at several different points in program, which reduces
program size.
pa
• Some times inefficient programs keep several copies of data, identifying and
eliminating duplications can lead to significant memory savings.
• Minimizing the size of the instruction text and reducing the number of
•
jin
instructions in a program which reduces program size
Proper instruction selection may reduce code size.
.re
• Special compilation modes produce the program in terms of the dense
instruction set.
w
• Program size of course varies with the type of program, but programs using the
dense instruction set are often 70 to 80% of the size of the standard instruction
w
set equivalents.
w
www.rejinpaul.com
8. PROGRAM VALIDATION AND
om
TESTING
• Complex systems need testing to ensure the working behavior of the
.c
systems.
ul
• Software Testingused to generate a comprehensive set of tests to
ensure that our system works properly.
pa
• The testing problem is divided into sub-problems and analyze each sub
problem.
jin
Types of testing strategies
1. White/Clear-box Testing generate tests ,based on the program
.re
structure.
2. Black-box Testing generate tests ,without looking at the internal
w
om
• Testingrequires the control/data flow graph of a program’s source
.c
code.
• To test the program exercise both its control and data operations.
ul
• To execute and evaluate the tests control the variables in the
pa
program and observe the results .
The following three things to be followed during a test
jin
1. Provide the program with inputs for the test.
2. Execute the program to perform the test.
.re
3. Examine the outputs to determine whether the test was successful.
• Execution PathTo test the program by forcing the program to
w
om
•It help us get a quantitative handle on the different paths required.
•Undirected graph-form any path through the graph from combinations of basis
.c
paths.
•Incidence matrix contains each row and column represents a node.
ul
•1 is entered for each node pair connected by an edge.
pa
jin
.re
w
w
w
www.rejinpaul.com
om
Cyclomatic Complexity
• It is a software metric tool.
.c
• Used to measure the control complexity of a program.
ul
M = e – n + 2p.
• e number of edges in the flow graph
pa
• n number of nodes in the flow graph
• p number of components in the graph
jin
.re
w
w
w
www.rejinpaul.com
om
Types of Clear Box test strategy
1. Branch testing
.c
2. Domain testing
ul
3. Data flow testing
pa
jin
.re
w
w
w
www.rejinpaul.com
om
8.1.1 Branch testing
.c
• This strategy requires the true and false branches of a
conditional.
ul
• Every simple condition in the conditional’s expression to be
pa
tested at least once.
if ((x == good_pointer) && (x->field1 == 3))
jin
{ printf("got the value\n"); }
The bad code we actually wrote
.re
if ((x = good_pointer) && (x->field1 == 3))
{ printf("got the value\n"); }
w
w
w
www.rejinpaul.com
8.1.2 Domain testing
om
• It concentrates on linear-inequalities.
• The program should use for the test is j <= i + 1
.c
• We test the inequality with three test points
• Two on the boundary of the valid region
ul
• Third outside the region but between the i values of the other
pa
two points.
jin
.re
w
w
w
www.rejinpaul.com
8.1.3 Data flow testing
om
• It use of def-use analysis (definition-use analysis).
.c
• It selects paths that have some relationship to the program’s
function.
ul
• Compilers which use def-use analysis for Optimization.
pa
• A variable’s value is defined when an assignment is made to the
variable.
• It is used when it appears on the right side of an assignment.
jin
.re
w
w
w
www.rejinpaul.com
8.2)Block Box Testing
om
.c
• Black-box tests are generated without knowledge of the code being
tested.
ul
• It have a low probability of finding all the bugs in a program.
pa
• We can’t test every possible input combination, but some rules help
us select reasonable sets of inputs.
1. Random Tests
jin
• Random values are generated with a given inputs.
.re
• The expected values are computed first, and then the test inputs are
applied.
w
w
w
www.rejinpaul.com
om
2. Regression Tests
• When tests are created during earlier or previous versions of the
system.
.c
• Those tests should be saved apply to the later versions of the
ul
system.
• It simply exercise current version of the code and possibly exercise
pa
different bugs.
• In digital signal processing systems Signal processing algorithms
jin
are implemented to save hardware costs.
• Data sets can be generated for the numerical accuracy of the
.re
system.
• These tests can often be generated from the original formulas
w
om
UNIT IV
.c
REAL TIME SYSTEMS
ul
Structure of a Real Time System - Estimating program run
pa
times – Task Assignment and Scheduling – Fault Tolerance
Techniques – Reliability, Evaluation – Clock
Synchronisation.
jin
.re
w
w
w
www.rejinpaul.com
om
Operating System
.c
An Operating System performs all the basic tasks like
ul
managing file, process, and memory.
pa
Thus operating system acts as manager of all the
resources, i.e. resource manager.
jin
Thus operating system becomes an interface between
user and machine.
.re
w
w
w
www.rejinpaul.com
om
Types of Operating Systems
.c
Batch Operating System
ul
Time-Sharing Operating Systems
Distributed Operating System
pa
Network Operating System
jin
Real-Time Operating System
.re
w
w
w
www.rejinpaul.com
om
1. Batch Operating System
.c
ul
pa
jin
.re
w
w
w
www.rejinpaul.com
Time-Sharing Operating
om
Systems
.c
ul
pa
jin
.re
w
w
w
www.rejinpaul.com
om
Distributed Operating System
.c
ul
pa
jin
.re
w
w
w
www.rejinpaul.com
om
Network Operating System
.c
ul
pa
jin
.re
w
w
w
www.rejinpaul.com
om
Real-Time Operating System
.c
These types of OSs serves the real-time systems. The
ul
time interval required to process and respond to
pa
inputs is very small. This time interval is
called response time.
jin
.re
w
w
w
www.rejinpaul.com
om
Real-time systems are used when there are time
requirements are very strict like missile systems, air
.c
traffic control systems, robots etc
Two types of Real-Time Operating System which
ul
are as follows:
pa
Hard Real-Time Systems:
Soft Real-Time Systems:
jin
.re
w
w
w
www.rejinpaul.com
om
Hard Real-Time Systems:
These OSs are meant for the applications where time
.c
constraints are very strict and even the shortest
possible delay is not acceptable.
ul
These systems are built for saving life like automatic
pa
parachutes or air bags which are required to be readily
available in case of any accident.
jin
Virtual memory is almost never found in these
systems.
.re
w
w
w
www.rejinpaul.com
om
Soft Real-Time Systems:
These OSs are for applications where for time-
.c
constraint is less strict.
ul
pa
jin
.re
w
w
w
www.rejinpaul.com
om
.c
ul
4.1) Structure of a Real Time
pa
System
jin
.re
w
w
w
www.rejinpaul.com
om
.c
ul
pa
jin
.re
w
w
w
www.rejinpaul.com
om
.c
ul
pa
jin
.re
w
w
w
www.rejinpaul.com
om
.c
ul
4.2 Estimating Program Run
pa
Times
jin
.re
w
w
w
www.rejinpaul.com
om
Real time system meet deadlines, it is important to be
able to accurately estimate program run times.
.c
Estimating the executing time of any given program is
a very difficult task
ul
It depend on the following factors
pa
Source code
Compiler-Mapping should be depend on the compiler
used.
jin
Machine architecture
.re
Operating system
w
w
w
www.rejinpaul.com
om
Analysis of a source code
L1: a = b x c;
.c
L2: b = d + e;
L3: d = a – f;
ul
pa
jin
.re
w
w
w
www.rejinpaul.com
om
Example 2
.c
ul
pa
jin
.re
w
w
w
www.rejinpaul.com
om
.c
ul
pa
jin
.re
w
w
w
www.rejinpaul.com
om
.c
ul
pa
jin
.re
w
om
Accounting of Pipeline
.c
ul
pa
jin
.re
w
om
.c
ul
pa
jin
.re
w
w
w
www.rejinpaul.com
om
Cache Memory
.c
Virtual Memory
ul
pa
jin
.re
w
w
w
www.rejinpaul.com
om
.c
ul
4.3 Task Assignment and
pa
Scheduling
jin
.re
w
w
w
www.rejinpaul.com
om
A Task requires some execution time on a processor
.c
Also a task may required certain amount of memory or
access to a bus
ul
Sometimes a resource must be exclusively held by a
pa
task
In other cases resource may be exclusive or non
jin
exclusive depending on the operation to be performed
on it
.re
w
w
w
www.rejinpaul.com
om
Release Time
A task is a time at which all the data that are required to
.c
begin executing the Task are available
Deadline
ul
The deadline is the time by which the task must complete its
pa
execution
The deadline must be hard or soft
Task are classified as
jin
Periodic
Sporadic
.re
Aperiodic
w
w
w
www.rejinpaul.com
om
Periodic
A task ti is periodic if it is released periodically.
.c
say every pi seconds pi is called the period of task Ti
ul
Sporadic Task
pa
Sporadic task is a not periodic task, but may be invoked at irregular
interval
Sporadic tasks are characterized by an upper bound on the rate at
jin
which they may be invoked
.re
APeriodic Task
Tasks to be those tasks which are not periodic and which also have no
upper bound on their invocation rate
w
w
w
www.rejinpaul.com
om
Task Assignment / Schedule
All task starts after the release time and complete before
.c
their deadline
ul
pa
jin
A schedule may be
Precomputed(Offline scheduling)
.re
Dynamically(Online Scheduling)
w
w
w
www.rejinpaul.com
om
Precomputed
Advance the operation with specification of periodic tasks will be
.c
run and slots for the sporadic / aperiodic tasks in the event that
they are involved.
ul
pa
Dynamically
Tasks are scheduled as they arrive in the system
jin
The algorithm used in online scheduling must be fast
and it takes to meet their deadlines is clearly useless
.re
Two types priority algorithms are used
Static priority algorithm
w
om
Static priority algorithm
Static priority algorithm assume that the task priority does not
.c
change within a mode
Example Rate monotonic algorithm
ul
Dynamic priority algorithm
pa
algorithm assume that the task priority can change within a time
Example Earliest Deadline First (EDF)algorthim
jin
.re
w
w
w
www.rejinpaul.com
om
Classical uni-processor Scheduling Algorthim
.c
ul
pa
jin
.re
w
w
w
www.rejinpaul.com
om
Example for Rate monotonic scheduling
.c
ul
pa
jin
.re
w
w
w
www.rejinpaul.com
om
.c
ul
pa
jin
.re
w
w
w
www.rejinpaul.com
om
.c
ul
pa
jin
.re
w
w
w
www.rejinpaul.com
om
UNIT V
.c
PROCESSES AND OPERATING SYSTEMS
ul
Introduction – Multiple tasks and multiple processes – Multirate
systems- Preemptive real-time operating systems- Priority based
pa
scheduling- Interprocess communication mechanisms – Evaluating
operating system performance- power optimization strategies for
processes – Example Real time operating systems-POSIX-Windows-
jin
CE. Distributed embedded systems – MPSoCs and shared memory
multiprocessors. – Design Example - Audio player, Engine control unit
– Video accelerator.
.re
w
w
w
www.rejinpaul.com
om
5.1)INTRODUCTION
Simple applications can be programmed on a microprocessor by writing a single
.c
piece of code.
But for a complex application, multiple operations must be performed at widely
ul
varying times.
Two fundamental abstractions that allow us to build complex applications on
pa
microprocessors.
1. Process defines the state of an executing program
2. operating system (OS)provides the mechanism for switching execution
between the processes.
jin
.re
w
w
w
www.rejinpaul.com
om
PROCESSES
Systems which are capable of performing multiprocessing known as multiple
.c
processor system.
Multiprocessor system can execute multiple processes simultaneously with the
ul
help of multiple CPU.
Multi-
Multi-tasking
tasking
The ability of an operating system to hold multiple processes
pa
in memory and switch the processor for executing one process.
5.2.1)Tasks and Processes
jin
Task is nothing but different parts of functionality in a single system.
Eg-Mobile Phones
When designing a telephone answering machine, we can define recording a
.re
phone call ,answering a call and operating the user’s control panel as distinct
tasks, at different rates.
Each application in a system is called a task.
w
w
w
www.rejinpaul.com
5.2.2)Process
om
A process is a single execution of a program.
If we run the same program two different times, we have created two
.c
different processes.
Each process has its own state that includes not only its registers but all
ul
of its memory.
pa
In some OSs, the memory management unit is used to keep each
process in a separate address space.
In others, particularly lightweight RTOSs, the processes run in the
jin
same address space.
Processes that share the same address space are often called threads.
.re
w
w
w
www.rejinpaul.com
om
This device is connected to serial ports on both ends.
The input to the box is an uncompressed stream of bytes.
The box emits a compressed string of bits, based on a compression table.
.c
ul
pa
jin
.re
Ex: compress data being sent to a modem.
The program’s need to receive and send data at different rates
w
EgThe program may emit 2 bits for the first byte and then 7 bits for the
second byte— will obviously find itself reflected in the structure of the code.
w
om
5.2.3)Asynchronous input
Ex:A control panel on a machine provides a different type of rate.
.c
The control panel of the compression box include a compression mode button
that disables or enables compression, so that the input text is passed through
ul
unchanged when compression is disabled.
Sampling the button’s state too slowly machine will miss a button
pa
depression entirely.
Sampling it too frequently the machine will do incorrectly compress data.
To solve this problem every n times the compression loop is executed.
jin
.re
w
w
w
www.rejinpaul.com
5.3.1)Multi--rate Systems
5.3.1)Multi
om
In operating system implementing code for satisfies timing requirements is
more complex when multiple rates of computation must be handled.
.c
Multirate embedded computing systemsEx: automobile engines, printers,
and cell phones.
ul
In all these systems, certain operations must be executed periodically with its
own rate.
pa
EgAutomotive engine control
jin
.re
w
w
w
www.rejinpaul.com
om
The simplest automotive engine controllers, such as the ignition controller for a
basic motorcycle engine, perform only one task—timing the firing of the spark
plug, which takes the place of a mechanical distributor.
Spark Plug
.c
The spark plug must be fired at a certain point in the combustion cycle.
ul
Microcontroller
Using a microcontroller that senses the engine crankshaft position allows the
spark timing to vary with engine speed.
pa
Firing the spark plug is a periodic process.
Engine controller
jin
Automobile engine controllers use additional sensors, including the gas pedal
position and an oxygen sensor used to control emissions.
They also use a multimode control scheme. one mode may be used for engine
.re
warm-up, another for cruise, and yet another for climbing steep hills.
The engine controller takes a variety of inputs that determine the state of the
engine.
w
It then controls two basic engine parameters: the spark plug firings and the
fuel/air mixture.
w
w
www.rejinpaul.com
om
Task performed by engine controller unit
.c
ul
pa
jin
.re
w
w
w
www.rejinpaul.com
5.3.1)Timing Requirements on Processes
om
Processes can have several different types of timing requirements based on the
application.
The timing requirements on a set of processes strongly depends on the type of
.c
scheduling.
A scheduling policy must define the timing requirements that it uses to
ul
determine whether a schedule is valid.
1. Release time
pa
The time at which the process becomes ready to execute.
simpler systems the process may become ready at the beginning of the period.
sophisticated systems set the release time at the arrival time of certain data, at
jin
a time after the start of the period.
.re
w
w
w
www.rejinpaul.com
om
2. Deadline
specifies when a computation must be finished.
.c
The deadline for an a periodic process is generally measured from the release
time or initiation time.
ul
The deadline for a periodic process may occur at the end of the period.
The period of a process is the time between successive executions.
pa
The process’s rate is the inverse of its period.
In a Multi rate system, each process executes at its own distinct rate.
jin
.re
w
w
w
www.rejinpaul.com
om
Example definitions of release times and deadlines
.c
ul
pa
jin
.re
w
w
w
www.rejinpaul.com
om
A sequence of processes with a high initiation rate
.c
ul
pa
jin
•In this case, the initiation interval is equal to one fourth of the period.
•It is possible for a process to have an initiation rate less than the period even in
.re
single-CPU systems.
•If the process execution time is less than the period, it may be possible to initiate
multiple copies of a program at slightly offset times.
w
w
w
www.rejinpaul.com
om
Data dependencies among processes
.c
ul
pa
•The data dependencies define a partial ordering on process execution.
jin
•P1 and P2 can execute in any order but must both complete before P3, and P3
must complete before P4.
•All processes must finish before the end of the period.
.re
Directed Acyclic Graph (DAG)
•It is a directed graph that contains no cycles.
•The data dependencies must form a directed acyclic graph.
w
om
Communication among processes at different rates
(MPEG audio/Video)
.c
ul
pa
•The system decoder process demultiplexes the audio and video data and
distributes it to the appropriate processes.
•Missing Deadline
jin
•Missing deadline in a multimedia system may cause an audio or video glitch.
•The system can be designed to take a variety of actions when a deadline is
missed.
.re
w
w
w
www.rejinpaul.com
om
5.3.2)CPU Metrics
CPU metrics are described by initiation time and completion time.
.c
Initiation timeIt is the time at which a process actually starts executing on
the CPU.
ul
Completion timeIt is the time at which the process finishes its work.
The CPU time of process i is called Ci .
pa
The CPU time is not equal to the completion time minus initiation time.
The total CPU time consumed by a set of processes is
jin
.re
The simplest and most direct measure is utilization.
w
w
w
www.rejinpaul.com
om
5.3.3)Process State and Scheduling
The first job of the OS is to determine that process runs next.
The work of choosing the order of running processes is known as scheduling.
.c
There three basic scheduling ,such as waiting, ready and executing.
ul
pa
jin
.re
A process goes into the waiting state when it needs data that it has finished all its work for
the current period.
A process goes into the ready state when it receives its required data, when it enters
w
a new period.
Finally a process can go into the executing state only when it has all its data, is ready to
w
run, and the scheduler selects the process as the next process to run.
w
www.rejinpaul.com
5.3.4)Scheduling Policies
om
A scheduling policy defines how processes are selected for promotion from the
ready state to the running state.
.c
SchedulingAllocate time for execution of the processes in a system .
For periodic processes, the length of time that must be considered is the hyper period,
which is the least-common multiple of the periods of all the processes.
ul
Unrolled schedule The complete schedule for the least-common multiple of the
periods.
pa
Types of scheduling
1. Cyclostatic scheduling or Time Division Multiple Access scheduling
Schedule is divided into equal-sized time slots over an interval equal to the length of the
jin
hyperperiod H. (run in the same time slot)
.re
Two factors affect this scheduling
w
om
2)Round Robin-scheduling
Uses the same hyper period as does cyclostatic.
.c
It also evaluates the processes in order.
If a process does not have any useful work to do, the scheduler moves on to the next
process in order to fill the time slot with useful work.
ul
pa
jin
All three processes execute during the first hyperperiod.
During the second one, P1 has no useful work and is skipped so P3 is directly move on to
the next process.
.re
Scheduling overhead
The execution time required to choose the next execution process, which is incurred in
addition to any context switching overhead.
w
w
w
www.rejinpaul.com
om
To calculate the utilization of CPU
.c
ul
pa
jin
.re
w
w
w
www.rejinpaul.com
5.4)Preemptive Real-
Real-Time Operating
om
Systems(RTOS)
A pre emptive OS solves the fundamental problem in multitasking system.
.c
It executes processes based upon timing requirements provided by the system designer.
To meet timing constraints accurately is to build a preemptive OS and to use priorities to
ul
control what process runs at any given time.
5.4.1) Preemption
pa
Preemption is an alternative to the C function call to control execution.
To be able to take full advantage of the timer, change the process as something more than
a function call.
Break the assumptions of our high-level programming language.
jin
Create new routines that allow us to jump from one subroutine to another at any point in
the program.
.re
The timer, will allow us to move between functions whenever necessary based upon the
system’s timing constraints.
5.4.2) Kernel
It is the part of the OS that determines what process is running.
w
om
5.4.3) Priorities
Based on the priorities kernel can do the processes sequentially.
which ones actually want to execute and select the highest priority process that is ready
to run.
.c
This mechanism is both flexible and fast.
The priority is a non-negative integer value.
ul
pa
jin
•When the system begins execution,P2 is the only ready process, so it is selected for execution.
.re
•At T=15, P1 becomes ready; it preempts P2 because p1 has a higher priority, so it execute
immediately
•P3’s data arrive at time 18, it has lowest priority.
w
om
5.4.4) Context Switching
To understand the basics of a context switch, let’s assume that the set of tasks is
in steady state.
.c
Everything has been initialized, the OS is running, and we are ready for a timer
interrupt.
ul
This diagram shows the application tasks, the hardware timer, and all the
functions in the kernel that are involved in the context switch.
pa
vPreemptiveTick() it is called when the timer ticks.
portSAVE_CONTEXT() swaps out the current task context.
vTaskSwitchContext ( ) chooses a new task.
jin
portRESTORE_CONTEXT() swaps in the new context
.re
w
w
w
www.rejinpaul.com
om
.c
ul
pa
jin
.re
w
w
w
www.rejinpaul.com
om
5.5) PRIORITY-
PRIORITY-BASED SCHEDULING
Operating system is to allocate resources in the computing system based on
the priority.
.c
After assigning priorities, the OS takes care of the rest by choosing the highest-
priority ready process.
ul
There are two major ways to assign priorities.
Static priorities that do not change during execution
pa
Dynamic priorities that do change during execution
Types of scheduling process
1. Rate-Monotonic Scheduling
jin
2. Earliest-Deadline-First Scheduling
.re
w
w
w
www.rejinpaul.com
om
5.5.1)
.5.1)RRate
ate--Monotonic Scheduling(
cheduling(RMS
RMS))
Rate-monotonic scheduling (RMS) is one of the first scheduling policies
.c
developed for real-time systems.
RMS is a static scheduling policy.
ul
It assigns fixed priorities are sufficient to efficiently schedule the processes in
many situations.
pa
RMS is known as rate-monotonic analysis (RMA), as summarized below.
All processes run periodically on a single CPU.
Context switching time is ignored.
jin
There are no data dependencies between processes.
The execution time for a process is constant.
.re
All deadlines are at the ends of their periods.
The highest-priority ready process is always selected for execution.
Priorities are assigned by rank order of period, with the process with the
w
om
Example-Rate-monotonic scheduling
set of processes and their characteristics
.c
ul
pa
According to RMA Assign highest priority for least execution period.
Hence P1 the highest priority, P2 the middle priority,and P3 the lowest priority.
jin
First execute P1 then P2 and finally P3.(T1>T2>T3)
After assigning priorities, construct a time line equal in length to hyper period, which is 12
in this case.
.re
w
w
w
www.rejinpaul.com
om
Every 4 time intervals P1 executes 1 units.(Execution time intervals for
P1 0-4,4-8,8-12)
Every 6 time intervals P2 executes 2 units. .(Execution time intervals
.c
for P2 0-6,6-12)
ul
Every 12 intervals P3 executes 3 units. .(Execution time intervals for P3
0-12)
pa
Time interval from 10-12 no scheduling available because no process
will be available for execution. All process are executed already.
jin
.re
w
w
w
www.rejinpaul.com
om
P1 is the highest-priority process, it can start to execute immediately.
After one time unit, P1 finishes and goes out of the ready state until the start of its next
period.
At time 1, P2 starts executing as the highest-priority ready process.
.c
At time 3, P2 finishes and P3 starts executing.
P1’s next iteration starts at time 4, at which point it interrupts P3.
ul
P3 gets one more time unit of execution between the second iterations of P1 and P2, but
P3 does not get to finish until after the third iteration of P1.
pa
Consider the following different set of execution times.
jin
In this case, Even though each process alone has an execution time significantly less than
.re
its period, combinations of processes can require more than 100% of the available CPU
cycles.
During one 12 time-unit interval, we must execute P1 -3 times, requiring 6 units of CPU
time; P2 twice, costing 6 units and P3 one time, costing 3 units.
w
The total of 6 + 6 + 3 = 15 units of CPU time is more than the 12 time units available,
clearly exceeding the available CPU capacity(12units).
w
w
www.rejinpaul.com
om
Response time The time at which the process finishes.
Critical instantThe instant during execution at which the task has the largest response
.c
time.
Let the periods and computation times of two processes P1 and P2 be τ1, τ2 and T1, T2,
with τ 1 < τ 2.
ul
let P1 have the higher priority. In the worst case we then execute P2 once during its period
and as many iterations of P1 as fit in the same interval.
pa
Since there are τ2/ τ1 iterations of P1 during a single period of P2.
The required constraint on CPU time, ignoring context switching overhead, is
jin
we give higher priority to P2, then execute all of P2 and all of P1 in one of P1’s periods in
the worst case.
.re
Total CPU utilization for a set of n tasks is
w
w
w
www.rejinpaul.com
om
5.5.2)EEarliest
5.5.2) arliest--Deadline
eadline--First Scheduling(EDF
Scheduling(EDF))
Earliest deadline first (EDF) is a dynamic priority scheme.
It changes process priorities during execution based on initiation times.
.c
As a result, it can achieve higher CPU utilizations than RMS.
The EDF policy is also very simple.
ul
It assigns priorities in order of deadline.
Assign highest priority to a process who has Earliest deadline.
pa
Assign lowest priority to a process who has farthest deadline.
After assigning scheduling procedure, the highest-priority process is chosen for
execution.
jin
Consider the following Example
.re
Hyper-period is 60
w
w
w
www.rejinpaul.com
om
Dead line Table
.c
ul
pa
jin
.re
w
w
w
www.rejinpaul.com
om
There is one time slot left at t= 30, giving a CPU utilization of 59/60.
EDF can achieve 100% utilization
RMS vs. EDF
.c
ul
pa
jin
.re
w
w
w
www.rejinpaul.com
om
Ex:Priority inversion
Low-priority process blocks execution of a higher priority process by keeping hold
of its resource.
.c
Consider a system with two processes
ul
Higher-priority P1 and the lower-priority P2.
Each uses the microprocessor bus to communicate to peripherals.
pa
When P2 executes, it requests the bus from the operating system and receives it.
If P1 becomes ready while P2 is using the bus, the OS will preempt P2 for P1,
leaving P2 with control of the bus.
jin
When P1 requests the bus, it will be denied the bus, since P2 already owns it.
Unless P1 has a way to take the bus from P2, the two processes may deadlock.
.re
w
w
w
www.rejinpaul.com
om
Data dependencies imply that certain combinations of processes can never occur. Consider the
simple example.
.c
ul
pa
jin
We know that P1 and P2 cannot execute at the same time, since P1 must finish before P2 can
begin.
.re
P3 has a higher priority, it will not preempt both P1 and P2 in a single iteration.
If P3 preempts P1, then P3 will complete before P2 begins.
if P3 preempts P2, then it will not interfere with P1 in that iteration.
w
Because we know that some combinations of processes cannot be ready at the same time,
worst-case CPU requirements are less than would be required if all processes could be ready
simultaneously.
w
w
www.rejinpaul.com
om
5.5)Inter--process communication mechanisms
5.5)Inter
.c
It is provided by the operating system as part of the process abstraction.
Blocking Communication The process goes into the waiting state until it receives a
response
ul
Non-blocking CommunicationIt allows a process to continue execution after
sending the communication.
pa
Types of inter-process communication
1. Shared Memory Communication
2. Message Passing
jin
3. Signals
.re
w
w
w
www.rejinpaul.com
om
5.5.1) Shared Memory Communication
The communication between inter-process is used by bus-based system.
CPU and an I/O device, communicate through a shared memory location.
.c
The software on the CPU has been designed to know the address of the shared location.
The shared location has also been loaded into the proper register of the I/O device.
ul
If CPU wants to send data to the device, it writes to the shared location.
The I/O device then reads the data from that location.
pa
The read and write operations are standard and can be encapsulated in a procedural
interface.
jin
.re
w
w
w
www.rejinpaul.com
om
CPU and the I/O device want to communicate through a shared memory block.
There must be a flag that tells the CPU when the data from the I/O device is ready.
The flag value of 0 when the data are not ready and 1 when the data are ready.
If the flag is used only by the CPU, then the flag can be implemented using a standard
.c
memory write operation.
If the same flag is used for bidirectional signaling between the CPU and the I/O device,
ul
care must be taken.
Consider the following scenario to call flag
pa
1. CPU reads the flag location and sees that it is 0.
2. I/O device reads the flag location and sees that it is 0.
3. CPU sets the flag location to 1 and writes data to the shared location.
jin
4. I/O device erroneously sets the flag to 1 and overwrites the data left by the CPU.
.re
w
w
w
www.rejinpaul.com
om
The text compressor is a good example of a shared memory.
The text compressor uses the CPU to compress incoming text, which is then sent on a
.c
serial line by a UART.
The input data arrive at a constant rate and are easy to manage.
But the output data are consumed at a variable rate, these data require an elastic buffer.
ul
The CPU and output UART share a memory area—the CPU writes compressed characters
into the buffer and the UART removes them as necessary to fill the serial line.
pa
Because the number of bits in the buffer changes constantly, the compression and
transmission processes need additional size information.
CPU writes at one end of the buffer and the UART reads at the other end.
jin
The only challenge is to make sure that the UART does not overrun the buffer.
.re
w
w
w
www.rejinpaul.com
om
5.5.2) Message Passing
Here each communicating entity has its own message send/receive unit.
The message is not stored on the communications link, but rather at the senders/ receivers
.c
at the end points.
Ex:Home control system
ul
It has one microcontroller per household device—lamp, thermostat, faucet, appliance.
The devices must communicate relatively infrequently.
pa
Their physical separation is large enough that we would not naturally think of them as
sharing a central pool of memory.
Passing communication packets among the devices is a natural way to describe
jin
coordination between these devices.
.re
w
w
w
www.rejinpaul.com
om
5.5.3) Signals
Generally signal communication used in Unix .
.c
A signal is analogous to an interrupt, but it is entirely a software creation.
A signal is generated by a process and transmitted to another process by the OS.
ul
A UML signal is actually a generalization of the Unix signal.
Unix signal carries no parameters other than a condition code.
pa
UML signal is an object, carry parameters as object attributes.
The sigbehavior( ) behavior of the class is responsible for throwing the signal,
as indicated by<<send>>.
jin
The signal object is indicated by the <<signal>>
.re
w
w
w
www.rejinpaul.com
om
5.6)Evaluating operating system performance
Analysis of scheduling policies is made by the following 4 assumptions
.c
Assumed that context switches require zero time. Although it is often
reasonable to neglect context switch time when it is much smaller than the
ul
process execution time, context switching can add significant delay in some
cases.
pa
We have largely ignored interrupts. The latency from when an interrupt is
requested to when the device’s service is complete is a critical parameter of real
time performance.
jin
We have assumed that we know the execution time of the processes.
We probably determined worst-case or best-case times for the processes in
isolation.
.re
5.6.1)Context switching time
It depends on following factors
The amount of CPU context that must be saved.
w
om
5.6.2)Interrupt latency
Interrupt latency It is the duration of time from the assertion of a device interrupt to
the completion of the device’s requested operation.
Interrupt latency is critical because data may be lost when an interrupt is not serviced in
.c
a timely fashion.
ul
pa
jin
.re
A task is interrupted by a device.
The interrupt goes to the kernel, which may need to finish a protected operation.
w
Once the kernel can process the interrupt, it calls the interrupt service routine (ISR),
which performs the required operations on the device.
w
om
Several factors in both hardware and software affect interrupt latency:
The processor interrupt latency
The execution time of the interrupt handler
Delays due to RTOS scheduling
.c
RTOS delay the execution of an interrupt handler in two ways.
Critical sections and interrupt latency
ul
Critical sections in the kernel will prevent the RTOS from taking interrupts.
Some operating systems have very long critical sections that disable interrupt handling for
pa
very long periods.
jin
.re
w
w
w
www.rejinpaul.com
om
If a device interrupts during a critical section, that critical section must finish before the
kernel can handle the interrupt.
The longer the critical section, the greater the potential delay.
Critical sections are one important source of scheduling jitter because a device may
.c
interrupt at different points in the execution of processes and hit critical sections at
different points.
ul
Interrupt priorities and interrupt latency
A higher-priority interrupt may delay a lower-priority interrupt.
A hardware interrupt handler runs as part of the kernel, not as a user thread.
pa
The priorities for interrupts are determined by hardware.
Any interrupt handler preempts all user threads because interrupts are part of the CPU’s
fundamental operation.
jin
We can reduce the effects of hardware preemption by dividing interrupt handling into
two different pieces of code.
Interrupt service handler (ISH) performs the minimal operations required to
.re
respond to the device.
Interrupt service routine (ISR) Performs updating user buffers or other more
complex operation.
w
w
w
www.rejinpaul.com
om
RTOS performance evaluation tools
Some RTOSs provide simulators or other tools that allow us to view the
operation of the processes,context switching time, interrupt response time,
.c
and other overheads.
Windows CE provides several performance analysis tools
ul
An instrumentation routine in the kernel that measures both interrupt service
routine and interrupt service thread latency.
pa
OS Bench measures the timing of operating system tasks such as critical
section access, signals, and so on
Kernel Tracker provides a graphical user interface for RTOS events.
jin
.re
w
w
w
www.rejinpaul.com
om
5.7)Power optimization strategies for processes
A power management policy is a strategy for determining when to perform
.c
certain power management operations.
The system can be designed based on the static and dynamic power
ul
management mechanisms.
Power saving straegies
pa
Avoiding a power-down mode can cost unnecessary power.
Powering down too soon can cause severe performance penalties.
Re-entering run mode typically costs a considerable amount of time.
jin
A straightforward method is to power up the system when a request is received.
.re
w
w
w
www.rejinpaul.com
om
Predictive shutdown
The goal is to predict when the next request will be made and to start the
.c
system just before that time, saving the requestor the start-up time.
Make guesses about activity patterns based on a probabilistic model of
expected behavior.
ul
This can cause two types of problems
pa
The requestor may have to wait for an activity period.
In the worst case,the requestor may not make a deadline due to the delay
incurred by system
jin
.re
w
w
w
www.rejinpaul.com
An L-
L-shaped usage distribution
om
A very simple technique is to use fixed times.
If the system does not receive inputs during an interval of length Ton, it shuts down.
.c
Powered-down system waits for a period Toff before returning to the power-on mode.
In this distribution, the idle period after a long active period is usually very short, and the
ul
length of the idle period after a short active period is uniformly distributed.
Based on this distribution, shutdown when the active period length was below a threshold,
pa
putting the system in the vertical portion of the L distribution.
jin
.re
w
w
w
www.rejinpaul.com
om
Advanced Configuration and Power Interface (ACPI)
It is an open industry standard for power management services.
.c
It is designed to be compatible with a wide variety of OSs.
A decision module determines power management actions.
ul
pa
jin
.re
w
w
w
www.rejinpaul.com
om
ACPI supports the following five basic global power states.
1. G3, the mechanical off state, in which the system consumes no power.
2. G2, the soft off state, which requires a full OS reboot to restore the machine to
working condition. This state has four sub-states:
.c
S1, a low wake-up latency state with no loss of system context
S2, a low wake-up latency state with a loss of CPU and system cache state
ul
S3, a low wake-up latency state in which all system state except for main
memory is lost.
pa
S4, the lowest-power sleeping state, in which all devices are turned off.
3. G1, the sleeping state, in which the system appears to be off.
jin
4. G0, the working state, in which the system is fully usable.
5. The legacy state, in which the system does not comply with ACPI.
.re
w
w
w
www.rejinpaul.com
om
5.8)Example Real time operating systems
5.8.1)POSIX
.c
POSIX is a Unix operating system created by a standards organization.
POSIX-compliant operating systems are source-code compatible.
ul
Application can be compiled and run without modification on a new POSIX
platform.
pa
It has been extended to support real time requirements.
Many RTOSs are POSIX-compliant and it serves as a good model for basic
RTOS techniques.
jin
The Linux operating system has a platform for embedded computing.
Linux is a POSIX-compliant operating system that is available as open source.
Linux was not originally designed for real-time operation .
.re
Some versions of Linux may exhibit long interrupt latencies,
To improve interrupt latency,A dual-kernel approach uses a specialized kernel,
the co-kernel, for real-time processes and the standard kernel for non-real-
w
time processes.
w
w
www.rejinpaul.com
om
Process in POSIX
A new process is created by making a copy of an existing process.
The copying process creates two different processes both running the same code.
.c
The complex task is to ensuring that one process runs the code intended for the new process
while the other process continues the work of the old process .
ul
Scheduling in POSIX
A process makes a copy of itself by calling the fork() function.
pa
That function causes the operating system to create a new process (the child process) which is
a nearly exact copy of the process that called fork() (the parent process).
They both share the same code and the same data values with one exception, the return value
jin
of fork().
The parent process is returned the process ID number of the child process, while the child
process gets a return value of 0.
.re
We can therefore test the return value of fork() to determine which process is the child
childid = fork();
if (childid == 0) { /* must be the child */
w
om
execv() function takes as argument the name of the file that holds the child’s
code and the array of arguments.
It overlays the process with the new code and starts executing it from the
main() function.
.c
In the absence of an error, execv() should never return.
The code that follows the call to perror() and exit(), take care of the case where
ul
execv() fails and returns to the parent process.
The exit() function is a C function that is used to leave a process
pa
childid = fork();
if (childid == 0) { /* must be the child */
jin
execv(“mychild”,childargs);
perror(“execv”);
exit(1);
.re
}
w
w
w
www.rejinpaul.com
om
The wait functions not only return the child process’s status, in many
implementations of POSIX they make sure that the child’s resources .
The parent stuff() function performs the work of the parent function.
.c
childid = fork();
ul
if (childid == 0) { /* must be the child */
pa
execv(“mychild”,childargs);
perror(“execl”);
exit(1);
jin
}
else { /* is the parent */
parent_stuff(); /* execute parent functionality */
.re
wait(&cstatus);
exit(0);
w
}
w
w
www.rejinpaul.com
om
The POSIX process model
Each POSIX process runs in its own address space and cannot directly access the
data or code.
.c
Real-time scheduling in POSIX
POSIX supports real-time scheduling in the POSIX_PRIORITY_SCHEDULING
ul
resource.
POSIX supports Rate-monotonic scheduling in the SCHED_FIFO scheduling
pa
policy.
It is a strict priority-based scheduling scheme in which a process runs until it is
preempted or terminates.
jin
The term FIFO simply refers processes run in first-come first-served order.
.re
w
w
w
www.rejinpaul.com
om
POSIX semaphores
POSIX supports semaphores and also supports a direct shared memory mechanism.
POSIX supports counting semaphores in the _POSIX_SEMAPHORES option.
.c
A counting semaphore allows more than one process access to a resource at a time.
If the semaphore allows up to N resources, then it will not block until N processes have
ul
simultaneously passed the semaphore;
The blocked process can resume only after one of the processes has given up its
pa
semaphore.
When the semaphore value is 0, the process must wait until another process gives up the
semaphore and increments the count.
jin
POSIX pipes
Parent process uses the pipe() function to create a pipe to talk to a child.
Each end of a pipe appears to the programs as a file.
.re
The pipe() function returns an array of file descriptors, the first for the write end and the
second for the read end.
POSIX also supports message queues under the _POSIX_MESSAGE_PASSING facility..
w
w
w
www.rejinpaul.com
om
5.8.2)Windows CE
Windows CE is designed to run on multiple hardware platforms and
instruction set architectures.
.c
It supports devices such as smart phones, electronic instruments etc..,
ul
pa
jin
.re
w
w
w
www.rejinpaul.com
om
Applications run under the shell and its user interface.
The Win32 APIs manage access to the operating system.
OEM Adaption Layer (OAL) provides an interface to the hardware and software
architecture.
.c
ul
pa
jin
OAL provides services such as a real-time clock, power management, interrupts, and a
.re
debugging interface.
A Board Support Package (BSP) for a particular hardware platform includes the OAL and
drivers.
w
w
w
www.rejinpaul.com
om
Memory Space
It support for virtual memory with a flat 32-bit virtual address space.
A virtual address can be statically mapped into main memory for key kernel-mode code.
An address can also be dynamically mapped, which is used for all user-mode and some
.c
kernel-mode code.
Flash as well as magnetic disk can be used as a backing store
ul
pa
jin
.re
The top 1 GB is reserved for system elements such as DLLs, memory mapped files, and
shared system heap.
The bottom 1 GB holds user elements such as code, data, stack, and heap.
w
w
w
www.rejinpaul.com
om
User address space in windows CE
Threads are defined by executable files while drivers are defined by
dynamically-linked libraries (DLLs).
A process can run multiple threads.
.c
Threads in different processes run in different execution
environments.
ul
Threads are scheduled directly by the operating system.
Threads may be launched by a process or a device driver.
pa
A driver may be loaded into the operating system or a process.
Drivers can create threads to handle interrupts
Each thread is assigned an integer priority.
jin
0 is the highest priority and 255 is the lowest priority.
Priorities 248 through 255 are used for non-real-time threads .
The operating system maintains a queue of ready processes at each
.re
priority level.
w
w
w
www.rejinpaul.com
om
Execution of a thread can also be blocked by a higher-priority thread.
Tasks may be scheduled using either of two policies: a thread runs until the end
of its quantum; or a thread runs until a higher-priority thread is ready to run.
.c
Within each priority level, round-robin scheduling is used.
WinCE supports priority inheritance.
ul
When priorities become inverted, the kernel temporarily boosts the priority of
the lower-priority thread to ensure that it can complete and release its
resources.
pa
Kernel will apply priority inheritance to only one level.
If a thread that suffers from priority inversion in turn causes priority inversion
jin
for another thread, the kernel will not apply priority inheritance to solve the
nested priority inversion.
.re
w
w
w
www.rejinpaul.com
om
Sequence diagram for an interrupt
.c
ul
pa
jin
.re
w
w
w
www.rejinpaul.com
om
Interrupt handling is divided among three entities
The interrupt service handler (ISH) is a kernel service that provides the first
response to the interrupt.
The ISH selects an interrupt service routine (ISR) to handle the interrupt.
.c
The ISR in turn calls an interrupt service thread (IST) which performs most of
the work required to handle the interrupt.
ul
The IST runs in the OAL and so can be interrupted by a higher-priority
interrupt.
pa
ISRdetermines which IST to use to handle the interrupt and requests the
kernel to schedule that thread.
The ISH then performs its work and signals the application about the updated
jin
device status as appropriate.
kernel-mode and user-mode drivers use the same API.
.re
w
w
w
www.rejinpaul.com
om
It is a collection of hardware and software and its communication.
It also has many control system performance.
.c
Processing Element (PE)is a basic unit of DES.
It allows the network to communicate.
ul
PE is an instruction set processor such as DSP,CPU and Microcontroller.
pa
Network abstractions
Networks are complex systems.
It provide high-level services such as data transmission from the other
jin
components in the system.
ISO has developed a seven-layer model for networks known as Open Systems
Interconnection (OSI) models.
.re
w
w
w
www.rejinpaul.com
om
5.9.1)OSI model layers
Physical layer defines the basic properties of the
.c
interface between systems, including the physical
connections, electrical properties & basic procedures
for exchanging bits.
ul
Data link layer used for error detection and control
across a single link.
pa
Network layer defines the basic end-to-end data
transmission service.
Transport layer defines connection-oriented
services that ensure that data are delivered in the
proper order .
jin
Session layer provides mechanisms for controlling
the interaction of end-user services across a network,
.re
such as data grouping and checkpointing.
Presentation layer layer defines data exchange
formats
w
om
5.9.2)C
5.9.2) Controller Area Network
etwork(CAN)
(CAN)Bus
Bus
It was designed for automotive electronics
and was first used in production cars in 1991.
.c
It uses bit-serial transmission.
CAN can run at rates of 1 Mbps over a twisted
ul
pair connection of 40 meters.
An optical link can also be used.
pa
4.7.2.1)Physical-electrical organization of a CAN
bus
Each node in the CAN bus has its own
jin
electrical drivers and receivers that connect
the node to the bus in wired-AND fashion.
When all nodes are transmitting 1s, the bus is
.re
said to be in the recessive state.
when a node transmits a 0s, the bus is in the
dominant state.
w
w
w
www.rejinpaul.com
5.9.2.2)Data Frame
om
.c
ul
pa
jin
Arbitration field The first field in the packet contains the packet’s destination address 11 bits
Remote Transmission Request (RTR) bit is set to 0 if the data frame is used to request data
from the destination identifier.
.re
When RTR = 1, the packet is used to write data to the destination identifier.
Control field 4-bit length for the data field with a 1 in between.
Data field0 to 64 bytes, depending on the value given in the control field.
w
bit (1) in the ACK slot , if the receiver detected an error, it put (0) value)
w
www.rejinpaul.com
om
Arbitration
It uses a technique known as Carrier Sense Multiple Access with Arbitration on Message
Priority (CSMA/AMP).
When a node hears a dominant bit in the identifier when it tries to send a recessive bit, it
.c
stops transmitting.
By the end of the arbitration field, only one transmitter will be left.
ul
The identifier field acts as a priority identifier, with the all-0 having the highest priority
Error handling
pa
An error frame can be generated by any node that detects an error on the bus.
Upon detecting an error, a node interrupts the current transmission.
Error flag field followed by an error delimiter field of 8 recessive bits.
Overload frame signals that a node is overloaded and will not be able to handle the next
.re
message. Hence the node can delay the transmission of the next frame .
w
w
w
www.rejinpaul.com
om
.c
ul
pa
The controller implements the physical and data link layers.
CAN does not need network layer services to establish end-to-end
connections.
jin
The protocol control block is responsible for determining when to send
.re
messages, when a message must be resent and when a message should
be received.
w
w
w
www.rejinpaul.com
5.9.3) I2C bus
om
I2C bus used to link microcontrollers
into systems.
I2C is designed to be low cost, easy to
.c
implement, and of moderate speed (up to
100kbps for the standard bus and up to
400 kbps for the extended bus).
ul
Serial data line (SDL) for data
transmission.
pa
Serial clock line (SCL) indicates when
valid data are on the data line.
Every node in the network is connected to
jin
both SCL and SDL.
Some nodes may act as bus masters .
Other nodes may act as slaves that only
.re
respond to requests from masters.
w
w
w
www.rejinpaul.com
5.9.3.1)Electrical interface to the I2C bus
om
Both bus lines are defined by an electrical signal.
Both bus signals use open collector/open drain
circuits.
.c
The open collector/open drain circuitry allows a slave
device to stretch a clock signal during a read.
The master is responsible for generating the SCL
ul
clock.
The slave can stretch the low period of the clock.
pa
It is a multi master bus so different devices may act
as the master at various times.
Master drives both SCL and SDL when it is sending
data.
high.
jin
When the bus is idle, both SCL and SDL remain
om
5.9.3.2)Format of an I2C address transmission
.c
ul
Every I2C device has an separate address.
pa
A device address is 7 bits and 1 bit for read/write data.
The address 0000000 ,which can be used to signal all devices simultaneously.
The address 11110XX is reserved for the extended 10-bit addressing scheme.
jin
.re
w
w
w
www.rejinpaul.com
om
.c
ul
pa
When a master wants to write a slave, it transmits the slave’s address followed by the data.
When a master send a read request with the slave’s address and the slave transmit the data.
jin
Transmission address has 7-bit and 1 bit for data direction.( 0 for writing from the master to
the slave and 1 for reading from the slave to the master)
A bus transaction is initiated by a start signal and completed with an end signal.
.re
A start is signaled by leaving the SCL high and sending a 1 to 0 transition on SDL.
A stop is signaled by setting the SCL high and sending a 0 to 1 transition on SDL.
w
w
w
www.rejinpaul.com
om
5.9.3.4)State transition graph for an I2C bus master
Starts and stops must be paired.
.c
A master can write and then read by sending a start after the data transmission, followed
by another address transmission and then more data.
ul
pa
jin
.re
w
w
w
www.rejinpaul.com
om
The transmission starts when SDL is pulled low while SCL remains high.
The clock is pulled low to initiate the data transfer.
.c
At each bit, the clock goes high while the data line assumes its proper value of 0 or 1.
An acknowledgment is sent at the end of every 8-bit transmission, whether it is an
address or data.
ul
After acknowledgment, the SDL goes from low to high while the SCL is high, signaling
the stop condition.
pa
jin
.re
w
w
w
www.rejinpaul.com
om
5.9.3.6)I2C
5.9.3.6) I2C interface in a microcontroller
System has a 1-bit hardware interface with routines for byte-level functions.
.c
I2C device used to generates the clock and data.
Application code calls routines to send an address, data byte, and also generates the SCL
,SDL and acknowledges.
ul
Timers is used to control the length of bits on the bus.
When Interrupts used in master mode, polled I/O may be acceptable.
pa
If no other pending tasks can be performed, because masters initiate their own transfers.
jin
.re
w
w
w
www.rejinpaul.com
om
5.9.4)ETHERNET
It is widely used as a local area network for general-purpose computing.
It is also used as a network for embedded computing.
.c
It is particularly useful when PCs are used as platforms, making it possible to use
standard components, and when the network does not have to meet real-time
ul
requirements.
It is a bus with a single signal path.
pa
It supports both twisted pair and coaxial cable.
Ethernet nodes are not synchronized, if two nodes decide to transmit at the same
time,the message will be ruined.
jin
.re
w
w
w
www.rejinpaul.com
om
A node that has a message waits for the
bus to become silent and then starts
.c
transmitting.
It simultaneously listens, and if it hears
ul
another transmission that interferes with
its transmission, it stops transmitting and
waits to retransmit.
pa
The waiting time is random, but weighted
by an exponential function of the number
of times the message has been aborted
jin
.re
w
w
w
www.rejinpaul.com
om
5.9.4.2)Ethernet--Packet format
5.9.4.2)Ethernet
.c
ul
pa
Preamble 56-bit of alternating 1 and 0 bits, allowing devices on the network
to easily synchronize their receiver clocks.
SFD8-bit ,indicates the beginning of the Ethernet frame
jin
Physical or MAC addresses destination and the source( 48-bit length)
Length data payloadThe minimum payload is 42 octets
.re
w
w
w
www.rejinpaul.com
5.9.5)IINTERNET PROTOCOL(
5.9.5) ROTOCOL(IP
IP))
om
It is the fundamental protocol on the Internet.
It provides connection orientded, packet-based
.c
communication.
It transmits packet over different networks from
ul
source to destination.
It allows data to flow seamlessly from one end user to
another.
pa
When node A wants to send data to node B, the data
pass through several layers of the protocol stack to
get to the Internet Protocol.
jin
IP creates packets for routing to the destination,
which are then sent to the data link and physical
layers.
A packet may go through many routers to get to its
.re
destination.
IP works at the network layer does not
guarantee that a packet is delivered to its
w
destination.
It supports best-effort routing packets packets
that do arrive may come out of order.
w
w
www.rejinpaul.com
om
5.9.5.1)IP packet structure
.c
ul
pa
jin
.re
w
w
w
www.rejinpaul.com
om
Version it ia s 4-bit field.used to identify v4 or v6.
Header Length (HL)It is a 4 bits, field.Indicates the length of the header.
.c
Service Typeit is a 8 bit field ,used to specify the type of service.
Total lengthIncluding header and data payload is 65,535 bytes.
ul
Identification identifying the group of fragments of a single IP datagram.
Flags bit 0 Reserved.
pa
bit 1: Don't Fragment (DF)
bit 2: More Fragments (MF)
Fragment Offset It is 13 bits long , specifies the offset of a particular fragment relative to
jin
the beginning of the original unfragmented IP datagram
Time To Live (TTL)It is a 8 bit wide, indicates th datagram's lifetime
Protocol protocol used in the data portion of the IP datagram
.re
Header Checksum(16 bit) used for error-checking of the header
Source address Sender packet address(32-bits size)
Destination address Receiver packet address(32-bits size)
w
w
w
www.rejinpaul.com
om
5.9.5.1) Transmission Control Protocol(
rotocol(TCP
TCP))
It provides a connection-oriented service.
It ensures that data arrive in the appropriate order.
.c
It uses an acknowledgment protocol to ensure that packets arrive.
TCP is used to provide File Transport Protocol (FTP) for batch file transfers.
ul
Hypertext Transport Protocol (HTTP) for World Wide Web service.
Simple Mail Transfer Protocol (SMTP) for email.
pa
Telnet for virtual terminals.
User Datagram Protocol (UDP), is used to provide connection-less services.
Simple Network Management Protocol (SNMP) provides the network management services.
jin
.re
w
w
w
www.rejinpaul.com
5.10) MPSoCs and shared memory
om
multiprocessors
Shared memory processors are well-suited to applications that require a large amount
of data to be processed(Signal processing systems )
.c
Most MPSoCs are shared memory systems.
Shared memory allows for processors to communicate with varying patterns.
ul
If the pattern of communication is very fixed and if the processing of different steps is
performed in different units, then a networked multiprocessor may be most appropriate.
pa
If one processing element is used for several different steps, then shared memory also
allows the required flexibility in communication.
jin
.re
w
w
w
www.rejinpaul.com
om
5.10.1)Heterogeneous shared memory multiprocessors
.c
Many high-performance embedded platforms are heterogeneous multiprocessors.
Different processing elements (PE)perform different functions.
PEs may be programmable processors with different instruction sets or specialized
ul
accelerators.
Processors with different instruction sets can perform different tasks faster and using less
pa
energy.
Accelerators provide even faster and lower-power operation for a narrow range of
functions.
jin
.re
w
w
w
www.rejinpaul.com
5.10.2)Accelerators
om
It is the important processing element for embedded multiprocessors.
It can provide large performance increases for applications with computational kernels .
It can also provide critical speedups for low-latency I/O functions.
.c
CPU(host) accelerator is attached to the CPU bus.
CPU talks to the accelerator through data and control registers in the accelerator.
ul
Control registers allow the CPU to monitor the accelerator’s operation and to give the
accelerator commands.
pa
The CPU and accelerator may also communicate via shared memory.
The accelerator operate on a large volume of data with efficient data in memory.
Accelerator read and write memory directly .
jin
The CPU and accelerator use synchronization mechanisms to ensure that they do not
destroy each other’s data.
An accelerator is not a co-processor.
.re
A co-processor is connected to the internals of the CPU and processes instructions.
An accelerator interacts with the CPU through the programming model interface.
It does not execute instructions.
w
om
CPU accelerators in a system
.c
ul
pa
jin
.re
w
w
w
www.rejinpaul.com
om
5.10.2)Accelerator Performance Analysis
The speed factor of accelerator will depend on the following factors.
Single threadedCPU is in idle state while the accelerator runs.
.c
MultithreadedCPU do some useful work in parallel with accelerator.
Blocking CPU’s scheduler block other operations wait for the accelerator call to
ul
complete.
Non-blocking CPU’s run some other work parallel with accelerator.
pa
Data dependencies allow P2 and P3 to run independently on the CPU.
P2 relies on the results of the A1 process that is implemented by the accelerator.
Single-threaded CPU blocks to wait for the accelerator to return the results of its
jin
computation.t, it doesn’t matter whether P2 or P3 runs next on the CPU.
Multithreaded CPU continues to do useful work while the accelerator runs, so the CPU
can start P3 just after starting the accelerator and finish the task earlier.
.re
w
w
w
www.rejinpaul.com
om
.c
ul
pa
jin
.re
w
w
w
www.rejinpaul.com
om
5.10.3)Components of execution time for an accelerator
Execution time of a accelerator depends on the
time required to execute the accelerator’s
.c
function.
It also depends on the time required to get the
ul
data into the accelerator and back out of it.
Accelerator will read all its input data, perform
pa
the required computation,and write all its results.
Total execution time given as
tacccel=tx+tin+tout
jin
tx execution time of the accelerator
Tin times required for reading the required
variables
.re
tout- times required for writing the required
variables
w
w
w
www.rejinpaul.com
om
Architectural design depends on the application.
An accelerator can be considered from two angles.
.c
Accelerator core functionality
Accelerator interface to the CPU bus.
The accelerator core typically operates off internal
ul
registers.
Requirement of number of registers is an important
pa
design decision.
Main memory accesses will probably take multiple
clock cycles.
Status registers used to test the accelerator’s state and
jin
to perform basic operations(starting, stopping, and
resetting the accelerator)
A register file in the accelerator acts as a buffer between
.re
main memory and the accelerator core.
Read unit can read the accelerator’s requirements and
load the registers with the next required data.
Write unit can send recently completed values to main
w
memory.
w
w
www.rejinpaul.com
om
5.10.5)cache problem in an accelerated system
CPU cache can cause problems for
.c
accelerators.
1. The CPU reads location S.
2. The accelerator writes S.
ul
3. The CPU again reads S.
If the CPU has cached location S ,the
pa
program will not see the value of S
written by the accelerator. It will instead
get the old value of S stored in the cache.
jin
To avoid this problem, the CPU’s cache
must update the cache by setting cache
entry is invalid.
.re
w
w
w
www.rejinpaul.com
om
Designing a distributed embedded system, depends upon the scheduling and allocation
of resources.
.c
We must schedule operations in time, including communication on the network and
computations on the processing elements.
ul
The scheduling of operations on the PEs and the communications between the PEs are
linked.
If one PE finishes its computations too late, it may interfere with another communication
pa
on the network as it tries to send its result to the PE that needs it.
This is bad for both the PE that needs the result and the other PEs whose communication
is interfered with.
jin
We must allocate computations to the processing elements.
The allocation of computations to the PEs determines what communications are
required—if a value computed on one PE is needed on another PE, it must be
.re
transmitted over the network.
w
w
w
www.rejinpaul.com
om
We can specify the system as a task graph. However, different processes may end up on
different processing elements. Here is a task graph
.c
ul
pa
We have labeled the data transmissions on each arc ,We want to execute the task on the
platform below.
jin
.re
The platform has two processing elements and a single bus connecting both PEs. Here
are the process speeds:
w
w
w
www.rejinpaul.com
om
As an initial design, let us allocate P1 and P2 to M1 and P3 to M2This schedule shows
what happens on all the processing elements and the network.
.c
ul
pa
The schedule has length 19. The d1 message is sent between the processes internal to
P1 and does not appear on the bus.
jin
Let’s try a different allocation. P1 on M1 and P2 and P3 on M2. This makes P2 run more
slowly. Here is the new schedule:.
The length of this schedule is 18, or one time unit less than the other schedule. The
.re
increased computation time of P2 is more than made up for by being able to transmit a
shorter message on the bus. If we had not taken communication into account when
analyzing total execution time, we could have made the wrong choice of which processes
to put on the same processing element.
w
w
w
www.rejinpaul.com
om
5.11.1)Operation and requirements
MP3 players use either flash memory or disk drives to store music.
.c
It performs the following functions such as audio storage, audio decompression, and
user interface.
ul
Audio compression It is a lossy process. The coder eliminates certain features of the audio
stream so that the result can be encoded in fewer bits.
pa
Audio decompression The incoming bit stream has been encoded using a Huffman style
code, which must be decoded.
Masking One tone can be masked by another if the tones are sufficiently close in frequency.
jin
Audio compression standards
Layer 1 (MP1) uses a lossless compression of sub bands and simple masking model.
Layer 2 (MP2) uses a more advanced masking model.
.re
Layer 3 (MP3) performs additional processing to provide lower bit rates.
w
w
w
www.rejinpaul.com
om
Filter bank splits the signal into a set of 32 sub-
bands that are equally spaced in the frequency
domain and together cover the entire frequency
.c
range of the audio.
EncoderIt reduce the bit rate for the audio
signals.
ul
Quantizer scales each sub-band( fits within 6
bits ), then quantizes based upon the current scale
pa
factor for that sub-band.
Masking model It is driven by a separate Fast
Fourier transform (FFT), the filter bank could be
used for masking, a separate FFT provides better
jin
results.
The masking model chooses the scale factors for
the sub-bands, which can change along with the
.re
audio stream.
Multiplexer output of the encoder passes along
all the required data.
w
w
w
www.rejinpaul.com
om
MPEG Layer 1 data frame format
A frame carries the basic MPEG data, error correction codes, and additional information.
After disassembling the data frame, the data are un-scaled and inverse quantized to
.c
produce sample streams for the sub-band.
ul
5.11.3)MPEG Layer 1 decoder
pa
•After disassembling the data frame, the data are un-
scaled and inverse quantized to produce sample
streams for the sub-band.
•An inverse filter bank then reassembles the sub-bands
jin
into the uncompressed signal.
User interface MP3 player is simple both the
physical size and power consumption of the device.
.re
Many players provide only a simple display and a few
buttons.
File system
system player generally must be compatible
w
5.11.4)Requirements
om
.c
ul
pa
jin
.re
w
w
w
www.rejinpaul.com
om
5.11.5) Specification
The File ID class is an abstraction of a file in the flash file system.
.c
The controller class provides the method that operates the player.
ul
pa
jin
.re
w
w
w
www.rejinpaul.com
om
5.11.6) State diagram for file display and selection
This specification assumes that all files are in the root directory and that all files are
playable audio.
.c
ul
pa
jin
.re
w
w
w
www.rejinpaul.com
om
5.11.7) State diagram for Audio Playback
It refers to sending the samples to the audio system.
Playback and reading the next data frame must be overlapped to ensure continuous operation.
.c
The details of playback depend on the hardware platform selected, but will probably involve a
DMA transfer.
ul
pa
jin
.re
w
w
w
www.rejinpaul.com
om
5.11.8) System architecture
The audio controller includes two processors.
The 32-bit RISC processor is used to perform system control and audio decoding.
.c
The 16-bit DSP is used to perform audio effects such as equalization.
The memory controller can be interfaced to several different types of memory.
ul
Flash memory can be used for data or code storage.
DRAM can be used to handle temporary disruptions of the CD data stream.
pa
The audio interface unit puts out audio in formats that can be used by A/D converters.
General- purpose I/O pins can be used to decode buttons, run displays.
jin
.re
w
w
w
www.rejinpaul.com
om
The audio output system should be tested separately from the compression system.
Testing of audio decompression requires sample audio files.
.c
The standard file system can either implement in a DOS FAT or a new file system.
While a non-standard file system may be easier to implement on the device, it also
ul
requires software to create the file system.
The file system and user interface can be tested independently .
pa
jin
.re
w
w
w
www.rejinpaul.com
om
5.11.10) System integration and debugging
.c
It ensure that audio plays smoothly and without interruption.
Any file access and audio output that operate concurrently should be separately tested,
ideally using an easily recognizable test signal.
ul
pa
jin
.re
w
w
w
www.rejinpaul.com
om
This unit controls the operation of a
.c
fuel-injected engine based on
several measurements taken from
the running engine.
ul
5.12.1)Operation and
Requirements
pa
The throttle is the command input.
The engine measures throttle,
RPM, intake air volume, and other
jin
variables.
The engine controller computes
injector pulse width and spark.
.re
w
w
w
www.rejinpaul.com
om
5.12.2)Requirements
.c
ul
pa
jin
.re
w
w
w
www.rejinpaul.com
5.12.3)Specification
om
The engine controller must deal with processes at different rates
.c
ΔNE and ΔT to represent the change in RPM and throttle position.
Controller computes two output signals, injector pulse width PW and spark advance
angle S.
ul
S=k2X ΔNE-k3VS
The controller then applies corrections to these initial values
pa
If intake air temperature (THA) increases during engine warm-up, the controller reduces
the injection duration.
If the throttle opens, the controller temporarily increases the injection frequency.
jin
Controller adjusts duration up or down based upon readings from the exhaust oxygen
sensor (OX).
.re
w
w
w
www.rejinpaul.com
5.12.4)System architecture
om
The two major processes, pulse-
.c
width and advance-angle,
compute the control parameters
for the spark plugs and injectors.
ul
Control parameters rely on
changes in some of the input
pa
signals.
Physical sensor classes used to
compute these values.
jin
Each change must be updated at
the variable’s sampling rate.
.re
w
w
w
www.rejinpaul.com
om
5.12.5)State diagram for throttle position sensing
Throttle sensing, which saves both the
.c
current value and change in value of
the throttle.
ul
pa
jin
.re
w
w
w
www.rejinpaul.com
om
width
.c
In each case, the value is computed
in two stages, first an initial value
ul
followed by a correction.
pa
State diagram for spark advance angle
jin
.re
w
w
w
www.rejinpaul.com
om
5.12.7)Component design and testing
Various tasks must be coded to satisfy the requirements of RTOS processes.
.c
Variables that are maintained across task execution, such as the change-of-state
variables, must be allocated and saved in appropriate memory locations.
Some of the output variables depend on changes in state, these tasks should be tested
ul
with multiple input variable sequences to ensure that both the basic and adjustment
calculations are performed correctly.
pa
jin
.re
w
w
w
www.rejinpaul.com
om
5.12.8)System integration and testing
Engines generate huge amounts of electrical noise that can cripple digital electronics.
.c
They also operate over very wide temperature ranges.
1. hot during engine operation,
ul
2. potentially very cold before the engine is started.
Any testing performed on an actual engine must be conducted using an engine
pa
controller that has been designed to withstand the harsh environment of the engine
compartment.
jin
.re
w
w
w
www.rejinpaul.com
5.13)Video Accelerator
om
It is a hardware circuits on a display adapter that speed up fill motion video.
Primary video accelerator functions are color space conversion, which converts YUV to RGB.
Hardware scaling is used to enlarge the image to full screen and double buffering which
.c
moves the frames into the frame buffer faster.
ul
Video compression
•MPEG-2 forms the basis for U.S. HDTV
pa
broadcasting.
• This compression uses several
component algorithms together in a
jin
feedback loop.
•Discrete cosine transform (DCT) used in
JPEG and MPEG-2.
•DCT used a block of pixels which is
.re
quantized for lossy compression.
•Variable-length coderassign number of
bits required to represent the block.
w
w
w
www.rejinpaul.com
om
5.13.1)Block motion Estimation
MPEG uses motion to encode one frame in
terms of another.
.c
Block motion estimationsome frames are
sent as modified forms of other frames
During encoding, the frame is divided into
ul
macro blocks.
Encoder uses the encoding information to
pa
recreate the lossily-encoded picture, compares
it to the original frame, and generates an error
signal.
Decoder keep recently decoded frames in
jin
memory so that it can retrieve the pixel values
of macro-blocks.
.re
w
w
w
www.rejinpaul.com
om
To find the best match between regions in the two frames.
Divide the current frame into 16 x 16 macro blocks.
.c
For every macro block in the frame, to find the region in the previous frame that most
closely matches the macro block.
Measure similarity using the following sum-of-differences measure
ul
pa
M(i,j) intensity of the macro block at pixel i,j,
S(i,j) intensity of the search region
N size of the macro block in one dimension
jin
<ox, oy>offset between the macro block and search region
We choose the macro block position relative to the search area that gives us the smallest
value for this metric.
.re
The offset at this chosen position describes a vector from the search area center to the
macro block's center that is called the motion vector.
w
w
w
www.rejinpaul.com
om
C code for a single search, which assumes that the search region does not extend past the
boundary of the frame.
.c
The arithmetic on each pixel is simple, but we have to process a lot of pixels.
If MBSIZE is 16 and SEARCHSIZE is 8, and remembering that the search distance in each
dimension is 8 + 1 + 8, then we must perform
ul
pa
jin
.re
w
w
w
www.rejinpaul.com
5.13.4)Requirements
om
.c
ul
pa
jin
.re
w
w
w
www.rejinpaul.com
5.13.5)Specification
om
Specification for the system is relatively straightforward because the algorithm is simple.
The following classes used to describe basic data types in the system motion vector,
.c
macro block, search area.
ul
pa
jin
.re
w
w
w
www.rejinpaul.com
om
5.13.6)Sequence Diagram
.c
The accelerator provides a behavior
compute-mv() that performs the block
motion estimation algorithm.
ul
After initiating the behavior, the accelerator
reads the search area and macro block from
pa
the PC, after computing the motion vector,
it returns it to the PC.
jin
.re
w
w
w
www.rejinpaul.com
5.13.7)Architecture
om
The macro block has 16 x16 = 256.
The search area has (8 + 8 + 1 + 8 + 8)2 =
1,089 pixels.
.c
FPGA probably will not have enough
memory to hold 1,089 (8-bit )values.
ul
The machine has two memories, one for
the macro block and another for the
search memories.
pa
It has 16 processing elements that
perform the difference calculation on a
pair of pixels.
jin
Comparator sums them up and selects
the best value to find the motion vector.
.re
w
w
w
www.rejinpaul.com
5.13.8)System testing
om
Testing video algorithms requires a large amount of data.
.c
we are designing only a motion estimation accelerator and not a complete video
compressor, it is probably easiest to use images, not video, for test data.
ul
use standard video tools to extract a few frames from a digitized video and store them in
JPEG format.
pa
Open source for JPEG encoders and decoders is available.
These programs can be modified to read JPEG images and put out pixels in the format
required by your accelerator.
jin
.re
w
w
w