Compiling SystemC and SystemC-AMS on Windows with MSYS2

Keywords: SystemC, SystemC-AMS, Windows , MSYS2

1. Introduction

One option to compile SystemC and SystemC-AMS libraries on Windows is to use a development environment like MSYS2. According to their website MSYS2 is a software distro and building platform for Windows [1]:

At its core is an independent rewrite of MSYS, based on modern Cygwin (POSIX compatibility layer) and MinGW-w64 with the aim of better interoperability with native Windows software. It provides a bash shell, Autotools, revision control systems and the like for building native Windows applications using MinGW-w64 toolchains.

It features a package management system to provide easy installation of packages, Pacman. It brings many powerful features such as dependency resolution and simple complete system upgrades, as well as straight-forward package building.

  • Windows 7 professional
  • MSYS2 20170918
  • gcc 7.3
  • SystemC 2.3.2
  • SystemC-AMS 2.1

2. Install MSYS2

Go to MSYS2 homepage and follow the instructions. I normally chose the 64-bit because is theoretically faster, but the 32-bit should work as well.

For more detailed installation instructions visit this page.

If pacman quits unexpectedly, edit your C:\msys64\etc\pacman.conf and uncommend the following line:

XferCommand = /usr/bin/wget --passive-ftp -c -O %o %u

3. Install GCC

If only 64-bit compiler is needed, use the following command:

pacman -S --needed base-devel mingw-w64-x86_64-toolchain

To install the 32-bit version instead:

pacman -S --needed base-devel mingw-w64-i686-toolchain

Other useful packages (optional):

pacman -S --needed  git subversion mercurial

If everything went well, one should be able to run the following command:

$ gcc --version
gcc.exe (Rev1, Built by MSYS2 project) 7.3.0
Copyright (C) 2017 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

3.1 SystemC

This should be strait forward. SystemC library is in a more advanced phase of development and I never had any problem compiling it in several different machines and operating systems.

First launch a mingw shell (32 or 64 bits):

Mingw64

Figure 1: Mingw64 Shortcut.

Then go to the SystemC folder and run the following commands:

cd systemc-2.3.2/
mkdir build && cd build
../configure --prefix=/usr/local/systemc-2.3.2
make -j4
make install

3.2 SystemC-AMS

Now there is a trick. SystemC-AMS 2.1 is not compiling out of the box with SystemC 2.3.2. But this is very simple to fix updating the following files:

  • ./src/scams/impl/predefined_moc/tdf/sca_tdf_ct_ltf_nd_proxy.h
  • ./src/scams/impl/predefined_moc/tdf/sca_tdf_ct_vector_ss_proxy.h

In both I have changed from:

#include "systemc-ams"

To:

#include <cstring>
#include "systemc-ams"

Otherwise the make process fails on these modules, complaining that "memset" is not defined. Now just follow the standard procedure:

cd systemc-ams-2.1
mkdir build && cd build
../configure --prefix=/usr/local/systemc-ams-2.1 --with-systemc=/usr/local/systemc-2.3.2
make -j4
make install

4. Conclusion

After completing this tutorial you should be able to compile applications using the SystemC and SystemC-AMS libraries. If you need an example project you might use my PLL simulator.

If you found a bug, have suggestions or just want to share your opinion about this tutorial, please leave a comment bellow.

5. References

Comments