{"id":1648,"date":"2014-01-13T15:04:15","date_gmt":"2014-01-13T15:04:15","guid":{"rendered":"http:\/\/blog.bachi.net\/?p=1648"},"modified":"2014-11-07T15:37:07","modified_gmt":"2014-11-07T15:37:07","slug":"questasim-modelsim-vhdl-simulation-from-mentorgraphics","status":"publish","type":"post","link":"https:\/\/blog.bachi.net\/?p=1648","title":{"rendered":"QuestaSim ModelSim VHDL Simulation from MentorGraphics"},"content":{"rendered":"<h3>General<\/h3>\n<p><a href=\"http:\/\/www.cs.colostate.edu\/~cs460\/labnotes\/modelsimtutorial.html\">Simple ModelSim Tutorial<\/a><\/p>\n<h3>VHDL<\/h3>\n<p><a href=\"http:\/\/www.altera.com\/support\/examples\/vhdl\/vhdl.html\">VHDL Design Examples<\/a><\/p>\n<ul>\n<li>Design Unit<\/li>\n<li>Entity<\/li>\n<li>Architecture<\/li>\n<li>Package<\/li>\n<li>Delta Delay<\/li>\n<\/ul>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">\r\nVSIM 13&gt; cd hdl\/simulation\/questa\r\nVSIM 13&gt; pwd\r\nhdl\/simulation\/questa\r\nVSIM 13&gt; do ..\/scripts\/do_all.do\r\n<\/pre>\n<table>\n<tr>\n<td><a href=\"http:\/\/blog.bachi.net\/wp-content\/uploads\/2014\/01\/questasim_flow.png\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/blog.bachi.net\/wp-content\/uploads\/2014\/01\/questasim_flow-150x150.png\" alt=\"questasim_flow\" width=\"150\" height=\"150\" class=\"alignleft size-thumbnail wp-image-1649\" \/><\/a><\/td>\n<\/tr>\n<\/table>\n<h4>Summary: History of VHDL<\/h4>\n<table>\n<tr>\n<td>1981<\/td>\n<td>Initiated by US DoD to address hardware life-cycle crisis<\/td>\n<\/tr>\n<tr>\n<td>1983-85<\/td>\n<td>Development of baseline language by Intermetrics, IBM and TI<\/td>\n<\/tr>\n<tr>\n<td>1986<\/td>\n<td>All rights transferred to IEEE<\/td>\n<\/tr>\n<tr>\n<td>1987<\/td>\n<td>Publication of IEEE Standard<\/td>\n<\/tr>\n<tr>\n<td>1987<\/td>\n<td>Mil Std 454 requires comprehensive VHDL descriptions to be delivered with ASICs<\/td>\n<\/tr>\n<tr>\n<td>1994<\/td>\n<td>Revised standard (named VHDL 1076-1993)<\/td>\n<\/tr>\n<tr>\n<td>2000<\/td>\n<td>Revised standard (named VHDL 1076 2000, Edition)<\/td>\n<\/tr>\n<tr>\n<td>2002<\/td>\n<td>Revised standard (named VHDL 1076-2002)<\/td>\n<\/tr>\n<tr>\n<td>2007<\/td>\n<td>VHDL Procedural Language Application Interface standard (VHDL 1076c-2007)<\/td>\n<\/tr>\n<tr>\n<td>2009<\/td>\n<td>Revised Standard (named VHDL 1076-2008)<\/td>\n<\/tr>\n<\/table>\n<h3>modelsim.ini Variables<\/h3>\n<h4>Explicit<\/h4>\n<p>This variable enables the resolving of ambiguous function overloading in favor of the &#8220;explicit&#8221; function declaration (not the one automatically created by the compiler for each type declaration). Using this variable makes QuestaSim compatible with common industry practice.<\/p>\n<p>You can override this variable by specifying vcom -explicit.<\/p>\n<h4>Specifying Resource Libraries<\/h4>\n<p>Note that the library clause is not used to specify the working library into which the design unit is placed after compilation. The vcom command adds compiled design units to the current working library. By default, this is the library named work. To change the current working library, you can use vcom -work and specify the name of the desired target library.<\/p>\n<h3>Compiling a VeriLog Design<\/h3>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">\r\nVSIM 13&gt; vlog &#x5B;...]\r\n<\/pre>\n<h3>Compiling a VHDL Design<\/h3>\n<p>For VHDL, the order of compilation is important. You must compile any entities or configurations before an architecture that references them.<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">\r\nVSIM 13&gt; vcom -2002 -explicit -work ..\/questa\/work ..\/source\/top_tb.vhd\r\n-2002              Revision VHDL 1076-2002\r\n-explicit          Enables the resolving of ambiguous function overloading\r\n-work &lt;directory&gt;  Specify the name of the desired target library\r\n&lt;source&gt;           VHDL source\r\n<\/pre>\n<h4>Built-in Libraries and Packages<\/h4>\n<p>In most vhdl programs you have already seen examples of packages and libraries. Here are two:<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">\r\nlibrary ieee;\r\nuse ieee.std_logic_1164.all;\r\nuse ieee.std_logic_signed.all;\r\n<\/pre>\n<p>The packages are <strong>std_logic_1164<\/strong> and <strong>std_logic_signed<\/strong> and the library is <strong>ieee<\/strong>. Since the <strong>scope<\/strong> of the library statement extends over the entire file, it is not necessary to repeat that for the second package.<br \/>\nIt&#8217;s instructive to show where the packages are physically located. For Altera Max+2 and Xilinx Foundation these locations typically are:<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">\r\nAltera: ~\\maxplus2\\vhdl93\\ieee\\std1164.vhd\r\nXilinx: ~\\fndtn\\synth\\lib\\packages\\ieee\\src\\std_logic_1164.vhd\r\n<\/pre>\n<p>It is thus tempting to come to the conclusion that the &#8220;library ieee;&#8221; statement indicates the &#8220;directory&#8221; in which the std_logic_1164 package is located. Note, however, where it is in Synplicity:<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">\r\nSynplicty: ~\\synplcty\\LIB\\vhd\\std1164.vhd\r\n<\/pre>\n<p>In the latter there is no mention of <strong>ieee<\/strong> at all. It is thus more appropriate to think of <strong>ieee<\/strong> as a pointer to the location of the package. The directory structure shown in those three examples depicts the directories where the packages are loaded when the software is installed. The pointer <strong>ieee<\/strong> is hardcoded in the compilers and thus there is no need for the user to associate that pointer with the directory structure, nor is it possible to put the packages anywhere else after the software has been loaded.<\/p>\n<h4>User Libraries and Packages<\/h4>\n<p>User libraries and packages are setup very similarly to the built-in ones. However, in that case, the user is responsible for the directory structure, the contents of the files, etc. Note that the user must then also set up the pointer to the package. The following shows a complete example of this arrangement. There are two ways to do this: 1) with the &#8220;work&#8221; directory; 2) with a user library.<\/p>\n<p><a href=\"http:\/\/www.arl.wustl.edu\/projects\/fpx\/class\/resources\/Libraries%20and%20Packages%20in%20VHDL.htm\">Libraries and Packages in VHDL<\/a><\/p>\n<h4>WORK is not a VHDL Library<\/h4>\n<p>WORK is not the name of a VHDL library. This may surprise some (or even most) VHDL designers, even experienced engineers. Most of the time, nobody gets bothered by this. But on occasion, it can cause great confusion and waste of time.<\/p>\n<p>All knowledge about VHDL starts with the IEEE Standard VHDL Language Reference Manual. LRM for short. Not much is said about &#8220;WORK&#8221;, but in section 11.2 (in the LRM 1076-2000) you can read the following:<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">\r\nEvery design unit &#x5B;...] is assumed to contain the following implicit context items &#x5B;...]:\r\nlibrary STD, WORK; use STD.STANDARD.all;\r\n&#x5B;...] Library logical name WORK denotes the current working library during a given analysis.\r\n<\/pre>\n<p>Let me repeat: WORK denotes the current working library.<\/p>\n<p>This means that there is no library named WORK. Instead, the identifier WORK just refers to the current library. You can compare WORK with the Java concept of this. In Java this refers to this object, which obviously is different for each object. This makes me think of a silly joke of man who asks: &#8220;is this the second street to the right?&#8221;<\/p>\n<p>Enough silliness. Much confusion comes from the fact that VHDL tools allow you to give the name &#8220;WORK&#8221; to a library:<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">\r\nvlib work\r\nvcom -work work myfile.vhd\r\n<\/pre>\n<p>That is as crazy as having a street address of <em>John Doe, Ourstreet, MyHomeTown<\/em>. How will your mail ever get there? And that is exactly the problem with using <strong>WORK<\/strong> as a library name. Other libraries cannot refer to you. If another library (say alex) they would refer to <span style=\"font-family: monospace; font-size: medium; color: black\">work.yourpackage.all<\/span>, the VHDL analyser would read this as the <span style=\"font-family: monospace; font-size: medium; color: black\">alex.yourpackage.all<\/span>.<\/p>\n<p>It would have been better if VHDL tools would refuse the explicit name of <strong>WORK<\/strong> for a library. It would have been better if <strong>WORK<\/strong> were a reserved keyword in VHDL. But hey, there is no way to change that now. The best you can do is be aware of this idiosyncrasy in VHDL and live with it. Preferably by avoiding <strong>WORK<\/strong> all together.<\/p>\n<p><a href=\"http:\/\/www.sigasi.com\/content\/work-not-vhdl-library\">WORK is not a VHDL Library<\/a><\/p>\n<h3>Simulating a VHDL Design<\/h3>\n<p>A VHDL design is ready for simulation after it has been compiled with vcom and possibly optimized with vopt. You can then use the vsim command to invoke the simulator with the name of the configuration or entity\/architecture pair or the name you assigned to the optimized version of the design.<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">\r\nVSIM 13&gt; vsim -novopt -t 1ps -lib work work.top_tb\r\n-novopt     Simulate without Optimization\r\n-t &lt;time&gt;   Override Resolution Limit\r\n-lib \r\n<\/pre>\n<h4>Simulator Resolution Limit<\/h4>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">\r\nvsim -t 10ps topmod\r\n<\/pre>\n<p>In the example above, a delay of 4 ps would be rounded down to 0 ps, and a delay of 6 ps would be rounded up to 10 ps.<\/p>\n<h4>Examining and Setting Signals and Variables with commands<\/h4>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">\r\nVSIM&gt; examine -time 13710 ns -radix hex \/top_tb\/DUT\/ata_block_i\r\n# 0EEDFA9A994350F07214CA6151823A08\r\n\r\nVSIM&gt; change \/top_tb\/DUT\/ata_block_i 00000000000000000000000000040002\r\n<\/pre>\n<p><a href=\"http:\/\/www.tkt.cs.tut.fi\/tools\/public\/tutorials\/mentor\/modelsim\/getting_started\/gsms.html\">ModelSim Tutorial<\/a><\/p>\n<h3>FAQ<\/h3>\n<h4>Question<\/h4>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">\r\n# ** Error: (vcom-11) Could not find work.aes_tb_package.\r\n# ** Error: ..\/tb\/aes_tester.vhd(54): (vcom-1195) Cannot find expanded name &quot;work.aes_tb_package&quot;.\r\n# ** Error: ..\/tb\/aes_tester.vhd(54): Unknown expanded name.\r\n# ** Error: ..\/tb\/aes_tester.vhd(56): VHDL Compiler exiting\r\n# ** Error: \/opt\/questasim_10.1d\/questasim\/linux\/vcom failed.\r\n<\/pre>\n<h4>Answer<\/h4>\n<p>Compile other VHDL file first!<\/p>\n<h4>Question<\/h4>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">\r\n# vsim -lib work -t 1ns -novopt work.aes_tester \r\n# ** Error: (vsim-19) Failed to access library 'work' at &quot;work&quot;.\r\n# No such file or directory. (errno = ENOENT)\r\n# Error loading design\r\n# Error: Error loading design \r\n#        Pausing macro execution \r\n<\/pre>\n<h4>Answer<\/h4>\n<p>Change to questa directory or map it like this:<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">\r\nvlib ..\/questa\/work\r\nvmap work ..\/questa\/work\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>General Simple ModelSim Tutorial VHDL VHDL Design Examples Design Unit Entity Architecture Package Delta Delay VSIM 13&gt; cd hdl\/simulation\/questa VSIM 13&gt; pwd hdl\/simulation\/questa VSIM 13&gt; do ..\/scripts\/do_all.do Summary: History of VHDL 1981 Initiated by US DoD to address hardware life-cycle crisis 1983-85 Development of baseline language by Intermetrics, IBM and TI 1986 All rights transferred [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-1648","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/blog.bachi.net\/index.php?rest_route=\/wp\/v2\/posts\/1648","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.bachi.net\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.bachi.net\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.bachi.net\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.bachi.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1648"}],"version-history":[{"count":25,"href":"https:\/\/blog.bachi.net\/index.php?rest_route=\/wp\/v2\/posts\/1648\/revisions"}],"predecessor-version":[{"id":3209,"href":"https:\/\/blog.bachi.net\/index.php?rest_route=\/wp\/v2\/posts\/1648\/revisions\/3209"}],"wp:attachment":[{"href":"https:\/\/blog.bachi.net\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1648"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.bachi.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1648"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.bachi.net\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1648"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}