2
votes

I have the following declaration in my architecture:

architecture behavioral of my_widget is
    type register_bank_t is array(1 to 4) of std_logic_vector(31 downto 0); 
    -- register addresses
    constant address : register_bank_t := (
        x"0000_1081", -- 1 
        x"0000_1082", -- 2 
        x"0000_1083", -- 3 
        x"0000_1084"  -- 4 
    );
..

Then later, in a process inside the same architecture, I do:

case bus_addr is
    when address(1) =>
        r_output_value <= reg(1);
    when address(2) =>
        r_output_value <= reg(2);
    when address(3) =>
        r_output_value <= reg(3);
    when address(4) =>
        r_output_value <= reg(4);
    when others =>
        r_output_value <= (others => '0'); 
end case;

I can't figure out why Modelsim gives me the following warning:

(vcom-1937) Choice in CASE statement alternative must be locally static.

When all the choices are clearly constants at compile time.

1
Use -2008 where the choices would be locally static - see IEEE Std 1076-2008 9.4.2 Locally static primaries, para 1 n) An indexed name whose prefix is a locally static primary and whose index expressions are all locally static expressions, added in -2008. You could likewise declare four constants for the 4 register locations. Why does type register_bank_t's range start at 1? - user1155120
The aggregate expression specifying the value of constant address is not of the type register_bank_t (your value needs an others choice) see 6.4.2.2 Constant declarations para 3: If the assignment symbol “:=” followed by an expression is present in a constant declaration, the expression specifies the value of the constant; the type of the expression shall be that of the constant. The value of a constant cannot be modified after the declaration is elaborated. - user1155120
The fact that all the values are not being initialized is a mistake I made when I copied in the original code and the truncated it to save space. - aghoras
In this example, the registers don't have a name: they are called register 1, register 2, etc. Are you saying that if I declare the indices as constants, then the choices will be considered static? - aghoras
No, an indexed name of a constant of an array type with a static index is only specified to be locally static and acceptable as a choice in a case statement in IEEE Std 1076-2008. Either use tools compliant with -2008 or define the addresses as separate constants e. g. constant register1_address: std_logic_vector(31 downto 0) := x"0000_1081"; , etc.. If the indexes into the register_bank_t array are locally static there is no difference in usage. - user1155120

1 Answers

0
votes

Here is what I have found out. Hopefully it will help the next person searching for this answer:

The warning is caused by the fact that constants defined at architecture level are not considered locally static within the process by the compiler (pre VHDL-2008). In order for that to happen, they have to be defined inside the process's declaration block.

One solution is to compile with VHDL 2008 (-2008 option in vcom). Another option is to pass the nocasestaticerror option to vcom which will suppress the warning.