Model-level debugging: a bridge between control engineering and software engineering

February 01, 2018 // By S. Tucker Taft
A "model-level" debugger is a debugger that can provide a side-by-side view of a simulation model of a control system (for example defined using Simulink) with the source code produced by an automatic code generator, and allow the developer to use the model instead of the generated source code for setting breakpoints, viewing and updating signal values, and stepping through execution. 

This is similar to how a "source-level" debugger supports debugging using the source code, freeing the user from worrying about the details of the assembly-level code.


Screen capture of the QGen model-level debugger.

A model-level debugger that is based on an underlying source-level debugger can also be used for testing systems that combine auto-generated and hand-written code, potentially on both the host and on some final target.  Furthermore, presuming a separate simulator for the model, the developer can use such a debugger to perform back-to-back comparisons against signal values logged during simulation, for an individual block, or for a model as a whole, while delving into the details of a particular subsystem as needed.  By displaying the model together with the generated source code, a model-level debugger provides a uniquely productive bridge between control engineering and software engineering.

 

Interacting with a model-level debugger

A model-level debugger lets you monitor and control the execution of code generated from simulation models, either on the host ("Software in the Loop", or SIL) or on an embedded target machine ("Processor in the Loop", or PIL). Such a debugger gives you full control through model-level breakpoints and signal-value displays, helping to connect the software elements to the corresponding modeling elements.

You can combine auto-generated and hand-written code. Both can be debugged together, and a model-level debugger can display the model and its signal values whenever it reaches sections of code that were auto-generated.  If the debugger stops in hand-written code, then only the source code would be displayed.  But if a breakpoint is reached in auto-generated code, then the source code line, and the associated block within the model, can both be displayed.  In effect, model-level debugging keeps the simulation model execution in sync with code execution, by using traceability information built by the automatic code generator.  You can thus analyze the model's behavior while stepping through the generated source code, or even the final assembly code.