지노랩 /JinoLab

[UVM] 3.8.1 에이전트의 동작 모드 (Operating Modes) 본문

UVM(Universal Verification Methodology)/3. 재사용 가능한 검증 컴포넌트 개발(Developing Reusabl

[UVM] 3.8.1 에이전트의 동작 모드 (Operating Modes)

지노랩/JinoLab 2025. 3. 16. 13:02

3.8.1 에이전트의 동작 모드 (Operating Modes)

1. 개요

UVM에서 에이전트(agent)는 Active Mode(능동 모드)와 Passive Mode(수동 모드)의 두 가지 방식으로 동작할 수 있음.

  • Active Mode: 에이전트가 시스템 내에서 실제 장치를 에뮬레이션하여 DUT의 신호를 구동함. 이 경우 드라이버(driver)와 시퀀서(sequencer)를 포함해야 하며, 추가적으로 모니터(monitor)도 인스턴스화하여 체크 및 커버리지 수집 기능을 수행함.
  • Passive Mode: 에이전트가 드라이버와 시퀀서를 인스턴스화하지 않고, 모니터만 활성화하여 동작.
    • 이 모드는 DUT의 신호를 수동적으로 감시하고, 체크 및 커버리지 수집만 수행할 때 유용.

2. 에이전트 구현 예제

아래 예제에서는 simple_agent 클래스가 Active Mode 및 Passive Mode를 모두 지원하도록 구성되어 있음.

class simple_agent extends uvm_agent;
    // UVM 자동화 매크로
    `uvm_component_utils(simple_agent)

    // 에이전트 하위 구성 요소
    uvm_sequencer #(simple_item) sequencer;
    simple_driver driver;
    simple_monitor monitor;

    // 에이전트의 활성화 여부 (Active / Passive Mode)
    uvm_active_passive_enum is_active = UVM_ACTIVE;

    // 생성자
    function new(string name = "simple_agent", uvm_component parent);
        super.new(name, parent);
    endfunction

    // build_phase: 에이전트 내부 컴포넌트 생성
    virtual function void build_phase(uvm_phase phase);
        super.build_phase(phase);

        // 모니터 생성
        monitor = simple_monitor::type_id::create("monitor", this);

        // Active Mode인 경우, 시퀀서와 드라이버도 생성
        if (is_active == UVM_ACTIVE) begin
            sequencer = uvm_sequencer#(simple_item)::type_id::create("sequencer", this);
            driver = simple_driver::type_id::create("driver", this);
        end
    endfunction

    // connect_phase: 드라이버와 시퀀서 연결
    virtual function void connect_phase(uvm_phase phase);
        if (is_active == UVM_ACTIVE) begin
            driver.seq_item_port.connect(sequencer.seq_item_export);
        end
    endfunction
endclass

3. 코드 설명

  1. 라인 3-5: uvm_component_utils(simple_agent) 매크로를 사용하여 UVM Factory에 등록함.
  2. 라인 7-9: sequencer, driver, monitor를 에이전트 내부에서 선언함.
  3. 라인 11: is_active 변수(uvm_active_passive_enum)를 선언하여 에이전트의 활성화 여부를 결정함.
    • 기본값으로 UVM_ACTIVE를 설정하여 Active Mode로 동작하도록 설정.
  4. 라인 14-17: 생성자에서 super.new(name, parent);를 호출하여 부모 클래스 초기화.
  5. 라인 20-28: build_phase()에서 다음을 수행함.
    • super.build_phase(phase);를 호출하여 상위 클래스의 설정을 적용(라인 21).
    • monitor = simple_monitor::type_id::create("monitor", this);를 사용하여 모니터를 생성(라인 24).
    • is_active == UVM_ACTIVE 조건을 체크하여 Active Mode일 경우, 시퀀서 및 드라이버도 생성(라인 26-28).
  6. 라인 31-34: connect_phase()에서 Active Mode인 경우, 드라이버와 시퀀서를 연결.
    • driver.seq_item_port.connect(sequencer.seq_item_export);를 사용하여 두 컴포넌트 간의 연결을 수행.

4. 주요 개념 설명

(1) is_active 변수의 역할

  • is_active 변수는 Active Mode와 Passive Mode를 결정하는 핵심적인 속성임.
  • Active Mode(UVM_ACTIVE): 에이전트가 시퀀서와 드라이버를 생성하고, DUT와 직접 상호작용.
  • Passive Mode(UVM_PASSIVE): 드라이버와 시퀀서를 생성하지 않으며, 오직 모니터만 활성화하여 DUT 신호를 감시.

(2) build_phase()에서 create()를 사용한 인스턴스 생성

  • create()를 사용하면 UVM Factory를 활용하여 객체를 동적으로 생성할 수 있음.
  • 이 방식을 사용하면 특정 테스트에서 객체를 쉽게 교체할 수 있으며, UVM의 유연성을 극대화할 수 있음.

(3) connect_phase()에서 Active Mode인 경우만 연결 수행

  • driver.seq_item_port.connect(sequencer.seq_item_export);를 통해 TLM 연결을 설정.
  • Passive Mode일 경우에는 연결이 이루어지지 않음, 즉 모니터만 DUT의 동작을 감시함.

5. 주요 코드 라인 분석

 

라인  코드  설명
9 monitor = simple_monitor::type_id::create("monitor", this); 항상 모니터는 생성됨
10-15 if (is_active == UVM_ACTIVE) { sequencer = create(...); driver = create(...); } Active Mode일 경우, 시퀀서와 드라이버도 생성
18-20 if (is_active == UVM_ACTIVE) { driver.seq_item_port.connect(sequencer.seq_item_export); } Active Mode인 경우에만 드라이버와 시퀀서를 연결

6. 정리

 

동작 모드 설명  생성되는 컴포넌트
Active Mode DUT와 직접 인터페이스하여 트랜잭션을 전달 드라이버, 시퀀서, 모니터
Passive Mode 신호 감시 및 검증 전용 모니터만 생성
  • Active Mode에서는 시퀀서와 드라이버가 생성되어 DUT와 직접 상호작용.
  • Passive Mode에서는 오직 모니터만 활성화되어 DUT의 동작을 감시.

이러한 방식으로 UVM 에이전트를 구성하면 유연한 검증 환경을 구축할 수 있으며, Active/Passive 모드를 쉽게 전환 가능.

 

 

 


 

본 내용은
accellera에서 공개한
Universal Verification Methodology
(UVM) 1.2 User's Guide
를 바탕으로 작성된 글입니다.