How to setup Lattice/Modelsim on Linux (Ubuntu 20.04)
Its a well known fact that verification by simulation (and of course other methods such as formal tools etc.) are highly recommended in order to validate an RTL design before it even hits the lab bench.
Lattice Semiconductor in their latest update of the Radiant toolchain bundled the Modelsim tools and removed support for Aldec. While Modelsim ran with no issues on Windows, I had to jump through a few hoops to get it to work on Linux. This blog covers the incantations required to successfully run Modelsim on Linux.
The open source tools such as Icarus Verilog are excellent and free. However, they are also somewhat limited as far as SystemVerilog support goes. Also, there are sometimes crashes of the simulator that left me frustrated trying to find out what caused the crash. Another very good reason to use Modelsim is the need to use a commercial simulator that can decrypt IP cores distributed with the Lattice tools. These cannot be simulated by the open source tools.
Summary
- Lattice tools ship with the 32 bit Modelsim version
- Lattice and Modelsim directory structures differ
- Modelsim license settings need to be tweaked
Initial Setup
Download the Radiant tools from the Lattice website after registering for an account. The tools can be installed in the users home directory or in a more usual place like /usr/local. I chose to install the Lattice tools in my home directory, this is probably poor Linux practice!) The Modelsim files are located at: /lscc/radiant/2.2/modeltech/linuxloem
This is not where the Modelsim scripts located at ~/lscc/radiant/2.2/modeltech/bin
expect it to be.
I created a soft link:
cd ~/lscc/radiant/2.2/modeltech/; ln -sf linuxloem linux_x86_64;
OK, next, the vcom refused to run and complained about 32 bit libraries. I had a 64 bit install. Lets see what kind of file it is:
<code>
file vcom
vcom: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), dynamically linked, interpreter /lib/ld-linux.so.2, for GNU/Linux 2.6.18, BuildID[sha1]=86e420fbff866af1daddc6baa53f93f07c313849, stripped
Lets install the 32 bit libraries it wants:
sudo apt-get install lib32z1
$ ./vsim
./vish: error while loading shared libraries: libXext.so.6: cannot open shared object file: No such file or directory
apt-file search libXext.so.6
libxext6: /usr/lib/x86_64-linux-gnu/libXext.so.6
libxext6: /usr/lib/x86_64-linux-gnu/libXext.so.6.4.0
libxext6-dbg: /usr/lib/debug/usr/lib/x86_64-linux-gnu/libXext.so.6.4.0
$ ldd vsim
linux-gate.so.1 (0xf7eec000)
libdl.so.2 => /lib32/libdl.so.2 (0xf7ece000)
libm.so.6 => /lib32/libm.so.6 (0xf7dca000)
libpthread.so.0 => /lib32/libpthread.so.0 (0xf7da7000)
libc.so.6 => /lib32/libc.so.6 (0xf7bbc000)
/lib/ld-linux.so.2 (0xf7eee000)
$ export LD_LIBRARY_PATH=/usr/lib/x86_64-linux-gnu
vrangan@ravana:~/lscc/radiant/2.2/modeltech/linux_x86_64$ echo $LD_LIBRARY_PATH
/usr/lib/x86_64-linux-gnu
vrangan@ravana:~/lscc/radiant/2.2/modeltech/linux_x86_64$ ./vsim
./vish: error while loading shared libraries: libXext.so.6: wrong ELF class: ELFCLASS64
$ sudo apt-get install libxext6:i386
$ ls /usr/lib/i386-linux-gnu/libX*
/usr/lib/i386-linux-gnu/libX11.so.6 /usr/lib/i386-linux-gnu/libXdmcp.so.6
/usr/lib/i386-linux-gnu/libX11.so.6.3.0 /usr/lib/i386-linux-gnu/libXdmcp.so.6.0.0
/usr/lib/i386-linux-gnu/libXau.so.6 /usr/lib/i386-linux-gnu/libXext.so.6
/usr/lib/i386-linux-gnu/libXau.so.6.0.0 /usr/lib/i386-linux-gnu/libXext.so.6.4.0
$ export LD_LIBRARY_PATH=/usr/lib/i386-linux-gnu
vrangan@ravana:~/lscc/radiant/2.2/modeltech/linux_x86_64$ ./vsim
./vish: error while loading shared libraries: libXft.so.2: cannot open shared object file: No such file or directory'
$ apt search libXft
Sorting... Done
Full Text Search... Done
libxft-dev/focal 2.3.3-0ubuntu1 amd64
$ sudo apt-get install libxft-dev:i386
</code>
Running simulations:
<code>
vsim -c -warning vsim-3009 -t ps -do "run -all; quit" work.tb_cpi -L lifcl
Reading pref.tcl
# 2020.3
# vsim -c -warning vsim-3009 -t ps -do "run -all; quit" work.tb_cpi -L lifcl
# Start time: 10:20:52 on Mar 16,2021
#
# ** License Issue: License request for latticemsim feature failed
# ** License Issue: No such feature exists. (/home/vrangan/lscc/radiant/2.2/modeltech/linuxloem/mgls/etc/cust/mgc/mgc.licenses)
# ** Error: Failure to obtain a Verilog simulation license. Unable to checkout any of these license features: 'latticemsim' or 'alteramtivlog'.
# Error loading design
Error loading design
</code>
Looks like the lattice license files isnt visible:
Lets copy the latticemsim line from the Lattice license file to the Modelsim License file and see if that works:
/home/vrangan/lscc/radiant/2.2/modeltech/linuxloem/mgls/etc/cust/mgc/mgc.licenses
Success!
Lets do this the right way:
<code>
export LM_LICENSE_FILE=$HOME/lscc/radiant/2.2/license/license.dat
</code>
Now everything seems right and works, Yay!