SystemVerilog generate label as signal name

Dear Forum,

I saw this syntax in some open source coding :

    generate
       for (i=0;i<`N ;i=i+1) begin:gen_label
          wire p ;
	      ...
       end
    endgenerate
    assign sig = gen_label[0].p; // use of 'gen_label' as signal here

I am wondering if this is correct and what it means exactly ?

Many Thanks
Jamal

A named begin/end block creates a hierarchical scope. In the case of a generated for-loop an iteration index gets appended to the scope name.

1 Like