parametric vector slices

A

alb

Hi everyone,

I'm not sure if the 'subject' is correctly formulated but I'll try anyway.

Assume an array of bits 'a' which has N number of bits. Now assume M < N
where N/M = k is an integer number. I'd like to slice a in k pieces in
such a way that I can assign each slice to another array of bits with M
bits.

Something like this:

<code>

--not tested
variable a : my_array_of_bits(N-1 downto 0);

type list is array (0 to k) of my_array_of_bits(M-1 downto 0);
variable l : list;

for i in 0 to l'range - 1 loop
l(i) <= a((i+1)*M - 1 downto i*M);
end loop;

</code>

Is there any better way to do this?

Al
 
A

Andy

Al,

For vhdl-2008 compliant tools, you can declare a type that is an unconstrained array of unconstrained arrays, so it is possible to write a "slice(input, M)" function that would return such a type. You may want a function that does the reverse too.

Check your tools' documentation to see which 2008 features they support.

Andy
 

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. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,901
Latest member
Noble71S45

Latest Threads

Top