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


Tutorials



OVM CONFIGURATION




Configuration is a mechanism in OVM 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 ovm_object based class respectively.


function void set_config_int (string inst_name,
string field_name,
ovm_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,
ovm_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 ovm component field macros and ovm component utilities macros.


(S)Ovm component utility macros:
For non parameterized classes
`ovm_component_utils_begin(TYPE)
`ovm_field_* macro invocations here
`ovm_component_utils_end
For parameterized classes.
`ovm_component_param_utils_begin(TYPE)
`ovm_field_* macro invocations here
`ovm_component_utils_end



For OVM Field macros, Refer to link
OVM_TRANSACTION

Example:
Following example is from link
OVM_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 ovm_driver;

integer int_cfg;
string str_cfg;

`ovm_component_utils_begin(driver)
`ovm_field_int(int_cfg, OVM_DEFAULT)
`ovm_field_string(str_cfg, OVM_DEFAULT)
`ovm_component_utils_end

function new(string name, ovm_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


ovm_configuration_1.tar
Browse the code in ovm_configuration_1.tar


(S)Command to run the simulation


your_tool_simulation_command +path_to_ovm_pkg -f filelist +OVM_TESTNAME=test1





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 ovm_object based class respectively.


function bit get_config_int (string field_name,
inout ovm_bitstream_t value)

function bit get_config_string (string field_name,
inout string value)

function bit get_config_object (string field_name,
inout ovm_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 ovm_driver;

integer int_cfg;
string str_cfg;

`ovm_component_utils(driver)

function new(string name, ovm_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));
ovm_report_info(get_full_name(),
$psprintf("int_cfg %0d : str_cfg %0s ",int_cfg,str_cfg),OVM_LOW);
endfunction

endclass
(S)Download the source code


ovm_configuration_2.tar
Browse the code in ovm_configuration_2.tar


(S)Command to run the simulation


your_tool_simulation_command +path_to_ovm_pkg -f filelist +OVM_TESTNAME=test1


(S)Log file

OVM_INFO @ 0: ovm_test_top.t_env
int_cfg x : str_cfg abcd
OVM_INFO @ 0: ovm_test_top.t_env.ag1
int_cfg x : str_cfg
OVM_INFO @ 0: ovm_test_top.t_env.ag1.drv
int_cfg 32 : str_cfg pars
OVM_INFO @ 0: ovm_test_top.t_env.ag1.mon
int_cfg 32 : str_cfg pars
OVM_INFO @ 0: ovm_test_top.t_env.ag2
int_cfg x : str_cfg
OVM_INFO @ 0: ovm_test_top.t_env.ag2.drv
int_cfg 32 : str_cfg pars
OVM_INFO @ 0: ovm_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 = "",
ovm_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


ovm_configuration_3.tar
Browse the code in ovm_configuration_3.tar


(S)Command to run the simulation


your_tool_simulation_command +path_to_ovm_pkg -f filelist +OVM_TESTNAME=test1



(S)Log file
When print_config_settings method is called

ovm_test_top.t_env.ag1.drv
ovm_test_top.*.ag1.* int_cfg int 32
ovm_test_top.t_env.ag1.drv.rsp_port
ovm_test_top.*.ag?.* str_cfg string pars
ovm_test_top.t_env.ag1.drv.rsp_port
ovm_test_top.*.ag1.* int_cfg int 32
ovm_test_top.t_env.ag1.drv.sqr_pull_port
ovm_test_top.*.ag?.* str_cfg string pars
ovm_test_top.t_env.ag1.drv.sqr_pull_port
ovm_test_top.*.ag1.* int_cfg int 32



When print_config_matches is set to 1.



OVM_INFO @ 0: ovm_test_top.t_env [auto-configuration]
Auto-configuration matches for component ovm_test_top.t_env (env).
Last entry for a given field takes precedence.

Config set from Instance Path Field name Type Value
------------------------------------------------------------------------------
ovm_test_top(test1) ovm_test_top.t_env str_cfg string abcd





Index
Introduction
Ovm Testbench
Ovm Reporting
Ovm Transaction
Ovm Factory
Ovm Sequence 1
Ovm Sequence 2
Ovm Sequence 3
Ovm Sequence 4
Ovm Sequence 5
Ovm Sequence 6
Ovm Configuration

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