-
Notifications
You must be signed in to change notification settings - Fork 270
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
1 parent
73f3764
commit 33447d1
Showing
10 changed files
with
95 additions
and
82 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,13 +4,19 @@ | |
# | ||
# Copyright (c) 2014-2023, Lars Asplund [email protected] | ||
|
||
""" | ||
Temporary helper module to compile C-code used by python_pkg. | ||
""" | ||
from pathlib import Path | ||
from glob import glob | ||
import subprocess | ||
import sys | ||
|
||
|
||
def compile_vhpi_application(run_script_root, vu): | ||
""" | ||
Compile VHPI application used by Aldec's simulators. | ||
""" | ||
path_to_shared_lib = (run_script_root / "vunit_out" / vu.get_simulator_name() / "libraries").resolve() | ||
if not path_to_shared_lib.exists(): | ||
path_to_shared_lib.mkdir(parents=True, exist_ok=True) | ||
|
@@ -20,31 +26,34 @@ def compile_vhpi_application(run_script_root, vu): | |
python_shared_lib = f"python{sys.version_info[0]}{sys.version_info[1]}" | ||
path_to_python_pkg = Path(__file__).parent.resolve() / "vhdl" / "python" / "src" | ||
c_file_paths = [path_to_python_pkg / "python_pkg_vhpi.c", path_to_python_pkg / "python_pkg.c"] | ||
path_to_simulator = Path(vu._simulator_class.find_prefix()).resolve() | ||
path_to_simulator = Path(vu._simulator_class.find_prefix()).resolve() # pylint: disable=protected-access | ||
ccomp_executable = path_to_simulator / "ccomp.exe" | ||
|
||
proc = subprocess.run([ | ||
str(ccomp_executable), | ||
"-vhpi", | ||
"-dbg", | ||
"-verbose", | ||
"-o", | ||
'"' + str(shared_lib) + '"', | ||
"-l", | ||
python_shared_lib, | ||
"-l", | ||
"python3", | ||
"-l", | ||
"_tkinter", | ||
"-I", | ||
'"' + str(path_to_python_include) + '"', | ||
"-I", | ||
'"' + str(path_to_python_pkg) + '"', | ||
"-L", | ||
'"' + str(path_to_python_libs) + '"', | ||
" ".join(['"' + str(path) + '"' for path in c_file_paths])], | ||
proc = subprocess.run( | ||
[ | ||
str(ccomp_executable), | ||
"-vhpi", | ||
"-dbg", | ||
"-verbose", | ||
"-o", | ||
'"' + str(shared_lib) + '"', | ||
"-l", | ||
python_shared_lib, | ||
"-l", | ||
"python3", | ||
"-l", | ||
"_tkinter", | ||
"-I", | ||
'"' + str(path_to_python_include) + '"', | ||
"-I", | ||
'"' + str(path_to_python_pkg) + '"', | ||
"-L", | ||
'"' + str(path_to_python_libs) + '"', | ||
" ".join(['"' + str(path) + '"' for path in c_file_paths]), | ||
], | ||
capture_output=True, | ||
text=True, | ||
check=False, | ||
) | ||
|
||
if proc.returncode != 0: | ||
|
@@ -53,8 +62,11 @@ def compile_vhpi_application(run_script_root, vu): | |
raise RuntimeError("Failed to compile VHPI application") | ||
|
||
|
||
def compile_fli_application(run_script_root, vu): | ||
path_to_simulator = Path(vu._simulator_class.find_prefix()).resolve() | ||
def compile_fli_application(run_script_root, vu): # pylint: disable=too-many-locals | ||
""" | ||
Compile FLI application used by Questa. | ||
""" | ||
path_to_simulator = Path(vu._simulator_class.find_prefix()).resolve() # pylint: disable=protected-access | ||
path_to_simulator_include = (path_to_simulator / ".." / "include").resolve() | ||
|
||
# 32 or 64 bit installation? | ||
|
@@ -63,6 +75,7 @@ def compile_fli_application(run_script_root, vu): | |
[vsim_executable, "-version"], | ||
capture_output=True, | ||
text=True, | ||
check=False, | ||
) | ||
if proc.returncode != 0: | ||
print(proc.stderr) | ||
|
@@ -94,16 +107,17 @@ def compile_fli_application(run_script_root, vu): | |
args += ["-ansi", "-pedantic"] | ||
|
||
args += [ | ||
'-I' + str(path_to_simulator_include), | ||
'-I' + str(path_to_python_include), | ||
"-I" + str(path_to_simulator_include), | ||
"-I" + str(path_to_python_include), | ||
"-freg-struct-return", | ||
str(c_file_path) | ||
str(c_file_path), | ||
] | ||
|
||
proc = subprocess.run( | ||
args, | ||
capture_output=True, | ||
text=True, | ||
check=False, | ||
) | ||
if proc.returncode != 0: | ||
print(proc.stdout) | ||
|
@@ -139,6 +153,7 @@ def compile_fli_application(run_script_root, vu): | |
args, | ||
capture_output=True, | ||
text=True, | ||
check=False, | ||
) | ||
if proc.returncode != 0: | ||
print(proc.stdout) | ||
|
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
Oops, something went wrong.