UVM: Resource Database - IKSciting
1764
post-template-default,single,single-post,postid-1764,single-format-standard,bridge-core-2.8.7,qodef-qi--no-touch,qi-addons-for-elementor-1.7.1,qode-page-transition-enabled,ajax_fade,page_not_loaded,,qode-title-hidden,qode_grid_1300,footer_responsive_adv,qode-content-sidebar-responsive,qode-theme-ver-27.1,qode-theme-bridge,qode_header_in_grid,wpb-js-composer js-comp-ver-6.6.0,vc_responsive,elementor-default,elementor-kit-838

Resource Database

Configuration Database 페이지에 소개된 uvm_config_db와 유사하게 resource database를 관리하는 uvm_resource_db에 대해 소개한다. 하지만 일반적으로 uvm_resource_db 대신 uvm_config_db를 사용하는 것이 권장되기 때문에 세부적인 내용까지 자세히 다루지는 않는다. 이유는 아래에서 설명한다.

먼저 uvm_resource_db의 사용법은 다음과 같다. 아래에 기술된 setread_by_name 외에도 read_by_typeget_by_nameget_by_typewrite_by_namewrite_by_type 등이 있다.

class my_test extends uvm_test;
  
  // ...

  function void build_phase(uvm_phase phase);
    // ...
    
    // set resource database
    uvm_resource_db#(int)::set("uvm_test_top.env", "my_int", 1024);
  endfunction: build_phase
  
endclass: my_test
class my_env extends uvm_env;
  
  // ...

  function void build_phase(uvm_phase phase);
    // ...
    
    // get resource database
    if (!uvm_resource_db#(int)::read_by_name("uvm_test_top.env", "my_int", my_int)) begin
      my_int = -1;
    end
    
    `uvm_info(get_type_name(), $sformatf("my_int = %1d", my_int), UVM_MEDIUM)
  endfunction: build_phase
  
endclass: my_env

uvm_config_db는 uvm_resource_db에 한 단계 layer를 추가한 것으로서 uvm_resource_db가 할 수 있는 모든 기능을 동일하게 수행할 수 있다. uvm_resource_db는 ‘last write wins’ 방식에 의해 동작하는 반면, uvm_config_db는 ‘parent wins’ 방식을 사용하는 대표적인 차이가 있다. 일반적으로 build_phase에서 configuration, resource control을 하는 경우가 많은데, build_phase는 top-down 순서로 진행되기 때문에 uvm_resource_db 사용 시, 의도와 다르게 동작할 여지가 있다. 참고로 start_of_simulation_phase 부터 run_phase 등의 경우 uvm_config_db도 ‘last write wins’ 방식으로 동작한다.

아래에서 볼 수 있듯, instance를 지정하기 위해 string만을 사용하는 uvm_resource_db와 달리, uvm_component 정보와 string을 함께 사용하는 uvm_config_db는 testbench hierarchy를 기술할 때 typo와 같은 실수의 여지를 줄여주는 장점이 있다. uvm_resource_db는 scope를 지정하기 위한 string으로 hierarchy에 있지 않은 임의의 path를 지정할 수도 있지만, 이는 권장되는 UVM 사용 방식은 아니다.

// uvm_resource_db
static function void set(input string scope, input string name, T val, input uvm_object accessor = null)
// uvm_resource_db
static function bit read_by_name(input string scope, input string name, inout T val, input uvm_object accessor = null)
// uvm_config_db
static function void set(uvm_component cntxt, string inst_name, string field_name, T value)
// uvm_config_db
static function bit get(uvm_component cntxt, string inst_name, string field_name, inout T value)

위에서 언급한 이유로 인해 특별한 이유가 없다면 uvm_resource_db 대신 uvm_config_db를 사용할 것을 권장한다.

References

8 Comments

Post A Comment