+ Post New Thread
Results 1 to 5 of 5
  1. #1
    Member level 4
    Points: 507, Level: 4

    Join Date
    Mar 2012
    Posts
    73
    Helped
    0 / 0
    Points
    507
    Level
    4

    giving value to a constant

    I have this:
    Code:
    constant offset_A: std_logic_vector(address_length+1 downto 0) :="01"&(others=>'0');
    constant offset_B: std_logic_vector(address_length+1 downto 0) := "10"&(others=>'0');
    but of course is not acceptable by compiler.

    Can you suggest me an alternative way?

    address_length is a generic so it can be used if you wish. What I want is obvious, give a value to the first 2 bits and the rest of them be '0'.

    The error I get is:
    Code:
     OTHERS aggregate cannot be operand of operator with unconstrained array formal.

    •   AltAdvertisment

        
       

  2. #2
    Advanced Member level 5
    Points: 37,449, Level: 47
    Achievements:
    7 years registered

    Join Date
    Jun 2010
    Posts
    6,805
    Helped
    1997 / 1997
    Points
    37,449
    Level
    47

    Re: giving value to a constant

    constant offset_A : std_logic_vector(address_length+1 downto 0) := (address_length+1 downto address_length => "01", others => '0' );



    •   AltAdvertisment

        
       

  3. #3
    Member level 4
    Points: 507, Level: 4

    Join Date
    Mar 2012
    Posts
    73
    Helped
    0 / 0
    Points
    507
    Level
    4

    Re: giving value to a constant

    Quote Originally Posted by TrickyDicky View Post
    constant offset_A : std_logic_vector(address_length+1 downto 0) := (address_length+1 downto address_length => "01", others => '0' );
    I get this error:
    Code:
    Error: C:/Modeltech_pe_edu_10.1a/examples/landmark_1.vhd(97): String literal found where non-array type ieee.std_logic_1164.STD_LOGIC was expected.
    ** Warning: C:/Modeltech_pe_edu_10.1a/examples/landmark_1.vhd(97): (vcom-1073) Non-locally static choice (association #1, choice #1) is allowed only if it is the only choice of the only association.



    •   AltAdvertisment

        
       

  4. #4
    Advanced Member level 5
    Points: 37,449, Level: 47
    Achievements:
    7 years registered

    Join Date
    Jun 2010
    Posts
    6,805
    Helped
    1997 / 1997
    Points
    37,449
    Level
    47

    Re: giving value to a constant

    try this:

    constant offset_A : std_logic_vector(address_length+1 downto 0) := (address_length => '1', others => '0' );



  5. #5
    Member level 4
    Points: 507, Level: 4

    Join Date
    Mar 2012
    Posts
    73
    Helped
    0 / 0
    Points
    507
    Level
    4

    Re: giving value to a constant

    Quote Originally Posted by TrickyDicky View Post
    try this:

    constant offset_A : std_logic_vector(address_length+1 downto 0) := (address_length => '1', others => '0' );
    This works. i only get the warning.



--[[ ]]--