Installation

Installing systemc-clang on Linux

We provide instructions for installation using Linux. You can install LLVM and Clang via source or via binaries.

Building LLVM/Clang from source

Follow the instructions to install clang. Notice that you should also install LLVM as it is needed for compilation of the stand-along program. A suggestion is to install LLVM/clang in a location that is accessible by the user. Note that the clang-llvm version systemc-clang supports is version 13.0.0 and higher.

Building systemc-clang

Clone systemc-clang repository.

$ git clone https://github.com/anikau31/systemc-clang.git

Create a build directory for this stand-alone program.

$ mkdir systemc-clang-build

Enter the cloned repository folder.

$ cd systemc-clang

Edit the path for the LLVM_INSTALL_DIR in paths.sh, and set it to the appropriate path where LLVM/clang was installed.

Source the paths file (assuming bash shell). This should setup certain environment variables that cmake will use.

$ source scripts/paths.sh

Go to the build directory.

$ cd ../systemc-clang-build

Run cmake.

$ cmake ../systemc-clang

Alternatively, you could use cmake to generate Ninja build scripts.

$ cmake ../systemc-clang -G Ninja

If there are no errors, then the configuration was successful. So, you can go ahead and compile the stand-alone program.

$ make

If using ninja:

$ ninja

Testing on a small example

Copy the compiled binary in the bin folder of LLVM_INSTALL_DIR.

$ cp systemc-clang $LLVM_INSTALL_DIR/bin

Set the SYSTEMC variable.

$ export SYSTEMC=<path-to-systemc-install>

Execute it on a simple example. You should see some (debug) information print out on the screen. Hope to make this more meaningful in the future.

$ $LLVM_INSTALL_DIR/bin/systemc-clang ../systemc-clang/tests/module1.hpp -- \
-D__STDC_CONSTANT_MACROS -D__STDC_LIMIT_MACROS  -I/usr/include  \
-I$SYSTEMC/include  -x c++ -w -c

Installing systemc-clang on OSX

We provide instructions for installation using OSX. You can install LLVM and Clang via source or via binaries.

  • systemc-clang requires llvm-config and by default does not come with the llvm package preinstalled on MacOS.

  • Download the clang pre built binaries from here for LLVM 13.0.0 or higher.

  • Untar the package into a suitable location, and modify the path.sh bash script in the systemc-clang folder to point to llvm-config, which will be found in the bin directory of the uncompressed binary.

Building systemc-clang

Clone systemc-clang repository.

$ git clone https://github.com/anikau31/systemc-clang.git

Create a build directory for this stand-alone program.

$ mkdir systemc-clang-build

Enter the cloned repository folder.

$ cd systemc-clang

Edit the path for the LLVM_INSTALL_DIR in paths.sh, and set it to the appropriate path where LLVM/clang was installed.

Source the paths file (assuming bash shell). This should setup certain environment variables that cmake will use.

$ source scripts/paths.sh

Go to the build directory.

$ cd ../systemc-clang-build

Run cmake.

$ cmake ../systemc-clang

Alternatively, you could use cmake to generate Ninja build scripts.

$ cmake ../systemc-clang -G Ninja

If there are no errors, then the configuration was successful. So, you can go ahead and compile the stand-alone program.

$ make

If using ninja:

$ ninja

Testing on a small example

Copy the compiled binary in the bin folder of LLVM_BUILD_DIR

$ cp systemc-clang $LLVM_BUILD_DIR/bin

Set the SYSTEMC variable.

$ export SYSTEMC=<path-to-systemc-install>

Execute it on a simple example. You should see some (debug) information print out on the screen. Hope to make this more meaningful in the future.

$ $LLVM_BUILD_DIR/bin/systemc-clang ../systemc-clang/tests/module1.hpp -- \
-D__STDC_CONSTANT_MACROS -D__STDC_LIMIT_MACROS  -I/usr/include  \
-I$SYSTEMC/include  -x c++ -w -c

Compile Options

systemc-clang enables certain features through compiler flag options.

Option

Arguments

Description

SYSTEMC_DIR

<path>

Path to SystemC installation.

LLVM_INSTALL_DIR

<path>

Path to LLVM/Clang installation.

CMAKE_BUILD_TYPE

[Release,Debug]

Build type. Use Release unless developing.

ENABLE_TESTS

[ON,OFF]

Compiles tests.

USE_CCACHE

[ON,OFF]

Uses ccache for faster recompilation

HDL

[ON,OFF]

Compiles the translator plugin to generate Verilog

These can be supplied to cmake via the -D option flag.