Compiling SystemC and SystemC-AMS on macOS

Keywords: SystemC, SystemC-AMS, macOS

1. Introduction

At the moment of writing, SystemC-AMS does not compile with the Xcode compiler.

In a previous attempt to solve this problem I have compiled GCC 7.2. However a better approach is to install the Homebrew package manager to install a pre-compiled package of gcc 7.3.

This tutorial was tested with the following software versions:

  • macOS High Sierra 10.13.3
  • Homebrew
  • gcc 7.3
  • SystemC 2.3.2
  • SystemC-AMS 2.1

The instructions in this tutorial where tested on a macOS High Sierra 10.13.3 and should run on latest versions without problems.

2. GCC Install

If the Xcode Command Line Tools (CLT) is not already, use the following command to install it:

xcode-select --install

2.1 Install Homebrew

The easiest way to install Homebrew is typing the following command in a terminal window:

/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

2.2 Install the gcc package

Type the following commend on a terminal window:

brew install gcc

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

$ gcc-7 --version
gcc-7 (Homebrew GCC 7.3.0) 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 Compiling SystemC and SystemC-AMS

SystemC 2.3.2 library can be downloaded from Accellera's website while SystemC-AMS PoC 2.1 (Proof-of-Concept) can be downloaded on Coseda's website.

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.

export CC=gcc-7
export CXX=g++-7
cd systemc-2.3.2/
mkdir build && cd build
../configure --prefix=/usr/local/systemc-2.3.2
make -j4
sudo make install

Note the first to lines telling the configure utility to use gcc 7.x.

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
sudo 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.

Comments