310 likes | 584 Views
Embedded Systems ECEC 356 – Fall 2014. Chapter 4: Extended State Machines and Hybrid Automata Chapter 5: Composition of machines. Andrew R. Cohen 10/14/2014. Last time - what’s on the test? You tell me… Today - review (1-4, etc) - start chapter 5 - hw3 due - Next time
E N D
Embedded SystemsECEC 356 – Fall 2014 • Chapter 4: Extended State Machines and Hybrid Automata • Chapter 5: Composition of machines Andrew R. Cohen 10/14/2014
Last time • - what’s on the test? You tell me… • Today • - review (1-4, etc) • - start chapter 5 • - hw3 due • - Next time • - exam 1
Example: Mouse Double Click Detector This simple form of hybrid system is called a timed automaton, where the dynamics is just passage of time.
Example: Mouse Double Click Detector • How many states does this automaton have?
Timed automaton model of a traffic light controller This light remains green at least 60 seconds, and then turns yellow if a pedestrian has requested a crossing. It then remains red for 60 seconds.
Example: “Tick” Generator (Timer) • How would you model a timer that generates a ‘tick’ • each time T time units elapses? • A similar timed automaton can model a generator • of a timer interrupt.
Hybrid Automaton for Bouncing Ball • y – vertical distance from ground (position) • a – coefficient of restitution, 0 ·a· 1 • If you plotted y(t), what would it look like?
Hybrid Automaton for Bouncing Ball • y – vertical distance from ground (position) • a – coefficient of restitution, 0 ·a· 1
When do reactions occur in a hybrid automaton? • Reactions are occurring continually, with the continuous state variable x being continually updated.
When do reactions occur in a hybrid automaton? • Suppose x and y are discrete and pure signals. When does the transition occur? • Answer: at the earliest time t when x is absent after entering s1.This will always be the same time when s1 is entered. Why? • If x is absent when s1 is entered, then the transition is taken then.If x is present when s1 is entered, then it will be absent at a timeinfinitesimally larger. How to model this rigorously?
Example: Newton’s Cradle • Image src: Wikipedia Commons • A middle ball does not move, so its momentum must be 0. • But the momentum of the first ball is transferred somehow to the fifth. So there is an instant at which it is non-zero!
Sneak Preview: Super-Dense Time • We will solve this problem by modeling signals as functions of super-dense time: • In this way, x can be present and absent at the same time, with a well-defined order between its presence and absence.
Modeling with State Machines • Questions: • How to represent the system for: • Systematic analysis • So that a computer program can manipulate it • How to model its environment • How to compose subsystems to make bigger systems • How to check whether the system satisfies its specification in its operating environment
Actor Model for State Machines • Expose inputs and outputs, enabling composition:
Composition of State Machines • Side-by-side composition • Cascade composition • Feedback composition
Side-by-Side Composition A key question: When do these machines react? Two possibilities: • Together (synchronous composition) • Independently (asynchronous composition)
Note that these two states are not reachable. Synchronous Composition Synchronous composition
Asynchronous composition using interleaving semantics Asynchronous Composition Note that now all states are reachable.
Syntax vs. Semantics Synchronous or Asynchronous composition? If asynchronous, does it allow simultaneous transitions in A & B?
Asynchronous composition is not synchronous composition with stuttering transitions. Stuttering is a reaction where no output is produced and the state is not changed. Synchronous composition These two FSMs cannot stutter. If they react, they change state.
Asynchronous composition is not synchronous composition with stuttering transitions. Stuttering is a reaction where no output is produced and the state is not changed. Asynchronous composition with interleaving semantics These two FSMs cannot stutter. If they react, they change state.
Asynchronous Composition • M1 = (S1, I1, O1, U1, s10) and M2 = (S2, I2, O2, U2, s20) • M is the asynchronous composition of M1 and M2 • = (S1× S2, I1× I2, O1× O2, U, (s10, s20)) • where • U((s1, s2), (i1, i2)) = ((s1’, s2’), (o1, o2)) • and • (s1’, o1) = U1(s1, i1) AND s2’ = s2 & o2 is absent • OR (s2’, o2) = U2(s2, i2) AND s1’ = s1 & o1 is absent (note interleaving semantics)
Cascade Composition A B Output port(s) of A connected to input port(s) of B
Example: Pedestrian Light This light stays green for 55 seconds, then goes red. Upon receiving a sigR input, it repeats the cycle.
Pedestrian Light with Car Light sigY sigG sigR sigR pedG What is the size of the state space of the composite machine? pedR
Homework • Exam 1 – Thursday 10/16/2014 • Chapters 1-4 of L&S, Appendix A • All material from lab • Open book / notes – NO ELECTRONIC DEVICES • Next Week • Chapter 5 – composition of state machines
Instructor Contact Information Andrew R. Cohen Associate Prof. Department of Electrical and Computer Engineering Drexel University 3120 – 40 Market St., Suite 110 Philadelphia, PA 19104 office phone: (215) 571 – 4358 http://bioimage.coe.drexel.edu/courses acohen@coe.drexel.edu