Hierarchical Names Support

Hierarchical names are partially supported in Efinity. This topic lists examples of hierarchical names and their support statuses.

Named Blocks (Supported)

module scope_access (
    input logic [7:0] x,
    output logic [7:0] result
);
    
    begin : named_scope  // named begin-end block
        logic [7:0] scope_var;
        assign scope_var = 8'h33;
    end
    
    always_comb begin
        result = named_scope.scope_var + x; // hierarchical access
    end

endmodule 

Nested Named Blocks (Supported)

module nested_scope (
    input logic [7:0] x,
    output logic [7:0] result
);

    begin : outer_scope
        logic [7:0] outer_var;
        assign outer_var = 8'h11 + x;

        begin : inner_scope
            logic [7:0] inner_var;
            assign inner_var = 8'h22 + x + x;
        end
    end

    always_comb begin
        result = outer_scope.outer_var + outer_scope.inner_scope.inner_var;
    end

endmodule

Named Generate Block (Supported)

module generate_access (
    input logic [1:0] mult,
    output logic [7:0] result
);

    logic [7:0] sum;

    genvar i;
    generate
        for (i = 0; i < 4; i++) begin : gen_block
            logic [7:0] gen_data;
            assign gen_data = 8'h10 * mult + i;
        end
    endgenerate

    always_comb begin
        // Access generated block variables
        sum = gen_block[0].gen_data +
              gen_block[1].gen_data +
              gen_block[2].gen_data +
              gen_block[3].gen_data;
        result = sum;
    end

endmodule

Named Fork-Join Blocks (Not Supported)

Hierarchical names to named fork-join blocks are not supported.
module fork_join_access (
    output logic [7:0] result
);
    
    initial begin
        // First fork-join block
        fork : mod_1
            begin
                logic [7:0] x;
                mod_2.x = 8'h25;
            end
        join
        
        // Second fork-join block  
        fork : mod_2
            begin
                logic [7:0] x;
                mod_1.x = 8'h35;
            end
        join
    end
    
    always_comb begin
        result = mod_1.x + mod_2.x;
    end

endmodule

Absolute Path Names (Not Supported)

Absolute path names using $root or $unit are not supported.
module deep_child();
    logic [7:0] deep_data;
    assign deep_data = 8'hAA;
endmodule

module mid_level();
    deep_child u_deep();
endmodule

module absolute_path (
    output logic [7:0] result
);
    
    logic [7:0] top_data;
    assign top_data = 8'hBB;
    
    mid_level u_mid();
    
    always_comb begin
        // Not Supported
        result = $root.absolute_path.u_mid.u_deep.deep_data + 
                 $root.absolute_path.top_data;
    end

endmodule 

External Net Access (Not Supported)

Accessing nets in other modules is not supported.
module child_mod();
    logic [7:0] child_data;
    assign child_data = 8'h55;
endmodule

module child_module_var (
    output logic [7:0] result
);
    
    child_mod u_child();

    always_comb begin
        result = u_child.child_data; // not supported
        // result = child_mod.child_data // also not supported
    end

endmodule 

Access Functions or Tasks in Other Modules (Partially Supported)

Accessing functions and tasks in other modules using hierarchical names is supported. However, they can only be accessed by using the module name, not the instance name.
module func_provider();
    function automatic logic [7:0] multiply_by_two(
        input logic [7:0] in_val
    );
        return in_val << 1;
    endfunction
endmodule

module function_access (
    input logic [7:0] input_val,
    output logic [7:0] result
);

    func_provider u_func_provider();

    always_comb begin
        result = func_provider.multiply_by_two(input_val); // Supported
        // result = u_func_provider.multiply_by_two(inpul_val); // Not Supported
    end

endmodule