PySysC/tests/router_example.py

31 lines
949 B
Python

import json
import cppyy
import os.path
import pysysc as scpy
from cppyy import gbl as cpp
conan_err = scpy.read_config_from_conan('../conanfile.txt')
scpy.load_systemc()
scpy.add_include_path('..')
scpy.add_library('components.h', '../build/Debug/lib/libcomponents.so')
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"]]
router = cpp.Router[4](cpp.sc_core.sc_module_name("router"))
members = scpy.get_members(initiator)
methods = scpy.get_methods(initiator)
ports = scpy.get_ports(initiator)
intors = scpy.get_inititator_sockets(initiator)
tgts = scpy.get_target_sockets(initiator)
childs = scpy.get_submodules(initiator)
initiator.socket.bind(router.target_socket)
for idx,m in enumerate(memories):
router.initiator_socket.at(idx).bind(m.socket)
cpp.sc_core.sc_in_action=True
cpp.sc_core.sc_start()
print("Done")