-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
195 additions
and
51 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
from pyaux import dlopen, dlclose, enc_args, run | ||
from pathlib import Path | ||
|
||
print("PY COSIM ENTER") | ||
|
||
run(str(Path(__file__).resolve().parent.parent / "tb-fail.so"), 0, None) | ||
|
||
print("PY COSIM EXIT") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
from pathlib import Path | ||
import ctypes | ||
import _ctypes | ||
|
||
|
||
def dlopen(path): | ||
if not Path(path).exists(): | ||
print('Executable binary not found: ' + path) | ||
exit(1) | ||
try: | ||
return ctypes.CDLL(path) | ||
except OSError: | ||
print('Loading executables dynamically seems not to be supported on this platform') | ||
exit(1) | ||
|
||
|
||
def dlclose(obj): | ||
_ctypes.dlclose(obj._handle) | ||
|
||
|
||
def enc_args(args): | ||
xargs = (ctypes.POINTER(ctypes.c_char) * len(args))() | ||
for idx, arg in enumerate(args): | ||
xargs[idx] = ctypes.create_string_buffer(arg.encode('utf-8')) | ||
return xargs | ||
|
||
def run(path, argc, argv): | ||
print("PY RUN ENTER") | ||
ghdl = dlopen(path) | ||
ghdl.main(argc, argv) | ||
# FIXME With VHDL 93, the execution is Aborted and Python exits here | ||
|
||
dlclose(ghdl) | ||
|
||
print("PY RUN EXIT") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
from pyaux import dlopen, dlclose, enc_args, run | ||
from pathlib import Path | ||
from json import load | ||
|
||
print("PY COSIM ENTER") | ||
|
||
with (Path(__file__).parent / 'vunit_out' / 'cosim' / 'tb_abrt.json').open() as json_file: | ||
ARGS = load(json_file) | ||
|
||
XARGS = enc_args([ARGS["bin"]] + ARGS["sim"]) | ||
|
||
run(ARGS["bin"], len(XARGS) - 1, XARGS) | ||
|
||
print("PY COSIM EXIT") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
from vunit import VUnit | ||
from os import makedirs, getenv | ||
from pathlib import Path | ||
from shutil import copyfile | ||
import re | ||
|
||
|
||
def post_func(results): | ||
""" | ||
Copy args.json to vunit/cosim/*.json | ||
""" | ||
report = results.get_report() | ||
cosim_args_dir = Path(report.output_path) / "cosim" | ||
try: | ||
makedirs(str(cosim_args_dir)) | ||
except FileExistsError: | ||
pass | ||
for key, item in report.tests.items(): | ||
copyfile( | ||
str(Path(item.path) / "ghdl" / "args.json"), | ||
str( | ||
cosim_args_dir / ("%s.json" % re.search(r"lib\.(.+)\.all", key)[1]) | ||
), | ||
) | ||
|
||
|
||
ROOT = Path(__file__).resolve().parent | ||
|
||
vu = VUnit.from_argv(vhdl_standard=getenv('VUNIT_VHDL_STANDARD', '2008')) | ||
|
||
lib = vu.add_library('lib').add_source_files(str(ROOT / 'vunit_tb.vhd')) | ||
|
||
vu.set_sim_option('ghdl.elab_flags', [ | ||
'-shared', | ||
'-Wl,-fPIC', | ||
'-Wl,' + str(ROOT.parent / 'caux.c'), | ||
'-Wl,' + str(ROOT.parent / 'main_sigabrt.c') | ||
]) | ||
|
||
vu.set_sim_option("ghdl.elab_e", True) | ||
vu._args.elaborate = True | ||
|
||
vu.main(post_run=post_func) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
#!/usr/bin/env sh | ||
|
||
cd $(dirname "$0") | ||
|
||
export VUNIT_VHDL_STANDARD="2008" | ||
python3 vunit_run.py -v | ||
python3 vunit_cosim.py | ||
|
||
export VUNIT_VHDL_STANDARD="93" | ||
python3 vunit_run.py -v | ||
python3 vunit_cosim.py |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
library vunit_lib; | ||
use vunit_lib.run_pkg.all; | ||
use vunit_lib.logger_pkg.all; | ||
|
||
entity tb_abrt is | ||
generic ( runner_cfg : string ); | ||
end entity; | ||
|
||
architecture tb of tb_abrt is | ||
|
||
constant block_len : natural := 5; | ||
|
||
begin | ||
|
||
main: process | ||
variable val, ind: integer; | ||
begin | ||
test_runner_setup(runner, runner_cfg); | ||
info("Hello wrapping/exitcb/py_vunit!"); | ||
test_runner_cleanup(runner); | ||
wait; | ||
end process; | ||
|
||
end architecture; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters