03_UVM Object (uvm_object) 심층 분석: 초심자를 위한 가이드

UVM 객체 (uvm_object) 심층 분석: 초심자를 위한 가이드

UVM(Universal Verification Methodology) 환경에서 모든 컴포넌트 및 객체 클래스는 uvm_object 기본 클래스에서 파생됩니다. uvm_object 클래스의 주요 역할은 print, copy, compare 및 record와 같은 일반적인 유틸리티 함수 집합을 정의하는 것입니다. 이러한 함수들은 UVM 테스트벤치의 다른 클래스에서 활용되어 개발 효율성을 높입니다.

uvm_object 란 무엇인가?

uvm_object는 UVM 환경에서 사용되는 모든 객체 클래스의 기반이 되는 클래스입니다. 이 클래스는 UVM 테스트벤치 내의 다양한 클래스에서 공통적으로 사용되는 유틸리티 함수들을 정의하여 코드 재사용성을 높이고 개발 시간을 단축시키는 데 중요한 역할을 합니다.

클래스 계층 구조

uvm_object 클래스는 uvm_void 클래스를 상속받아 구현됩니다. 이를 통해 UVM 환경의 모든 객체들이 기본적인 UVM 기능을 상속받을 수 있도록 합니다.

uvm_object

클래스 정의

virtual class uvm_object extends uvm_void;

  // Creates a new uvm_object with the given name, empty by default
  function new(string name="");

  // Utility functions
  function void print (uvm_printer printer=null);
  function void copy (uvm_object rhs, uvm_copier copier=null);
  function bit  compare (uvm_object rhs, uvm_comparer comparer=null);
  function void record (uvm_recorder recorder=null);
  ...

  // These two functions have to be redefined by child classes
  virtual function uvm_object create (string name=""); return null; endfunction
  virtual function string get_type_name (); return ""; endfunction
endclass

uvm_object에서 파생된 클래스는 createget_type_name과 같은 순수 가상 method를 구현해야 합니다. 이러한 구현은 UVM 코딩 지침에 따라 매크로를 포함하여 처리됩니다.

create method는 이 객체와 동일한 유형의 새 객체를 할당하고 기본 uvm_object 핸들을 통해 반환합니다. newcreate의 차이점은 전자는 현재 객체에 대한 메모리를 할당하는 반면 후자는 다른 곳에 할당된 다른 객체에 대한 핸들을 반환한다는 것입니다.

class my_object extends uvm_object;
  ...

  // Implementation : Create an object of the new class type and return it
  virtual function uvm_object create(string name="my_object");
    my_object obj = new(name);
    return obj;
  endfunction
endclass

get_type_name 함수는 객체의 클래스 유형 이름을 반환하며 디버깅 기능 및 UVM 팩토리에 의해 특정 유형의 객체를 생성하는 데 사용됩니다.

class my_object extends uvm_object;

  // This static method is used to access via scope operator ::
  // without having to create an object of the class
  static function string type_name();
    return "my_object";
  endfunction

  virtual function string get_type_name();
    return type_name;
  endfunction
endclass

Factory Interface

UVM은 UVM 환경에서 정의된 모든 클래스가 이 "factory"에 등록되는 새로운 개념을 사용합니다. factory는 나중에 요청된 클래스 유형의 객체를 반환할 수 있습니다. 사용자 클래스는 factory에 등록할 수 있도록 클래스 내에 특정 매크로를 포함해야 합니다.

// An object derived from uvm_object by itself does not get
// registered with the UVM factory unless the macro is called
// within the class definition
class my_object extends uvm_object;

    // Register current object type with the factory
  `uvm_object_utils (my_object)

   ...
endclass

UVM Utility와 Field Macros에 대해 더 알아보기!

Utility Function

Print

function void print(uvm_printer printer = null);

print 는 UVM Print 정책에 따라 결정된 형식으로 현재 객체의 변수를 심층적으로 인쇄합니다. 이 함수는 virtual로 선언되지 않았으므로 다른 구현을 위해 하위 클래스에서 재정의할 수 없습니다. 그러나 사용자 정의 정보를 추가하기 위한 후크/콜백 함수인 do_print가 있습니다.

UVM Object Print에 대해 더 알아보기!

Copy

function void uvm_object::copy (uvm_object rhs, uvm_copier copier=null);

위의 print method와 마찬가지로 copy는 재정의할 수 없으며 파생 클래스의 필드를 복사하려면 해당 클래스가 대신 do_copy method를 재정의해야 합니다.

UVM Object Copy에 대해 더 알아보기!

Compare

function bit compare (uvm_object rhs, uvm_comparer comparer=null);

이 method는 이 데이터 객체의 멤버와 이 method에 인수로 제공된 객체의 멤버를 심층적으로 비교하여 일치하는 경우 1을, 그렇지 않은 경우 0을 반환합니다. 이 method는 재정의할 수 없으며 사용자 정의 가능한 후크인 do_compare에 사용자 정의 코드를 추가할 수 있습니다.

UVM Object Compare에 대해 더 알아보기!

간단히 말해서, uvm_object 클래스는 uvm_sequence_item (트랜잭션용) 및 uvm_component (테스트벤치 컴포넌트용)와 같은 다른 기본 UVM 클래스의 상위 클래스입니다. uvm_object에서 상속함으로써 이러한 클래스는 위에서 설명한 필수 기능과 속성을 상속받아 UVM 검증 환경의 중요한 구성 요소가 됩니다.

다음 이전

POST ADS 2