array must be of constant range error
What the error says: the size/width of the register, which comes from the expression after the -:, must be a constant.

You can not have variable width assignments. How do you want to do that in hardware?
You can use only part(s) of an existing register which means you have to start with a register big enough for the maximum size you think you will need.



If you tell a bit more about what you want to do and the limits we might come up with a solution. Often shift operations &lt;&lt; &gt;&gt; can get you a long way.