e.g.
//declare a constant like this.
const uint8 NUM_1G_PORTS = 4;
//attempt to declare an array of objects
GMII_driver GMII_driver_port[0:NUM_1G_PORTS-1]; //line 175
Kaboom, Questa 6.6 chokes on it:
# ** Error: ../../top.sv(175): Range must be bounded by constant
expressions.
Bit frustrating. Been using SV for > 6 months now, using CRV, ABV,
abstract classes, virtual interfaces, mailboxes, queues, etc etc,.
Awesome. But I still can't get something as simple as this to work.
Of course the workaround is to just stick the constant value of 3 in
there. But I resent it deeply :(
(I suppose I could dynamically allocate...yes this is the best
workaround I have. But can I do it without having to use a dynamic
array, and call new?)
Cheers
Andrew
Andrew FPGA <andrew.n...@gmail.com> writes:
> //declare a constant like this.
> const uint8 NUM_1G_PORTS = 4;
>
> //attempt to declare an array of objects
> GMII_driver GMII_driver_port[0:NUM_1G_PORTS-1]; //line 175
>
> Kaboom, Questa 6.6 chokes on it:
> # ** Error: ../../top.sv(175): Range must be bounded by constant
> expressions.
Constant values are not fixed at elaboration time. The array
declaration needs a known value though.
> Any ideas on how I can do this?
Use a parameter. Or good old `define.
--
Marcus Harnisch
http://www.doulos.com/
Use a parameter, not a const variable. A const variable is not a
compile-time constant. It is just a variable that you can't change
after it is initialized. Its value is set at runtime, and not even at
the start in some cases. A parameter or localparam is a compile-time
constant, and is what is required here.