uvm_object_utils_begin 测试集字段后设置字段失败

uvm_object_utils_begin fails set field after test set filed

出于某种原因,我的对象在创建时没有选择通过测试的配置。当我启用跟踪时,我没有看到 GET,只有 SET。 我有以下反对意见:

class top_env_cfg extends uvm_object;
   int set_default_env = 1;
   `uvm_object_utils_begin(top_env_cfg)
      `uvm_field_int(set_default_env,UVM_DEFAULT);
   `uvm_object_utils_end
  function new(string name = "top_env_cfg");
    super.new(name);
  endfunction
endclass

在我的测试中,在 build_phase 中,我正在执行以下操作:

uvm_config_db#(int)::set(this, "*", "set_default_env" ,0);

在我 build_phase 的环境中,我将此对象创建为:

env_cfg = top_env_cfg::type_id::create("env_cfg", this);

创建此对象后,set_default_env 仍然是 1。 可能出了什么问题,我该如何调试它。 提前致谢。

了解 "automated retrieval of config_db resources" 的重要一点是它 不会 实际上自动发生。 This Verilab paper 解释了幕后发生的事情,我在这里引用相关部分:

[...] one question that is often asked with respect to retrieving data is: do you always have to explicitly call the get() function? The short answer is that it depends. In the UVM, there are mechanisms to automate the retrieval of data from the configuration database. In order to have the resource automatically retrieved two things must happen:

  • First, that resource has to be registered with the factory using the field automation macros.
  • Second, super.build_phase(phase) must be called in the build_phase() function.

当您从 uvm_component 调用 super.build_phase() 时,将发生 "automated" 检索。如果您在问题中提到,您有一个 uvm_object(您没有 UVM build_phase),因此您需要明确执行 uvm_config get() 调用命令从数据库中检索资源。