#903 defparams in a generate block are put in wrong scope

devel
closed-fixed
4
2012-08-17
2012-08-14
Martin Whitaker
No

For example, with the following code

genvar i;
for (i = 0; i < 2; i = i + 1) begin : Loop
m1 m();
defparam m.p = 1 + i;
end

the compiler issues the warning

defparam.v:11: warning: Scope of m.p not found.

and the defparam is not applied. Trying to work round this by

defparam Loop[i].m.p = 1 + i;

also fails with the error

defparam.v:11: error: Unable to bind parameter `i' in `m2'

The root cause of these problems is that defparams are treated as being in the scope of the enclosing module, rather than in the current lexical scope.

This can be worked round by overriding the parameter during module instation, like this

m1 #(.p(1 + i)) m();

Regression test attached.

Discussion

  • Test case showing bug

     
    Attachments
    • priority: 5 --> 4
    • milestone: --> devel
    • labels: --> Verilog compiler bug
     
  • Setting priority to 4 as there is a workaround.

     
    • assigned_to: nobody --> martinwhitaker
     
    • status: open --> closed-fixed
     
  • Patch submitted on patch tracker.