Overriding or changing the existing configuration of VE components from testcases/sequences is something needed every now and then while working in system verilog based environment. Also in many circumstances we need to share some variables/flags between multiple components of env(ovm_env) not necessarily through the TLMs.
Some of the examples are like,
· Enabling/disabling specific streams of scoreboard.
· Enabling/disabling specific checkers after specific sequences are executed.
· Informing driver/sequencer to inject error into some Nth packet etc...
Let’s see and understand how this could be achieved in OVM based system-verilog environment. OVM’s configuration table and its methods provide easy way to achieve this.
Let’s assume that one needs to disable the specific stream of scoreboard using OVM’s configuration table from testcases.
Step 1: Define a configuration class containing all the parameters/configuration fields which need to be changed run-time,
class xyz_config extends ovm_object;
bit sb_stream_disable;
`ovm_object_utils_begin(xyz_config)
`ovm_field_int(sb_stream_disable, OVM_ALL_ON)
`ovm_object_utils_end
//Constructor
….
endclass : xyz_config
Based on the complexity of the environment you can also create multiple configuration classes to configure specific agents or specific set of components.
Step 2: Use the configuration class in scoreboard to disable the applicable data-stream.
class xyz_scoreboard extends ovm_scoreboard;
xyz_config cfg;
`ovm_component_utils_begin(xyz_scoreboard)
`ovm_object_utils(cfg, OVM_ALL_ON)
`ovm_component_utils_end
//Constructor
//Run thread
task run();
//Use the cfg.disable_sb_stream to disable the scoreboard data stream
....
endtask : run
endclass : xyz_scoreboard
As it is specified here, `ovm_object_utils is must here. It 'gets' the configuration instance from the OVM’s configuration table for ‘this` class.
Step 3: From the OVM based testcases disable the scoreboard at required point of time in the simulation.
class test extends ovm_test;
xyz_cfg cfg = new();
function void build();
super.build();
//Sharing the config. instance at target path.
set_config_obect(“env.scoreboard”,”cfg”,cfg,,0);
endfunction : build
task run();
//Some test code
//After some time disable the scoreboard stream
cfg.disable_sb_stream = 1;
//Other code
endtask : run
endclass : test
As you can see, one needs to ‘new’ the config. instance and share it with required classes using set_config_object method of ovm. The usage of set_config_object function with proper arguments is one of the crucial point here.
Let’s understand what arguments should be passed to this function,
1st argument is a string which specifies the target path where configuration needs to be shared. One could also use wildcard expressions here as env.*
2nd argument specifies the string-instance name of the object.
3rd argument is the object handle.
4th argument specifies whether object needs to be cloned before passing it to targeted component. For run-time passing set it to 0. This means all the components in env. which attempt to get the "cfg" from configuration table will use the same object throughout the simulation.
In cases where you have only few fields to share, you can also use OVM’sset_field_int and get_field_int methods.
The only additional step needed to pass the config. runtime is to call theapply_config_settings() method on the targeted component, as explained inthis thread under OVM forum.
Enjoy Configuring!!
No comments:
Post a Comment
Please provide valuable comments and suggestions for our motivation. Feel free to write down any query if you have regarding this post.