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

Genvar not found, related to n-dim array and parameters? #2661

Closed
s-holst opened this issue Nov 18, 2024 · 1 comment · Fixed by #2674
Closed

Genvar not found, related to n-dim array and parameters? #2661

s-holst opened this issue Nov 18, 2024 · 1 comment · Fixed by #2674

Comments

@s-holst
Copy link

s-holst commented Nov 18, 2024

In the following code, the genvar index is not found when used in the initialization of a localparam.

This seems to be related to multi-dimensional arrays, packed structs, and parameters (tried to simplify, but removing any of these aspects does not trigger this bug anymore).

module submodule #(
  parameter logic [0:2][31:0] two_d_logic_array = '{default: 0}
) ();
endmodule

package pkg;
  typedef struct packed {
    logic [0:2][31:0][0:3]  three_d_logic_array;
  } a_packed_struct;
endpackage

module top #(
  parameter pkg::a_packed_struct my_packed_struct = '{ three_d_logic_array: '{default: 0} }
)();
for (genvar index = 0; index < int'(4); index++) begin
    localparam logic [0:2][31:0] my_two_d_logic_array = my_packed_struct.three_d_logic_array[index]; // <-- ERROR: Identifier `\index' is implicitly declared and `default_nettype is set to none.
    submodule #(
      .two_d_logic_array ( my_two_d_logic_array )
    ) sub1 ();
end
endmodule

Debug output:

synlig> read_systemverilog -debug id_not_found.sv


1. Executing SystemVerilog frontend.
[INF:CM0023] Creating log file "/.../slpp_all/surelog.log".
[INF:CP0300] Compilation...
[INF:CP0301] /.../id_not_found.sv:7:1: Compile package "pkg".
[INF:CP0303] /.../id_not_found.sv:2:1: Compile module "work@submodule".
[INF:CP0303] /.../id_not_found.sv:13:1: Compile module "work@top".
[INF:CP0302] Compile class "work@mailbox".
[INF:CP0302] Compile class "work@process".
[INF:CP0302] Compile class "work@semaphore".
[INF:EL0526] Design Elaboration...
[INF:CP0335] /.../id_not_found.sv:16:50: Compile generate block "[email protected][0]".
[INF:CP0335] /.../id_not_found.sv:16:50: Compile generate block "[email protected][1]".
[INF:CP0335] /.../id_not_found.sv:16:50: Compile generate block "[email protected][2]".
[INF:CP0335] /.../id_not_found.sv:16:50: Compile generate block "[email protected][3]".
[NTE:EL0503] /.../id_not_found.sv:13:1: Top level module "work@top".
[NTE:EL0508] Nb Top level modules: 1.
[NTE:EL0509] Max instance depth: 3.
[NTE:EL0510] Nb instances: 5.
[NTE:EL0511] Nb leaf instances: 4.
[INF:UH0706] Creating UHDM Model...
[INF:UH0707] Elaborating UHDM...
[  FATAL] : 0
[ SYNTAX] : 0
[  ERROR] : 0
[WARNING] : 0
[   NOTE] : 5
Object 'work@top' of type 'design'
  Object 'builtin' of type 'package'
  Object 'pkg' of type 'package'
    Object 'pkg::a_packed_struct' of type 'struct_typespec'
      Object 'three_d_logic_array' of type 'typespec_member'
        Object '' of type 'range'
          Object '' of type 'constant'
          Object '' of type 'constant'
        Object '' of type 'range'
          Object '' of type 'constant'
          Object '' of type 'constant'
        Object '' of type 'range'
          Object '' of type 'constant'
          Object '' of type 'constant'
  Object 'work@top' of type 'module_inst'
    Object 'my_packed_struct' of type 'parameter'
      Object 'pkg::a_packed_struct' of type 'struct_typespec'
        Object 'three_d_logic_array' of type 'typespec_member'
          Object '' of type 'range'
            Object '' of type 'constant'
            Object '' of type 'constant'
          Object '' of type 'range'
            Object '' of type 'constant'
            Object '' of type 'constant'
          Object '' of type 'range'
            Object '' of type 'constant'
            Object '' of type 'constant'
    Object '' of type 'param_assign'
      Object 'my_packed_struct' of type 'parameter'
        Object 'pkg::a_packed_struct' of type 'struct_typespec'
          Object 'three_d_logic_array' of type 'typespec_member'
            Object '' of type 'range'
              Object '' of type 'constant'
              Object '' of type 'constant'
            Object '' of type 'range'
              Object '' of type 'constant'
              Object '' of type 'constant'
            Object '' of type 'range'
              Object '' of type 'constant'
              Object '' of type 'constant'
      Object '' of type 'operation'
        Object '' of type 'operation'
          Object '' of type 'tagged_pattern'
            Object '' of type 'constant'
    Object 'genblk1[0]' of type 'gen_scope_array'
      Object '' of type 'gen_scope'
        Object 'my_two_d_logic_array' of type 'parameter'
          Object '' of type 'range'
            Object '' of type 'constant'
            Object '' of type 'constant'
          Object '' of type 'range'
            Object '' of type 'constant'
            Object '' of type 'constant'
        Object 'index' of type 'parameter'
        Object '' of type 'param_assign'
          Object 'my_two_d_logic_array' of type 'parameter'
            Object '' of type 'range'
              Object '' of type 'constant'
              Object '' of type 'constant'
            Object '' of type 'range'
              Object '' of type 'constant'
              Object '' of type 'constant'
          Object 'my_packed_struct.three_d_logic_array[index]' of type 'hier_path'
            Object 'my_packed_struct' of type 'ref_obj'
            Object 'three_d_logic_array' of type 'bit_select'
              Object 'index' of type 'ref_obj'
        Object 'sub1' of type 'module_inst'
          Object 'two_d_logic_array' of type 'parameter'
            Object '' of type 'range'
              Object '' of type 'constant'
              Object '' of type 'constant'
            Object '' of type 'range'
              Object '' of type 'constant'
              Object '' of type 'constant'
          Object '' of type 'param_assign'
            Object 'two_d_logic_array' of type 'parameter'
              Object '' of type 'range'
                Object '' of type 'constant'
                Object '' of type 'constant'
              Object '' of type 'range'
                Object '' of type 'constant'
                Object '' of type 'constant'
            Object 'my_packed_struct.three_d_logic_array[index]' of type 'hier_path'
              Object 'my_packed_struct' of type 'ref_obj'
              Object 'three_d_logic_array' of type 'bit_select'
                Object 'index' of type 'ref_obj'
/.../id_not_found.sv:17: ERROR: Identifier `\index' is implicitly declared and `default_nettype is set to none.
@kamilrakoczy
Copy link
Collaborator

The essence of the problem laid in simplify_parameter function which it is executed while initial AST tree is being formed.

That function calls synlig_simplify function on some nodes and those calls demand properly set scope.
Because of the fact that in that moment AST tree is not properly formed yet, scope has to be artificially created.
The issue was that Synlig didn't consider adding nodes from currently created subtree to scope.

#2674 should fix this issue.

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

Successfully merging a pull request may close this issue.

2 participants