MikePopoloski / slang

SystemVerilog compiler and language services
MIT License
546 stars 114 forks source link

Array with size from body parameter is <error> #980

Closed pehnetom closed 1 week ago

pehnetom commented 2 weeks ago

Describe the bug When a array size is defined by body parameter, then elaborated symbol will have type <error>.

To Reproduce Following SV source code results in the bug:

interface test_interface();
    parameter int C_PARAM_PARAM = 42;
    logic [1:C_PARAM_PARAM] value_1;
    logic value_2;
    logic value_3;
    integer integer_4;
endinterface : test_interface

Value_1 symbol will have type <error>.

Additional context This maybe happens as a value of the parameter symbol is <unset> and the actual value is kept inside initializer. Problem detected with using pyslang==5.0.0 and pyslang==6.0

MikePopoloski commented 1 week ago

It sounds like you're inspecting an uninstantiated instance of the interface? slang will automatically create these to ensure that the body gets some checking even if the interface is unused in the design, but parameters are forced to invalid values since it's not a real instantiation and no param values were provided. You can see this in the API by looking at the isUninstantiated member of the instance body.

If you inspect an actual instance of that interface it should have the correct types.

MikePopoloski commented 1 week ago

Going to close this since there's been no response. Feel free to reopen if you have further questions.

pehnetom commented 1 week ago

Sorry for the late repsonse.

What you wrote is correct. I created a dummy top module to wrap uninstantiated modules/interface, which solved the problem for me. Thanks!