Get attribute of a field from a VHDL record type
You cannot use the 'range
attribute on a type †, which is what you are trying to do in your code. If you were to do something like this:
signal big_record_instance : big_record_t;
signal ex : unsigned(big_record_instance.field_a'range);
It should work, because you are now trying to get the range of an instance, not a type.
An alternative if you don't have an instance might be to have your width based on constants in the same package that your record type is defined, something like this:
constant field_a_width : integer := 16;
type big_record_t is record
field_a : std_logic_vector(field_a_width-1 downto 0);
field_b : std_logic_vector(23 downto 0);
end record;
signal ex : std_logic_vector(field_a_width-1 downto 0);
Or perhaps
constant field_a_width : integer := 16;
subtype field_a_type is std_logic_vector(field_a_width-1 downto 0);
type big_record_t is record
field_a : field_a_type;
field_b : std_logic_vector(23 downto 0);
end record;
signal ex : field_a_type;
† see exception in comments