to_unsigned as an expression in an aggregate

Discussion in 'VHDL' started by Nick Bayard, Feb 22, 2013.

  1. Nick Bayard

    Nick Bayard Guest

    I'm getting some odd results when I try to use an aggregate expression to pack several unsigned vectors. I get the error. "This expression must be of a locally static subtype. Invalid aggregate." If I use the concatenate operator (commented below), it seems to compile file. Is this bug from my vendor tool (Aldec) or is there some reason I can't use to_unsigned in an aggregate? Thanks.

    library IEEE;
    use IEEE.std_logic_1164.all;
    use IEEE.numeric_std.all;

    entity my_entity is
    output : out unsigned(39 downto 0)

    architecture my_arch of my_entity is
    signal int1 : integer := 0;
    signal int2 : integer := 0;
    signal us1 : unsigned(9 downto 0) := (others => '0');
    signal us2 : unsigned(9 downto 0) := (others => '0');
    output <= (to_unsigned(int1,10), to_unsigned(int2,10), us1, us2);
    --output <= to_unsigned(int1,10) & to_unsigned(int2,10) & us1 & us2;
    Nick Bayard, Feb 22, 2013
    1. Advertisements

  2. Nick Bayard

    Andy Guest

    The VHDL-2008 standard was updated to addresses this, but I don't know whether it requires named vs positional notation in the aggregate expression for this to be allowed. I also don't know if the size of the actual must be locally static (e.g. whether a call to to_unsigned() would work), but that may be taken care of by named association.

    output <= (39 downto 30 => to_unsigned(int1,10),
    29 downto 20 => to_unsigned(int2,10),
    19 downto 10 => us1,
    9 downto 0 => us2);

    This also depends on whether your tool supports VHDL-2008.

    Support for 2008 is an option that must be enabled for the tool, and then there may be (most likely are) limitations as to which new-for-2008 featuresare supported.

    Another really nice change is that std_logic_vector is now a resolved subtype of std_ulogic_vector. Which means these two formerly separate types can now be direclty assigned to and/or associated with each other without explicit conversion.

    Andy, Feb 25, 2013
    1. Advertisements

  3. Nick Bayard

    Nick Bayard Guest

    Thanks Brian. This the first time that I've heard anyone mention anything indicating that these two expressions did anything differently.
    Nick Bayard, Feb 26, 2013
  4. Nick Bayard

    Nick Bayard Guest

    Andy, my tool does claim to support VHDL-2008 and it is enabled. At this point, the error appears to lie somewhere between my incorrect implementation and the incorrect implementation of the tool. Thanks.
    Nick Bayard, Feb 26, 2013
  5. Nick Bayard

    Andy Guest

    Did you try named association instead of positional association in the aggregate expression? Check your tool user manual to see what parts of 2008 they support.

    Andy, Feb 26, 2013
  6. Nick Bayard

    HT-Lab Guest

    Works fine in Modelsim (10.2)

    HT-Lab, Feb 27, 2013
  7. Nick Bayard

    nbayard Guest

    Aldec has acknowledged that it was a problem with the tool.
    nbayard, Mar 15, 2013
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.