Inconsistent Requirement Comments Generation in Generated Code (Simulink Requirement Manager)
37 views (last 30 days)
Show older comments
Dear MathWorks Community,
I am experiencing an issue with inconsistent requirement comment generation in my C/C++ code, and I'm seeking guidance on how to resolve it.
Problem Description: I am using the Simulink App: Requirement Manager to link requirements to my Simulink model. After linking requirements to various model elements, I enabled the "Requirements in block comments" option within the configuration settings, as shown in the attached screenshot. Subsequently, I generated code from the model.
Observed Behavior: Upon reviewing the generated code, I've noticed that requirement comments are generated successfully in some parts of the code, but they are entirely missing in other parts, even for elements that clearly have linked requirements.
Desired Behavior: My goal is to have requirement comments generated for all elements in the code that have linked requirements. This is crucial for my workflow, as it allows me to perform accurate requirement coverage analysis later on.
Question: Could you please help me understand why some linked requirements are not resulting in comments in the generated code? Are there specific conditions or settings that might prevent comment generation, even when the "Requirements in block comments" option is active? What steps can I take to ensure that all linked requirements are consistently reflected as comments in the generated code?
Any insights or troubleshooting steps would be greatly appreciated.
Config:

Code have linked req comments:

Code donnot have linked req comments:

0 Comments
Answers (1)
Tridib
on 6 Nov 2025 at 7:22
Some blocks, like virtual blocks or ones that get optimized out, don’t have code sections where you can add comments. Requirement comments only show up in the code for blocks that actually generate code. If a block is removed or inlined during optimization, its requirements will not appear in the generated code. You can use the code generation report to see which blocks were removed or inlined.
Make sure you are using valid link types, because other custom link types might not show up as comments in the code.
If you link requirements to subsystems or masked subsystems, check that the subsystem itself generates a code section. Sometimes, only the inside of the subsystem generates code, not the subsystem block itself.
You can also use Model Advisor checks to catch any requirement traceability issues.
Hope this helps!
0 Comments
See Also
Categories
Find more on Simulink Coder in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!