smilingspider

Just another WordPress.com site

Category Archives: Tools

Tool’s hell part I: setting up ModelSim with Altera’s libraries under Win 7. Quartus II ver 9.x and up.

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.

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

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).

msconsole

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.

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:

vlib cyclone
vmap cyclone cyclone
vcom -work cyclone -2002 -explicit $path_to_quartus/eda/sim_lib/cyclone_atoms.vhd
vcom -work cyclone -2002 -explicit $path_to_quartus/eda/sim_lib/cyclone_components.vhd

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!

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:

lpm = $MODEL_TECH/../altera/vhdl/lpm

altera_mf = $MODEL_TECH/../altera/vhdl/altera_mf
altera = $MODEL_TECH/../altera/vhdl/altera
sgate = $MODEL_TECH/../altera/vhdl/sgate
altgxb = $MODEL_TECH/../altera/vhdl/altgxb
cyclone = $MODEL_TECH/../altera/vhdl/cyclone
cycloneii = $MODEL_TECH/../altera/vhdl/cycloneii
cycloneiii = $MODEL_TECH/../altera/vhdl/cycloneiii
max = $MODEL_TECH/../altera/vhdl/max
maxii = $MODEL_TECH/../altera/vhdl/maxii
stratix = $MODEL_TECH/../altera/vhdl/stratix
stratixii = $MODEL_TECH/../altera/vhdl/stratixii
stratixiii = $MODEL_TECH/../altera/vhdl/stratixiii
stratixgx_gxb = s$MODEL_TECH/../altera/vhdl/tratixgx_gxb
stratixiigx = $MODEL_TECH/../altera/vhdl/stratixiigx
stratixiigx_hssi = $MODEL_TECH/../altera/vhdl/stratixiigx_hssi
arriagx = $MODEL_TECH/../altera/vhdl/arriagx
arriagx_gxb = $MODEL_TECH/../altera/vhdl/arriagx_gxb

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.

msim

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

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.