Hi,
How can I print an associative array which is of this form : The type of transaction that is stored in the array is an axiTransaction.
axiTrans wr_input_array[int][addr];
Thanks.
Hi,
How can I print an associative array which is of this form : The type of transaction that is stored in the array is an axiTransaction.
axiTrans wr_input_array[int][addr];
Thanks.
In reply to UVM_learner6:
Hi,
How can I print an associative array which is of this form : The type of transaction that is stored in the array is an axiTransaction.
axiTrans wr_input_array[int][addr];
Thanks.
There are multiple ways to do it.
//1
/*
If axiTrans class is extended from the uvm_object(or any child class of it) and field macros are used then use sprint to print it.
*/
class axi_tran extends uvm_object;
logic [31:0] data;
`uvm_object_utils_begin(axi_tran)
`uvm_field_int(data, UVM_DEFAULT)
`uvm_object_utils_end
function new(string name = "axi_tran");
super.new(name);
endfunction
//other methods
endclass : axi_tran
/* ..... other code ......... */
/* ..... other code ......... */
/* ..... other code ......... */
//print the transaction
//display master 0, addr = 2, transaction
$display(axi_tran_arr[0][addr].sprint());
//or use uvm_info
//`uvm_info("", $sformatf("%p",axi_tran_arr[0][addr].sprint()),UVM_LOW);
///OUTPUT:
------------------------------------
Name Type Size Value
------------------------------------
axi_tran axi_tran - @339
data integral 32 'h4a7a3d21
------------------------------------
//2
//create method to print the transaction
class axi_tran;
logic [31:0] data;
//create method to print the transaction, can give any name
function void display();
$display("---------------------");
$display("axi_tran");
$display("data : %h", data);
//.... add for other variable also
$display("---------------------");
endfunction
endclass : axi_tran
/* ..... other code ......... */
/* ..... other code ......... */
/* ..... other code ......... */
//print the transaction
//display master 0, addr = 2, transaction
axi_tran_arr[0][2].display();
///OUTPUT:
---------------------
axi_tran
data : 4a7a3d21
---------------------