Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝
Chap 6 lesson5emsysnewstatemachinefsm
1. 2008 Chapter-6 L5: "Embedded Systems - Architecture, Programming
and Design" , Raj Kamal, Publs.: McGraw-Hill, Inc.
1
Program Modeling Concepts:
Lesson-5: STATE MACHINE
PROGRAMMING MODELS
FOR EVENT CONTROLLED
PROGRAMS
2. 2008 Chapter-6 L5: "Embedded Systems - Architecture, Programming
and Design" , Raj Kamal, Publs.: McGraw-Hill, Inc.
2
State machine modelState machine model
Assumed that there are states and state
transition functions, which produce the
states.
A state transition function is a function,
which changes a state to its next state
3. 2008 Chapter-6 L5: "Embedded Systems - Architecture, Programming
and Design" , Raj Kamal, Publs.: McGraw-Hill, Inc.
3
Examples of StatesExamples of States
Three states in a washing machine:
‘Washing, ‘Rinsing and Drying,
A telephone process five states:
Idle, Receiving a ring, Dialing,
Connected and Exchanging
messages.
4. 2008 Chapter-6 L5: "Embedded Systems - Architecture, Programming
and Design" , Raj Kamal, Publs.: McGraw-Hill, Inc.
4
• States of a process (function or
interrupt service routine (ISR) or
task: Idle, Running, Blocked,
Finished
Examples of StatesExamples of States
5. 2008 Chapter-6 L5: "Embedded Systems - Architecture, Programming
and Design" , Raj Kamal, Publs.: McGraw-Hill, Inc.
5
• When there are inputs to a process
that change the state of the process
to a new state, and generate outputs
which may also be the inputs for
the next state.
A process modeled using theA process modeled using the
statesstates
6. 2008 Chapter-6 L5: "Embedded Systems - Architecture, Programming
and Design" , Raj Kamal, Publs.: McGraw-Hill, Inc.
6
Programming Model for an EventProgramming Model for an Event
Controlled or Response ControlledControlled or Response Controlled
ProgramsPrograms
• A programming model is to assume
that the running process (program
flow) can be considered as running of
a machine in a particular state, which
will lead to other states. or thread on
an event(s) resulting into state
transition
7. 2008 Chapter-6 L5: "Embedded Systems - Architecture, Programming
and Design" , Raj Kamal, Publs.: McGraw-Hill, Inc.
7
A program flow in system can be
modeled simply by an inter-state
transition (from one state to
another).
or thread)
State machine modelState machine model
8. 2008 Chapter-6 L5: "Embedded Systems - Architecture, Programming
and Design" , Raj Kamal, Publs.: McGraw-Hill, Inc.
8
The steps to model and represent the
states and inter-state transitions are as
follows:
1) A transition to a new state occurs
from the previous state on an event
(input). The event may be setting a
value of certain parameter or the result
of the execution of certain codes.
Steps in Modeling as State machineSteps in Modeling as State machine
9. 2008 Chapter-6 L5: "Embedded Systems - Architecture, Programming
and Design" , Raj Kamal, Publs.: McGraw-Hill, Inc.
9
2) A transition may be also be
interrupt flag driven (after a flag
sets) or semaphore driven or
interrupt-source servicing need
driven.
Steps in Modeling as State machineSteps in Modeling as State machine
10. 2008 Chapter-6 L5: "Embedded Systems - Architecture, Programming
and Design" , Raj Kamal, Publs.: McGraw-Hill, Inc.
10
3) A state is identified by a flag
condition or set of codes being
executed or set of values of
certain parameters.
Steps in Modeling as State machineSteps in Modeling as State machine
11. 2008 Chapter-6 L5: "Embedded Systems - Architecture, Programming
and Design" , Raj Kamal, Publs.: McGraw-Hill, Inc.
11
4) A state can receive multiple
tokens (inputs, messages, flags
interrupts or semaphores) from
another state (s). [A token (event) is
a general term that means either an
input or event-input.]
Steps in Modeling as State machineSteps in Modeling as State machine
12. 2008 Chapter-6 L5: "Embedded Systems - Architecture, Programming
and Design" , Raj Kamal, Publs.: McGraw-Hill, Inc.
12
• An event-input characteristic is
that it is asynchronous (one
never knows the instance when
an event may happen). An
event-input may be the setting
or resetting of a flag.
Steps in Modeling as State machineSteps in Modeling as State machine
13. 2008 Chapter-6 L5: "Embedded Systems - Architecture, Programming
and Design" , Raj Kamal, Publs.: McGraw-Hill, Inc.
13
5) A state can generate multiple
tokens (outputs, messages, flags
interrupts or semaphores)
Steps in Modeling as State machineSteps in Modeling as State machine
14. 2008 Chapter-6 L5: "Embedded Systems - Architecture, Programming
and Design" , Raj Kamal, Publs.: McGraw-Hill, Inc.
14
Finite State Machine (FSM) Model forFinite State Machine (FSM) Model for
Event Controlled or Response ControlledEvent Controlled or Response Controlled
ProgramsPrograms
In FSM model:
A circle represents a state of a
program
A directed arc (or an arrow)
represent the program flow from a
state to another.
15. 2008 Chapter-6 L5: "Embedded Systems - Architecture, Programming
and Design" , Raj Kamal, Publs.: McGraw-Hill, Inc.
15
Modeling a process as finite stateModeling a process as finite state
machine (FSM)machine (FSM),,
Followings specified for each state
The state is one of a finite number of states.
Finite set of inputs (tokens or event-flags or status
flags) with their values for the state.
Finite actions (for example computations) during
the state and finite set of outputs with their
possible values (or tokens or event-flags or status
flags) and an output (action) function for the state
that give the outputs.
State transition function for each state to take it to
the next state.
16. 2008 Chapter-6 L5: "Embedded Systems - Architecture, Programming
and Design" , Raj Kamal, Publs.: McGraw-Hill, Inc.
16
FSM model for the timer statesFSM model for the timer states
17. 2008 Chapter-6 L5: "Embedded Systems - Architecture, Programming
and Design" , Raj Kamal, Publs.: McGraw-Hill, Inc.
17
FSM model for a ‘C’ FunctionFSM model for a ‘C’ Function
18. 2008 Chapter-6 L5: "Embedded Systems - Architecture, Programming
and Design" , Raj Kamal, Publs.: McGraw-Hill, Inc.
18
FSM model for an ISRFSM model for an ISR
19. 2008 Chapter-6 L5: "Embedded Systems - Architecture, Programming
and Design" , Raj Kamal, Publs.: McGraw-Hill, Inc.
19
FSM model for a Task in a MultitaskingFSM model for a Task in a Multitasking
SystemSystem
20. 2008 Chapter-6 L5: "Embedded Systems - Architecture, Programming
and Design" , Raj Kamal, Publs.: McGraw-Hill, Inc.
20
FSM states in a program model of an ACVMFSM states in a program model of an ACVM
task for
read_coins ( );
Task deliver_chocolate
( );
signal input
task
display_thanks
( );};
Signal deliver Signal
display
→Arrows show state transition to next
state on a software interrupt signal for
the transition
task
get_user_input
( );
User interrupt
21. 2008 Chapter-6 L5: "Embedded Systems - Architecture, Programming
and Design" , Raj Kamal, Publs.: McGraw-Hill, Inc.
21
Moore and Mealy ModelsMoore and Mealy Models
• A set of outputs represents a state in Moore
model
• A set of outputs represents a state-transition
in Mealy model
22. 2008 Chapter-6 L5: "Embedded Systems - Architecture, Programming
and Design" , Raj Kamal, Publs.: McGraw-Hill, Inc.
22
Moore ModelMoore Model
A flag indicating sate condition or a set of
codes being executed or a set of values of
certain parameters identifies a next state
on mapping the inputs, variables and
previous states using the next-state
transition function.
23. 2008 Chapter-6 L5: "Embedded Systems - Architecture, Programming
and Design" , Raj Kamal, Publs.: McGraw-Hill, Inc.
23
Mealy ModelMealy Model
A state can generate multiple tokens
(outputs, messages, flags interrupts or
semaphores). An output or set of outputs
and variables identifies a next state on
mapping the inputs, variables and previous
states using the output-state transition
(action) function.
24. 2008 Chapter-6 L5: "Embedded Systems - Architecture, Programming
and Design" , Raj Kamal, Publs.: McGraw-Hill, Inc.
24
FSMFSM
When there is only one directed
incoming arc and one outgoing arc
at a state
25. 2008 Chapter-6 L5: "Embedded Systems - Architecture, Programming
and Design" , Raj Kamal, Publs.: McGraw-Hill, Inc.
25
FSMFSM
(1) A state from a process flow in
FSM can lead to any one of the
several possible subsequent states.
This will depend on the output
function and state transition
function at the state.
26. 2008 Chapter-6 L5: "Embedded Systems - Architecture, Programming
and Design" , Raj Kamal, Publs.: McGraw-Hill, Inc.
26
(2)There can be several directed
graphs from a state. But there can
only be one directed graph towards
a state from one definite state.
FSMFSM
27. 2008 Chapter-6 L5: "Embedded Systems - Architecture, Programming
and Design" , Raj Kamal, Publs.: McGraw-Hill, Inc.
27
SummarySummary
28. 2008 Chapter-6 L5: "Embedded Systems - Architecture, Programming
and Design" , Raj Kamal, Publs.: McGraw-Hill, Inc.
28
We learnt
• Program modeling for real time (event
controlled or response time
constrained) programs can be done by
the Finite State Machine(s) model
29. 2008 Chapter-6 L5: "Embedded Systems - Architecture, Programming
and Design" , Raj Kamal, Publs.: McGraw-Hill, Inc.
29
We learntWe learnt
A finite state machine model assumes the
finite number of states and reduces the
programming tasks to the following. (i)
Coding for each state transition function
and each output function (ii) Knowing the
time periods taken by the process at each
state transition function and between each
state, when programming for real time.
30. 2008 Chapter-6 L5: "Embedded Systems - Architecture, Programming
and Design" , Raj Kamal, Publs.: McGraw-Hill, Inc.
30
We learnt
(ii) The FSM model is appropriate
for one process at a time, for the
sequential flows from one state to
the next state, and for a controlled
flow of the program. The FSM is
found to easily model the states in
processes in real time systems.
31. 2008 Chapter-6 L5: "Embedded Systems - Architecture, Programming
and Design" , Raj Kamal, Publs.: McGraw-Hill, Inc.
31
End of Lesson 5 of Chapter 6End of Lesson 5 of Chapter 6