# How to pass a variable value from env class to transaction class without using config\_db?

**URL:** <https://verificationacademy.com/forums/t/how-to-pass-a-variable-value-from-env-class-to-transaction-class-without-using-config-db/34431>\
**Category:** UVM\
**Tags:** UVM, p\_sequencer, config\_db\
**Created:** [May 7, 2018, 6:32am UTC](https://verificationacademy.com/forums/t/how-to-pass-a-variable-value-from-env-class-to-transaction-class-without-using-config-db/34431 "2018-05-07T06:32:15Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![pankaj12saha](https://verificationacademy.com/forums/letter_avatar_proxy/v4/letter/p/ba9def/32.png) [@pankaj12saha](https://verificationacademy.com/forums/u/pankaj12saha)\
**Post date:** [May 7, 2018, 6:32am UTC](https://verificationacademy.com/forums/t/how-to-pass-a-variable-value-from-env-class-to-transaction-class-without-using-config-db/34431/1 "2018-05-07T06:32:15Z")

</div>

Hi Folks,  
Actually I am trying to pass a variable value from environment class to my transaction class. Please suggest any method to pass value of a variable from my component hierarchy classes to my transaction class except the config\_db method.

---

<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:** [May 7, 2018, 7:11am UTC](https://verificationacademy.com/forums/t/how-to-pass-a-variable-value-from-env-class-to-transaction-class-without-using-config-db/34431/2 "2018-05-07T07:11:09Z")

</div>

_In reply to [pankaj12saha](https://verificationacademy.com/forums/t/how-to-pass-a-variable-value-from-env-class-to-transaction-class-without-using-config-db/34431):_

If you do not waht to use the config\_db you can use parameters, parameterized classes and packages.  
The question is why you do not want to use the config\_db, because it is the most elegant way.

---

<div class="post-metadata">

**Author:** ![mayurkubavat](https://verificationacademy.com/forums/letter_avatar_proxy/v4/letter/m/a9a28c/32.png) [@mayurkubavat](https://verificationacademy.com/forums/u/mayurkubavat)\
**Post date:** [May 7, 2018, 9:34am UTC](https://verificationacademy.com/forums/t/how-to-pass-a-variable-value-from-env-class-to-transaction-class-without-using-config-db/34431/3 "2018-05-07T09:34:36Z")

</div>

_In reply to [pankaj12saha](https://verificationacademy.com/forums/t/how-to-pass-a-variable-value-from-env-class-to-transaction-class-without-using-config-db/34431/2):_

I don’t think you can communicate runtime information with help of parameters.

You can use find() method available in uvm\_root class. Use this method in transaction class to find instance of Env and access Env properties from there.

```verilog

// Declare Env class handle in Transaction class
..
  uvm_component_h = uvm_top.find("*.env_h");

  if($cast(env_h, uvm_component_h))
  ..

```

---

<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:** [May 7, 2018, 2:22pm UTC](https://verificationacademy.com/forums/t/how-to-pass-a-variable-value-from-env-class-to-transaction-class-without-using-config-db/34431/4 "2018-05-07T14:22:41Z")

</div>

_In reply to [MayurKubavat](https://verificationacademy.com/forums/t/how-to-pass-a-variable-value-from-env-class-to-transaction-class-without-using-config-db/34431/3):_

It would really help to know why you have the requirement not to use the config\_db — is this an interview question? It’s best not to have handles to components in our downstream classes. This creates circular dependencies.

The ideal solution is using the config\_db in your sequence, then pass the value of the variable you want from your env to your sequence item by assigning it directly after creating the sequence\_item.

---

<div class="post-metadata">

**Author:** ![manasa-n](https://verificationacademy.com/forums/letter_avatar_proxy/v4/letter/m/4bbf92/32.png) [@manasa-n](https://verificationacademy.com/forums/u/manasa-n)\
**Post date:** [May 9, 2018, 6:44am UTC](https://verificationacademy.com/forums/t/how-to-pass-a-variable-value-from-env-class-to-transaction-class-without-using-config-db/34431/5 "2018-05-09T06:44:08Z")

</div>

Im not sure why you need to do this, but i think you can do  
val= $root.testbench.env.variable  
val is transaction class local variable

---

<div class="post-metadata">

**Author:** ![pankaj12saha](https://verificationacademy.com/forums/letter_avatar_proxy/v4/letter/p/ba9def/32.png) [@pankaj12saha](https://verificationacademy.com/forums/u/pankaj12saha)\
**Post date:** [May 10, 2018, 9:07am UTC](https://verificationacademy.com/forums/t/how-to-pass-a-variable-value-from-env-class-to-transaction-class-without-using-config-db/34431/6 "2018-05-10T09:07:02Z")

</div>

_In reply to [dave\_59](https://verificationacademy.com/forums/t/how-to-pass-a-variable-value-from-env-class-to-transaction-class-without-using-config-db/34431/5):_

Thanks u Dave for answering my question. Actually I tried the config\_db and I am able to get the value to transaction class. The main problem which I am facing is, While making multiple instances of transaction class ,I am not getting the value of variable, that is why I asked that above mentioned question.  
I got to know one more method by using parameter and `define concept this concept is working fine.  
And once again to thank everyone for suggestion of my query.
