nickg / nvc

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

Error when using function signature in report statement #892

Closed tmeissner closed 1 month ago

tmeissner commented 1 month ago

When a function signature is used in a report statement, nvc emits an error like this:

** Error: ambiguous use of name WAIT_LEVEL
    > test.vhd:23
    |
  6 |   procedure wait_level(signal    data   : in std_logic;
    |   ^ hidden declaration of WAIT_LEVEL as WAIT_LEVEL [STD_LOGIC, STD_LOGIC, TIME]
 ...
 10 |   procedure wait_level(signal    data   : in std_logic_vector;
    |   ^ visible declaration of WAIT_LEVEL as WAIT_LEVEL [STD_LOGIC_VECTOR, STD_LOGIC_VECTOR, TIME]
 ...
 19 |   procedure wait_level(signal    data   : in std_logic;
    |   ^ visible declaration of WAIT_LEVEL as WAIT_LEVEL [STD_LOGIC, STD_LOGIC, TIME]
 ...
 23 |     report wait_level[std_logic, std_logic, time]'instance_name & " timeout occurred";
    |            ^^^^^^^^^^ use of name WAIT_LEVEL here
** Error: unexpected [ while parsing report statement, expecting one of **, severity or ;
    > test.vhd:23
    |
 23 |     report wait_level[std_logic, std_logic, time]'instance_name & " timeout occurred";
    |                      ^ this token was unexpected

The first error is a subsequent error from the fact that nvc can't distinguish between the two function of same name. For that reason I give the signature of the function in line 23, however nvc can't parse that code.

$ nvc --version
nvc 1.13-devel (1.12.0.r41.g3edb4fec) (Using LLVM 14.0.6)
Copyright (C) 2011-2024  Nick Gasson
This program comes with ABSOLUTELY NO WARRANTY. This is free software, and
you are welcome to redistribute it under certain conditions. See the GNU
General Public Licence for details.

Full MWE

library ieee;
  use ieee.std_logic_1164.all;

package test is

  procedure wait_level(signal    data   : in std_logic;
                       constant value   : in std_logic;
                       constant timeout : in time);

  procedure wait_level(signal    data   : in std_logic_vector;
                       constant value   : in std_logic_vector;
                       constant timeout : in time);

end package test;

package body test is

  procedure wait_level(signal    data   : in std_logic;
                       constant value   : in std_logic;
                       constant timeout : in time) is
  begin
    report wait_level[std_logic, std_logic, time]'instance_name & " timeout occurred";
  end procedure wait_level;

  procedure wait_level(signal    data   : in std_logic_vector;
                       constant value   : in std_logic_vector;
                       constant timeout : in time) is
  begin
    report wait_level[std_logic, std_logic, time]'instance_name & " timeout occurred";
  end procedure wait_level;

end package body;
tmeissner commented 1 month ago

Thanks for fixing this :+1: