I am new to Verilog.
How can I randomize the following:
bit [7:0] data [];
*Without use randomize() of systemVerilog.
SystemVerilog will not change the size of a dynamic array unless you put a constraint on it. So you either need to allocate the array before calling randomize(), or use a constraint to randomize the size.
bit [7:0] data [];
data = new[10];
randomize(data);
or
bit [7:0] data [];
randomize(data) with {data.size inside {[5:15]} ;};
or if you do not have access to the randomize() SystemVerilog, you can do
data = new[10];
foreach(data[ii]) data[ii] = $urandom;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With