MINGW PORT OF ICARUS VERILOG Copyright 2006 Stephen Williams Icarus Verilog source can be compiled with the mingw C/C++ compilers to get a Windows binary that does not require the POSIX compatibility cruft of the Cygwin.dll library. The resulting program can be run with or without Cygwin, so this is the preferred Windows distribution form. The configure scripts automatically detect that the compilers in use are the mingw compilers and will configure the Makefiles appropriately. The mingw patch doesn't contain tools beyond the compiler, but there is the "msys" package that the makers of Mingw publish that has enough extra tools to get most everything else working. There are a few extra packages needed beyond mingw and msys, and the following instructions explain how to get them and install them. * Some Preliminary Comments -- PLEASE READ ME -- The Windows port of Icarus Verilog is the most difficult of all the ports. The Windows system off the shelf is completely stripped, devoid of any support for software development. Everything needed to compile Icarus Verilog must be collected from various sources and stitched together by hand. Normal human beings with a basic understanding of software development can do this, but some patience (and access to the Internet) is required. You may choose to print these instructions. FOR BEST RESULTS, FOLLOW THESE INSTRUCTIONS CAREFULLY. NOTE that if you have Cygwin installed, it is best to not use a cygwin window to do the build, as the Cygwin tools will intermix with the mingw tools such that it is hard to be sure you are using the right compiler. Thus, it is recommended that these steps be *not* done in a Cygwin window. Use an MSYS window instead, and be careful that your msys/mingw tools are not masked by paths that point to Cygwin binaries. I have no plans to intentionally support MSVC++ compilation. Don't ask. * Summary of Prerequisites This is a brief list of prerequisite packages, along with the URL where each can be found. In most cases, the specific version is not critical, but these are the versions I use. msys-1.0 msysDTK-1.0 Mingw32-5.x readline-4.2-20010727.zip bzip2-1.0.3 zlib-1.2.3 gperf-3.0.1 bison-2.1 flex-2.5.4a The above table lists the packages required. It is convenient to install them in the above order. Many of these packages are also collected into the directory: Incidentally, besides Mingw32, none of these packages are needed after installation of Icarus Verilog is complete. These are only needed to build the compiler. The Mingw32 package can be used to compile VPI modules if you choose. * Install MSYS and msysDTK The msys package is available from the mingw download site. This is not the compiler but a collection of *nix tools ported to Windows and wrapped in a convenient installer. The msys package is all the various basic tools (shells, file utils, etc) and the msysDTK is extra developer tools other than the compiler. Download the msys-1.x.x.exe and msysdtc-1.x.x.exe binaries. These are self-installing packages. Install msys first, and then msysDTC. Most likely, you want to install them in c:/msys. (The msysDTK is installed in the same location, as it is an add-on.) This install should be easy and reliable. The installation will leave an "msys" icon on your desktop and in the mingw sub-menu of your Start menu. This icon brings up a shell window (a command line) that has paths all set up for executing msys and mingw commands. This is what you will want to use while executing commands below. * Install Mingw32 The obvious step 2, then, is install the mingw compilers. These can be found at the web page . The Mingw-5.x.x package is a convenient remote installer. Download this program and run it. The installer will ask wich components you want to install. You need only the base C compiler and the C++ compiler. (You may install other languages if you wish.) When I install Mingw32 (using the installer) I typically set a destination directory of d:\mingw or the like. You will be using that path later. NOTES: If you intend to compile VPI modules for Icarus Verilog, you need Mingw32, even if you are using a precompiled binary. VPI modules only require Mingw32, and none of the other libraries. Finally, as part of installing the mingw32 compilers, remember to add the mingw/bin directory to your path. You will need that to be able to find the compilers later. * Install Mingw32 Packages There is a collection of precompiled libraries and add-on packages that are intended for use with the Mingw32 compiler. These do not come with simplified Windows installers, but they are pretty easy to install by hand. Icarus Verilog uses the readline-4.2 package from that collection. Since I installed Mingw32 in c:\mingw, I also created a Mingw-packages directory called c:\mingw-packages. The install, then, is as easy as this: $ cd c:/mingw-packages $ unzip readline-4.2-20010727.zip [lots of inflating...] There is no need to adjust your execution path for this package as we are only using a library out of here. However, do remember the directory name, as you will need it later. Done. On to the next packages. * Install GnuWin32 Packages The GnuWin32 project is a collections of open source programs and libraries ported to Windows. These also work well with the Mingw compiler, and in fact Icarus Verilog uses a few pieces from this collection. You will need these gnuwin32 packages to compile Icarus Verilog: bzip2-1.0.3.exe zlib-1.2.3.exe gperf-3.0.1.exe bison-2.1.exe flex-2.5.4a.exe I suggest creating a common directory for holding all your gnuwin32 packages. I use C:\gnuwin32. The download page at the gnuwin32 site has a "setup" link for each of these packages. Click the setup to download the installer for each of the desired programes, then execute the downloaded .exe files to invoke the installer. Install into the c:\gunwin32 directory. NOTES: You need the binaries and the developer files, but you do not need the source to these packages. The installer gives you the choice. After you are done installing the gnuwin32 tools, you should add the c:\gnuwin32\bin directory (assuming you installed in c:\gnuwin32) to your Windows path. The msys shell will pick up your Windows path. * Unpack Icarus Verilog source Unpack the compressed tar file (.tar.gz) of the source with a command like this: $ gunzip -d verilog-xxxxxxxx.tar.gz | tar xvf - This will create a directory "verilog-xxxxxxxx" that contains all the source for Icarus Verilog. Descend into that directory, as that is where we will work from now on. $ cd verilog-xxxxxxxx NOTES: The exact name of the file will vary according to the snapshot. The 20030303 name is only an example. Unpack the source into a directory that has no spaces. The makefiles included in the source get confused by white space in directory names. * Preconfigure Icarus Verilog (Not normally needed) Under certain cases, you may need to "preconfigure" the Icarus Verilog source tree. You should only need to do this if you are getting the Icarus Verilog source tree from CVS, or you are using an existing source tree that you've patched to cause configure.in files to change. NOTE: If you are building from a fresh, bundled source tree that you downloaded from an FTP site, then SKIP THIS STEP. Go on to the "Configure Icarus Verilog" step below. First, remove any autom4te.cache directories that may exist in your source tree. These can make a mess of autoconf runs. Then, generate configure scripts with this command: $ sh autoconf.sh This script will run the "autoconf" command (part of the msysDTK) to generate all the necessary "configure" scripts. This will take a few minutes. This should go smoothly. * Configure Icarus Verilog Now we are all set to configure and compile Icarus Verilog. Choose a destination path where you will want to install the binaries. I chose on my system the directory "D:\iverilog". This choice is not permanent, so don't get too much angst over it. Just choose a name without white space. Now, configure the source to make the makefiles and configuration details. Run these commands: $ CPPFLAGS="-Ic:/gnuwin32/include -Ic:/mingw-packages/include" $ LDFLAGS="-Lc:/gnuwin32/lib -Lc:/mingw-packages/lib" $ export CPPFLAGS LDFLAGS $ ./configure --prefix=c:/iverilog NOTES: The CPPFLAGS and LDFLAGS variables tell configure where the gnuwin32 packages are. The configure program will write these values into the Makefiles, so you only need to keep these variables long enough for the configure program to work. Your PATH variable was set in the previous step. Use forward slashes as directory characters. All the various tools prefer the forward slash. Substitute your chosen directory for the prefix. This will cause the makefiles to build and the source code to configure. The configure program will detect that this is a mingw environment and set things up to build properly. (For a prefix, use the drive letter notation; the mingw compiled parts require it, and the Cygwin tools should be able to handle it. You may need to check or upgrade your Cygwin installation if this causes problems for you.) * Compile Icarus Verilog This, believe it or not, should be the easy part: $ make It could take a while. Now is a good time to go get some coffee or take a tea break. * Install Icarus Verilog If the compile ran OK, then next you install Icarus Verilog in the directory you have chosen. When you are ready, install like this: $ make install This is part of what the configure program did for you. The Makefiles now know to put the files under the D:\iverilog directory (or whatever directory you chose) and away you go. You may find that you need to put some of the prerequisite DLLs into the d:\iverilog\bin directory. These include: c:\mingw\bin\mingw10.dll c:\mingw-packages\bin\libreadline.dll c:\gnuwin32\bin\bzip2.dll c:\gnuwin32\bin\zlib.dll If you already have these in your Windows path (i.e. your system32 directory) then you do not need to copy them into the iverilog directory. However, prepackaged Icarus Verilog binaries include these files. * Running Icarus Verilog Finally, put the C:\iverilog\bin directory in your Windows path, and you should be able to run the iverilog and vvp commands to your heart's content. Currently, the iverilog.exe uses the path to itself to locate the libraries and modules associated with itself. In other words, if you execute the C:\iverilog\bin\iverilog.exe program, it will locate its subparts in the C:\iverilog directory and subdirectories below that. This means you can move the Icarus Verilog installation by simply moving the root directory and all its contents. The vvp.pdf and iverilog.pdf files document the main commands. View these with Acrobat reader, or any other viewer capable of displaying PDF format files.