Subject: Re: [sv-bc] Proposal for SV-BC75 declarations in unnamed blocks
From: Gordon Vreugdenhil (gvreugde@synopsys.com)
Date: Mon Mar 03 2003 - 16:54:54 PST
Steven Sharp wrote:
[...]
>
> module top;
> initial
> begin // no name
> reg r1;
> bar.r2 = 0; // downward reference legal
> begin : bar
> reg r2;
> end
> begin : fubar
> top.r1 = 0; // upward reference ILLEGAL
> bar.r2 = 0; // upward then downward reference legal
> top.bar.r2 = 0; // this one is problematic
> r1 = 0; // upward reference, but not hierarchical name so legal
> end
> end
> endmodule
>
> I would expect most of these to be legal, as noted. The paths don't
> start outside the unnamed block and reference into it.
>
> Normally I would expect top.bar.r2 to be legal. It would be legal in
> Verilog now if the r1 declaration were removed. I don't see why adding
> the r1 declaration, which doesn't change the actual hierarchy, would
> make that illegal. But if the tool creates a generated name for the
> unnamed block scope, then it becomes impossible to use top.bar.r2. The
> name would have to be top.<generated_name>.bar.r2. This seems bad.
> Adding a new variable declaration into a block shouldn't make all the
> existing names in scopes inside that block change.
We really do end up having 3 kinds of blocks:
1) named blocks
2) anonymous statement blocks (no declarations)
3) anonymous declarative blocks (at least one declaration)
Heirarchical names must be allowed to cross into an anonymous statement
block due to backwards compatibility but they can't be allowed into
anonymous declarative blocks due to name uniqueness.
There is a really big difference here -- an anonymous statement
block doese *NOT* create a scope; declared names don't live there.
For example, the following is legal:
module top;
initial
begin
begin : bar
reg r2;
end
begin
reg y;
begin : bar
reg r2;
end
end
end
since the innermost "bar" is in a anonymous declarative
block which creates a different scope. But remove
the declaration of "y" and all of a sudden the design is
illegal since the two "bar" blocks are now both named in
the top scope since the anonymous statment blocks don't
create scopes.
Sigh; I don't see any clean solution. The <generated name> solution
works but I really don't like it. I'd rather re-examine the whole
question of permitting declarations inside unnamed blocks and
reconsider whether some other mechanism should be used to "hide"
declarations from heirarchical name references.
Gord.
-- ---------------------------------------------------------------------- Gord Vreugdenhil gvreugde@synopsys.com Staff Engineer, VCS (Verification Tech. Group) (503) 547-6054 Synopsys Inc., Beaverton OR
This archive was generated by hypermail 2b28 : Mon Mar 03 2003 - 16:55:42 PST