T
Tim Hubberstey
Guest
Hi all,
I was trying to create a mask for a vector in a semi-portable way when I
encountered an interesting behavior of aggregates. The problem is that
for 'outa', the aggregate ends up bring (7 downto 0) while for 'outb',
it ends up bring (0 to 7) with the result that the mask value is
incorrect. I solved this by doing it a different way so there is no
urgency.
------------------
-- in a separate package:
constant MaskBit : natural := 3;
------------------
signal Vector2Mask : std_logic_vector(7 downto 0) := (others => '1');
signal outa, outb : std_logic_vector(7 downto 0);
begin
-- outa = F7, aggregate is a "downto"
outa <= ( 7 downto MaskBit+1 => '1',
MaskBit => '0',
MaskBit-1 downto 0 => '1' );
-- outb = EF, aggregate is a "to"
outb <= Vector2Mask and
( 7 downto MaskBit+1 => '1',
MaskBit => '0',
MaskBit-1 downto 0 => '1' );
------------------
I looked at the LRM and I think that the issue is that there is no
reference for the aggregate in case 'outb' so it uses a 'default'
behavior. I didn't find the LRM to be very clear though, so I have a few
questions:
1. What exactly is happening here?
2. Is there a way to constrain the direction and/or size of an aggregate
so that I can force the direction to be the same ("downto" in this
example) in all cases? I know I can create a variable and assign it with
the aggregate but this seems unnecessarily complex.
Any insight is appreciated.
Thanks,
Tim
PS: I know this won't work if MaskBit is 0 or 7. What I *really* wanted
to do was:
outb <= Vector2Mask and (MaskBit => '0', others => '1');
but this produces an "'Others' is in unconstrained array aggregate"
error.
--
Tim Hubberstey, P.Eng. . . . . . Hardware/Software Consulting Engineer
Marmot Engineering . . . . . . . VHDL, ASICs, FPGAs, embedded systems
Vancouver, BC, Canada . . . . . . . . . . . http://www.marmot-eng.com
I was trying to create a mask for a vector in a semi-portable way when I
encountered an interesting behavior of aggregates. The problem is that
for 'outa', the aggregate ends up bring (7 downto 0) while for 'outb',
it ends up bring (0 to 7) with the result that the mask value is
incorrect. I solved this by doing it a different way so there is no
urgency.
------------------
-- in a separate package:
constant MaskBit : natural := 3;
------------------
signal Vector2Mask : std_logic_vector(7 downto 0) := (others => '1');
signal outa, outb : std_logic_vector(7 downto 0);
begin
-- outa = F7, aggregate is a "downto"
outa <= ( 7 downto MaskBit+1 => '1',
MaskBit => '0',
MaskBit-1 downto 0 => '1' );
-- outb = EF, aggregate is a "to"
outb <= Vector2Mask and
( 7 downto MaskBit+1 => '1',
MaskBit => '0',
MaskBit-1 downto 0 => '1' );
------------------
I looked at the LRM and I think that the issue is that there is no
reference for the aggregate in case 'outb' so it uses a 'default'
behavior. I didn't find the LRM to be very clear though, so I have a few
questions:
1. What exactly is happening here?
2. Is there a way to constrain the direction and/or size of an aggregate
so that I can force the direction to be the same ("downto" in this
example) in all cases? I know I can create a variable and assign it with
the aggregate but this seems unnecessarily complex.
Any insight is appreciated.
Thanks,
Tim
PS: I know this won't work if MaskBit is 0 or 7. What I *really* wanted
to do was:
outb <= Vector2Mask and (MaskBit => '0', others => '1');
but this produces an "'Others' is in unconstrained array aggregate"
error.
--
Tim Hubberstey, P.Eng. . . . . . Hardware/Software Consulting Engineer
Marmot Engineering . . . . . . . VHDL, ASICs, FPGAs, embedded systems
Vancouver, BC, Canada . . . . . . . . . . . http://www.marmot-eng.com