Target Language Compiler    

Fix the Bug and Verify the Fix

The problem we identified is caused by evaluating a constant rather than a variable inside the TLC function FcnEliminateUnnecessaryParams(). This is a typical coding error and is easily repaired. Here is the code we need to fix:

Testing the constant parameter k against 0.0, 1.0, and -1.0 is fine; the problem occurs in the assignment of y to k in the latter two cases:

  1. To fix these coding errors, edit gain.tlc, and make two substitutions:
  1. Now the input variable is copied or negated into the output variable instead of assigning a constant value to the output. Save gain.tlc.

  1. Build the stand-alone model again. Go through the debugging procedure described above to verify that y is correctly assigned inside FcnEliminateUnnecessaryParams. Complete the build by typing continue at each TLC-DEBUG> prompt.
  2. Execute the stand-alone model by typing !simple_log. A new version of simple_log.mat is created containing its output.
  3. Compare the workspace variable rt_yout with yout, as you did before. All values in the first column should now correspond.

For more information about the TLC debugger, see Debugging TLC Files.


  Debug gain.tlc Using TLC Code Coverage to Aid Debugging