Skip to content

Using output as a source (rather than a dest) throw internal error instead of user error #263

@timsherwood

Description

@timsherwood

PyRTL throws an "internal error" when an output is used as a source. This should be caught with a proper pyrtl error (earlier in the process if possible).

Traceback (most recent call last):
File "outerr.py", line 9, in
mem_direct[mreg] <<= mout + 1
File "/Users/sherwood/Desktop/work-stuff/GitProjects/PyRTL/pyrtl/wire.py", line 259, in add
return self._two_var_op(other, '+')
File "/Users/sherwood/Desktop/work-stuff/GitProjects/PyRTL/pyrtl/wire.py", line 201, in _two_var_op
working_block().add_net(net)
File "/Users/sherwood/Desktop/work-stuff/GitProjects/PyRTL/pyrtl/core.py", line 297, in add_net
self.sanity_check_net(net)
File "/Users/sherwood/Desktop/work-stuff/GitProjects/PyRTL/pyrtl/core.py", line 569, in sanity_check_net
raise PyrtlInternalError('error, Outputs cannot be arguments for a net')
pyrtl.pyrtlexceptions.PyrtlInternalError: error, Outputs cannot be arguments for a net

Here is a small piece of code that demonstrates the error.

from pyrtl import *

mem_direct = MemBlock(bitwidth=8, addrwidth=8, name='mem_direct')
mout = Output(8, 'mem_direct_output')
mreg = Register(8, 'mreg')

mout <<= mem_direct[mreg]
mreg.next <<= mreg + 1
mem_direct[mreg] <<= mout + 1

Metadata

Metadata

Assignees

No one assigned

    Labels

    beginner friendlyA good target for undergrads to contribute to PyRTLconfusing or uncaught errorPyRTL error messages not sufficient for situation

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions