Hey, can you please write the code in the eda playground, so that i can look into it, also in the code that you have provided here, semicolon is missing after this “bit [15:0] a, size_a,c”
from the compilation error, it seems you need to give some constant value to lsb_index, you can try and check, also, it would be better if you provide more information related to the code, i can make sense of it then.
I believe that the compiler needs have a bit-wise width defined during compilation and default variable declarations are automatic that can be changed on the fly during the simulation. So, it’s the requirements for the compiler to have constant value while accessing the bit-width.
Even with static declaration of the lsb_index won’t work since the memory is not allocated until the object for the class gets created which happens during the simulation.
Apart from that, not related to the question,
other issues:
the width of the a is [15:0] where you are trying to get [19:0] is another issue in the code.
since rand is not used, all other variables except a won’t be randomizing and make the in-line constraint to generate 0s for all the variables.