New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Generic parameters treated strictly when -frelaxed selected #2651
Comments
This one is not easy to support as aggregate are analyzed before elaboration. I don't plan to work on it soon, but I will try to do all the preliminary work. |
I'm not surprised this is harder, I was quite surprised at just how small commit ae75c96 is! Just for reference, this issue doesn't just apply to explicit generic parameters, but also to locally calculated constants, the following code also fails in essentially the same way: library ieee;
use ieee.std_logic_1164.all;
entity test_others is
port (
data_i : in std_ulogic_vector;
data_o : out std_ulogic_vector
);
end;
architecture arch of test_others is
constant WIDTH_IN : natural := data_i'LENGTH;
begin
data_o <= (WIDTH_IN-1 downto 0 => data_i, others => '0');
end; |
Think I'll also add this as a note here: experimenting with replacing the library ieee;
use ieee.std_logic_1164.all;
entity test_others is
port (
data_i : in std_ulogic_vector;
data_o : out std_ulogic_vector
);
end;
architecture arch of test_others is
constant WIDTH_IN : natural := data_i'LENGTH;
constant WIDTH_OUT : natural := data_o'LENGTH;
function extend(data : std_ulogic_vector) return std_ulogic_vector
is
variable result : data_o'SUBTYPE;
-- variable result : std_ulogic_vector(WIDTH_OUT-1 downto 0);
begin
result(WIDTH_IN-1 downto 0) := data;
result(WIDTH_OUT-1 downto WIDTH_IN) := (others => '0');
return result;
end;
begin
-- data_o <= (WIDTH_IN-1 downto 0 => data_i, others => '0');
data_o <= extend(data_i);
end; fails with message
Again it seems plausible to me that the pedantry of the VHDL standard (😬) does indeed forbid this, but this definitely seems another candidate for However ... in this case I'm not going to claim that ModelSim does it better ... instead, it produces the message
Cool! My experience seems to be that |
The subtype attribute doesn't generate anymore an error in that case. |
Description
When analysing with the
-frelaxed
flag the treatment of generic size parameters is stricter than expected, in particularothers
cannot be used.Expected behaviour
It would be useful to support the relaxed behaviour implemented by ModelSim/QuestaSim and by Vivado. These tools treat generic size parameters more like global constants and allow more flexible aggregate constructions.
How to reproduce?
The code below fails with ghdl, but only produces warnings with ModelSim and with Vivado
built with command
generates errors
With ModelSim the following warning is generated:
Context
Please, provide the following information:
Built from sources using NIX at commit 98e90ff
The text was updated successfully, but these errors were encountered: