Install Lattice Diamond

Lattice Diamond is developed on Red Hat and is not officially supported on Ubuntu; however with some persuasion, it can be made to work.

 

Start by downloading the Lattice Diamond Linux package here: https://www.latticesemi.com/Products/DesignSoftwareAndIP/FPGAandLDS/LatticeDiamond

 

The main point of difference is the package management system on Red Hat versus Ubuntu. Red Hat is RPM based (.rpm) while Ubuntu is a Debian system (.deb), so the first step is to convert the .rpm Lattice Diamond software package to a .deb

 

Alien is a common, reliable application for converting files to Debian packages (read more here: https://en.wikipedia.org/wiki/Alien_(file_converter)). If not already present on your system, install it:

 

~$ sudo apt install alien

 

Then point it to the Lattice Diamond software package .rpm for it to convert. Be sure to use the scripts option so that it includes all scripts in the package.

 

~$ sudo alien --scripts ./Downloads/diamond_3_12-base-240-2-x86_64-linux.rpm

 

Unless otherwise specified, alien will output the converted Debian package to the ~ home directory, where you can then use the usually dpkg package manager to install it.

 

~$ sudo dpkg -i ./diamond-3-12-base_3.12-241_amd64.deb 

 

 

While Lattice Diamond is free to use, you still need to generate a license file for it which can be done here:

https://www.latticesemi.com/Support/Licensing/DiamondAndiCEcube2SoftwareLicensing/DiamondFreeFloatingLicense

 

Once you’ve received the license file from Lattice in your email, move it to the license folder in the installation directory of the Lattice Diamond software:

 

~$ sudo mv ./Downloads/license.dat /usr/local/diamond/3.12/license

 

The file needs a few tweaks to understand/verify your system. On line 1, replace the nodename variable with the host name of your machine (which is the name that appears between the @ symbol and : in the Linux command line. For example, user@hostname:~$).

 

On line 2, replace the daemon_path variable with the following:

 

/usr/local/diamond/3.12/ispfpga/bin/lin64

 

And finally, on line 18, replace the daemon_path variable with

 

/usr/local/diamond/3.12/modeltech/linuxloem

 

Save and close the license file. Then finally, create a blank log file for the license manager to use:

 

~$ sudo vi /usr/local/diamond/3.12/license/license.log

 

Start the License Manager

Before Lattice Diamond can be launched (whether it be the GUI or from the command line) the license manager must be running to confirm to the software that a valid license is present.

 

~$ /usr/local/diamond/3.12/ispfpga/bin/lin64/lmgrd -l /usr/local/diamond/3.12/license/license.log -c /usr/local/diamond/3.12/license/license.dat

 

However, you might get an error like this:

 

bash: /usr/local/diamond/3.12/ispfpga/bin/lin64/lmgrd: No such file or directory

 

A bash error thrown by an executable in this context usually means that a dependency is missing. To determine what’s missing, use the LDD command to print the shared library dependencies of the executable throwing the error:

 

~$ ldd /usr/local/diamond/3.12/ispfpga/bin/lin64/lmgrd

 

Libraries expected by the executable appear on the left side of the => operator while the corresponding libraries present on the system appear on the right side of the => operator.

 

The LDD command shows that the lmgrd command called by Lattice Diamond is expecting the Linux Standard Base (LSB) library, but it is currently not present on my Ubuntu machine. So I can resolve this by installing it:

 

~$ sudo apt-get install lsb 

 

 

Once the missing dependency is resolved, the license manager should start right up and immediate return the command line back for you to then be able to launch the Lattice Diamond software:

 

 

Run Lattice Diamond from the Command Line

The Lattice Diamond software can be launched as either its GUI or just have the tools sourced to run in the background and be called from the command line. To launch source the tools and just have them running as a background task, pass the & symbol at the end of the command like below:

 

~$ /usr/local/diamond/3.12/bin/lin64/diamond &

 

Run Lattice Diamond GUI

To launch the GUI itself, simply pass the following command:

 

~$ /usr/local/diamond/3.12/bin/lin64/diamond 

 

 

 

 

 

 

 

Create New Project

Click the New... option from the Start Page window to create a new project and follow the prompts:

 

 

Name the project and select desired file path location:

 

 

Download the TinyFPGA A1 template files here: https://tinyfpga.com/a-series-guide.html Add the top level Verilog file to the project and the pinout file (.LPF) for the TinyFPGA A1.

 

 

Select the FPGA part number for the TinyFPGA A1 which is MachXO2, LCMXO2-256HC, performance grade 4, QFN32 package type, commercial, LCMXO2-256HC-4SG32C part name.

 

 

Select Lattice LSE for the synthesis tool. 

 

 

Finally, review and verify the project settings information before clicking ‘Finish’. 

 

 

Add the desired code to TinyFPGA Verilog file, TinyFPGA_A1.v, found under the Input Files folder in the File List tab.

 

 

If your custom code changes the top level signal names or the number utilized, be sure to also update the pinout constraints file. It is also found in the File List tab in the LPF Constraints Files folder as template_a1.lpf

 

 

After making the desired modifications, save the top level Verilog file and pinout constraints file then run synthesis, place & route, and generate a bitstream. Switch over to the Process tab, right-click on JEDEC File under Export Files and select Rerun All.

 

 

Program TinyFPGA

With the bitstream ready, it’s time to program the FPGA on the TinyFPGA board with it. You must use the Python programmer from TinyFPGA versus the Programmer in Lattice Diamond as it doesn’t work in Ubuntu due to conflicts with the USB serial driver and FTDI chip driver.

 

First, make sure the following dependencies are installed on your machine:

 

~$ sudo apt-get install python-tk

~$ pip install serial

~$ pip install pyserial

~$ pip install tinyfpga

 

Then clone the TinyFPGA Programmer Application from its repository:

 

~$ git clone --recursive https://github.com/tinyfpga/TinyFPGA-Programmer-Application.git

 

Supply power to the TinyFPGA and connect it to your host machine:

Change directories into the top level file and run the main Python script to launch the programmer:

 

~$ cd ./TinyFPGA-Programmer-Application

~$ python tinyfpga-programmer-gui.py

 

First select the TinyFPGA USB device from the drop down box at the top. Then click the Select File button then navigate to the bitstream file generated in Lattice Diamond, it’ll be located at /<project directory>/impl1/<project_name>.jed

 

 

Finally, click Program FPGA and wait for the Success notification text below the status bar. Click Exit Bootloader once done.