A SM can have variables declared at the SM scope ie not within a state which

A sm can have variables declared at the sm scope ie

This preview shows page 8 - 10 out of 13 pages.

A SM can have variables declared at the SM scope (i.e., not within a state), which can be accessed by all actions and conditions of the SM. Variables can be declared for the entire SM, not within each state. The variable is defined for the entire SM and thus the variable keeps its value across ticks. The variable maintains its value until being written again. Variables declared in main() would not be visible to the SM's tick function. The variables can be declared global. Alternatively, the variables could be declared as "static" variables within the tick function (for advanced C programmers; will be introduced in another section). The statements that can appear in actions can include more than just assignment statements. Any C statements can appear, such as if-else statements, loops, and function calls. However, for this material's purposes, “good practice” is to ensure that actions don't wait on an external input value, such as while (!A0) {};. Waiting behavior should be captured as states and transitions so that all time-ordered behavior is visible at the transition level. Also, a state with actions that wait could cause the SM to violate the basic assumption that SM ticks occur faster than events so that no events are missed. The statement while (A0) {...} should not appear in a state's actions. The statement will execute if A0 is 1, meaning the actions wait on an external input. Any such waiting should be done using transitions, e.g., a transition with condition A0, pointing back to the state. The statement if (A0) {...} should not appear in a state's actions. The statement does not wait on input so is fine. A state's actions may include a function call. If the function does not wait on an input, a function call is no different than just a written-out sequence of statements. A state's actions may include a for loop. If the loop does not wait on an input, a for loop is no different than just a written-out sequence of statements. Conditions in an SM should be C expressions. The following rule is important:
Image of page 8

Subscribe to view the full document.

HW2Z2 EEL 4730 RVC Name: Tristan S. Shadd-Simmons ID: 6169148 1. Exactly one—no more, no fewer—of a state's exiting transitions should have a condition that evaluates to true at a given time. In this way, the next state for each tick is precisely and clearly defined. A “common error” is to create transitions leaving a state whose conditions are not mutually exclusive, like one transition with condition A0 and another with condition A1, both of which could be true simultaneously. Another “common error” is to create transitions such that sometimes no transition has a true condition, like one transition with condition A0 and another with condition !A0 && A1, which fail to cover the situation ! A0 && !A1. Technically, neither situation is an error. In the first case, the SM becomes non-deterministic, because the model does not define which of two true transitions will be taken. In the second case, the SM will implicitly take a transition back to the same state, but explicit transitions are preferable for clarity.
Image of page 9
Image of page 10
  • Fall '13

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern

Ask Expert Tutors You can ask 0 bonus questions You can ask 0 questions (0 expire soon) You can ask 0 questions (will expire )
Answers in as fast as 15 minutes