Modelsim Altera

I frequently find myself deep in tool’s hell trying to set up a program for my engineering needs, it’s a common and necessary step in the design cycle, that’s reasonable. Unfortunately, the amount of time I invest in such triviality is, more than often, just ridiculous.

  1. Modelsim Altera Starter Edition
  2. Modelsim Altera

Modelsim Altera Starter Edition

If you are into hardware design, you’ll have a good grasp of the kind of tools we, hardware designers, must deal with on a daily basis. I’ve a strong opinion about these tools. I’m aware that they get the work done, but c’mon, most of them look ugly, have an awkward graphical interface and love to install the “hard way”, let’s address that right away and leave the opinions for later.

ModelSim, nice, advanced verification, eh?

This first post will be a mini guide in how to (quickly!) set up everyone’s favorite HDL simulator, ModelSim. If you’re having trouble with mentor graphics’ finest, follow this guide and you should be investing countless hours of waveform debugging in no time.

First Circle: The basics

This is the scenario I faced while trying to install this thing: I’m working with Altera Quartus II 9.1 Web Edition; I tried installing Quartus II version 9 through 11, and version 9.1 was the only one I could get working under windows 7 (64-bit).

ENSC 350 ModelSim Altera Tutorial This is a quick guide get you started with the ModelSim Altera simulator. ModelSim is only a functional verification tool so you will also have to use Quartus II to complete timing analysis on your design before you can be sure it will work the DE2 hardware. ModelSim Basic Simulation (Optional).

  1. Download Quartus Prime software, and any other software products you want to install, into a temporary directory. Download device support files into the same directory as the Quartus Prime software installation file. Change the file permission for all the setup (.run) files by running the command: chmod +x.run.
  2. MORE THAN A TUTORIAL -A DEMO QUARTUS II / MODELSIM MODELSIM ECE232 Altera/ModelsimTutorial Design an 8 bit CLA Adder Delay computation for P iandGiandCi P ⊕ i = Xi Yi Gi = Xi & Y i Ci+1 = Gi+PiCi.

ModelSim console (FATAL) error. With bonus ambiguous signal value warning.

Now, you may be aware that Altera has its own ModelSim “edition”, called ModelSim-Altera. The main advantage of this edition is that it has all of Altera’s libraries built-in right out the box, so no need to mess with that, but if you’re out of luck (like myself) installing a Modelsim-Altera version compatible with Quartus II ver 9.1 will surely fail for whatever reason.

The only solution left is to use a stand-alone version of ModelSim (whichever version you hate the less) and manually compile Altera’s libraries and link them to ModelSim’s configuration files.

Altera

This is what we’re going to do:

  1. Install ModelSim.
  2. Find out which Altera libraries we need.
  3. Modify a ModelSim script to compile the libraries that we need
  4. Link the libraries to ModelSim’s configuration files.

Second Circle: Getting our hands dirty

Let’s get this show started. After successfully installing ModelSim you’ll need to browse the following directory path_to_quartus/eda/sim_lib and take note of its contents, you should identify the FPGA/device of your interest and take note of the exact filename because this is the library we will include in our automated script later (the extension could be either .vhd or .v for verilog). You can also compile for all the devices available. I’m working with VHDL, so I identify all the files with .vhd extension, it should be the same for Verilog files.

Next, download this handy script and open it with your favorite text editor (please, do not use notepad). We will run this script from ModelSim’s console to compile all our libraries. The script must include the exact same paths of the files you identified in the previous step. Be sure to modify the following line: path_to_quartus with the actual Quartus path you got.

Now, as an example, in the /eda/sim_lib directory, I’ve identified the cyclone family as a potential must-include FPGA library on ModelSim, so I’ve added the following lines to the script:

You can manually type or uncomment the line of your interest inside the script. Remember that # is the comment identifier on ModelSim scripts. Be sure to include stuff that actually exists in the /eda/sim_lib directory, otherwise your compilation will fail, and that will probably make you sad for a while, but worry not, you can always try again!

Modelsim

Once ready, we’ll head to ModelSim’s application directory, in my case rootDrive/modeltech_6.5b inside, we will create the following subdirectories /altera/vhdl here we’ll place our nifty little script.

Fire up ModelSim and change directory to where the script is located, once there, simply type the following: do vhdl-library-setup.tcl in the console, the script should start execution. It will take a while, depending on how many libraries you’ve included inside the script.

After ModelSim is done, close it and browse to your rootDrive/modeltech_x.x/ directory, we’re looking for modelSim’s configuration file, modelsim.ini we will modify it. It might be set to read-only, be sure to modify that file attribute beforehand.

It may be wise to make a backup copy of modelsim.ini just in case things get hairy after our modifications. Ok, now take a look inside the ini file and identify the [Library] configuration block, we will add some lines after sv_std = $MODEL_TECH/../sv_std and before the [vcom] block.

Now, we will link each library that was created in the /altera/vhdl path with a variable, this is easy, for the script provided, I’ve included the following lines:

We’re adding just the name of the library to the path where it was compiled, again, make sure you’re adding actual directories you created in the rootDrive/modeltech_x.x/ altera/vhdl path and make sure to not repeat variable names.

Third Circle: Wrapping it up

Once done, save and start ModelSim, you should see our newly compiled libraries right in ModelSim’s main library tab. Success, you should be able to painfully debug Altera components now.

ModelSim simulating a 10 hour-long run. Note the uglytraditional wave editor.

Modelsim Altera

This is all for now, tool configuration is a pain in the arse, but it is something that must be done, hopefully this guide will help you to do it as quickly as possible. I promise a more “action-oriented” post the next time.