Skip to content

Commit

Permalink
Fix some Vivado issues (SystemVerilog support, space in file name, en…
Browse files Browse the repository at this point in the history
…vironment variable)
  • Loading branch information
oscargus committed Nov 7, 2022
1 parent 3292c28 commit 56ee9ad
Showing 1 changed file with 18 additions and 8 deletions.
26 changes: 18 additions & 8 deletions vunit/vivado/vivado.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"""

from subprocess import check_call
from os import makedirs
from os import makedirs, environ
from pathlib import Path


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

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

def _read_compile_order(file_name, fail_on_non_hdl_files):
"""
Read the compile order file and filter out duplicate files
Read the compile order file and filter out duplicate files.
"""
compile_order = []
unique = set()
Expand All @@ -93,7 +93,7 @@ def _read_compile_order(file_name, fail_on_non_hdl_files):
for line in ifile.readlines():
library_name, file_type, file_name = line.strip().split(",", 2)

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

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

0 comments on commit 56ee9ad

Please sign in to comment.