# Making a configuration object available throughout the testbench hierarchy

**URL:** <https://verificationacademy.com/forums/t/making-a-configuration-object-available-throughout-the-testbench-hierarchy/30949>\
**Category:** UVM\
**Tags:** UVM-Configuration-database, UVM\
**Created:** [August 14, 2015, 8:24am UTC](https://verificationacademy.com/forums/t/making-a-configuration-object-available-throughout-the-testbench-hierarchy/30949 "2015-08-14T08:24:41Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![owenjarvie](https://verificationacademy.com/forums/letter_avatar_proxy/v4/letter/o/7ab992/32.png) [@owenjarvie](https://verificationacademy.com/forums/u/owenjarvie)\
**Post date:** [August 14, 2015, 8:24am UTC](https://verificationacademy.com/forums/t/making-a-configuration-object-available-throughout-the-testbench-hierarchy/30949/1 "2015-08-14T08:24:41Z")

</div>

Hi all,

I am trying to set a configuration object in the configuration database in the build phase of the environment using the code section shown below:

```verilog
environment_config env_cfg

function void build_phase (uvm_phase phase);
   super.build_phase (phase);
   env_cfg = environment_config::type_id::create("env_cfg", this);
   if (!uvm_config_db#(environment_config)::set(this, "*", "env_cfg", env_cfg)) begin
        `uvm_error ("CFG_ERR", "Couldn't set in DB")
   end

```

I receive the following compilation error when I try to run using Incisiv:

Expecting a function name [10.3.3(IEEE)].  
(`include file: /projects/iptet/members/ojarvie/work.main/digital/dai\_top/verif/uvc/dai\_uvc/sv/dai\_pkg.sv line 26, file: dai\_top.sv line 2)  
package worklib.dai\_pkg:sv

Could anybody be of assistance with this matter?

---

<div class="post-metadata">

**Author:** ![Ashith](https://verificationacademy.com/forums/user_avatar/verificationacademy.com/ashith/32/2071_2.png) [@Ashith](https://verificationacademy.com/forums/u/Ashith)\
**Post date:** [August 14, 2015, 8:40am UTC](https://verificationacademy.com/forums/t/making-a-configuration-object-available-throughout-the-testbench-hierarchy/30949/2 "2015-08-14T08:40:45Z")

</div>

```verilog
environment_config env_cfg;

```

You have missed semicolon at the end of above line.  
-Ashith

---

<div class="post-metadata">

**Author:** ![owenjarvie](https://verificationacademy.com/forums/letter_avatar_proxy/v4/letter/o/7ab992/32.png) [@owenjarvie](https://verificationacademy.com/forums/u/owenjarvie)\
**Post date:** [August 14, 2015, 8:56am UTC](https://verificationacademy.com/forums/t/making-a-configuration-object-available-throughout-the-testbench-hierarchy/30949/3 "2015-08-14T08:56:20Z")

</div>

_In reply to [Ashith](https://verificationacademy.com/forums/t/making-a-configuration-object-available-throughout-the-testbench-hierarchy/30949/2):_

Sorry, I must’ve deleted that semicolon when I copied it across. That is not the issue as that semicolon is in my code when I run the simulation. Can you think of anything else?

---

<div class="post-metadata">

**Author:** ![owenjarvie](https://verificationacademy.com/forums/letter_avatar_proxy/v4/letter/o/7ab992/32.png) [@owenjarvie](https://verificationacademy.com/forums/u/owenjarvie)\
**Post date:** [August 14, 2015, 9:00am UTC](https://verificationacademy.com/forums/t/making-a-configuration-object-available-throughout-the-testbench-hierarchy/30949/4 "2015-08-14T09:00:11Z")

</div>

_In reply to [owenjarvie](https://verificationacademy.com/forums/t/making-a-configuration-object-available-throughout-the-testbench-hierarchy/30949/3):_

I perhaps should have mentioned that the error "Expecting a function name [10.3.3(IEEE)] refers to the if statement line.

---

<div class="post-metadata">

**Author:** ![Ashith](https://verificationacademy.com/forums/user_avatar/verificationacademy.com/ashith/32/2071_2.png) [@Ashith](https://verificationacademy.com/forums/u/Ashith)\
**Post date:** [August 14, 2015, 9:15am UTC](https://verificationacademy.com/forums/t/making-a-configuration-object-available-throughout-the-testbench-hierarchy/30949/5 "2015-08-14T09:15:36Z")

</div>

I think it is complaining because uvm\_config\_db :: set function does not return any value, whether set was successful or not. So if you use inside a if statement will cause this failure.

Try removing the if statement and just keeping the set function. See if this works…

- Ashith

---

<div class="post-metadata">

**Author:** ![owenjarvie](https://verificationacademy.com/forums/letter_avatar_proxy/v4/letter/o/7ab992/32.png) [@owenjarvie](https://verificationacademy.com/forums/u/owenjarvie)\
**Post date:** [August 14, 2015, 9:34am UTC](https://verificationacademy.com/forums/t/making-a-configuration-object-available-throughout-the-testbench-hierarchy/30949/6 "2015-08-14T09:34:06Z")

</div>

_In reply to [Ashith](https://verificationacademy.com/forums/t/making-a-configuration-object-available-throughout-the-testbench-hierarchy/30949/5):_

Ashith,

The code is compiling now, thanks for your time.

Owen

---

<div class="post-metadata">

**Author:** ![muralikrishna229](https://verificationacademy.com/forums/letter_avatar_proxy/v4/letter/m/a587f6/32.png) [@muralikrishna229](https://verificationacademy.com/forums/u/muralikrishna229)\
**Post date:** [August 17, 2015, 9:57am UTC](https://verificationacademy.com/forums/t/making-a-configuration-object-available-throughout-the-testbench-hierarchy/30949/7 "2015-08-17T09:57:44Z")

</div>

_In reply to [owenjarvie](https://verificationacademy.com/forums/t/making-a-configuration-object-available-throughout-the-testbench-hierarchy/30949/6):_

Hi Ashith,

But the statement inside if should be either 1 or 0.If it sets it will give 1 else 0.I think removing the if is not so a proper solution.And i don’t see any issues in the code which he pasted.  
Owen: can you tell what the changes you made to the above code to make it work.

Thanks,  
-Murali

---

<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:** [August 17, 2015, 3:24pm UTC](https://verificationacademy.com/forums/t/making-a-configuration-object-available-throughout-the-testbench-hierarchy/30949/8 "2015-08-17T15:24:20Z")

</div>

_In reply to [muralikrishna229](https://verificationacademy.com/forums/t/making-a-configuration-object-available-throughout-the-testbench-hierarchy/30949/7):_

Removing the “if” statement seems to be the proper solution to me. There is no value returned by the set() method, so there is nothing to check.

---

<div class="post-metadata">

**Author:** ![muralikrishna229](https://verificationacademy.com/forums/letter_avatar_proxy/v4/letter/m/a587f6/32.png) [@muralikrishna229](https://verificationacademy.com/forums/u/muralikrishna229)\
**Post date:** [August 18, 2015, 9:36am UTC](https://verificationacademy.com/forums/t/making-a-configuration-object-available-throughout-the-testbench-hierarchy/30949/9 "2015-08-18T09:36:46Z")

</div>

_In reply to [dave\_59](https://verificationacademy.com/forums/t/making-a-configuration-object-available-throughout-the-testbench-hierarchy/30949/8):_

Hi Dave,

Agree with you.But the set has to return either “1 or 0”.Why it is not returning any value.  
Every time people are using “if” for the set and get and it became a common practice.And mostly no one is facing issues like this.In this why simulator is giving error ?

Thanks,  
-Murali

---

<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:** [August 18, 2015, 2:39pm UTC](https://verificationacademy.com/forums/t/making-a-configuration-object-available-throughout-the-testbench-hierarchy/30949/10 "2015-08-18T14:39:20Z")

</div>

_In reply to [muralikrishna229](https://verificationacademy.com/forums/t/making-a-configuration-object-available-throughout-the-testbench-hierarchy/30949/9):_

Look at the definition of uvm\_config\_db:: **set** (). The return type is void. Only uvm\_config\_db:: **get** (). has a return value to tell you if there was something retrieved.

---

<div class="post-metadata">

**Author:** ![muralikrishna229](https://verificationacademy.com/forums/letter_avatar_proxy/v4/letter/m/a587f6/32.png) [@muralikrishna229](https://verificationacademy.com/forums/u/muralikrishna229)\
**Post date:** [August 19, 2015, 6:01am UTC](https://verificationacademy.com/forums/t/making-a-configuration-object-available-throughout-the-testbench-hierarchy/30949/11 "2015-08-19T06:01:24Z")

</div>

_In reply to [dave\_59](https://verificationacademy.com/forums/t/making-a-configuration-object-available-throughout-the-testbench-hierarchy/30949/10):_

Thanks a lot Dave.

Thanks,  
-Murali
