Skip to content

Error when using a function to constrain and initialize an output port #1234

@Galactic-Explorer

Description

@Galactic-Explorer
$ nvc -a pkg.vhd ent.vhd test.vhd -e test -r

Name       WORK.TEST.ENT_INST
Kind       instance
Context    WORK.TEST
Types
  WORK.PKG.STD_LOGIC_ARR_PARAMS         {WORK.PKG.LOGIC_PAIR_T{}, -2^31..2^31-1}
  WORK.PKG.LOGIC_PAIR_T$                {$<0..8>, $<0..8>}
  WORK.PKG.LOGIC_PAIR_T                 {0..8, 0..8}
Variables
  PARAMS                                // WORK.PKG.STD_LOGIC_ARR_PARAMS{} => stack, constant
  REC_OUT                               // [*] : WORK.PKG.LOGIC_PAIR_T${} => stack, signal
  i1                                    // # => stack, temp
Linkage
  WORK.PKG
  STD.STANDARD
  IEEE.STD_LOGIC_1164
  IEEE.NUMERIC_STD
  WORK.TEST
  WORK.PKG.INIT(29WORK.PKG.STD_LOGIC_ARR_PARAMS)25WORK.PKG.LOGIC_PAIR_ARR_T
Begin
   0: %0 := package init WORK.PKG       // P<WORK.PKG>
      %1 := package init STD.STANDARD   // P<STD.STANDARD>
      %2 := package init IEEE.STD_LOGIC_1164 // P<IEEE.STD_LOGIC_1164>
      %3 := package init IEEE.NUMERIC_STD // P<IEEE.NUMERIC_STD>
      %4 := var upref 1, PARAMS         // @<WORK.PKG.STD_LOGIC_ARR_PARAMS{}>
      PARAMS := copy %4
      %6 := var upref 1, REC_OUT        // @<WORK.PKG.LOGIC_PAIR_T${}>
      %7 := fcall WORK.PKG.INIT(29WORK.PKG.STD_LOGIC_ARR_PARAMS)25WORK.PKG.LOGIC_PAIR_ARR_T %0, PARAMS // [*] : WORK.PKG.LOGIC_PAIR_T{}
      %8 := null                        // @<WORK.PKG.LOGIC_PAIR_T{}>
      %9 := debug locus T_PORT_DECL@000002626DE70300 // D<>
      %10 := link var %0 WORK.PKG.LOGIC_PAIR_ARR_T // @<[*] : WORK.PKG.LOGIC_PAIR_T{}>
      %11 := load %10                   // [*] : WORK.PKG.LOGIC_PAIR_T{}
      %12 := uarray len %11 dim #0      // #
      %13 := uarray len %7 dim #0       // #
      length check left %12 == right %13 locus %9
      %15 := alloc #5                   // @<WORK.PKG.LOGIC_PAIR_T${}>
      %16 := wrap %15 [#4 downto #0]    // [*] : WORK.PKG.LOGIC_PAIR_T${}
      REC_OUT := store %16
      i1 := store #0
      array scope locus %9              // [*] : WORK.PKG.LOGIC_PAIR_T{}
      jump 1
   1: %21 := load i1                    // #
      %22 := cmp %21 == #5              // 0..1
      cond %22 then 3 else 2
   2: %24 := array ref %15 offset %21   // @<WORK.PKG.LOGIC_PAIR_T${}>
      %25 := array ref %8 offset %21    // @<WORK.PKG.LOGIC_PAIR_T{}>
      %26 := unwrap %7                  // @<WORK.PKG.LOGIC_PAIR_T{}>
      %27 := array ref %26 offset %21   // @<WORK.PKG.LOGIC_PAIR_T{}>
      %28 := debug locus T_PORT_DECL@000002626DE70300 // D<>
      record scope locus %28            // WORK.PKG.LOGIC_PAIR_T{}
      %30 := record ref %25 field 0     // @<0..8>
      %31 := record ref %27 field 0     // @<0..8>
      %32 := load %31                   // 0..8
      %33 := record ref %24 field 0     // @<$<0..8>>
      %34 := link var %2 IEEE.STD_LOGIC_1164.STD_LOGIC$resolution // @<R<0..8>>
      %35 := load %34                   // R<0..8>
      %36 := debug locus T_FIELD_DECL@0000026265FA01C0 // D<>
      %37 := init signal count #1 size #1 value %32 flags #512 locus %36 offset %30 // $<0..8>
      resolve signal %37 resolution %35
      %33 := store %37
      %40 := record ref %25 field 1     // @<0..8>
      %41 := record ref %27 field 1     // @<0..8>
      %42 := load %41                   // 0..8
      %43 := record ref %24 field 1     // @<$<0..8>>
      %44 := load %34                   // R<0..8>
      %45 := debug locus T_FIELD_DECL@0000026265FA0230 // D<>
      %46 := init signal count #1 size #1 value %42 flags #512 locus %45 offset %40 // $<0..8>
      resolve signal %46 resolution %44
      %43 := store %46
      pop scope
      %50 := add %21 + #1               // #
      i1 := store %50
      jump 1
   3: pop scope
      %54 := debug locus T_PARAM@000002626DE70410 // D<>
      %55 := load REC_OUT               // [*] : WORK.PKG.LOGIC_PAIR_T${}
      %56 := uarray len %55 dim #0      // #
      length check left %56 == right #5 locus %54
      i1 := store #0
      %59 := unwrap %55                 // @<WORK.PKG.LOGIC_PAIR_T${}>
      %60 := cmp %56 == #0              // 0..1
      cond %60 then 5 else 4
   4: %62 := load i1                    // #
      %63 := array ref %59 offset %62   // @<WORK.PKG.LOGIC_PAIR_T${}>
      %64 := array ref %6 offset %62    // @<WORK.PKG.LOGIC_PAIR_T${}>
      %65 := record ref %63 field 0     // @<$<0..8>>
      %66 := record ref %64 field 0     // @<$<0..8>>
      %67 := load %66                   // $<0..8>
      %68 := load %65                   // $<0..8>
      map signal %68 to %67 count #1
      %70 := record ref %63 field 1     // @<$<0..8>>
      %71 := record ref %64 field 1     // @<$<0..8>>
      %72 := load %71                   // $<0..8>
      %73 := load %70                   // $<0..8>
      map signal %73 to %72 count #1
      %75 := add %62 + #1               // #
      i1 := store %75
      %77 := cmp %75 == %56             // 0..1
      cond %77 then 5 else 4
   5: return     <----

** Fatal: (init): variable WORK.PKG.LOGIC_PAIR_ARR_T not found in unit WORK.PKG
    > C:\...\test.vhd:20
    |
 20 |     ent_inst : entity work.ent
    |     ^ while elaborating instance ENT_INST
    |
    = Note: generic PARAMS => PARAMS
[00007FF6BDDF3339] _nvc_file_canseek+0x659
[00007FF6BDF7293A] nvc_random_get_next+0x3caca
[00007FF6BDF516D9] nvc_random_get_next+0x1b869
[00007FF6BDE39A16] std_to_string_real+0x3f286
[00007FF6BDF75E12] nvc_random_get_next+0x3ffa2
[00007FF6BDE3A597] std_to_string_real+0x3fe07
[00007FF6BDE0FBA1] std_to_string_real+0x15411
[00007FF6BDE292F0] std_to_string_real+0x2eb60
[00007FF6BDE2D309] std_to_string_real+0x32b79
[00007FF6BDE29362] std_to_string_real+0x2ebd2
[00007FF6BDDF0177]
[00007FF6BDDEFE57]
[00007FF6BDDE7C35]
[00007FF6BC9DE518]
[00007FF6BC9DE575]
[00007FFF8B52E8D6] (KERNEL32) BaseThreadInitThunk+0x16
[00007FFF8C97C34B] (ntdll) RtlUserThreadStart+0x2b

nvc 1.16.1 (1.16.1.r0.ge2307876) (Using LLVM 20.1.3) [x86_64-w64-mingw32]

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

ent.txt
pkg.txt
test.txt

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