aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTristan Gingold <tgingold@free.fr>2019-02-06 20:23:52 +0100
committerTristan Gingold <tgingold@free.fr>2019-02-07 05:33:58 +0100
commit50da90f509aa6de2961f1795af0be2452bc2c6d9 (patch)
tree0a0b2b9259df2b68a270933ec99a5a21dbb9c86e
parent2c5f8d35f89153533edffe3ae472b91932670519 (diff)
downloadghdl-50da90f509aa6de2961f1795af0be2452bc2c6d9.tar.gz
ghdl-50da90f509aa6de2961f1795af0be2452bc2c6d9.tar.bz2
ghdl-50da90f509aa6de2961f1795af0be2452bc2c6d9.zip
Add testcase for #747
-rw-r--r--testsuite/gna/issue747/fa.vhdl17
-rw-r--r--testsuite/gna/issue747/fa_tb.vhdl57
-rwxr-xr-xtestsuite/gna/issue747/testsuite.sh11
3 files changed, 85 insertions, 0 deletions
diff --git a/testsuite/gna/issue747/fa.vhdl b/testsuite/gna/issue747/fa.vhdl
new file mode 100644
index 000000000..11530b709
--- /dev/null
+++ b/testsuite/gna/issue747/fa.vhdl
@@ -0,0 +1,17 @@
+library ieee;
+use ieee.std_logic_1164.all;
+
+entity fa is
+ port(
+ a:in std_ulogic;
+ b: in std_ulogic;
+ ci: in std_ulogic;
+ co: out std_ulogic;
+ s: out std_ulogic);
+end fa;
+
+architecture fa_behave of fa is
+begin
+ s <= a xor b xor ci;
+ co <= (a and b) or (a and ci) or (b and ci);
+end fa_behave;
diff --git a/testsuite/gna/issue747/fa_tb.vhdl b/testsuite/gna/issue747/fa_tb.vhdl
new file mode 100644
index 000000000..600c02f47
--- /dev/null
+++ b/testsuite/gna/issue747/fa_tb.vhdl
@@ -0,0 +1,57 @@
+library ieee;
+use ieee.std_logic_1164.all;
+
+entity fa_tb is
+end fa_tb;
+
+architecture fa_behave of fa_tb is
+ signal a, b, ci, co, s : std_ulogic;
+
+begin
+ DUT : entity work.fa
+ port map(a => a,
+ b => b,
+ ci => ci,
+ s => s,
+ co => co);
+
+ process
+ type pattern_type is record
+ a, b, ci, s, co : std_ulogic;
+ end record;
+
+ type pattern_array is array (natural range <>) of pattern_type;
+ constant patterns : pattern_array :=
+ (('0', '0', '0', '0', '0'),
+ ('0', '0', '1', '1', '0'),
+ ('0', '1', '0', '1', '0'),
+ ('0', '1', '1', '0', '1'),
+ ('1', '0', '0', '1', '0'),
+ ('1', '0', '1', '0', '1'),
+ ('1', '1', '0', '0', '1'),
+ ('1', '1', '1', '1', '1'));
+
+ begin
+ for i in pattern_array'range loop
+ a <= pattern_array(i).a;
+ b <= pattern_array(i).b;
+ ci <= pattern_array(i).ci;
+
+ wait for 1 ns;
+
+ assert s = pattern_array(i).s
+ report "bad sum value" severity error;
+
+ assert co = pattern_array(i).co
+ report "bad co value" severity error;
+
+ end loop;
+
+ assert false
+ report "end of test" severity note;
+
+ wait;
+ end process;
+
+end fa_behave;
+
diff --git a/testsuite/gna/issue747/testsuite.sh b/testsuite/gna/issue747/testsuite.sh
new file mode 100755
index 000000000..0f9f8991f
--- /dev/null
+++ b/testsuite/gna/issue747/testsuite.sh
@@ -0,0 +1,11 @@
+#! /bin/sh
+
+. ../../testenv.sh
+
+#export GHDL_STD_FLAGS=--std=08
+analyze fa.vhdl
+analyze_failure fa_tb.vhdl
+
+clean
+
+echo "Test successful"