Take the 2-minute tour ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

Given an array of naturals. How can i declare an array of std_logic_vectors which will have a size same as the element of the naturals array.To put it more plainly if i have an array T= (5,20,11,10,6) with 5 elements is it possible to create an array of std_logic_vectors where every vector will have the size shown in T .ie 5 vectors the first (5 downto 0) the second (20 downto 0) the third (11 down to 0)and so on.

share|improve this question
    
Sounds like homework. The array T will need to be either a constant or a generic. From there, it is just a matter of indexing T. Default direction for indices based on natural is 0 to integer'high. –  Jim Lewis Jan 29 at 17:20
    
why would you need this? –  Philippe Jan 29 at 20:21
1  
Two weeks ago, there was a similar question, which I answered here: Creating a generic array whose elements have increasing width in vhdl. You can replace the increasing size of vectors to your used defined sizes. –  Paebbels Jan 29 at 22:56

1 Answer 1

Arrays must have the same type for their elements. When the element type is an unconstrained array like std_logic_vector the bounds must all match too. In the simplest case you can't have different length std_logic_vector arrays contained in another array. Normally one would use the largest size array for all of the elements. With access types it is possible to create pointers to arrays of different lengths but that is only usable in simulation.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.