{"id":2033,"date":"2016-09-05T11:57:15","date_gmt":"2016-09-05T09:57:15","guid":{"rendered":"http:\/\/priit.ati.ttu.ee\/?page_id=2033"},"modified":"2020-06-04T14:15:06","modified_gmt":"2020-06-04T12:15:06","slug":"modelsimquestasim","status":"publish","type":"page","link":"http:\/\/priit.ati.ttu.ee\/?page_id=2033","title":{"rendered":"ModelSim\/QuestaSim"},"content":{"rendered":"<p style=\"text-align: right;\">\n    <!-- WP Last Modified by Dogan Ucar (https:\/\/www.dogan-ucar.de). -->\n    <!-- This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;-->\n    <!-- 2016 - 2026 Dogan Ucar. -->Last modified: 2020-06-04 14:15:06<\/p>\n<h3>Before we start<\/h3>\n<p>In the lab class we need to <a href=\"https:\/\/slotsups.com\/triple-aces-casino-review\/\" style=\"text-decoration: none; color:#333\">luckyladys<\/a>choose the configuration for the environment\t<a href=\"https:\/\/777slotsroom.com\/jack-and-the-beanstalk-slot\/\" style=\"text-decoration: none; color:#333\">jack and the beanstalk slot machine<\/a>    which allows<br \/>\nus to use ModelSim. The command for the environment choices is <b>cad<\/b>. The command must<br \/>\nbe entered twice.<br \/>\nTo select ModelSim choose <b>option 2 <\/b>(Mentor Graphics 2018 EDA version).<\/p>\n<p><span style=\"color: red;\">Another important note to remember is that ModelSim<br \/>\n<b>doesn&#8217;t support CTRL+s<\/b> shortcut.<\/span><\/p>\n<h3>Starting ModelSim<\/h3>\n<p>To start the program you must insert command<\/p>\n<p><b>vsim &amp;<\/b><\/p>\n<p>The &amp; in the end of the command shows that the program is run in the backround and the<br \/>\npromt is returned immediately. It means that to run another process you don&#8217;t have<br \/>\nto open a new command line window. You can use <b>&amp;<\/b> behind every process command.<\/p>\n<p><img title=\"ModelSim\" src=\"ModelSim\/1main.PNG\" alt=\"ModelSim\"><\/p>\n<p>Figure 1. ModelSim main view.<\/p>\n<h3>Specifying the simulation directory<\/h3>\n<p>You need to tell the simulator where to find the lab directory containing your design files. For that:<\/p>\n<ul>\n<li><b>File-&gt;Change Directory<\/b><\/li>\n<li>Navigate to the directory containing your design files<\/li>\n<li><b>Ok<\/b><\/li>\n<\/ul>\n<h2>Compiling the design<\/h2>\n<p>To compile your design you can either create a new project and compile the files<br \/>\nin the project or just compile every file without creating a project. Somewhat<br \/>\neasier is to create a new project. This gives you the chance to open the project<br \/>\nlater without any need to specify the files in there or the library used.<\/p>\n<h3><span style=\"color: red;\">Option1: Compilation without project creation<\/span><\/h3>\n<h4>Creating a compilation library<\/h4>\n<p>A compilation library is a directory on your disk into which all HDL designs are compiled.<br \/>\nYou can specify this library through the ModelSim or it can be created using operation system<br \/>\ncommands. Usual library name is <b>work<\/b>. Now lets create a directory called <b>work<\/b><br \/>\nand map the directory to the logical library named <b>work<\/b>.<\/p>\n<ul>\n<li><b>File-&gt;New-&gt;Library<\/b><\/li>\n<li>Select <b>Create a new library and a logical mapping to it<\/b> (Figure 2).<\/li>\n<li>Type <b>work<\/b> into the library form. Note that it&#8217;s duplicated.<\/li>\n<li>Select <b>Ok<\/b>.<\/li>\n<li>Verify that the directory with the name <b>work<\/b> has been created in your lab directory.<\/li>\n<\/ul>\n<p><img title=\"ModelSim\" src=\"ModelSim\/2library.PNG\" alt=\"ModelSim\"><\/p>\n<p>Figure 2. Creating a new library.<\/p>\n<h4>Compiling your design<\/h4>\n<p>Now lets compile the design. For example we&#8217;ll take the lab1 mux.vhd VHDL file.<\/p>\n<ul>\n<li><b>Compile-&gt;Compile&#8230;<\/b><\/li>\n<li>The following dialog box appears (Figure 3).<\/li>\n<li>Make sure that <b>Library<\/b> is set to <b>work<\/b>.<\/li>\n<li>Select the design file you want to compile, for example mux.vhd and then click <b>Compile<\/b>.<\/li>\n<li>Check the main ModelSim window for the results of compilation.<\/li>\n<\/ul>\n<p><img title=\"ModelSim\" src=\"ModelSim\/3compile.PNG\" alt=\"ModelSim\"><\/p>\n<p>Figure 3. Compiling source files.<\/p>\n<h3><span style=\"color: red;\">Option2: Compiling with project creation<\/span><\/h3>\n<p>Creating a new project:<\/p>\n<ul title=\"Creating a new project steps\">\n<li><b>File-&gt;New-&gt;Project<\/b><\/li>\n<li><b>Create Project<\/b> dialog box appers (Figure 4).<\/li>\n<li>Type the name of the project in the <b>Project Name<\/b> field.<\/li>\n<li>Specify the directory on your disk, where the project would be located in the<br \/>\n<b>Project Location<\/b> field.<\/li>\n<li>Specify the compilation library name. A compilation library is a directory on your disk<br \/>\ninto which all HDL designs are compiled. The default library name is <b>work<\/b>. It is better to<br \/>\nleave it with a default name.<\/li>\n<\/ul>\n<p>After a new project creation a new tab <b>Project<\/b> appears in the <b>Workspace<\/b> window.<br \/>\nThis shows the list of the files of the current project.<\/p>\n<p><img title=\"ModelSim\" src=\"ModelSim\/4project.PNG\" alt=\"ModelSim\"><\/p>\n<p>Figure 4. Creating a project.<\/p>\n<h4>Adding an existing design file to the project<\/h4>\n<ul title=\"Adding an existing design to project steps\">\n<li><b>File-&gt;Add to Project-&gt;Existing File&#8230;<\/b><\/li>\n<li>Browse the file, for example mux.vhd. (Figure 5).<\/li>\n<li>You can either <b>reference from current location<\/b> or <b>copy to project directory<\/b><br \/>\nchoosing appropriate radio button.<\/li>\n<li>Select <b>Ok<\/b>. The chosen file will appear in the <b>Workspace<\/b> window with the question mark in the column of status,<br \/>\nthis means thtat the file is not yet compiled.<\/li>\n<\/ul>\n<p><img title=\"ModelSim\" src=\"ModelSim\/5add.PNG\" alt=\"ModelSim\"><\/p>\n<p>Figure 5. Adding files to project.<\/p>\n<h4>Adding a new design file to the project<\/h4>\n<ul title=\"Adding a new design file to the project\">\n<li><b>File-&gt;Add to Project-&gt;New File&#8230;<\/b><\/li>\n<li>Specify the name of the file in <b>File Name<\/b> field.<\/li>\n<li>Select VHDL in the <b>Add file as type<\/b>.<\/li>\n<li>Select <b>Ok<\/b>. A new file will appear in the <b>Workspace<\/b> window with the question mark in<br \/>\nthe column of the <b>status<\/b>,<br \/>\nthis means that the file is not yet compiled.<\/li>\n<\/ul>\n<p>With double click on the design file in <b>Workspace<\/b> window you open the content of this file in the Source Code Editor.<\/p>\n<h4>Compiling your design<\/h4>\n<p>You can compile either all files together or every file separately.<\/p>\n<p>Compiling separately:<\/p>\n<ul>\n<li>Select design file you wish to compile from the list of the project files in <b>Workspace<\/b> window.<\/li>\n<li><b>Compile-&gt;Compile Selected<\/b><\/li>\n<\/ul>\n<p>Compiling together:<\/p>\n<ul>\n<li><b>Compile-&gt;Compile All<\/b> (remember that files should be in the proper order in the list)<\/li>\n<li><b>Compile-&gt;Compile Order<\/b> (order your design files according to dependencies)<\/li>\n<\/ul>\n<p>If your design contains errors, you&#8217;ll see the message [file name] failed with n error(s).<br \/>\nWith double click on this line the exact message of errors appears in the following format:<\/p>\n<p># ERROR: file_name(line_number): description&#8230;<\/p>\n<p>With double click on the error message ModelSim will open the source file in its Source Code Editor at the error line.<\/p>\n<h3>Simulation<\/h3>\n<h4>Starting the simulator<\/h4>\n<p>To invoke the simulator:<\/p>\n<ul>\n<li><b>Simulator-&gt;Start Simulation<\/b><\/li>\n<li>In the design tab find work library.<\/li>\n<li>In the work library find the topmost design&#8217;s testbench you wish to simulate.<\/li>\n<li>Be aware to uncheck the <b>Enable optimization <\/b> box.<\/li>\n<li>Select it and click <b>Ok<\/b>.<\/li>\n<\/ul>\n<p>Another way is according to Figure 6.<\/p>\n<p><img title=\"ModelSim\" src=\"ModelSim\/6simulation.PNG\" alt=\"ModelSim\"><\/p>\n<p>Figure 6. Simulation starting.<\/p>\n<p>The &#8220;loading&#8230;&#8221; message will appear in the main window to confirm that the files<br \/>\nhave loaded correctly. If you receive an error message asking to re-compile the testbench design, then you<br \/>\nhave compiled the files in the wrong order.<\/p>\n<h4>Organizing the display<\/h4>\n<p>Usually windows Workspace, Objects and Wave are used during simulation (Figure 7).<\/p>\n<ul>\n<li>Open Objects Window by <b>View-&gt;Debug Windows-&gt;Objects<\/b><\/li>\n<li>Open Wave Window by <b>View-&gt;Debug Windows-&gt;Wave<\/b><\/li>\n<\/ul>\n<p>You can also open other individual windows under <b>View<\/b> menu.<\/p>\n<p><img title=\"ModelSim\" src=\"ModelSim\/7wave.PNG\" alt=\"ModelSim\"><\/p>\n<p>Figure 7. Simulation view.<\/p>\n<h3>Viewing your design<\/h3>\n<h4>Travesing the design hierarchy<\/h4>\n<p>The design&#8217;s hierarchy can be traversed in the workspace window under tab <b>sim<\/b>.<\/p>\n<h4>Displaying signals and waveform window<\/h4>\n<p>For debugging purposes you can view signals within your design in the objects window. The waveform window displays the signals&#8217; current value as well as any history.<\/p>\n<p>To add the signals into the Wave window:<\/p>\n<ul>\n<li><b>Add-&gt;To Wave-&gt;Signals in Region<\/b>or<\/li>\n<li>Select signals in Object window. Then drag and drop selected signals to the Wave window.<\/li>\n<\/ul>\n<h3>Controlling the simulation<\/h3>\n<h4>Running simulation<\/h4>\n<p>You can run the simulation for a set amount of time by typing <b>run X<\/b> in the command<br \/>\nline of Main window, where X is the number of nanoseconds that you wish to run for.<br \/>\nIn example run for 100 ns:<b>VSIM &gt; run 100 ns<\/b><\/p>\n<p>Command <b>run<\/b> without specifying the time will execute simulation for the<br \/>\ndefault amount of time. You can set the default run period:<\/p>\n<ul>\n<li><b>Simulate-&gt;Runtime Options&#8230;<\/b><\/li>\n<li>Enter amount of time into the <b>Default Run<\/b> box.<\/li>\n<li>Select <b>Ok<\/b>.<\/li>\n<li><b>Simulate-&gt;Run-&gt;Run &#8220;default time&#8221; ns<\/b>.<\/li>\n<\/ul>\n<h4>Using the waveform display<\/h4>\n<p>Observe the behaviour of the design in the waveform display. You can zoom in and zoom out of<br \/>\nthe view of waveforms by clicking right mouse button and choosing the appropriate option. Also you can see the waveforms on the whole screen:<\/p>\n<ul>\n<li>Do a right click and choose <b>Zoom Full<\/b>.<\/li>\n<li>Highlight a signal, do a right click and choose <b>Radix<\/b> to change the display format.<\/li>\n<\/ul>\n<h4>Restart the Simulation<\/h4>\n<p>The simulation can be restarted to time 0 using the <b>restart<\/b> command. When this happens,<br \/>\nthe simulator reloads any re-compiled design files in the libraries. In this case,<br \/>\nas you have just re-compiled your edited source code into the work library, the simulator<br \/>\nwill restart using the modified code.<\/p>\n<ul>\n<li>Click in the main window to make it active.<\/li>\n<li><b>Simulate-&gt;Run-&gt;Restart<\/b><\/li>\n<li>Leave all of the options in set and click on the <b>Restart<\/b> button.<\/li>\n<\/ul>\n<p>The simulation time will be set back to zero. Note that the signals are still listed in the waveform display, but the<br \/>\nprevious waveforms are no longer displayed.<\/p>\n<h4>Quitting the simulator<\/h4>\n<p>When you have finished simulating:<\/p>\n<ul>\n<li><b>Simulate-&gt;End Simulation<\/b><\/li>\n<\/ul>\n<h2>Command line operation<\/h2>\n<p>The command line can be used as an alternative to the pull-down menus of the<br \/>\nGraphical User Interface for scripting and batch-mode operation. Only simple<br \/>\ncommand syntax is shown here. The Command Reference guide in the docs directory of the ModelSim<br \/>\ninstallation contains full details.<\/p>\n<h3>Commands<\/h3>\n<h4>Creating a compilation library<\/h4>\n<p>Create a physical compilation directory with <b>vlib<\/b>:<\/p>\n<ul>\n<li><b>vlib .\/work<\/b>Create a logical name for the physical directory with <b>vmap<\/b>:<\/li>\n<li><b>vmap work .\/work<\/b><\/li>\n<\/ul>\n<h4>Compiling your design<\/h4>\n<p>To compile VHDL design files you <b>vcom<\/b>:<\/p>\n<ul>\n<li><b>vcom mux.vhd<\/b><\/li>\n<\/ul>\n<h4>Starting the simulator<\/h4>\n<p>Start the simulator with <b>vsim<\/b> on the topmost design unit:<\/p>\n<ul>\n<li><b>vsim work.T_mux<\/b><\/li>\n<\/ul>\n<h4>Simulator User Interface<\/h4>\n<p>Use <b>view<\/b> to open all or selected window of the simulator interface:<\/p>\n<ul>\n<li><b>view *<\/b><\/li>\n<li><b>view wave<\/b><\/li>\n<\/ul>\n<h4>Add signals in the waveform window<\/h4>\n<p>Use <b>add wave<\/b> to add selected signals, or all the signals in the selected region<br \/>\nto the waveform viewer.<\/p>\n<ul>\n<li><b>add wave \/t_mux\/uut\/*<\/b><\/li>\n<\/ul>\n<h4>Running the simulation<\/h4>\n<p>The simulation is started by typing <b>run X<\/b> in the main window, where X is the<br \/>\nnumber of nanoseconds that you wish to run for:<\/p>\n<ul>\n<li><b>run 100 ns<\/b><\/li>\n<\/ul>\n<h4>Restart simulation<\/h4>\n<p>Restart keeping all the current display formats:<\/p>\n<ul>\n<li><b>restart -f<\/b><\/li>\n<\/ul>\n<h4>Quitting the simulator<\/h4>\n<p>When you have finished simulating quit the simulator:<\/p>\n<ul>\n<li><b>quit -sim<\/b><\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>Before we start In the lab class we need to luckyladyschoose the configuration for the environment jack and the beanstalk slot machine which allows us to use ModelSim. The command for the environment choices is cad. The command must be entered twice. To select ModelSim choose option 2 (Mentor Graphics 2018 EDA version). Another important [&#8230;]<\/p>\n","protected":false},"author":1,"featured_media":0,"parent":1269,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":[],"_links":{"self":[{"href":"http:\/\/priit.ati.ttu.ee\/index.php?rest_route=\/wp\/v2\/pages\/2033"}],"collection":[{"href":"http:\/\/priit.ati.ttu.ee\/index.php?rest_route=\/wp\/v2\/pages"}],"about":[{"href":"http:\/\/priit.ati.ttu.ee\/index.php?rest_route=\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"http:\/\/priit.ati.ttu.ee\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/priit.ati.ttu.ee\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=2033"}],"version-history":[{"count":11,"href":"http:\/\/priit.ati.ttu.ee\/index.php?rest_route=\/wp\/v2\/pages\/2033\/revisions"}],"predecessor-version":[{"id":2743,"href":"http:\/\/priit.ati.ttu.ee\/index.php?rest_route=\/wp\/v2\/pages\/2033\/revisions\/2743"}],"up":[{"embeddable":true,"href":"http:\/\/priit.ati.ttu.ee\/index.php?rest_route=\/wp\/v2\/pages\/1269"}],"wp:attachment":[{"href":"http:\/\/priit.ati.ttu.ee\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2033"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}