Skip to content

Fix invalid_connection error when probes are used with modules #2

@mdko

Description

@mdko

My additions to sanity check in the modules-v3 branch erroneously say that connections between internal module wires and probes are invalid. Probes are extra-modular, meta-level entities that shouldn't affect correctness.

For example:

import pyrtl

class Foo(pyrtl.Module):
    def __init__(self):
        super().__init__()
    
    def definition(self):
        i = self.Input(1, 'i')
        o = self.Output(3, 'o')
        b = pyrtl.Register(2, 'b')
        b.next <<= i + 1
        o <<= b

f = Foo()
for w in pyrtl.working_block().wirevector_subset(cls=pyrtl.Register):
    pyrtl.probe(w)

produces

Traceback (most recent call last):
  File "probes.py", line 16, in <module>
    pyrtl.probe(w)
  File "/Users/michael/PyRTL/pyrtl/helperfuncs.py", line 56, in probe
    p <<= w  # late assigns len from w automatically
  File "/Users/michael/PyRTL/pyrtl/wire.py", line 181, in __ilshift__
    self._build(other)
  File "/Users/michael/PyRTL/pyrtl/wire.py", line 168, in _build
    working_block().add_net(net)
  File "/Users/michael/PyRTL/pyrtl/core.py", line 297, in add_net
    self.sanity_check_net(net)
  File "/Users/michael/PyRTL/pyrtl/core.py", line 919, in sanity_check_net
    fail(arg, dest, "Argument and destination must belong to same module")
  File "/Users/michael/PyRTL/pyrtl/core.py", line 883, in fail
    raise PyrtlError('Invalid connection (%s -> %s). %s for these wire types.'
pyrtl.pyrtlexceptions.PyrtlError: Invalid connection (b/2R -> (Probe-0: b)/2O). Argument and destination must belong to same module for these wire types.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions