Skip to content

Commit f87ce3e

Browse files
committed
Fix some Vivado issues (SystemVerilog support, space in file name, environment variable)
1 parent 3292c28 commit f87ce3e

1 file changed

Lines changed: 18 additions & 8 deletions

File tree

vunit/vivado/vivado.py

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
"""
1010

1111
from subprocess import check_call
12-
from os import makedirs
12+
from os import makedirs, environ
1313
from pathlib import Path
1414

1515

@@ -31,7 +31,7 @@ def add_from_compile_order_file(
3131
no_dependency_scan = []
3232
with_dependency_scan = []
3333
for library_name, file_name in compile_order:
34-
is_verilog = file_name.endswith(".v") or file_name.endswith(".vp")
34+
is_verilog = file_name.endswith(".v") or file_name.endswith(".vp") or file_name.endswith(".sv")
3535

3636
# Optionally use VUnit dependency scanning for everything in xil_defaultlib, which
3737
# typically contains unencrypted top levels that instantiate encrypted implementations.
@@ -81,7 +81,7 @@ def create_compile_order_file(project_file, compile_order_file, vivado_path=None
8181

8282
def _read_compile_order(file_name, fail_on_non_hdl_files):
8383
"""
84-
Read the compile order file and filter out duplicate files
84+
Read the compile order file and filter out duplicate files.
8585
"""
8686
compile_order = []
8787
unique = set()
@@ -93,7 +93,7 @@ def _read_compile_order(file_name, fail_on_non_hdl_files):
9393
for line in ifile.readlines():
9494
library_name, file_type, file_name = line.strip().split(",", 2)
9595

96-
if file_type not in ("Verilog", "VHDL", "Verilog Header"):
96+
if file_type not in ("Verilog", "VHDL", "Verilog Header", "SystemVerilog"):
9797
if fail_on_non_hdl_files:
9898
raise RuntimeError(f"Unsupported compile order file: {file_name}")
9999
print(f"Compile order file ignored: {file_name}")
@@ -120,12 +120,22 @@ def run_vivado(tcl_file_name, tcl_args=None, cwd=None, vivado_path=None):
120120
"""
121121
Run tcl script in Vivado in batch mode.
122122
123-
Note: the shell=True is important in windows where Vivado is just a bat file.
123+
:param tcl_file_name: Path to tcl file
124+
:param tcl_args: tcl arguments passed to Vivado via the ``-tclargs`` switch
125+
:param cwd: Passed as ``cwd`` to ``subprocess.check_call``
126+
:param vivado_path: Path to Vivado install directory. If ``None``, the
127+
environment variable ``VUNIT_VIVADO_PATH`` is used if set. Otherwise,
128+
rely on that ``vivado`` is in the path.
124129
"""
125-
vivado = "vivado" if vivado_path is None else str(Path(vivado_path).resolve() / "bin" / "vivado")
126-
cmd = f"{vivado} -nojournal -nolog -notrace -mode batch -source {str(Path(tcl_file_name).resolve())}"
130+
vivado = (
131+
str(Path(vivado_path).resolve() / "bin" / "vivado")
132+
if vivado_path is not None
133+
else environ.get("VUNIT_VIVADO_PATH", "vivado")
134+
)
135+
cmd = f'"{vivado}" -nojournal -nolog -notrace -mode batch -source "{str(Path(tcl_file_name).resolve())}"'
127136
if tcl_args is not None:
128-
cmd += " -tclargs " + " ".join([str(val) for val in tcl_args])
137+
cmd += " -tclargs " + " ".join([f'"{val}"' for val in tcl_args])
129138

130139
print(cmd)
140+
# shell=True is important in Windows where Vivado is just a bat file.
131141
check_call(cmd, cwd=cwd, shell=True)

0 commit comments

Comments
 (0)