Stateflow User's Guide Previous page   Next Page

Debugging a Truth Table During Simulation

The last step in developing the truth table model is to test it during a simulated run. In Specifying a Breakpoint for the Call to a Truth Table, you set a function call breakpoint for the truth table ttable. This pauses execution during simulation so that you can debug each execution step of a truth table using the Stateflow Debugger.

Simulate and debug the individual operation steps of a truth table with the following steps:

  1. Select the Debug button in the Stateflow diagram editor toolbar to start the Stateflow Debugging window as shown.

  2. From the Stateflow Debugging window, select the Start button to begin simulation of your model.
  1. When you simulate your model, Stateflow checks the truth tables automatically for syntactical errors if they have changed since the last simulation. If you receive errors or warnings, make corrections before you try to simulate again.

    If Stateflow finds no syntactical errors in the truth table, Stateflow builds a simulation application and begins the simulation of your model.

  1. Wait until the breakpoint for the call to the truth table is reached.
  1. When this breakpoint is encountered, the truth table ttable appears and the Start button in the Stateflow Debugger changes to the Continue button.

  1. In the Stateflow Debugging window, click the Step button three times to advance simulation through the call to the truth table.
  1. The INIT action of the truth table is highlighted prior to its execution.

  1. Click Step to execute the INIT action and advance truth table execution to the first condition, as shown.

  1. Click Step to evaluate the first condition and advance truth table execution to the second condition.

  2. Click Step to evaluate the second condition and advance truth table execution to the third condition.

  3. Click Step to evaluate the third condition and advance truth table execution to the first decision.

  4. Click Step twice.
  1. Because the first decision is true, truth table execution advances to its action, which is labeled A1.

  1. Click Step three times to execute action A1 and advance to the FINAL action.

  2. In the Stateflow Debugging window, from the Browse Data pull-down, select All Data (Current Chart).
  1. A continuously updated display appears in the bottom pane of the Stateflow Debugging window, as shown.

    You can use this display to monitor Stateflow data during simulation.

  1. In the Stateflow Debugging window, click Step.
  1. This executes the final action and exits the truth table. The Display block in the Simulink window should now display the number 1, as shown.

  1. Change the values of the Constant blocks and continue stepping through the simulation.
  1. For example, you might want to set the Constant1 block to 1 (sets b to 1) and the other Constant blocks to 0 (sets a and c to 0). Or you might want to set all the Constant blocks to 0. To enter a new value for a Constant block, double-click it. In the resulting Block Parameters dialog enter the new value in the Constant value field.


Previous page  Specifying a Breakpoint for the Call to a Truth Table Options for Assigning Actions to Decisions in Truth Tables Next page

© 1994-2005 The MathWorks, Inc.