diff --git a/.cproject b/.cproject
index 6336f9c..d09f2b3 100644
--- a/.cproject
+++ b/.cproject
@@ -51,7 +51,9 @@
+
+
diff --git a/.pydevproject b/.pydevproject
index 9708187..7a6fcf5 100644
--- a/.pydevproject
+++ b/.pydevproject
@@ -1,10 +1,18 @@
+
+
Default
+
+
python interpreter
+
+
3.6
-
+
+
+
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 3ad52e6..5c9016c 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -3,12 +3,9 @@ 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(Conan)
include(BuildType)
include(clang-format)
@@ -35,14 +32,60 @@ elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC")
set(warnings "/W4 /WX /EHsc")
endif()
-setup_conan()
+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})
@@ -58,7 +101,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/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/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/modules.py b/modules.py
new file mode 100644
index 0000000..f202049
--- /dev/null
+++ b/modules.py
@@ -0,0 +1,100 @@
+#
+# 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, '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/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, '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
+
+from pysysc.sysc import ScModule
+class TopModule(ScModule):
+
+ def __init__(self, name):
+ ScModule.__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)]
+ self.ScThread("RunThread")
+
+ def EndOfElaboration(self):
+ print("Elaboration finished")
+
+ def StartOfSimulation(self):
+ print("Simulation started")
+
+ def EndOfSimulation(self):
+ print("Simulation finished")
+
+ def RunThread(self):
+ print("Starting RunThread")
+ while(cpp.sc_core.sc_time_stamp()
@@ -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 94%
rename from components/initiator.cpp
rename to vp_components/initiator.cpp
index a13c127..c246c0e 100644
--- a/components/initiator.cpp
+++ b/vp_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/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