nickg / nvc

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

** Fatal: tree kind T_ALIAS does not have item I_PORTS #755

Closed smaslovski closed 1 year ago

smaslovski commented 1 year ago

Hi,

I get this crash report when analysing (with nvc --std=2008 -a) the code given further below:

% nvc --std=2008 -a test_bug.vhd
** Fatal: tree kind T_ALIAS does not have item I_PORTS
         ../lib/ieee.08/numeric_std.vhdl:1608
[0x55a60416c932] ../src/object.c:213 object_lookup_failed
[0x55a60416f525] ../src/names.c:576 overload_positional_argument
[0x55a60416f525] ../src/tree.c:3028 solve_one_param.cold
[0x55a604220681] ../src/names.c:3128 solve_subprogram_params.lto_priv.0
[0x55a604224046] ../src/names.c:3300 solve_fcall.part.0.lto_priv.0
[0x55a60421ca7c] ../src/names.c:2742 overload_next_argument
[0x55a60421ca7c] ../src/names.c:3041 solve_one_param
[0x55a604220bd1] ../src/names.c:3172 solve_subprogram_params.lto_priv.0
[0x55a604224046] ../src/names.c:3300 solve_fcall.part.0.lto_priv.0
[0x55a60421ca7c] ../src/names.c:2742 overload_next_argument
[0x55a60421ca7c] ../src/names.c:3041 solve_one_param
[0x55a604220b18] ../src/names.c:3187 solve_subprogram_params.lto_priv.0
[0x55a604224046] ../src/names.c:3300 solve_fcall.part.0.lto_priv.0
[0x55a60421ca7c] ../src/names.c:2742 overload_next_argument
[0x55a60421ca7c] ../src/names.c:3041 solve_one_param
[0x55a604220b18] ../src/names.c:3187 solve_subprogram_params.lto_priv.0
[0x55a604224046] ../src/names.c:3300 solve_fcall.part.0.lto_priv.0
[0x55a60421ca7c] ../src/names.c:2742 overload_next_argument
[0x55a60421ca7c] ../src/names.c:3041 solve_one_param
[0x55a604220b18] ../src/names.c:3187 solve_subprogram_params.lto_priv.0
[0x55a604228005] ../src/names.c:3366 solve_pcall
[0x55a604228005] ../src/names.c:4352 _solve_types.lto_priv.0
[0x55a604229dc9] ../src/names.c:4408 solve_types
[0x55a6041a4770] ../src/parse.c:9844 p_procedure_call_statement
[0x55a6041a4770] ../src/parse.c:10062 p_sequential_statement.lto_priv.0
[0x55a60419b5ef] ../src/parse.c:7764 p_sequence_of_statements.lto_priv.0
[0x55a60419d0c8] ../src/parse.c:7961 p_process_statement_part
[0x55a60419d0c8] ../src/parse.c:8023 p_process_statement.lto_priv.0
[0x55a6041a96c4] ../src/parse.c:12195 p_concurrent_statement.lto_priv.0
[0x55a6041ac49e] ../src/parse.c:12242 p_architecture_body
[0x55a6041ac49e] ../src/parse.c:12501 p_secondary_unit
[0x55a6041acc07] ../src/parse.c:12527 p_design_unit
[0x55a6041acc07] ../src/parse.c:12618 parse
[0x55a6041e1752] ../src/common.c:2244 analyse_file.part.0
[0x55a6041776e8] ../src/nvc.c:2238 analyse
[0x55a6041776e8] ../src/common.c:1692 process_command
[0x55a6041725e9] ../src/nvc.c:1823 main

Here is the code:

-- types
library ieee;
context ieee.ieee_std_context;

package types is
  alias logic is std_ulogic;
  subtype unsigned_byte is unsigned(7 downto 0);
end package types;

-- testbench
library ieee;
context ieee.ieee_std_context;
use std.textio.all;
use std.env.all;
use work.types.all;

entity tb is end entity tb;

architecture bug of tb is
  signal rst, clk : logic;
  signal cnt : unsigned_byte := (others => '0');
begin

reset: rst <= '1', '0' after 20 ns;

clock: process
begin
  clk <= '0';
  wait for 10 ns;
  clk <= '1';
  wait for 10 ns;
end process clock;

counter: process (clk) is
begin
  if rst then
    cnt <= (others => '0');
  elsif rising_edge(clk) then
    cnt <= cnt + 1;
  end if; 
end process;

write_log: postponed process (clk) is
  alias s is to_string [logic return string];
  alias s is to_string [unsigned_byte return string];
  alias h is to_hex_string [unsigned_byte return string];
  variable log_line : line;
begin
  swrite(log_line,
    "time: "  & time'image(now) &
    ", rst: " & s(rst)          & ", clk: " & s(clk) &
    ", cnt: " & h(cnt)          & " = "     & s(cnt));
  writeline(output, log_line);
end process write_log;

fin: process begin
  wait for 256*20 ns; finish;
end process fin;

end architecture bug;

BR, Stanislav

nickg commented 1 year ago

It's caused by an alias of an alias of a subprogram. Should be fixed now. Thanks for reporting.