+++
title = "Unified FPGA toolchain script"
tags = ["Embedded", "FPGA", "Python"]
date = "2022-09-11"
+++

[View project on gitea](https://git.joppeb.nl/joppe/remotesyn)

The vendor provided toolchains for FPGA’s… a nuisance for the most of us but unfortunately unreplacable! (Yes, I know. There are a few open source alternatives and they are very promising but I think everybody can agree that for a lot of devices the open source toolchains are not as mature as the vendor provided ones). Me not being a big fan of slow and unresponsive GUIs (yes, looking at you Vivado!) I always reach out to the command line tools the vendors provide and with a bunch of scripts the whole workflow can be done from the command line and the project source tree becomes more version controllable. There I was, a bunch of clunky scripts which needed fix after fix and big changes from project to project wishing there was a better way to do this. After some searching some tools came up and they are awesome (think of TerosHDL for VSCode and fusesoc) but they all missed one thing: the option for remote building on my big PC at home while I am working on my old and low laptop somewhere else. In the scripts I wrote I used SSH and a lot of copying files from one side to the other to provide this option but every project had its own set of scripts.

That’s why I came up with the plan to write one tool for all projects, be it with Quartus, the old ISE, Vivado, just simulation or even formal verification with SymbiYosys. A single project configuration file is used to define the actions which could be locally or remotely executed and with the setup of the code of the tool, new FPGA toolchains or other action types can be easily added when they are needed.

```ini
[project]
name                = spartan6_project
version             = 0.1
out_dir             = OUT
build_dir           = BUILD

# Basic synthesis
[target.synth]
toolchain           = ISE
family              = spartan6
device              = xc6slx9
package             = tqg144
speedgrade          = -2
toplevel            = toplevel

files_vhdl          = RTL/toplevel.vhd
files_con           = CON/toplevel.ucf

# Behavioural simulation
[target.sim]
toolchain           = ghdl
toplevel            = tb_toplevel
runtime             = all

files_vhdl          = RTL/toplevel.vhd
                      SIM/tb_toplevel.vhd
```

With this simple configuration file the execution of ‘rbuild synth’ will run the full Xilinx ISE toolchain and ‘rbuild sim’ will run GHDL and perform a behavioral simulation. Deciding to move to a different device from a different vendor? Instead of creating a whole new project in the vendor specific toolchains or creating a bunch of new scripts the only thing which must be done is changing a few lines in the project configuration file (not counting the device specific parts of the design of course).

I have not used the tool itself that much yet but that will definitely change pretty soon and I will keep adding and updating the actions when I need to. One last thing must se said I suppose: even though the remote building can be pretty useful it also provides a way to share one installation with multiple people (which is cool but you’ll probably be walking a legally grey line with it) . Using the tool for remote building (or any other set of tools) could potentially void licensing and EULA agreements so some research has to be done (or ignore it and we’ll all find out soon if it has consequences or not).