2

My question is about how to use predefined array element in hierarchical path in Verilog (SystemVerilog).

So for example I have defined the following string array:

string my_modules [0:1] = {"my_module_0","my_module_1"};

After, in my code I try to use them in some hierarchy:

generate
for (genvar i = 0; i < 2; i++) begin: BLOCK
    wire a = top_module.my_modules[i].a;
end
endgenerate

But I'm getting simulation error, because it cannot find the hierarchy as it is looking for my_modules module instead of its defined value (i.e my_module_0 and my_module_1).

Can someone advise on this ?

Thanks.

1
  • 5
    You cannot use strings to form variable pathnames in SystemVerilog. If you could show more of what you are trying to accomplish, we might able to suggest an alternative. Commented Aug 25, 2014 at 17:10

1 Answer 1

2

I tried with NCVerilog and the result is ok with small modification.

generate
for (genvar i = 0; i < 2; i++) begin: BLOCK
    wire a = top_module.my_modules[i][0];
end
endgenerate
  1. There is no my_modules[i].a. How could a string type has a sub-field a?
  2. I append [0] to my_modules[i] because my_modules[i] is a string type.
Sign up to request clarification or add additional context in comments.

2 Comments

This compiles at least in cadence xcelium too... thanks
Actually in elaboration there's a hierarchical lookup failure with this code unfortunately...

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.