diff options
author | Tristan Gingold <tgingold@free.fr> | 2022-06-04 16:37:23 +0200 |
---|---|---|
committer | Tristan Gingold <tgingold@free.fr> | 2022-06-04 18:55:57 +0200 |
commit | 89afd0cc5a3b36f185c62c9f183066133631910e (patch) | |
tree | 1828a8e2d3285a8ed7dfc4b677c7dd0f9692f1de /testsuite/synth/issue2072/swaptest.vhdl | |
parent | 467f6d66017b73496cef8b5212385c3b407a722f (diff) | |
download | ghdl-89afd0cc5a3b36f185c62c9f183066133631910e.tar.gz ghdl-89afd0cc5a3b36f185c62c9f183066133631910e.tar.bz2 ghdl-89afd0cc5a3b36f185c62c9f183066133631910e.zip |
testsuite/synth: add a test for #2072
Diffstat (limited to 'testsuite/synth/issue2072/swaptest.vhdl')
-rw-r--r-- | testsuite/synth/issue2072/swaptest.vhdl | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/testsuite/synth/issue2072/swaptest.vhdl b/testsuite/synth/issue2072/swaptest.vhdl new file mode 100644 index 000000000..11ea76368 --- /dev/null +++ b/testsuite/synth/issue2072/swaptest.vhdl @@ -0,0 +1,34 @@ +library ieee; +use ieee.std_logic_1164.all; +use ieee.numeric_std.all; + +entity swaptest is +port ( + clk : in std_logic; + d : in unsigned(7 downto 0); + q : out unsigned(7 downto 0) +); +end entity; + +architecture rtl of swaptest is + +FUNCTION bswap(v : unsigned) RETURN unsigned IS + VARIABLE u: unsigned(0 TO v'length-1) :=v; + VARIABLE x: unsigned(0 TO v'length-1); +BEGIN + FOR i IN 0 TO v'length-1 LOOP + x((v'length-1)-i):=u(i); + END LOOP; + return x; +END FUNCTION; + +begin + + process(clk) begin + if rising_edge(clk) then + q(7 downto 1) <= bswap(d(7 downto 1)); + end if; + end process; + +end architecture; + |