HW2Z2 EEL 4730 RVC Name Tristan S Shadd Simmons ID 6169148 The RIBS Riverside

Hw2z2 eel 4730 rvc name tristan s shadd simmons id

This preview shows page 7 - 9 out of 13 pages.

HW2Z2 EEL 4730 RVC Name: Tristan S. Shadd-Simmons ID: 6169148 The RIBS (Riverside-Irvine Builder of State machines) tool supports graphical state diagram capture of an SM. A user can insert states and insert transitions between states. The user can click on a state and write C code for that state's actions (in the text box on the right). Likewise, the user can click on a transition and write C conditions (bottomright text box). The SM begins by transitioning to an initial state from the initial “black dot”. Pressing "Generate C" automatically generates C code for RIMS. Pressing "RIMS Simulation" automatically starts RIMS and runs the generated C code on RIMS, where the user can set input switches and observe output LEDs, while RIBS highlights the currently-executing state. RIBS draw a user’s inserted as a circle, a circle is a widely-used shape for a state. The user clicks on the start state first, then the end state. A transition is then drawn graphically to point from the start to end state. While that method is reasonable, RIBS instead has the user check a box indicating a state is the initial state. Most microcontrollers have C compilers, not SM compilers. So to be practical, RIBS first translates to C, after which a C compiler converts to machine code for a microcontroller. Because microprocessors typically have C compilers but not SM compilers, implementing an SM in C is necessary. Using a standard method for implementing an SM to C enhances the readability and correctness of the resulting C code. The tick function reflects the SM model of a tick: A tick takes a true transition from the current state to a new current state “first switch statement”, then executes that new current state's actions once as the “second switch statement”. The LT_SMStart tells the tick function to execute the special one-sided transition from nothing to the initial state of the SM. Each case is for transitions leaving a particular state. Unlit has two transitions leaving the state, one with condition !A0 going back to state Unlit, and one with condition A0 going to state Lit. A SM should be created to have exactly one true transition at any given time, never more. If so, then an if-else statement or multiple if statements would yield the same result. if-else is slightly more efficient because once a true transition is found, the remaining transitions need not be checked. The state could be omitted, but such omission is bad practice. Did the programmer intend for no actions, or did the programmer merely forget to include that state? In fact, a wise programmer might add some form of error indication in the default case of the second switch statement, to catch a missing state. In contrast, the break statements must appear to cause a jump to the switch's end, else execution "falls through" to the next case.
Image of page 7

Subscribe to view the full document.

HW2Z2 EEL 4730 RVC Name: Tristan S. Shadd-Simmons ID: 6169148 Omitting a break statement in a switch statement is a common C programming error.
Image of page 8
Image of page 9
  • 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