A
ALuPin
Hi,
one possible solution to reverse an unconstrained std_logic_vector is
to use
the following function:
function reverse(p: std_logic_vector) return std_logic_vector is
variable result: std_logic_vector(p'reverse_range);
begin
for i in p'range loop
result(i) := p(i);
end loop;
return result;
end;
Now I have the following type and signal declaration:
subtype stype_data is std_logic_vector(7 downto 0);
type type_array is array (natural range <>) of stype_data;
signal ls_test_data : type_array(3 downto 0);
How would a function have to look like to be capable of
reverse the order of the array elements ? Is it legal to use
the following unconstrained function to achieve that reversing ?
function reverse2(p: type_array) return type_array is
variable result: type_array(p'reverse_range);
begin
for i in p'range loop
result(i) := p(i);
end loop;
return result;
end;
Thank you for your opinion.
Rgds,
ALuPin
one possible solution to reverse an unconstrained std_logic_vector is
to use
the following function:
function reverse(p: std_logic_vector) return std_logic_vector is
variable result: std_logic_vector(p'reverse_range);
begin
for i in p'range loop
result(i) := p(i);
end loop;
return result;
end;
Now I have the following type and signal declaration:
subtype stype_data is std_logic_vector(7 downto 0);
type type_array is array (natural range <>) of stype_data;
signal ls_test_data : type_array(3 downto 0);
How would a function have to look like to be capable of
reverse the order of the array elements ? Is it legal to use
the following unconstrained function to achieve that reversing ?
function reverse2(p: type_array) return type_array is
variable result: type_array(p'reverse_range);
begin
for i in p'range loop
result(i) := p(i);
end loop;
return result;
end;
Thank you for your opinion.
Rgds,
ALuPin