{"id":2897,"date":"2013-12-03T10:58:52","date_gmt":"2013-12-03T15:58:52","guid":{"rendered":"https:\/\/blogs.mathworks.com\/seth\/?p=2897"},"modified":"2017-04-27T08:52:22","modified_gmt":"2017-04-27T13:52:22","slug":"tracing-requirements-to-models-tests-and-generated-code","status":"publish","type":"post","link":"https:\/\/blogs.mathworks.com\/simulink\/2013\/12\/03\/tracing-requirements-to-models-tests-and-generated-code\/","title":{"rendered":"Tracing Requirements to Models, Tests, and Generated Code"},"content":{"rendered":"<p>When I wrote a <a href=\"https:\/\/blogs.mathworks.com\/seth\/2013\/09\/06\/welcome-r2013b\">post about the R2013b new features<\/a>, <a href=\"https:\/\/www.mathworks.com\/matlabcentral\/cody\/players\/3540556-fraser-macmillen \">Fraser<\/a> replied in a <a href=\"https:\/\/blogs.mathworks.com\/seth\/2013\/09\/06\/welcome-r2013b\/#comment-41851\">comment<\/a> that one of his favorite new feature is the requirements linking to MATLAB code.<\/p>\r\n\r\n<p>This made me realize that I never described on this blog how <a href=\"https:\/\/www.mathworks.com\/products\/simverification\/\">Simulink Verification and Validation<\/a> allows the tracing of requirements to models, tests, and generated code:\r\n\r\n<p><img decoding=\"async\" src=\"https:\/\/blogs.mathworks.com\/images\/seth\/2013Q4\/bigPicture.jpg\" alt=\"Tracing requirements to models, tests, and generated code\" \/><\/p>\r\n\r\n<p>To help readers not familiar with this topic, this week I give a quick overview of how Simulink Verification and Validation can facilitate maintaining and demonstrating traceability of high-level requirements to Simulink models and generated code.<\/p>\r\n\r\n\r\n<p><strong>Linking Blocks to Requirements<\/strong><\/p>\r\n\r\n<p>The first step is to link requirements stored in an external document to blocks in your model. If I have requirements stored in a Microsoft\u00ae Word document, I can select the text I want to link:<\/p>\r\n\r\n<p><img decoding=\"async\" src=\"https:\/\/blogs.mathworks.com\/images\/seth\/2013Q4\/WordReqLink.png\" alt=\"Select Text in the Requirement Document\" \/><\/p>\r\n\r\n<p>Then I go to the model, right-click the block to be linked and select <em>Link to Selection in Word<\/em>:<\/p>\r\n\r\n<p><img decoding=\"async\" src=\"https:\/\/blogs.mathworks.com\/images\/seth\/2013Q4\/rightClickLinking.png\" alt=\"Linking a block to external requirement\" \/><\/p>\r\n\r\n<p>Once the link  is created, you will see a hyperlink in the Word document. Clicking this link highlights the linked block in Simulink.<\/p>\r\n\r\n<p><img decoding=\"async\" src=\"https:\/\/blogs.mathworks.com\/images\/seth\/2013Q4\/WordReqHyperLink.png\" alt=\"Word Document linked to a Simulink block\" \/><\/p>\r\n\r\n<p>In the model, the right-click menu of the block now contains a link that can be used to highlight the requirement in Word.<\/p>\r\n\r\n<p><img decoding=\"async\" src=\"https:\/\/blogs.mathworks.com\/images\/seth\/2013Q4\/blockWithLink.png\" alt=\"Simulink block linked to an external requirement\" \/><\/p>\r\n\r\n<p><strong>Requirements in the generated code<\/strong><\/p>\r\n\r\n<p>If you generate code for your model, you can choose to include the requirements as comments in the code. In the code generation report, you will see hyperlinks allowing you to navigate directly to the requirements document.\r\n\r\n<p><img decoding=\"async\" src=\"https:\/\/blogs.mathworks.com\/images\/seth\/2013Q4\/codeWithReq.png\" alt=\"Code Generation report with requirement link\" \/><\/p>\r\n\r\n<p><strong>Traceability report<\/strong><\/p>\r\n\r\n<p>To get the big picture of the requirements in your model, you can generate a <a title=\"https:\/\/www.mathworks.com\/help\/releases\/R2017a\/slvnv\/ug\/create-and-customize-requirements-report.html (link no longer works)\">traceability report<\/a>. Using <a href=\"https:\/\/www.mathworks.com\/products\/SL_reportgenerator\/\">Simulink Report Generator<\/a>, you can configure the look of the report.<\/p>\r\n\r\n<p>For the simple block in the example above, the default report looks like this:<\/p>\r\n\r\n<p><img decoding=\"async\" src=\"https:\/\/blogs.mathworks.com\/images\/seth\/2013Q4\/TracabilityReport.png\" alt=\"Traceability Report\" \/><\/p>\r\n\r\n<p><strong>Requirements Consistency Check<\/strong><\/p>\r\n\r\n<p>As your project evolves, you can run a set of <a title=\"https:\/\/www.mathworks.com\/help\/releases\/R2017a\/slvnv\/ref\/requirements-consistency-checks.html (link no longer works)\">Requirements Consistency Checks<\/a> in the Model Advisor to ensure that the requirements links are still up-to-date and valid.<\/p>\r\n\r\n<p><img decoding=\"async\" src=\"https:\/\/blogs.mathworks.com\/images\/seth\/2013Q4\/ReqConsistentCheck.png\" alt=\"Consistency Checking\" \/><\/p>\r\n\r\n<p><strong>Now it's your turn<\/strong><\/p>\r\n\r\n<p>Consult the <a href=\"https:\/\/www.mathworks.com\/products\/simverification\/index.html\">Simulink Verification and Validation<\/a> product page or its <a title=\"https:\/\/www.mathworks.com\/help\/slvnv\/index.html (link no longer works)\">documentation<\/a> to learn more about how it can help you manage requirements and a lot more.<\/p>\r\n\r\n<p>How do you navigate between your Simulink models and your requirements? Let us know by leaving a <a href=\"https:\/\/blogs.mathworks.com\/seth\/?p=2897&#comment\">comment here<\/a>.<\/p>","protected":false},"excerpt":{"rendered":"<div class=\"overview-image\"><img decoding=\"async\"  class=\"img-responsive\" src=\"https:\/\/blogs.mathworks.com\/images\/seth\/2013Q4\/ReqConsistentCheck.png\" onError=\"this.style.display ='none';\" \/><\/div><p>When I wrote a post about the R2013b new features, Fraser replied in a comment that one of his favorite new feature is the requirements linking to MATLAB code.\r\n\r\nThis made me realize that I never... <a class=\"read-more\" href=\"https:\/\/blogs.mathworks.com\/simulink\/2013\/12\/03\/tracing-requirements-to-models-tests-and-generated-code\/\">read more >><\/a><\/p>","protected":false},"author":41,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[21,24,63],"tags":[351],"_links":{"self":[{"href":"https:\/\/blogs.mathworks.com\/simulink\/wp-json\/wp\/v2\/posts\/2897"}],"collection":[{"href":"https:\/\/blogs.mathworks.com\/simulink\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blogs.mathworks.com\/simulink\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blogs.mathworks.com\/simulink\/wp-json\/wp\/v2\/users\/41"}],"replies":[{"embeddable":true,"href":"https:\/\/blogs.mathworks.com\/simulink\/wp-json\/wp\/v2\/comments?post=2897"}],"version-history":[{"count":35,"href":"https:\/\/blogs.mathworks.com\/simulink\/wp-json\/wp\/v2\/posts\/2897\/revisions"}],"predecessor-version":[{"id":6513,"href":"https:\/\/blogs.mathworks.com\/simulink\/wp-json\/wp\/v2\/posts\/2897\/revisions\/6513"}],"wp:attachment":[{"href":"https:\/\/blogs.mathworks.com\/simulink\/wp-json\/wp\/v2\/media?parent=2897"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blogs.mathworks.com\/simulink\/wp-json\/wp\/v2\/categories?post=2897"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blogs.mathworks.com\/simulink\/wp-json\/wp\/v2\/tags?post=2897"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}