SlideShare a Scribd company logo
1 of 31
Download to read offline
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
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
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.
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
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
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
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
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
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
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
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
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
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
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.
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.
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
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
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
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
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
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
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.
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.
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
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.
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
2008 Chapter-6 L5: "Embedded Systems - Architecture, Programming
and Design" , Raj Kamal, Publs.: McGraw-Hill, Inc.
27
SummarySummary
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
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.
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.
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

More Related Content

Similar to Chap 6 lesson5emsysnewstatemachinefsm

[Capella Day 2019] Model execution and system simulation in Capella
[Capella Day 2019] Model execution and system simulation in Capella[Capella Day 2019] Model execution and system simulation in Capella
[Capella Day 2019] Model execution and system simulation in CapellaObeo
 
Model Execution and System Simulation
Model Execution and System SimulationModel Execution and System Simulation
Model Execution and System SimulationObeo
 
Chap01 lesson 9emsys
Chap01 lesson 9emsysChap01 lesson 9emsys
Chap01 lesson 9emsysVarun Mishra
 
Chap 01 lesson_2emsys
Chap 01 lesson_2emsysChap 01 lesson_2emsys
Chap 01 lesson_2emsysarunsaras08
 
Simulation with Python and MATLAB® in Capella
Simulation with Python and MATLAB® in CapellaSimulation with Python and MATLAB® in Capella
Simulation with Python and MATLAB® in CapellaObeo
 
Rejunevating software reengineering processes
Rejunevating software reengineering processesRejunevating software reengineering processes
Rejunevating software reengineering processesmanishthaper
 
Chap_6Lesson02Emsys3EInterruptBasedIOs.pdf
Chap_6Lesson02Emsys3EInterruptBasedIOs.pdfChap_6Lesson02Emsys3EInterruptBasedIOs.pdf
Chap_6Lesson02Emsys3EInterruptBasedIOs.pdfMAHESHV559910
 
MANAGING AND ANALYSING SOFTWARE PRODUCT LINE REQUIREMENTS
MANAGING AND ANALYSING SOFTWARE PRODUCT LINE REQUIREMENTSMANAGING AND ANALYSING SOFTWARE PRODUCT LINE REQUIREMENTS
MANAGING AND ANALYSING SOFTWARE PRODUCT LINE REQUIREMENTSijseajournal
 
Traffic Simulator
Traffic SimulatorTraffic Simulator
Traffic Simulatorgystell
 
Advanced Production Accounting
Advanced Production AccountingAdvanced Production Accounting
Advanced Production AccountingAlkis Vazacopoulos
 
Chap_9Lesson02Emsys3ETaskandTaskStates.pdf
Chap_9Lesson02Emsys3ETaskandTaskStates.pdfChap_9Lesson02Emsys3ETaskandTaskStates.pdf
Chap_9Lesson02Emsys3ETaskandTaskStates.pdfSenthilKumarP45
 
Design the implementation of CDEx Robust DC Motor.
Design the implementation of CDEx Robust DC Motor.Design the implementation of CDEx Robust DC Motor.
Design the implementation of CDEx Robust DC Motor.Ankita Tiwari
 
CONCEPT OF OPERATIONS TO SYSTEM DESIGN AND DEVELOPMENT-AN INTEGRATED SYSTEM F...
CONCEPT OF OPERATIONS TO SYSTEM DESIGN AND DEVELOPMENT-AN INTEGRATED SYSTEM F...CONCEPT OF OPERATIONS TO SYSTEM DESIGN AND DEVELOPMENT-AN INTEGRATED SYSTEM F...
CONCEPT OF OPERATIONS TO SYSTEM DESIGN AND DEVELOPMENT-AN INTEGRATED SYSTEM F...ijcisjournal
 
Unity3D Scripting: State Machine
Unity3D Scripting: State MachineUnity3D Scripting: State Machine
Unity3D Scripting: State MachineSperasoft
 
MODELLING, ANALYSIS AND SIMULATION OF DYNAMIC SYSTEMS USING CONTROL TECHNIQUE...
MODELLING, ANALYSIS AND SIMULATION OF DYNAMIC SYSTEMS USING CONTROL TECHNIQUE...MODELLING, ANALYSIS AND SIMULATION OF DYNAMIC SYSTEMS USING CONTROL TECHNIQUE...
MODELLING, ANALYSIS AND SIMULATION OF DYNAMIC SYSTEMS USING CONTROL TECHNIQUE...shivamverma394
 

Similar to Chap 6 lesson5emsysnewstatemachinefsm (20)

[Capella Day 2019] Model execution and system simulation in Capella
[Capella Day 2019] Model execution and system simulation in Capella[Capella Day 2019] Model execution and system simulation in Capella
[Capella Day 2019] Model execution and system simulation in Capella
 
Model Execution and System Simulation
Model Execution and System SimulationModel Execution and System Simulation
Model Execution and System Simulation
 
Chap01 lesson 9emsys
Chap01 lesson 9emsysChap01 lesson 9emsys
Chap01 lesson 9emsys
 
Sadcw 6e chapter5
Sadcw 6e chapter5Sadcw 6e chapter5
Sadcw 6e chapter5
 
New Features in QP5
New Features in QP5New Features in QP5
New Features in QP5
 
Chap 01 lesson_2emsys
Chap 01 lesson_2emsysChap 01 lesson_2emsys
Chap 01 lesson_2emsys
 
Simulation with Python and MATLAB® in Capella
Simulation with Python and MATLAB® in CapellaSimulation with Python and MATLAB® in Capella
Simulation with Python and MATLAB® in Capella
 
Rejunevating software reengineering processes
Rejunevating software reengineering processesRejunevating software reengineering processes
Rejunevating software reengineering processes
 
Chap_6Lesson02Emsys3EInterruptBasedIOs.pdf
Chap_6Lesson02Emsys3EInterruptBasedIOs.pdfChap_6Lesson02Emsys3EInterruptBasedIOs.pdf
Chap_6Lesson02Emsys3EInterruptBasedIOs.pdf
 
MANAGING AND ANALYSING SOFTWARE PRODUCT LINE REQUIREMENTS
MANAGING AND ANALYSING SOFTWARE PRODUCT LINE REQUIREMENTSMANAGING AND ANALYSING SOFTWARE PRODUCT LINE REQUIREMENTS
MANAGING AND ANALYSING SOFTWARE PRODUCT LINE REQUIREMENTS
 
Traffic Simulator
Traffic SimulatorTraffic Simulator
Traffic Simulator
 
Advanced Production Accounting
Advanced Production AccountingAdvanced Production Accounting
Advanced Production Accounting
 
Presentation Of Mbt Tools
Presentation Of Mbt ToolsPresentation Of Mbt Tools
Presentation Of Mbt Tools
 
Ch1
Ch1Ch1
Ch1
 
Chap_9Lesson02Emsys3ETaskandTaskStates.pdf
Chap_9Lesson02Emsys3ETaskandTaskStates.pdfChap_9Lesson02Emsys3ETaskandTaskStates.pdf
Chap_9Lesson02Emsys3ETaskandTaskStates.pdf
 
Design the implementation of CDEx Robust DC Motor.
Design the implementation of CDEx Robust DC Motor.Design the implementation of CDEx Robust DC Motor.
Design the implementation of CDEx Robust DC Motor.
 
Pr full uml
Pr full umlPr full uml
Pr full uml
 
CONCEPT OF OPERATIONS TO SYSTEM DESIGN AND DEVELOPMENT-AN INTEGRATED SYSTEM F...
CONCEPT OF OPERATIONS TO SYSTEM DESIGN AND DEVELOPMENT-AN INTEGRATED SYSTEM F...CONCEPT OF OPERATIONS TO SYSTEM DESIGN AND DEVELOPMENT-AN INTEGRATED SYSTEM F...
CONCEPT OF OPERATIONS TO SYSTEM DESIGN AND DEVELOPMENT-AN INTEGRATED SYSTEM F...
 
Unity3D Scripting: State Machine
Unity3D Scripting: State MachineUnity3D Scripting: State Machine
Unity3D Scripting: State Machine
 
MODELLING, ANALYSIS AND SIMULATION OF DYNAMIC SYSTEMS USING CONTROL TECHNIQUE...
MODELLING, ANALYSIS AND SIMULATION OF DYNAMIC SYSTEMS USING CONTROL TECHNIQUE...MODELLING, ANALYSIS AND SIMULATION OF DYNAMIC SYSTEMS USING CONTROL TECHNIQUE...
MODELLING, ANALYSIS AND SIMULATION OF DYNAMIC SYSTEMS USING CONTROL TECHNIQUE...
 

Recently uploaded

Extrusion Processes and Their Limitations
Extrusion Processes and Their LimitationsExtrusion Processes and Their Limitations
Extrusion Processes and Their Limitations120cr0395
 
Booking open Available Pune Call Girls Koregaon Park 6297143586 Call Hot Ind...
Booking open Available Pune Call Girls Koregaon Park  6297143586 Call Hot Ind...Booking open Available Pune Call Girls Koregaon Park  6297143586 Call Hot Ind...
Booking open Available Pune Call Girls Koregaon Park 6297143586 Call Hot Ind...Call Girls in Nagpur High Profile
 
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...ranjana rawat
 
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escortsranjana rawat
 
HARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IVHARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IVRajaP95
 
Processing & Properties of Floor and Wall Tiles.pptx
Processing & Properties of Floor and Wall Tiles.pptxProcessing & Properties of Floor and Wall Tiles.pptx
Processing & Properties of Floor and Wall Tiles.pptxpranjaldaimarysona
 
Software Development Life Cycle By Team Orange (Dept. of Pharmacy)
Software Development Life Cycle By  Team Orange (Dept. of Pharmacy)Software Development Life Cycle By  Team Orange (Dept. of Pharmacy)
Software Development Life Cycle By Team Orange (Dept. of Pharmacy)Suman Mia
 
Introduction to Multiple Access Protocol.pptx
Introduction to Multiple Access Protocol.pptxIntroduction to Multiple Access Protocol.pptx
Introduction to Multiple Access Protocol.pptxupamatechverse
 
High Profile Call Girls Dahisar Arpita 9907093804 Independent Escort Service ...
High Profile Call Girls Dahisar Arpita 9907093804 Independent Escort Service ...High Profile Call Girls Dahisar Arpita 9907093804 Independent Escort Service ...
High Profile Call Girls Dahisar Arpita 9907093804 Independent Escort Service ...Call girls in Ahmedabad High profile
 
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICSAPPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICSKurinjimalarL3
 
College Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service NashikCollege Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service NashikCall Girls in Nagpur High Profile
 
the ladakh protest in leh ladakh 2024 sonam wangchuk.pptx
the ladakh protest in leh ladakh 2024 sonam wangchuk.pptxthe ladakh protest in leh ladakh 2024 sonam wangchuk.pptx
the ladakh protest in leh ladakh 2024 sonam wangchuk.pptxhumanexperienceaaa
 
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...Dr.Costas Sachpazis
 
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...Dr.Costas Sachpazis
 
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...Soham Mondal
 
UNIT-III FMM. DIMENSIONAL ANALYSIS
UNIT-III FMM.        DIMENSIONAL ANALYSISUNIT-III FMM.        DIMENSIONAL ANALYSIS
UNIT-III FMM. DIMENSIONAL ANALYSISrknatarajan
 
IMPLICATIONS OF THE ABOVE HOLISTIC UNDERSTANDING OF HARMONY ON PROFESSIONAL E...
IMPLICATIONS OF THE ABOVE HOLISTIC UNDERSTANDING OF HARMONY ON PROFESSIONAL E...IMPLICATIONS OF THE ABOVE HOLISTIC UNDERSTANDING OF HARMONY ON PROFESSIONAL E...
IMPLICATIONS OF THE ABOVE HOLISTIC UNDERSTANDING OF HARMONY ON PROFESSIONAL E...RajaP95
 
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝soniya singh
 

Recently uploaded (20)

Extrusion Processes and Their Limitations
Extrusion Processes and Their LimitationsExtrusion Processes and Their Limitations
Extrusion Processes and Their Limitations
 
Booking open Available Pune Call Girls Koregaon Park 6297143586 Call Hot Ind...
Booking open Available Pune Call Girls Koregaon Park  6297143586 Call Hot Ind...Booking open Available Pune Call Girls Koregaon Park  6297143586 Call Hot Ind...
Booking open Available Pune Call Girls Koregaon Park 6297143586 Call Hot Ind...
 
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
 
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
 
HARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IVHARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IV
 
Processing & Properties of Floor and Wall Tiles.pptx
Processing & Properties of Floor and Wall Tiles.pptxProcessing & Properties of Floor and Wall Tiles.pptx
Processing & Properties of Floor and Wall Tiles.pptx
 
★ CALL US 9953330565 ( HOT Young Call Girls In Badarpur delhi NCR
★ CALL US 9953330565 ( HOT Young Call Girls In Badarpur delhi NCR★ CALL US 9953330565 ( HOT Young Call Girls In Badarpur delhi NCR
★ CALL US 9953330565 ( HOT Young Call Girls In Badarpur delhi NCR
 
Software Development Life Cycle By Team Orange (Dept. of Pharmacy)
Software Development Life Cycle By  Team Orange (Dept. of Pharmacy)Software Development Life Cycle By  Team Orange (Dept. of Pharmacy)
Software Development Life Cycle By Team Orange (Dept. of Pharmacy)
 
Introduction to Multiple Access Protocol.pptx
Introduction to Multiple Access Protocol.pptxIntroduction to Multiple Access Protocol.pptx
Introduction to Multiple Access Protocol.pptx
 
High Profile Call Girls Dahisar Arpita 9907093804 Independent Escort Service ...
High Profile Call Girls Dahisar Arpita 9907093804 Independent Escort Service ...High Profile Call Girls Dahisar Arpita 9907093804 Independent Escort Service ...
High Profile Call Girls Dahisar Arpita 9907093804 Independent Escort Service ...
 
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICSAPPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
 
College Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service NashikCollege Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
 
the ladakh protest in leh ladakh 2024 sonam wangchuk.pptx
the ladakh protest in leh ladakh 2024 sonam wangchuk.pptxthe ladakh protest in leh ladakh 2024 sonam wangchuk.pptx
the ladakh protest in leh ladakh 2024 sonam wangchuk.pptx
 
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
 
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
 
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
 
UNIT-III FMM. DIMENSIONAL ANALYSIS
UNIT-III FMM.        DIMENSIONAL ANALYSISUNIT-III FMM.        DIMENSIONAL ANALYSIS
UNIT-III FMM. DIMENSIONAL ANALYSIS
 
IMPLICATIONS OF THE ABOVE HOLISTIC UNDERSTANDING OF HARMONY ON PROFESSIONAL E...
IMPLICATIONS OF THE ABOVE HOLISTIC UNDERSTANDING OF HARMONY ON PROFESSIONAL E...IMPLICATIONS OF THE ABOVE HOLISTIC UNDERSTANDING OF HARMONY ON PROFESSIONAL E...
IMPLICATIONS OF THE ABOVE HOLISTIC UNDERSTANDING OF HARMONY ON PROFESSIONAL E...
 
Call Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCR
Call Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCRCall Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCR
Call Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCR
 
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝
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