nickg / nvc

VHDL compiler and simulator
https://www.nickg.me.uk/nvc/
GNU General Public License v3.0
589 stars 75 forks source link

8.2 ms not equal to 8200 us #899

Closed avelure closed 1 week ago

avelure commented 1 week ago

I noticed there is an issue with converting decimal time values to fullscale. The value in this case ends up being 1 fs too low, eg. 8199999999999 fs. I checked GHDL and Modelsim where the result was correct.

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

entity test is
end entity test;
architecture beh of test is
constant C_TIME_1 : time := 8.2 ms;
constant C_TIME_2 : time := 8200 us;
begin

  process
  begin
    assert C_TIME_1 = C_TIME_2 report "Not same " & to_string(C_TIME_1) & " /= " &  to_string(C_TIME_2) severity error;
    wait;
  end process;

end architecture beh;
$ nvc --std=08 -a test_time.vhd
$ nvc -e test -r
** Error: 0ms+0: Not same 8199999999999 fs /= 8200000000000 fs
   Process :test:_p0 at C:\proj\public\minimal\test_time.vhd:14