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

2008: Generic Package fails with signed type, but not integer #924

Closed
bpadalino opened this issue Jul 21, 2024 · 1 comment
Closed

2008: Generic Package fails with signed type, but not integer #924

bpadalino opened this issue Jul 21, 2024 · 1 comment

Comments

@bpadalino
Copy link
Contributor

package testpkg is
  generic (
    type A ;
    val : A ;
    function to_string(x : A) return string is <> ;
  ) ;

    constant x : A := val ;

    function doit(l, r : A) return string ;

end package ;

package body testpkg is

    function doit(l, r : A) return string is
    begin
        return to_string(l) & to_string(r) ;
    end function ;

end package body ;

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

entity test is
end entity ;

architecture arch of test is


    --package test_int is new work.testpkg generic map(A => integer, val => 12) ;
    package test_signed is new work.testpkg generic map (A => signed, val => to_signed(12, 16)) ;

begin

    tb : process
    begin
        --report test_int.doit(44, 55) ;
        report test_signed.doit(to_signed(44, 16), to_signed(55, 16)) ;
        std.env.stop ;
    end process ;

end architecture ;

The integer version works, but not the signed version.

$ nvc --std=2019 -a test.vhdl -e test -r
** Fatal: tree kind T_ALIAS does not have item I_PORTS
[0x5599b8e2a2f9] ../src/object.c:254 object_lookup_failed
[0x5599b8e27692] ../src/tree.c:595 tree_ports
[0x5599b8e27692] ../src/tree.c:50 simp_call_args.cold
[0x5599b8ea2f3d] ../src/simp.c:238 simp_fcall
[0x5599b8ea2f3d] ../src/simp.c:1565 simp_tree.lto_priv.0
[0x5599b8eb7b44] ../src/object.c:714 object_rewrite
[0x5599b8eb7ba6] ../src/object.c:778 object_rewrite
[0x5599b8eb7d74] ../src/object.c:789 object_rewrite
[0x5599b8eb7ba6] ../src/object.c:778 object_rewrite
[0x5599b8eb7d74] ../src/object.c:789 object_rewrite
[0x5599b8eb7d74] ../src/object.c:789 object_rewrite
[0x5599b8eb7d74] ../src/object.c:789 object_rewrite
[0x5599b8f79eaf] ../src/tree.c:1302 tree_rewrite.isra.0
[0x5599b8eb587c] ../src/simp.c:1700 analyse_file
[0x5599b8e3a60a] ../src/nvc.c:246 analyse
[0x5599b8e3a60a] ../src/nvc.c:1920 process_command
[0x5599b8e314e5] ../src/nvc.c:2060 main
@nickg nickg closed this as completed in 809b75b Jul 21, 2024
@nickg
Copy link
Owner

nickg commented Jul 21, 2024

The difference is to_signed is an alias for signed but an implicit subprogram for integer.

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