ESD Module2-1
ESD Module2-1
MODULE -2
Embedded System Design Concepts: Characteristics and Quality Attributes of Embedded
systems, Operational and non-operational quality attributes, Embedded systems- Application
and Domain specific, Hardware Software Co-Design and Program Modelling (excluding
UML), Embedded firmware design and development (excluding C language).
Each embedded system has certain functions to perform and they are developed in
such a manner to do the intended functions only.
They cannot be used for any other purpose.
This is the major criterion which distinguishes an embedded system from a general
purpose system.
For example, the embedded control unit of a microwave oven cannot be replaced with
an air conditioners embedded control unit, because the embedded control units of
microwave oven and air conditioner are specifically designed to perform certain
specific tasks.
Also an embedded control unit developed for a particular domain, say telecom, cannot
be replaced with another control unit designed to serve another domain like consumer
electronics.
Dr.
[Link]
BhargaviM , KSSEM
Sangam, Asst. Professor, Dept. Of ECE Page 1
Embedded System Design-BEC601
[Link]
Dr. BhargaviM
Sangam, Asst. Professor, Dept. Of ECE
, KSSEM Page 2
Embedded System Design-BEC601
It contains a card reader embedded unit, responsible for reading and validating the
user's ATM card, transaction unit for performing transactions, a currency counter for
dispatching/vending currency to the authorised person and a printer unit for printing
the transaction details.
We can visualise these as independent embedded systems, but they work together to
achieve a common goal.
Another typical example of a distributed embedded system is the Supervisory Control
And Data Acquisition (SCADA) system used in Control & Instrumentation applications,
which contains physically distributed individual embedded control units connected to a
supervisory module.
The product aesthetics (size, weight, shape, style etc) will be one of the deciding
factors to choose a product.
Ex. Currently available cell phones. The cell phones that have the maximum features
are popular but also their size and weight is an important characteristic.
6. Power concerns
Quality attributes are the non-functional requirements that need to be documented properly in
any system design.
If the quality attributes are more concrete and measurable it will give a positive impact on the
system development process and the end product.
These are the attributes that together form the deciding factor about the quality of an
embedded system.
Dr.
[Link]
BhargaviM , KSSEM
Sangam, Asst. Professor, Dept. Of ECE Page 3
Embedded System Design-BEC601
1. Response:
Response is a measure of quickness of the system.
It gives you an idea about how fast your system is tracking the input variables.
Most of the embedded system demand fast response which should be real-time.
2. Throughput
Throughput deals with the efficiency of system.
It can be defined as rate of production or process of a defined process over a stated
period of time.
The rates can be expressed in terms of units of products, batches produced or any
other meaningful measurements.
In case of card reader like the ones used in buses, throughput means how much
transaction the reader can perform in a minute or hour or day.
Throughput is generally measured in terms ‘Benchmark’.
A ‘Benchmark’ is a reference point by which something can be measured.
Benchmark can be set of performance criteria that a product is expected to meet or a
standard product that can be used for comparing other products of the same product
line.
3. Reliability
Reliability is a measure of how much percentage you rely upon the proper functioning
of the system or what is the % susceptibility of the system failures.
[Link]
Dr. BhargaviM
Sangam, Asst. Professor, Dept. Of ECE
, KSSEM Page 4
Embedded System Design-BEC601
Mean Time between failures (MTBF) and Mean Time To Repair (MTTR) are terms
used in defining system reliability.
MTBF gives the frequency in hours/weeks/months.
Mean Time between failures can be defined as the average time the system is
functioning before a failure occurs.
Mean time to repair can be defined as the average time the system has spent in
repairs.
MTTF specifies how long the system is allowed to be out of order following a failure.
For an embedded system with critical application need, it should be of order of
minutes.
4. Maintainability
Maintainability deals with support and maintenance to the end user or a client in
case of technical issues and product failures or on the basis of a routine system
check-up
Reliability and maintainability are considered as two complementary disciplines.
It can be classified into two types :-
a) Scheduled or Periodic Maintenance ( Preventive maintenance)
This is the maintenance that is required regularly after a periodic time interval.
Example: Periodic Cleaning of Air Conditioners Refilling of printer cartridges.
b) Maintenance to unexpected failure
This involves the maintenance due to a sudden breakdown in the functioning of
the system.
Example:
Air conditioning not powering ON
Printer not taking full stacks of paper
In embedded system, the ideal value for availability is expressed as,
Ai=MTBF/(MTBF+MTTR)
Where,
Ai= availability in ideal condition
MTBF= Mean Time between Failures
MTTR= Mean time to repair
5. Security
Confidentiality, Integrity and Availability are three major measures of information
security.
Confidentiality deals with protection data from unauthorized disclosure.
Integrity gives protection from unauthorized modification.
Availability gives protection from unauthorized user
Certain Embedded systems have to make sure they conform to the security measures.
Ex. An Electronic Safety Deposit Locker can be used only with a pin number like a
password.
6. Safety
Safety deals with the possible damage that can happen to the operating person and
environment due to the breakdown of an embedded system or due to the emission of
hazardous materials from the embedded products.
[Link]
Dr. BhargaviM
Sangam, Asst. Professor, Dept. Of ECE
, KSSEM Page 5
Embedded System Design-BEC601
It deals with how easily one can test his/her design, application and by which mean
he/she can test it.
For an embedded product, testability is applicable to both the embedded hardware and
firmware.
In hardware testing the peripherals and total hardware function is in designed manner.
Firmware testing is functioning in the expected way.
Debug-ability is means of debugging the product as such for figuring out the probable
sources that create unexpected behaviour in the total system.
Debug-ability has two aspects in the embedded system development, namely,
hardware level debugging and firmware level debugging.
Hardware level debugging is used for figuring out issues created by hardware
problems whereas, firmware debugging is employed to figure out the probable errors
that appear as a result in the firmware.
2. Evolvability
Mrs. BhargaviM
Dr. Kishore Sangam, Asst. Professor, Dept. Of ECE
, KSSEM Page 6
Embedded System Design-BEC601
For embedded system, the qualitative attribute “Evolvability” refer to ease with which
the embedded product can be modified to take advantage of new firmware or
hardware technology.
3. Portability
Portability is measured of “system Independence”.
An embedded product can be called portable if it is capable of performing its
operation as it is intended to do in various environments irrespective of different
processor and or controller and embedded operating systems.
The ease with which an embedded product can be ported to a new platform is a direct
measure of re-work required.
A standard embedded product should always be flexible and portable.
In embedded products, ‘porting’ means migration of embedded firmware written for
one target processor to a different target processor.
4. Time to prototype and market
Time to Market is the time elapsed between the conceptualization of a product and
time at which the product is ready for selling or use
Product prototyping help in reducing time to market.
In order to shorten the time to prototype, make use of all possible option like use of
reuse, off the self component etc.
5. Per unit and total cost
Cost is an important factor which needs to be carefully monitored. Proper market
study and cost benefit analysis should be carried out before taking decision on the per
unit cost of the embedded product.
When the product is introduced in the market, for the initial period the sales and
revenue will be low
There won’t be much competition when the product sales and revenue increase.
During the maturing phase, the growth will be steady and revenue reaches highest
point and at retirement time there will be a drop in sales volume.
Mrs. BhargaviM
Dr. Kishore Sangam, Asst. Professor, Dept. Of ECE
, KSSEM Page 7
Embedded System Design-BEC601
[Link]
Dr. BhargaviMSangam, Asst. Professor, Dept. Of ECE
, KSSEM Page 8
Embedded System Design-BEC601
In the second phase of washing, water is pumped out from the tub and the inner tub
uses centrifugal force to wring out more water from the clothes by spinning at several
hundred Rotations Per Minute (RPM).
Mrs. BhargaviM
Dr. Kishore Sangam, Asst. Professor, Dept. Of ECE
, KSSEM Page 9
Embedded System Design-BEC601
[Link]
Dr. BhargaviM
Sangam, Asst. Professor, Dept. Of ECE
, KSSEM Page 10
Embedded System Design-BEC601
Automotive embedded systems are the one where electronics take control over the
mechanical systems.
The presence of automotive embedded system in a vehicle varies from simple mirror
and wiper controls to complex air bag controller and antilock brake systems (ABS).
Automotive embedded systems are normally built around microcontrollers or DSPs or
a hybrid of the two and are generally known as Electronic Control Units (ECUs).
The number of embedded controllers in an ordinary vehicle varies from 20 to 40
whereas a luxury vehicle like Mercedes S and BMW 7 may contain 75 to 100
numbers of embedded controllers.
The first embedded system used in automotive application was the microprocessor
based fuel injection system introduced by Volkswagen 1600 in 1968.
The electronic control units (ECUs) used in the automotive embedded industry can be
broadly classified into two:
High-speed Electronic Control Units (HECUs):
1. These are deployed in critical control units requiring fast response.
2. They include fuel injection systems, antilock brake systems, engine control, electronic
throttle, steering controls, transmission control unit and central control unit.
Low-speed Electronic Control Units (LECUs):
1. These are deployed in applications where response time is not so critical.
[Link]
Dr. BhargaviM
Sangam, Asst. Professor, Dept. Of ECE
, KSSEM Page 11
Embedded System Design-BEC601
2. They generally are built around low cost microprocessors/microcontrollers and digital
signal processors.
3. Audio controllers, passenger and driver door locks, door glass controls (power
windows), wiper control, mirror control, seat control systems, head lamp and tail lamp
controls, sun roof control unit etc. are examples of LECUs.
Automotive applications make use of serial buses for communication, which greatly
reduces the amount of wiring required inside a vehicle.
Different types of serial interface buses are:
1. Controller Area Network (CAN) Bus
2. Local Interconnect Network (LIN) Bus
3. Media-Oriented System Transport (MOST) Bus
Controller Area Network (CAN) Bus
• CAN Bus was originally proposed by Robert Bosch, pioneer in the
Automotive embedded solution providers.
• It supports medium speed (ISO11519-class B with data rates up to 125 Kbps)
and high speed (IS011898 class C with data rates up to 1 Mbps) data transfer.
• CAN is an event-driven protocol interface with support for error handling in
data transmission.
• It is generally employed in safety system like airbag control; power train
systems like engine control and Antilock Brake System (ABS); and navigation
systems like GPS.
[Link]
Dr. BhargaviM
Sangam, Asst. Professor, Dept. Of ECE
, KSSEM Page 12
Embedded System Design-BEC601
[Link]
Dr. BhargaviM
Sangam, Asst. Professor, Dept. Of ECE
, KSSEM Page 13
Embedded System Design-BEC601
In hardware software co-design, models are used for capturing and describing the system
characteristics.
A model is a formal system consisting of objects and composition rules.
It is hard to make a decision on which model should be followed in a particular system
design.
Most often designers switch between varieties of models from the requirements specification
to the implementation aspect of the system design.
The reason being, the objective varies with each phase.
For example, at the specification stage, only the functionality of the system is in focus
and not the implementation information.
When the design moves to the implementation aspect, the information about the
system components is revealed and the designer has to switch to a model capable of
capturing the system's structure.
Selecting the Architecture
A model only captures the system characteristics and does not provide information on
'how the system can be manufactured?’.
The architecture specifies how a system is going to implement in terms of the number
and types of different components and the interconnection among them.
The commonly used architectures in system design are Controller Architecture, Data
path Architecture, Complex Instruction Set Computing (CISC), Reduced Instruction
Set Computing (RISC), Very Long Instruction Word Computing (VLIW), Single
Instruction Multiple Data (SIMD), Multiple Instruction Multiple Data (MIMD), etc.
• Some of them fall into Application Specific Architecture Class (like controller
architecture), while others fall into either general purpose architecture class (CISC,
RISC, etc.) or parallel processing class (like VLIW, SIMD, MIMD, etc.).
The control architecture implements the finite state machine model using a state register
and two combinational circuits. The state register holds the present state and the
combinational circuits implement the logic for next state and output.
The data path architecture is best suited for implementing the data flow graph model where
the output is generated as a result of a set of predefined computations on the input data. A
datapath represents a channel between the input and output and in datapath architecture the
datapath may contain registers, datapath to multiple buses. Most of the time the arithmetic
units are connected in parallel with pipelining support for bringing high performance.
The finite state machine datapath (FSMD) architecture combines the controller architecture
with datapath architecture. It implements a controller with datapath. The controller generates
the control input whereas the datapath processes the data. The datapath contains two types of
I/O ports, out of which one acts as the control port for receiving/sending the control signals
from/to the controller unit and the second I/O port interfaces the datapath with external world
for data input and data output.
The Complex Instruction set computing (CISC) uses an instruction set representing
complex operations. It is possible for a CISC instruction set to perform large complex
operation with a single instruction. The use of a single complex instruction in place of
Mrs. BhargaviM
Dr. Kishore Sangam, Asst. Professor, Dept. Of ECE
, KSSEM Page 14
Embedded System Design-BEC601
multiple simple instructions greatly reduces the program memory access and program
memory size requirement. However it requires additional silicon for implementing microcode
decode for decoding the CISC instruction.
The very long instruction word (VLIW) architecture implements multiple functional units
(ALU’s, multipliers, etc) in the datapath. The VLIW instruction packages one standard
instruction per functional unit of the datapath.
Parallel processing architecture implements multiple concurrent processing elements (PEs)
and each processing element may associate a datapath containing register and local memory.
Single instruction multiple data (SIMD) and multiple instruction multiple data (MIMD)
architectures are examples for parallel processing architecture.
In SIMD architecture, a single instruction is executed in parallel with the help of processing
elements. The scheduling of the instruction execution and controlling of each PE is
performed through single controller.
The SIMD architecture forms the basis of re-configurable processor.
The processing elements of MIMD architecture execute different instructions at a given point
of time.
The MIMD architecture forms the basis of multiprocessor systems.
The PEs in multiprocessor systems communicates through mechanisms like shared memory
and message passing.
[Link]
Dr. BhargaviM
Sangam, Asst. Professor, Dept. Of ECE
, KSSEM Page 15
Embedded System Design-BEC601
[Link]
Dr. BhargaviMSangam,
, KSSEMAsst. Professor, Dept. Of ECE Page 16
Embedded System Design-BEC601
In a DFG model, a data path is the data flow path from input to output.
A DFG model is said to be acyclic DFG (ADFG) if it doesn't contain multiple values
for the input variable and multiple output values for a given set of input(s).
• Feedback inputs (Output is fed back to Input), events, etc. are examples for non-
acyclic inputs.
A DFG model translates the program as a single sequential process execution.
Control Data Flow Graph/Diagram (CDFG) Model
The DFG model is a data driven model in which the execution is controlled by data
and it doesn't involve any control operations (conditionals).
The Control DFG (CDFG) model is used for modelling applications involving
conditional program execution.
CDFG models contains both data operations and control operations. The CDFG uses
Data Flow Graph (DFG) as element and conditional (constructs) as decision makers.
CDFG contains both data flow nodes and decision nodes, whereas DFG contains only
data flow nodes.
Consider the implementation of the CDFG for the following requirement.
= 1, = + ; = − ;
This requirement contains a decision making process.
The CDFG model for the same is given in the figure.
The control node is represented by a 'Diamond' block which is the decision making
element in a normal flow chart based design.
CDFG translates the requirement, which is modelled to a concurrent process model.
The decision on which process is to be executed is determined by the control node.
A real world example for modelling the embedded application using CDFG is
capturing and saving of the image to a format set by the user in a digital still camera.
The decision on, in which format the image is stored (formats like JPEG, TIFF, BMP,
etc.) is controlled by the camera settings, configured by the user.
State Machine Model
[Link]
Dr. BhargaviM
Sangam, Asst. Professor, Dept. Of ECE
, KSSEM Page 17
Embedded System Design-BEC601
The State Machine Model is used for modelling reactive or event-driven embedded
systems whose processing behaviour are dependent on state transitions.
• Embedded systems used in the control and industrial applications are typical
examples for event driven systems.
The State Machine model describes the system behaviour with 'States', 'Events',
'Actions' and 'Transitions’.
• State is a representation of a current situation.
• An event is an input to the state.
▪ The event acts as stimuli for state transition.
• Transition is the movement from one state to another.
• Action is an activity to be performed by the state machine.
Finite State Machine (FSM) Model
A Finite State Machine (FSM) model is one in which the number of states are finite.
• The system is described using a finite number of possible states.
As an example, let us consider the design of an embedded system for driver/passenger
'Seat Belt Warning' in an automotive using the FSM model.
The system requirements are captured as,
• When the vehicle ignition is turned on and the seat belt is not fastened within
10 seconds of ignition ON, the system generates an alarm signal for 5 seconds.
The Alarm is turned off when the alarm time (5 seconds) expires or if the driver/passenger
fastens the belt or if the ignition switch is turned off, whichever happens first.
Here the states are • 'Alarm Off’
• 'Waiting’
• 'Alarm On’
The events are • 'Ignition Key ON’
• 'Ignition Key OFF’
• 'Timer Expire’
• 'Alarm Time Expire’
• 'Seat Belt ON’
Using the FSM, the system requirements can be modelled as given in figure.
[Link]
Dr. BhargaviMSangam, Asst. Professor, Dept. Of ECE
, KSSEM Page 18
Embedded System Design-BEC601
The 'Ignition Key ON' event triggers the 10 second timer and transitions the state to
'Waiting’.
If a Seat Belt ON’ or 'Ignition Key OFF' event occurs during the wait state, the state
transitions into 'Alarm Off’.
When the wait timer expires in the waiting state, the event 'Timer Expire' is generated
and it transitions the state to 'Alarm On' from the 'Waiting' state.
The 'Alarm On' state continues until a 'Seat Belt ON' or 'Ignition Key OFF' event or
'Alarm Time Expire' event, whichever occurs first.
The occurrence of any of these events transitions the state to 'Alarm Off’.
The wait state is implemented using a timer:
o The timer also has certain set of states and events for state transitions
o Using the FSM model, the timer can be modelled as shown in the figure.
[Link]
Dr. BhargaviMSangam, Asst. Professor, Dept. Of ECE
, KSSEM Page 19
Embedded System Design-BEC601
As seen from the FSM, the timer state can be either 'IDLE' or 'READY' or
'RUNNING’.
During the normal condition when the timer is not running, it is said to be in the
'IDLE' state.
The timer is said to be in the 'READY’ state when the timer is loaded with the count
corresponding to the required time delay.
The timer remains in the 'READY' state until a 'Start Timer' event occurs.
The timer changes its state to 'RUNNING' from the 'READY' state on receiving a
'Start Timer' event and remains in the 'RUNNING' state until the timer count expires
or a 'Stop Timer' even occurs.
The timer state changes to 'IDLE' from 'RUNNING' on receiving a 'Stop Timer' or
'Timer Expire' event.
FSM Model – Example 1
Design an automatic tea/coffee vending machine based on FSM model for the following
requirement.
• The tea/coffee vending is initiated by user inserting a 5 rupee coin.
• After inserting the coin, the user can either select 'Coffee' or 'Tea' or press 'Cancel' to cancel
the order and take back the coin.
Solution:
The FSM Model contains four states namely,
• 'Wait for coin’
• 'Wait for User Input’
• 'Dispense Tea'
• 'Dispense Coffee'
[Link]
Dr. BhargaviM
Sangam, Asst. Professor, Dept. Of ECE
, KSSEM Page 20
Embedded System Design-BEC601
The event 'Insert Coin' (5 rupee coin insertion), transitions the state to 'Wait for User
Input’.
The system stays in this state until a user input is received from the buttons 'Cancel',
'Tea' or 'Coffee' (Tea and Coffee is the drink select button).
If the event triggered in 'Wait State' is 'Cancel' button press, the coin is pushed out and
the state transitions to 'Wait for Coin’.
If the event received in the 'Wait State' is either 'Tea' button press, or 'Coffee' button
press, the state changes to 'Dispense Tea' and 'Dispense Coffee' respectively.
Once the coffee/tea vending is over, the respective states transition back to the 'Wait
for Coin' state
FSM Model – Example 2
Design a coin operated public telephone unit based on FSM model for the following
requirements.
• The calling process is initiated by lifting the receiver (off-hook) of the telephone unit.
• After lifting the phone the user needs to insert a 1 rupee coin to make the call.
• If the line is busy, the coin is returned on placing the receiver back on the hook (on-hook).
• If the line is through, the user is allowed to talk till 60 seconds and at the end of 45th
second, prompt for inserting another 1 rupee coin for continuing the call is initiated.
• If the user doesn't insert another 1 rupee coin, the call is terminated on completing the 60
seconds time slot.
• The system is ready to accept new call request when the receiver is placed back on the hook
(on-hook).
• The system goes to the 'Out of Order' state when there is a line fault.
[Link]
Dr. BhargaviMSangam, Asst. Professor, Dept. Of ECE
, KSSEM Page 21
Embedded System Design-BEC601
[Link]
Dr. BhargaviM
Sangam, Asst. Professor, Dept. Of ECE
, KSSEM Page 22
Embedded System Design-BEC601
Dr.
[Link]
BhargaviMSangam,
, KSSEMAsst. Professor, Dept. Of ECE Page 23
Embedded System Design-BEC601
execution of task and thereby leads to poor processor utilisation, when the task
involves I/O waiting, sleeping for specified duration etc.
• If the task is split into multiple subtasks, it is possible to tackle the CPU usage
effectively by switching the task execution, when the subtask under execution
goes to a wait or sleep mode.
However, concurrent processing model requires additional overheads in task
scheduling, task synchronization and communication.
As an example, consider the implementation of the 'Seat Belt Warning' system using
concurrent processing model.
We can split the tasks into:
• Timer task for waiting 10 seconds (wait timer task)
• Task for checking the ignition key status (ignition key status monitoring task)
• Task for checking the seat belt status (seat belt status monitoring task)
• Task for starting and stopping the alarm (alarm control task)
• Alarm timer task for waiting 5 seconds (alarm timer task)
The tasks cannot be executed them randomly or sequentially.
We need to synchronize their execution through some mechanism.
We need to start the alarm only after the expiration of the 10 seconds wait timer and
that too only if the seat belt is OFF and the ignition key is ON.
Hence the alarm control task is executed only when the wait timer is expired and if
the ignition key is in the ON state and seat belt is in the OFF state.
Object-Oriented Model
The object-oriented model is an object based model for modelling system
requirements.
[Link]
Dr. BhargaviMSangam, Asst. Professor, Dept. Of ECE
, KSSEM Page 24
Embedded System Design-BEC601
It disseminates a complex software requirement into simple well defined pieces called
objects.
Object-oriented model brings re-usability, maintainability and productivity in system
design.
In the object-oriented modelling, object is an entity used for representing or modelling
a particular piece of the system.
• Each object is characterized by a set of unique behaviour and state.
A class is an abstract description of a set of objects and it can be considered as a
'blueprint' of an object.
A class represents the state of an object through member variables and object
behaviour through member functions.
The member variables and member functions of a class can be private, public or
protected.
• Private member variables and functions are accessible only within the class, whereas public
variables and functions are accessible within the class as well as outside the class.
• The protected variables and functions are protected from external access.
• However, classes derived from a parent class can also access the protected member
functions and variables.
[Link]
Dr. BhargaviM
Sangam, Asst. Professor, Dept. Of ECE
, KSSEM Page 25
Embedded System Design-BEC601
[Link]
Dr. BhargaviM
Sangam, Asst. Professor, Dept. Of ECE
, KSSEM Page 26
Embedded System Design-BEC601
Almost all tasks in embedded applications are non-ending and are repeated infinitely
throughout the operation.
• This repetition is achieved by using an infinite loop.
• Hence the name 'Super loop based approach’.
The only way to come out of the loop is either a hardware reset or an interrupt assertion.
Advantage of Super Loop Based Approach: • It doesn't require an operating system
• There is no need for scheduling which task is to be executed and assigning priority to each
task.
• The priorities are fixed and the order in which the tasks to be executed are also fixed.
• Hence the code for performing these tasks will be residing in the code memory without an
operating system image.
Applications of Super Loop Based Approach:
• This type of design is deployed in low-cost embedded products and products where
response time is not time critical.
• Some embedded products demands this type of approach if some tasks itself are sequential.
For example, reading/writing data to and from a card using a card reader requires a sequence
of operations like checking the presence of card, authenticating the operation,
reading/writing, etc.
It should strictly follow a specified sequence and the combination of these series of tasks
constitutes a single task-namely data read/write.
A typical example of a 'Super loop based’ product is an electronic video game toy containing
keypad and display unit.
• The program running inside the product may be designed in such a way that it reads the
keys to detect whether the user has given any input and if any key press is detected the
graphic display is updated.
• The keyboard scanning and display updating happens at a reasonably high rate.
[Link]
Dr. BhargaviMSangam, Asst. Professor, Dept. Of ECE
, KSSEM Page 27
Embedded System Design-BEC601
• Even if the application misses a key press, it won't create any critical issues; rather it will be
treated as a bug in the firmware.
Use of GPOS in embedded products merges the demarcation of Embedded Systems and
general computing systems in terms of OS.
For developing applications on top of the OS, the OS supported APIs are used.
Similar to the different hardware specific drivers, OS based applications also require 'Driver
software' for different hardware present on the board to communicate with them.
Real Time Operating System (RTOS) based design approach is employed in embedded
products demanding Real-time response. • RTOS responds in a timely and predictable
manner to events.
Real Time operating system contains a Real Time kernel responsible for performing pre-
emptive multitasking, scheduler for scheduling tasks, multiple threads, etc.
A Real Time Operating System (RTOS) allows flexible scheduling of system resources like
the CPU and memory and offers some way to communicate between tasks. 'Windows CE',
'pSOS', 'VxWorks', 'ThreadX', 'MicroC/OS-II’, 'Embedded Linux', 'Symbian’, etc. are
examples of RTOS employed in embedded product development.
[Link]
Dr. BhargaviM
Sangam, Asst. Professor, Dept. Of ECE
, KSSEM Page 28
Embedded System Design-BEC601
Dr.
[Link]
BhargaviM , KSSEM
Sangam, Asst. Professor, Dept. Of ECE Page 29
Embedded System Design-BEC601
Similar to 'C' and other high level language programming, we can have multiple
source files called modules in assembly language programming.
• Each module is represented by an '.asm' or '.src' file.
This approach is known as 'Modular Programming’.
Modular programming is employed when the program is too complex or too big.
• In 'Modular Programming', the entire code is divided into submodules and
each module is made re-usable.
Modular Programs are usually easy to code, debug and alter.
Each source module is written in Assembly and is stored as .src file or .asm file.
Each file can be assembled separately to examine the syntax errors and incorrect
assembly instructions.
[Link]
Dr. BhargaviM
Sangam, Asst. Professor, Dept. Of ECE
, KSSEM Page 30
Embedded System Design-BEC601
[Link]
Dr. BhargaviM
Sangam, Asst. Professor, Dept. Of ECE
, KSSEM Page 31
Embedded System Design-BEC601
Hex file is created from the final 'Absolute Object File' using the Object to Hex File
Converter utility.
• 'OH51' from Keil software is an example for Object to Hex File Converter utility for
A51 Assembler/C51 Compiler for 8051 specific controller.
Advantages of Assembly Language Base Development
Efficient Code Memory and Data Memory Usage (Memory Optimisation)
1. Since the developer is well versed with the target processor architecture and
memory organisation, optimised code can be written for performing operations.
2. This leads to less utilisation of code memory and efficient utilisation of data
memory.
High Performance
1. Optimised code not only improves the code memory usage but also improves the
total system performance.
2. Through effective assembly coding, optimum performance can be achieved for a
target application.
Low Level Hardware Access
1. Most of the code for low level programming like accessing external device
specific registers from the operating system kernel, device drivers, and low level
interrupt routines, etc. are making use of direct assembly coding since low level
device specific operation support is not commonly available with most of the
high-level language cross compilers.
Code Reverse Engineering
1. Reverse engineering is the process of understanding the technology behind a
product by extracting the information from a finished product.
2. Reverse engineering is performed by 'hawkers' to reveal the technology behind
'Proprietary Products’.
3. Though most of the products employ code memory protection, if it may be
possible to break the memory protection and read the code memory, it can easily
be converted into assembly code using a dis-assembler program for the target
machine.
Drawbacks of Assembly Language Based Development
High Development Time
1. Assembly language is much harder to program than high level languages.
2. The developer must pay attention to more details and must have thorough knowledge
of the architecture, memory organisation and register details of the target processor in
use.
3. Learning the inner details of the processor and its assembly instructions is highly time
consuming and it creates a delay impact in product development.
4. Also more lines of assembly code are required for performing an action which can be
done with a single instruction in a high-level language like 'C'.
Developer Dependency
[Link]
Dr. BhargaviMSangam, Asst. Professor, Dept. Of ECE
, KSSEM Page 32
Embedded System Design-BEC601
1. Unlike high level languages, there is no common written rule for developing assembly
language based applications.
2. In assembly language programming, the developers will have the freedom to choose
the different memory location and registers.
3. Also the programming approach varies from developer to developer depending on
his/her taste.
4. For example, moving data from a memory location to accumulator can be achieved
through different approaches.
5. If the approach done by a developer is not documented properly at the development
stage, he/she may not be able to recollect why this approach is followed at a later
stage or when a new developer is instructed to analyse this code, he/she also may not
be able to understand what is done and why it is done.
6. Hence upgrading an assembly program or modifying it on a later stage is very
difficult.
Non-Portable
1. Target applications written in assembly instructions are valid only for that particular
family of processors (e.g. Application written for Intel x86 family of processors) and
cannot be re-used for another target processors/controllers (Say ARM11 family of
processors).
2. If the target processor/controller changes, a complete re-writing of the application
using the assembly instructions for the new target processor/controller is required.
[Link]
Dr. BhargaviMSangam,
, KSSEMAsst. Professor, Dept. Of ECE Page 33
Embedded System Design-BEC601
The program written in any of the high level languages is saved with the
corresponding language extension (.c for C, .cpp for C++ etc).
Any text editor like ‘Notepad' or 'WordPad' from Microsoft or the text editor provided
by an Integrated Development (IDE) tool can be used for writing the program.
Most of the high level languages support modular programming approach and hence
we can have multiple source files called modules written in corresponding high level
language.
The source files corresponding to each module is represented by a file with
corresponding language extension.
Translation of high level source code to executable object code is done by cross-
compiler. Each high level language should have a cross-compiler for converting the
high level source code into the target processor machine code.
C51 Cross-compiler from Keil software is an example for Cross-compiler used for 'C'
language for the 8051 family of microcontroller.
Conversion of each module's source code to corresponding object file is performed by
the cross-compiler.
Rest of the steps involved in the conversion of high level language to target
processor's machine code are same as that of the steps involved in assembly language
based development.
[Link]
Dr. BhargaviM
Sangam, Asst. Professor, Dept. Of ECE
, KSSEM Page 34
Embedded System Design-BEC601
• Developer requires less or little knowledge on the internal hardware details and
architecture of the target processor/controller.
• Bare minimal knowledge of the memory organisation and register details of the
target processor in use and syntax of the high level language are the only pre-
requisites for high level language based firmware development.
• With high level language, each task can be accomplished by lesser number of lines
of code compared to the target processor/controller specific assembly language based
development.
Developer Independency
• The syntax used by most of the high level languages are universal and a program
written in the high level language can easily be understood by a second person
knowing the syntax of the language.
• High level languages always instruct certain set of rules for writing the code and
commenting the piece of code.
• If the developer strictly adheres to the rules, the firmware will be 100% developer
independent.
Portability
• An application written in high level language for a particular target processor can easily be
converted to another target processor/controller specific application, with little or less effort
by simply re-compiling/little code modification followed by recompiling the application for
the required target processor/controller, provided, the cross-compiler has support for the
processor/controller selected.
• Little effort may be required in the existing code to replace the target processor specific
files with new header files, register definitions with new ones, etc.
• This is the major flexibility offered by high level language based design.
• Target images created by such compilers may be messy and non- optimised in terms
of performance as well as code size.
• The time required to execute a task also increases with the number of instructions.
[Link]
Dr. BhargaviMSangam, Asst. Professor, Dept. Of ECE
, KSSEM Page 35
Embedded System Design-BEC601
• High level language based code snippets may not be efficient in accessing low level
hardware where hardware access timing is critical (of the order of nano or micro
seconds).
High Investment Cost
• The investment required for high level language based development tools
(Integrated Development Environment incorporating cross-compiler) is high
compared to Assembly Language based firmware development tools.
Certain embedded firmware development situations may demand the mixing of high level
language with Assembly and vice versa.
High level language and assembly languages are usually mixed in three ways:
[Link]
Dr. BhargaviM
Sangam, Asst. Professor, Dept. Of ECE
, KSSEM Page 36
Embedded System Design-BEC601
• Write a simple function in C that passes parameters and returns values the way you want
your assembly routine to.
• Use the SRC directive (#PRAGMA SRC at the top of the file) so that the C compiler
generates an .SRC file instead of an .OBJ file.
• Compile the C file. Since the SRC directive is specified, the .SRC file is generated. The
.SRC file contains the assembly code generated for the C code you wrote.
• Edit the .A51 file and insert the assembly code you want to execute in the body of the
assembly function shell included in the . A51 file.
Mixing the code written in a high level language like 'C' and Assembly language is
useful in the following scenarios:
• The source code is already available in Assembly language and a routine
written in a high level language like 'C' needs to be included to the existing
code.
• The entire source code is planned in Assembly code for various reasons like
optimised code, optimal performance, efficient code memory utilisation and
proven expertise in handling the Assembly, etc. But some portions of the code
may be very difficult and tedious to code in Assembly. For example, 16-bit
multiplication and division in 8051 Assembly Language.
• To include built in library functions written in 'C' language provided by the
cross compiler. For example, Built in Graphics library functions and String
operations supported by 'C’.
Most often the functions written in 'C' use parameter passing to the function and
returns value/s to the calling functions.
Parameters are passed to the function and values are returned from the function using
CPU registers, stack memory and fixed memory.
Its implementation is cross compiler dependent and it varies across cross compilers.
[Link]
Dr. BhargaviM
Sangam, Asst. Professor, Dept. Of ECE
, KSSEM Page 37
Embedded System Design-BEC601
C51 uses the keywords #pragma asm and #pragma endasm to indicate a block of code
written in assembly.
Dr.
[Link]
BhargaviM , KSSEM
Sangam, Asst. Professor, Dept. Of ECE Page 38