Ilovepdf Merged 1
Ilovepdf Merged 1
Presentation by
Dr.K.Ragavan
Assistant Professor Senior Grade I
Department of IOT
School of Computer Science and Engineering
VIT University, Vellore
Syllabus
2
Evolution of embedded
programming tools
Embedded Software
19
State machine
When inputs appear intermittently rather than as periodic
samples, it is often convenient to think of the system as
reacting to those inputs.
20
Seat belt controller
The controller’s job is to turn on a buzzer if a person sits in
a seat and does not fasten the seat belt within a fixed
amount of time.
This system has three inputs and one output.
The inputs are a sensor for the seat & The output is the
buzzer.
21
Circular buffer
The data stream style makes sense for data that comes in
regularly and must be processed on the fly.
22
At each point in time, the algorithm needs a subset of the
data stream that forms a window into the stream.
The window slides with time as we throw out old values
no longer needed and add new values.
Since the size of the window does not change we can use
a fixed-size buffer to hold the current data.
The buffer points to the location at which the next sample
will be placed every time we add a sample we automatically
overwrite the oldest sample, which is the one that needs to
be thrown out.
23
24
Queue
Queues are also used in signal processing and event
processing.
Queues are used whenever data may arrive and depart at
somewhat unpredictable times or when variable amounts
of data may arrive.
A queue is often referred to as an elastic buffer.
One way to build a queue is with a linked list. This
approach allows the queue to grow to an arbitrary size.
Another way to design the queue is to use an array to
hold all the data.
25
26
School of Computer Science and Engineering
Presentation by
Dr.K.Ragavan
Assistant Professor Senior Grade I
Department of IOT
School of Computer Science and Engineering
VIT University, Vellore
Syllabus
2
MODELS OF PROGRAMS
3
Modelling programs
• Creating a model for the embedded system provides
a time-saving and cost-effective approach to the
development of dynamic control systems, based on
a single model maintained in a tightly integrated
software suite.
• It refers to a visual method for designing complex
control systems
9
Data Flow Graphs
A data flow graph is a model of a program with no
conditionals.
10
Before we are able to draw the data flow graph for this
code we need to modify it slightly.
There are two assignments to the variable x it
appears twice on the left side of an assignment.
We need to rewrite the code in single-assignment
form, in which a variable appears only once on the left
side.
11
12
ADVANTAGES of DFG
• Data flow graph models help in a simple code
design.
16
Decision nodes
17
Dr.K.Ragavan, SCOPE, VIT Vellore 18
Dr.K.Ragavan, SCOPE, VIT Vellore 19
ADVANTAGES - (CDFG) Modelling
• a variable value changing above a limit or below a
limit or falling within a range is also like an event
that activates a certain process.
• task scheduling,
• task synchronisation
• communication.
example, consider the implementation
of the 'Seat Belt Warning' system
• We can split the tasks into:
• 1. Timer task for waiting 10 seconds (wait timer task)
• 2. Task for checking the ignition key status (ignition key
status monitoring task)
• 3. Task for checking the seat belt status (seat belt
status monitoring task)
• 4. Task for starting and stopping the alarm (alarm
control task)
• 5. Alarm timer task for waiting 5 seconds (alarm timer
task)
Concurrent/Communicating Process
Model (continued)
• The tasks cannot be executed randomly or
sequentially.
• We need to synchronise their execution
through some mechanism.
• For example, 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.
• We will use events to indicate these scenarios.
•
Compiler phases
– Front end (3 phases)
– back end Dr.K.Ragavan, SCOPE, VIT Vellore 5
Dr.K.Ragavan, SCOPE, VIT Vellore 6
Compile Time Evaluation
• we optimize the code at the compile time – two techniques
– constant folding
– constant propogation
• Constant Folding – technique of evaluating an expression whose
operands are known to be constants at compile time itself
Example: Length = (22/7)*d
• Above 22/7 is a constant expression
• So first solve the constant expression before and keep the
constant value – so called folding the constant and place the value
at compile time since evaluated at compile time and keep the
value of reuse
Dr.K.Ragavan, SCOPE, VIT Vellore 7
Dr.K.Ragavan, SCOPE, VIT Vellore 8
Example – finding area of circle
c = 7;
k = 0;
for (i = 0; i < N; i++)
{
y[i] = k;
k = k + c;
} Dr.K.Ragavan, SCOPE, VIT Vellore 15
Loop Optimization
Loops are important targets for optimization
because programs with loops tend to spend a
lot of time executing those loops.
There are three important techniques in
optimizing loops:
Code motion
Induction variable elimination
Strength reduction.
Dr.K.Ragavan, SCOPE, VIT Vellore 16
Code motion lets us move unnecessary code out of
a loop.
Consider the following loop:
for (i = 0; i < N*M; i++)
{
z[i] = a[i] + b[i];
}
We optimize the
code in inner loop
Dr.K.Ragavan, SCOPE, VIT Vellore
17
An induction variable is a variable whose
value is derived from the loop iteration
variable’s value.