Finite State Machines. CS 447 Wireless Embedded Systems

Similar documents
Discrete Dynamics Finite State Machines גרא וייס המחלקה למדעי המחשב אוניברסיטת בן-גוריון

Embedded Real-Time Systems

Cyber-Physical Systems Discrete Dynamics

Embedded Systems 2. REVIEW: Actor models. A system is a function that accepts an input signal and yields an output signal.

Laurea Specialistica in Ingegneria. Ingegneria dell'automazione: Sistemi in Tempo Reale

Introduction to Embedded Systems

Comparing State Machines: Equivalence and Refinement

Introduction to Embedded Systems

State Machines Composition

EECS 144/244: Fundamental Algorithms for System Modeling, Analysis, and Optimization

Model-Based Design. Chapter Modeling Physical Dynamics Newtonian Mechanics

Bridging the Semantic Gap Between Heterogeneous Modeling Formalisms and FMI

Embedded Systems Development

540 IEEE TRANSACTIONS ON AUTOMATIC CONTROL, VOL. 43, NO. 4, APRIL Algorithmic Analysis of Nonlinear Hybrid Systems

Embedded Systems 5. Synchronous Composition. Lee/Seshia Section 6.2

FDST Markov Chain Models

Embedded systems specification and design

Bridging the Semantic Gap Between Heterogeneous Modeling Formalisms and FMI

Lecture 8: Complete Problems for Other Complexity Classes

Symbolic Verification of Hybrid Systems: An Algebraic Approach

Automata-theoretic analysis of hybrid systems

Automata-Theoretic Model Checking of Reactive Systems

Q = Set of states, IE661: Scheduling Theory (Fall 2003) Primer to Complexity Theory Satyaki Ghosh Dastidar

Software Verification

Using the Principles of Synchronous Languages in Discrete-event and Continuous-time Models

MECH 1500 Final Part 2 Review

Outline. Complexity Theory. Example. Sketch of a log-space TM for palindromes. Log-space computations. Example VU , SS 2018

(a) Definition of TMs. First Problem of URMs

Chapter Two: Finite Automata

State Graphs FSMs. Page 1

Time and Schedulability Analysis of Stateflow Models

Sequential Circuits Sequential circuits combinational circuits state gate delay

Lecture 1 From Continuous-Time to Discrete-Time

Let us first give some intuitive idea about a state of a system and state transitions before describing finite automata.

Finite-state machines (FSMs)

Bayes Nets. CS 188: Artificial Intelligence Fall Example: Alarm Network. Bayes Net Semantics. Building the (Entire) Joint. Size of a Bayes Net

Luay H. Tahat Computer Science Department Gulf University for Science & Technology Hawally 32093, Kuwait

An Introduction to Hybrid Systems Modeling

CS 591, Lecture 9 Data Analytics: Theory and Applications Boston University

The algorithmic analysis of hybrid system

EE 144/244: Fundamental Algorithms for System Modeling, Analysis, and Optimization Fall 2016

Computational Complexity of Bayesian Networks

2/18/2019. Position-versus-Time Graphs. Below is a motion diagram, made at 1 frame per minute, of a student walking to school.

Complexity (Pre Lecture)

Deterministic Finite Automata (DFAs)

1 Implicit Differentiation

an efficient procedure for the decision problem. We illustrate this phenomenon for the Satisfiability problem.

Section 7.1: Functions Defined on General Sets

Stochastic Simulation.

Computability Theory. CS215, Lecture 6,

Position-versus-Time Graphs

Formal Methods Engineering Nasreen Iqbal De Montfort University

Turing Machine Variants

Lecture 3. 1 Terminology. 2 Non-Deterministic Space Complexity. Notes on Complexity Theory: Fall 2005 Last updated: September, 2005.

1 Definition of a Turing machine

Part I: Definitions and Properties

Information System Design IT60105

The efficiency of identifying timed automata and the power of clocks

Models of Computation, Recall Register Machines. A register machine (sometimes abbreviated to RM) is specified by:

15-451/651: Design & Analysis of Algorithms September 13, 2018 Lecture #6: Streaming Algorithms last changed: August 30, 2018

Worst-case Throughput Analysis for Parametric Rate and Parametric Actor Execution Time Scenario-Aware Dataflow Graphs. Mladen Skelin.

Bayesian Networks. Vibhav Gogate The University of Texas at Dallas

Let s now begin to formalize our analysis of sequential machines Powerful methods for designing machines for System control Pattern recognition Etc.

SOLVING INEQUALITIES and 9.1.2

Computational Models Lecture 8 1

Outline F eria AADL behavior 1/ 78

Deterministic Finite Automata (DFAs)

Sequential logic and design

Finite State Machines 2

Implicit Differentiation

Digital Logic Design. Midterm #2

CSE 473: Artificial Intelligence Autumn 2011

{},{a},{a,c} {},{c} {c,d}

PHY152H1S Practical 10: Special Relativity

Computational Models Lecture 8 1

Informatics 1 - Computation & Logic: Tutorial 1

Introduction to Computers & Programming

Foundations of Query Languages

Computational Models Lecture 8 1

Relating Voltage, Current and Resistance

Lecture 22: Quantum computational complexity

Solutions. Prelim 2[Solutions]

Computation Theory Finite Automata

EE249 - Fall 2012 Lecture 18: Overview of Concrete Contract Theories. Alberto Sangiovanni-Vincentelli Pierluigi Nuzzo

CS:4330 Theory of Computation Spring Regular Languages. Finite Automata and Regular Expressions. Haniel Barbosa

Turing Machines. Our most powerful model of a computer is the Turing Machine. This is an FA with an infinite tape for storage.

Unit: Blocking Synchronization Clocks, v0.3 Vijay Saraswat

CSC165. Larry Zhang, October 7, 2014

Models for representing sequential circuits

CS 301. Lecture 17 Church Turing thesis. Stephen Checkoway. March 19, 2018

Unit 5: Representations of Linear Relations

Deterministic Finite Automata (DFAs)

1 Deterministic Turing Machines

UNIT-I. Strings, Alphabets, Language and Operations

Overview of Chapter 4

14.1. Unit 14. State Machine Design

Lecture notes on Turing machines

Bayesian Networks. Vibhav Gogate The University of Texas at Dallas

(p == train arrives late) (q == there are taxis) (r == If p and not q, then r. Not r. p. Therefore, q. Propositional Logic

Hybrid systems and computer science a short tutorial

Transcription:

Finite State Machines CS 447 Wireless Embedded Systems

Outline Discrete systems Finite State Machines Transitions Timing Update functions Determinacy and Receptiveness 1

Discrete Systems Operates in sequence of discrete steps Have discrete dynamics E.g., system that counts cars entering / leaving parking garage 2

Discrete Systems Parking garage counter Each entry / departure is a discrete event Occurs at some instant in time, not over time 3

Discrete Systems Parking garage counter model 4

Discrete Systems ArrivalDetector actor Outputs present when car arrival detected DepartureDetector actor Outputs present when car departure detected 5

Discrete Systems Counter actor has two inputs: u & d u: R -> { absent, present } At time t, u(t) either present or absent Known as a pure signal (carries no value, has all info needed) 6

Discrete Systems Counter actor has two inputs: u & d d: R -> { absent, present } At time t, d(t) either present or absent Known as a pure signal (carries no value, has all info needed) 7

Discrete Systems Counter actor: Event present on up input port => increments count, outputs Event present on down port => decrements count, outputs 8

Discrete Systems Counter actor: All other times, i.e., u(t), d(t) absent Count not adjusted Count not outputted 9

Discrete Systems Counter actor output port count c: R -> {absent } Z At time t, c(t) is either absent or an integer 10

Discrete Systems Discrete dynamics can be described as sequence of steps or reactions Each is assumed to be instantaneous Counter is event-triggered Input present events cause Counter to react up present => increment then output count down present => decrement then output count 11

Outline Discrete systems Finite State Machines Transitions Timing Update functions Determinacy and Receptiveness 12

Finite State Machines Have notion of state System s condition at some particular point in time State Machine Models a discrete dynamic system Each reaction maps valuations of inputs to outputs Mapping depends on current state Finite state machine - # states if finite 13

Finite State Machines Few states, draw FSM using graph notation Nodes: states Edges: transitions Start state indicated with dangling edge 14

Outline Discrete systems Finite State Machines Transitions Timing Update functions Determinacy and Receptiveness 15

Transitions Transitions between states governed by discrete dynamics of state machine Map input valuations to output valuations Can go to another state Or stay in same state 16

Transitions E.g., transition from State1 to State2 Labeled guard / action Guard: determines whether transition is taken on a reaction Action: output produced by each reaction 17

Transitions Guard Determines whether transition will be taken on a reaction Predicate (Boolean-value expression) evaluates to true or false When true, transition taken (aka transition enabled) 18

Transitions Action Defines what output(s) are produced by reaction E.g., assignment of values (or absent) to output port No action => implicitly absent Typically defined as name := value 19

FSM for Garage Counter 20

FSM for Garage Counter E.g., up ^ ~down Outputs 1 Moves to state 1 (up present, down absent) ( count := 1 ; count var implicit..) 21

FSM for HVAC System w/ Thermostat Two states: { heating, cooling } 22

FSM for HVAC System w/ Thermostat Setpoint is 20 C Heater on: allow temp to rise to 22 Heater off: allow temp to drop to 18 This is called hysteresis Avoids chattering Heater turning on/off rapidly (when temperature close to setpoint) 23

FSM for HVAC System w/ Thermostat System could be event triggered when temperature provided Or time-triggered updates at regular intervals 24

Outline Discrete systems Finite State Machines Transitions Timing Update functions Determinacy and Receptiveness 25

Timing Nothing constrains when a state machine reacts Talk about this later If input absent and no guard evaluates to true, Machine will stutter In other words: If inputs & outputs absent, FSM does not change state (implicit) 26

Timing In Garage FSM, what happens if counter = 0 and car leaves? It will stay in state 0 (implicit, no transition with ~up ^ down) FSM models should define all possible behaviors! 27

Timing Default transition Sometimes useful to be explicit E.g., in state 0, no transition means stay in state 0 (implicit) Could use a default transition Dashed line Guard is true Not always necessary Enabled if no other transition taken 28

Outline Discrete systems Finite State Machines Transitions Timing Update functions Determinacy and Receptiveness 29

Update Functions Graphical notation for FSM defines specific mathematical model for dynamics of state machine Mathematical notation helpful for larger state machines FSM is five-tuple: < states, inputs, outputs, updates, initial > states: finite set of states inputs: set of input valuations outputs: set of output valuations updates: transitions - (state, input) => (state, output) initial: starting state 30

Update Functions Updates (aka transitions) Maps (state + input) to (state + output) Encodes all transitions, guards, and outputs for FSM 31

Update Functions FSM reacts in sequence s: N -> states s is function that gives FSM state at each n N s(0) is initial state N is number of reactions (natural number) x: y: N -> inputs N -> outputs Input and output valuations at each reaction x(0) initial input valuation y(0) initial output valuation 32

Update Functions Dynamics of state machine (S(n+1), y(n)) = update( s(n), x(n) ) English: current state s(n) and input x(n) yields next state s(n+1) and output y(n) 33

Update Functions Formal FSM model for garage counter states: { 0, 1, 2, M } inputs: up, down, {present, absent} outputs: count, { 0, 1, 2,, M } initial state: 0 transitions: 34

Outline Discrete systems Finite State Machines Transitions Timing Update functions Determinacy and Receptiveness 35

Determinacy and Receptiveness State machines have important properties Determinacy Receptiveness 36

Determinacy and Receptiveness Determinacy State machine is deterministic if, for each state, there is at most one transition enabled by each input value Guards leaving a state must NOT overlap Overlap = non-deterministic Determinate: given same inputs, FSM will always product same outputs NOTE: not ALL determinate state machines are deterministic Why? Give an example? 37

Determinacy and Receptiveness Receptiveness State machine is receptive if, for each state, there is at least one transition possible on each input symbol Receptiveness ensures that state machine is always ready to react to any input Won t get stuck in any state Default transitions can help.. 38

Determinacy and Receptiveness FSM is both determinate and receptive: For every state, there is exactly one transition possible on each input value. This is helpful when designing embedded systems.. 39

Why non-determinism can be problematic flying ejectbuttonpressed / ejectbuttonpressed / do nothing eject pilot 40