为了在不同的用例里面使用不同的时钟或者复位参数,可以在测试用例里面使用config_db::set,而在tb_top里面使用config_db::get。但是,测试用例和tb_top都是在0时刻执行。所以,需要在config_db::get前加入时间延时。
以时钟参数为例,tb_top可以如下所示实现:
initial begin
static real clk_half_period = 10.0;
clk = 0 ;
forever begin
uvm_config_db#(real)::wait_modified(uvm_root::get(),“uvm_test_top”,“clk_half_period”,clk_half_period));
void'(uvm_config_db#(real)::get(uvm_root::get(),"uvm_test_top","clk_half_period",clk_half_period));
end
forever begin
#(clk_half_period*1.0ns) clk = ~clk;
end
end
wait_modified会等待config_db::set执行,执行后才能config_db::get。
测试用例可以如下图所示:
uvm_config_db#(real)::set(this,"","clk_half_period",20);