I have created an environment with object handle env. I am trying to call a function in the env from the scoreboard through
uvm_top.uvm_test_top.env.print();
But i am getting compilation error saying that uvm_test_top is not an instance in uvm_root. can u please help me out how to achieve this.
“uvm_test_top” is the string instance name given to your test. You can’t use strings a hierarchical reference.
In order to call a method in your_env class from your_scoreboard, your_scoreboard will have to get a handle to your_env. This is not a very good idea as it ties your scoreboard to a particular env class if the method you want to call is not a virtual method in uvm_component. But here is how you could do it.
class your_scoreboard extends uvm_scoreboard;
typedef your_env; // forward reference to your_env declared later
task run_phase(uvm_phase phase);
your_env env;
...
if(!$cast(env,uvm_top.find("uvm_test_top.env")) `uvm_error("BADENV","env was not a your_env");
env.print();
...
endtask
endclass
The $cast may be needed because find() returns a uvm_component. I wasn’t sure if you really meant the virtual print() method of uvm_object, or something else. Because I can’t see a reason why you would want the scoreboard to call the print method of another component.