Synthesis guide

From Zet
Jump to: navigation, search

This guide is a description on how to synthesize Zet with Quartus II in Linux for the Altera board, as this is the OS used for Zet development. You don't need to be root at any moment.

Downloading and installing Quartus II

First, we need to get Quartus II for Linux from the Altera website, which is free of charge and doesn't need any license. The latest version in the time of writing is 11.1 SP2. To do this:

  1. Go to altera.com and then click on the upper right link "Download Center".
  2. In the Download Individual Components section, Step 1 we select Quartus II Web Edition, Step 2, we select the latest version at the moment (11.1 Service Pack 2), then Step 3, view download.
  3. We click on the file 11.1sp2_quartus_free_linux.sh which is a 3.0GB file.
  4. Now, we can create a one-time access, by entering an email address (any address will work) and the download will start. It's a 3.0 Gb file :) We choose to download it at ~/Downloads for example.
  5. Once downloaded, we untar it. So we open a terminal window:
cd ~/Downloads
chmod 755 11.1sp2_259_quartus_free_linux.sh
./11.1sp2_259_quartus_free_linux.sh

This will probably fail in Ubuntu with the following message:

./setup: 1: Syntax error: "&" unexpected

To avoid this, change the /bin/sh link to /bin/bash:

sudo ln -sf bash /bin/sh

Now, run it again:

cd 11.1sp2_259_quartus_free_linux/
./setup $(cat .setup_args)

A graphical installer will appear:

  • The first is a welcome screen, we click on Next >.
  • 2nd you agree on the license terms. Click it and Next >.
  • 3rd you choose the installation directory, in my case I usually leave it as /home/zeus/opt/altera/11.1sp2. Then Next >.
  • 4th choose the devices families. We can click on Cyclone II, III and IV and leave the others unselected, as we don't support them. Then Next >.
  • 5th review and click Next >. The installation starts and eventually ends.
  • 6th there is a prompt asking you to activate TalkBack, where you can deactivate it and click ok.
  • 7th the installation asks you if you want to remove the temporary files. You can click on Yes.
  • 8th we unclick Start Quartus II 11.1sp2 and Get Quartus II Subscription License. Then click on Finish.

We can try to run it by executing: ~/opt/altera/11.1sp2/quartus/bin/quartus. It can fail with the following message: bash: warning: setlocale: .... To fix it just run this command:

sudo locale-gen en_US en_US.UTF-8

Now exit the terminal and open a new one again. It should work now.

Setting up the USB permissions for the Quartus Programmer

In order to flash the FPGA the USB bus has to have permissions to be accessed by the normal user. To do that:

sudo su -
echo ATTR{idVendor}==\"09fb\", ATTR{idProduct}==\"6001\", MODE=\"666\" > /etc/udev/rules.d/51-usbblaster.rules
udevadm control --reload-rules

Downloading and Installing Open Watcom

To be able to synthesize Zet, you need the boot rom, which is generated using the Watcom installer. The latest version in the time of writing is 1.9.

  1. Go to openwatcom.org and click on Download on the section Latest Release.
  2. Click on the DOS, Windows, OS/2, Linux version in any server close to you. This will bring you to the FTP/HTTP directory
  3. Download the file open-watcom-c-linux-1.9 and save it at ~/Downloads.
  4. Once downloaded, we can run it:
cd ~/Downloads
chmod 755 open-watcom-c-linux-1.9
TERMINFO=/lib/terminfo ./open-watcom-c-linux-1.9

A text mode installation will appear:

  1. We choose I Agree when the license terms appear.
  2. Then it shows a prompt asking the installation path, where we write something like this: /home/zeus/opt/ow-1.9. And then click on Next >>.
  3. We select a Full installation and then click on Next >>.
  4. It says that will copy all selected files. We click on Next >>.
  5. The installation ends. We accept to exit the installation program.

We have to change the PATH environment variable and the WATCOM variable as well. To do this, we edit the ~/.bashrc file and add these two lines:

export PATH=$PATH:$HOME/opt/ow-1.9/binl
export WATCOM=$HOME/opt/ow-1.9

We save, exit and reopen the terminal.

Synthesizing Zet

To synthesize Zet, we'll use the GIT version, which is the development one. You can do the same using the Release .tar.bz2 or .zip files in the webpage.

  • First we need git and php5-cli installed:
sudo apt-get install git php5-cli
  • We clone the Zet repository:
cd ~
git clone git://github.com/marmolejo/zet.git
  • Build the BIOS. The boot rom is necessary to synthesize Zet:
cd ~/zet/src/bios
wmake
  • Then build the microcode ROM:
cd ~/zet/cores/zet/rtl
../bin/micro2rom < altera/microcode.txt

Now we can do the actual synthesis.

  • We can launch Quartus II by executing: ~/opt/altera/11.1sp2/quartus/bin/quartus. A dialog box will appear, we choose to run Quartus II.
  • Inside the program, we choose to open the project ~/zet/boards/altera-de2-115/syn/kotku.qpf, considering that we have the Altera DE2-115 board and we click on the play icon to build the FPGA bitstream. This process will take about 20 minutes and it will result with the files kotku.sof and kotku.pof (in directory ~/zet/boards/altera-de2-115/syn/) for direct configuration and persistent FPGA bitstream config.

Installing the system

To flash the BIOS:

  1. Plug the USB Blaster cable to the board and the PC and switch the RUN/PROG switch on the board to RUN position. Then, turn it on. Run the following:
cd ~/zet/boards/altera-de2-115/bin
wget -O flash_bios.sof http://zet.aluzina.org/images/1/12/Flash_bios-de2-115.sof
~/opt/altera/11.1sp2/nios2eds/nios2_command_shell.sh ./flash_bios.sh

To flash the bitfiles:

  1. Plug the USB Blaster to the board and the PC and switch the RUN/PROG switch on the board to PROG position. Then, turn it on.
  2. Open the Quartus II programmer by clicking in "Tools" > "Programmer". Then in Hardware Setup select the USB-Blaster variant.
  3. Select the file kotku.sof and click on Delete
  4. Change the programming mode to Active Serial Programming
  5. Click on Add File... and select kotku.pof
  6. Click on Prgram/Configure.
  7. Then just click on Start. The bitstream flashing will proceed.

If you have Microsoft Windows, you can follow the Altera DE1 Installation guide with the bitstream files to flash them into the board and boot the system.