-
Notifications
You must be signed in to change notification settings - Fork 40
Getting started
This page explains building and installation of ICSC on any Linux OS. In the following description Ubuntu 22.04 is used, all operations are done in bash
terminal.
ICSC is based on Clang/LLVM tool chain. It uses Google Protobuf library and patched SystemC library. Patched SystemC sources are uploaded into ICSC repository.
There are two ways to install ICSC:
- Installation with
install.sh
script -- checked for SLES12, Ubuntu 22.04 and Ubuntu 20.04 - Manual installation
ICSC can be installed at any Linux OS with:
- Any C++ compiler supports C++17
- CMake version 3.13 or later
- git to clone ICSC repository
Default Ubuntu 20.04/22.04 C++ compiler is g++ 9.3.0/11.3.0 that works fine. Default Ubuntu 20.04/22.04 CMake version is 3.16/3.22 that works fine.
Initial step before installation is to setup some folder as $ICSC_HOME
and clone ISCS source repository to $ICSC_HOME/icsc
:
$ export ICSC_HOME=/home/user/my_iscs_folder
$ git clone https://github.com/intel/systemc-compiler $ICSC_HOME/icsc
After clone before installation there is the following folder structure:
$ICSC_HOME
* icsc
* cmake -- CMake files
* components -- assertions, fifo and other library components
* designs -- folder for user designs with an design template
* doc -- user guide latex and pdf files
* examples -- a few illustrative examples
* sc_elab -- elaborator sources
* sc_tool -- ISCS sources
* systemc -- patched SystemC 2.3.3 sources
* tests -- unit tests
* .gitmodules -- not intended to be used here, can be removed
* CMakeLists.txt -- Cmake file for ICSC tool
* LICENSE.txt -- Apache 2.0 WITH LLVM exceptions license
* README.md -- Tool description
* install.sh -- Installation script
The install.sh
script contains all the stages of manual installation, that includes generating SystemVerilog code for examples
.
Open bash terminal and run icsc/install.sh
from $ICSC_HOME
folder:
$ cd $ICSC_HOME
$ icsc/install.sh -- download and install all required components
$ cd $ICSC_HOME
$ source setenv.sh -- setup PATH and LD_LIBRARY_PATH
The install.sh
has an option gdb
to download and build gdb 11.2
with Python3
which required for SystemC pretty printers. If system default gdb
does not work with pretty printers well, this option could be used:
$ icsc/install.sh gdb -- run install with gdb build
Before using the installed tool in a new terminal it needs to run setenv.sh
:
$ export ICSC_HOME=/home/user/my_iscs_folder
$ cd $ICSC_HOME
$ source setenv.sh -- setup PATH and LD_LIBRARY_PATH
Release and debug mode for user design is supported with two version of SystemC library installed:
-
systemc.so
for release mode, -
systemcd.so
for debug mode.
Using debug mode allows to see SystemC channels and data type variables in debug session with gdb
with the pretty-printers provided.
It needs to have:
- Protobuf version 3.6.1 or later, can be downloaded from https://github.com/protocolbuffers/protobuf/releases
- LLVM 12.0.1 and Clang 12.0.1, can be downloaded from https://releases.llvm.org/download.html#12.0.1
Download Protobuf, LLVM and Clang into $ICSC_HOME
folder.
Download Protobuf version 3.6.1 or later from https://github.com/protocolbuffers/protobuf/releases into $ICSC_HOME
folder.
$ cd $ICSC_HOME/protobuf-3.13.0
$ mkdir build && cd build
$ cmake ../cmake/ -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=$ICSC_HOME -DBUILD_SHARED_LIBS=ON
$ make -j8
$ make install
Download LLVM 12.0.1 and Clang 12.0.1 from https://releases.llvm.org/download.html#12.0.1 into $ICSC_HOME
folder.
$ mv $ICSC_HOME/clang-12.0.1.src $ICSC_HOME/llvm-12.0.1.src/tools/clang
$ cd $ICSC_HOME/llvm-12.0.1.src
$ mkdir build && cd build
$ cmake ../ -DLLVM_ENABLE_ASSERTIONS=ON -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=$ICSC_HOME
$ make -j8
$ make install
For release build use -fno-tree-vectorize
to avoid bug in g++ 10.x
and g++ 11.x
. This is specified in the project CMakeLists.txt
.
$ cd $ICSC_HOME/icsc
$ mkdir build && cd build
$ cmake ../ -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=$ICSC_HOME
$ make -j8
$ make install
After installation there is the following folder structure:
$ICSC_HOME
* bin -- binary utilities, can be removed
* build -- build folder where examples, tests and user designs are built
* designs -- folder for examples, tests and user designs with an design template
* icsc -- ICSC sources
* build -- build folder, can be removed
* cmake -- CMake files
* components -- assertions, fifo and other library components
* doc -- user guide latex and pdf files
* sc_elab -- elaborator sources
* sc_tool -- ISCS sources
* systemc -- patched SystemC 2.3.3 sources
* .gitmodules -- not intended to be used here, can be removed
* CMakeLists.txt -- Cmake file for ICSC tool
* LICENSE.txt -- Apache 2.0 WITH LLVM exceptions license
* README.md -- Tool description
* install.sh -- Installation script
* include -- LLVM/Clang, SystemC and other headers
* lib -- tool compiled libraries
* libexec -- can be removed
* lib64 -- tool compiled libraries
* share -- gdb and pretty-printers to show SystemC types
* CMakeLists.txt -- CMake file for examples, tests and user designs
* gdbinit-example.txt -- GDB configuration to be copied into ~/.gdbinit
* README -- build and run examples, tests and used designs instruction
* setenv.sh -- set environment script for bash terminal
There are number of examples in examples
sub-folder:
-
asserts
-- immediate and temporal SystemC assertions with SVA generation -
counter
-- simple counter with SC_METHOD and SC_CTHREAD processes -
decoder
-- configurable FIFO example -
dvcon20
-- assertion performance evaluation examples -
fsm
-- finite state machine coding -
intrinsic
-- Verilog code intrinsic example -
latch_ff
-- simple latch and flip flop with asynchronous reset
There are number of unit tests in tests
sub-folder:
-
const_prop
-- constant propagation analysis tests -
cthread
-- general tests inSC_CTHREAD
-
elab_only
-- dynamic elaborator tests -
method
-- general tests inSC_METHOD
-
mif
-- modular interface tests -
misc
-- extra tests -
record
-- local and members of struct and class type -
state
-- state tests -
uniquify
-- module uniquification tests
$ cd $ICSC_HOME
$ source setenv.sh # setup PATH and LD_LIBRARY_PATH
$ cd build
$ cmake ../ # prepare Makefiles in Release mode
$ ctest -R DesignTargetName # compile and run SV generation for DesignTargetName
where DesignTargetName
is a target name in CMakeLists.txt
.
For Debug mode use cmake ../ -DCMAKE_BUILD_TYPE=Debug
.
$ cd $ICSC_HOME
$ source setenv.sh # setup PATH and LD_LIBRARY_PATH
$ cd build
$ cmake ../ # prepare Makefiles in Release mode
$ ctest -j8 # compile and run SV generation for all designs
Generated SystemVerilog files are put into sv_out
folders.
For counter
example:
$ cd examples/counter # go to counter example folder
$ cat sv_out/counter.sv # see generated SystemVerilog file
SystemC simulation for examples and tests can be run with:
$ cd $ICSC_HOME
$ mkdir build && cd build
$ cmake ../ # prepare Makefiles in Release mode
$ make counter # compile SystemC simulation for counter example
$ cd examples/counter # go to counter example folder
$ ./counter # run SystemC simulation
To run ICSC for custom design it needs to create a CMakeList.txt file for the project. SystemVeriog generation is performed with svc_target
function call. svc_target
is CMake function defined in $ICSC_HOME/lib64/cmake/SVC/svc_target.cmake
.
The custom design can be placed into $ICSC_HOME/designs
folder.
There is an empty design template $ICSC_HOME/designs/template
. This design template contains example.cpp
and dut.h
files.
In the design template top module is specified as variable name dut_inst
which is instantiated in module tb
, so full SystemC name is tb.dut_inst
.
# Design template CMakeList.txt file
project(mydesign)
# All synthesizable source files must be listed here (not in libraries)
add_executable(mydesign example.cpp)
# Test source directory
target_include_directories(mydesign PUBLIC $ENV{ICSC_HOME}/examples/template)
# Add compilation options
# target_compile_definitions(mydesign PUBLIC -DMYOPTION)
# target_compile_options(mydesign PUBLIC -Wall)
# Add optional library, do not add SystemC library (it added by svc_target)
#target_link_libraries(mydesign sometestbenchlibrary)
# svc_target will create @mydesign_sctool executable that runs code generation
# and @mydesign that runs general SystemC simulation
# ELAB_TOP parameter accepts hierarchical name of DUT
# (that is SystemC name, returned by sc_object::name() method)
svc_target(mydesign ELAB_TOP tb.dut_inst)
The pretty printers for gdb
support SystemC integer types, sc_signal
, sc_in
, sc_out
, sc_inout
and sc_vector
. The printers can be used in gdb
command line as well as in C++ IDE. These printers require gdb
built with Python 3
which can be provided by install.sh
script.
To setup the pretty printers it needs to copy GDB configuration from icsc/gdbinit-example.txt
into ~/.gdbinit
.