Scope interpretation - Bug in ModelTech?

W

Wallclimber

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;
 
E

Egbert Molenkamp

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
 
W

Wallclimber

Egbert Molenkamp said:
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
 
W

Wallclimber

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top