Does UVM support printout of 2-dimensional arrays (of int in principle)?
I wanted to print it in the do_print method using an uvm_printer. However, I think it’s not possible to get a printout like:
1 2 3 4
5 6 7 8
9 8 7 6
and I can print it only manually ( using $display).
In reply to adrianf0:
Overwriting do_print allows you to print these data in any format, as 1 long row or 1 column or, or …
And in the UVM never and naver use $display. The UVM provides you with a powerful reporting mechanism. You should use this and not the simple $display.
To get the format you want to print you need 2 nested loops, 1 for the rows and 1 for the columns:
for (int i = 0; i < max_i; i++)
for (int j = 0; j < max_i; j++)
$sformatf(“some string %0d[%0d][%0d]”, x[i][j]);
In reply to chr_sue:
Thank you for your post.
At the end I solved it like that:
...
rand logic[7:0] Y[V_SIZE][H_SIZE];
...
virtual function void do_print(uvm_printer printer);
super.do_print(printer);
printer.print_array_header("Luminance", $size(Y,1)*$size(Y,2) );
for(int unsigned x = 0; x < $size(Y,1); x++) begin
string Y_string;
for(int unsigned y = 0; y < $size(Y,2); y++)
Y_string = {Y_string, $sformatf("%d ", Y[x][y])};
printer.print_generic($sformatf("Y[%0d][:]",x), "int", $size(Y,2), Y_string);
end
printer.print_array_footer($size(Y) );
endfunction // do_print