CSCI1600: Embedded and Real Time Software Lecture 11: Modeling IV: Compositions of State Machines Steven Reiss, Fall 2017 Hand out digital watch statechart Without the introductory discussion of the circuit, this lecture would have run short. Might want to look at some of the material in the text and see if it can augment the lecture.
Modeling Tasks We can model individual tasks using FSMs Extended FSMs, Timed automata, Peroidic automata … Hybrid automata to reflect state of outside world This is sufficient for coding We need to model the overall application In order to prove properties of the system In order to understand overall system behavior What was in chapter 5? Lecture 12: Modeling Compositions 12/2/2018
Digital Watch Lots of features Four buttons for input How does it work? How would you model it? Lecture 12: Modeling Compositions 12/2/2018
Statecharts Here is one model Lets look at it in detail Understand what it means Map to a single FSM How many think they could explain/understand this? Lecture 12: Modeling Compositions 12/2/2018
Example : Concurrent Machines This diagram is not readable. Replace Lecture 12: Modeling Compositions 12/2/2018
Example: Concurrency Lecture 12: Modeling Compositions 12/2/2018
Example: Concurrency Lecture 12: Modeling Compositions 12/2/2018
Example : Communicating Tasks Lecture 12: Modeling Compositions 12/2/2018
Example: Hierarchical Lecture 12: Modeling Compositions 12/2/2018
Example: Hierarchical Lecture 12: Modeling Compositions 12/2/2018
Example: Hierarchical Lecture 12: Modeling Compositions 12/2/2018
Microwave Oven Lecture 12: Modeling Compositions 12/2/2018
Digital Watch Can you understand this now? Lecture 12: Modeling Compositions 12/2/2018
Example Tic-Tac-Toe NIM Lecture 12: Modeling Compositions 12/2/2018
Implementing a Statechart Handling concurrency The FSM is in multiple states What does this mean formally (single FSA) What does this mean in a statechart What do you do with an input How is this implemented What if the results are contradictory (set x = 1, set x = 0) What does this mean for your implementation Lecture 12: Modeling Compositions 12/2/2018
Mapping to Code Direct sequential coding Explicit state variables Determine state from various conditions Act accordingly Allows common operations for multiple states Explicit state variables switch (state) { … } Table-driven Approximate the state machine Lecture 12: Modeling Compositions 12/2/2018
Homework Read and Prepare for IO Lab Read 6.1, 6.2, 6.4 Exercise 6.7 Lecture 12: Modeling Compositions 12/2/2018