Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ project(scc VERSION 2025.12 LANGUAGES CXX C)

option(USE_CWR_SYSTEMC "Use Synopsys Virtualizer SystemC" OFF)
option(USE_NCSC_SYSTEMC "Cadence Xcelium SystemC" OFF)
option(USE_NCSC_SYSTEMC3 "Cadence Xcelium SystemC version 3.0" OFF)
option(BUILD_SCC_DOCUMENTATION "Create and install the HTML based API documentation (requires Doxygen)" OFF)
option(FULL_TRACE_TYPE_LIST "Test for extended set of templated datatypes" OFF)
#Note: this needs to match the SystemC kernel build options
Expand Down Expand Up @@ -33,8 +34,9 @@ if(CMAKE_PROJECT_NAME STREQUAL "scc")
endif(APPLE)
set(Boost_NO_BOOST_CMAKE ON) # Don't do a find_package in config mode before searching for a regular boost install.
option(ENABLE_CLANG_TIDY "Add clang-tidy automatically to builds" OFF)
option(BUILD_SCC_LIB_ONLY "Build only the library (no examples" OFF)
option(BUILD_SCC_LIB_ONLY "Build only the library (no examples, no tests)" OFF)
option(INSTALL_DEPENDENCIES "Should dependencies be installed when installing SCC" OFF)
option(NCSC_LINK_CHECK "If NCSC is used, check if the libraries veing built link in an example" OFF)
set(CLANG_FORMAT_EXCLUDE_PATTERNS "/third_party/" "/build/" ".direnv")
if(ENABLE_CLANG_FORMAT)
find_package(ClangFormat)
Expand Down Expand Up @@ -139,7 +141,7 @@ if(SystemC_FOUND)
add_subdirectory(src/components)
add_subdirectory(src/sysc)
add_subdirectory(third_party)
if(NOT BUILD_SCC_LIB_ONLY)
if(NOT BUILD_SCC_LIB_ONLY AND NOT (USE_NCSC_SYSTEMC OR USE_NCSC_SYSTEMC3))
if(NOT (DEFINED CMAKE_CXX_CLANG_TIDY OR CMAKE_CXX_COMPILER_ID STREQUAL "Clang"))
add_subdirectory(examples)
endif()
Expand All @@ -149,6 +151,8 @@ if(SystemC_FOUND)
set(WITH_SCP4SCC ON)
add_subdirectory(tests)
endif()
elseif(USE_NCSC_SYSTEMC OR USE_NCSC_SYSTEMC3 AND NCSC_LINK_CHECK)
add_subdirectory(examples/transaction_recording)
endif()

# Define the scc library
Expand Down
21 changes: 20 additions & 1 deletion CMakePresets.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
"generator": "Ninja",
"binaryDir": "${sourceDir}/build/${presetName}",
"cacheVariables": {
"CMAKE_POLICY_DEFAULT_CMP0091": "NEW",
"CMAKE_CXX_STANDARD": "17",
"CMAKE_INSTALL_PREFIX": "${sourceDir}/install/${presetName}",
"CMAKE_EXPORT_COMPILE_COMMANDS": "ON",
Expand Down Expand Up @@ -61,6 +60,26 @@
"CMAKE_BUILD_TYPE": "Release",
"BUILD_SCC_DOCUMENTATION": "ON"
}
},
{
"name": "NCSC_RelWithDebInfo",
"inherits": "Base",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "RelWithDebInfo",
"USE_NCSC_SYSTEMC": "ON",
"NCSC_LINK_CHECK": "ON",
"CMAKE_INSTALL_PREFIX": "${sourceDir}/out/install/${presetName}"
}
},
{
"name": "NCSC3_RelWithDebInfo",
"inherits": "Base",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "RelWithDebInfo",
"USE_NCSC_SYSTEMC3": "ON",
"NCSC_LINK_CHECK": "ON",
"CMAKE_INSTALL_PREFIX": "${sourceDir}/out/install/${presetName}"
}
}
],
"testPresets": [
Expand Down
48 changes: 41 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,12 +77,15 @@ The full documentation can be found at the [Github pages](https://minres.github.
Build notes
=======================================

If SystemC is build using cmake with `SC_WITH_PHASE_CALLBACK_TRACING=ON` (which is the default for SystemC 2.3.4), tracing will not work. Either SystemC is being installed with SC_WITH_PHASE_CALLBACK_TRACING=ON (which is the prefered way as this setting is in sync with the automake configure configuration, see <https://github.com/accellera-official/systemc/issues/24>) or the SCC is being build using `SC_WITH_PHASE_CALLBACK_TRACING=ON`.
If SystemC 2.x is build using cmake with `SC_WITH_PHASE_CALLBACK_TRACING=ON` (which is the default for SystemC 2.3.4), tracing will not work.
Either SystemC is being installed with SC_WITH_PHASE_CALLBACK_TRACING=OFF (which is the prefered way as this setting is in sync with the automake configure configuration, see <https://github.com/accellera-official/systemc/issues/24>) or the SCC is being build using `SC_WITH_PHASE_CALLBACK_TRACING=ON`.

Build instructions using conan
=======================================

The repo is cmake based and (preferably) uses conan. Make sure that you have at least cmake 3.24 and conan version >2.0 installed. Other combinations may work, but are not tested.
The repo is cmake based and (preferably) uses conan.
Make sure that you have at least cmake 3.24 and conan version >2.0 installed.
Other combinations may work, but are not tested.

On Linux
=======================================
Expand All @@ -101,22 +104,25 @@ For example:

cmake --preset Release -DCMAKE_INSTALL_PREFIX=<some install path>
cmake --build build/Release -j16
cmake --build build/Release --target test
cmake --build build/Release --target test
cmake --build build/Release --target install
build//Release/examples/ace-axi/ace_axi_example
build//Release/examples/axi-axi/axi_axi_example
build/Release/examples/ace-axi/ace_axi_example
build/Release/examples/axi-axi/axi_axi_example

```

> **_NOTE:_** **Do not install SCC in the same installation directory as SystemC.**
SCC follows the convention of mapping C++ namespaces directly into the directory hierarchy. As many SCC components are related to TLM 2.0, a significant portion of the SCC code resides in the `tlm` namespace, which results in the creation of a `tlm` directory under SCC's `include` folder. The SystemC itself also provides a `tlm` header file (or directory) in its own include path. If SCC and SystemC are installed into the same prefix, this results in a clash to create a directory where a file or another directory already exists—causing installation errors. Install SCC and SystemC into separate directories.
SCC follows the convention of mapping C++ namespaces directly into the directory hierarchy.
As many SCC components are related to TLM 2.0, a significant portion of the SCC code resides in the `tlm` namespace, which results in the creation of a `tlm` directory under SCC's `include` folder.
The SystemC itself also provides a `tlm` header file (or directory) in its own include path.
If SCC and SystemC are installed into the same prefix, this results in a clash to create a directory where a file or another directory already exists—causing installation errors.
Install SCC and SystemC into separate directories.

On Windows
=======================================

```
cmake --preset Release -DBUILD_SHARED_LIBS=OFF -DCMAKE_INSTALL_PREFIX=<some install path>
cmake --build build/Release --config Release
cmake --build build/Release --config Release --target install
```

Expand All @@ -135,3 +141,31 @@ The script can also be downloaded and run with the install dir as argument:
curl https://raw.githubusercontent.com/Minres/SystemC-Components/develop/contrib/install_wo_conan.sh >install_wo_conan.sh
bash install_wo_conan.sh <install dir>
```

Building and installing SCC for Cadence Xcelium
===============================================

You need to setup your environment and make Xcelium available. This means ncroot and ncsc need to be found by the shell.

```
cmake --preset NCSC_RelWithDebInfo -DCMAKE_INSTALL_PREFIX=<some install path>
cmake --build build/NCSC_RelWithDebInfo --parallel --target install
```

If the used version of Xcelium supports SystemC 3.x the commands become:

```
cmake --preset NCSC3_RelWithDebInfo -DCMAKE_INSTALL_PREFIX=<some install path>
cmake --build build/NCSC3_RelWithDebInfo --parallel --target install
```

Building the library for 32bit (the Xcelium default - sic!) works atm only for a standalone build as there is no mechanism to tell conan to build in 32bit. The following commands might help in non-conan builds:

```
CXXFLAGS="-m32" CFLAGS="-m32" LDFLAGS="-m32" \
cmake -S . -B build/NCSC_RelWithDebInfo -Wno-dev -DCMAKE_INSTALL_PREFIX=<scc install dir> \
-DCMAKE_BUILD_TYPE=RelWithDebInfo -DBUILD_SHARED_LIBS=OFF -DBUILD_SCC_LIB_ONLY=ON -DCMAKE_CXX_STANDARD=17 \
-DBoost_NO_SYSTEM_PATHS=TRUE -DBOOST_ROOT=<boost install dir> -DBoost_NO_WARN_NEW_VERSIONS=ON
cmake --build build/NCSC_RelWithDebInfo --parallel --target install
```

190 changes: 76 additions & 114 deletions cmake/FindXMSystemC.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -40,160 +40,122 @@ This will define the following variables:
Libraries needed to link to SCV.

#]=======================================================================]
set(NCSC_LIBS systemc_sh xmscCoSim_sh xmscCoroutines_sh)
#set(NCSC_LIBS systemc_sh xmscCoroutines_sh ovm scBootstrap_sh)

# find install location and version of XCelium
find_program(ncroot_EXECUTABLE ncroot)
if(NOT ncroot_EXECUTABLE)
message(FATAL_ERROR "No ncroot in PATH")
endif()

execute_process(
COMMAND ${ncroot_EXECUTABLE}
OUTPUT_VARIABLE NCROOT_PATH
OUTPUT_VARIABLE CDSROOT_PATH
)
string(STRIP ${NCROOT_PATH} NCROOT_PATH)
message("Using Xcelium at ${NCROOT_PATH}")


SET(_COMMON_HINTS
${NCROOT_PATH}/tools/systemc/include
${NCROOT_PATH}/tools/systemc/lib/64bit
)

SET(_SYSTEMC_HINTS
${_COMMON_HINTS}
)

SET(_TLM_HINTS
${NCROOT_PATH}/tools/systemc/include/tlm2
${_COMMON_HINTS}
)

SET(_SCV_HINTS
${_COMMON_HINTS}
)
string(STRIP ${CDSROOT_PATH} CDSROOT_PATH)

SET(_COMMON_PATHS
${NCROOT_PATH}/tools/systemc/include
${NCROOT_PATH}/tools/systemc/lib
/usr/include
/usr/lib
)

FIND_PATH(SystemC_INCLUDE_DIR
NAMES systemc
HINTS ${_SYSTEMC_HINTS}
PATHS ${_COMMON_PATHS}
)
find_program(ncsc_EXECUTABLE ncsc)
if(NOT ncsc_EXECUTABLE)
message(FATAL_ERROR "No ncsc in PATH")
endif()

FIND_PATH(TLM_INCLUDE_DIR
NAMES tlm
HINTS ${_TLM_HINTS}
PATHS ${_COMMON_PATHS}
)
execute_process(
COMMAND ${ncsc_EXECUTABLE} -version
OUTPUT_VARIABLE NCSC_OUTPUT
)
separate_arguments(NCSC_OUTPUT_LIST NATIVE_COMMAND ${NCSC_OUTPUT})
list(GET NCSC_OUTPUT_LIST 2 NCSC_VERSION_STRING)
string(SUBSTRING ${NCSC_VERSION_STRING} 0 2 NCSC_VERSION_MAJOR)
string(SUBSTRING ${NCSC_VERSION_STRING} 3 2 NCSC_VERSION_MINOR)
set(NCSC_VERSION ${NCSC_VERSION_MAJOR}${NCSC_VERSION_MINOR})
message(STATUS "Xcelium is at ${CDSROOT_PATH}, version is ${NCSC_VERSION_MAJOR}.${NCSC_VERSION_MINOR}")
# if we reach here we found Xcelium
set(XMSystemC_FOUND True)
# check if we build 32 or 64bit
file(WRITE "${CMAKE_BINARY_DIR}/test_arch_size.cpp" "
#include <cstdlib>
int main( int argc, char** argv ){
return sizeof(void*);
}")
set(CMAKE_TRY_COMPILE_CONFIGURATION ${CMAKE_BUILD_TYPE})
TRY_RUN(RUN_RESULT_VAR COMPILE_RESULT_VAR
${CMAKE_BINARY_DIR}
${CMAKE_BINARY_DIR}/test_arch_size.cpp
RUN_OUTPUT_VARIABLE IS_64_SYSTEM)
if(${RUN_RESULT_VAR} EQUAL 8)
set(BITS_MOD 64bit)
set(LIB_MOD 64)
endif()
# set default values of variables
set(NCSC_LIBS systemc_sh scBootstrap_sh xmscCoroutines_sh)
set(GCC_LIB_PATH ${CDSROOT_PATH}/tools.lnx86/cdsgcc/gcc/install/lib${LIB_MOD})
set(NCSC_ROOT_PATH ${CDSROOT_PATH}/tools.lnx86/systemc)
set(NCSC_LIB_PATHS ${CDSROOT_PATH}/tools.lnx86/systemc/lib/${BITS_MOD}/gnu)
# check if there is and will be used SystemC 3
if(NCSC_VERSION GREATER_EQUAL 2603 AND USE_NCSC_SYSTEMC3)
set(NCSC_ROOT_PATH ${CDSROOT_PATH}/tools.lnx86/systemc_301)
set(NCSC_LIB_PATHS ${CDSROOT_PATH}/tools.lnx86/systemc_301/lib/${BITS_MOD}/gnu)
set(SC_VERSION_MAJOR 3)
set(SC_VERSION_MINOR 0)
set(SC_VERSION_PATCH 1)
else()
set(SC_VERSION_MAJOR 2)
set(SC_VERSION_MINOR 3)
set(SC_VERSION_PATCH 4)
endif()
set(SystemC_VERSION ${SC_VERSION_MAJOR}.${SC_VERSION_MINOR}.${SC_VERSION_PATCH} CACHE STRING "SystemC Version")

# seed the include directories
set(NCSC_SystemC_INCLUDE_DIRS ${NCSC_ROOT_PATH}/include;${CDSROOT_PATH}/tools.lnx86/tbsc/include;${CDSROOT_PATH}/tools.lnx86/vic/include;${NCSC_ROOT_PATH}/include/factory;${NCSC_ROOT_PATH}/include/tlm2)
# find needed libraries
foreach(LIB_NAME ${NCSC_LIBS})
FIND_LIBRARY(${LIB_NAME}_LIBRARY
NAMES ${LIB_NAME}
HINTS ${_SYSTEMC_HINTS}
PATHS ${_COMMON_PATHS}
HINTS ${NCSC_LIB_PATHS}
PATHS ${NCSC_LIB_PATHS}
)
set(LIB_FILE_NAMES ${LIB_FILE_NAMES} ${${LIB_NAME}_LIBRARY})
set(LIB_VAR_NAMES ${LIB_VAR_NAMES} ${LIB_NAME}_LIBRARY)
list(APPEND LIB_FILE_NAMES ${${LIB_NAME}_LIBRARY})
list(APPEND LIB_VAR_NAMES ${LIB_NAME}_LIBRARY)
endforeach()

mark_as_advanced(
SystemC_INCLUDE_DIR
SystemC_LIBRARY
NCSC_SystemC_INCLUDE_DIRS
NCSC_SystemC_LIBRARIES
${LIB_VAR_NAMES}
)

if (SystemC_INCLUDE_DIR)
file(STRINGS "${SystemC_INCLUDE_DIR}/sysc/cosim/xmsc_ver.h" version-file
REGEX "#define[ \t]SC_VERSION_(MAJOR|MINOR|PATCH).*")
if (NOT version-file)
message(AUTHOR_WARNING "SystemC_INCLUDE_DIR found, but xmsc_ver.h is missing")
endif()
list(GET version-file 0 major-line)
list(GET version-file 1 minor-line)
list(GET version-file 2 patch-line)
string(REGEX REPLACE "^#define[ \t]+SC_VERSION_MAJOR[ \t]+([0-9]+)$" "\\1" SC_VERSION_MAJOR ${major-line})
string(REGEX REPLACE "^#define[ \t]+SC_VERSION_MINOR[ \t]+([0-9]+)$" "\\1" SC_VERSION_MINOR ${minor-line})
string(REGEX REPLACE "^#define[ \t]+SC_VERSION_PATCH[ \t]+([0-9]+)$" "\\1" SC_VERSION_PATCH ${patch-line})
set(SystemC_VERSION ${SC_VERSION_MAJOR}.${SC_VERSION_MINOR}.${SC_VERSION_PATCH} CACHE STRING "SystemC Version")
endif()


include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(XMSystemC
REQUIRED_VARS
${LIB_VAR_NAMES}
SystemC_INCLUDE_DIR
TLM_INCLUDE_DIR
NCSC_SystemC_INCLUDE_DIRS
VERSION_VAR SystemC_VERSION
)

if(XMSystemC_FOUND)
set(SystemC_FOUND True)
get_filename_component(NCSC_LIB_DIR ${systemc_sh_LIBRARY} DIRECTORY)
set(SystemC_LIBRARY_DIRS ${NCSC_LIB_DIR})
set(SystemC_LIBRARIES ${NCSC_LIBS} ${NCROOT_PATH}/tools/lib/64bit/libudm.so)
set(SystemC_INCLUDE_DIRS ${TLM_INCLUDE_DIR} ${SystemC_INCLUDE_DIR})
set(SystemC_DEFINITIONS ${PC_SystemC_CFLAGS_OTHER} NCSC)
set(SystemC_LIBRARIES ${NCSC_LIBS})
set(SystemC_INCLUDE_DIRS ${NCSC_SystemC_INCLUDE_DIRS})
set(SystemC_DEFINITIONS NCSC)
endif()


if(SystemC_FOUND AND NOT TARGET SystemC::systemc)
add_library(SystemC::systemc UNKNOWN IMPORTED)
set_target_properties(SystemC::systemc PROPERTIES
IMPORTED_LOCATION ${systemc_sh_LIBRARY}
INTERFACE_COMPILE_DEFINITIONS "${SystemC_DEFINITIONS}"
# INTERFACE_COMPILE_OPTIONS "${SystemC_OPTIONS}"
INTERFACE_INCLUDE_DIRECTORIES "${SystemC_INCLUDE_DIRS}"
INTERFACE_LINK_DIRECTORIES "${SystemC_LIBRARY_DIRS}"
INTERFACE_LINK_DIRECTORIES "${SystemC_LIBRARY_DIRS};${GCC_LIB_PATH}"
INTERFACE_LINK_LIBRARIES "${SystemC_LIBRARIES}"
)
if(UNIX)
set_target_properties(SystemC::systemc PROPERTIES
INTERFACE_LINK_OPTIONS "LINKER:-rpath,${NCSC_LIB_PATHS}:${GCC_LIB_PATH}"
)
if(NCSC_VERSION GREATER_EQUAL 2509)
#target_compile_options(SystemC::systemc PUBLIC -Wno-free-nonheap-object)
add_compile_options(-Wno-free-nonheap-object)
endif()
endif()
endif()

FIND_PATH(SCV_INCLUDE_DIR
NAMES scv.h
HINTS ${_SCV_HINTS}
PATHS ${_COMMON_PATHS}
)

FIND_LIBRARY(SCV_LIBRARY
NAMES scv
HINTS ${_SCV_HINTS}
PATHS ${_COMMON_PATHS}
)

mark_as_advanced(
SCV_INCLUDE_DIR
SCV_LIBRARY
)

if(NOT SCV_INCLUDE_DIR MATCHES "SCV_INCLUDE_DIR-NOTFOUND")
find_package_handle_standard_args(SCV
FOUND_VAR SCV_FOUND
REQUIRED_VARS
SCV_LIBRARY
SCV_INCLUDE_DIR
VERSION_VAR 2.0.1
)

if(SCV_FOUND)
set(SCV_LIBRARIES ${SCV_LIBRARY})
set(SCV_INCLUDE_DIRS ${SCV_INCLUDE_DIR})
set(SCV_DEFINITIONS ${PC_SCV_CFLAGS_OTHER})
endif()

if(SCV_FOUND AND NOT TARGET SystemC::scv)
add_library(SystemC::scv UNKNOWN IMPORTED)
set_target_properties(SystemC::scv PROPERTIES
IMPORTED_LOCATION "${SCV_LIBRARY}"
INTERFACE_COMPILE_OPTIONS "${PC_SCV_CFLAGS_OTHER}"
INTERFACE_INCLUDE_DIRECTORIES "${SCV_INCLUDE_DIR}"
)
endif()
endif()

2 changes: 1 addition & 1 deletion cmake/SystemCPackage.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ if(NOT SystemC_FOUND)
elseif(USE_VCS_SYSTEMC)
find_package(VCSSystemC REQUIRED)
set(SystemC_LIBRARIES SystemC::systemc)
elseif(USE_NCSC_SYSTEMC)
elseif(USE_NCSC_SYSTEMC OR USE_NCSC_SYSTEMC3)
find_package(XMSystemC REQUIRED)
set(SystemC_LIBRARIES SystemC::systemc)
elseif(USE_MTI_SYSTEMC)
Expand Down
Loading
Loading