nickg / nvc

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

Error: no matching operator "*" [REAL, universal_real return TIME] #805

Closed smaslovski closed 10 months ago

smaslovski commented 10 months ago

Hi,

I believe that the following error message is due to a bug in nvc:

$ nvc --std=2008 -a bug3.vhd
** Error: no matching operator "*" [REAL, universal_real return TIME]
    > bug3.vhd:11
    |
 11 |   y := abs(x*5.0)**2 * 1.0 ns;
    |            ^^^^^
    |
    = Note: no implicit conversion was performed on the second argument as the innermost complete context did not determine a unique numeric type
    = Help: IEEE Std 1076-2008 section 9.3.6 "Type conversions"
** Error: unexpected ** while parsing simple variable assignment, expecting one of when or ;
    > bug3.vhd:11
    |
 11 |   y := abs(x*5.0)**2 * 1.0 ns;
    |                  ^^ this token was unexpected

Here is the content of bug3.vhd:

entity bug is end entity;

architecture mixed of bug is
begin

log: process is
  variable x : real;
  variable y : time;
begin
  x := 2.0;
  y := abs(x*5.0)**2 * 1.0 ns;
  assert false report "y: " & to_string(y) severity failure;
end process;

end architecture;

The same code works as expected in GHDL:

$ ghdl -a --std=08 bug3.vhd
$ ghdl -e --std=08 bug
$ ghdl -r --std=08 bug     
bug3.vhd:12:3:@0ms:(assertion failure): y: 100000000 fs
ghdl:error: assertion failed
ghdl:error: simulation failed

BR,

Stanislav