def is_tb(i: Instantiable) -> bool:
"""Boolean indication of whether Instantiable `m` meets the test-bench interface."""
if isinstance(i, (Module, ExternalModuleCall)):
m = i
elif isinstance(i, GeneratorCall):
m = i.result
else:
raise TypeError(f"Invalid un-instantiable argument {i} to `is_tb`")
if len(m.ports) != 1:
return False
# There's exactly one port. Retrieve it from the `ports` dict,
# first requiring getting its name from the `keys`.
port = m.ports[list(m.ports.keys())[0]]
# While that port is *conventionally* called "VSS", it *can* be called anything.
# The testbench interface is met so long as we have a single, scalar port.
return port.width == 1
Fails if the argument is a GeneratorCall, but has not yet been run. I.e. i.result is None.
This here:
https://github.com/dan-fritchman/Hdl21/blob/edc6bb0a52cd779038ce2511cadcab116ab4c20f/hdl21/sim/data.py#L42
Fails if the argument is a
GeneratorCall
, but has not yet been run. I.e.i.result
isNone
.