Configuration is a mechanism in UVM that higher level components in a hierarchy can configure the lower level components variables. Using set_config_* methods, user can configure integer, string and objects of lower level components. Without this mechanism, user should access the lower level component using hierarchy paths, which restricts reusability. This mechanism can be used only with components. Sequences and transactions cannot be configured using this mechanism. When set_config_* method is called, the data is stored w.r.t strings in a table. There is also a global configuration table.
Higher level component can set the configuration data in level component table. It is the responsibility of the lower level component to get the data from the component table and update the appropriate table.
Following are the method to configure integer , string and object of uvm_object based class respectively.
string inst_name: Hierarchical string path.
string field_name: Name of the field in the table.
bitstream_t value: In set_config_int, a integral value that can be anything from 1 bit to 4096 bits.
bit clone : If this bit is set then object is cloned.
inst_name and field_name are strings of hierarchal path. They can include wile card "*" and "?" characters. These methods must be called in build phase of the component.
"*" matches zero or more characters
"?" matches exactly one character
"*" -All the lower level components.
"*abc" -All the lower level components which ends with "abc".
Example: "xabc","xyabc","xyzabc" ....
"abc*" -All the lower level components which starts with "abc".
Example: "abcx","abcxy","abcxyz" ....
"ab?" -All the lower level components which start with "ab" , then followed by one more character.
Example: "abc","abb","abx" ....
"?bc" -All the lower level components which start with any one character ,then followed by "c".
Example: "abc","xbc","bbc" ....
"a?c" -All the lower level components which start with "a" , then followed by one more character and then followed by "c".
Example: "abc","aac","axc" â~@¦..
There are two ways to get the configuration data:
1)Automatic : Using Field macros
2)Manual : using gte_config_* methods.
To use the atomic configuration, all the configurable fields should be defined using uvm component field macros and uvm component utilities macros.
(S)uvm component utility macros: For non parameterized classes
`uvm_field_* macro invocations here
For parameterized classes.
`uvm_field_* macro invocations here
From the above log report of th example, we can see the variables int_cfg and str_cfg of all the components and they are as per the configuration setting from the testcase.
Using get_config_* methods, user can get the required data if the data is available in the table.
Following are the method to get configure data of type integer , string and object of uvm_object based class respectively.
If a entry is found in the table with "field_name" then data will be updated to "value" argument . If entry is not found, then the function returns "0". So when these methods are called, check the return value.
(S)Driver class code: class driver extends uvm_driver;
function new(string name, uvm_component parent);
UVM_INFO @ 0: uvm_test_top.t_env int_cfg x : str_cfg abcd UVM_INFO @ 0: uvm_test_top.t_env.ag1 int_cfg x : str_cfg UVM_INFO @ 0: uvm_test_top.t_env.ag1.drv int_cfg 32 : str_cfg pars UVM_INFO @ 0: uvm_test_top.t_env.ag1.mon int_cfg 32 : str_cfg pars UVM_INFO @ 0: uvm_test_top.t_env.ag2 int_cfg x : str_cfg UVM_INFO @ 0: uvm_test_top.t_env.ag2.drv int_cfg 32 : str_cfg pars UVM_INFO @ 0: uvm_test_top.t_env.ag2.mon int_cfg 32 : str_cfg pars
Configuration Setting Members:
(S)print_config_settings functionvoid print_config_settings
( string field = "",
uvm_component comp = null,
bit recurse = 0 )
This method prints all configuration information for this component.
If "field" is specified and non-empty, then only configuration settings matching that field, if any, are printed. The field may not contain wildcards. If "recurse" is set, then information for all children components are printed recursively.
(S)Log file When print_config_settings method is called
uvm_test_top.t_env.ag1.drv uvm_test_top.*.ag1.* int_cfg int 32 uvm_test_top.t_env.ag1.drv.rsp_port uvm_test_top.*.ag?.* str_cfg string pars uvm_test_top.t_env.ag1.drv.rsp_port uvm_test_top.*.ag1.* int_cfg int 32 uvm_test_top.t_env.ag1.drv.sqr_pull_port uvm_test_top.*.ag?.* str_cfg string pars uvm_test_top.t_env.ag1.drv.sqr_pull_port uvm_test_top.*.ag1.* int_cfg int 32
When print_config_matches is set to 1.
UVM_INFO @ 0: uvm_test_top.t_env [auto-configuration] Auto-configuration matches for component uvm_test_top.t_env (env). Last entry for a given field takes precedence.
Config set from Instance Path Field name Type Value ------------------------------------------------------------------------------ uvm_test_top(test1) uvm_test_top.t_env str_cfg string abcd