warning message for case statements where the selector signal is of type std_logic_vector

P

profpenguin

I have had to compile some VHDL code using "Modelsim". For all the
"case" statements in the code that where the selector signal is of type
"std_logic_vector", I get the following warning:

"Array type case expression must be of a locally static subtype"

I only see this type of warning from Modelsim. Cadence's NCVHDL, never
complained. Normally I have used NCVHDL, and have just recently needed
to use Modelsim for a customer.

I googled searched the warning, and came across several similar
questions posted. After looking at them all, I couldn't find one that
addressed why I got this warning or how to avoid it.

I created a simple example, in order to see if I could get rid of the
warning by trying several ideas, some coming from the other postings.
For example, I tried type qualification. Also defining a type array
inside the architecture and using a signal of that type as the
selector, thinking that that should be locally static. Using
bit_vector instead of std_logic_vector. Nothing I do seems to get rid
of the warning.

Here is my very simple base example file that I tried all sorts of
modifications too.
-----------------------------------------------------------
LIBRARY ieee;
USE ieee.std_logic_1164.ALL;
USE ieee.numeric_std.ALL;

ENTITY case_example IS
PORT(
sel_sig : in std_logic_vector(3 downto 0);
output : out std_logic
);
END ENTITY case_example;

ARCHITECTURE rtl OF case_example IS

type sel_sig_t is array (3 downto 0) of bit;
signal sel_sig_i : sel_sig_t;

BEGIN

case_example_proc:
PROCESS(sel_sig)
BEGIN
CASE (sel_sig) IS
WHEN "0000" => output <= '1';
WHEN OTHERS => output <= '0';
END CASE;
END PROCESS case_example_proc;
END ARCHITECTURE rtl;

--------------------------------------------------------------

I can accept the idea that since std_logic_vector type is unbounded,
that by the strictest interpretation of the LRM, the sel_sig type is
not locally static hence the warning, but since the file actually
provides bounds to the array, Modelsim is smart enough to be able to
compile, and maybe that is what is happening. But if I use sel_sig_i
as the selector signal, why doesn't the warning go away? Wouldn't
sel_sig_t be locally static type?

Do other people using Modelsim see this warning when using case
statements where the selector signal is a std_logic_vector? Does the
simulation behave as you expect? Do you code the design differently?

The original code that I was compiling has seen silicon, which does
work. So could is this just slight differences in the LRM
interpretation?

Thank you in advance.

Calvin
 
J

Jezwold

The sample code you gave just compiled correctly under modelsim 5.3 and
the only error i got was that Array case expressions must not be in
parentheses.
 
J

Jezwold

Having read some of the comments it apears that you should in fact get
an error because its not a locally static variable,so I susspect
version 5.3 is incorrect and later versions have been modified to more
acuratly follow the lrm
 
P

profpenguin

Thanks for your answer.

What makes 'sel_sig' type not locally static. Is it because the type
of sel_sig is std_logic_vector, which is defined as an unbounded array,
even though the entity port description bounds the array?

If I use the internally declared 'sel_sig_i' signal for the selector
expression. I get the same warning. In this case, the signal's type
is defined in the file, it is bounded, I am not making a subtype of an
unbounded array. Why isn't this not locally static?

I have tried to understand the LRM's definition, but I find the wording
confusing.



Thanks again
Calvin
 
T

Tristan Gingold

Thanks for your answer.

What makes 'sel_sig' type not locally static. Is it because the type
of sel_sig is std_logic_vector, which is defined as an unbounded array,
even though the entity port description bounds the array?
No, it is because you are enclosing the name within parenthesis. Then
the expression is not a name anymore, and its type is the base type.
If I use the internally declared 'sel_sig_i' signal for the selector
expression. I get the same warning. In this case, the signal's type
is defined in the file, it is bounded, I am not making a subtype of an
unbounded array. Why isn't this not locally static?

I have tried to understand the LRM's definition, but I find the wording
confusing.
A parenthesis expression is not a name, that the reason of the error.

Tristan.
 
C

Calvin

Tristan Gingold said:
No, it is because you are enclosing the name within parenthesis. Then
the expression is not a name anymore, and its type is the base type.

A parenthesis expression is not a name, that the reason of the error.

Tristan.

Thank you.

Once the parenthesis were removed, the warning message did not appear.

Calvin
 
D

Douglas Sykora

Calvin said:
Tristan Gingold <[email protected]> wrote in message

Thank you.

Once the parenthesis were removed, the warning message did not appear.

Why do parenthesis turn a variable into a non-(locally static subtype)?
I sure would like to understand this a little better.
Thanks in Advance,
Doug
 

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,766
Messages
2,569,569
Members
45,042
Latest member
icassiem

Latest Threads

Top