From 5d59bec38597c623945395e892b242f841feedfb Mon Sep 17 00:00:00 2001 From: Eyck Jentzsch Date: Wed, 17 Mar 2021 09:20:28 +0100 Subject: [PATCH 1/4] cleanup --- .pydevproject | 8 ++- components/CMakeLists.txt | 1 - components/initiator.cpp | 8 +-- components/logging.cpp | 115 -------------------------------------- components/logging_.h | 42 -------------- router_example.py | 1 - 6 files changed, 10 insertions(+), 165 deletions(-) delete mode 100644 components/logging.cpp delete mode 100644 components/logging_.h diff --git a/.pydevproject b/.pydevproject index 9708187..a16af72 100644 --- a/.pydevproject +++ b/.pydevproject @@ -1,10 +1,14 @@ + - Default + pysysc-env + python interpreter + 3.6 - + + diff --git a/components/CMakeLists.txt b/components/CMakeLists.txt index b60cdb3..1acfabe 100644 --- a/components/CMakeLists.txt +++ b/components/CMakeLists.txt @@ -1,6 +1,5 @@ set(LIB_SOURCES initiator.cpp - logging.cpp target.cpp clkgen.cpp resetgen.cpp diff --git a/components/initiator.cpp b/components/initiator.cpp index a13c127..c246c0e 100644 --- a/components/initiator.cpp +++ b/components/initiator.cpp @@ -55,7 +55,7 @@ void Initiator::thread_process() { wait( dmi_data.get_write_latency() ); } - SCCINFO() << "DMI = { " << (cmd ? 'W' : 'R') << ", " << hex << i + SCCDEBUG() << "DMI = { " << (cmd ? 'W' : 'R') << ", " << hex << i << " } , data = " << hex << data << " at time " << sc_time_stamp(); } else @@ -101,7 +101,7 @@ void Initiator::thread_process() { dmi_ptr_valid = socket->get_direct_mem_ptr( *trans, dmi_data ); } - SCCINFO() << "trans = { " << (cmd ? 'W' : 'R') << ", " << hex << i + SCCDEBUG() << "trans = { " << (cmd ? 'W' : 'R') << ", " << hex << i << " } , data = " << hex << data << " at time " << sc_time_stamp(); } } @@ -119,7 +119,7 @@ void Initiator::thread_process() { for (unsigned int i = 0; i < n_bytes; i += 4) { - SCCINFO() << "mem[" << (A + i) << "] = " + SCCTRACE() << "mem[" << (A + i) << "] = " << *(reinterpret_cast( &data[i] )); } @@ -131,7 +131,7 @@ void Initiator::thread_process() { for (unsigned int i = 0; i < n_bytes; i += 4) { - SCCINFO() << "mem[" << (A + i) << "] = " + SCCTRACE() << "mem[" << (A + i) << "] = " << *(reinterpret_cast( &data[i] )); } } diff --git a/components/logging.cpp b/components/logging.cpp deleted file mode 100644 index 76ca550..0000000 --- a/components/logging.cpp +++ /dev/null @@ -1,115 +0,0 @@ -/* - * logging.cpp - * - * Created on: 24.12.2018 - * Author: eyck - */ - - -#include -#include -#include -#include -#include -#include "logging_.h" - -using namespace sc_core; - -enum log_level {NONE, FATAL, ERROR, WARNING, INFO, DEBUG, TRACE}; - -namespace { - -static std::deque msg_buf; - -inline log_level verbosity2log(int verb) { - if (verb >= sc_core::SC_FULL) return TRACE; - if (verb >= sc_core::SC_HIGH) return DEBUG; - return INFO; -} - -std::string time2string(const sc_core::sc_time &t) { - const std::array time_units{"fs", "ps", "ns", "us", "ms", "s "}; - const std::array multiplier{1ULL, - 1000ULL, - 1000ULL * 1000, - 1000ULL * 1000 * 1000, - 1000ULL * 1000 * 1000 * 1000, - 1000ULL * 1000 * 1000 * 1000 * 1000}; - std::ostringstream oss; - const sc_core::sc_time_tuple tt{t}; - const auto val = tt.value(); - if (!val) { - oss << "0 s"; - } else { - const unsigned scale = tt.unit(); - const auto fs_val = val * multiplier[scale]; - for (int j = multiplier.size() - 1; j >= scale; --j) { - if (fs_val > multiplier[j]) { - const auto i = val / multiplier[j - scale]; - const auto f = val % multiplier[j - scale]; - oss << i << '.' << std::setw(3 * (j - scale)) << std::setfill('0') << std::left << f << ' ' - << time_units[j]; - break; - } - } - } - return oss.str(); -} - -const std::string compose_message(const sc_report &rep) { - std::stringstream os; - os << "[" << std::setw(20) << time2string(sc_core::sc_time_stamp()) << "] "; - if (rep.get_id() >= 0) - os << "(" - << "IWEF"[rep.get_severity()] << rep.get_id() << ") "; - os << rep.get_msg_type(); - if (*rep.get_msg()) os << ": " << rep.get_msg(); - if (rep.get_severity() > SC_INFO) { - std::array line_number_str; - os << " [FILE:" << rep.get_file_name() << ":" << rep.get_line_number() << "]"; - sc_simcontext *simc = sc_get_curr_simcontext(); - if (simc && sc_is_running()) { - const char *proc_name = rep.get_process_name(); - if (proc_name) os << "[PROCESS:" << proc_name << "]"; - } - } - return os.str(); -} - -void report_handler(const sc_report &rep, const sc_actions &actions) { - std::array map = {{INFO, WARNING, ERROR, FATAL}}; - if (actions & SC_DISPLAY) { - auto level = rep.get_severity() > sc_core::SC_INFO ? map[rep.get_severity()] : verbosity2log(rep.get_verbosity()); - msg_buf.push_back(compose_message(rep)); - } - if (actions & SC_STOP) sc_stop(); - if (actions & SC_ABORT) abort(); - if (actions & SC_THROW) throw rep; -} -} - -bool has_output(){ - return !msg_buf.empty(); -} - -std::string get_output(){ - std::string ret = msg_buf.front(); - msg_buf.pop_front(); - return ret; -} - -void init_logging(unsigned level) { - const std::array verbosity = {SC_NONE, // Logging::NONE - SC_LOW, // Logging::FATAL - SC_LOW, // Logging::ERROR - SC_LOW, // Logging::WARNING - SC_MEDIUM, // Logging::INFO - SC_HIGH, // logging::DEBUG - SC_FULL, // logging::TRACE - SC_DEBUG}; // logging::TRACE+1 - sc_report_handler::set_verbosity_level(verbosity[level]); - sc_report_handler::set_handler(report_handler); -} - - - diff --git a/components/logging_.h b/components/logging_.h deleted file mode 100644 index 20defd8..0000000 --- a/components/logging_.h +++ /dev/null @@ -1,42 +0,0 @@ -/* - * logging.h - * - * Created on: 24.12.2018 - * Author: eyck - */ - -#ifndef LOGGING_H_ -#define LOGGING_H_ - -#include -#include -#include - -bool has_output(); -std::string get_output(); -void init_logging(unsigned level); - -class Log { -public: - Log(const char* file, int line):messageLevel(sc_core::SC_INFO), file(file), line(line){}; - Log(const Log&) = delete; - Log& operator =(const Log&) = delete; - virtual ~Log(){ - ::sc_core::sc_report_handler::report(messageLevel, "", os.str().c_str(), file, line ); - } - std::ostringstream& Get(sc_core::sc_severity level = sc_core::SC_INFO){ - messageLevel = level; - return os; - } -protected: - std::ostringstream os; - sc_core::sc_severity messageLevel; - const char* file; - int line; -}; - -#define LOG(level) Log(__FILE__, __LINE__).Get(level) -#define LOG_INFO Log(__FILE__, __LINE__).Get(sc_core::SC_INFO) -#define LOG_WARN Log(__FILE__, __LINE__).Get(sc_core::SC_WARNING) -#define LOG_ERR Log(__FILE__, __LINE__).Get(sc_core::SC_ERROR) -#endif /* LOGGING_H_ */ diff --git a/router_example.py b/router_example.py index 1005e37..4e139cf 100644 --- a/router_example.py +++ b/router_example.py @@ -24,7 +24,6 @@ pysysc.add_library('components.h', os.path.join(myDir, 'build/%s/lib/libcomponen ############################################################################### cpp.scc.init_logging(cpp.scc.log.INFO, 24, False); cpp.sc_core.sc_report_handler.set_actions(cpp.sc_core.SC_ID_MORE_THAN_ONE_SIGNAL_DRIVER_, cpp.sc_core.SC_DO_NOTHING); -cpp.scc.init_cci("GlobalBroker") ############################################################################### # instantiate ############################################################################### -- 2.40.1 From 0fcd9f486508363072d1050ddfb7ef5637fb12e7 Mon Sep 17 00:00:00 2001 From: Eyck Jentzsch Date: Wed, 12 May 2021 14:45:58 +0200 Subject: [PATCH 2/4] add module example --- modules.py | 83 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 83 insertions(+) create mode 100644 modules.py diff --git a/modules.py b/modules.py new file mode 100644 index 0000000..de62405 --- /dev/null +++ b/modules.py @@ -0,0 +1,83 @@ +# +# Copyright (c) 2019 -2021 MINRES Technolgies GmbH +# +# SPDX-License-Identifier: Apache-2.0 +# + +import os.path +import logging +import cppyy +from cppyy import gbl as cpp +import pysysc +from pysysc.structural import Connection, Module, Signal, Simulation + +############################################################################### +# setup and load +############################################################################### +logging.basicConfig(level=logging.DEBUG) +build_type='Debug' +############################################################################### +myDir = os.path.dirname( os.path.realpath(__file__)) +pysysc.read_config_from_conan(os.path.join(myDir, 'conanfile.txt'), build_type) +pysysc.load_systemc() +############################################################################### +logging.debug("Loading SC-Components lib") +pysysc.add_include_path(os.path.join(myDir, 'scc/incl')) +pysysc.add_library('scc.h', os.path.join(myDir, 'build/%s/lib/libscc.so'%build_type)) +############################################################################### +logging.debug("Loading Components lib") +pysysc.add_include_path(os.path.join(myDir, 'components')) +pysysc.add_library('components.h', os.path.join(myDir, 'build/%s/lib/libcomponents.so'%build_type)) + +############################################################################### +# define toplevel class +############################################################################### +num_of_mem = 4 + +class TopModule(cpp.scc.PyScModule): + + def __init__(self, name): + super().__init__(self, name) + ############################################################################### + # instantiate + ############################################################################### + self.clk_gen = Module(cpp.ClkGen).create("clk_gen") + self.rst_gen = Module(cpp.ResetGen).create("rst_gen") + self.initiator = Module(cpp.Initiator).create("initiator") + self.memories = [Module(cpp.Memory).create("mem%d"%idx) for idx in range(0,num_of_mem)] + self.router = Module(cpp.Router[num_of_mem]).create("router") + ############################################################################### + # connect them + ############################################################################### + self.clk = Signal("clk").src(self.clk_gen.clk_o).sink(self.initiator.clk_i).sink(self.router.clk_i) + [self.clk.sink(m.clk_i) for m in self.memories] + self.rst = Signal("rst").src(self.rst_gen.reset_o).sink(self.initiator.reset_i).sink(self.router.reset_i) + [self.rst.sink(m.reset_i) for m in self.memories] + Connection().src(self.initiator.socket).sink(self.router.target_socket) + [Connection().src(self.router.initiator_socket.at(idx)).sink(m.socket) for idx,m in enumerate(self.memories)] + + def EndOfElaboration(self): + print("Elaboration finished") + + def StartOfSimulation(self): + print("Simulation started") + + def EndOfSimulation(self): + print("Simulation finished") + +############################################################################### +# configure +############################################################################### +Simulation.setup(logging.root.level) +############################################################################### +# instantiate +############################################################################### +#from modules import TopModule +dut = Module(TopModule).create("dut") +############################################################################### +# run if it is standalone +############################################################################### +if __name__ == "__main__": + Simulation.configure(enable_vcd=False) + Simulation.run() + logging.debug("Done") -- 2.40.1 From 6ed7d882c9a47c4b17766dc252a5fdc2fcc8be3f Mon Sep 17 00:00:00 2001 From: Stas Kaushanski Date: Tue, 18 May 2021 16:33:29 +0200 Subject: [PATCH 3/4] Remove conan dependency --- .cproject | 2 ++ CMakeLists.txt | 5 +---- README.md | 13 ------------- conanfile.txt | 12 ------------ router_example.py | 11 ++++++----- router_example2.py | 11 ++++++----- scc | 2 +- top/CMakeLists.txt | 2 +- {components => vp_components}/CMakeLists.txt | 4 ++-- {components => vp_components}/clkgen.cpp | 0 {components => vp_components}/clkgen.h | 6 +++--- {components => vp_components}/components.h | 0 {components => vp_components}/initiator.cpp | 0 {components => vp_components}/initiator.h | 0 {components => vp_components}/resetgen.cpp | 0 {components => vp_components}/resetgen.h | 6 +++--- {components => vp_components}/router.h | 0 {components => vp_components}/target.cpp | 0 {components => vp_components}/target.h | 0 19 files changed, 25 insertions(+), 49 deletions(-) delete mode 100644 conanfile.txt rename {components => vp_components}/CMakeLists.txt (69%) rename {components => vp_components}/clkgen.cpp (100%) rename {components => vp_components}/clkgen.h (75%) rename {components => vp_components}/components.h (100%) rename {components => vp_components}/initiator.cpp (100%) rename {components => vp_components}/initiator.h (100%) rename {components => vp_components}/resetgen.cpp (100%) rename {components => vp_components}/resetgen.h (75%) rename {components => vp_components}/router.h (100%) rename {components => vp_components}/target.cpp (100%) rename {components => vp_components}/target.h (100%) diff --git a/.cproject b/.cproject index 6336f9c..d09f2b3 100644 --- a/.cproject +++ b/.cproject @@ -51,7 +51,9 @@ + + diff --git a/CMakeLists.txt b/CMakeLists.txt index 3ad52e6..8818c6c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -8,7 +8,6 @@ set(ENABLE_SHARED TRUE CACHE BOOL "Build shared libraries") include(GNUInstallDirs) -include(Conan) include(BuildType) include(clang-format) @@ -35,8 +34,6 @@ elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC") set(warnings "/W4 /WX /EHsc") endif() -setup_conan() - # This line finds the boost lib and headers. set(Boost_NO_BOOST_CMAKE ON) # Don't do a find_package in config mode before searching for a regular boost install. find_package(Boost COMPONENTS program_options system thread REQUIRED) @@ -58,7 +55,7 @@ if(CCI_FOUND) endif() add_subdirectory(scc) -add_subdirectory(components) +add_subdirectory(vp_components) add_subdirectory(top) # CTest is a testing tool that can be used to test your project. diff --git a/README.md b/README.md index dc90e37..cf0c91d 100644 --- a/README.md +++ b/README.md @@ -8,8 +8,6 @@ A simple C++/SystemC/CMake project to test pysysc ``` -pip install conan -conan remote add minres https://api.bintray.com/conan/minres/conan-repo cd PySysC-SC mkdir build cd build @@ -18,15 +16,4 @@ cmake -DBUILD_SHARED_LIBS=ON .. cmake --build . ``` -## Notes - -If you encounter issues when linking wrt. c++11 symbols you might have run into GCC ABI incompatibility introduced from GCC 5.0 onwards. You can fix this by adding '-s compiler.libcxx=libstdc++11' to the conan call or changing compiler.libcxx to -``` -compiler.libcxx=libstdc++11 -``` -in $HOME/.conan/profiles/default or run - -``` -conan profile update settings.compiler.libcxx=libstdc++11 default -``` diff --git a/conanfile.txt b/conanfile.txt deleted file mode 100644 index cf5024c..0000000 --- a/conanfile.txt +++ /dev/null @@ -1,12 +0,0 @@ -[requires] -SystemC/2.3.3@minres/stable -SystemC-CCI/1.0.0@minres/stable - -[generators] -cmake - -[options] -SystemC:stdcxx=11 -SystemC:shared=True -SystemC-CCI:stdcxx=11 -SystemC-CCI:shared=True diff --git a/router_example.py b/router_example.py index 4e139cf..387d953 100644 --- a/router_example.py +++ b/router_example.py @@ -9,16 +9,17 @@ build_type='Debug' logging.basicConfig(level=logging.DEBUG) ############################################################################### myDir = os.path.dirname( os.path.realpath(__file__)) -res=pysysc.read_config_from_conan(os.path.join(myDir, 'conanfile.txt'), build_type) pysysc.load_systemc() ############################################################################### logging.debug("Loading SC-Components lib") -pysysc.add_include_path(os.path.join(myDir, 'scc/incl')) -pysysc.add_library('scc.h', os.path.join(myDir, 'build/%s/lib/libscc.so'%build_type)) +pysysc.add_include_path(os.path.join(myDir, 'scc/src/sysc')) +pysysc.add_include_path(os.path.join(myDir, 'scc/src/common')) +pysysc.add_include_path(os.path.join(myDir, 'scc/third_party')) +pysysc.add_library('scc_sysc.h', os.path.join(myDir, 'build/%s/scc/src/sysc/libscc-sysc.so'%build_type)) ############################################################################### logging.debug("Loading Components lib") -pysysc.add_include_path(os.path.join(myDir, 'components')) -pysysc.add_library('components.h', os.path.join(myDir, 'build/%s/lib/libcomponents.so'%build_type)) +pysysc.add_include_path(os.path.join(myDir, 'vp_components')) +pysysc.add_library('components.h', os.path.join(myDir, 'build/%s/vp_components/libvp_components.so'%build_type)) ############################################################################### # configure ############################################################################### diff --git a/router_example2.py b/router_example2.py index 22ede81..8e8dd5e 100644 --- a/router_example2.py +++ b/router_example2.py @@ -12,16 +12,17 @@ logging.basicConfig(level=logging.INFO) build_type='Debug' ############################################################################### myDir = os.path.dirname( os.path.realpath(__file__)) -pysysc.read_config_from_conan(os.path.join(myDir, 'conanfile.txt'), build_type) pysysc.load_systemc() ############################################################################### logging.debug("Loading SC-Components lib") -pysysc.add_include_path(os.path.join(myDir, 'scc/incl')) -pysysc.add_library('scc.h', os.path.join(myDir, 'build/%s/lib/libscc.so'%build_type)) +pysysc.add_include_path(os.path.join(myDir, 'scc/src/sysc')) +pysysc.add_include_path(os.path.join(myDir, 'scc/src/common')) +pysysc.add_include_path(os.path.join(myDir, 'scc/third_party')) +pysysc.add_library('scc_sysc.h', os.path.join(myDir, 'build/%s/scc/src/sysc/libscc-sysc.so'%build_type)) ############################################################################### logging.debug("Loading Components lib") -pysysc.add_include_path(os.path.join(myDir, 'components')) -pysysc.add_library('components.h', os.path.join(myDir, 'build/%s/lib/libcomponents.so'%build_type)) +pysysc.add_include_path(os.path.join(myDir, 'vp_components')) +pysysc.add_library('components.h', os.path.join(myDir, 'build/%s/vp_components/libvp_components.so'%build_type)) ############################################################################### # configure ############################################################################### diff --git a/scc b/scc index 385eed0..e98dde3 160000 --- a/scc +++ b/scc @@ -1 +1 @@ -Subproject commit 385eed07957bed93669ae6c453d706414e95aebc +Subproject commit e98dde35c4b8502eb0abef51e34f45fad8c72b81 diff --git a/top/CMakeLists.txt b/top/CMakeLists.txt index 818261c..e06a243 100644 --- a/top/CMakeLists.txt +++ b/top/CMakeLists.txt @@ -1,4 +1,4 @@ cmake_minimum_required(VERSION 3.3) set(APP_NAME top) add_executable(${APP_NAME} sc_main.cpp) -target_link_libraries (${APP_NAME} LINK_PUBLIC components) +target_link_libraries (${APP_NAME} LINK_PUBLIC vp_components) diff --git a/components/CMakeLists.txt b/vp_components/CMakeLists.txt similarity index 69% rename from components/CMakeLists.txt rename to vp_components/CMakeLists.txt index 1acfabe..0d98499 100644 --- a/components/CMakeLists.txt +++ b/vp_components/CMakeLists.txt @@ -6,8 +6,8 @@ set(LIB_SOURCES ) # Define two variables in order not to repeat ourselves. -set(LIBRARY_NAME components) +set(LIBRARY_NAME vp_components) # Define the library add_library(${LIBRARY_NAME} SHARED ${LIB_SOURCES}) target_link_libraries (${LIBRARY_NAME} LINK_PUBLIC scc) -target_include_directories (components PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}) +target_include_directories (${LIBRARY_NAME} PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}) diff --git a/components/clkgen.cpp b/vp_components/clkgen.cpp similarity index 100% rename from components/clkgen.cpp rename to vp_components/clkgen.cpp diff --git a/components/clkgen.h b/vp_components/clkgen.h similarity index 75% rename from components/clkgen.h rename to vp_components/clkgen.h index 23e2fd4..cafb2b4 100644 --- a/components/clkgen.h +++ b/vp_components/clkgen.h @@ -5,8 +5,8 @@ * Author: eyck */ -#ifndef COMPONENTS_CLKGEN_H_ -#define COMPONENTS_CLKGEN_H_ +#ifndef VP_COMPONENTS_CLKGEN_H_ +#define VP_COMPONENTS_CLKGEN_H_ #include @@ -20,4 +20,4 @@ protected: void end_of_elaboration() override; }; -#endif /* COMPONENTS_CLKGEN_H_ */ +#endif /* VP_COMPONENTS_CLKGEN_H_ */ diff --git a/components/components.h b/vp_components/components.h similarity index 100% rename from components/components.h rename to vp_components/components.h diff --git a/components/initiator.cpp b/vp_components/initiator.cpp similarity index 100% rename from components/initiator.cpp rename to vp_components/initiator.cpp diff --git a/components/initiator.h b/vp_components/initiator.h similarity index 100% rename from components/initiator.h rename to vp_components/initiator.h diff --git a/components/resetgen.cpp b/vp_components/resetgen.cpp similarity index 100% rename from components/resetgen.cpp rename to vp_components/resetgen.cpp diff --git a/components/resetgen.h b/vp_components/resetgen.h similarity index 75% rename from components/resetgen.h rename to vp_components/resetgen.h index 4148ba4..a344054 100644 --- a/components/resetgen.h +++ b/vp_components/resetgen.h @@ -5,8 +5,8 @@ * Author: eyck */ -#ifndef COMPONENTS_RESETGEN_H_ -#define COMPONENTS_RESETGEN_H_ +#ifndef VP_COMPONENTS_RESETGEN_H_ +#define VP_COMPONENTS_RESETGEN_H_ #include @@ -23,4 +23,4 @@ protected: void thread(); }; -#endif /* COMPONENTS_RESETGEN_H_ */ +#endif /* VP_COMPONENTS_RESETGEN_H_ */ diff --git a/components/router.h b/vp_components/router.h similarity index 100% rename from components/router.h rename to vp_components/router.h diff --git a/components/target.cpp b/vp_components/target.cpp similarity index 100% rename from components/target.cpp rename to vp_components/target.cpp diff --git a/components/target.h b/vp_components/target.h similarity index 100% rename from components/target.h rename to vp_components/target.h -- 2.40.1 From 1997acfb301205b07810765a0af471268452f213 Mon Sep 17 00:00:00 2001 From: Eyck Jentzsch Date: Mon, 30 Aug 2021 18:03:30 +0200 Subject: [PATCH 4/4] update scc, move to inline conan, test SC thread supports --- .pydevproject | 14 +++++++++----- CMakeLists.txt | 52 +++++++++++++++++++++++++++++++++++++++++++++++--- modules.py | 31 +++++++++++++++++++++++------- scc | 2 +- 4 files changed, 83 insertions(+), 16 deletions(-) diff --git a/.pydevproject b/.pydevproject index a16af72..7a6fcf5 100644 --- a/.pydevproject +++ b/.pydevproject @@ -1,14 +1,18 @@ - + + + + Default + - pysysc-env - python interpreter - + + 3.6 - + + diff --git a/CMakeLists.txt b/CMakeLists.txt index 8818c6c..5c9016c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -3,10 +3,8 @@ set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/cmake ${C project(pysysc-sc) -set(ENABLE_SCV TRUE CACHE BOOL "Enable use of SCV") set(ENABLE_SHARED TRUE CACHE BOOL "Build shared libraries") - include(GNUInstallDirs) include(BuildType) include(clang-format) @@ -34,12 +32,60 @@ elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC") set(warnings "/W4 /WX /EHsc") endif() +include(ConanInline) +conan_check() +set(CONAN_BOOST_OPTIONS +boost:fPIC=True +boost:shared=True +boost:header_only=False +boost:without_context=True +boost:without_contract=True +boost:without_coroutine=True +boost:without_fiber=True +boost:without_graph=True +boost:without_graph_parallel=True +boost:without_iostreams=True +boost:without_json=True +boost:without_locale=True +boost:without_log=True +boost:without_math=True +boost:without_mpi=True +boost:without_nowide=True +boost:without_python=True +boost:without_random=True +boost:without_regex=True +boost:without_serialization=True +boost:without_stacktrace=True +boost:without_test=True +boost:without_timer=True +boost:without_type_erasure=True +boost:without_wave=True +) +set(CONAN_PACKAGES boost/1.75.0) +set(CONAN_SETTINGS ${CONAN_BOOST_OPTIONS}) +if(NOT DEFINED ENV{SYSTEMC_HOME}) + set(CONAN_PACKAGES ${CONAN_PACKAGES} + systemc/2.3.3 + systemc-cci/1.0.0 + ) + set(CONAN_SETTINGS ${CONAN_SETTINGS} + #systemc:phase_cb=False + systemc-cci:shared=False + ) +endif() +conan_configure(REQUIRES ${CONAN_PACKAGES} + GENERATORS cmake_find_package + OPTIONS ${CONAN_SETTINGS} + ) +conan_install() +conan_setup(TARGETS) + # This line finds the boost lib and headers. set(Boost_NO_BOOST_CMAKE ON) # Don't do a find_package in config mode before searching for a regular boost install. find_package(Boost COMPONENTS program_options system thread REQUIRED) # set-up SystemC and SCV -find_package(OSCISystemC) +include(SystemCPackage) if(SystemC_FOUND) include_directories(${SystemC_INCLUDE_DIRS}) link_directories(${SystemC_LIBRARY_DIRS}) diff --git a/modules.py b/modules.py index de62405..f202049 100644 --- a/modules.py +++ b/modules.py @@ -18,26 +18,36 @@ logging.basicConfig(level=logging.DEBUG) build_type='Debug' ############################################################################### myDir = os.path.dirname( os.path.realpath(__file__)) -pysysc.read_config_from_conan(os.path.join(myDir, 'conanfile.txt'), build_type) +pysysc.read_config_from_conan(os.path.join(myDir, 'build/%s/conanfile.txt'%build_type), build_type) pysysc.load_systemc() ############################################################################### logging.debug("Loading SC-Components lib") -pysysc.add_include_path(os.path.join(myDir, 'scc/incl')) -pysysc.add_library('scc.h', os.path.join(myDir, 'build/%s/lib/libscc.so'%build_type)) +# pysysc.add_include_path(os.path.join(myDir, 'scc/incl')) +# pysysc.add_library('scc.h', os.path.join(myDir, 'build/%s/lib/libscc.so'%build_type)) +pysysc.add_include_path(os.path.join(myDir, 'scc/src/common')) +pysysc.add_library('scc_util.h', os.path.join(myDir, 'build/%s/scc/src/common/libscc-util.so'%build_type)) +pysysc.add_include_path(os.path.join(myDir, 'scc/third_party')) +pysysc.add_include_path(os.path.join(myDir, 'scc/third_party/scv-tr/src')) +pysysc.add_library('scv-tr.h', os.path.join(myDir, 'build/%s/scc/third_party/scv-tr/src/libscv-tr.so'%build_type)) +pysysc.add_include_path(os.path.join(myDir, 'scc/src/sysc')) +pysysc.add_library('scc_sysc.h', os.path.join(myDir, 'build/%s/scc/src/sysc/libscc-sysc.so'%build_type)) +pysysc.add_include_path(os.path.join(myDir, 'scc/src/components')) +cppyy.include('scc_components.h') ############################################################################### logging.debug("Loading Components lib") -pysysc.add_include_path(os.path.join(myDir, 'components')) -pysysc.add_library('components.h', os.path.join(myDir, 'build/%s/lib/libcomponents.so'%build_type)) +pysysc.add_include_path(os.path.join(myDir, 'vp_components')) +pysysc.add_library('components.h', os.path.join(myDir, 'build/%s/vp_components/libvp_components.so'%build_type)) ############################################################################### # define toplevel class ############################################################################### num_of_mem = 4 -class TopModule(cpp.scc.PyScModule): +from pysysc.sysc import ScModule +class TopModule(ScModule): def __init__(self, name): - super().__init__(self, name) + ScModule.__init__(self, name) ############################################################################### # instantiate ############################################################################### @@ -55,6 +65,7 @@ class TopModule(cpp.scc.PyScModule): [self.rst.sink(m.reset_i) for m in self.memories] Connection().src(self.initiator.socket).sink(self.router.target_socket) [Connection().src(self.router.initiator_socket.at(idx)).sink(m.socket) for idx,m in enumerate(self.memories)] + self.ScThread("RunThread") def EndOfElaboration(self): print("Elaboration finished") @@ -65,6 +76,12 @@ class TopModule(cpp.scc.PyScModule): def EndOfSimulation(self): print("Simulation finished") + def RunThread(self): + print("Starting RunThread") + while(cpp.sc_core.sc_time_stamp()