Scope interpretation - Bug in ModelTech?

W

Wallclimber

Guest
Hello All,

Find below a package that compiles fine with NCSim (version 5.10) but
gives an error with ModelTech 5.7. The error is in this statement:

v_I := pkg_test_use.c_MyConst2;

...: cannot find expanded name: pkg_test_use.c_myconst2
...: Unkown field: c_myconst2
Apparently, ModelTech only looks at constants that have been declared
in the public part of the package, not in the body.

Now here's the strange part. When I remove the declaration of
c_MyConst, ModelTech doesn't complain anymore. Even though the
statement above doesn't even touch c_MyConst!

Am I overlooking some special scoping rule or is this an (admittedly
obscure) scoping bug?

Tom Verbeure

Here is the complete program:

---------------------------------------------------------
package pkg_test_use is
constant c_MyConst : integer := 1;
end pkg_test_use;

package body pkg_test_use is
constant c_MyConst2 : integer := 100;

function f_Function(Num : in integer) return integer
is
constant c_MyConst2 : integer := 200;
variable v_I : integer;
begin
v_I := c_MyConst2;
v_I := pkg_test_use.c_MyConst2;
return v_I;
end f_Function;
end pkg_test_use;
 
IMHO it seems a bug ModelSim and NCsim.
Since c_MyConst2 is not declared in the package (only in the package body) a
VHDL Analayser should complain.
v_I := pkg_test_use.c_MyConst2;
ModelSim does (also the synthesis tool I used; Leonardo). I guess NCSim is
wrong here.

Indeed modelsim does not complain if there is nothing (accept comment) in
the package. That is strange.
(Leonardo still complains "Error, c_MyConst2 is not declared in
pkg_test_use.").
The bug of ModelSim will not effect a real design since an empty package is
not very useful :)

Send a bug report to both tool vendors (and we are curious how they
respond).

Egbert Molenkamp


"Wallclimber" <hombre@gmail.com> wrote in message
news:f7896340.0405251408.165d4586@posting.google.com...
Hello All,

Find below a package that compiles fine with NCSim (version 5.10) but
gives an error with ModelTech 5.7. The error is in this statement:

v_I := pkg_test_use.c_MyConst2;

...: cannot find expanded name: pkg_test_use.c_myconst2
...: Unkown field: c_myconst2

Apparently, ModelTech only looks at constants that have been declared
in the public part of the package, not in the body.

Now here's the strange part. When I remove the declaration of
c_MyConst, ModelTech doesn't complain anymore. Even though the
statement above doesn't even touch c_MyConst!

Am I overlooking some special scoping rule or is this an (admittedly
obscure) scoping bug?

Tom Verbeure

Here is the complete program:

---------------------------------------------------------
package pkg_test_use is
constant c_MyConst : integer := 1;
end pkg_test_use;

package body pkg_test_use is
constant c_MyConst2 : integer := 100;

function f_Function(Num : in integer) return integer
is
constant c_MyConst2 : integer := 200;
variable v_I : integer;
begin
v_I := c_MyConst2;
v_I := pkg_test_use.c_MyConst2;
return v_I;
end f_Function;
end pkg_test_use;
 
"Egbert Molenkamp" <remove_funny_molenkam@cs.utwente.nl> wrote in message news:<c91gb6$7bj$1@ares.cs.utwente.nl>...
IMHO it seems a bug ModelSim and NCsim.
Since c_MyConst2 is not declared in the package (only in the package body) a
VHDL Analayser should complain.
v_I := pkg_test_use.c_MyConst2;
ModelSim does (also the synthesis tool I used; Leonardo). I guess NCSim is
wrong here.
As, interesting. I tried a whole bunch of scoping tests and it turns
out that NCSim is extremely liberal about scoping rules compared to
MTI. Unfortunately, the LRM is not an easy read about this. Anyway,
it's not that important since in real life, these contructs almost
never happen.

Send a bug report to both tool vendors (and we are curious how they
respond).
I did. I'll let know their reaction. If I were them, I'd just ignore
it. I'm sure they have more urgent things to do. :)

Tom
 
Find below the answer from Modeltech:

Hi Tom,

This turned out to be tricky issue. We behave right and wrong here.
Right - when we give an error for
v_I := pkg_test_use.c_MyConst2;

Comment from our VHDL guru here.

I believe we are correct here. Section 6.3 on selected names. States
for a prefix that is a package, the suffix denotes an object declared
in the package. If the prefix is not a package, but an entity,
an architecture, a subprogram, a block, a process, or a loop, then
the suffix denotes a object declared immediately within that construct.
Package body is not mention here so only the object declared within
a package are visible.

Wrong - when we don't give an error if the declaration list of package declaration
is empty - that is what was happening when you commented out c_MyConst.

We will fix this incorrect behavior.
 

Welcome to EDABoard.com

Sponsor

Back
Top