Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Negative time in delay and waits #633

Closed
avelure opened this issue Feb 24, 2023 · 1 comment
Closed

Negative time in delay and waits #633

avelure opened this issue Feb 24, 2023 · 1 comment

Comments

@avelure
Copy link

avelure commented Feb 24, 2023

Debugging a timing issue I noticed that NVC accepts negative values in delayed assignments and waits, and it actually works as well.
This is pretty cool, modelsim and ghdl always complain on this, but I'm not sure this is according to the standard.
In LRM 10.5.2.2, paragraph two, last sentence it specifies "It is an error if the time expression in a waveform element evaluates to a
negative value."
This sentence is also repeated for waits in 10.2 p146 3rd last paragraph, last sentence.

library ieee;
use ieee.std_logic_1164.all;
use ieee.numeric_std.all;

entity test is
end entity test;
architecture beh of test is
  signal sig1 : std_logic := 'U';

begin
  
  process
  begin
    wait for 2 ns;
    sig1 <= 'Z' after -1 ns;
    wait;
  end process;

  process(sig1)
  begin
    if sig1'event then
      assert now = 2 ns report "delay" severity error;
    end if;
  end process;

  process
  begin
    wait for 3 ns;
    report "First wait";
    wait for -1 ns;
    report "Second wait";
    assert now = 3 ns report "wait" severity error;
    wait;
  end process;

end architecture beh;
C:\proj\public\minimal$ nvc --std=08 -a test_event.vhd

C:\proj\public\minimal$ nvc --std=08 -e test-beh -r --exit-severity=failure
** Error: 1ns+0: Assertion Error: delay
         C:\proj\public\minimal\test_event.vhd:22
** Note: 3ns+0: Report Note: First wait
         C:\proj\public\minimal\test_event.vhd:29
** Note: 2ns+0: Report Note: Second wait
         C:\proj\public\minimal\test_event.vhd:31
** Error: 2ns+0: Assertion Error: wait
         C:\proj\public\minimal\test_event.vhd:32
@nickg
Copy link
Owner

nickg commented Feb 25, 2023

There was already some code to check this at elaboration time but it didn't work if the wait statement was in the top-level entity (don't ask). It's fixed by a combination of f62347a and d079ff5 (which also adds a run-time test in case the delay is not a constant).

@nickg nickg closed this as completed Feb 25, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants