How can I set/ get a struct using uvm_config_db

In reply to sharvil111:

In reply to Shadow:
Here, there are two definitions of structure “my_struct. One definition is in the scope “my_vir_sequence::my_struct” and the other is in “my_test::my_struct”. The config db set is done for test structure type and get is done for sequence structure type. Eventhough the type names of test and sequence are same, they are in different scopes and treated differently. Henceforth the config db get is failing.
You can declare my_struct globally in your package and use it in both test and sequence.

package my_test_suite_pkg;
typedef struct {
bit [3:0] addr;
string msg;
int value;
} my_struct; // single definition of my_struct
`include "my_vir_sequence.sv" // definition of my_vir_sequence class
`include "my_test.sv"  // definition of my_test class
endpackage

Or you can declare it in a separate global package and import that package in your test suite.

package my_pkg;
typedef struct {
bit [3:0] addr;
string msg;
int value;
} my_struct;
endpackage
package my_test_suite_pkg;
import my_pkg::*;
`include "my_vir_sequence.sv" // definition of my_vir_sequence class
`include "my_test.sv"  // dtion of my_test class
endpackage

Or if you don’t want to play with packages, one can use scope resolution wile getting the structure “my_test::my_struct”. But I would not prefer this option due to dependency issues.

// In sequence class:
my_test::my_struct test_ctrls;
if(!uvm_config_db#(my_test::my_struct)::get(null, "*", "my_s", test_ctrls))

Please refer to this post by Dave for more information about packages.

Thank You sharvil111.
As this requirement is solely for my test case, I would not go with package but would get my work done using scope resolution operator. But, if I rely on scope resolution operator, then actually I don’t need to use config_db in first place, and the whole purpose of posting this question is missed :P .