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

Subtype association in port map crashes nvc during elaboration #662

Closed
augustofg opened this issue Mar 30, 2023 · 2 comments
Closed

Subtype association in port map crashes nvc during elaboration #662

augustofg opened this issue Mar 30, 2023 · 2 comments

Comments

@augustofg
Copy link

Here is a minimal reproducible example:

library ieee;
use ieee.std_logic_1164.all;

package test_pkg is
  type t1 is record
    f1 : std_logic;
  end record t1;
  subtype t1_sub is t1;
end package;

-------------------------------
library ieee;
use ieee.std_logic_1164.all;

library work;
use work.test_pkg.all;

entity test is
  port (
    pin  : in  t1;
    pout : out t1_sub
  );
end entity;

architecture test_arch of test is
begin
  pout.f1 <= pin.f1;
end architecture;

-------------------------------
library ieee;
use ieee.std_logic_1164.all;

library work;
use work.test_pkg.all;

entity sub is
end entity;

architecture sub_arch of sub is
  signal a : t1_sub;
  signal b : t1_sub := (f1 => '0');
begin

  cmp: entity work.test
    port map (
      pin => b,
      pout => a
    );

  process
  begin
    report "b.a = " & std_logic'image(b.f1);
    wait for 1 ns;
  end process;
end architecture;

Tested with GHDL and it works as expected, but crashes with nvc during elaboration:

$ nvc --std=2008 -a nvc_subtype_test.vhd 
$ nvc --std=2008 -e sub

Name       WORK.SUB.CMP
Kind       instance
Context    WORK.SUB
Blocks     1
Registers  4
Types      7
  WORK.TEST_PKG.T1$                     {$<0..8>}
Variables  1
  PIN                                   // WORK.TEST_PKG.T1${}, signal
Begin
   0: r0 := package init WORK.TEST_PKG  // P<WORK.TEST_PKG>
      r1 := package init IEEE.STD_LOGIC_1164 // P<IEEE.STD_LOGIC_1164>
      r2 := var upref 1, B              // @<T1_SUB${}>
      r3 := index PIN                   // @<WORK.TEST_PKG.T1${}>
      r3 := copy r2	 <----

** Fatal: source and destination types do not match
[0x55fa60ba753d] 
[0x55fa60b02e42] 
[0x55fa60b9d006] 
[0x55fa60b55cab] 
[0x55fa60b5bd7d] 
[0x55fa60b5d56a] 
[0x55fa60b0ac76] 
[0x55fa60b007ca] 
[0x7feff743c78f] (/usr/lib/libc.so.6) ../sysdeps/nptl/libc_start_call_main.h:58 __libc_start_call_main
[0x7feff743c849] (/usr/lib/libc.so.6) ../csu/libc-start.c:360 __libc_start_main@@GLIBC_2.34
[0x55fa60b01954]
@nickg
Copy link
Owner

nickg commented Mar 30, 2023

Thanks for the test case. This should be fixed now, could you try again?

@augustofg
Copy link
Author

Works for me now. Thanks!

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