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

Discussion in 'VHDL' started by profpenguin@shaw.ca, Feb 5, 2005.

  1. Guest

    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
    , Feb 5, 2005
    #1
    1. Advertising

  2. Jezwold Guest

    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.
    Jezwold, Feb 5, 2005
    #2
    1. Advertising

  3. Jezwold Guest

    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
    Jezwold, Feb 5, 2005
    #3
  4. Guest

    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
    , Feb 5, 2005
    #4
  5. wrote:

    > 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.
    Tristan Gingold, Feb 6, 2005
    #5
  6. Calvin Guest

    Tristan Gingold <> wrote in message news:<cu5hbm$91b$.9tel.net>...
    > 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
    Calvin, Feb 7, 2005
    #6
  7. "Calvin" <> wrote in message
    news:...
    > Tristan Gingold <> wrote in message

    news:<cu5hbm$91b$.9tel.net>...
    > > 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.


    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
    >
    > Calvin
    Douglas Sykora, Feb 11, 2005
    #7
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Thomas Rouam
    Replies:
    6
    Views:
    1,103
  2. Dave
    Replies:
    0
    Views:
    587
  3. Will
    Replies:
    3
    Views:
    689
    JohnDuq
    Mar 20, 2009
  4. Will
    Replies:
    1
    Views:
    801
    joris
    Mar 10, 2009
  5. John Crichton
    Replies:
    6
    Views:
    248
    John Crichton
    Jul 12, 2010
Loading...

Share This Page