From 27f4e930279e8a4e0773c44eebfbf3db9b0781b4 Mon Sep 17 00:00:00 2001 From: eyck Date: Thu, 8 Oct 2020 17:45:57 +0200 Subject: [PATCH 1/3] update SCC --- .cproject | 7 +++++-- .pydevproject | 10 +++++++--- .settings/language.settings.xml | 8 +++----- CMakeLists.txt | 6 +++--- components/CMakeLists.txt | 2 +- components/initiator.cpp | 8 ++++---- components/router.h | 6 +++--- conanfile.txt | 6 +++--- router_example.py | 7 +++---- router_example2.py | 10 +++++++--- sc-components | 2 +- top/sc_main.cpp | 4 ++-- top/top.h | 11 ++++++----- 13 files changed, 48 insertions(+), 39 deletions(-) diff --git a/.cproject b/.cproject index 57cad41..bd78173 100644 --- a/.cproject +++ b/.cproject @@ -16,7 +16,7 @@ - + @@ -49,6 +49,9 @@ + + + @@ -118,4 +121,4 @@ - + \ No newline at end of file diff --git a/.pydevproject b/.pydevproject index 37ae0d1..9708187 100644 --- a/.pydevproject +++ b/.pydevproject @@ -1,6 +1,10 @@ -PySysC Python 3.6.3 -python interpreter -3.6 + + Default + + python interpreter + + 3.6 + diff --git a/.settings/language.settings.xml b/.settings/language.settings.xml index 2adf654..238ce28 100644 --- a/.settings/language.settings.xml +++ b/.settings/language.settings.xml @@ -5,13 +5,11 @@ - + - - @@ -19,11 +17,11 @@ - + - + \ No newline at end of file diff --git a/CMakeLists.txt b/CMakeLists.txt index 714b4e5..f2a1484 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -52,7 +52,7 @@ setup_conan() #find_package(Boost COMPONENTS program_options filesystem system thread REQUIRED) # set-up SystemC and SCV -find_package(SystemC) +find_package(OSCISystemC) if(SystemC_FOUND) include_directories(${SystemC_INCLUDE_DIRS}) link_directories(${SystemC_LIBRARY_DIRS}) @@ -63,8 +63,8 @@ endif() if(CCI_FOUND) include_directories(${CCI_INCLUDE_DIRS}) link_directories(${CCI_LIBRARY_DIRS}) -else() - message( FATAL_ERROR "SystemC CCI library not found." ) +#else() + #message( FATAL_ERROR "SystemC CCI library not found." ) endif() include(sc-components/cmake/clang-format.cmake) diff --git a/components/CMakeLists.txt b/components/CMakeLists.txt index 7e747a5..b60cdb3 100644 --- a/components/CMakeLists.txt +++ b/components/CMakeLists.txt @@ -10,5 +10,5 @@ set(LIB_SOURCES set(LIBRARY_NAME components) # Define the library add_library(${LIBRARY_NAME} SHARED ${LIB_SOURCES}) -target_link_libraries (${LIBRARY_NAME} LINK_PUBLIC sc-components) +target_link_libraries (${LIBRARY_NAME} LINK_PUBLIC scc) target_include_directories (components PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}) diff --git a/components/initiator.cpp b/components/initiator.cpp index 90f64f1..a13c127 100644 --- a/components/initiator.cpp +++ b/components/initiator.cpp @@ -55,7 +55,7 @@ void Initiator::thread_process() { wait( dmi_data.get_write_latency() ); } - SCINFO() << "DMI = { " << (cmd ? 'W' : 'R') << ", " << hex << i + SCCINFO() << "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 ); } - SCINFO() << "trans = { " << (cmd ? 'W' : 'R') << ", " << hex << i + SCCINFO() << "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) { - SCINFO() << "mem[" << (A + i) << "] = " + SCCINFO() << "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) { - SCINFO() << "mem[" << (A + i) << "] = " + SCCINFO() << "mem[" << (A + i) << "] = " << *(reinterpret_cast( &data[i] )); } } diff --git a/components/router.h b/components/router.h index 34e62b8..8e2420c 100644 --- a/components/router.h +++ b/components/router.h @@ -124,14 +124,14 @@ struct Router: sc_module // Simple fixed address decoding inline unsigned int decode_address( sc_dt::uint64 address, sc_dt::uint64& masked_address ) { - unsigned int target_nr = static_cast( (address >> 8) & 0x3 ); - masked_address = address & 0xFF; + unsigned int target_nr = static_cast( (address >> 10) % initiator_socket.size() ); + masked_address = address & 0x3FF; return target_nr; } inline sc_dt::uint64 compose_address( unsigned int target_nr, sc_dt::uint64 address) { - return (target_nr << 8) | (address & 0xFF); + return (target_nr << 10) | (address & 0x3FF); } }; diff --git a/conanfile.txt b/conanfile.txt index 941d2c2..92ae706 100644 --- a/conanfile.txt +++ b/conanfile.txt @@ -1,7 +1,7 @@ [requires] fmt/5.2.1@bincrafters/stable -SystemC/2.3.2@minres/stable -SystemC-CCI/1.0.0@minres/stable +SystemC/2.3.3@minres/stable +#SystemC-CCI/1.0.0@minres/stable [generators] cmake @@ -10,4 +10,4 @@ cmake fmt:header_only=True SystemC:stdcxx=11 SystemC:shared=True -SystemC-CCI:stdcxx=11 \ No newline at end of file +#SystemC-CCI:stdcxx=11 diff --git a/router_example.py b/router_example.py index b54ea26..05fa02f 100644 --- a/router_example.py +++ b/router_example.py @@ -14,7 +14,7 @@ pysysc.load_systemc() ############################################################################### logging.debug("Loading SC-Components lib") pysysc.add_include_path(os.path.join(myDir, 'sc-components/incl')) -pysysc.add_library('scc.h', os.path.join(myDir, 'build/%s/lib/libsc-components.so'%build_type)) +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')) @@ -22,7 +22,7 @@ pysysc.add_library('components.h', os.path.join(myDir, 'build/%s/lib/libcomponen ############################################################################### # configure ############################################################################### -cpp.scc.init_logging(cpp.logging.INFO, False); +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") ############################################################################### @@ -58,7 +58,6 @@ for idx,m in enumerate(memories): if __name__ == "__main__": if os.path.isfile('router_example.json'): cfg = cpp.scc.configurer(cpp.std.string('router_example.json')); - trace = cpp.scc.configurable_tracer("router_example", 1, True, True) - trace.add_control() + tracer = cpp.scc.tracer('vcd_trace', 1, True) cpp.sc_core.sc_start() logging.debug("Done") diff --git a/router_example2.py b/router_example2.py index a04f81a..b4927b8 100644 --- a/router_example2.py +++ b/router_example2.py @@ -2,6 +2,7 @@ import os.path import logging from cppyy import gbl as cpp import pysysc +import pysysc.structural as struct from pysysc.structural import Connection, Module, Signal, Simulation ############################################################################### @@ -16,7 +17,7 @@ pysysc.load_systemc() ############################################################################### logging.debug("Loading SC-Components lib") pysysc.add_include_path(os.path.join(myDir, 'sc-components/incl')) -pysysc.add_library('scc.h', os.path.join(myDir, 'build/%s/lib/libsc-components.so'%build_type)) +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')) @@ -31,8 +32,8 @@ Simulation.setup(logging.root.level) clk_gen = Module(cpp.ClkGen).create("clk_gen") rst_gen = Module(cpp.ResetGen).create("rst_gen") initiator = Module(cpp.Initiator).create("initiator") -memories = [Module(cpp.Memory).create(name) for name in ["mem0", "mem1", "mem2", "mem3"]] -router = Module(cpp.Router[4]).create("router") +memories = [Module(cpp.Memory).create("mem%d"%i) for i in range(2)] +router = Module(cpp.Router[len(memories)]).create("router") ############################################################################### # connect it ############################################################################### @@ -45,6 +46,9 @@ Connection().src(initiator.socket).sink(router.target_socket) ############################################################################### # run if it is standalone ############################################################################### +struct.dump_structure() +simcontext = cpp.sc_core.sc_get_curr_simcontext() +objects = cpp.sc_core.sc_get_top_level_objects(simcontext) if __name__ == "__main__": Simulation.configure(enable_vcd=True) Simulation.run() diff --git a/sc-components b/sc-components index 3419e18..2d83649 160000 --- a/sc-components +++ b/sc-components @@ -1 +1 @@ -Subproject commit 3419e182354b400d397c3f62b8b47383249dd1d0 +Subproject commit 2d83649df082540eb37fa03b8658f08361addda8 diff --git a/top/sc_main.cpp b/top/sc_main.cpp index 1c5faae..f57004b 100644 --- a/top/sc_main.cpp +++ b/top/sc_main.cpp @@ -29,8 +29,8 @@ int sc_main(int argc, char *argv[]) { /////////////////////////////////////////////////////////////////////////// // configure logging /////////////////////////////////////////////////////////////////////////// - scc::init_logging(logging::INFO); - //scc::init_logging(logging::WARNING); + scc::init_logging(log::INFO); + //scc::init_logging(log::WARNING); /////////////////////////////////////////////////////////////////////////// // instantiate top level diff --git a/top/top.h b/top/top.h index 0b5ea74..6e152c5 100644 --- a/top/top.h +++ b/top/top.h @@ -7,13 +7,14 @@ #include #include +enum { SLV_CNT=2}; SC_MODULE(Top) { ClkGen * clk_gen; ResetGen* reset_gen; Initiator* initiator; - Router<4>* router; - Memory* memory[4]; + Router* router; + Memory* memory[SLV_CNT]; Top(const sc_core::sc_module_name& nm) : sc_core::sc_module() @@ -24,8 +25,8 @@ SC_MODULE(Top) { clk_gen=new ClkGen("clk_gen"); reset_gen=new ResetGen("reset_gen"); initiator = new Initiator("initiator"); - router = new Router<4>("router"); - for (int i = 0; i < 4; i++) { + router = new Router("router"); + for (int i = 0; i < SLV_CNT; i++) { char txt[20]; sprintf(txt, "memory_%d", i); memory[i] = new Memory(txt); @@ -33,7 +34,7 @@ SC_MODULE(Top) { // Bind sockets initiator->socket.bind(router->target_socket); - for (int i = 0; i < 4; i++) + for (int i = 0; i < SLV_CNT; i++) router->initiator_socket[i].bind(memory[i]->socket); // connect signals clk_gen->clk_o(clk); From f1a15fa4cbd50724a6f04a1bab998857f5eec7b8 Mon Sep 17 00:00:00 2001 From: Eyck Jentzsch Date: Sat, 13 Mar 2021 14:57:31 +0100 Subject: [PATCH 2/3] update to latest SCC --- .gitmodules | 2 +- CMakeLists.txt | 17 ++++------------- cmake/Common.cmake | 20 -------------------- cmake/Conan.cmake | 45 --------------------------------------------- conanfile.txt | 2 -- sc-components | 2 +- 6 files changed, 6 insertions(+), 82 deletions(-) delete mode 100644 cmake/Common.cmake delete mode 100644 cmake/Conan.cmake diff --git a/.gitmodules b/.gitmodules index 73349ab..fbca556 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,3 +1,3 @@ [submodule "sc-components"] path = sc-components - url = https://git.minres.com/SystemC/SystemC-Components.git + url = https://github.com/Minres/SystemC-Components.git diff --git a/CMakeLists.txt b/CMakeLists.txt index f2a1484..b27b8d9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,22 +1,13 @@ cmake_minimum_required(VERSION 3.3) set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/cmake ${CMAKE_CURRENT_SOURCE_DIR}/sc-components/cmake) +project(pysysc-sc) + set(ENABLE_SCV TRUE CACHE BOOL "Enable use of SCV") set(ENABLE_SHARED TRUE CACHE BOOL "Build shared libraries") -include(GitFunctions) -get_branch_from_git() - -### set the directory names of the submodules -set(GIT_SUBMODULES sc-components) -set(GIT_SUBMODULE_DIR_sc-components .) -### set each submodules's commit or tag that is to be checked out -### (leave empty if you want master) -#set(GIT_SUBMODULE_VERSION_sc-components 3af6b9836589b082c19d9131c5d0b7afa8ddd7cd) -set(GIT_SUBMODULE_BRANCH_sc-components ${GIT_BRANCH}) include(GNUInstallDirs) -include(Submodules) include(Conan) include(BuildType) @@ -48,8 +39,8 @@ 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 filesystem system thread REQUIRED) +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) diff --git a/cmake/Common.cmake b/cmake/Common.cmake deleted file mode 100644 index 673ec59..0000000 --- a/cmake/Common.cmake +++ /dev/null @@ -1,20 +0,0 @@ -# Function to link between sub-projects -function(add_dependent_subproject subproject_name) - #if (NOT TARGET ${subproject_name}) # target unknown - if(NOT PROJECT_${subproject_name}) # var unknown because we build only this subproject - find_package(${subproject_name} CONFIG REQUIRED) - else () # we know the target thus we are doing a build from the top directory - include_directories(../${subproject_name}/incl) - endif () -endfunction(add_dependent_subproject) - -# Make sure we tell the topdir CMakeLists that we exist (if build from topdir) -get_directory_property(hasParent PARENT_DIRECTORY) -if(hasParent) - set(PROJECT_${PROJECT_NAME} true PARENT_SCOPE) -endif() - -# Function to link between sub-projects -function(add_dependent_header subproject_name) - include_directories(../${subproject_name}/incl) -endfunction(add_dependent_header) diff --git a/cmake/Conan.cmake b/cmake/Conan.cmake deleted file mode 100644 index 5bd9930..0000000 --- a/cmake/Conan.cmake +++ /dev/null @@ -1,45 +0,0 @@ -macro(setup_conan) - find_program(conan conan) - if(NOT EXISTS ${conan}) - message(FATAL_ERROR "Conan is required. Please see README.md") - return() - endif() - - if(${CMAKE_HOST_SYSTEM_NAME} STREQUAL Darwin) - set(os Macos) - else() - set(os ${CMAKE_HOST_SYSTEM_NAME}) - endif() - - if(${CMAKE_CXX_COMPILER_ID} STREQUAL GNU) - set(compiler gcc) - elseif(${CMAKE_CXX_COMPILER_ID} STREQUAL AppleClang) - set(compiler apple-clang) - else() - message(FATAL_ERROR "Unknown compiler: ${CMAKE_CXX_COMPILER_ID}") - endif() - - string(SUBSTRING ${CMAKE_CXX_COMPILER_VERSION} 0 3 compiler_version) - - set(conanfile ${CMAKE_SOURCE_DIR}/conanfile.txt) - set(conanfile_cmake ${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) - set(compiler_libcxx libstdc++11) - - if("${CMAKE_BUILD_TYPE}" STREQUAL "") - set(CONAN_BUILD_TYPE Debug) - elseif("${CMAKE_BUILD_TYPE}" STREQUAL "RelWithDebInfo") - set(CONAN_BUILD_TYPE Release) - else() - set(CONAN_BUILD_TYPE ${CMAKE_BUILD_TYPE}) - endif() - - execute_process(COMMAND ${conan} install --build=missing - -s build_type=${CONAN_BUILD_TYPE} -s compiler.libcxx=${compiler_libcxx} - ${CMAKE_SOURCE_DIR} RESULT_VARIABLE return_code) - if(NOT ${return_code} EQUAL 0) - message(FATAL_ERROR "conan install command failed.") - endif() - - include(${conanfile_cmake}) - conan_basic_setup() -endmacro() diff --git a/conanfile.txt b/conanfile.txt index 92ae706..9c5e086 100644 --- a/conanfile.txt +++ b/conanfile.txt @@ -1,7 +1,6 @@ [requires] fmt/5.2.1@bincrafters/stable SystemC/2.3.3@minres/stable -#SystemC-CCI/1.0.0@minres/stable [generators] cmake @@ -10,4 +9,3 @@ cmake fmt:header_only=True SystemC:stdcxx=11 SystemC:shared=True -#SystemC-CCI:stdcxx=11 diff --git a/sc-components b/sc-components index 2d83649..385eed0 160000 --- a/sc-components +++ b/sc-components @@ -1 +1 @@ -Subproject commit 2d83649df082540eb37fa03b8658f08361addda8 +Subproject commit 385eed07957bed93669ae6c453d706414e95aebc From c75d64a356f0e7423c55356cfca1b28d255ab76c Mon Sep 17 00:00:00 2001 From: Eyck Jentzsch Date: Sat, 13 Mar 2021 14:58:32 +0100 Subject: [PATCH 3/3] update .gitignore --- .gitignore | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.gitignore b/.gitignore index 84c048a..85d5cdd 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,3 @@ /build/ +/.settings +/*.vcd