Say I have a custom record type:
type CustomRecord is record
S : signed;
V : std_logic;
end record;
We instantiate this by using
signal X : CustomRecord(S(21 downto 0))
which is fine. But then say I want another signal that depends on X
‘s size, I would do
signal Y : CustomRecord(S(X.S'length downto 0))
How would I define a custom attribute for CustomRecord (e.g. ‘length) so that the expression instead becomes something like:
signal Y : CustomRecord(S(X'depth downto 0))
All user-defined attributes I can find online are all hard-baked into the code.
When I try to define my own using
attribute depth : integer;
attribute depth of CustomRecord : type is CustomRecord.S'length;
I get “record type ‘CustomRecord’ cannot be selected”, which I do more-or-less understand, but I don’t know how to work around it.
Aside note: I know having the .S isn’t that big of a deal, but in reality, X.S is an array of signed, so the expression is actually CustomRecord(S(X.S'length downto 0)(X.S(X.S'left)'length downto 0))
which I want to simplify to CustomRecord(S(X'width downto 0)(X'depth downto 0))
. I’ve simplified it to just a signed for this example.
Charlie is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
3
Getting something the same size is easy:
signal Y : X'subtype ;
This is why @Tricky suggested you to look at `subtype.
However, changing the size is tedious as you have found and needs to be looked by the VHDL working group (and you should join us).
What can we do about this for future revisions of VHDL is discussed here:
https://gitlab.com/IEEE-P1076/VHDL-Issues/-/issues
In particular issues that are indirectly related, but may be interesting are here:
https://gitlab.com/IEEE-P1076/VHDL-Issues/-/issues/83
https://gitlab.com/IEEE-P1076/VHDL-Issues/-/issues/81