hdl.ir: typecheck convert(ports=) more carefully.
The `ports` argument to the `convert` functions is a frequent hotspot of beginner issues. Check to make sure it is either a list or a tuple, and give an appropriately helpful error message if not. Fixes #362.
This commit is contained in:
parent
fd7f69f7a5
commit
f2b4584b34
2 changed files with 16 additions and 0 deletions
|
|
@ -532,6 +532,12 @@ class Fragment:
|
|||
if ports is None:
|
||||
fragment._propagate_ports(ports=(), all_undef_as_ports=True)
|
||||
else:
|
||||
if not isinstance(ports, tuple) and not isinstance(ports, list):
|
||||
msg = "`ports` must be either a list or a tuple, not {!r}"\
|
||||
.format(ports)
|
||||
if isinstance(ports, Value):
|
||||
msg += " (did you mean `ports=(<signal>,)`, rather than `ports=<signal>`?)"
|
||||
raise TypeError(msg)
|
||||
mapped_ports = []
|
||||
# Lower late bound signals like ClockSignal() to ports.
|
||||
port_lowerer = DomainLowerer(fragment.domains)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue