I have written a code to remove the dublicate elements in an array
module tb;
integer A[$];
initial
begin
A={5,5,5,2,2,2,2,2,2,123,321,567,765,5,5,5,5,5};
for(int i=0;i<=(A.size()-1);i=i+1)
begin
for(int j=i+1;j<=(A.size()-1);j=j+1)
begin
if(A[i]==A[j])
begin
A.delete(j);
end
end
$display(A[i]);
end
end
endmodule
The above code is not working.
If I replace the A.delete(j) with A.delete(j–) the code is woking fine. Can anyone please explain me in detail, why the code is not working with A.delete(j) and it is working with A.delete(j–).