updates build instruction and SCC to latest version
This commit is contained in:
parent
775872b190
commit
fcd60ef660
|
@ -3,3 +3,6 @@
|
|||
/*.vcd
|
||||
/*.png
|
||||
/*.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": []
|
||||
}
|
||||
]
|
||||
}
|
|
@ -12,6 +12,7 @@ include(clang-format)
|
|||
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||
set(CMAKE_CXX_EXTENSIONS OFF)
|
||||
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
|
||||
set(CMAKE_CXX_STANDARD 17)
|
||||
|
||||
include(CheckCXXCompilerFlag)
|
||||
CHECK_CXX_COMPILER_FLAG("-march=native" COMPILER_SUPPORTS_MARCH_NATIVE)
|
||||
|
@ -63,8 +64,8 @@ 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)
|
||||
set(CONAN_PACKAGE_OPTIONS fmt:header_only=True spdlog:header_only=True ${BOOST_OPTIONS})
|
||||
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_OPTIONS ${CONAN_PACKAGE_OPTIONS} systemc-cci:shared=False)
|
||||
set(CONAN_PACKAGE_LIST ${CONAN_PACKAGE_LIST} systemc/2.3.4)
|
||||
set(CONAN_PACKAGE_OPTIONS ${CONAN_PACKAGE_OPTIONS} systemc:shared=True)
|
||||
endif()
|
||||
conan_configure(REQUIRES ${CONAN_PACKAGE_LIST}
|
||||
GENERATORS cmake_find_package
|
||||
|
@ -84,7 +85,7 @@ find_package(lz4 REQUIRED)
|
|||
|
||||
add_subdirectory(scc)
|
||||
add_subdirectory(vp_components)
|
||||
add_subdirectory(top)
|
||||
#add_subdirectory(top)
|
||||
|
||||
# CTest is a testing tool that can be used to test your project.
|
||||
# enable_testing()
|
||||
|
|
27
README.md
27
README.md
|
@ -4,16 +4,29 @@ A simple C++/SystemC/CMake project to test pysysc
|
|||
|
||||
# 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
|
||||
mkdir build
|
||||
cd build
|
||||
conan install .. --build=missing
|
||||
cmake -DBUILD_SHARED_LIBS=ON ..
|
||||
cmake --build .
|
||||
python3 -mvenv .venv
|
||||
. .venv/bin/activate
|
||||
pip install "conan<2.0"
|
||||
cmake -S . -B build -DBUILD_SHARED_LIBS=ON -DCMAKE_EXPORT_COMPILE_COMMANDS=ON
|
||||
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.
|
||||
|
|
78
modules.py
78
modules.py
|
@ -4,46 +4,41 @@
|
|||
# SPDX-License-Identifier: Apache-2.0
|
||||
#
|
||||
|
||||
import os.path
|
||||
import logging
|
||||
import cppyy
|
||||
from cppyy import gbl as cpp
|
||||
import os.path
|
||||
|
||||
import pysysc
|
||||
import pysysc.scc as scc
|
||||
from cppyy import gbl as cpp
|
||||
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()
|
||||
myDir = os.path.dirname(os.path.realpath(__file__))
|
||||
pysysc.load_systemc(17)
|
||||
###############################################################################
|
||||
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')
|
||||
scc.load_lib(myDir)
|
||||
###############################################################################
|
||||
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))
|
||||
|
||||
pysysc.add_include_path(os.path.join(myDir, "vp_components"))
|
||||
pysysc.add_library("components.h", "libvp_components.so", myDir)
|
||||
###############################################################################
|
||||
# configure
|
||||
###############################################################################
|
||||
scc.setup(logging.root.level)
|
||||
scc.configure(enable_trace=False)
|
||||
###############################################################################
|
||||
# define toplevel class
|
||||
###############################################################################
|
||||
num_of_mem = 4
|
||||
|
||||
from pysysc.sysc import ScModule
|
||||
|
||||
|
||||
class TopModule(ScModule):
|
||||
|
||||
def __init__(self, name):
|
||||
|
@ -54,17 +49,32 @@ class TopModule(ScModule):
|
|||
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.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 = (
|
||||
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 = (
|
||||
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)]
|
||||
[
|
||||
Connection().src(self.router.initiator_socket.at(idx)).sink(m.socket)
|
||||
for idx, m in enumerate(self.memories)
|
||||
]
|
||||
self.ScThread("RunThread")
|
||||
|
||||
def EndOfElaboration(self):
|
||||
|
@ -78,23 +88,23 @@ class TopModule(ScModule):
|
|||
|
||||
def RunThread(self):
|
||||
print("Starting RunThread")
|
||||
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())
|
||||
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.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()))
|
||||
###############################################################################
|
||||
# configure
|
||||
###############################################################################
|
||||
Simulation.setup(logging.root.level)
|
||||
print(
|
||||
"Hello from Thread %s, @ %s"
|
||||
% (self.name(), cpp.sc_core.sc_time_stamp().to_string())
|
||||
)
|
||||
|
||||
|
||||
###############################################################################
|
||||
# instantiate
|
||||
###############################################################################
|
||||
#from modules import TopModule
|
||||
# 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")
|
||||
|
|
|
@ -1,37 +1,45 @@
|
|||
import os.path
|
||||
import logging
|
||||
from cppyy import gbl as cpp
|
||||
import os.path
|
||||
|
||||
import pysysc
|
||||
from cppyy import gbl as cpp
|
||||
|
||||
###############################################################################
|
||||
# setup and load
|
||||
###############################################################################
|
||||
build_type='Debug'
|
||||
logging.basicConfig(level=logging.DEBUG)
|
||||
###############################################################################
|
||||
myDir = os.path.dirname( os.path.realpath(__file__))
|
||||
pysysc.load_systemc()
|
||||
myDir = os.path.dirname(os.path.realpath(__file__))
|
||||
pysysc.load_systemc(17)
|
||||
###############################################################################
|
||||
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/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))
|
||||
pysysc.add_include_path(os.path.join(myDir, "scc/third_party/cci-1.0.0"))
|
||||
pysysc.add_include_path(os.path.join(myDir, "scc/third_party/scv-tr/src"))
|
||||
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", "libscc-sysc.so", myDir)
|
||||
###############################################################################
|
||||
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))
|
||||
pysysc.add_include_path(os.path.join(myDir, "vp_components"))
|
||||
pysysc.add_library("components.h", "libvp_components.so", myDir)
|
||||
###############################################################################
|
||||
# configure
|
||||
###############################################################################
|
||||
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_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
|
||||
)
|
||||
###############################################################################
|
||||
# instantiate
|
||||
###############################################################################
|
||||
clkgen = cpp.ClkGen(cpp.sc_core.sc_module_name("clk_gen"))
|
||||
rstgen = cpp.ResetGen(cpp.sc_core.sc_module_name("rst_gen"))
|
||||
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"))
|
||||
###############################################################################
|
||||
# signals
|
||||
|
@ -48,7 +56,7 @@ initiator.clk_i(sig_clk)
|
|||
initiator.reset_i(sig_rst)
|
||||
router.clk_i(sig_clk)
|
||||
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)
|
||||
m.clk_i(sig_clk)
|
||||
m.reset_i(sig_rst)
|
||||
|
@ -56,8 +64,8 @@ for idx,m in enumerate(memories):
|
|||
# run if it is standalone
|
||||
###############################################################################
|
||||
if __name__ == "__main__":
|
||||
if os.path.isfile('router_example.json'):
|
||||
cfg = cpp.scc.configurer(cpp.std.string('router_example.json'));
|
||||
tracer = cpp.scc.tracer('vcd_trace', 1, True)
|
||||
if os.path.isfile("router_example.json"):
|
||||
cfg = cpp.scc.configurer(cpp.std.string("router_example.json"))
|
||||
tracer = cpp.scc.tracer("vcd_trace", 1, True)
|
||||
cpp.sc_core.sc_start()
|
||||
logging.debug("Done")
|
||||
|
|
|
@ -1,40 +1,38 @@
|
|||
import os.path
|
||||
import logging
|
||||
from cppyy import gbl as cpp
|
||||
import os.path
|
||||
|
||||
import pysysc
|
||||
import pysysc.structural as struct
|
||||
import pysysc.scc as scc
|
||||
import pysysc.structural as struct
|
||||
from cppyy import gbl as cpp
|
||||
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.load_systemc()
|
||||
myDir = os.path.dirname(os.path.realpath(__file__))
|
||||
pysysc.load_systemc(17)
|
||||
###############################################################################
|
||||
logging.debug("Loading SC-Components lib")
|
||||
#pysysc.add_include_path(os.path.join(myDir, '../install/include'))
|
||||
#pysysc.add_library('scc_util.h', os.path.join(myDir, '../install/lib64/libscc-util.so'))
|
||||
#pysysc.add_library('scc_sysc.h', os.path.join(myDir, '../install/lib64/libscc-sysc.so'))
|
||||
scc.load_lib(os.path.join(myDir, '../install'))
|
||||
scc.load_lib(myDir)
|
||||
###############################################################################
|
||||
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/vp_components/libvp_components.so'))
|
||||
pysysc.add_include_path(os.path.join(myDir, "vp_components"))
|
||||
pysysc.add_library("components.h", "libvp_components.so", myDir)
|
||||
###############################################################################
|
||||
# configure
|
||||
###############################################################################
|
||||
scc.setup(logging.root.level)
|
||||
scc.configure(enable_trace=True)
|
||||
###############################################################################
|
||||
# instantiate
|
||||
###############################################################################
|
||||
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("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")
|
||||
###############################################################################
|
||||
# connect it
|
||||
|
@ -44,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.sink(m.reset_i) for m in memories]
|
||||
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
|
||||
###############################################################################
|
||||
|
@ -52,6 +53,5 @@ struct.dump_structure()
|
|||
simcontext = cpp.sc_core.sc_get_curr_simcontext()
|
||||
objects = cpp.sc_core.sc_get_top_level_objects(simcontext)
|
||||
if __name__ == "__main__":
|
||||
scc.configure(enable_trace=True)
|
||||
Simulation.run()
|
||||
logging.debug("Done")
|
||||
|
|
2
scc
2
scc
|
@ -1 +1 @@
|
|||
Subproject commit d6b718cebd9712374b0fbe145da2920800480fac
|
||||
Subproject commit 85dc2b4e51e0197daf8d19c77d85667580a480eb
|
Loading…
Reference in New Issue