In SystemVerilog, I have a dynamic array of ints. I need to modify this array so as to skip the first 2 elements. For backward compatibility, I cannot change the data type to a queue. (which would allow me to do pop_front). So I came up with this hacky code that copies the array at least twice. Is there a better way?
tmp_arr = new[dyn_arr.size() -2];
for(int i = 0; i < tmp_arr.size(); i++) begin
tmp_arr[i] = dyn_arr[i + 2]; // First Copy
end
dyn_arr = tmp_arr; // Second Copy
My test is also on edaplayground. https://www.edaplayground.com/x/2VPm