ModelSim ENG
Contents
Before we start
Go to your project directory in the linux command line by using command cd
Example:
cd ~/P/lab_1
If your target directory does not exist, you can create it with command mkdir
Example:
mkdir -p /P/lab_1
IT IS HIGHLY SUGGESTED to develop your code in the ~/Desktop directory.
After you completed your work move (mv) or copy (cp) your work to the ~/P folder.
In the lab class, we need to set up the Linux command line environment, 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 2021 EDA version).
Another important note to remember is that ModelSim doesn’t support CTRL+c shortcut.
Starting ModelSim
To start the program, you must insert the command
vsim &
The & in the end of the command shows that the program is run in the background and the
prompt is returned immediately. It means that to run another process, you don’t have
to open a new command line window. You can use & behind every process command.
If you forgot to change your working directory before, it is also possible to do it now.
File->Change Directory
Navigate to the directory containing your design files
Ok
Compiling the design
To compile your design you can either create a new project and compile the files
in the project or just compile every file without creating a project. Somewhat
easier is to create a new project. This gives you the chance to open the project
later without any need to specify the files in there or the library used.
Option1: Compilation without project creation - preferred
Creating a compilation library
A compilation library is a directory on your disk into which all HDL designs are compiled.
You can specify this library through the ModelSim or it can be created using operation system
commands. Usual library name is work. Now lets create a directory called work
and map the directory to the logical library named work.
- File->New->Library
- Select Create a new library and a logical mapping to it (Figure 2).
- Type work into the library form. Note that it’s duplicated.
- Select Ok.
- Verify that the directory with the name work has been created in your lab directory.
Figure 2. Creating new work library
Compiling your design
Now lets compile the design.
For example we’ll take the lab1 mux.vhd VHDL file.
- Compile->Compile…
- The following dialog box appears (Figure 3).
- Make sure that Library is set to work.
- Select the design file you want to compile, for example mux.vhd and then click Compile.
- Check the main ModelSim window for the results of compilation.
Figure 3. Compiling source files
Option2: Compiling with project creation - WIP
Simulation
Starting the simulator
To invoke the simulator:
- Simulator->Start Simulation
- In the design tab find work library.
- In the work library find the topmost design’s testbench you wish to simulate.
- Be aware to uncheck the Enable optimization box.
- Select it and click Ok.
Another way is according to Figure x.