Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save IordanisKostelidis/ce2f85f01c7683561d4fb85f4a173056 to your computer and use it in GitHub Desktop.

Select an option

Save IordanisKostelidis/ce2f85f01c7683561d4fb85f4a173056 to your computer and use it in GitHub Desktop.

Running Quartus + Questa on Apple Silicon

The current methods to run an Intel FPGA workflow on Apple Silicon involve two possibile approaches:

  • Using a WoA Virtual Machine: Performance is terrible (already in amd64 Windows platforms is terrible, adding a virtualization layer on top of it leads to eternal compilation times) + space wasted for all the Microsoft bloatware
  • Using a Docker Container: Performance is better than WoA, but the USB drivers are not working

Running Ubuntu on UTM with Rosetta enabled should tackle these problems

Configuring the virtual machine

Enabling persistent Rosetta 2 on Ubuntu Guest

  • Create the required directory for the Rosetta mount:
sudo mkdir /media/rosetta
  • Create a new file in the home directory (e.g. rosetta.sh) and copy the following script:
#!/bin/sh
sudo mount -t virtiofs rosetta /media/rosetta
sudo /usr/sbin/update-binfmts --install rosetta /media/rosetta/rosetta \
     --magic "\x7fELF\x02\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x3e\x00" \
     --mask "\xff\xff\xff\xff\xff\xfe\xfe\x00\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff" \
     --credentials yes --preserve no --fix-binary yes
  • Create a new service file for the Rosetta service on /etc/systemd/system/rosetta.service:
[Unit]
Description=Enable Rosetta 2 Translation Layer

[Service]
Type=oneshot
ExecStart=/bin/sh /home/[your username]/rosetta.sh

[Install]
WantedBy=multi-user.target
  • Enable the Rosetta service on boot:
systemctl enable rosetta.service
  • Reboot the virtual machine

Installing dependencies

  • Edit /etc/apt/sources.list file and add multiarch repositories
deb [arch=amd64] http://archive.ubuntu.com/ubuntu/ jammy main restricted
deb [arch=amd64] http://archive.ubuntu.com/ubuntu/ jammy-updates main restricted
deb [arch=amd64] http://archive.ubuntu.com/ubuntu/ jammy universe
deb [arch=amd64] http://archive.ubuntu.com/ubuntu/ jammy-updates universe
deb [arch=amd64] http://archive.ubuntu.com/ubuntu/ jammy multiverse
deb [arch=amd64] http://archive.ubuntu.com/ubuntu/ jammy-updates multiverse
deb [arch=amd64] http://security.ubuntu.com/ubuntu jammy-security main restricted
deb [arch=amd64] http://security.ubuntu.com/ubuntu jammy-security universe
deb [arch=amd64] http://security.ubuntu.com/ubuntu jammy-security multiverse
  • Install the required libraries for Quartus
sudo apt update
sudo apt install libbz2-1.0:amd64 binutils:amd64 libglib2.0-0:amd64 libnsl-dev:amd64 g++-multilib:amd64 libfontconfig:amd64 libx11-xcb1:amd64 libxext6:amd64 libsm6:amd64 libdbus-1-3:amd64 libxft2:amd64 libxtst6:amd64 libxi6:amd64 libgtk2.0-0:amd64

These libraries where tested for Quartus 23.1std, if for other versions Quartus crashes (cli outputs aborted (core dumped)), use strace to debug for missing libraries

Patching Quartus Installer

The installation script for Quartus checks if SSE3 instruction are supported on the current CPU, the main problem is that this script doesn't run on the Rosetta environment, failing the checks.

  • Run the Quartus installer with the following arguments: ./qinst-lite-linux-23.1std.1-993.run --confirm
  • When asked to run the installer, DO NOT ENTER ANYTHING, copy the extracted installer located in /tmp in a known directory
  • Select to not run the installer, the script should clean the tmp directory
  • Edit the script located in ./adm/qenv.sh and add the following before the line containing # We don't support processors without SSE extensions (e.g. Pentium II and older CPUs).
if test `uname -m` = "aarch64" ; then
	export QUARTUS_BIT_TYPE=64
fi
  • In the current terminal window, run this command to skip CPU checks during installation: export QUARTUS_CPUID_BYPASS=1
  • Run the installation script, a GUI window should appear

Patching Quartus installation

After the installation has completed, open the installation directory (should be located in the home directory) and edit ./23.1std/quartus/adm/qenv.sh:

  • Add the following before the line containing # We don't support processors without SSE extensions (e.g. Pentium II and older CPUs).
if test `uname -m` = "aarch64" ; then
	export QUARTUS_BIT_TYPE=64
fi
  • Comment out the lines between # We don't support processors without SSE extensions (e.g. Pentium II and older CPUs). and ##### Determine what bitness executables we should use

Installing the license file

  • Obtain all the required licenses for the current setup from the Self-Service portal
  • Copy the generated license file in a known directory
  • Edit .bashrc, adding the following contents at the end of the file:
export LM_LICENSE_FILE='/home/[your username]/[your_license_file].dat' 
export PATH=$PATH:/home/[your username]/intelFPGA_lite/23.1std/questa_fse/linux_x86_64/ 

Now Quartus can be run from the desktop shortcut, while Questa can be run by using vsim on a terminal window.

Benchmarks

The same project was compiled on different machines (a VHDL digital filter), obtaining the following compilation times:

  • Windows on i7 10th gen host: 3min 23s
  • Macbook Air M2 - WoA + Parallels: 6min 18s
  • Macbook Air M2 - Docker: 2min 02s
  • Macbook Air M2 - Ubuntu + Rosetta: 1min 24s
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment