[sv-bc] Hierarchical resolution in nested modules

From: Gordon Vreugdenhil <gordonv_at_.....>
Date: Mon Dec 03 2007 - 16:02:49 PST
In SV-BC today, I mentioned that there are some interactions in
the name resolution rules with I think are correct but just
wanted to raise explicitly.

Here is an example:
    module top;
       parameter p = 1;
       struct { int b } a;
       module nest;
          initial a.b = 5;
       endmodule
       if (p) begin : c   // generate if
          if (p) begin : a
             int b;
             nest child();
          end
       end
    endmodule

This is a fairly contrived case to make sure that "a"
doesn't conflict.  The basic point is that in the
"a.b = 5" assignment, the "a.b" refers to "top.a.b"
and not "top.c.a.b".  The reason is that the struct
"a" is lexically visible and thus "a" binds immediately
to it.

If we instead had:
    module top;
       parameter p = 1;
       module nest;
          initial a.b = 5;
       endmodule
       if (p) begin : c   // generate if
          if (p) begin : a
             int b;
             nest child();
          end
       end
       struct { int b } a;
    endmodule

then "a.b" is treated as a hierarchical name (meaning that
"a" must be a scope name).  Since "child" is an instance
of "nest", a.b will resolve hierarchically upwards through
the instance tree to top.c.a.b.  It is a bit weird to
think about "upwards" resolution actually causing this
effect but I think that it holds together.

Basically, although I think this is correct behavior based
on the rules that we have, I just want to make sure that everyone
is in agreement.

Gord.

-- 
--------------------------------------------------------------------
Gordon Vreugdenhil                                503-685-0808
Model Technology (Mentor Graphics)                gordonv@model.com


-- 
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.
Received on Mon Dec 3 16:03:21 2007

This archive was generated by hypermail 2.1.8 : Mon Dec 03 2007 - 16:03:55 PST