From e7b2039857db4ba617c5a399c11cc4ff4c969959 Mon Sep 17 00:00:00 2001 From: Tristan Gingold Date: Sat, 29 Mar 2014 04:38:27 +0100 Subject: Fix ticket11: remove from active list a signal not active in the next delta due to a second assignment. --- testsuite/gna/ticket11/signalevents.vhdl | 20 ++++++++++++++++++++ testsuite/gna/ticket11/testsuite.sh | 10 ++++++++++ translate/grt/grt-signals.adb | 28 ++++++++++++++++++++++++++++ 3 files changed, 58 insertions(+) create mode 100644 testsuite/gna/ticket11/signalevents.vhdl create mode 100755 testsuite/gna/ticket11/testsuite.sh diff --git a/testsuite/gna/ticket11/signalevents.vhdl b/testsuite/gna/ticket11/signalevents.vhdl new file mode 100644 index 0000000..98161ae --- /dev/null +++ b/testsuite/gna/ticket11/signalevents.vhdl @@ -0,0 +1,20 @@ +entity tb is +end entity; + +architecture arch of tb is + signal s: integer := 0; +begin + process is + begin + wait for 1 us; + s <= 1; + s <= 2 after 1 us; + assert s = 0; + wait on s; + report "s = " & integer'image(s); + assert s = 2 severity failure; + assert now = 2 us severity failure; + wait; + end process; + +end architecture; diff --git a/testsuite/gna/ticket11/testsuite.sh b/testsuite/gna/ticket11/testsuite.sh new file mode 100755 index 0000000..7226710 --- /dev/null +++ b/testsuite/gna/ticket11/testsuite.sh @@ -0,0 +1,10 @@ +#! /bin/sh + +. ../../testenv.sh + +analyze signalevents.vhdl +elab_simulate tb + +clean + +echo "Test successful" diff --git a/translate/grt/grt-signals.adb b/translate/grt/grt-signals.adb index d939a97..4443bd9 100644 --- a/translate/grt/grt-signals.adb +++ b/translate/grt/grt-signals.adb @@ -675,6 +675,34 @@ package body Grt.Signals is Next := Next.Next; end if; end loop; + + -- A previous assignment (with a 0 after time) may have put this + -- signal on the active chain. But maybe this previous + -- transaction has been removed (due to rejection) and therefore + -- this signal won't be active at the next delta. So remove it + -- from the active chain. This is a little bit costly (because + -- the chain is simply linked), but that issue doesn't appear + -- frequently. + if Sign.Link /= null + and then Driver.First_Trans.Next.Time /= Current_Time + then + if Ghdl_Signal_Active_Chain = Sign then + -- At the head of the chain. + -- FIXME: this is not atomic. + Ghdl_Signal_Active_Chain := Sign.Link; + else + -- In the middle of the chain. + declare + Prev : Ghdl_Signal_Ptr := Ghdl_Signal_Active_Chain; + begin + while Prev.Link /= Sign loop + Prev := Prev.Link; + end loop; + Prev.Link := Sign.Link; + end; + end if; + Sign.Link := null; + end if; end; elsif Reject /= 0 then -- LRM93 8.4 -- cgit