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
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?
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…
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.
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 ?
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.