Added support for SCV & CCI, updated notes
This commit is contained in:
parent
c8c2c3918c
commit
b1334a0689
10
NOTES.md
10
NOTES.md
|
@ -4,11 +4,15 @@
|
||||||
|
|
||||||
```
|
```
|
||||||
apt-get install -y make build-essential libssl-dev zlib1g-dev libbz2-dev libreadline-dev libsqlite3-dev wget curl llvm libncurses5-dev libncursesw5-dev xz-utils tk-dev libffi-dev liblzma-dev python-openssl
|
apt-get install -y make build-essential libssl-dev zlib1g-dev libbz2-dev libreadline-dev libsqlite3-dev wget curl llvm libncurses5-dev libncursesw5-dev xz-utils tk-dev libffi-dev liblzma-dev python-openssl
|
||||||
|
|
||||||
git clone https://github.com/pyenv/pyenv.git ~/.pyenv
|
git clone https://github.com/pyenv/pyenv.git ~/.pyenv
|
||||||
echo 'export PYENV_ROOT="$HOME/.pyenv"' >> ~/.bash_profile
|
echo 'export PYENV_ROOT="$HOME/.pyenv"' >> ~/.bashrc
|
||||||
echo 'export PATH="$PYENV_ROOT/bin:$PATH"' >> ~/.bash_profile
|
echo 'export PATH="$PYENV_ROOT/bin:$PATH"' >> ~/.bashrc
|
||||||
|
echo 'eval "$(pyenv init -)"' >> ~/.bashrc
|
||||||
|
|
||||||
git clone https://github.com/pyenv/pyenv-virtualenv.git $(pyenv root)/plugins/pyenv-virtualenv
|
git clone https://github.com/pyenv/pyenv-virtualenv.git $(pyenv root)/plugins/pyenv-virtualenv
|
||||||
echo 'eval "$(pyenv virtualenv-init -)"' >> ~/.bash_profile
|
echo 'eval "$(pyenv virtualenv-init -)"' >> ~/.bashrc
|
||||||
|
|
||||||
git clone https://github.com/pyenv/pyenv-virtualenvwrapper.git $(pyenv root)/plugins/pyenv-virtualenvwrapper
|
git clone https://github.com/pyenv/pyenv-virtualenvwrapper.git $(pyenv root)/plugins/pyenv-virtualenvwrapper
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
|
@ -17,8 +17,11 @@ lang_level=11
|
||||||
'''
|
'''
|
||||||
|
|
||||||
sysIncludeDirs = set()
|
sysIncludeDirs = set()
|
||||||
|
|
||||||
includeDirs = set()
|
includeDirs = set()
|
||||||
|
|
||||||
|
interactive = False
|
||||||
|
|
||||||
class NullLogger(object):
|
class NullLogger(object):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.terminal = sys.stdout
|
self.terminal = sys.stdout
|
||||||
|
@ -47,6 +50,10 @@ def read_config_from_conan(conanfile, build_type='Release'):
|
||||||
for p in e['packages']:
|
for p in e['packages']:
|
||||||
if name == 'SystemC' and p['cpp_info']['rootpath']:
|
if name == 'SystemC' and p['cpp_info']['rootpath']:
|
||||||
os.environ['SYSTEMC_HOME']=p['cpp_info']['rootpath']
|
os.environ['SYSTEMC_HOME']=p['cpp_info']['rootpath']
|
||||||
|
elif name == 'SystemC-CCI' and p['cpp_info']['rootpath']:
|
||||||
|
os.environ['CCI_HOME']=p['cpp_info']['rootpath']
|
||||||
|
elif name == 'SystemCVerification' and p['cpp_info']['rootpath']:
|
||||||
|
os.environ['SCV_HOME']=p['cpp_info']['rootpath']
|
||||||
with open(os.path.join(tmpdirname, "conanbuildinfo.json")) as f:
|
with open(os.path.join(tmpdirname, "conanbuildinfo.json")) as f:
|
||||||
data=json.load(f)
|
data=json.load(f)
|
||||||
# set include pathes and load libraries
|
# set include pathes and load libraries
|
||||||
|
@ -63,24 +70,56 @@ def read_config_from_conan(conanfile, build_type='Release'):
|
||||||
return msg
|
return msg
|
||||||
|
|
||||||
systemc_loaded=False
|
systemc_loaded=False
|
||||||
|
cci_loaded=False
|
||||||
|
|
||||||
def load_systemc():
|
def load_systemc():
|
||||||
if 'SYSTEMC_HOME' in os.environ:
|
if 'SYSTEMC_HOME' in os.environ:
|
||||||
add_sys_include_path(os.path.join(os.environ['SYSTEMC_HOME'], 'include'))
|
add_sys_include_path(os.path.join(os.environ['SYSTEMC_HOME'], 'include'))
|
||||||
for l in ['lib', 'lib64', 'lib-linux', 'lib-linux64']:
|
for l in ['lib', 'lib64', 'lib-linux', 'lib-linux64']:
|
||||||
for f in ['libsystemc.so']:
|
for f in ['libsystemc.so']:
|
||||||
if os.path.isfile(os.path.join(os.environ['SYSTEMC_HOME'], l, f)):
|
full_file=os.path.join(os.environ['SYSTEMC_HOME'], l, f)
|
||||||
cppyy.load_library(os.path.join(os.environ['SYSTEMC_HOME'], l, f))
|
if os.path.isfile(full_file):
|
||||||
|
cppyy.load_library(full_file)
|
||||||
cppyy.cppdef("""
|
cppyy.cppdef("""
|
||||||
#define SC_CPLUSPLUS %s
|
#define SC_CPLUSPLUS %s
|
||||||
#include "systemc"
|
#include "systemc"
|
||||||
#include "tlm"
|
#include "tlm"
|
||||||
"""
|
namespace sc_core { extern void pln(); }
|
||||||
% lang_symbols[lang_level])
|
""" % lang_symbols[lang_level])
|
||||||
systemc_loaded=True
|
systemc_loaded=True
|
||||||
|
_load_systemc_cci()
|
||||||
|
break
|
||||||
|
if systemc_loaded: break;
|
||||||
|
if not interactive: cppyy.gbl.sc_core.pln()
|
||||||
cppyy.gbl.sc_core.sc_in_action=True
|
cppyy.gbl.sc_core.sc_in_action=True
|
||||||
return True
|
return True
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
def _load_systemc_scv():
|
||||||
|
if 'SCV_HOME' in os.environ:
|
||||||
|
add_sys_include_path(os.path.join(os.environ['SCV_HOME'], 'include'))
|
||||||
|
for l in ['lib', 'lib64', 'lib-linux', 'lib-linux64']:
|
||||||
|
for f in ['libscv.so']:
|
||||||
|
full_file = os.path.join(os.environ['SCV_HOME'], l, f)
|
||||||
|
if os.path.isfile(full_file):
|
||||||
|
cppyy.load_library(full_file)
|
||||||
|
cppyy.include("cci_configuration")
|
||||||
|
cci_loaded=True
|
||||||
|
return True
|
||||||
|
return False
|
||||||
|
|
||||||
|
def _load_systemc_cci():
|
||||||
|
if 'CCI_HOME' in os.environ:
|
||||||
|
add_sys_include_path(os.path.join(os.environ['CCI_HOME'], 'include'))
|
||||||
|
for l in ['lib', 'lib64', 'lib-linux', 'lib-linux64']:
|
||||||
|
for f in ['libcciapi.so']:
|
||||||
|
full_file = os.path.join(os.environ['CCI_HOME'], l, f)
|
||||||
|
if os.path.isfile(full_file):
|
||||||
|
cppyy.load_library(full_file)
|
||||||
|
cppyy.include("cci_configuration")
|
||||||
|
cci_loaded=True
|
||||||
|
return True
|
||||||
|
return False
|
||||||
|
|
||||||
def add_library(file, lib):
|
def add_library(file, lib):
|
||||||
buf = io.StringIO()
|
buf = io.StringIO()
|
||||||
|
@ -98,19 +137,19 @@ def add_sys_include_path(incl):
|
||||||
cppyy.add_include_path(incl)
|
cppyy.add_include_path(incl)
|
||||||
|
|
||||||
# prepare a pythonizor
|
# prepare a pythonizor
|
||||||
def _pythonizor(klass, name):
|
def _pythonizor(clazz, name):
|
||||||
# A pythonizor receives the freshly prepared bound C++ class, and a name stripped down to
|
# A pythonizor receives the freshly prepared bound C++ class, and a name stripped down to
|
||||||
# the namespace the pythonizor is applied. Also accessible are klass.__name__ (for the
|
# the namespace the pythonizor is applied. Also accessible are clazz.__name__ (for the
|
||||||
# Python name) and klass.__cppname__ (for the C++ name)
|
# Python name) and clazz.__cppname__ (for the C++ name)
|
||||||
if name == 'sc_time':
|
if name == 'sc_time':
|
||||||
klass.__repr__ = lambda self: repr(self.to_string())
|
clazz.__repr__ = lambda self: repr(self.to_string())
|
||||||
klass.__str__ = lambda self: self.to_string()
|
clazz.__str__ = lambda self: self.to_string()
|
||||||
elif name in ['sc_object', 'sc_module']:
|
elif name in ['sc_object', 'sc_module']:
|
||||||
klass.__repr__ = lambda self: repr(self.name())
|
clazz.__repr__ = lambda self: repr(self.name())
|
||||||
elif len(name) > 8 and name[:7] == 'sc_port<':
|
elif len(name) > 8 and name[:7] == 'sc_port<':
|
||||||
klass.__repr__ = lambda self: repr(self.name())
|
clazz.__repr__ = lambda self: repr(self.name())
|
||||||
elif len(name) > 10 and name[:9] == 'sc_export<':
|
elif len(name) > 10 and name[:9] == 'sc_export<':
|
||||||
klass.__repr__ = lambda self: repr(self.name())
|
clazz.__repr__ = lambda self: repr(self.name())
|
||||||
# else:
|
# else:
|
||||||
# print('not pythonizing', name)
|
# print('not pythonizing', name)
|
||||||
|
|
||||||
|
|
|
@ -8,6 +8,7 @@ from builtins import getattr
|
||||||
import re
|
import re
|
||||||
from enum import Enum
|
from enum import Enum
|
||||||
import logging
|
import logging
|
||||||
|
import pysysc
|
||||||
|
|
||||||
class Mode(Enum):
|
class Mode(Enum):
|
||||||
SIM = 1
|
SIM = 1
|
||||||
|
@ -44,7 +45,23 @@ class Simulation(object):
|
||||||
}
|
}
|
||||||
cpp.sc_core.sc_report_handler.set_verbosity_level(verb_lut[log_level]);
|
cpp.sc_core.sc_report_handler.set_verbosity_level(verb_lut[log_level]);
|
||||||
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);
|
||||||
|
try:
|
||||||
|
cpp.scc.init_cci("GlobalBroker")
|
||||||
|
except Exception:
|
||||||
|
pass
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def configure(name="", enable_vcd=False):
|
||||||
|
if len(name) and os.path.isfile(name):
|
||||||
|
Simulation.cfg = cpp.scc.configurer(cpp.std.string(name));
|
||||||
|
if enable_vcd:
|
||||||
|
trace_name = os.path.basename(name)
|
||||||
|
Simulation.trace = cpp.scc.configurable_tracer(trace_name, 1, True, True)
|
||||||
|
Simulation.trace.add_control()
|
||||||
|
else:
|
||||||
|
if enable_vcd:
|
||||||
|
Simulation.trace = cpp.scc.tracer('vcd_trace', 1, True)
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue