# How to access a DUT signal from a UVM test case class?

**URL:** <https://verificationacademy.com/forums/t/how-to-access-a-dut-signal-from-a-uvm-test-case-class/29099>\
**Category:** UVM\
**Tags:** UVM, reference, DUT, hierarchical\
**Created:** [January 22, 2014, 7:16pm UTC](https://verificationacademy.com/forums/t/how-to-access-a-dut-signal-from-a-uvm-test-case-class/29099 "2014-01-22T19:16:29Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![kaushalmodi](https://verificationacademy.com/forums/letter_avatar_proxy/v4/letter/k/6bbea6/32.png) [@kaushalmodi](https://verificationacademy.com/forums/u/kaushalmodi)\
**Post date:** [January 22, 2014, 7:16pm UTC](https://verificationacademy.com/forums/t/how-to-access-a-dut-signal-from-a-uvm-test-case-class/29099/1 "2014-01-22T19:16:29Z")

</div>

Hi,

I would like to access a DUT signal from within one of my UVM test cases.  
But when I try to do so, I get the Cadence ncvlog error E\*ILLHIN: illegal location for a hierarchical name (in a package).

This is the organization of the files for compilation.

PRJ\_pkg.sv:

```verilog

`include "uvm_macros.svh"
package PRJ_pkg;
   import uvm_pkg::*;
   import agt1_pkg::*;
   import agt2_pkg::*;
   import reg_model_pkg::*;
   import reg_seq_pkg::*; // Contains sequences derived from uvm_reg_sequence class

   `include "PRJ_env.sv"
   `include "PRJ_base_test.sv"
   `include "PRJ_TEST1.sv" // class PRJ_TEST1 extends PRJ_base_test;
endpackage

```

reg\_seq\_pkg.sv:

```verilog

`include "uvm_macros.svh"
package reg_seq_pkg;
   import uvm_pkg::*;
   `include "sample_reg_seq.sv"
endpackage   

```

top.sv:

```verilog

module top;
   import PRJ_pkg::*;

   // Interface declarations

   DUT u_dut (
       ...
     );

   // uvm_config_db # ( ) :: set statements for interface handle transfer to the agents
endmodule : top

```

PROBLEM:  
I can do hierarchical reference ( like “top.u\_dut.sig” ) from the body task of “sample\_reg\_seq.sv” which is a sequence derived from uvm\_reg\_sequence.  
BUT I can’t do the same from the main\_phase task of “PRJ\_TEST1.sv”; I get the above E\*ILLHIN compilation error,

I couldn’t figure out what I can add to PRJ\_TEST1.sv to make that hierarchical ref work.

---

<div class="post-metadata">

**Author:** ![tfitz](https://verificationacademy.com/forums/user_avatar/verificationacademy.com/tfitz/32/3025_2.png) [@tfitz](https://verificationacademy.com/forums/u/tfitz)\
**Post date:** [January 22, 2014, 7:25pm UTC](https://verificationacademy.com/forums/t/how-to-access-a-dut-signal-from-a-uvm-test-case-class/29099/2 "2014-01-22T19:25:40Z")

</div>

First of all, you should be using run\_phase() and not main\_phase().

Second of all, why would you possibly want to hard-code a hierarchical path to the DUT in your UVM? You are completely sacrificing the ability to reuse anything when you do that. Instead, you should create an interface that includes the signal(s) you want to access (the interface could include the hierarchical reference), and then you could pass that interface as a virtual interface via the config\_db to your test/env and access it that way.

Good luck,  
-Tom

---

<div class="post-metadata">

**Author:** ![kaushalmodi](https://verificationacademy.com/forums/letter_avatar_proxy/v4/letter/k/6bbea6/32.png) [@kaushalmodi](https://verificationacademy.com/forums/u/kaushalmodi)\
**Post date:** [January 22, 2014, 11:04pm UTC](https://verificationacademy.com/forums/t/how-to-access-a-dut-signal-from-a-uvm-test-case-class/29099/3 "2014-01-22T23:04:54Z")

</div>

_In reply to [tfitz](https://verificationacademy.com/forums/t/how-to-access-a-dut-signal-from-a-uvm-test-case-class/29099/2):_

Hi Tom,

Thanks! The technique to create a probing interface worked. But I am curious why the hierarchical reference worked in a uvm\_reg\_sequence based class but not a uvm\_test based class.

Also, why shouldn’t main\_phase be used? I am curious. What are the best scenarios for using run\_phase and main\_phase? Thanks.

---

<div class="post-metadata">

**Author:** ![Beeri](https://verificationacademy.com/forums/letter_avatar_proxy/v4/letter/b/ea5d25/32.png) [@Beeri](https://verificationacademy.com/forums/u/Beeri)\
**Post date:** [January 24, 2014, 4:23am UTC](https://verificationacademy.com/forums/t/how-to-access-a-dut-signal-from-a-uvm-test-case-class/29099/4 "2014-01-24T04:23:10Z")

</div>

Sometimes, in cases you are sure that reuse is irrelevant, one can use the $root.  
For example:  
if ($root.top.u\_dut.sig)  
`uvm\_error (“test”, "signal is active)

Though, I recommend not to use this method, and to stick to interface passing through config\_db.

Beeri

---

<div class="post-metadata">

**Author:** ![tomrohit](https://verificationacademy.com/forums/letter_avatar_proxy/v4/letter/t/e36b37/32.png) [@tomrohit](https://verificationacademy.com/forums/u/tomrohit)\
**Post date:** [July 18, 2014, 8:57am UTC](https://verificationacademy.com/forums/t/how-to-access-a-dut-signal-from-a-uvm-test-case-class/29099/5 "2014-07-18T08:57:13Z")

</div>

_In reply to [kaushalmodi](https://verificationacademy.com/forums/t/how-to-access-a-dut-signal-from-a-uvm-test-case-class/29099/4):_

Hi,

The virtual interface technique works fine when there is a need to monitor signals. But, if there is a need to drive signals buried deep into DUT, how can that be achieved using virtual interface?

My exact use case is, i am trying to do $readmemh on memory cells (behavioral memory model) which are instantiated in DUT.

---

<div class="post-metadata">

**Author:** ![Balu\_15](https://verificationacademy.com/forums/letter_avatar_proxy/v4/letter/b/85f322/32.png) [@Balu\_15](https://verificationacademy.com/forums/u/Balu_15)\
**Post date:** [September 2, 2014, 12:59pm UTC](https://verificationacademy.com/forums/t/how-to-access-a-dut-signal-from-a-uvm-test-case-class/29099/6 "2014-09-02T12:59:51Z")

</div>

_In reply to [Beeri](https://verificationacademy.com/forums/t/how-to-access-a-dut-signal-from-a-uvm-test-case-class/29099/5):_

Hi Beeri ,

Are you got the solution for Your Query?

please suggest me how can we access the top module signals in uvm test class .

Thanks  
kbkdec15

---

<div class="post-metadata">

**Author:** ![Vinay\_Jain](https://verificationacademy.com/forums/user_avatar/verificationacademy.com/vinay_jain/32/3037_2.png) [@Vinay\_Jain](https://verificationacademy.com/forums/u/Vinay_Jain)\
**Post date:** [September 2, 2014, 1:07pm UTC](https://verificationacademy.com/forums/t/how-to-access-a-dut-signal-from-a-uvm-test-case-class/29099/7 "2014-09-02T13:07:05Z")

</div>

_In reply to [kbkdec15](https://verificationacademy.com/forums/t/how-to-access-a-dut-signal-from-a-uvm-test-case-class/29099/6):_

The solution is already there. Please see above Tom’s solution.

---

<div class="post-metadata">

**Author:** ![jamesq2001](https://verificationacademy.com/forums/letter_avatar_proxy/v4/letter/j/8797f3/32.png) [@jamesq2001](https://verificationacademy.com/forums/u/jamesq2001)\
**Post date:** [April 1, 2015, 4:59pm UTC](https://verificationacademy.com/forums/t/how-to-access-a-dut-signal-from-a-uvm-test-case-class/29099/8 "2015-04-01T16:59:20Z")

</div>

_In reply to [tomrohit](https://verificationacademy.com/forums/t/how-to-access-a-dut-signal-from-a-uvm-test-case-class/29099/7):_

Hi Tom,

It would be a big advantage if we could sample internal RTL signals in the DUT especially from functional coverage perspective. Unfortunately UVM doesn’t seem have build-in support for directly accessing RTL signals, not like Specman does (in Specman, an RTL signal can be accessed using RTL path). There are situations we want to sample RTL signals on an RTL event or want to collect the cross coverage of the RTL signal values with a coverpoint.

Thanks,  
James

---

<div class="post-metadata">

**Author:** ![dave\_59](https://verificationacademy.com/forums/user_avatar/verificationacademy.com/dave_59/32/4499_2.png) [@dave\_59](https://verificationacademy.com/forums/u/dave_59)\
**Post date:** [April 2, 2015, 5:44am UTC](https://verificationacademy.com/forums/t/how-to-access-a-dut-signal-from-a-uvm-test-case-class/29099/9 "2015-04-02T05:44:40Z")

</div>

_In reply to [jamesq2001](https://verificationacademy.com/forums/t/how-to-access-a-dut-signal-from-a-uvm-test-case-class/29099/8):_

See my DVCon paper [The Missing Link: The Testbench to DUT Connection](https://verificationacademy.com/resources/technical-papers/the-missing-link-the-testbench-to-dut-connection)

---

<div class="post-metadata">

**Author:** ![Vinay\_Jain](https://verificationacademy.com/forums/user_avatar/verificationacademy.com/vinay_jain/32/3037_2.png) [@Vinay\_Jain](https://verificationacademy.com/forums/u/Vinay_Jain)\
**Post date:** [April 2, 2015, 6:15am UTC](https://verificationacademy.com/forums/t/how-to-access-a-dut-signal-from-a-uvm-test-case-class/29099/10 "2015-04-02T06:15:11Z")

</div>

_In reply to [dave\_59](https://verificationacademy.com/forums/t/how-to-access-a-dut-signal-from-a-uvm-test-case-class/29099/9):_

Also you can see a small article on [how to access the DUT memory from anywhere in TB.](http://v4verification.com/2015/03/accessing-dut-memory-from-anywhere-in-tb-with-help-of-abstract-class/)  
As @dave_59 suggested me, that we can also use the Interface class(better way actually) instead of abstract class. But this article give you a idea how things work.

---

<div class="post-metadata">

**Author:** ![jamesq2001](https://verificationacademy.com/forums/letter_avatar_proxy/v4/letter/j/8797f3/32.png) [@jamesq2001](https://verificationacademy.com/forums/u/jamesq2001)\
**Post date:** [April 2, 2015, 9:32pm UTC](https://verificationacademy.com/forums/t/how-to-access-a-dut-signal-from-a-uvm-test-case-class/29099/11 "2015-04-02T21:32:30Z")

</div>

_In reply to [Vinay Jain](https://verificationacademy.com/forums/t/how-to-access-a-dut-signal-from-a-uvm-test-case-class/29099/10):_

Thanks Dave and Vinay/Jain for the paper/article. It is good to know there are working workaround. I believe we can use module as well instead of interface to bind to RTL and to embed the probe class for sampling internal RTL signals.

---

<div class="post-metadata">

**Author:** ![MikeSocowave](https://verificationacademy.com/forums/letter_avatar_proxy/v4/letter/m/779978/32.png) [@MikeSocowave](https://verificationacademy.com/forums/u/MikeSocowave)\
**Post date:** [October 8, 2015, 12:51pm UTC](https://verificationacademy.com/forums/t/how-to-access-a-dut-signal-from-a-uvm-test-case-class/29099/12 "2015-10-08T12:51:35Z")

</div>

_In reply to [jamesq2001](https://verificationacademy.com/forums/t/how-to-access-a-dut-signal-from-a-uvm-test-case-class/29099/11):_

Hi,

Question regarding Dave\_59’s article. I’m trying to use something like this in a bigger UVM design. But I can’t see how the probe class can be used more than once. The uvm\_object is registered with an ID of "probe\_"PATH where PATH is a string to delimit different instances. But I can’t see how PATH gets set i.e. The $cast will fail because PATH isn’t set.

Newbie at UVM btw…

MikeS

---

<div class="post-metadata">

**Author:** ![MikeSocowave](https://verificationacademy.com/forums/letter_avatar_proxy/v4/letter/m/779978/32.png) [@MikeSocowave](https://verificationacademy.com/forums/u/MikeSocowave)\
**Post date:** [October 8, 2015, 1:47pm UTC](https://verificationacademy.com/forums/t/how-to-access-a-dut-signal-from-a-uvm-test-case-class/29099/13 "2015-10-08T13:47:56Z")

</div>

_In reply to [MikeSoco](https://verificationacademy.com/forums/t/how-to-access-a-dut-signal-from-a-uvm-test-case-class/29099/12):_

OK. %m - gives the path. Ignore!

---

<div class="post-metadata">

**Author:** ![MayaSasidharan](https://verificationacademy.com/forums/letter_avatar_proxy/v4/letter/m/c5a1d2/32.png) [@MayaSasidharan](https://verificationacademy.com/forums/u/MayaSasidharan)\
**Post date:** [March 22, 2016, 6:59am UTC](https://verificationacademy.com/forums/t/how-to-access-a-dut-signal-from-a-uvm-test-case-class/29099/14 "2016-03-22T06:59:01Z")

</div>

Hi,  
I am also facing a similar limitation wrt hierarchical path.  
i want to run a particular sequence till i get 100% coverage for a cross product.  
I thought of using the inbuilt function $get\_coverage of covergroup in the sequence to decide when to stop the simulation.  
But i cannot give the hierarchical path in the sequence. it gives me “illegal location for a hierarchical name” error.  
Going through different forums, i came to know that interface is the only component which can have hierarchical path in it.  
I would like to know if there is anyway other than using an interface to achieve this.

Thanks,  
Maya

---

<div class="post-metadata">

**Author:** ![dave\_59](https://verificationacademy.com/forums/user_avatar/verificationacademy.com/dave_59/32/4499_2.png) [@dave\_59](https://verificationacademy.com/forums/u/dave_59)\
**Post date:** [March 22, 2016, 6:59am UTC](https://verificationacademy.com/forums/t/how-to-access-a-dut-signal-from-a-uvm-test-case-class/29099/15 "2016-03-22T06:59:23Z")

</div>

_In reply to [Maya Sasidharan](https://verificationacademy.com/forums/t/how-to-access-a-dut-signal-from-a-uvm-test-case-class/29099/14):_

See my [link](https://verificationacademy.com/forums/uvm/how-access-dut-signal-uvm-test-case-class#reply-49334) above

---

<div class="post-metadata">

**Author:** ![chr\_sue](https://verificationacademy.com/forums/user_avatar/verificationacademy.com/chr_sue/32/1199_2.png) [@chr\_sue](https://verificationacademy.com/forums/u/chr_sue)\
**Post date:** [March 22, 2016, 8:45am UTC](https://verificationacademy.com/forums/t/how-to-access-a-dut-signal-from-a-uvm-test-case-class/29099/16 "2016-03-22T08:45:27Z")

</div>

_In reply to [Maya Sasidharan](https://verificationacademy.com/forums/t/how-to-access-a-dut-signal-from-a-uvm-test-case-class/29099/15):_

Where do you have your covergroups implemented? In the sequence?  
My practical experience shows this is not a good place having functional coverage there.  
Because a sequence is a transient object which will be generated at a certain time and disappears after completion. You should implement your covergroups and crosses in a UVM component. Thsi is stable at least for a certain test and belongs to the verification environment. From there you can call $get\_coverage easily.

---

<div class="post-metadata">

**Author:** ![MayaSasidharan](https://verificationacademy.com/forums/letter_avatar_proxy/v4/letter/m/c5a1d2/32.png) [@MayaSasidharan](https://verificationacademy.com/forums/u/MayaSasidharan)\
**Post date:** [March 22, 2016, 9:41am UTC](https://verificationacademy.com/forums/t/how-to-access-a-dut-signal-from-a-uvm-test-case-class/29099/17 "2016-03-22T09:41:57Z")

</div>

_In reply to [chr\_sue](https://verificationacademy.com/forums/t/how-to-access-a-dut-signal-from-a-uvm-test-case-class/29099/16):_

Hi chr\_sue,  
I have the cover group as a separate component in the environment. it gets the transactions from the uvm\_monitor.My apologies for not mentioning this in the question.  
i am trying to access uvm\_test\_top.envh.cgh from sequence.

Thanks,  
Maya

---

<div class="post-metadata">

**Author:** ![chr\_sue](https://verificationacademy.com/forums/user_avatar/verificationacademy.com/chr_sue/32/1199_2.png) [@chr\_sue](https://verificationacademy.com/forums/u/chr_sue)\
**Post date:** [March 22, 2016, 10:05am UTC](https://verificationacademy.com/forums/t/how-to-access-a-dut-signal-from-a-uvm-test-case-class/29099/18 "2016-03-22T10:05:41Z")

</div>

_In reply to [Maya Sasidharan](https://verificationacademy.com/forums/t/how-to-access-a-dut-signal-from-a-uvm-test-case-class/29099/17):_  
Hi Maya,

the sequence does not have a fixed place in your UVM environment. There is no hierarchical path to the UVM environment. You should call $get\_coverage from your env and stop the execution when the coverage goal is reached.

---

<div class="post-metadata">

**Author:** ![chr\_sue](https://verificationacademy.com/forums/user_avatar/verificationacademy.com/chr_sue/32/1199_2.png) [@chr\_sue](https://verificationacademy.com/forums/u/chr_sue)\
**Post date:** [March 23, 2016, 7:26am UTC](https://verificationacademy.com/forums/t/how-to-access-a-dut-signal-from-a-uvm-test-case-class/29099/19 "2016-03-23T07:26:43Z")

</div>

_In reply to [Maya Sasidharan](https://verificationacademy.com/forums/t/how-to-access-a-dut-signal-from-a-uvm-test-case-class/29099/18):_

Sounds good to me. Good luck for your further work.

---

<div class="post-metadata">

**Author:** ![MayaSasidharan](https://verificationacademy.com/forums/letter_avatar_proxy/v4/letter/m/c5a1d2/32.png) [@MayaSasidharan](https://verificationacademy.com/forums/u/MayaSasidharan)\
**Post date:** [March 23, 2016, 8:52am UTC](https://verificationacademy.com/forums/t/how-to-access-a-dut-signal-from-a-uvm-test-case-class/29099/20 "2016-03-23T08:52:12Z")

</div>

_In reply to [dave\_59](https://verificationacademy.com/forums/t/how-to-access-a-dut-signal-from-a-uvm-test-case-class/29099/19):_

Hi Dave  
I wanted to access a variable in a uvm\_component from uvm\_sequence and this is how i accomplished it.  
below is the background of my problem.  
I have a cover\_group as a separate component in the environment. it gets the transactions from the uvm\_monitor. Then i want to run the sequence till i get a particular coverage value say \>90%.

I derived a class coverage\_obj from uvm\_object and have a static variable coverage\_value in it.  
In cover\_group, i created a coverage\_obj and the static variable coverage\_value will be updated each time covergroup.sample() is called using get\_coverage function.

Then the sequence also have coverage\_obj instantiated.

Then in the sequence i check for the coverage\_value.since its a static variable,both uvm\_component and uvm\_sequence sees the same variable.  
This way i was able to access the variable in a uvm\_component from uvm\_sequence.

Thanks,  
Maya

[Next page](https://verificationacademy.com/forums/t/how-to-access-a-dut-signal-from-a-uvm-test-case-class/29099.md?page=2)
