aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTristan Gingold <tgingold@free.fr>2020-06-04 04:04:25 +0200
committerTristan Gingold <tgingold@free.fr>2020-06-04 13:39:10 +0200
commit1ec534e9464accf9c8544001368cb485bbc2aa52 (patch)
tree12469f0e94f242452c886f113c48170350d13d6d
parent53276df143b43ac3d8be5bb95e3ae9f1ba7f3e81 (diff)
downloadghdl-1ec534e9464accf9c8544001368cb485bbc2aa52.tar.gz
ghdl-1ec534e9464accf9c8544001368cb485bbc2aa52.tar.bz2
ghdl-1ec534e9464accf9c8544001368cb485bbc2aa52.zip
testsuite/gna: add a test for stack2 release.
-rw-r--r--testsuite/gna/bug0115/repro1.vhdl50
-rwxr-xr-xtestsuite/gna/bug0115/testsuite.sh10
2 files changed, 60 insertions, 0 deletions
diff --git a/testsuite/gna/bug0115/repro1.vhdl b/testsuite/gna/bug0115/repro1.vhdl
new file mode 100644
index 000000000..cbf1bd9c2
--- /dev/null
+++ b/testsuite/gna/bug0115/repro1.vhdl
@@ -0,0 +1,50 @@
+-- Test release of stack2 for conditions.
+entity repro1 is
+end;
+
+library ieee;
+use ieee.numeric_std.all;
+
+architecture behav of repro1 is
+ function ispow2a(i : integer) return boolean is
+ begin
+ if to_integer(to_unsigned(i, 32) and to_unsigned(i - 1, 32)) = 0 then
+ return true;
+ else
+ return false;
+ end if;
+ end;
+
+ function ispow2b(i : integer) return boolean is
+ begin
+ return to_integer(to_unsigned(i, 32) and to_unsigned(i - 1, 32)) = 0;
+ end;
+
+ function ispow2c(i : integer) return boolean is
+ begin
+ while to_integer(to_unsigned(i, 32) and to_unsigned(i - 1, 32)) = 0 loop
+ return true;
+ end loop;
+ return false;
+ end;
+
+ function ispow2d(i : integer) return boolean is
+ begin
+ loop
+ exit when to_integer(to_unsigned(i, 32) and to_unsigned(i - 1, 32)) = 0;
+ return False;
+ end loop;
+ return True;
+ end;
+
+ signal s : boolean;
+begin
+ assert ispow2a (64);
+ assert not ispow2b (31);
+
+ assert ispow2c (64);
+ assert not ispow2c (31);
+
+ assert ispow2d (128);
+ assert not ispow2d (30);
+end behav;
diff --git a/testsuite/gna/bug0115/testsuite.sh b/testsuite/gna/bug0115/testsuite.sh
new file mode 100755
index 000000000..7f0bbe5fe
--- /dev/null
+++ b/testsuite/gna/bug0115/testsuite.sh
@@ -0,0 +1,10 @@
+#! /bin/sh
+
+. ../../testenv.sh
+
+analyze repro1.vhdl
+elab_simulate repro1 --checks
+
+clean
+
+echo "Test successful"