-1

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.

3
  • 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. Commented Jan 29, 2015 at 17:20
  • why would you need this? Commented Jan 29, 2015 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. Commented Jan 29, 2015 at 22:56

1 Answer 1

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.