Jonathan Bromley
Guest
Sat Jul 30, 2011 1:59 pm
On Fri, 6 Aug 2010 10:34:38 -0700 (PDT), Sudoer
<TheProperNoun_at_psychophile.com> wrote:
Quote:
I often use records within records, or records within records within
records, ad nausea. It's nice that I can currently do the following:
A.A.A <= X;
A.A.B <= Y;
A.A.C <= Z;
However, there's a lot of repetition in my code, so I often prefer the
following:
A <= ( A => ( A => X,
B => Y,
C => Z ) );
The benefit is more noticeable with long and descriptive names for the
elements, but the problem is that if my intention is to set only the
A, B, and C leaf elements and leave any others unchanged it doesn't
seem possible.
How about an alias?
alias AA: ABC_record_type is A.A;
...
AA.A <= X;
Doesn't quite do what you asked for (I don't think that's
possible) but it does simplify the naming problem somewhat.
Functions and procedures might be useful too:
procedure tweakJustTheLeafParts(signal T: inout ABC_record_type) is
begin
T.A <= X;
...
end;
...
tweakJustTheLeafParts(A.A); -- does A.A.A <= X;
Watch out for multiple drivers, though, as Rob Gaddi points out.
--
Jonathan Bromley
Jonathan Bromley
Guest
Sat Jul 30, 2011 2:01 pm
On Sat, 30 Jul 2011 14:59:57 +0100, Jonathan Bromley
..... sent a long-dead post by mistake. Sorry, please ignore.
Quote:
On Fri, 6 Aug 2010 10:34:38 -0700 (PDT), Sudoer
TheProperNoun_at_psychophile.com> wrote:
I often use records within records, or records within records within
records, ad nausea. It's nice that I can currently do the following:
A.A.A <= X;
A.A.B <= Y;
A.A.C <= Z;
However, there's a lot of repetition in my code, so I often prefer the
following:
A <= ( A => ( A => X,
B => Y,
C => Z ) );
The benefit is more noticeable with long and descriptive names for the
elements, but the problem is that if my intention is to set only the
A, B, and C leaf elements and leave any others unchanged it doesn't
seem possible.
How about an alias?
alias AA: ABC_record_type is A.A;
...
AA.A <= X;
Doesn't quite do what you asked for (I don't think that's
possible) but it does simplify the naming problem somewhat.
Functions and procedures might be useful too:
procedure tweakJustTheLeafParts(signal T: inout ABC_record_type) is
begin
T.A <= X;
...
end;
...
tweakJustTheLeafParts(A.A); -- does A.A.A <= X;
Watch out for multiple drivers, though, as Rob Gaddi points out.