From 1ec534e9464accf9c8544001368cb485bbc2aa52 Mon Sep 17 00:00:00 2001 From: Tristan Gingold Date: Thu, 4 Jun 2020 04:04:25 +0200 Subject: testsuite/gna: add a test for stack2 release. --- testsuite/gna/bug0115/repro1.vhdl | 50 ++++++++++++++++++++++++++++++++++++++ testsuite/gna/bug0115/testsuite.sh | 10 ++++++++ 2 files changed, 60 insertions(+) create mode 100644 testsuite/gna/bug0115/repro1.vhdl create mode 100755 testsuite/gna/bug0115/testsuite.sh 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" -- cgit v1.2.3