{"id":10520,"date":"2019-02-22T09:00:19","date_gmt":"2019-02-22T14:00:19","guid":{"rendered":"https:\/\/blogs.mathworks.com\/pick\/?p=10520"},"modified":"2019-02-19T08:23:07","modified_gmt":"2019-02-19T13:23:07","slug":"hdl-coder-tutorial-and-evaluation-reference-guide","status":"publish","type":"post","link":"https:\/\/blogs.mathworks.com\/pick\/2019\/02\/22\/hdl-coder-tutorial-and-evaluation-reference-guide\/","title":{"rendered":"HDL Coder Tutorial and Evaluation Reference Guide"},"content":{"rendered":"<div xmlns:mwsh=\"http:\/\/www.mathworks.com\/namespace\/mcode\/v1\/syntaxhighlight.dtd\" class=\"content\">\n<p>Curie&#8217;s pick of the week is &#8211; actually, make that plural! My picks are the <a href=\"https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/69651\">HDL Coder Tutorial<\/a> and <a href=\"https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/58941\">HDL Coder Evaluation Reference Guide<\/a>, both by <a href=\"http:\/\/www.mathworks.com\/matlabcentral\/profile\/authors\/5844587\">Jack Erickson<\/a>.\n   <\/p>\n<p>If you weren&#8217;t aware, you can generate HDL (hardware description language) code from MATLAB and Simulink to program custom FPGA or ASIC hardware. I have worked with customers that are targeting an FPGA for the first time, to customers with decades of ASIC design experience who want to connect their chip design workflow to model-based design to improve their agility and efficiency.\n   <\/p>\n<p>A powerful tool such as <a href=\"https:\/\/www.mathworks.com\/products\/hdl-coder.html\">HDL Coder<\/a> means there is a learning curve, especially if you are new to Simulink. To help you get started, the tutorial provides step-by-step instructions on how to take this sample MATLAB code:\n   <\/p>\n<pre style=\"background: #F9F7F3; padding: 10px; border: 1px solid rgb(200,200,200)\"><span style=\"color: #228B22\">% Correlate Rx filter against matched filter<\/span>\r\nFilterOut = filter(CorrFilter, 1, RxSignal);\r\n\r\n<span style=\"color: #228B22\">% Find peak magnitude &amp; location<\/span>\r\n[peak, location] = max(abs(FilterOut));<\/pre>\n<p>To a Simulink architectural, fixed-point model that is ready to generate VHDL or Verilog:<\/p>\n<p><img decoding=\"async\" vspace=\"5\" hspace=\"5\" src=\"https:\/\/blogs.mathworks.com\/pick\/files\/hdl1.png\"> <\/p>\n<p>It is as much about learning the Model-Based Design tools as understanding the process of targeting algorithm designs on FPGA\/ASIC hardware.\n   <\/p>\n<p>So you are feeling empowered to start your next HDL design in Simulink after completing the tutorial. But you still have so many questions: &#8220;What are the best practices to create efficient hardware?&#8221; &#8220;How do I direct the tool to use FPGA resources such as RAM and DSP blocks?&#8221; &#8220;I can&#8217;t figure out how to model my clock signal!&#8221; (You don&#8217;t).\n   <\/p>\n<p>The answers to these questions, and many other popular topics among our users are captured in the <a href=\"https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/58941\">HDL Coder Evaluation Reference Guide<\/a>. The 28-page document describes design patterns and settings that produce efficient HDL code, and highlights useful tools that help speed up your design process.\n   <\/p>\n<p>For instance, you will learn how to make local enable signal behave synchronously; view timing diagram with the Logic Analyzer scope; and incorporate MATLAB code in your Simulink design using the MATLAB function block &#8211; very handy when it comes to control logic.\n   <\/p>\n<p><img decoding=\"async\" vspace=\"5\" hspace=\"5\" src=\"https:\/\/blogs.mathworks.com\/pick\/files\/hdl2.png\"> <\/p>\n<p>And yes, there is an entire section devoted to FPGA resource mapping, with examples such as this complex multiplier that maps to DSP blocks on Xilinx\u00ae and Intel\u00ae FPGAs:\n   <\/p>\n<p><img decoding=\"async\" vspace=\"5\" hspace=\"5\" src=\"https:\/\/blogs.mathworks.com\/pick\/files\/hdl3.png\"> <\/p>\n<p>So don&#8217;t let the number of pages scare you and start reading! (Really, half of them are pictures). And if you want to evaluate capabilities specific to your HDL design, my colleagues and I look forward to working with you.\n   <\/p>\n<p>Give it a try and let us know what you think <a href=\"http:\/\/blogs.mathworks.com\/pick\/?p=10520#respond\">here<\/a>!\n   <\/p>\n<p><script language=\"JavaScript\">\n<!--\n\n    function grabCode_8da315b954fb41ceb4f5b81b9a32fa6f() {\n        \/\/ Remember the title so we can use it in the new page\n        title = document.title;\n\n        \/\/ Break up these strings so that their presence\n        \/\/ in the Javascript doesn't mess up the search for\n        \/\/ the MATLAB code.\n        t1='8da315b954fb41ceb4f5b81b9a32fa6f ' + '##### ' + 'SOURCE BEGIN' + ' #####';\n        t2='##### ' + 'SOURCE END' + ' #####' + ' 8da315b954fb41ceb4f5b81b9a32fa6f';\n    \n        b=document.getElementsByTagName('body')[0];\n        i1=b.innerHTML.indexOf(t1)+t1.length;\n        i2=b.innerHTML.indexOf(t2);\n \n        code_string = b.innerHTML.substring(i1, i2);\n        code_string = code_string.replace(\/REPLACE_WITH_DASH_DASH\/g,'--');\n\n        \/\/ Use \/x3C\/g instead of the less-than character to avoid errors \n        \/\/ in the XML parser.\n        \/\/ Use '\\x26#60;' instead of '<' so that the XML parser\n        \/\/ doesn't go ahead and substitute the less-than character. \n        code_string = code_string.replace(\/\\x3C\/g, '\\x26#60;');\n\n        author = 'Curie Chung';\n        copyright = 'Copyright 2019 The MathWorks, Inc.';\n\n        w = window.open();\n        d = w.document;\n        d.write('\n\n<pre>\\n');\r\n        d.write(code_string);\r\n\r\n        \/\/ Add author and copyright lines at the bottom if specified.\r\n        if ((author.length > 0) || (copyright.length > 0)) {\r\n            d.writeln('');\r\n            d.writeln('%%');\r\n            if (author.length > 0) {\r\n                d.writeln('% _' + author + '_');\r\n            }\r\n            if (copyright.length > 0) {\r\n                d.writeln('% _' + copyright + '_');\r\n            }\r\n        }\r\n\r\n        d.write('<\/pre>\n\n\\n');\n      \n      d.title = title + ' (MATLAB code)';\n      d.close();\n      }   \n      \n-->\n<\/script><\/p>\n<p style=\"text-align: right; font-size: xx-small; font-weight:lighter;   font-style: italic; color: gray\"><a href=\"javascript:grabCode_8da315b954fb41ceb4f5b81b9a32fa6f()\"><span style=\"font-size: x-small;        font-style: italic;\">Get<br \/>\n            the MATLAB code<br \/>\n            <noscript>(requires JavaScript)<\/noscript><\/span><\/a><\/p>\n<p>      Published with MATLAB&reg; R2019a<\/p>\n<\/div>\n<p><!--\n8da315b954fb41ceb4f5b81b9a32fa6f ##### SOURCE BEGIN #####\n%% \n%\n% Curie's pick of the week is \u00e2\u20ac\u201c actually, make that plural! My picks are\n% the <https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/69651 HDL Coder\n% Tutorial> and <https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/58941\n% HDL Coder Evaluation Reference Guide>, both by\n% <http:\/\/www.mathworks.com\/matlabcentral\/profile\/authors\/5844587 Jack\n% Erickson>. \n% \n% If you weren\u00e2\u20ac&#x2122;t aware, you can generate HDL (hardware description\n% language) code from MATLAB and Simulink to program custom FPGA or ASIC\n% hardware. I have worked with customers that are targeting an FPGA for the\n% first time, to customers with decades of ASIC design experience who want\n% to connect their chip design workflow to model-based design to improve\n% their agility and efficiency.\n%\n% A powerful tool such as\n% <https:\/\/www.mathworks.com\/products\/hdl-coder.html HDL Coder> means there\n% is a learning curve, especially if you are new to Simulink. To help you\n% get started, the tutorial provides step-by-step instructions on how to\n% take this sample MATLAB code:\n\n% Correlate Rx filter against matched filter\nFilterOut = filter(CorrFilter, 1, RxSignal);\n\n% Find peak magnitude & location\n[peak, location] = max(abs(FilterOut));\n\n%%\n% To a Simulink architectural, fixed-point model that is ready to generate\n% HDL:\n% \n% <<simref.png>>\n% \n% It is as much about learning the Model-Based Design tools as\n% understanding the process of targeting algorithm designs on FPGA\/ASIC\n% hardware.\n%\n% So you are feeling empowered to start your next HDL design in Simulink\n% after completing the tutorial. But you still have so many questions:\n% \"What are the best practices to create efficient hardware?\" \"How do I\n% direct the tool to use FPGA resources such as RAM and DSP blocks?\" \"I\n% can't figure out how to model my clock signal!\" (You don't).\n%\n% The answers to these questions, and many other popular topics among our\n% users are captured in the <https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/58941\n% HDL Coder Evaluation Reference Guide>. The\n% 28-page document describes design patterns and settings that produce\n% efficient HDL code, and highlights useful tools that help speed up your\n% design process.\n%\n% For instance, you will learn how to make local enable signal behave\n% synchronously; view timing diagram with the Logic Analyzer scope; and\n% incorporate MATLAB code in your Simulink design using the MATLAB function\n% block \u00e2\u20ac\u201c very handy when it comes to control logic.\n% \n% <<logicanalyzer.png>>\n% \n% And yes, there is an entire section devoted to FPGA resource mapping,\n% with examples such as mapping a complex multiplier to DSP blocks:\n%\n% <<resourcemap.png>>\n%\n% So don't let the number of pages scare you and start reading! (Really,\n% half the document is pictures). And if you want to evaluate capabilities\n% specific to your HDL design, my colleagues and I look forward to working\n% with you.\n% \n% Give it a try and let us know what you think\n% <http:\/\/blogs.mathworks.com\/pick\/?p=10520#respond here>!\n%\n##### SOURCE END ##### 8da315b954fb41ceb4f5b81b9a32fa6f\n--><\/p>\n","protected":false},"excerpt":{"rendered":"<div class=\"overview-image\"><img decoding=\"async\"  class=\"img-responsive\" src=\"https:\/\/blogs.mathworks.com\/pick\/files\/hdl1.png\" onError=\"this.style.display ='none';\" \/><\/div>\n<p>\nCurie&#8217;s pick of the week is &#8211; actually, make that plural! My picks are the HDL Coder Tutorial and HDL Coder Evaluation Reference Guide, both by Jack Erickson.<\/p>\n<p>If you weren&#8217;t&#8230; <a class=\"read-more\" href=\"https:\/\/blogs.mathworks.com\/pick\/2019\/02\/22\/hdl-coder-tutorial-and-evaluation-reference-guide\/\">read more >><\/a><\/p>\n","protected":false},"author":36,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[16],"tags":[],"_links":{"self":[{"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/posts\/10520"}],"collection":[{"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/users\/36"}],"replies":[{"embeddable":true,"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/comments?post=10520"}],"version-history":[{"count":6,"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/posts\/10520\/revisions"}],"predecessor-version":[{"id":10562,"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/posts\/10520\/revisions\/10562"}],"wp:attachment":[{"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/media?parent=10520"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/categories?post=10520"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/tags?post=10520"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}