CSCI1600: Embedded and Real Time Software Lecture 7: Modeling II: Discrete Systems Steven Reiss,...
-
Upload
gerard-barton -
Category
Documents
-
view
219 -
download
0
Transcript of CSCI1600: Embedded and Real Time Software Lecture 7: Modeling II: Discrete Systems Steven Reiss,...
![Page 1: CSCI1600: Embedded and Real Time Software Lecture 7: Modeling II: Discrete Systems Steven Reiss, Fall 2015.](https://reader036.fdocuments.net/reader036/viewer/2022062409/5697bfb61a28abf838c9e6cd/html5/thumbnails/1.jpg)
CSCI1600: Embedded and Real Time SoftwareLecture 7: Modeling II: Discrete Systems
Steven Reiss, Fall 2015
![Page 2: CSCI1600: Embedded and Real Time Software Lecture 7: Modeling II: Discrete Systems Steven Reiss, Fall 2015.](https://reader036.fdocuments.net/reader036/viewer/2022062409/5697bfb61a28abf838c9e6cd/html5/thumbnails/2.jpg)
Embedded Systems
Are sets of tasks The task is the primary abstraction to be used
If we want to understand the system We want to model it
Should we model the whole system Or should we just model the individual tasks
![Page 3: CSCI1600: Embedded and Real Time Software Lecture 7: Modeling II: Discrete Systems Steven Reiss, Fall 2015.](https://reader036.fdocuments.net/reader036/viewer/2022062409/5697bfb61a28abf838c9e6cd/html5/thumbnails/3.jpg)
How to Model a Task English description
Typically used first
Imprecise, hard to check, incomplete
Formal mathematics
Very precise
Difficult to understand
Hard to express external events
Formal diagrams
Combine formal math with understanding
Diagrams make it easier to comprehend what is there
Provide a framework for the math and understanding
![Page 4: CSCI1600: Embedded and Real Time Software Lecture 7: Modeling II: Discrete Systems Steven Reiss, Fall 2015.](https://reader036.fdocuments.net/reader036/viewer/2022062409/5697bfb61a28abf838c9e6cd/html5/thumbnails/4.jpg)
Modeling Control Systems
Control oriented systems Typically respond to external stimuli
Reaction based on previous interactions These determine the state of the system
Stimulus moves system to a new state Control is state-oriented
Natural model is finite state automata
![Page 5: CSCI1600: Embedded and Real Time Software Lecture 7: Modeling II: Discrete Systems Steven Reiss, Fall 2015.](https://reader036.fdocuments.net/reader036/viewer/2022062409/5697bfb61a28abf838c9e6cd/html5/thumbnails/5.jpg)
Basic Finite State Automata
![Page 6: CSCI1600: Embedded and Real Time Software Lecture 7: Modeling II: Discrete Systems Steven Reiss, Fall 2015.](https://reader036.fdocuments.net/reader036/viewer/2022062409/5697bfb61a28abf838c9e6cd/html5/thumbnails/6.jpg)
Problem
Want to automatically trigger switch When train goes from R to L
What does sensing look like
What does train look like
When should you trigger the switch
C
D
A B
![Page 7: CSCI1600: Embedded and Real Time Software Lecture 7: Modeling II: Discrete Systems Steven Reiss, Fall 2015.](https://reader036.fdocuments.net/reader036/viewer/2022062409/5697bfb61a28abf838c9e6cd/html5/thumbnails/7.jpg)
Problem
Can only trigger one switch at a time Switch trigger
Should be momentary (>100ms, <500ms)
What does this task do?
How many tasks should it be?
Is it a FSA?
![Page 8: CSCI1600: Embedded and Real Time Software Lecture 7: Modeling II: Discrete Systems Steven Reiss, Fall 2015.](https://reader036.fdocuments.net/reader036/viewer/2022062409/5697bfb61a28abf838c9e6cd/html5/thumbnails/8.jpg)
Problem
Problem: when is the train on which block When is train completely on A/C or B or D side of switch
Handling initial conditions
Handling reversing directions
C
D
A B
![Page 9: CSCI1600: Embedded and Real Time Software Lecture 7: Modeling II: Discrete Systems Steven Reiss, Fall 2015.](https://reader036.fdocuments.net/reader036/viewer/2022062409/5697bfb61a28abf838c9e6cd/html5/thumbnails/9.jpg)
Issues with Basic FSA
Need to specify actions
Semi-external events: timers
Internal events from other automata
Conditional events
Multiple FSA’s in parallel
Counters and other variables
State space blowup
![Page 10: CSCI1600: Embedded and Real Time Software Lecture 7: Modeling II: Discrete Systems Steven Reiss, Fall 2015.](https://reader036.fdocuments.net/reader036/viewer/2022062409/5697bfb61a28abf838c9e6cd/html5/thumbnails/10.jpg)
Actions: Moore vs Mealy Machine
![Page 11: CSCI1600: Embedded and Real Time Software Lecture 7: Modeling II: Discrete Systems Steven Reiss, Fall 2015.](https://reader036.fdocuments.net/reader036/viewer/2022062409/5697bfb61a28abf838c9e6cd/html5/thumbnails/11.jpg)
Moore vs. Mealy
Which is more useful?
Are they equivalent?
![Page 12: CSCI1600: Embedded and Real Time Software Lecture 7: Modeling II: Discrete Systems Steven Reiss, Fall 2015.](https://reader036.fdocuments.net/reader036/viewer/2022062409/5697bfb61a28abf838c9e6cd/html5/thumbnails/12.jpg)
Extended State Machines Each arc has condition/action
To traverse arc, condition must hold
When traversing arc, action is taken
There are a finite set of (bounded) variables Conditions can reference these
Condition can be
Event
Time out
Expression over variables
Combination of the two
![Page 13: CSCI1600: Embedded and Real Time Software Lecture 7: Modeling II: Discrete Systems Steven Reiss, Fall 2015.](https://reader036.fdocuments.net/reader036/viewer/2022062409/5697bfb61a28abf838c9e6cd/html5/thumbnails/13.jpg)
Extended State Machines Actions
Can access and change variables
Can be { var = expression; … }
Can do something external
When no condition is true Stay in same state
When multiple conditions are true What should be done
Nondeterminism,
Allow priority specification
![Page 14: CSCI1600: Embedded and Real Time Software Lecture 7: Modeling II: Discrete Systems Steven Reiss, Fall 2015.](https://reader036.fdocuments.net/reader036/viewer/2022062409/5697bfb61a28abf838c9e6cd/html5/thumbnails/14.jpg)
Digital Watch
Four buttons
Chimes, alarms, time, stopwatch, light
How does it work?
Number of states?
Lots of tasks Specifying each
Specifying their interaction
![Page 15: CSCI1600: Embedded and Real Time Software Lecture 7: Modeling II: Discrete Systems Steven Reiss, Fall 2015.](https://reader036.fdocuments.net/reader036/viewer/2022062409/5697bfb61a28abf838c9e6cd/html5/thumbnails/15.jpg)
Statecharts
David Harel (80’s)
Part of UML
Extended FSM notation
![Page 16: CSCI1600: Embedded and Real Time Software Lecture 7: Modeling II: Discrete Systems Steven Reiss, Fall 2015.](https://reader036.fdocuments.net/reader036/viewer/2022062409/5697bfb61a28abf838c9e6cd/html5/thumbnails/16.jpg)
Concurrency
Concurrent FSMs Same box, dashed line
State of overall is cross-product of states
Can have array (n copies)
![Page 17: CSCI1600: Embedded and Real Time Software Lecture 7: Modeling II: Discrete Systems Steven Reiss, Fall 2015.](https://reader036.fdocuments.net/reader036/viewer/2022062409/5697bfb61a28abf838c9e6cd/html5/thumbnails/17.jpg)
Hierarchical Automata
Allow abstraction
Can be used to generalize groups of states
Can be used for clustering
Can have multiple levels
What state to goto inside?
![Page 18: CSCI1600: Embedded and Real Time Software Lecture 7: Modeling II: Discrete Systems Steven Reiss, Fall 2015.](https://reader036.fdocuments.net/reader036/viewer/2022062409/5697bfb61a28abf838c9e6cd/html5/thumbnails/18.jpg)
Start and Stop States
Start states are large dots
Stop states are encircled dots
Hierarchal elements can have internal start states
![Page 19: CSCI1600: Embedded and Real Time Software Lecture 7: Modeling II: Discrete Systems Steven Reiss, Fall 2015.](https://reader036.fdocuments.net/reader036/viewer/2022062409/5697bfb61a28abf838c9e6cd/html5/thumbnails/19.jpg)
History Mechanism
Keep track of state in nested automata
Circled-H is entry point Default entry
Can point to start state
![Page 20: CSCI1600: Embedded and Real Time Software Lecture 7: Modeling II: Discrete Systems Steven Reiss, Fall 2015.](https://reader036.fdocuments.net/reader036/viewer/2022062409/5697bfb61a28abf838c9e6cd/html5/thumbnails/20.jpg)
Delays and Timeouts
Delays cause a state to hold until time has expired time< in state
Timeouts are automatic events <time in state
Separate timeout event
![Page 21: CSCI1600: Embedded and Real Time Software Lecture 7: Modeling II: Discrete Systems Steven Reiss, Fall 2015.](https://reader036.fdocuments.net/reader036/viewer/2022062409/5697bfb61a28abf838c9e6cd/html5/thumbnails/21.jpg)
Homework
Read Chapter 4