CSCI1600: Embedded and Real Time Software Lecture 12: Modeling IV: Compositions of State Machines Steven Reiss, Fall 2016 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.
Circuit Review Lecture 12: Modeling Compositions 10/31/2019
Modeling Tasks We can model individual tasks using FSMs Extended FSMs, Timed automata, … Hybrid automata to reflect state of outside world This is sufficient for coding We need to model the overall application We need this to prove properties of the system We need this to understand overall system behavior What was in chapter 5? Lecture 12: Modeling Compositions 10/31/2019
Digital Watch Lots of features Four buttons for input How does it work? How would you model it? Lecture 12: Modeling Compositions 10/31/2019
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 10/31/2019
Example : Concurrent Machines This diagram is not readable. Replace Lecture 12: Modeling Compositions 10/31/2019
Example: Concurrency Lecture 12: Modeling Compositions 10/31/2019
Example: Concurrency Lecture 12: Modeling Compositions 10/31/2019
Example : Communicating Tasks Lecture 12: Modeling Compositions 10/31/2019
Example: Hierarchical Lecture 12: Modeling Compositions 10/31/2019
Example: Hierarchical Lecture 12: Modeling Compositions 10/31/2019
Example: Hierarchical Lecture 12: Modeling Compositions 10/31/2019
Microwave Oven Lecture 12: Modeling Compositions 10/31/2019
Digital Watch Can you understand this now? Lecture 12: Modeling Compositions 10/31/2019
Example Tic-Tac-Toe Lecture 12: Modeling Compositions 10/31/2019
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 10/31/2019
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 10/31/2019
Homework Read 6.1, 6.2, 6.4 Exercise 6.7 Lecture 12: Modeling Compositions 10/31/2019