Hello Seongjoo,
(Sorry if this does not fully answer your question, as I used Google Translate)
Verifying your model can significantly reduce the number of bugs you detect in the code, but it does not necessarily remove them. This is why it is important to verify the code even after verifying the model.
Some examples of why it is necessary to test the code are:
- Your code uses different libraries, for example Math libraries on an embedded processor.
- You combine the auto-generated code with some hand-written code.
- You have certain "rules" in your model such that you use entirely different code depending on simulation or code.(For example, coder.target in MATLAB Function blocks)
- You are customizing the code generation process and using your own style of code that may introduce additional bugs.
Besides the above, you can use Software-in-the-loop (SIL), Processor-in-the-loop (PIL), or Hardware-in-the-loop (HIL) modes to test your code inside Simulink. This lets you use the same test vectors for both simulation and code, so this also helps reduce work.
In general, it is good to work on the model until it is in a good state. Once this is the case, you generate code and check that the model and code behave the same (or as expected).
Best,
Sebastian
