Doubt on "set_config_int"

Hello friends,
I have declared a varible in my environment like this:
bit checks =0; & registered in ovm factory
ovm_component_utils_begin(class name) ovm_field_int(checks, OVM_ALL_ON);
`ovm_component_utils_end
Now i trying to configure “checks =1” in my config file using
set_config_int(env,“checks”,1);
But here my problem is that “checks” is not taking the updated value i.e 1, eventhough i am changing the value from config file.
kindly let me know the reason for this problem.
Thanks in Advance

Regards
Raghavendra

Hi raghavendrap,

You need to get this configuration setting in your class, using get_config_int (“checks”, checks)

So for example,

module top;
import ovm_pkg::*;

class env extends ovm_env;
  bit checks=0;  
  function new(); super.new("env"); endfunction
  function void build();
    assert(get_config_int ("checks", checks));
  endfunction  
  function void check(); assert(checks==1);endfunction
endclass


  env e;

  initial
  begin
    e=new();
    set_config_int("env", "checks", 1);
    e.do_test;
  end
endmodule

Thank you Sir,
Now its working fine.
Doubt: if in my verification environment i have 50 to 100 configuring parameters & i need to configure these parameters values from their default values according to my write or read operations, what is the easiest way to do this?

Regards
Raghavendra

As far as i know, this is the only way to use the configuration facilty in OVM.

To make things easier, you can use wildcards in the path name (first arg in set_config_), and the field name (second arg in set_config_).

For example,

set_config_int("*", "checks", 1);

Sets any variable set by the checks field name to 1, i.e. any component that has a get_config_int(“checks”,…) will be true.

set_config_int("env.*", "checks", 1);

Sets any variable set by the checks field name to 1 starting from the env down the hierarchy of your testbench (all the instances inside env).

set_config_int("env.??_operation", "checks", 1);

Sets any variable set by the checks field name to 1 only in instances named env._operation. (this can be rd or wr for example).

All these examples apply also for the field name.

I hope this helps.

Bahaa

Hi Bosman,

Proceeding with your reply, I’m little bit ambiguous with the usage of get_config_int and set_config_int.
I’ve read the reference manual but still couldn’t able to get the proper and timely usage of get_config_* though many of my other environments have worked successfully without the usage of get_config_*.
It would be helpful for me if you can give me clear picture of these functions.

raja.

Hello raja,

The manual states that “set_config_* methods work in conjunction with the get_config_* methods”. Thus, you have to use both for the configuration mechanism to work properly.

Generally, you can call get_config_* anytime after set_config_* has been used. So for example, if you use set_config_* in the build phase of the environment class, you can call get_config_* in any of the env’s children in the build phase (since build is top down) or in any subsequent phase.

– Bahaa

Hi Raja,

If you use the field automation macros as shown in your original example, i.e.

`ovm_component_utils_begin(class name)
`ovm_field_int(checks, OVM_ALL_ON);
`ovm_component_utils_end

then your checks member will get configured automatically at the end of the build phase for the class. You DO NOT need to call get_config_* provided you have called set_config_* before the build phase for the class (build is called top down). Calling set_config_* from the initial block of the top level module should always work.

Regards,
Dave

Hi Dave
I think its not working what you have adviced.
I tried reversing the order of set_config_* and “super.build()” in both ways & found that in either ways we have to go for get_config_*.

Another Issue:
As per Bosman we are using get_config_* like this:
assert(get_config_int("checks ",checks ));
Here “assert” verifies whether the function is successful or not.
In this when i am overriding default value of “checks” in the config file, obviously this “assert” statement fails which in turn gives error during simulation time(Ofcourse this error is true for overriding). Now I want these errors to be suppressed i.e., not to display during simulation. Can anyone suggest me how to do this?
I tried using OVM_URM_SEVERITY to all combinations which was obsolete!

Please help me in this regards,
Thanks in advance,
Raghavendra

Hi raghavendrap,

The assert statement produces a simulation error if fails (not an OVM error) by default. You have two options if you are not interested in the return of the get_config_*:

1-

void'(get_config_int("checks ",checks ));

2-

assert (get_config_int("checks ",checks ))
else ovm_report_warning ("NO_CONFIG", "No config settings for field check");

In the second solution, if the assert fails, it will report an OVM warning, which can be suppressed using

set_report_id_action_hier("NO_CONFIG", OVM_NO_ACTION);

BTW, Dave is right. If you are using the field automation macros, you don’t need the get_config_*.

Regards
Bahaa

Hi Raghavendra,

You will not pick up the configured value if you are using the deprecated do_test task to run your simulation. If you use an ovm_test class to instantiate the environment and use run_test to start the simulation then the OVM phases will work correctly. e.g. here is a complete example using OVM 1.1:

`include "ovm_macros.svh"
package my_pkg;
  `ifdef INCA 
    `include "ovm.svh"
  `else
    import ovm_pkg::*;
  `endif

class env extends ovm_env;
   bit check = 0;

   function new(string name="", ovm_component parent=null);
      super.new(name,parent);
   endfunction : new

   function void build();
      super.build();
   endfunction: build

   function void end_of_elaboration();
      ovm_report_info("ENV",$psprintf("check=%0d",check));
   endfunction: end_of_elaboration

   task run();
      ovm_top.stop_request();
   endtask:run
   
   `ovm_component_utils_begin(env)
     `ovm_field_int(check,OVM_ALL_ON)
   `ovm_component_utils_end
endclass : env

class my_test extends ovm_test;
   function new(string name="", ovm_component parent=null);
      super.new(name,parent);
   endfunction : new
   env e;

   function void build();
      super.build();
      $cast(e,create_component("env","e"));
   endfunction: build
   `ovm_component_utils(my_test)
endclass: my_test
endpackage

module top();
  `ifndef INCA 
     import ovm_pkg::*;
  `endif
  import my_pkg::*;
   initial
     begin
        set_config_int("*","check",1);
        run_test("my_test");        
     end
endmodule: top

The simulation output (for Questa) is as follows:

# run -all 
# OVM_INFO @ 0 [RNTST] Running test my_test...
# OVM_INFO @ 0: ovm_test_top.e [ENV] check=1
# ** Note: $finish    : /apps/ovm/src/base/ovm_root.svh(304)
#    Time: 0 ns  Iteration: 26  Instance: /ovm_pkg::ovm_root::run_test

Regards,
Dave

Dave,

I tried using the deprecated do_test and it works well. Here is the code

module top;
`include "ovm.svh"

class a extends ovm_component;
 bit checks=0;
  `ovm_component_utils_begin(a)
    `ovm_field_int(checks, OVM_ALL_ON)
  `ovm_component_utils_end
  
  function new(string name="comp", ovm_component parent=null);
    super.new(name, parent);
  endfunction
  function void end_of_elaboration(); 
    ovm_report_info("CHECK",$psprintf("checks=%0d",checks));
  endfunction
endclass

class env extends ovm_env;
 a mya;
  function new(string name="env", ovm_component parent=null);
    super.new(name, parent);
    mya=new("comp", this);
  endfunction
  function void build();
    super.build();
    set_config_int("comp", "checks", 1);
  endfunction
endclass


  env e;

  initial
  begin
    e=new();
    e.do_test;
  end
endmodule

Here is the output:

# ----------------------------------------------------------------
# OVM-1.1
# (C) 2007-2008 Mentor Graphics Corporation
# (C) 2007-2008 Cadence Design Systems, Inc.
# ----------------------------------------------------------------
# OVM_INFO @ 0: env.comp [Check] checks=1
# 
# --- OVM Report Summary ---
# 
# ** Report counts by severity
# OVM_INFO :    1
# OVM_WARNING :    0
# OVM_ERROR :    0
# OVM_FATAL :    0
# ** Report counts by id
# [CHECK               ]     1