-
Notifications
You must be signed in to change notification settings - Fork 263
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix some Vivado issues (SystemVerilog support, space in file name, environment variable) #871
base: master
Are you sure you want to change the base?
Conversation
f87ce3e
to
56ee9ad
Compare
Yes, please do something about the documentation. |
fbd9cbf
to
746b483
Compare
Now there is some sort of documentation for the functions in the module. Located at the bottom of the "Documentation" section (below "Examples"). |
4f457d8
to
30d9da6
Compare
Sorry to bother you @LarsAsplund , but can you please see if anything else is required (or if you prefer the Vivado menu entry elsewhere). |
Sorry for letting this slip. Will try to find some time "soon" to complete it. |
30d9da6
to
afdbad7
Compare
Finally got around to this. Not sure this is exactly what you wanted, but at least a "Tool Integration" menu item and then Vivado shows up there. Not clear to me how the "dynamic menus" work and if this will be an entry there (or if that it a better solution). |
Hello, bump on this one @oscargus @LarsAsplund . Any chance this could get pulled into mainline? This is very useful for using with Verification IPs |
…vironment variable)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This PR seems to address multiple issues in a single commit. @oscargus can you please split it into three commits so it's easier to review? It's ok to keep them in a single PR tho.
@@ -113,7 +114,7 @@ | |||
# -- InterSphinx -------------------------------------------------------------- | |||
|
|||
intersphinx_mapping = { | |||
"python": ("https://docs.python.org/3.8/", None), | |||
"python": ("https://docs.python.org/3/", None), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This belongs to a separated PR or, at least, to a separated commit within this PR.
@@ -30,6 +30,7 @@ | |||
|
|||
extensions = [ | |||
"sphinx.ext.autodoc", | |||
"sphinx.ext.autosummary", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't see where is the .. autosummary::
used in the docs. Is this extension used anywhere?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You are correct. I probably thought it was required for automodule
at the time.
@@ -13,3 +13,5 @@ | |||
add_from_compile_order_file, | |||
create_compile_order_file, | |||
) | |||
|
|||
__all__ = ["run_vivado", "add_from_compile_order_file", "create_compile_order_file"] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As far as I am aware, the purpose of __all__
seems to be to reduce the number of imported elements when from <module> import *
is used. However, doing so is generally considered a not good programming practice. In fact, we recently merged a PR to reduce the "catch them all" imports in VHDL (#992). Therefore, I'm not sure we want to support/enforce those kind of imports in Python.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If I remember correctly: this will also make the documentation clearer, but I'll play around with it and see if it is actually the case.
for library_name, file_name in compile_order: | ||
is_verilog = file_name.endswith(".v") or file_name.endswith(".vp") | ||
is_verilog = file_name.endswith(verilog_file_endings) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rather than using .endswith
, I would suggest using Pathlib's .suffix
(https://docs.python.org/3/library/pathlib.html#pathlib.PurePath.suffix) because semantically we are cheking the extension of a filename not the end of an arbitrary string. At the same time, since the tuple/list is used once only, the declaraction of the variable feels redundant. I would suggest Path(file_name).suffix in ['.v', '.vp', '.sv']
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Part of fixing #796
with Path(file_name).open("r", encoding="utf-8") as ifile: | ||
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 valid_file_types: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would use a list instead of a tuple.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a concrete reason for that? I tend to go for tuples as there is a (minor) performance benefit of those.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There lines fix #796
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Conceptually, I understand the tuples as an array of a fixed size, while a list is kind of expected to grow/reduce. Hence, I tend to use lists in other places of the codebase.
However, if there is a performance benefit, it is ok to use tuples here, and I will take it into account when touching other parts of the codebase. It's always nice to learn something!
|
||
print(cmd) | ||
# shell=True is important in Windows where Vivado is just a bat file. | ||
check_call(cmd, cwd=cwd, shell=True) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably not to be done in this PR, but check_call
's args
parameter can be either a list of a string: https://docs.python.org/3/library/subprocess.html#subprocess.CompletedProcess.args.
I feel it would be cleaner if we managed cmd
as a list, so we could append tcl_args
without explicitly using " ".join
. See https://docs.python.org/3/library/subprocess.html#converting-an-argument-sequence-to-a-string-on-windows.
I'll see what I can do in terms of splitting it. It's been a while. |
str(Path(vivado_path).resolve() / "bin" / "vivado") | ||
if vivado_path is not None | ||
else environ.get("VUNIT_VIVADO_PATH", "vivado") | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it is easier to comment line by line.
This line introduces the environment variable (documented above).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixes #811
if vivado_path is not None | ||
else environ.get("VUNIT_VIVADO_PATH", "vivado") | ||
) | ||
cmd = f'"{vivado}" -nojournal -nolog -notrace -mode batch -source "{Path(tcl_file_name).resolve()}"' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This gets rid of redundant str
in f-string and quotes the location of vivado (in case of spaces).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This and below fixes #686
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]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
More quoting of stuff in case of spaces.
:param compile_order_file: Filename for to write compile-order file. | ||
: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. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Better documentation related to environment variable.
:param compile_order_file: Compile-order file (from :func:`create_compile_order_file`) | ||
:param dependency_scan_defaultlib: Whether to do VUnit scanning of ``xil_defaultlib``. | ||
:param fail_on_non_hdl_files: Whether to fail on non-HDL files. | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Documentation of parameters/arguments.
Closes #686
Closes #796
Closes #811
Not sure where it can be tested. Didn't really find a test file for vivado.py?
The vivado module is not in the documentation? So not really clear where I should document the environment variable. (But I can improve the documentation for
run_vivado
.