|HOME |ABOUT |ARTICLES |ACK |FEEDBACK |TOC |LINKS |BLOG |JOBS |


Tutorials



UVM CONFIGURATION




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.



Set_config_* Methods:



Following are the method to configure integer , string and object of uvm_object based class respectively.


function void set_config_int (string inst_name,
string field_name,
uvm_bitstream_t value)

function void set_config_string (string inst_name,
string field_name,
string value)

function void set_config_object (string inst_name,
string field_name,
uvm_object value, bit clone = 1)


(S)Arguments description:


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




(S)Some examples:


"*" -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.



Automatic Configuration:



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_component_utils_begin(TYPE)
`uvm_field_* macro invocations here
`uvm_component_utils_end
For parameterized classes.
`uvm_component_param_utils_begin(TYPE)
`uvm_field_* macro invocations here
`uvm_component_utils_end



For UVM Field macros, Refer to link
UVM_TRANSACTION

Example:
Following example is from link
UVM_TESTBENCH

2 Configurable fields, a integer and a string are defined in env, agent, monitor and driver classes. Topology of the environment using these classes is




(S)Driver class Source Code:


Similar to driver class, all other components env, agent and monitor are define.


class driver extends uvm_driver;

integer int_cfg;
string str_cfg;

`uvm_component_utils_begin(driver)
`uvm_field_int(int_cfg, UVM_DEFAULT)
`uvm_field_string(str_cfg, UVM_DEFAULT)
`uvm_component_utils_end

function new(string name, uvm_component parent);
super.new(name, parent);
endfunction

function void build();
super.build();
endfunction

endclass

(S)Testcase:


Using set_config_int() and set_config_string() configure variables at various hierarchal locations.


//t_env.ag1.drv.int_cfg
//t_env.ag1.mon.int_cfg
set_config_int("*.ag1.*","int_cfg",32);

//t_env.ag2.drv
set_config_int("t_env.ag2.drv","int_cfg",32);

//t_env.ag2.mon
set_config_int("t_env.ag2.mon","int_cfg",32);

//t_env.ag1.mon.str_cfg
//t_env.ag2.mon.str_cfg
//t_env.ag1.drv.str_cfg
//t_env.ag2.drv.str_cfg
set_config_string("*.ag?.*","str_cfg","pars");

//t_env.str_cfg
set_config_string("t_env","str_cfg","abcd");

(S)Download the source code


uvm_configuration_1.tar
Browse the code in uvm_configuration_1.tar


(S)Command to run the simulation


VCS Users : make vcs
Questa Users: make questa





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.



Manual Configurations:



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.


function bit get_config_int (string field_name,
inout uvm_bitstream_t value)

function bit get_config_string (string field_name,
inout string value)

function bit get_config_object (string field_name,
inout uvm_object value,
input bit clone = 1)



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.


Example:
(S)Driver class code:
class driver extends uvm_driver;

integer int_cfg;
string str_cfg;

`uvm_component_utils(driver)

function new(string name, uvm_component parent);
super.new(name, parent);
endfunction

function void build();
super.build();
void'(get_config_int("int_cfg",int_cfg));
void'(get_config_string("str_cfg",str_cfg));
uvm_report_info(get_full_name(),
$psprintf("int_cfg %0d : str_cfg %0s ",int_cfg,str_cfg),UVM_LOW);
endfunction

endclass
(S)Download the source code


uvm_configuration_2.tar
Browse the code in uvm_configuration_2.tar


(S)Command to run the simulation


VCS Users : make vcs
Questa Users: make questa


(S)Log file

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
function void 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)print_config_matches
static bit print_config_matches = 0


Setting this static variable causes get_config_* to print info about matching configuration settings as they are being applied. These two members will be helpful to know while debugging.



(S)Download the source code


uvm_configuration_3.tar
Browse the code in uvm_configuration_3.tar


(S)Command to run the simulation


VCS Users : make vcs
Questa Users: make questa



(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




Index
Introduction
Uvm Testbench
Uvm Reporting
Uvm Transaction
Uvm Configuration
Uvm Factory
Uvm Sequence 1
Uvm Sequence 2
Uvm Sequence 3
Uvm Sequence 4
Uvm Sequence 5
Uvm Sequence 6
Uvm Tlm 1
Uvm Tlm 2
Uvm Callback

Report a Bug or Comment on This section - Your input is what keeps Testbench.in improving with time!





<< PREVIOUS PAGE

TOP

NEXT PAGE >>

copyright © 2007-2017 :: all rights reserved www.testbench.in::Disclaimer