+ Post New Thread
Results 1 to 8 of 8
  1. #1
    Advanced Member level 5
    Points: 13,178, Level: 27
    Achievements:
    7 years registered

    Join Date
    Aug 2011
    Posts
    2,612
    Helped
    304 / 304
    Points
    13,178
    Level
    27

    Assigning a null array in VHDL

    Hello,

    In a package I have the following definition of a unconstrained unsigned array:
    Code:
    type array_1d_unsigned is array ( integer range <> ) of unsigned ;
    In another file I have an input port named 'x' that is of that type:
    Code:
    entity some_entity is
    (
    x : array_1d_unsigned  
    ) ;
    While instantiating the entity, I want x to be assigned with a null array.
    Code:
    inst_some_entity : some_entity
    (
    x => -- I want to assign a null array here.  
    ) ;
    What's the correct syntax for that ?

    •   AltAdvertisement

        
       

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

    Join Date
    Jun 2010
    Posts
    6,894
    Helped
    2026 / 2026
    Points
    38,054
    Level
    47

    Re: Assigning a null array in VHDL

    You'll need to create a null constant (or signal):

    Code VHDL - [expand]
    1
    2
    3
    4
    5
    
    constant NULL_ARRAY : array_1d_unsigned(1 to 0)(1 to 0) := (others => "");
     
    ..
     
    x => NULL_ARRAY,

    Because its unconstrained, you cannot do it inline, because OTHERS is not allowed in an unconstrained context


    1 members found this post helpful.

  3. #3
    Advanced Member level 5
    Points: 13,178, Level: 27
    Achievements:
    7 years registered

    Join Date
    Aug 2011
    Posts
    2,612
    Helped
    304 / 304
    Points
    13,178
    Level
    27

    Re: Assigning a null array in VHDL

    This is what I tried to do.
    But how will the definition of that constant look?
    Please show an example.



    •   AltAdvertisement

        
       

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

    Join Date
    Jun 2010
    Posts
    6,894
    Helped
    2026 / 2026
    Points
    38,054
    Level
    47

    Re: Assigning a null array in VHDL

    I dont understand what you mean, I showed you how to define the constant.



  5. #5
    Advanced Member level 5
    Points: 13,178, Level: 27
    Achievements:
    7 years registered

    Join Date
    Aug 2011
    Posts
    2,612
    Helped
    304 / 304
    Points
    13,178
    Level
    27

    Re: Assigning a null array in VHDL

    Sorry.
    I viewed this on my cellphone first.
    And what you wrote in the line of code didn't show.

    Forum admins - please note of this problem.
    A snapshot of how this looks on my phone is attached.Click image for larger version. 

Name:	no_text.JPG 
Views:	3 
Size:	78.9 KB 
ID:	156581



    •   AltAdvertisement

        
       

  6. #6
    Super Moderator
    Points: 31,889, Level: 43
    ads-ee's Avatar
    Join Date
    Sep 2013
    Location
    USA
    Posts
    7,381
    Helped
    1731 / 1731
    Points
    31,889
    Level
    43

    Re: Assigning a null array in VHDL

    Quote Originally Posted by shaiko View Post
    Sorry.
    I viewed this on my cellphone first.
    And what you wrote in the line of code didn't show.

    Forum admins - please note of this problem.
    A snapshot of how this looks on my phone is attached.Click image for larger version. 

Name:	no_text.JPG 
Views:	3 
Size:	78.9 KB 
ID:	156581
    You can't use the mobile site if you want to see any attachments. The forum on the mobile site is text based only.

    Use the full site.


    1 members found this post helpful.

  7. #7
    Advanced Member level 5
    Points: 13,178, Level: 27
    Achievements:
    7 years registered

    Join Date
    Aug 2011
    Posts
    2,612
    Helped
    304 / 304
    Points
    13,178
    Level
    27

    Re: Assigning a null array in VHDL

    TrickyDicky,

    The solution with the constant worked.
    But what if x was an array of integers ?
    Code:
    type array_1d_integer is array ( integer range <> ) of integer ;
    Can you post an example of a null array instantiation of this type ?



  8. #8
    Advanced Member level 5
    Points: 38,054, Level: 47
    Achievements:
    7 years registered

    Join Date
    Jun 2010
    Posts
    6,894
    Helped
    2026 / 2026
    Points
    38,054
    Level
    47

    Re: Assigning a null array in VHDL

    A NULL array is defined as array with 0 length. ie. one with a range where 'left is higher than 'right in the case of to, and 'left is less that 'right when using downto.



--[[ ]]--