Are constants not locally static?

Discussion in 'VHDL' started by M. Norton, Oct 16, 2008.

  1. M. Norton

    M. Norton Guest

    Well this one was a new one on me. Granted this is a warning, but
    thought it might be worth running down, as it seemed to be one of
    those warnings I want to make certain disappear. From Modelsim:

    ** Warning: blah blah(183): Case choice must be a locally static
    expression.

    So, here's the structure I have. In a package I created an array of
    records and defined them, like so:

    type filt_record is record
    name : string(1 to 18);
    address : std_logic_vector(10 downto 0);
    weight : integer;
    a429_label : std_logic_vector(7 downto 0);
    end record filt_record;

    type filt_table is array (0 to NUM_CHANNELS-1) of filt record;

    constant FILT_DATA : filt_table := (
    0 => ("Display Brightness", "000--------", 1, "01000000"),
    ... yada yada ...
    27 => ("Combiner +12V ", "111-----111", 16, "10110001"));

    Okay, so far, so good. Also, so I could refer to the indicies by
    name, I created a number of constants mapping name to integer, like
    so:

    constant DISPLAY_BRIGHTNESS : integer := 0;
    ....
    constant COMB_P12V : integer := 27;

    Seems fine. So onto the code that caused the warning. The package is
    declared properly, and so forth earlier. The signal below
    "label_value" is a signal and is a smaller slice of a larger input
    std_logic_vector port. So it's well declared.

    LABEL_CHECKING : process is
    begin
    loop
    wait until some'event;

    --
    -- Perform some specific label checks
    --
    case label_value is
    when FILT_DATA(COMB_BACKLIGHT).a429_label =>
    -- Do some stuff
    when others =>
    null;
    end case;
    end loop;
    end process LABEL_CHECKING;

    The only thing I can think is that the compiler thinks
    FILT_DATA(COMB_BACKLIGHT).a429_label is not locally static. However,
    FILT_DATA is a constant array of records and COMB_BACKLIGHT is one of
    those array index constants. It seems to me like everything in the
    "when" statement should evaluate to something that cannot change.

    So, is Modelsim throwing a warning about nothing, or is there
    something I've missed?

    Thanks for any help with this oddball warning.

    Best regards,
    Mark Norton
    M. Norton, Oct 16, 2008
    #1
    1. Advertising

  2. M. Norton wrote:

    > The only thing I can think is that the compiler thinks
    > FILT_DATA(COMB_BACKLIGHT).a429_label is not locally static.


    It's not.
    Either simplify the condition or use if/then/elsif...

    -- Mike Treseler

    ___________________
    57 Thu Oct 16 /evtfs/home/tres> verror 1186
    vcom Message # 1186:
    When the expression is of an array type, the length of the array must
    be known at compile time. The simulator is less restrictive than the
    LRM requires as long as the array length of the expression can be
    determined in the compiler.
    IEEE Std 1076-1993, 8.8 Case statement:

    If the expression is of a one-dimensional character array type, then
    the expression must be one of the following:
    -- The name of an object whose subtype is locally static
    -- An indexed name whose prefix is one of the members of this list
    and whose indexing expressions are locally static expressions
    -- A slice name whose prefix is one of the members of this list and
    whose discrete range is a locally static discrete range
    -- A function call whose return type mark denotes a locally static
    subtype
    -- A qualified expression or type conversion whose type mark
    denotes a locally static subtype

    It is an error if the element subtype of the one-dimensional character
    array type is not a locally static subtype.
    Mike Treseler, Oct 16, 2008
    #2
    1. Advertising

  3. M. Norton

    M. Norton Guest

    On Oct 16, 2:37 pm, Mike Treseler <> wrote:
    > M. Norton wrote:
    > > The only thing I can think is that the compiler thinks
    > > FILT_DATA(COMB_BACKLIGHT).a429_label is not locally static.

    >
    > It's not.
    > Either simplify the condition or use if/then/elsif...


    Thank you. I had thought you couldn't get much more static than a
    constant array with a constant index, but perhaps there's a granite or
    bedrock declaration someplace ;-). I'll just chalk it up to a quirk
    of the language.

    Mark
    M. Norton, Oct 17, 2008
    #3
  4. An indexed name is never locally static, nor is a selected name.
    The name you have is a selected name of an indexed name, so
    it is not locally static. See 7.4.1 Locally static primaries
    and 7.4.2 Globally static primaries. Subelements (that is,
    indexed names and/or selected names) are on the list in 7.4.2
    but not on the list in 7.4.1.

    While what you have can be considered globally static, it is
    never considered locally static. Since the compiler knows the
    array length of the value it's allowed (but not compliant,
    hence the warning).


    M. Norton wrote:
    > Well this one was a new one on me. Granted this is a warning, but
    > thought it might be worth running down, as it seemed to be one of
    > those warnings I want to make certain disappear. From Modelsim:
    >
    > ** Warning: blah blah(183): Case choice must be a locally static
    > expression.
    >
    > So, here's the structure I have. In a package I created an array of
    > records and defined them, like so:
    >
    > type filt_record is record
    > name : string(1 to 18);
    > address : std_logic_vector(10 downto 0);
    > weight : integer;
    > a429_label : std_logic_vector(7 downto 0);
    > end record filt_record;
    >
    > type filt_table is array (0 to NUM_CHANNELS-1) of filt record;
    >
    > constant FILT_DATA : filt_table := (
    > 0 => ("Display Brightness", "000--------", 1, "01000000"),
    > ... yada yada ...
    > 27 => ("Combiner +12V ", "111-----111", 16, "10110001"));
    >
    > Okay, so far, so good. Also, so I could refer to the indicies by
    > name, I created a number of constants mapping name to integer, like
    > so:
    >
    > constant DISPLAY_BRIGHTNESS : integer := 0;
    > ...
    > constant COMB_P12V : integer := 27;
    >
    > Seems fine. So onto the code that caused the warning. The package is
    > declared properly, and so forth earlier. The signal below
    > "label_value" is a signal and is a smaller slice of a larger input
    > std_logic_vector port. So it's well declared.
    >
    > LABEL_CHECKING : process is
    > begin
    > loop
    > wait until some'event;
    >
    > --
    > -- Perform some specific label checks
    > --
    > case label_value is
    > when FILT_DATA(COMB_BACKLIGHT).a429_label =>
    > -- Do some stuff
    > when others =>
    > null;
    > end case;
    > end loop;
    > end process LABEL_CHECKING;
    >
    > The only thing I can think is that the compiler thinks
    > FILT_DATA(COMB_BACKLIGHT).a429_label is not locally static. However,
    > FILT_DATA is a constant array of records and COMB_BACKLIGHT is one of
    > those array index constants. It seems to me like everything in the
    > "when" statement should evaluate to something that cannot change.
    >
    > So, is Modelsim throwing a warning about nothing, or is there
    > something I've missed?
    >
    > Thanks for any help with this oddball warning.
    >
    > Best regards,
    > Mark Norton
    James Unterburger, Oct 17, 2008
    #4
  5. M. Norton

    M. Norton Guest

    On Oct 16, 5:19 pm, James Unterburger <> wrote:
    > An indexed name is never locally static, nor is a selected name.
    > The name you have is a selected name of an indexed name, so
    > it is not locally static.  See 7.4.1 Locally static primaries
    > and 7.4.2 Globally static primaries.  Subelements (that is,
    > indexed names and/or selected names) are on the list in 7.4.2
    > but not on the list in 7.4.1.
    >
    > While what you have can be considered globally static, it is
    > never considered locally static.  Since the compiler knows the
    > array length of the value it's allowed (but not compliant,
    > hence the warning).


    Thank you. I suppose I don't truly comprehend the distinction between
    globally and locally static. The question I ask myself is, if
    something is globally static, how could it be less static at a lower
    level of scope?

    However, it's a language definition thing and that's not really my
    forte. It's sufficient to understand that even though everything is a
    constant, I can't use anything with an index or a record selection as
    an expression in a case statement, but would be valid for an if/then
    logic expression.
    M. Norton, Oct 20, 2008
    #5
    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. Charles M. Elias

    Why is this not a locally static choice?

    Charles M. Elias, Jun 26, 2003, in forum: VHDL
    Replies:
    2
    Views:
    1,499
    Charles M. Elias
    Jun 26, 2003
  2. jesse_j
    Replies:
    2
    Views:
    1,473
    jesse_j
    Dec 12, 2004
  3. Mohammed  A khader
    Replies:
    1
    Views:
    2,615
    Jonathan Bromley
    Jan 28, 2005
  4. Taras_96

    Locally static?!

    Taras_96, May 2, 2005, in forum: VHDL
    Replies:
    3
    Views:
    698
    Jim Lewis
    May 16, 2005
  5. a s
    Replies:
    7
    Views:
    1,190
    Mike Treseler
    Nov 30, 2011
Loading...

Share This Page