Skip to content

Getting started

Mikhail Moiseev edited this page Mar 21, 2021 · 51 revisions

This page explains building and installation of ICSC on any Linux OS. In the following description Ubuntu 20.04 is used, all operations are given for 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
  • Manual installation

Prepare to installation

ICSC can be installed at any Linux OS with:

  • C++ compiler supports C++17, default Ubuntu C++ compiler is g++ 9.3.0 that works fine
  • CMake version 3.12 or later, default Ubuntu CMake version is 3.16
  • git to clone ICSC repository

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

Installation with install.sh

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

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

Manual installation

Preparing dependencies

It needs to have:

Download Protobuf, LLVM and Clang into $ICSC_HOME folder.

Building and installing Protobuf

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

Building and installing LLVM/Clang

Download LLVM 7.0.0 and Clang 7.0.0 from https://releases.llvm.org/download.html#7.0.0 into $ICSC_HOME folder.

$ mv $ICSC_HOME/cfe-7.0.0.src $ICSC_HOME/llvm-7.0.0.src/tools/clang
$ cd $ICSC_HOME/llvm-7.0.0.src
$ mkdir build && cd build
$ cmake ../ -DLLVM_ENABLE_ASSERTIONS=ON -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=$ICSC_HOME
$ make -j8
$ make install

Building and installing ICSC

$ cd $ICSC_HOME/icsc
$ mkdir build && cd build
$ cmake ../ -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=$ICSC_HOME
$ make -j8
$ make install

Folders and files after installation

After installation there is the following folder structure:

 $ICSC_HOME
   * bin                 -- binary utilities, can be removed
   * build               -- build folder, can be removed
   * icsc                -- ICSC sources
        * build          -- build folder, can be removed        
        * 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
   * include             -- LLVM/Clang, SystemC and other headers
   * lib                 -- tool compiled libraries
   * libexec             -- can be removed
   * lib64               -- tool compiled libraries
   * share               -- can be removed  
   * CMakeLists.txt      -- CMake file for examples, tests and user designs
   * README              -- build and run examples, tests and used designs description
   * setenv.sh           -- set environment script for bash terminal  

Run tool for examples and tests

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
  • int_error -- error reporting example, dangling pointer de-reference inside
  • 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 in SC_CTHREAD
  • elab_only -- dynamic elaborator tests
  • method -- general tests in SC_METHOD
  • mif -- modular interface tests
  • misc -- extra tests
  • record -- local and members of struct and class type
  • state -- state tests
  • uniquify -- module uniquification tests

Generate SV code for one specific example or design

$ cd $ICSC_HOME
$ source setenv.sh                   # setup PATH and LD_LIBRARY_PATH
$ cd build   
$ cmake ../                          # prepare Makefiles 
$ ctest -R DesignTargetName          # compile and run SV generation

where DesignTargetName is a target name in CMakeLists.txt.

Generate SV code for examples, tests and designs

$ cd $ICSC_HOME
$ source setenv.sh                   # setup PATH and LD_LIBRARY_PATH
$ cd build   
$ cmake ../                          # prepare Makefiles 
$ ctest -j8                          # compile and run SV generation

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 

Run SystemC simulation

SystemC simulation for examples and tests can be run with:

$ cd $ICSC_HOME
$ mkdir build && cd build
$ cmake ../                          # prepare Makefiles 
$ make counter                       # compile SystemC simulation for counter example
$ cd examples/counter                # go to counter example folder
$ ./counter                          # run SystemC simulation 

Run tool for custom design

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/icsc/designs folder. There is an empty design template $ICSC_HOME/icsc/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)
Clone this wiki locally