The issue you are facing is an expected behavior of SIL simulation.
Consider a model that references a child model using the “Model Block” and we put the child model in SIL mode. The simulation semantics for this modelling pattern are as follows:
- SIL simulation generates code only for the child model.
- The generated code is built into an executable representing the child model.
- The main model communicates with the child model’s executable.
Therefore, in the test-harness for your model, SIL simulation mode generates code for the “component under test” and runs that generated code as an executable that communicates with the test-harness.
However, the data space is not shared between the executable and the harness. Thus, any extern variable that the main-model writes to, and the test-harness reads from, are different.
In other words, global variables from the SIL model are not accessible from the harness.
A possible workaround for this issue is captured below:
You can enable global variables as function interfaces as outlined in the following documentation:
If this option is selected, the variables declared as global in the custom code can be used as global arguments on the block interface and they will appear as a port.
After enabling this feature, verifying that the C Caller blocks are modifying the global variables appropriately can be done in two ways:
- Log the signal and do the verification after the simulation is done running.
- Route that signal to the test-harness to do the verification.