Skip to content

Issue with array concatenation in version 1.16.0 #1199

@jorkrohn

Description

@jorkrohn

The following code fails during elaboration in 1.16.0, but works fine in 1.15.2:

library ieee;
use ieee.std_logic_1164.all;

entity nvc_bug is
end entity nvc_bug;

architecture rtl of nvc_bug is

  type t_slv_array is array (natural range <>) of std_logic_vector;

  function get_slv_array return t_slv_array is
    variable v_data_out : t_slv_array(0 to 1)(7 downto 0) := (others=>x"00");
  begin
    return v_data_out(0 to 1);
  end function get_slv_array;

  constant C_CONSTANT : t_slv_array(0 to 2)(7 downto 0)  := x"00" & get_slv_array;

begin
end architecture rtl;

I get the following output:

Name       WORK.NVC_BUG
Kind       instance
Variables
  C_CONSTANT                            // [24] : 0..8 => stack, constant
Linkage
  STD.STANDARD
  IEEE.STD_LOGIC_1164
  WORK.NVC_BUG.GET_SLV_ARRAY()28WORK.NVC_BUG-RTL.T_SLV_ARRAY
Begin
   0: %0 := package init STD.STANDARD   // P<STD.STANDARD>
      %1 := package init IEEE.STD_LOGIC_1164 // P<IEEE.STD_LOGIC_1164>
      %2 := const [#2,#2,#2,#2,#2,#2,#2,#2] // [8] : 0..8 => const, 2
      %3 := address of %2               // @<0..8> => const, 2
      %4 := context upref 0             // P<WORK.NVC_BUG>
      %5 := fcall WORK.NVC_BUG.GET_SLV_ARRAY()28WORK.NVC_BUG-RTL.T_SLV_ARRAY %4 // [*, *] : 0..8
      %6 := uarray len %5 dim #0        // #
      %7 := add #1 + %6                 // #
      %8 := sub %7 - #1                 // #
      %9 := cast %8                     // -2^31..2^31-1
      %10 := range length left #0 right %9 dir #0 // #
      %11 := mul %10 * #8               // #
      %12 := alloc %11                  // @<0..8>
      %13 := debug locus T_ASSOC@000002A60B2A1180 // D<>
      %14 := debug locus T_RANGE@000002A6085FD610 // D<>
      index check #0 left #0 right %9 dir #0 locus %13
      %16 := array ref %12 offset #0    // @<0..8>
      %17 := link var %1 IEEE.STD_LOGIC_1164.STD_LOGIC_VECTOR // @<[*] : 0..8>
      %16 := copy %3 count #8
      %19 := debug locus T_ASSOC@000002A60A290160 // D<>
      %20 := cast %6                    // -2^31..2^31-1
      %21 := sub %20 - #1               // -2^31..2^31-1
      %22 := add #1 + %21               // -2^31..2^31-1
      index check %22 left #0 right %9 dir #0 locus %19
      %24 := array ref %12 offset #8    // @<0..8>
      %25 := mul %6 * #8                // #
      %26 := unwrap %5                  // @<0..8>
      %24 := copy %26 count %25
      %28 := debug locus T_CONST_DECL@000002A60A2901D0 // D<>
      length check left #3 == right %10 locus %28
      C_CONSTANT := copy %12 count #24
      return     <----

** Fatal: (init): variable IEEE.STD_LOGIC_1164.STD_LOGIC_VECTOR not found in unit IEEE.STD_LOGIC_1164
[00007FF6AE633339] _nvc_file_canseek+0x659
[00007FF6AE7B287A] nvc_random_get_next+0x3caca
[00007FF6AE791619] nvc_random_get_next+0x1b869
[00007FF6AE679856] std_to_string_real+0x3f0c6
[00007FF6AE7B5D52] nvc_random_get_next+0x3ffa2
[00007FF6AE67A3D7] std_to_string_real+0x3fc47
[00007FF6AE64FB71] std_to_string_real+0x153e1
[00007FF6AE669269] std_to_string_real+0x2ead9
[00007FF6AE630177]
[00007FF6AE627C35]
[00007FF6AD21E518]
[00007FF6AD21E575]
[00007FFBEAA5E8D6] (KERNEL32) BaseThreadInitThunk+0x16
[00007FFBEBF714FB] (ntdll) RtlUserThreadStart+0x2b

nvc 1.16.0 (1.16.0.r0.g0fca6f2b) (Using LLVM 20.1.3) [x86_64-w64-mingw32]

Please report this bug at https://github.com/nickg/nvc/issues

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions