Hi All,
When i am tried to use foreach loop to print each elements of packed array, it is printing from MSB position to 0th position, instead of printing from 0th position to MSB. It is confusing (since foreach loop iteration element(“i”) starts from 0 and iterate till n-1. But in below code it starts from n-1 & ends at 0).
Anyone could please tell us the reason behind this
module test;
bit[3:0] a;
initial begin
a=4'b1101;
foreach(a[i])
$display("i=%0d, a[%0d] = %0d",i,i,a[i]);
end
endmodule
Simulator Output :