Menu

#961 Assertion failed in elaborate_type_row when function input has same name as module parameter

devel
closed-fixed
nobody
6
2014-10-30
2014-10-30
No

I have uncovered what appears to be a bug in handling constant functions. The problem occurs when you have a function which uses a module parameter with a given name and the function has a input with the same name. In my example, there is a module parameter called w. If the declaration of the function output uses the parameter w to for example specify an output width, and the module also has an input named w then the compile fails with an assertion failure. If you change the name of the function input then the error goes away. The issue seems to be that iverilog is confused about the difference between the module parameter reference and the input reference. They have the same name but they aren't referring to the same thing.

I will attach an example that compiles fine unless you pass a -D fail. Then the compile will fail. Here is the output I get.

bash-3.2$ /usr/local/bin/iverilog -D fail functest.v
functest.v:10: error: A reference to a wire or reg (`w') is not allowed in a constant expression.
Assertion failed: (me), function elaborate_type_raw, file elab_type.cc, line 129.
sh: line 1: 60560 Done /usr/local/lib/ivl/ivlpp -L -F"/var/folders/0t/7n1dqzv974v_fl_2knb70tl038ym5p/T//ivrlg23caa5ea2" -f"/var/folders/0t/7n1dqzv974v_fl_2knb70tl038ym5p/T//ivrlg3caa5ea2" -p"/var/folders/0t/7n1dqzv974v_fl_2knb70tl038ym5p/T//ivrli3caa5ea2"
60561 Abort trap: 6 | /usr/local/lib/ivl/ivl -C"/var/folders/0t/7n1dqzv974v_fl_2knb70tl038ym5p/T//ivrlh3caa5ea2" -C"/usr/local/lib/ivl/vvp.conf" -- -
bash-3.2$ /usr/local/bin/iverilog functest.v
bash-3.2$

This fails with a build just pulled from the git repository.

Discussion

  • Martin Whitaker

    Martin Whitaker - 2014-10-30

    You seem to have forgotten to add the attachment, but it was easy enough to reproduce the bug from your description. There are actually two bugs here:

    1. It appears the return type of the function is being elaborated within the scope of the function, whereas it should be elaborated within the scope of the enclosing module.

    2. An assertion failure occurs if the elaboration of a function return type fails for any reason (not just this one).

    The second bug is just poor error recovery - the compiler is emitting a sensible error message before the assertion failure - so is less critical.

    The first bug is also present in v0.9.

    N.B. This bug occurs with any function, not just constant functions.

     

    Last edit: Martin Whitaker 2014-10-30
  • Martin Whitaker

    Martin Whitaker - 2014-10-30
    • Priority: 5 --> 6
     
  • Martin Whitaker

    Martin Whitaker - 2014-10-30

    I've pushed a fix for this for both devel and v0.9.

     
  • Martin Whitaker

    Martin Whitaker - 2014-10-30
    • status: open --> closed-fixed
     
    • Peter Johnson

      Peter Johnson - 2014-10-31

      I just pulled the repository and checked it. Looks like your fix works for me. Thanks.

       

Log in to post a comment.