Compare commits
7 commits
0230edd2fb
...
6ff0e77d38
Author | SHA1 | Date | |
---|---|---|---|
6ff0e77d38 | |||
645a838a73 | |||
70a7b0520a | |||
9ca64a7d4d | |||
0f497e76e8 | |||
fcfa9eb7d0 | |||
3c5c3a4555 |
1 changed files with 23 additions and 0 deletions
23
vhdl/util.vhdl
Normal file
23
vhdl/util.vhdl
Normal file
|
@ -0,0 +1,23 @@
|
||||||
|
library ieee;
|
||||||
|
use ieee.std_logic_1164.all;
|
||||||
|
|
||||||
|
package util is
|
||||||
|
function flip_endianness(val : in std_logic_vector) return std_logic_vector;
|
||||||
|
end package;
|
||||||
|
|
||||||
|
package body util is
|
||||||
|
function flip_endianness(val : in std_logic_vector) return std_logic_vector is
|
||||||
|
constant BYTES : natural := val'length / 8;
|
||||||
|
variable ret : std_logic_vector(val'length-1 downto 0);
|
||||||
|
begin
|
||||||
|
assert val'length mod 8 = 0
|
||||||
|
report "length of vector not a multiple of 8"
|
||||||
|
severity failure;
|
||||||
|
|
||||||
|
for i in 0 to BYTES-1 loop
|
||||||
|
ret((BYTES-i)*8 - 1 downto (BYTES-i-1) * 8) := val((i+1)*8 - 1 downto i*8);
|
||||||
|
end loop;
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
end function;
|
||||||
|
end package body;
|
Loading…
Reference in a new issue