I'm trying to generalize my virtual sequence for different kinds of good, corner and error scenarios. Hence I've declared a struct in my test and declared the fields that I want to exercise in that struct. Now, from the build_phase of my test I'm setting this struct and trying to get it in the body task of my virtual sequence(as shown in the below code).
The print after setting the struct to config_db is printing the values that I'm passing, but I'm ending up with the fatal error from my sequence saying that my_s not available in data base. I tried to parameterize config db with 'struct' and also 'struct my_struct' keyword but in vain.
Please let me know how can I get a struct successfully from config_db.
//-------- TEST CASE CODE-------//
class my_test extends test_base;
typedef struct {
bit [3:0] addr;
string msg;
int value;
} my_struct;
my_struct my_s;
virtual function void build_phase(uvm_phase phase);
super.build_phase(phase);
my_s.addr = 4'ha;
my_s.msg = "GOOD";
my_s.value = 1;
uvm_config_db #(my_struct)::set(null, "*", "my_s", my_s);
`uvm_info("build_phase", $sformatf("Set the struct in config db through build_phase of my_test and the struct looks as follows %p", my_s), UVM_LOW)
endfunction
endclass
//-------- SEQ CODE-------//
class my_vir_sequence extends virtual_seq_base;
typedef struct {
bit [3:0] addr;
string msg;
int value;
} my_struct;
my_struct test_ctrls;
virtual task body();
my_sequence_item seq_item;
super.body();
if(!uvm_config_db#(my_struct)::get(null, "*", "my_s", test_ctrls))
`uvm_fatal("body", "Coudln't get my_struct from config db")
`uvm_do_on_with(seq_item, p_sequencer, {
addr == test_ctrls.addr;
value == test_ctrls.value;
msg == test_ctrls.msg;
})
endtask
endclass
Below is the print I'm getting after 'set' of struct in the config_db
UVM_INFO ./tb/my_test.sv(83) @ 0.00 ps: uvm_test_top [build_phase] Set the struct in config db through build_phase of my_test and the struct looks as follows '{addr:'ha, msg:"GOOD", value:1}
Below is the fatal msg printing from my sequence:
UVM_FATAL ./env/my_sequence_collection.sv(358) @ 25029958.10 ps: uvm_test_top.env.test_env_seqr@ [body] Coudln't get my_struct from config db