Non Overridable (“Private or output”) Generics
Is your capability/feature request related to a problem?
Motivation
Many designs require a public generic A and a derived value B, where:
• B computed A
• B used in the entity’s port clause, and perhaps architecture
• B to not be overridden by instantiation
• B defined once, not repeated in multiple places
Avoiding:
• duplicated expressions in port declarations
• accidental misuse (overriding B inconsistently with A)
• cluttered entity interfaces
• inability to enforce relationships between generics
Describe the solution you'd like
entity foo is
generic (
X : natural := 4;
Y : natural := 2;
W : private natural := X * Y -- or W : out natural, which could share a constant back up to the higher level. There could be better syntax, but this should give context.
);
port (
data_in : in std_logic_vector(W-1 downto 0)
data_out : out std_logic_vector(W-1 downto 0)
);
end entity;
Describe alternatives you've considered
packages and calculations in packages
Additional context
There may be other constants that an instantiation could calculate (not limited to bus widths), akin to a construction of an object.
Other bus width functions could be
Provide the largest number the logic vector is required to represent, have a standard lib way to calc the required width.
Have a standard INTEGER_VECTOR (or natural) that can be defined on a port as
my_integers : in (0 TO SIZE - 1)(RANGE <lower> TO <upper>);