shaiko
Advanced Member level 5
- Joined
- Aug 20, 2011
- Messages
- 2,644
- Helped
- 303
- Reputation
- 608
- Reaction score
- 297
- Trophy points
- 1,363
- Activity points
- 18,302
I want to write a VHDL function that fits a vector to an array.
The problem is, that I don't know how to make a function return an array.
This is what I wrote so far:
The problem is, that I don't know how to make a function return an array.
This is what I wrote so far:
Code:
function vector_to_array ( vector , width , depth : unsigned ) return "WHAT_SHOULD I WRITE HERE ???" is
type temp_array is array ( 0 to to_integer ( depth ) ) of unsigned ( to_integer ( width ) - 1 downto 0 ) ;
variable my_array : temp_array := ( others => ( others => '0' ) ) ;
begin
for index in 0 to ( to_integer ( depth ) - 1 )
loop
my_array ( index ) := vector ( ( ( to_integer ( width ) * ( to_integer ( depth ) - index ) ) - 1 ) downto ( to_integer ( width ) * ( to_integer ( depth ) - index ) - to_integer ( width ) ) ) ;
end loop ;
return my_array ;
end function vector_to_array ;