{"id":101,"date":"2010-07-07T01:22:39","date_gmt":"2010-07-07T01:22:39","guid":{"rendered":"https:\/\/blogs.mathworks.com\/seth\/2010\/07\/07\/10-simple-rules-for-high-performance-generated-code\/"},"modified":"2010-07-07T01:22:39","modified_gmt":"2010-07-07T01:22:39","slug":"10-simple-rules-for-high-performance-generated-code","status":"publish","type":"post","link":"https:\/\/blogs.mathworks.com\/simulink\/2010\/07\/07\/10-simple-rules-for-high-performance-generated-code\/","title":{"rendered":"10 Simple Rules for High-Performance Generated Code"},"content":{"rendered":"<p>I was recently asked, \"Do you have some kind of list or simple rules to get high performance generated code using Real-Time Workshop?\"  I put the question to my colleague (and <a href=\"https:\/\/blogs.mathworks.com\/seth\/2008\/11\/26\/wheres-the-code\/\">first guest blogger<\/a>) <a href=\"https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/authors\/7529\">Tom Erkkinen<\/a>, and he came up with the following.<\/p>\r\n<p>\r\n<ol>\r\n\t<li>Use <a href=\"https:\/\/www.mathworks.com\/products\/rtwembedded\/\">ERT based targets<\/a><\/li>\r\n\t<li>Use <a href=\"https:\/\/www.mathworks.com\/help\/releases\/R2010a\/toolbox\/ecoder\/ug\/br1dugb-1.html\">Code Generation Advisor<\/a>, with efficiency as top priority<\/li>\r\n\t<li><a href=\"https:\/\/www.mathworks.com\/help\/releases\/R2010a\/toolbox\/simulink\/gui\/bq7cqu2-1.html#bq7cq12-1\">Inline parameters<\/a><\/li>\r\n\t<li>For floating point, use single precision signals (if your application allows for it)<\/li>\r\n\t<li>For fixed point, <a href=\"https:\/\/www.mathworks.com\/help\/releases\/R2010a\/toolbox\/fixpoint\/ug\/brabj3k-1.html#brabj44\">remove unnecessary saturation checks<\/a><\/li>\r\n\t<li><a href=\"https:\/\/www.mathworks.com\/help\/releases\/R2010a\/toolbox\/ecoder\/ug\/br9m3so.html\">Limit use of nonvirtual buses, except at model boundaries<\/a><\/li>\r\n\t<li>Use <a href=\"https:\/\/www.mathworks.com\/help\/releases\/R2010a\/toolbox\/simulink\/slref\/codereusesubsystem.html\">reusable subsystems<\/a><\/li>\r\n\t<li>Use <a href=\"https:\/\/www.mathworks.com\/help\/releases\/R2010a\/toolbox\/ecoder\/ug\/brc_o1j-1.html\">TFL<\/a> when ANSI-C is insufficient<\/li>\r\n\t<li>Use state machines only when really needed, otherwise consider using <a href=\"https:\/\/www.mathworks.com\/help\/releases\/R2010a\/toolbox\/stateflow\/ug\/f32-95974.html\">truth tables<\/a><\/li>\r\n\t<li>Consider using <a href=\"https:\/\/www.mathworks.com\/help\/releases\/R2010a\/toolbox\/simulink\/slref\/lookuptablend.html\">Simulink lookup tables<\/a>, your legacy tables may not be as optimized<\/li>\r\n<\/ol>\r\nIf you would like to learn more, follow the links to appropriate resources.<br\/><br\/>\r\n<\/p>\r\n\r\n<p><strong>What are your tips?<\/strong><\/p>\r\n\r\n<p>Do you use generated code in production?  Leave a comment with your tips for generating high-performance code <a href=\"https:\/\/blogs.mathworks.com\/seth\/?p=101&#comment\">here<\/a>.<\/p>\r\n","protected":false},"excerpt":{"rendered":"<p>I was recently asked, \"Do you have some kind of list or simple rules to get high performance generated code using Real-Time Workshop?\"  I put the question to my colleague (and first guest blogger)... <a class=\"read-more\" href=\"https:\/\/blogs.mathworks.com\/simulink\/2010\/07\/07\/10-simple-rules-for-high-performance-generated-code\/\">read more >><\/a><\/p>","protected":false},"author":40,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[21,55,33],"tags":[144,461,142],"_links":{"self":[{"href":"https:\/\/blogs.mathworks.com\/simulink\/wp-json\/wp\/v2\/posts\/101"}],"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\/40"}],"replies":[{"embeddable":true,"href":"https:\/\/blogs.mathworks.com\/simulink\/wp-json\/wp\/v2\/comments?post=101"}],"version-history":[{"count":0,"href":"https:\/\/blogs.mathworks.com\/simulink\/wp-json\/wp\/v2\/posts\/101\/revisions"}],"wp:attachment":[{"href":"https:\/\/blogs.mathworks.com\/simulink\/wp-json\/wp\/v2\/media?parent=101"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blogs.mathworks.com\/simulink\/wp-json\/wp\/v2\/categories?post=101"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blogs.mathworks.com\/simulink\/wp-json\/wp\/v2\/tags?post=101"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}