Merge branch 'develop'
This commit is contained in:
commit
104cb8afa3
|
@ -2,4 +2,7 @@
|
||||||
/.settings
|
/.settings
|
||||||
/*.vcd
|
/*.vcd
|
||||||
/*.png
|
/*.png
|
||||||
/*.dot
|
/*.dot
|
||||||
|
/*.fst
|
||||||
|
/*.ftr
|
||||||
|
/.venv
|
|
@ -0,0 +1,29 @@
|
||||||
|
{
|
||||||
|
// Use IntelliSense to learn about possible attributes.
|
||||||
|
// Hover to view descriptions of existing attributes.
|
||||||
|
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
|
||||||
|
"version": "0.2.0",
|
||||||
|
"configurations": [
|
||||||
|
{
|
||||||
|
"name": "Python Debugger: router_example.py",
|
||||||
|
"type": "debugpy",
|
||||||
|
"request": "launch",
|
||||||
|
"program": "${workspaceFolder}/router_example.py",
|
||||||
|
"console": "integratedTerminal"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Python Debugger: router_example2.py",
|
||||||
|
"type": "debugpy",
|
||||||
|
"request": "launch",
|
||||||
|
"program": "${workspaceFolder}/router_example2.py",
|
||||||
|
"console": "integratedTerminal"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Python Debugger: modules.py",
|
||||||
|
"type": "debugpy",
|
||||||
|
"request": "launch",
|
||||||
|
"program": "${workspaceFolder}/modules.py",
|
||||||
|
"console": "integratedTerminal"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
|
@ -0,0 +1,14 @@
|
||||||
|
{
|
||||||
|
"editor.rulers": [
|
||||||
|
{
|
||||||
|
"column": 140,
|
||||||
|
"comment": "clang-format"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"editor.formatOnSave": true,
|
||||||
|
"editor.defaultFormatter": "llvm-vs-code-extensions.vscode-clangd",
|
||||||
|
"cmake.buildDirectory": "${workspaceFolder}/build",
|
||||||
|
"[jsonc]": {
|
||||||
|
"editor.defaultFormatter": "vscode.json-language-features"
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,32 @@
|
||||||
|
{
|
||||||
|
"version": "2.0.0",
|
||||||
|
"tasks": [
|
||||||
|
{
|
||||||
|
"label": "router_example",
|
||||||
|
"type": "shell",
|
||||||
|
"command": "python3 router_example.py",
|
||||||
|
"options": {
|
||||||
|
"cwd": "${workspaceFolder}"
|
||||||
|
},
|
||||||
|
"problemMatcher": []
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"label": "router_example2",
|
||||||
|
"type": "shell",
|
||||||
|
"command": "python3 router_example2.py",
|
||||||
|
"options": {
|
||||||
|
"cwd": "${workspaceFolder}"
|
||||||
|
},
|
||||||
|
"problemMatcher": []
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"label": "modules",
|
||||||
|
"type": "shell",
|
||||||
|
"command": "python3 modules.py",
|
||||||
|
"options": {
|
||||||
|
"cwd": "${workspaceFolder}"
|
||||||
|
},
|
||||||
|
"problemMatcher": []
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
|
@ -1,4 +1,4 @@
|
||||||
cmake_minimum_required(VERSION 3.3)
|
cmake_minimum_required(VERSION 3.12)
|
||||||
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/cmake ${CMAKE_CURRENT_SOURCE_DIR}/scc/cmake)
|
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/cmake ${CMAKE_CURRENT_SOURCE_DIR}/scc/cmake)
|
||||||
|
|
||||||
project(pysysc-sc)
|
project(pysysc-sc)
|
||||||
|
@ -9,10 +9,10 @@ include(GNUInstallDirs)
|
||||||
include(BuildType)
|
include(BuildType)
|
||||||
include(clang-format)
|
include(clang-format)
|
||||||
|
|
||||||
set(CMAKE_CXX_STANDARD 11)
|
|
||||||
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||||
set(CMAKE_CXX_EXTENSIONS OFF)
|
set(CMAKE_CXX_EXTENSIONS OFF)
|
||||||
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
|
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
|
||||||
|
set(CMAKE_CXX_STANDARD 17)
|
||||||
|
|
||||||
include(CheckCXXCompilerFlag)
|
include(CheckCXXCompilerFlag)
|
||||||
CHECK_CXX_COMPILER_FLAG("-march=native" COMPILER_SUPPORTS_MARCH_NATIVE)
|
CHECK_CXX_COMPILER_FLAG("-march=native" COMPILER_SUPPORTS_MARCH_NATIVE)
|
||||||
|
@ -51,17 +51,44 @@ if(EXISTS /etc/redhat-release)
|
||||||
endif()
|
endif()
|
||||||
# Boost on CentOS quirks end
|
# Boost on CentOS quirks end
|
||||||
endif()
|
endif()
|
||||||
set(CONAN_PACKAGE_LIST fmt/8.0.1 spdlog/1.9.2 zlib/1.2.11 boost/1.75.0 yaml-cpp/0.7.0 lz4/1.9.3)
|
set(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_PACKAGE_LIST fmt/8.0.1 spdlog/1.9.2 zlib/1.2.11 boost/1.75.0 yaml-cpp/0.7.0 jsoncpp/1.9.5 lz4/1.9.3)
|
||||||
if(BUILD_SCC_DOCUMENTATION)
|
if(BUILD_SCC_DOCUMENTATION)
|
||||||
list(APPEND CONAN_PACKAGE_LIST doxygen/1.9.2)
|
list(APPEND CONAN_PACKAGE_LIST doxygen/1.9.2)
|
||||||
endif()
|
endif()
|
||||||
set(CONAN_PACKAGE_OPTIONS fmt:header_only=True spdlog:header_only=True boost:without_stacktrace=True boost:shared=False boost:header_only=False)
|
set(CONAN_PACKAGE_OPTIONS fmt:header_only=True spdlog:header_only=True ${BOOST_OPTIONS})
|
||||||
if(${CMAKE_SYSTEM_NAME} STREQUAL "Linux")
|
if(${CMAKE_SYSTEM_NAME} STREQUAL "Linux")
|
||||||
list(APPEND CONAN_PACKAGE_OPTIONS boost:fPIC=True)
|
list(APPEND CONAN_PACKAGE_OPTIONS boost:fPIC=True)
|
||||||
endif()
|
endif()
|
||||||
if(NOT USE_CWR_SYSTEMC AND NOT USE_NCSC_SYSTEMC AND NOT DEFINED ENV{SYSTEMC_HOME})
|
if(NOT USE_CWR_SYSTEMC AND NOT USE_NCSC_SYSTEMC AND NOT DEFINED ENV{SYSTEMC_HOME})
|
||||||
set(CONAN_PACKAGE_LIST ${CONAN_PACKAGE_LIST} systemc/2.3.3 systemc-cci/1.0.0)
|
set(CONAN_PACKAGE_LIST ${CONAN_PACKAGE_LIST} systemc/2.3.4)
|
||||||
set(CONAN_PACKAGE_OPTIONS ${CONAN_PACKAGE_OPTIONS} systemc-cci:shared=False)
|
set(CONAN_PACKAGE_OPTIONS ${CONAN_PACKAGE_OPTIONS} systemc:shared=True)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
conan_configure(REQUIRES ${CONAN_PACKAGE_LIST} GENERATORS cmake_find_package OPTIONS ${CONAN_PACKAGE_OPTIONS})
|
conan_configure(REQUIRES ${CONAN_PACKAGE_LIST} GENERATORS cmake_find_package OPTIONS ${CONAN_PACKAGE_OPTIONS})
|
||||||
|
@ -81,12 +108,11 @@ find_package(spdlog REQUIRED)
|
||||||
find_package(lz4 REQUIRED)
|
find_package(lz4 REQUIRED)
|
||||||
find_package(fmt REQUIRED)
|
find_package(fmt REQUIRED)
|
||||||
find_package(yaml-cpp REQUIRED)
|
find_package(yaml-cpp REQUIRED)
|
||||||
|
|
||||||
include(SystemCPackage)
|
include(SystemCPackage)
|
||||||
|
|
||||||
add_subdirectory(scc)
|
add_subdirectory(scc)
|
||||||
add_subdirectory(vp_components)
|
add_subdirectory(vp_components)
|
||||||
add_subdirectory(top)
|
#add_subdirectory(top)
|
||||||
|
|
||||||
# CTest is a testing tool that can be used to test your project.
|
# CTest is a testing tool that can be used to test your project.
|
||||||
# enable_testing()
|
# enable_testing()
|
||||||
|
|
27
README.md
27
README.md
|
@ -4,16 +4,29 @@ A simple C++/SystemC/CMake project to test pysysc
|
||||||
|
|
||||||
# How to build
|
# How to build
|
||||||
|
|
||||||
> Currently only Linux and MacOS are tested
|
> Currently only Linux and MacOS are tested.
|
||||||
|
|
||||||
|
The install instruction below assume using bash.
|
||||||
|
|
||||||
```
|
```
|
||||||
|
git clone --recursive -b develop https://git.minres.com/SystemC/PySysC-SC.git
|
||||||
cd PySysC-SC
|
cd PySysC-SC
|
||||||
mkdir build
|
python3 -mvenv .venv
|
||||||
cd build
|
. .venv/bin/activate
|
||||||
conan install .. --build=missing
|
pip install "conan<2.0"
|
||||||
cmake -DBUILD_SHARED_LIBS=ON ..
|
cmake -S . -B build -DBUILD_SHARED_LIBS=ON -DCMAKE_EXPORT_COMPILE_COMMANDS=ON
|
||||||
cmake --build .
|
cmake --build build -j24
|
||||||
|
export SYSTEMC_HOME=$(grep -A1 rootpath_systemc\] build/conanbuildinfo.txt | tail -1)
|
||||||
|
export STDCXX=17
|
||||||
|
pip install "cppyy<3.0"
|
||||||
|
pip install https://github.com/Minres/PySysC/tarball/master
|
||||||
|
pip install scc/contrib/pysysc/
|
||||||
|
python3 router_example.py
|
||||||
|
python3 router_example2.py
|
||||||
|
python3 modules.py
|
||||||
```
|
```
|
||||||
|
|
||||||
|
These steps clone the PySysC-SC repository and builds the shared libraries using conan 1.x.
|
||||||
|
This also downloads and builds SYSTEMC (as a conan package).
|
||||||
|
Then it installs the python packages cppyy, PySysC, and PySysC.SCC using the same settings as the cmake build.
|
||||||
|
Eventually it runs the 3 examples.
|
||||||
|
|
86
modules.py
86
modules.py
|
@ -4,48 +4,43 @@
|
||||||
# SPDX-License-Identifier: Apache-2.0
|
# SPDX-License-Identifier: Apache-2.0
|
||||||
#
|
#
|
||||||
|
|
||||||
import os.path
|
|
||||||
import logging
|
import logging
|
||||||
import cppyy
|
import os.path
|
||||||
from cppyy import gbl as cpp
|
|
||||||
import pysysc
|
import pysysc
|
||||||
|
import pysysc.scc as scc
|
||||||
|
from cppyy import gbl as cpp
|
||||||
from pysysc.structural import Connection, Module, Signal, Simulation
|
from pysysc.structural import Connection, Module, Signal, Simulation
|
||||||
|
|
||||||
###############################################################################
|
###############################################################################
|
||||||
# setup and load
|
# setup and load
|
||||||
###############################################################################
|
###############################################################################
|
||||||
logging.basicConfig(level=logging.DEBUG)
|
logging.basicConfig(level=logging.DEBUG)
|
||||||
build_type='Debug'
|
|
||||||
###############################################################################
|
###############################################################################
|
||||||
myDir = os.path.dirname( os.path.realpath(__file__))
|
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(17)
|
||||||
pysysc.load_systemc()
|
|
||||||
###############################################################################
|
###############################################################################
|
||||||
logging.debug("Loading SC-Components lib")
|
logging.debug("Loading SC-Components lib")
|
||||||
# pysysc.add_include_path(os.path.join(myDir, 'scc/incl'))
|
scc.load_lib(myDir)
|
||||||
# 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")
|
logging.debug("Loading Components lib")
|
||||||
pysysc.add_include_path(os.path.join(myDir, 'vp_components'))
|
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))
|
pysysc.add_library("components.h", "libvp_components.so", myDir)
|
||||||
|
###############################################################################
|
||||||
|
# configure
|
||||||
|
###############################################################################
|
||||||
|
scc.setup(logging.root.level)
|
||||||
|
scc.configure(enable_trace=False)
|
||||||
###############################################################################
|
###############################################################################
|
||||||
# define toplevel class
|
# define toplevel class
|
||||||
###############################################################################
|
###############################################################################
|
||||||
num_of_mem = 4
|
num_of_mem = 4
|
||||||
|
|
||||||
from pysysc.sysc import ScModule
|
from pysysc.sysc import ScModule
|
||||||
|
|
||||||
|
|
||||||
class TopModule(ScModule):
|
class TopModule(ScModule):
|
||||||
|
|
||||||
def __init__(self, name):
|
def __init__(self, name):
|
||||||
ScModule.__init__(self, name)
|
ScModule.__init__(self, name)
|
||||||
###############################################################################
|
###############################################################################
|
||||||
|
@ -54,47 +49,62 @@ class TopModule(ScModule):
|
||||||
self.clk_gen = Module(cpp.ClkGen).create("clk_gen")
|
self.clk_gen = Module(cpp.ClkGen).create("clk_gen")
|
||||||
self.rst_gen = Module(cpp.ResetGen).create("rst_gen")
|
self.rst_gen = Module(cpp.ResetGen).create("rst_gen")
|
||||||
self.initiator = Module(cpp.Initiator).create("initiator")
|
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.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")
|
self.router = Module(cpp.Router[num_of_mem]).create("router")
|
||||||
###############################################################################
|
###############################################################################
|
||||||
# connect them
|
# connect them
|
||||||
###############################################################################
|
###############################################################################
|
||||||
self.clk = Signal("clk").src(self.clk_gen.clk_o).sink(self.initiator.clk_i).sink(self.router.clk_i)
|
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.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 = (
|
||||||
|
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]
|
[self.rst.sink(m.reset_i) for m in self.memories]
|
||||||
Connection().src(self.initiator.socket).sink(self.router.target_socket)
|
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)]
|
[
|
||||||
|
Connection().src(self.router.initiator_socket.at(idx)).sink(m.socket)
|
||||||
|
for idx, m in enumerate(self.memories)
|
||||||
|
]
|
||||||
self.ScThread("RunThread")
|
self.ScThread("RunThread")
|
||||||
|
|
||||||
def EndOfElaboration(self):
|
def EndOfElaboration(self):
|
||||||
print("Elaboration finished")
|
print("Elaboration finished")
|
||||||
|
|
||||||
def StartOfSimulation(self):
|
def StartOfSimulation(self):
|
||||||
print("Simulation started")
|
print("Simulation started")
|
||||||
|
|
||||||
def EndOfSimulation(self):
|
def EndOfSimulation(self):
|
||||||
print("Simulation finished")
|
print("Simulation finished")
|
||||||
|
|
||||||
def RunThread(self):
|
def RunThread(self):
|
||||||
print("Starting RunThread")
|
print("Starting RunThread")
|
||||||
while(cpp.sc_core.sc_time_stamp()<cpp.sc_core.sc_time(500, cpp.sc_core.SC_NS)):
|
while cpp.sc_core.sc_time_stamp() < cpp.sc_core.sc_time(500, cpp.sc_core.SC_NS):
|
||||||
#self.pyScWait(self.clk.signal.value_changed_event())
|
# self.pyScWait(self.clk.signal.value_changed_event())
|
||||||
self.ScWait(cpp.sc_core.sc_time(100, cpp.sc_core.SC_NS))
|
self.ScWait(cpp.sc_core.sc_time(100, cpp.sc_core.SC_NS))
|
||||||
print("Hello from Thread %s, @ %s"%(self.name(), cpp.sc_core.sc_time_stamp().to_string()))
|
print(
|
||||||
###############################################################################
|
"Hello from Thread %s, @ %s"
|
||||||
# configure
|
% (self.name(), cpp.sc_core.sc_time_stamp().to_string())
|
||||||
###############################################################################
|
)
|
||||||
Simulation.setup(logging.root.level)
|
|
||||||
|
|
||||||
###############################################################################
|
###############################################################################
|
||||||
# instantiate
|
# instantiate
|
||||||
###############################################################################
|
###############################################################################
|
||||||
#from modules import TopModule
|
# from modules import TopModule
|
||||||
dut = Module(TopModule).create("dut")
|
dut = Module(TopModule).create("dut")
|
||||||
###############################################################################
|
###############################################################################
|
||||||
# run if it is standalone
|
# run if it is standalone
|
||||||
###############################################################################
|
###############################################################################
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
Simulation.configure(enable_vcd=False)
|
|
||||||
Simulation.run()
|
Simulation.run()
|
||||||
logging.debug("Done")
|
logging.debug("Done")
|
||||||
|
|
|
@ -1,37 +1,45 @@
|
||||||
import os.path
|
|
||||||
import logging
|
import logging
|
||||||
from cppyy import gbl as cpp
|
import os.path
|
||||||
|
|
||||||
import pysysc
|
import pysysc
|
||||||
|
from cppyy import gbl as cpp
|
||||||
|
|
||||||
###############################################################################
|
###############################################################################
|
||||||
# setup and load
|
# setup and load
|
||||||
###############################################################################
|
###############################################################################
|
||||||
build_type='Debug'
|
|
||||||
logging.basicConfig(level=logging.DEBUG)
|
logging.basicConfig(level=logging.DEBUG)
|
||||||
###############################################################################
|
###############################################################################
|
||||||
myDir = os.path.dirname( os.path.realpath(__file__))
|
myDir = os.path.dirname(os.path.realpath(__file__))
|
||||||
pysysc.load_systemc()
|
pysysc.load_systemc(17)
|
||||||
###############################################################################
|
###############################################################################
|
||||||
logging.debug("Loading SC-Components lib")
|
logging.debug("Loading SC-Components lib")
|
||||||
pysysc.add_include_path(os.path.join(myDir, 'scc/src/sysc'))
|
pysysc.add_include_path(os.path.join(myDir, "scc/third_party/cci-1.0.0"))
|
||||||
pysysc.add_include_path(os.path.join(myDir, 'scc/src/common'))
|
pysysc.add_include_path(os.path.join(myDir, "scc/third_party/scv-tr/src"))
|
||||||
pysysc.add_include_path(os.path.join(myDir, 'scc/third_party'))
|
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/common"))
|
||||||
|
pysysc.add_include_path(os.path.join(myDir, "scc/third_party"))
|
||||||
|
pysysc.add_library("scc_sysc.h", "libscc-sysc.so", myDir)
|
||||||
###############################################################################
|
###############################################################################
|
||||||
logging.debug("Loading Components lib")
|
logging.debug("Loading Components lib")
|
||||||
pysysc.add_include_path(os.path.join(myDir, 'vp_components'))
|
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))
|
pysysc.add_library("components.h", "libvp_components.so", myDir)
|
||||||
###############################################################################
|
###############################################################################
|
||||||
# configure
|
# configure
|
||||||
###############################################################################
|
###############################################################################
|
||||||
cpp.scc.init_logging(cpp.scc.log.INFO, 24, 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.sc_core.sc_report_handler.set_actions(
|
||||||
|
cpp.sc_core.SC_ID_MORE_THAN_ONE_SIGNAL_DRIVER_, cpp.sc_core.SC_DO_NOTHING
|
||||||
|
)
|
||||||
###############################################################################
|
###############################################################################
|
||||||
# instantiate
|
# instantiate
|
||||||
###############################################################################
|
###############################################################################
|
||||||
clkgen = cpp.ClkGen(cpp.sc_core.sc_module_name("clk_gen"))
|
clkgen = cpp.ClkGen(cpp.sc_core.sc_module_name("clk_gen"))
|
||||||
rstgen = cpp.ResetGen(cpp.sc_core.sc_module_name("rst_gen"))
|
rstgen = cpp.ResetGen(cpp.sc_core.sc_module_name("rst_gen"))
|
||||||
initiator = cpp.Initiator(cpp.sc_core.sc_module_name("initiator"))
|
initiator = cpp.Initiator(cpp.sc_core.sc_module_name("initiator"))
|
||||||
memories = [cpp.Memory(cpp.sc_core.sc_module_name(name)) for name in ["mem0", "mem1", "mem2", "mem3"]]
|
memories = [
|
||||||
|
cpp.Memory(cpp.sc_core.sc_module_name(name))
|
||||||
|
for name in ["mem0", "mem1", "mem2", "mem3"]
|
||||||
|
]
|
||||||
router = cpp.Router[4](cpp.sc_core.sc_module_name("router"))
|
router = cpp.Router[4](cpp.sc_core.sc_module_name("router"))
|
||||||
###############################################################################
|
###############################################################################
|
||||||
# signals
|
# signals
|
||||||
|
@ -48,7 +56,7 @@ initiator.clk_i(sig_clk)
|
||||||
initiator.reset_i(sig_rst)
|
initiator.reset_i(sig_rst)
|
||||||
router.clk_i(sig_clk)
|
router.clk_i(sig_clk)
|
||||||
router.reset_i(sig_rst)
|
router.reset_i(sig_rst)
|
||||||
for idx,m in enumerate(memories):
|
for idx, m in enumerate(memories):
|
||||||
router.initiator_socket.at(idx).bind(m.socket)
|
router.initiator_socket.at(idx).bind(m.socket)
|
||||||
m.clk_i(sig_clk)
|
m.clk_i(sig_clk)
|
||||||
m.reset_i(sig_rst)
|
m.reset_i(sig_rst)
|
||||||
|
@ -56,8 +64,8 @@ for idx,m in enumerate(memories):
|
||||||
# run if it is standalone
|
# run if it is standalone
|
||||||
###############################################################################
|
###############################################################################
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
if os.path.isfile('router_example.json'):
|
if os.path.isfile("router_example.json"):
|
||||||
cfg = cpp.scc.configurer(cpp.std.string('router_example.json'));
|
cfg = cpp.scc.configurer(cpp.std.string("router_example.json"))
|
||||||
tracer = cpp.scc.tracer('vcd_trace', 1, True)
|
tracer = cpp.scc.tracer("vcd_trace", 1, True)
|
||||||
cpp.sc_core.sc_start()
|
cpp.sc_core.sc_start()
|
||||||
logging.debug("Done")
|
logging.debug("Done")
|
||||||
|
|
|
@ -1,39 +1,38 @@
|
||||||
import os.path
|
|
||||||
import logging
|
import logging
|
||||||
from cppyy import gbl as cpp
|
import os.path
|
||||||
|
|
||||||
import pysysc
|
import pysysc
|
||||||
|
import pysysc.scc as scc
|
||||||
import pysysc.structural as struct
|
import pysysc.structural as struct
|
||||||
|
from cppyy import gbl as cpp
|
||||||
from pysysc.structural import Connection, Module, Signal, Simulation
|
from pysysc.structural import Connection, Module, Signal, Simulation
|
||||||
|
|
||||||
###############################################################################
|
###############################################################################
|
||||||
# setup and load
|
# setup and load
|
||||||
###############################################################################
|
###############################################################################
|
||||||
logging.basicConfig(level=logging.INFO)
|
logging.basicConfig(level=logging.DEBUG)
|
||||||
build_type='Debug'
|
|
||||||
###############################################################################
|
###############################################################################
|
||||||
myDir = os.path.dirname( os.path.realpath(__file__))
|
myDir = os.path.dirname(os.path.realpath(__file__))
|
||||||
pysysc.load_systemc()
|
pysysc.load_systemc(17)
|
||||||
###############################################################################
|
###############################################################################
|
||||||
logging.debug("Loading SC-Components lib")
|
logging.debug("Loading SC-Components lib")
|
||||||
pysysc.add_include_path(os.path.join(myDir, 'scc/src/sysc'))
|
scc.load_lib(myDir)
|
||||||
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")
|
logging.debug("Loading Components lib")
|
||||||
pysysc.add_include_path(os.path.join(myDir, 'vp_components'))
|
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))
|
pysysc.add_library("components.h", "libvp_components.so", myDir)
|
||||||
###############################################################################
|
###############################################################################
|
||||||
# configure
|
# configure
|
||||||
###############################################################################
|
###############################################################################
|
||||||
Simulation.setup(logging.root.level)
|
scc.setup(logging.root.level)
|
||||||
|
scc.configure(enable_trace=True)
|
||||||
###############################################################################
|
###############################################################################
|
||||||
# instantiate
|
# instantiate
|
||||||
###############################################################################
|
###############################################################################
|
||||||
clk_gen = Module(cpp.ClkGen).create("clk_gen")
|
clk_gen = Module(cpp.ClkGen).create("clk_gen")
|
||||||
rst_gen = Module(cpp.ResetGen).create("rst_gen")
|
rst_gen = Module(cpp.ResetGen).create("rst_gen")
|
||||||
initiator = Module(cpp.Initiator).create("initiator")
|
initiator = Module(cpp.Initiator).create("initiator")
|
||||||
memories = [Module(cpp.Memory).create("mem%d"%i) for i in range(2)]
|
memories = [Module(cpp.Memory).create("mem%d" % i) for i in range(2)]
|
||||||
router = Module(cpp.Router[len(memories)]).create("router")
|
router = Module(cpp.Router[len(memories)]).create("router")
|
||||||
###############################################################################
|
###############################################################################
|
||||||
# connect it
|
# connect it
|
||||||
|
@ -43,7 +42,10 @@ clk = Signal("clk").src(clk_gen.clk_o).sink(initiator.clk_i).sink(router.clk_i)
|
||||||
rst = Signal("rst").src(rst_gen.reset_o).sink(initiator.reset_i).sink(router.reset_i)
|
rst = Signal("rst").src(rst_gen.reset_o).sink(initiator.reset_i).sink(router.reset_i)
|
||||||
[rst.sink(m.reset_i) for m in memories]
|
[rst.sink(m.reset_i) for m in memories]
|
||||||
Connection().src(initiator.socket).sink(router.target_socket)
|
Connection().src(initiator.socket).sink(router.target_socket)
|
||||||
[Connection().src(router.initiator_socket.at(idx)).sink(m.socket) for idx,m in enumerate(memories)]
|
[
|
||||||
|
Connection().src(router.initiator_socket.at(idx)).sink(m.socket)
|
||||||
|
for idx, m in enumerate(memories)
|
||||||
|
]
|
||||||
###############################################################################
|
###############################################################################
|
||||||
# run if it is standalone
|
# run if it is standalone
|
||||||
###############################################################################
|
###############################################################################
|
||||||
|
@ -51,6 +53,5 @@ struct.dump_structure()
|
||||||
simcontext = cpp.sc_core.sc_get_curr_simcontext()
|
simcontext = cpp.sc_core.sc_get_curr_simcontext()
|
||||||
objects = cpp.sc_core.sc_get_top_level_objects(simcontext)
|
objects = cpp.sc_core.sc_get_top_level_objects(simcontext)
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
Simulation.configure(enable_vcd=True)
|
|
||||||
Simulation.run()
|
Simulation.run()
|
||||||
logging.debug("Done")
|
logging.debug("Done")
|
||||||
|
|
2
scc
2
scc
|
@ -1 +1 @@
|
||||||
Subproject commit f1d272d59fb597a1eb616a02ec6c0cf8684716df
|
Subproject commit 85dc2b4e51e0197daf8d19c77d85667580a480eb
|
Loading…
Reference in New Issue