bf is an item , create in factory
there is a dynamic array in bf which is called axcs
when I wanna access it
report # ** Fatal: (SIGSEGV) Bad handle or reference.
function my_transfer test(b_t data);
my_transfer bf[4];
for(int i=0;i<4;i++) begin
bf[i] = my_transfer::type_id::create($sformatf("bf[%0d]",i));
bf[i].axcs = new[128]; //dynamic array
for(int j=0;j<128;j++) begin
bf[i].axcs[j].a_data = 30'b0; //report # ** Fatal: (SIGSEGV) Bad handle or reference.
end
...
dave_59
November 19, 2021, 7:56pm
2
In reply to designer007 :
What type is axcs?
Either bf[i] or bf[i].axcs is null. You need to check which one is null.
In reply to dave_59 :
class my_transfer extends uvm_sequence_item;
rand c0_t axcs0[];
rand c1_t axcs[];
...
//----------------------
class c1_t extends uvm_sequence_item;
rand bit[29:0] a_data;
...
In reply to dave_59 :
bf[i].axcs is item , should also be create,
Thanks @dave_59 @chr_sue
bf[i] = my_transfer::type_id::create($sformatf("bf[%0d]",i));
bf[i].axcs = new[128]; //dynamic array
chr_sue
November 20, 2021, 1:53pm
5
In reply to designer007 :
Please find a code example which reflects your problem:
package my_pkg;
import uvm_pkg::*;
`include "uvm_macros.svh"
class c1_t extends uvm_sequence_item;
`uvm_object_utils(c1_t)
rand bit[29:0] a_data;
function new(string name = "");
super.new(name);
endfunction
endclass
class my_transfer extends uvm_sequence_item;
`uvm_object_utils(my_transfer)
rand c1_t axcs[];
function new(string name = "");
super.new(name);
axcs = new[128];
endfunction
endclass
endpackage
module top;
import uvm_pkg::*;
`include "uvm_macros.svh"
import my_pkg::*;
initial begin
my_transfer bf[4];
for(int i=0;i<4;i++) begin
bf[i] = my_transfer::type_id::create($sformatf("bf[%0d]",i));
for (int j = 0; j < 128; j++) begin
bf[i].axcs[j] = c1_t::type_id::create($sformatf("axcs[%0d]", j));
bf[i].axcs[j].a_data = j;
end
end
for(int i=0;i<4;i++) begin
for (int j = 0; j < 128; j++) begin
`uvm_info("TOP", $sformatf("bf[%0d].axcs[%0d].a_data = %0d", i, j, bf[i].axcs[j].a_data), UVM_MEDIUM)
end
end
end
endmodule