지난 게시글에서 Agent에 대해 간단히 언급하였는데, 이에 대해 자세히 알아보자.
Agent는 UVM 환경에서 가장 기본적인 검증 블록을 뜻한다. 하나의 DUT 인터페이스를 다루기 위해 필요한 컴포넌트들은 너무 많다(driver, monitor, sequencer). 이걸 묶어 하나의 단위로 다루면 재사용성, 확장성, 유지보수성이 올라가게 되는데, 이를 묶어서 하나로 묶은 통합 컨트롤 유닛을 UVM Agent라고 한다.
구분 | 🟢 Active Agent | 🔵 Passive Agent |
생성 컴포넌트 | Sequencer, Driver, Monitor 모두 생성 | Monitor만 생성 |
DUT와의 인터페이스 | 데이터를 전송할 수 있음 | DUT의 동작을 관찰만 함 |
사용 목적 | DUT에 입력 신호를 생성/제어 | DUT의 출력 검증, 커버리지 측정 |
시퀀스 실행 | O | X (sequencer 없음) |
예시 상황 | Master/Tx쪽 인터페이스 | Slave/Rx 감시, 참조 모델 비교 |
UVM 에이전트는 Active Agent와 Passive Agent 두 가지가 있으며, Active는 DUT에 데이터를 전송하고 감시하며, Passive는 DUT를 감시만 하게 된다.
Passive Agent는 DUT를 건드리지 않고 감시만 하는 역할로, 출력 검증, 커버리지 측정, Scoreboard 비교 등 다양한 상황에서 꼭 필요하기 때문에 존재한다.
1. Agent의 구성요소
구성 요소 | 역할 | 설명 |
driver | DUT로 신호 전달 | 테스트 데이터를 실제 DUT에 보냄 |
sequencer | 시나리오 관리 | 테스트 순서를 제어하는 트랜잭션 생성기 |
monitor | DUT 감시 | DUT가 출력하는 신호를 관찰 |
config 객체 | 에이전트 제어 설정 | active/passive 모드 등 동작 모드 설정 |
2. Agent의 구현
1) Agent 클래스 생성
// my_agent is user-given name for this class that has been derived from "uvm_agent"
class my_agent extends uvm_agent;
// [Recommended] Makes this agent more re-usable
`uvm_component_utils (my_agent)
// This is standard code for all components
function new (string name = "my_agent", uvm_component parent = null);
super.new (name, parent);
endfunction
// Code for rest of the steps come here
endclass
- class my_agent extends uvm_agent; UVM의 표준 agent 클래스를 상속해서, 나만의 에이전트를 만든다.
- `uvm_component_utils(my_agent)` 이 클래스를 UVM factory에 등록 → 동적으로 생성 가능하게 함
- super.new(name, parent); 상위 클래스인 uvm_agent의 생성자를 호출해서 기본 초기화 수행한다.
2) 서브 컴포넌트 선언
// Create handles to all agent components like driver, monitor and sequencer
// my_driver, my_monitor and agent_cfg are custom classes assumed to be defined
// Agents can be configured via a configuration object that can be passed in from the test
my_driver m_drv0;
my_monitor m_mon0;
uvm_sequencer #(my_data) m_seqr0;
agent_cfg m_agt_cfg;
Agent 내부에서 사용할 driver, monitor, sequencer 등의 핸들을 미리 선언하는 단계이다. 각 driver, monitor, sequencer는 UVM이 기본 제공하는 Class를 상속해서 만들게 된다.
3) 빌드 단계에서 컴포넌트 생성
virtual function void build_phase (uvm_phase phase);
// If this UVM agent is active, then build driver, and sequencer
if (get_is_active()) begin
m_seqr0 = uvm_sequencer#(my_data)::type_id::create ("m_seqr0", this);
m_drv0 = my_driver::type_id::create ("m_drv0", this);
end
// Both active and passive agents need a monitor
m_mon0 = my_monitor::type_id::create ("m_mon0", this);
//[Optional] Get any agent configuration objects from uvm_config_db
endfunction
앞에서 선언만 해두었던 드라이버, 모니터, 시퀀서 등의 구성 요소를 실제 시뮬레이션 시작 전에 UVM 방식으로 동적으로 생성하는 단계이다.
4) 컴포넌트 간 연결
virtual function void connect_phase (uvm_phase phase);
// Connect the driver to the sequencer if this agent is Active
if (get_is_active())
m_drv0.seq_item_port.connect (m_seqr0.seq_item_export);
endfunction
이전 단계에서 create()로 생성한 컴포넌트들을 서로 연결(connect) 시켜서 실제 트랜잭션이 흐를 수 있도록 만드는 작업이다.
3. Agent 구현 전체 코드 예시
class my_agent extends uvm_agent;
`uvm_component_utils (my_agent)
my_driver m_drv0;
my_monitor m_mon0;
uvm_sequencer #(my_data) m_seqr0;
agent_cfg m_agt_cfg;
function new (string name = "my_agent", uvm_component parent=null);
super.new (name, parent);
endfunction
// If Agent is Active, create Driver and Sequencer, else skip
// Always create Monitor regardless of Agent's nature
virtual function void build_phase (uvm_phase phase);
super.build_phase (phase);
uvm_config_db #(agent_cfg) :: get (this, "*", "agt_cfg", m_agt_cfg);
if (get_is_active()) begin
m_seqr0 = uvm_sequencer#(my_data)::type_id::create ("m_seqr0", this);
m_drv0 = my_driver::type_id::create ("m_drv0", this);
m_drv0.vif = m_agt_cfg.vif;
end
m_mon0 = my_monitor::type_id::create ("m_mon0", this);
m_mon0.vif = m_agt_cfg.vif;
endfunction
// Connect Sequencer to Driver, if the agent is active
virtual function void connect_phase (uvm_phase phase);
if (get_is_active())
m_drv0.seq_item_port.connect (m_seqr0.seq_item_export);
endfunction
endclass
'이론 공부 > UVM (Universal Verification Methodology)' 카테고리의 다른 글
UVM Testbench Structure - 05. Monitor (0) | 2025.04.19 |
---|---|
UVM Testbench Structure - 04. Driver (0) | 2025.04.19 |
UVM Testbench Structure - 03. Sequencer (0) | 2025.04.18 |
UVM Testbench Structure - 01. UVM TOP (0) | 2025.04.18 |
UVM 개요 (0) | 2025.04.18 |