aboutsummaryrefslogtreecommitdiffstats
path: root/testsuite
diff options
context:
space:
mode:
authorTristan Gingold <tgingold@free.fr>2020-02-29 17:38:25 +0100
committerTristan Gingold <tgingold@free.fr>2020-02-29 17:38:25 +0100
commitd6f06fcd8eadbfa7f7065e29b4650093570c80b6 (patch)
treee10167af9eaf89947f1d842c836b0bd4ff5101c0 /testsuite
parentaaa25b2ed917f4c90c1011239142987299440961 (diff)
downloadghdl-d6f06fcd8eadbfa7f7065e29b4650093570c80b6.tar.gz
ghdl-d6f06fcd8eadbfa7f7065e29b4650093570c80b6.tar.bz2
ghdl-d6f06fcd8eadbfa7f7065e29b4650093570c80b6.zip
testsuite/synth: add test for #1146
Diffstat (limited to 'testsuite')
-rw-r--r--testsuite/synth/issue1146/ent.vhdl36
-rwxr-xr-xtestsuite/synth/issue1146/testsuite.sh13
2 files changed, 49 insertions, 0 deletions
diff --git a/testsuite/synth/issue1146/ent.vhdl b/testsuite/synth/issue1146/ent.vhdl
new file mode 100644
index 000000000..8ba3c3f3c
--- /dev/null
+++ b/testsuite/synth/issue1146/ent.vhdl
@@ -0,0 +1,36 @@
+entity ent is
+ generic (
+ t1 : time := 2 sec;
+ t2 : time := 5 sec
+ );
+end;
+
+architecture a of ent is
+ constant t3 : time := t1 + t2;
+ constant diff : time := abs (t1 - t2);
+
+ constant shorter : time := minimum(t1, t2);
+ constant longer : time := maximum(t1, t2);
+
+ constant ratio1 : natural := t1 / t2;
+ constant ratio2 : natural := (t1 / 2) / (t2 * 0.5);
+ constant ratio3 : natural := (t1 * 2) / (t2 / 0.5);
+begin
+ assert t3 > 6 sec;
+ assert t3 = 7 sec;
+ assert t3 < 8 sec;
+
+ assert t3 /= 1 ns;
+
+ assert t3 >= shorter;
+ assert shorter <= longer;
+
+ assert diff = longer - shorter;
+ assert -diff = +(shorter-longer);
+
+ assert ratio1 = ratio2;
+ assert ratio1 = ratio3;
+
+ assert t1 * 2 = 2 * t1;
+ assert t1 * 0.5 = 0.5 * t1;
+end;
diff --git a/testsuite/synth/issue1146/testsuite.sh b/testsuite/synth/issue1146/testsuite.sh
new file mode 100755
index 000000000..730cf6d16
--- /dev/null
+++ b/testsuite/synth/issue1146/testsuite.sh
@@ -0,0 +1,13 @@
+#! /bin/sh
+
+. ../../testenv.sh
+
+GHDL_STD_FLAGS=--std=08
+for t in ent; do
+ synth $t.vhdl -e $t > syn_$t.vhdl
+ analyze syn_$t.vhdl
+done
+
+clean
+
+echo "Test successful"