I would like to push 1,2,3 …1000 values into a queue. Or assign the same to a dynamic/ static array. I am unable to find a good example. Is the below correct ?
I dont want to use any loop statement
I am fine if there is any UVM wrapper support also for the same
int a_q[$] = '{[1:1000]};
int a_d[] = new(1000);
a_d = '{[1:1000]}
int a_s[1000] = '{[1:1000]};
or a_s[1000] = '{1:1000};
The IEEE 1800-2023 SystemVerilog LRM introduced an array map function that accomplishes this task. Some tools already support this functionality.
int a[100]; // or a[] = new[100];
a = a.map() with (item.index+1);
If that’s not possible, you’ll need to create a function that returns an unpacked array containing the specified range.
typedef int unpacked_int[];
function unpacked range(int start,end);
range = new[end-start+1];
for(int i=start;i<=end;i++) range[i-start] = i;
endfunction
int a_q[$] = range(1,1000);