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.
'subtypeor'elementattributes? Posting a minimal reproducible example would help us help you.x'length downto 0extend the new object by one?x'length downto 0would absolutely extend the new object by one, and that is very much intended. I'm looking to change the size of these new objects (either smaller or larger than the original), but'subtypeand'elementis definitely interesting and was something I wasn't aware of. Thank you.