Skip to content

Commit 49d9b18

Browse files
Tool code initial commit
1 parent afd4be9 commit 49d9b18

File tree

2,010 files changed

+470631
-14
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

2,010 files changed

+470631
-14
lines changed

.gitignore

+83
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
### C template
2+
# Prerequisites
3+
*.d
4+
5+
# Object files
6+
*.o
7+
*.ko
8+
*.obj
9+
*.elf
10+
11+
# Linker output
12+
*.ilk
13+
*.map
14+
*.exp
15+
16+
# Precompiled Headers
17+
*.gch
18+
*.pch
19+
20+
# Libraries
21+
*.lib
22+
*.a
23+
*.la
24+
*.lo
25+
26+
# Shared objects (inc. Windows DLLs)
27+
*.dll
28+
*.so
29+
*.so.*
30+
*.dylib
31+
32+
# Executables
33+
*.exe
34+
*.out
35+
*.app
36+
*.i*86
37+
*.x86_64
38+
*.hex
39+
40+
# Debug files
41+
*.dSYM/
42+
*.su
43+
*.idb
44+
*.pdb
45+
*.log
46+
test/smem/vcs
47+
test/smem/vcs_sc
48+
49+
# Kernel Module Compile Results
50+
*.mod*
51+
*.cmd
52+
.tmp_versions/
53+
modules.order
54+
Module.symvers
55+
Mkfile.old
56+
dkms.conf
57+
### C++ template
58+
# Prerequisites
59+
60+
# Compiled Object files
61+
*.slo
62+
63+
# Precompiled Headers
64+
65+
# Compiled Dynamic libraries
66+
67+
# Fortran module files
68+
*.mod
69+
*.smod
70+
71+
# Compiled Static libraries
72+
*.lai
73+
74+
# Executables
75+
76+
# SystemC elaboration
77+
*.scelab
78+
79+
# Clion
80+
.idea/
81+
82+
# Misc
83+
sc_tool/arc

CMakeLists.txt

+111
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
#******************************************************************************
2+
# Copyright (c) 2020, Intel Corporation. All rights reserved.
3+
#
4+
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception.
5+
#
6+
# *****************************************************************************
7+
8+
cmake_minimum_required(VERSION 3.5)
9+
project(sctool)
10+
11+
set(CMAKE_CXX_STANDARD 17)
12+
13+
find_package(LLVM 7.0.0 REQUIRED CONFIG)
14+
15+
message(STATUS "Found LLVM ${LLVM_PACKAGE_VERSION}")
16+
message(STATUS "Using LLVMConfig.cmake in: ${LLVM_DIR}")
17+
message(STATUS "LIBDIR ${LLVM_LIBRARY_DIRS}")
18+
message(STATUS "LLVM_TOOLS_BINARY_DIR ${LLVM_TOOLS_BINARY_DIR}")
19+
message(STATUS "LLVM_INCLUDE_DIRS ${LLVM_INCLUDE_DIRS}")
20+
message(STATUS "CMAKE_BUILD_TYPE ${CMAKE_BUILD_TYPE}")
21+
22+
include_directories(${LLVM_INCLUDE_DIRS})
23+
link_directories(${LLVM_LIBRARY_DIRS})
24+
add_definitions(${LLVM_DEFINITIONS})
25+
26+
27+
# Support for using custom linker
28+
if( LLVM_USE_LINKER )
29+
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fuse-ld=${LLVM_USE_LINKER}")
30+
set(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} -fuse-ld=${LLVM_USE_LINKER}")
31+
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -fuse-ld=${LLVM_USE_LINKER}")
32+
message("USING CUSTOM LINKER: ${CMAKE_EXE_LINKER_FLAGS}")
33+
endif()
34+
35+
set(BUILD_SHARED_LIBS ON)
36+
37+
# Patched SystemC kernel with additional elaboration instrumentation
38+
add_subdirectory(systemc)
39+
40+
# SystemC Precompiled header to speed-up parsing in debug build
41+
SET(CLANG_CXX_EXECUTABLE ${LLVM_TOOLS_BINARY_DIR}/clang++)
42+
SET(CLANG_INT_INC_DIR ${LLVM_LIBRARY_DIR}/clang/${LLVM_PACKAGE_VERSION}/include)
43+
44+
message(STATUS "CLANG_CXX_EXECUTABLE ${CLANG_CXX_EXECUTABLE}")
45+
message(STATUS "CLANG_INT_INC_DIR ${CLANG_INT_INC_DIR}")
46+
47+
SET(SYSTEMC_PCH ${CMAKE_BINARY_DIR}/systemc/systemc.h.pch)
48+
49+
# Create SystemC pre-compiled headers
50+
add_custom_command(OUTPUT ${SYSTEMC_PCH}
51+
COMMAND
52+
${CLANG_CXX_EXECUTABLE} -Xclang -emit-pch -x c++-header
53+
${CMAKE_SOURCE_DIR}/systemc/src/systemc.h -o ${SYSTEMC_PCH} ${MSVC_FLAGS}
54+
-D__SC_TOOL__ -D__SC_TOOL_ANALYZE__ -DNDEBUG -std=c++14
55+
-I${CMAKE_SOURCE_DIR}/systemc/src
56+
DEPENDS systemc
57+
COMMENT "Generating SystemC precompiled header ${SYSTEMC_PCH}"
58+
)
59+
add_custom_target(systemcPCH DEPENDS ${SYSTEMC_PCH})
60+
61+
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
62+
63+
# Dynamic Elaboration (Requires GDB 8.0.1 configured with Python3)
64+
add_subdirectory(sc_elab)
65+
66+
# ScTool main library
67+
add_subdirectory(sc_tool)
68+
69+
# Integration tests : SystemC Design -> Elaboration -> StaticAnalysis
70+
set(SYSTEMC_INCLUDE_DIR ${CMAKE_CURRENT_LIST_DIR}/systemc/src)
71+
include(cmake/svc_target.cmake)
72+
73+
enable_testing()
74+
75+
# Compile tests and test designs
76+
if( ${CMAKE_BUILD_TYPE} STREQUAL "Debug" )
77+
message (STATUS "Debug mode: add tests and test designs")
78+
add_subdirectory(tests)
79+
add_subdirectory(designs)
80+
endif()
81+
82+
###############################################################################
83+
84+
# Install targets
85+
install (EXPORT SVCTargets NAMESPACE SVC::
86+
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/SVC)
87+
88+
# Create the SVCConfig.cmake, installed @ICSC_HOME/lib/cmake/SVC
89+
include(CMakePackageConfigHelpers)
90+
configure_package_config_file(cmake/SVCConfig.cmake.in
91+
${CMAKE_CURRENT_BINARY_DIR}/SVCConfig.cmake
92+
INSTALL_DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/SVC)
93+
94+
install(FILES ${PROJECT_BINARY_DIR}/SVCConfig.cmake cmake/svc_target.cmake
95+
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/SVC)
96+
97+
# Install sctMemory
98+
install(DIRECTORY components/memory/sctmemory DESTINATION include)
99+
100+
# Install sctCommon
101+
install(DIRECTORY components/common/sctcommon DESTINATION include)
102+
103+
# Install release mode CMakeLists and scripts
104+
if( ${CMAKE_BUILD_TYPE} STREQUAL "Release" )
105+
message (STATUS "Release mode: copy CMakeLists and scripts")
106+
install(FILES cmake/CMakeLists.txt
107+
cmake/setenv.sh
108+
cmake/README
109+
DESTINATION $ENV{ICSC_HOME})
110+
111+
endif()

cmake/CMakeLists.txt

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#******************************************************************************
2+
# Copyright (c) 2020, Intel Corporation. All rights reserved.
3+
#
4+
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception.
5+
#
6+
# *****************************************************************************
7+
#
8+
# Intel(r) Compiler for SystemC*, version 1.3.7
9+
#
10+
# *****************************************************************************
11+
12+
cmake_minimum_required(VERSION 3.12)
13+
14+
## C++ standard
15+
set(CMAKE_CXX_STANDARD 17)
16+
17+
enable_testing()
18+
19+
## SVC package contains ICSC and SystemC libraries
20+
find_package(SVC REQUIRED)
21+
22+
## Add examples, tests and user designs
23+
add_subdirectory(icsc/examples)
24+
add_subdirectory(icsc/tests)
25+
add_subdirectory(icsc/designs)

cmake/README

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
#******************************************************************************
2+
# Copyright (c) 2020, Intel Corporation. All rights reserved.
3+
#
4+
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception.
5+
#
6+
# *****************************************************************************
7+
#
8+
# Intel(r) Compiler for SystemC*, version 1.3.7
9+
#
10+
# *****************************************************************************
11+
12+
-------------------------------------------------------------------------------
13+
1. Build and run examples, tests and designs
14+
-------------------------------------------------------------------------------
15+
16+
* Run bash shell
17+
$ bash
18+
19+
* Setup ICSC environment
20+
$ source setenv.sh
21+
22+
* Build sources
23+
$ mkdir build && cd build
24+
$ cmake ../
25+
$ make -j8
26+
27+
* Run SystemVerilog generation
28+
$ ctest -j8
29+
30+
* Check the generated SystemVerilog in sv_out folder
31+
$cd examples/counter/sv_out
32+
$cat counter.sv
33+
34+
* Run SystemC simulation for an example
35+
$ cd examples/counter
36+
$ ./counter
37+

cmake/SVCConfig.cmake.in

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
#******************************************************************************
2+
# Copyright (c) 2020, Intel Corporation. All rights reserved.
3+
#
4+
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception.
5+
#
6+
# *****************************************************************************
7+
8+
# - Config file for the SVC package
9+
# It defines the following variables:
10+
# SystemC_TARGET_ARCH - Target architecture according to the Accellera SystemC conventions
11+
# SystemC_CXX_STANDARD - Preferred C++ standard
12+
# SystemC_CXX_STANDARD_REQUIRED - Determine whether the selected C++ standard is a requirement
13+
# CLANG_INT_INC_DIR - Location of Clang internal headers, required to run tool
14+
@PACKAGE_INIT@
15+
16+
# Checking PThread are installed, required for SystemC
17+
include(CMakeFindDependencyMacro)
18+
19+
# if (@CMAKE_USE_PTHREADS_INIT@)
20+
set (THREADS_PREFER_PTHREAD_FLAG ON)
21+
find_dependency (Threads)
22+
if (NOT CMAKE_USE_PTHREADS_INIT)
23+
message (SEND_ERROR "Failed to find the Pthreads library required to implement the SystemC coroutines and async_request_update() of primitive channels on Unix.")
24+
endif (NOT CMAKE_USE_PTHREADS_INIT)
25+
# endif (@CMAKE_USE_PTHREADS_INIT@)
26+
27+
# Contains includes and options for each used library (SystemC, ScTool, SysCRTTI)
28+
include ("${CMAKE_CURRENT_LIST_DIR}/SVCTargets.cmake")
29+
include ("${CMAKE_CURRENT_LIST_DIR}/svc_target.cmake")
30+
31+
# Are configured at cmake run
32+
set (SystemC_TARGET_ARCH @SystemC_TARGET_ARCH@)
33+
set (SystemC_CXX_STANDARD @CMAKE_CXX_STANDARD@)
34+
set (SystemC_CXX_STANDARD_REQUIRED @CMAKE_CXX_STANDARD_REQUIRED@)
35+
36+
# CLang internal headers, required as sc_tool located out of CLang folder
37+
set (CLANG_INT_INC_DIR "$ENV{ICSC_HOME}/lib/clang/7.0.0/include")

cmake/setenv.sh

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#******************************************************************************
2+
# Copyright (c) 2020, Intel Corporation. All rights reserved.
3+
#
4+
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception.
5+
#
6+
# *****************************************************************************
7+
#
8+
# Intel(r) Compiler for SystemC*, version 1.3.7
9+
#
10+
# *****************************************************************************
11+
12+
# Setup environment to run examples, tests and user designs
13+
14+
#!/bin/bash
15+
export SHELL=/bin/sh
16+
17+
export ICSC_HOME="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
18+
19+
export CMAKE_PREFIX_PATH=$ICSC_HOME
20+
export PATH=$ICSC_HOME/bin:$ICSC_HOME/include:$PATH
21+
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$ICSC_HOME/lib64:$ICSC_HOME/lib
22+
export SYSTEMC_HOME=$ICSC_HOME
23+
24+
25+

0 commit comments

Comments
 (0)