| |
Config是OVM验证组件中每个component都带有的一个“configuration items”,其主要作用是增加代码的可重用性。目前不知如何使用。
ovm_component类中含有two sets of methods for putting
configuration items into the database and for retrieving them later
import ovm_pkg::*;
//----------------------------------------------------------------------
// component
//
// A component that is configured. It receives its configuration
// information via calls to get_config_*.
//----------------------------------------------------------------------
class component extends ovm_component;
int t;
int i;
function new(string name, ovm_component parent);
super.new(name, parent);
t = 13; // default value
i = 91;
endfunction
function void build();
string msg;
if(!get_config_int("t", t)) begin
$sformat(msg, "no value for t found in config database, using default value of %0d", t);
ovm_report_warning("build", msg);
end
if(!get_config_int("i", i)) begin
$sformat(msg, "no value for i found in config database, using default value of %0d", i);
ovm_report_warning("build", msg);
end
endfunction
function void end_of_elaboration();
print_config_settings();
endfunction
endclass
//----------------------------------------------------------------------
// c
//----------------------------------------------------------------------
class c extends ovm_component;
component child1;
component child2;
function new(string name, ovm_component parent);
super.new(name, parent);
endfunction
function void build();
child1 = new("child1", this);
child2 = new("child2", this);
endfunction
endclass
//----------------------------------------------------------------------
// env
//----------------------------------------------------------------------
class env extends ovm_component;
c c1;
c c2;
function new(string name, ovm_component parent = null);
super.new(name, parent);
endfunction
function void build();
c1 = new("c1", this);
c2 = new("c2", this);
set_config_int("c2.*", "i", 42);
set_config_int("*", "t", 19);
endfunction
function void end_of_elaboration();
print_config_settings();
endfunction
task run;
global_stop_request();
endtask
endclass
//----------------------------------------------------------------------
// top
//----------------------------------------------------------------------
module top;
env e;
initial begin
e = new("env");
run_test();
end
endmodule
输出:
# ----------------------------------------------------------------
# OVM_INFO @ 0: reporter [RNTST] Running test ...
# OVM_WARNING @ 0: env.c1.child1 [build] no value for i found in config database, using default value of 91
# OVM_WARNING @ 0: env.c1.child2 [build] no value for i found in config database, using default value of 91
# Configuration settings for component env.c1.child1 (recurse = 0)
# Set to Set from Component match Field name Type Value
# -------------------------------------------------------------------------------
# env.c1.child1 env(<unknown>) env.* t int 19
# Configuration settings for component env.c1.child2 (recurse = 0)
# Set to Set from Component match Field name Type Value
# -------------------------------------------------------------------------------
# env.c1.child2 env(<unknown>) env.* t int 19
# Configuration settings for component env.c2.child1 (recurse = 0)
# Set to Set from Component match Field name Type Value
# -------------------------------------------------------------------------------
# env.c2.child1 env(<unknown>) env.* t int 19
# env.c2.child1 env(<unknown>) env.c2.* i int 42
# Configuration settings for component env.c2.child2 (recurse = 0)
# Set to Set from Component match Field name Type Value
# -------------------------------------------------------------------------------
# env.c2.child2 env(<unknown>) env.* t int 19
# env.c2.child2 env(<unknown>) env.c2.* i int 42
# env NONE
#
# --- OVM Report Summary ---
#
# ** Report counts by severity
# OVM_INFO : 1
# OVM_WARNING : 2
# OVM_ERROR : 0
# OVM_FATAL : 0
# ** Report counts by id
# [RNTST] 1
# [build] 2