Batch Mode Simulation : Simulating a Truth Table

Simulating a Truth Table

When the model is simulated and active breakpoints are inserted into the truth table, a read-only matrix of the truth table is started. From this table you can view the execution of each element in the table. When a step or microstep is started, depending on the truth table implementation, the “fired” row in the truth table is highlighted for one step.

Input and output logic from a truth table is included in the simulation when the model includes a truth table in its scope. Truth table inputs and outputs are Rational Statemate elements, therefore input values can be set and output values examined using Simulation debugging tools such as Monitors, the Examine command and the DoAction command.

The following sections describe how to insert a breakpoint into a truth table and simulate it.

Note: For additional information on Truth Tables, refer to the Rational Statemate User Guide.

For the purpose of this discussion, we use the Statechart shown below as an example.This Statechart operates as follows:

When C2 is true and C5, C10 are false, VAL_OUT is assigned to two times VAL_IN.
When C5 is true and C2, C10 are false, VAL_OUT is assigned to five times VAL_OUT.
When C10 is true and C2, C5 are false, VAL_OUT is assigned to 10 times VAL_IN.

The actual logic that implements this functionality is contained in the truth table which implements the function CALC1.

The elements for this Statechart need to be defined in the Data Dictionary as follows:

1.
Define C10, C2, C5 as a condition
2.
Define CALC1 as a subroutine
3.
Define E1 as an event
4.
Define VAL_IN and VAL_OUT as data-items

After defining the elements in the Data Dictionary for the sample Statechart, execute the Data Dictionary page for CALC1.

You can see in the Data Dictionary page above for the function CALC1, how the parameter table is filled. Note that the order of the parameters in the Statechart matches those in the parameter list. When these actual model parameters match with the formal parameters in the parameter list, VAL_IN is passed to X_DATA, VAL_OUT is passed to Y_DATA and the condition C2 is passed to multiply-by-two, C5 is passed to multiply-by-5, etc.

Note: The Select Implementation is set to Truth Table
.

To complete this exercise, construct the Truth Table shown above. For additional information on Truth Tables, refer to the Rational Statemate User Guide.