Added support for SCV & CCI, updated notes

This commit is contained in:
Eyck Jentzsch 2019-01-06 15:21:25 +01:00
parent c8c2c3918c
commit b1334a0689
3 changed files with 77 additions and 17 deletions

View File

@ -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
git clone https://github.com/pyenv/pyenv.git ~/.pyenv
echo 'export PYENV_ROOT="$HOME/.pyenv"' >> ~/.bash_profile
echo 'export PATH="$PYENV_ROOT/bin:$PATH"' >> ~/.bash_profile
echo 'export PYENV_ROOT="$HOME/.pyenv"' >> ~/.bashrc
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
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
```

View File

@ -17,8 +17,11 @@ lang_level=11
'''
sysIncludeDirs = set()
includeDirs = set()
interactive = False
class NullLogger(object):
def __init__(self):
self.terminal = sys.stdout
@ -47,6 +50,10 @@ def read_config_from_conan(conanfile, build_type='Release'):
for p in e['packages']:
if name == 'SystemC' and 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:
data=json.load(f)
# set include pathes and load libraries
@ -63,25 +70,57 @@ def read_config_from_conan(conanfile, build_type='Release'):
return msg
systemc_loaded=False
cci_loaded=False
def load_systemc():
if 'SYSTEMC_HOME' in os.environ:
add_sys_include_path(os.path.join(os.environ['SYSTEMC_HOME'], 'include'))
for l in ['lib', 'lib64', 'lib-linux', 'lib-linux64']:
for f in ['libsystemc.so']:
if os.path.isfile(os.path.join(os.environ['SYSTEMC_HOME'], l, f)):
cppyy.load_library(os.path.join(os.environ['SYSTEMC_HOME'], l, f))
full_file=os.path.join(os.environ['SYSTEMC_HOME'], l, f)
if os.path.isfile(full_file):
cppyy.load_library(full_file)
cppyy.cppdef("""
#define SC_CPLUSPLUS %s
#include "systemc"
#include "tlm"
"""
% lang_symbols[lang_level])
systemc_loaded=True
namespace sc_core { extern void pln(); }
""" % lang_symbols[lang_level])
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
return True
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):
buf = io.StringIO()
with redirect_stdout(buf), redirect_stderr(buf):
@ -98,19 +137,19 @@ def add_sys_include_path(incl):
cppyy.add_include_path(incl)
# 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
# the namespace the pythonizor is applied. Also accessible are klass.__name__ (for the
# Python name) and klass.__cppname__ (for the C++ name)
# the namespace the pythonizor is applied. Also accessible are clazz.__name__ (for the
# Python name) and clazz.__cppname__ (for the C++ name)
if name == 'sc_time':
klass.__repr__ = lambda self: repr(self.to_string())
klass.__str__ = lambda self: self.to_string()
clazz.__repr__ = lambda self: repr(self.to_string())
clazz.__str__ = lambda self: self.to_string()
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<':
klass.__repr__ = lambda self: repr(self.name())
clazz.__repr__ = lambda self: repr(self.name())
elif len(name) > 10 and name[:9] == 'sc_export<':
klass.__repr__ = lambda self: repr(self.name())
clazz.__repr__ = lambda self: repr(self.name())
# else:
# print('not pythonizing', name)

View File

@ -8,6 +8,7 @@ from builtins import getattr
import re
from enum import Enum
import logging
import pysysc
class Mode(Enum):
SIM = 1
@ -44,6 +45,22 @@ class Simulation(object):
}
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);
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):
pass