This file explains how to use the Linux version of Quartus to compile configuration images for Altera FPGAs from HDL sources in a desktopless environment using only command lines and Makefiles. Because the miscreants at FPGA companies refuse to disclose the detailed internal structure of their programmable logic devices and the configuration bit format, compiling configuration images requires using their proprietary tools. And of course the greatest problem with modern proprietary software is that it's typically available only for point-and-click, don't-try-to-think operating systems and environments. Both Altera and Xilinx provide "free" versions of their tools on their websites, but they are crippled in that they require Weendoze (in the case of Altera) or Linux with GUI (in the case of Xilinx). Xilinx' "native Linux" version is the worst -- it's distributed in a binary package consisting of encrypted (!) ZIPs and an installer. The installer is a Weendoze application ported to Linux through some kind of linked-in Weendoze emulation library and requires libraries that I don't have, an X display, and probably other crap. And the ZIPs with the actual meat are encrypted specifically to prevent you from bypassing their fucking installer! Because I have never succeeded in getting past the installer, I can't tell whether the actual compiler tools are normal Unix apps or are also linked with Weendoze emulation libraries that impose ridiculous unnecessary requirements. So Xilinx has lost me as a customer thanks to their stinky installer, and I've turned to Altera. But Altera's "free" version is only for Weendoze, so it's even worse, right? Not so fast. Remember, that's just their "free" version, and they also have the full one for Weendoze, a few commercial Unixes and Linux. So how does one get a hold of the full version? The answer is that Altera has a secret FTP site: ftp.altera.com:/outgoing/release The /outgoing directory is mode 751, so you can't see /outgoing/release unless you know it's there. The /outgoing/release directory itself, however, is mode 755, and you can list its contents -- it contains *everything*, all Altera software! There you can download the full version of Quartus for Linux, and it's a normal tarball with more gzipped tarballs inside. No stinky GUI installers! The only installer is a csh script, and you can even bypass it and install completely manually, which is what I always do. The only gotcha is that after you've installed the full version of Quartus, you can't actually do anything useful with it until you set the LM_LICENSE_FILE environment variable to a valid license file. So how do you get one? You can of course buy a legal copy of Quartus and deal with all the crippling restrictions imposed by their "floating" license system, as their other alternative ("node-locked") is offered only for Weendoze. I say no thanks -- fuck Altera and use a pirate license file. There are two pirate Quartus license files available in this directory, and the rest of this README file gives instructions on how to use them. counted-license.dat appears to have been created by someone inside Altera with access to their license generator, as it's obviously not what they give to mere mortal customers. It allows almost unrestricted use of the software -- the file will work on any machine, there is no expiration date, and it'll work with future versions up to 2025.08! Look at the file with your favourite text editor and see for yourself. It's full of FEATURE lines for quartus, a bunch of fancy extensions, and what seems like the complete library of their licensed IP cores. The only fly in the counted-license.dat ointment is that it's counted. This means that you can't point the LM_LICENSE_FILE environment variable directly to this file. Instead you have to run their lmgrd daemon with this license file and point the Quartus tools to its TCP port. The counting daemon won't allow two instances of any program that uses FEATURE quartus (which is everything in the suite) to run at the same time. This restriction may be perfectly livable if you live in the desktop PC paradigm where your Linux box is your PC that no one else uses. I however live in the mainframe paradigm, in an alternate desktopless Universe, and my Linux box that runs Quartus is a compute server that everyone in our coven logs into from our dumb terminals. I thus find the counted license system severely crippling, as covenors logging into the box whenever they feel like it may be barred from the FPGA compiler at random unpredictable times when another covenor happens to be using it. The alternative is nioskit-license.dat. This file was once a regular legal license issued to an ordinary unprivileged customer, but it's still a little special. Altera's regular subscription licenses are either tied to a parallel port or USB dongle (Weendoze only obviously) and uncounted, or use the counted daemon-based scheme like our counted-license.dat. nioskit-license.dat is neither. It was a special promotional license that came with Altera's Nios II development kit (which is an actual piece of hardware in a fancy box), and in some ways it's actually better (more liberal) than what they give to regular paying customers! It's uncounted and "node-locked" like their Weendoze dongle licenses, but tied to an Ethernet MAC address instead of a Weendoze hardware dongle. It was officially issued for Weendoze only, but it works with the Linux version too. The Nios kit license is uncounted, which solves the problem of unencumbered coven use, but has two other restrictions in exchange: * It's tied to Ethernet MAC address 00:d0:b7:e1:b9:f5 (which belongs to the machine for which it was originally issued). * It has an expiration date of 2006-10-26, which is now in the past. A simple unsophisticated workaround for these problems is to change the MAC address of the machine (trivial under Linux) and set the system clock back, but this solution is obviously very ungraceful, particularly the latter part, especially for a coven compute server. So what's the solution? I was so unhappy with the idea of using a counted license for the coven and so determined to get nioskit-license.dat to work instead that I've worked out a rather elaborate solution. It involves fooling the license validator by playing with dynamic linking. Quartus for Linux is dynamically linked like most regular Linux applications, and all syscalls it makes to get the date and the Ethernet MAC address go through the shared glibc. Therein lies a solution. I've written a special shared library called libquartushack.so that implements special hacked versions of a few syscall wrapper functions that tell Quartus' license validator what it wants to hear, specifically a fixed system time in the past and the majic MAC address. (File times returned by the stat syscall are also botched as the miscreants make a feeble attempt to catch people setting the clock back by looking at the timestamps on some files.) So how does one use libquartushack.so so that it lies to Quartus but doesn't muck up the rest of the system (which is also dynamically linked of course)? Suppose you want to use the FPGA compiler in a Makefile; how do you feed sweet lies to Quartus (about the system time) while keeping make on the real unhobbled time? The solution lies in the Quartus wrapper script. Suppose (just as an example) that Quartus has been installed in /opt/quartus. All real binaries will be in /opt/quartus/linux, but Altera's docs tell you not to run them directly but to go through the wrappers in /opt/quartus/bin instead. The wrapper is a csh script; I've looked at it and found it gross and disgusting, so I've always violated Altera's directions and made a bin -> linux symlink in my Quartus root directory (which would be /opt/quartus in this example). My new solution is to replace Altera's wrapper with my own that looks like this: #!/bin/sh progname=`basename $0` LD_PRELOAD=libquartushack.so LD_LIBRARY_PATH=/opt/quartus/linux LM_LICENSE_FILE=/usr/local/pirate-licenses/nioskit-license.dat export LD_PRELOAD LD_LIBRARY_PATH LM_LICENSE_FILE exec /opt/quartus/linux/$progname $* (Of course change the paths accordingly; this one's for the /opt/quartus Quartus root path we're using in this example.) That's it! You put this wrapper script in /opt/quartus/bin, make a symlink to it from every user-runnable Quartus program name just like Altera's install script does, and libquartushack.so goes into /opt/quartus/linux right alongside with Altera's binaries and SOs. Any covenor who wants to use Quartus only needs to add /opt/quartus/bin to his/her path, no need to set any other environment variables as in my previous solution, and no pollution of the rest of the system. The whole solution can be installed by any ordinary user who has write permission to the desired place in the filesystem with sufficient disk space, no root privileges are required. Now the whole nioskit-license.dat solution is quite contrived, isn't it? And also 6.0 is probably the last version of Quartus it'll support, as the version field is set to 2006.06 in this license file. You may think at this point that using counted-license.dat is so much better -- and it may be for you. It all depends on whether you live in the desktop paradigm or the mainframe paradigm, and whether you need the FPGA compiler just for your own rugged self or for an entire coven. OK, so once you have the bootleg license squared away, how do you actually use the FPGA compiler? Well, you need to read Altera's documentation, but an example is provided in quartus_cmdline_test.tar.Z. It's one of Altera's own examples from Quartus 5.0 converted to a Makefile-based flow. You should be able to type 'make' and see the project compile into filtref.sof, which is the finished SRAM object file for a Cyclone FPGA. It works with Quartus version 5.0, but 6.0 complains about bad Verilog in acc.v (hey, it's Altera's own example code...). The latter problem doesn't seem to have anything to do with licensing. Some final notes: * Quartus requires an x86 CPU with SSE instructions. cat /proc/cpuinfo and make sure sse is in there. In version 5.0 all quartus executables would immediately die with an illegal instruction fault when run on a sans-SSE CPU. I haven't observed this behavior in version 6.0, but I wouldn't count on it working on a sans-SSE CPU -- it'll probably just die later, though I have no way to test it since I've upgraded to a CPU with SSE on the assumption that it's required before I got past the license hurdle with my libquartushack.so. * Altera also makes an x86_64 version of Quartus for Linux, but I've never touched it and have no idea how/if my libquartushack.so would work with it. Sorry, x86_64 is way too modern for my old peasant mind. * Neither of the two bootleg license files on this site has the FEATURE altera_mainwin_lnx line that enables the Linux version of the Quartus GUI, so the latter is not available, only the command line tools. But then the whole point of this entire exercise is to enable old farts like me to do FPGA design from an ASR33 -- if you want GUI, use the stuff that's readily and legally available from www.altera.com and www.xilinx.com.