diff options
author | Tristan Gingold <tgingold@free.fr> | 2020-01-26 17:05:06 +0100 |
---|---|---|
committer | Tristan Gingold <tgingold@free.fr> | 2020-01-26 17:05:06 +0100 |
commit | 5e24f5149656e295946e2ab36cd58626fcc2c51c (patch) | |
tree | d28e59ec671aaed8747da823af9494a5741c6d5e /testsuite/synth/issue1116 | |
parent | f11a4cf6ccb7d26fe8fba0f2d1e9d411e3f37a43 (diff) | |
download | ghdl-5e24f5149656e295946e2ab36cd58626fcc2c51c.tar.gz ghdl-5e24f5149656e295946e2ab36cd58626fcc2c51c.tar.bz2 ghdl-5e24f5149656e295946e2ab36cd58626fcc2c51c.zip |
testsuite/synth: add case for #1116
Diffstat (limited to 'testsuite/synth/issue1116')
-rw-r--r-- | testsuite/synth/issue1116/ent1.vhdl | 24 | ||||
-rw-r--r-- | testsuite/synth/issue1116/ent1_disp.vhdl | 34 | ||||
-rw-r--r-- | testsuite/synth/issue1116/ent2.vhdl | 26 | ||||
-rwxr-xr-x | testsuite/synth/issue1116/testsuite.sh | 13 |
4 files changed, 97 insertions, 0 deletions
diff --git a/testsuite/synth/issue1116/ent1.vhdl b/testsuite/synth/issue1116/ent1.vhdl new file mode 100644 index 000000000..e7621b06c --- /dev/null +++ b/testsuite/synth/issue1116/ent1.vhdl @@ -0,0 +1,24 @@ +library ieee; +use ieee.std_logic_1164.all; + +entity ent1 is + port ( + clk : in std_logic; + i : in std_logic_vector(31 downto 0); + o : out std_logic_vector(7 downto 0) + ); +end; + +architecture a of ent1 is + function switch_endianness(x : std_logic_vector(31 downto 0)) return std_logic_vector is + begin + return x(7 downto 0) & x(15 downto 8) & x(23 downto 16) & x(31 downto 24); + end function; +begin + process(clk) + begin + if rising_edge(clk) then + o <= switch_endianness(i)(7 downto 0); + end if; + end process; +end; diff --git a/testsuite/synth/issue1116/ent1_disp.vhdl b/testsuite/synth/issue1116/ent1_disp.vhdl new file mode 100644 index 000000000..d031b8ec9 --- /dev/null +++ b/testsuite/synth/issue1116/ent1_disp.vhdl @@ -0,0 +1,34 @@ +library ieee; +use ieee.std_logic_1164.all; + +entity ent1_disp is + port ( + clk : in std_logic; + i : in std_logic_vector(31 downto 0); + o : out std_logic_vector(7 downto 0) + ); +end; + +architecture a of ent1_disp is + function switch_endianness(x : std_logic_vector(31 downto 0)) return std_logic_vector is + begin + return x(7 downto 0) & x(15 downto 8) & x(23 downto 16) & x(31 downto 24); + end function; + + procedure disp (v : std_logic_vector) is + begin + report "left: " & natural'image (v'left); + if v'ascending then + report "to"; + else + report "downto"; + end if; + report "right: " & natural'image (v'right); + end disp; +begin + process + begin + disp (switch_endianness(i)); + wait; + end process; +end; diff --git a/testsuite/synth/issue1116/ent2.vhdl b/testsuite/synth/issue1116/ent2.vhdl new file mode 100644 index 000000000..fbec42d6b --- /dev/null +++ b/testsuite/synth/issue1116/ent2.vhdl @@ -0,0 +1,26 @@ +library ieee; +use ieee.std_logic_1164.all; + +entity ent2 is + port ( + clk : in std_logic; + i : in std_logic_vector(31 downto 0); + o : out std_logic_vector(7 downto 0) + ); +end; + +architecture a of ent2 is + subtype word is std_logic_vector(31 downto 0); + + function switch_endianness(x : word) return word is + begin + return x(7 downto 0) & x(15 downto 8) & x(23 downto 16) & x(31 downto 24); + end function; +begin + process(clk) + begin + if rising_edge(clk) then + o <= switch_endianness(i)(7 downto 0); + end if; + end process; +end; diff --git a/testsuite/synth/issue1116/testsuite.sh b/testsuite/synth/issue1116/testsuite.sh new file mode 100755 index 000000000..166e4c704 --- /dev/null +++ b/testsuite/synth/issue1116/testsuite.sh @@ -0,0 +1,13 @@ +#! /bin/sh + +. ../../testenv.sh + +synth --expect-failure ent1.vhdl -e + +for t in ent2; do + synth $t.vhdl -e $t > syn_$t.vhdl + analyze syn_$t.vhdl + clean +done + +echo "Test successful" |