uvm config_db

530 阅读1分钟

在这里插入图片描述

local config在这里插入图片描述

global config

uvm_resource_db 使用较少(了解内容)
在这里插入图片描述

set_config_int这种用法被淘汰

可以写config文件,传多个东西

class xxx_agent_config extends uvm_object;

   `uvm_object_utils(xxx_agent_config)

   function new(string name="xxx_agent_config");
      super.new(name);
   endfunction: new   
   
   uvm_active_passive_enum       active            = UVM_PASSIVE;
   int                           monitor_verbosity = UVM_DEBUG;
   bit                           has_coverage      = 0;
   bit                           board_2           = 0;
   int                           clock_type        = 3;
   uvm_sequencer #(xxx_tran_control)   sqr;
   
   virtual xxx_ifc_control          xxx_vif_ctrl_b1;
   virtual xxx_ifc_control          xxx_vif_ctrl_b2;
   virtual xxx_ifc_fb               xxx_vif_fb_b1;
   virtual xxx_ifc_fb               xxx_vif_fb_b2;
endclass

在sequnece中使用config_db

  • 在sequence可以向component设置参数;也可以向sequence中设置参数。

sequence中set

//设置参数
virtual task case0_vseq::body();
      my_transaction tr;
      drv0_seq seq0;
      drv1_seq seq1;
      if(starting_phase != null) 
         starting_phase.raise_objection(this);
      fork
         `uvm_do_on(seq0, p_sequencer.p_sqr0);
         `uvm_do_on(seq1, p_sequencer.p_sqr1);
         begin
            #10000;
             uvm_config_db#(bit)::set(uvm_root::get(), "uvm_test_top.env0.scb", "cmp_en", 0);//向scb中设置参数
            #10000;
            uvm_config_db#(bit)::set(uvm_root::get(), "uvm_test_top.env0.scb", "cmp_en", 1);
         end
      join 
      #100;
      if(starting_phase != null) 
         starting_phase.drop_objection(this);
   endtask

// scb中取得参数
task my_scoreboard::main_phase(uvm_phase phase);
   my_transaction  get_expect,  get_actual, tmp_tran;
   bit result;
   bit cmp_en = 1'b1;
 
   super.main_phase(phase);
   fork
      while(1) begin
          // 等待cmp_en改变,否则阻塞
         uvm_config_db#(bit)::wait_modified(this, "", "cmp_en");
         void'(uvm_config_db#(bit)::get(this, "", "cmp_en", cmp_en)); 
         `uvm_info("my_scoreboard", $sformatf("cmp_en value modified, the new value is %0d", cmp_en), UVM_LOW)
      end
     ...
   join
endtask

wait_modified

  • sequence是动态运行的,它什么时候要设置参数不固定,component需要知道什么时候sequence设置了参数,这通过wait_modified任务实现。
super.main_phase(phase);
   fork
      while(1) begin
          // 等待cmp_en改变,否则阻塞
         uvm_config_db#(bit)::wait_modified(this, "", "cmp_en");
         void'(uvm_config_db#(bit)::get(this, "", "cmp_en", cmp_en)); 
         `uvm_info("my_scoreboard", $sformatf("cmp_en value modified, the new value is %0d", cmp_en), UVM_LOW)
      end
     ...
   join

sequence中get

//get
uvm_config_db#(int)::get(null, get_full_name(), "count", count)
//set
uvm_config_db#(int)::set(this, "env.i_agt.sqr.*", "count", 9);  //build_phase

misc

  • 使用了field automation 不用get
  • 对于uvm_component派生类来说,field_automation机制最重要的是 可以在build_phase中自动获取uvm_config_db#()::set()的数值(必须加super.build_phase(phase))---- 也就是不用写 uvm_config_db#()::get()
  • 扩展于uvm_object
  • config_db的set函数没有返回值。
  • 可以传递数值/对象/vif

8、uvm_config_db和uvm_resource_db有什么区别?

uvm_config_db和uvm_resource_db都是参数化的类,用于配置验证组件中不同类型的参数。
相比于uvm_resource_db,uvm_config_db增加了层次关系。
对于最后配置的参数值,uvm_resource_db是“last write wins”, uvm_config_db是“parent wins”