Skip to content

Not all constants should be globally static

Consider the following:

signal s : std_logic_vector(1 to 5);
...
p1: process is
begin
  for i in 2 to 4 loop
    b: block is
      constant ii : integer := i;
    begin
      s(ii) <= '1';
    end block;
  end loop;
end process;

Which sub-elements of s have drivers in this process? According to 9.4.3 e) a constant declared by a constant declaration with a globally static subtype is a globally static primary, and hence s(ii) is a static name and is also the longest static prefix of the target of the signal assignment, and so should be used to define a driver in this process. But drivers are calculated during elaboration and s(ii) cannot be evaluated at that time because the declarations in the sequential block are only elaborated when the block is executed, so what is the intended behaviour?

I believe we should restrict which constant declarations are considered globally static, to exclude those declared in sequential block declarative regions (and maybe also in subprograms).

Edited by Nick Gasson
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information