Making a configuration object available throughout the testbench hierarchy

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:

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?

environment_config   env_cfg;

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

In reply to Ashith:

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?

In reply to owenjarvie:

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

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

In reply to Ashith:

Ashith,

The code is compiling now, thanks for your time.

Owen

In reply to owenjarvie:

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

In reply to muralikrishna229:

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.

In reply to dave_59:

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

In reply to muralikrishna229:

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.

In reply to dave_59:

Thanks a lot Dave.

Thanks,
-Murali