概述UVM驗(yàn)證環(huán)境中的Agent
時(shí)間:2021-11-05 13:43:50
手機(jī)看文章
掃描二維碼
隨時(shí)隨地手機(jī)看文章
[導(dǎo)讀]UVM?agent可以被認(rèn)為是特定interface的驗(yàn)證組件工具包(package),其中包括一個(gè)用于連接DUT的SystemVeriloginterface以及一個(gè)組成整個(gè)agent組件類的SystemVerilog?package。agent類是一個(gè)容器類,包含driver...
UVM?agent 可以被認(rèn)為是特定interface的驗(yàn)證組件工具包(package ),其中包括一個(gè)用于連接DUT的SystemVerilog interface以及一個(gè)組成整個(gè)agent 組件類的SystemVerilog?package。
agent 類是一個(gè)容器類,包含driver、sequencer 和monitor。agent 類還具有一個(gè)analysis port,該端口連接到monitor上的analysis port。我們使用一個(gè)APB總線agent 展示它是如何封裝、配置、構(gòu)建和連接的。APB?agent 使用一個(gè)名為apb_if的接口(apb_if.sv)。agent 的各種類模板文件一起收集在一個(gè)SystemVerilog package中(apb_agent_pkg.sv)。
1、agent的拓?fù)浣涌凇?/span>UVM agent中有一個(gè)類型為UVM_ACTIVE_PASSIVE_e的變量,UVM_ACTIVE會構(gòu)建sequencer 和driver,UVM_PASSIVE則不會。此參數(shù)默認(rèn)情況下為UVM_ACTIVE,當(dāng)然也可以不去使用。
2、virtual interface句柄配置對象還會包含一個(gè)driver 和monitor需要使用的?virtual interface句柄。配置對象在Testcase中構(gòu)造和配置,并將virtual interface賦值給agent中的virtual interface。?3、子組件的行為配置對象還可以包含影響agent 的行為的其他變量。例如,在apb agent的配置對象中,有一些變量可以設(shè)置哪些內(nèi)存地址是有效的。
1、Monitor analysis port到agent's analysis port
2、?sequencer的seq_item_pull_export到driver的seq_item_pull_port3、將agent配置對象中的virtual interface賦值給driver?和monitor?中virtual interfaces句柄
上述連接方式只是一個(gè)示例,具體項(xiàng)目可能有所不同,但是本質(zhì)上是一樣的。
以下示例了apb agent 的 build phase和 connect phase:
agent 類是一個(gè)容器類,包含driver、sequencer 和monitor。agent 類還具有一個(gè)analysis port,該端口連接到monitor上的analysis port。我們使用一個(gè)APB總線agent 展示它是如何封裝、配置、構(gòu)建和連接的。APB?agent 使用一個(gè)名為apb_if的接口(apb_if.sv)。agent 的各種類模板文件一起收集在一個(gè)SystemVerilog package中(apb_agent_pkg.sv)。
package apb_agent_pkg;import uvm_pkg::*;`include "uvm_macros.svh"`include "apb_seq_item.svh"`include "apb_agent_config.svh" `include "apb_driver.svh"`include "apb_coverage_monitor.svh"`include "apb_monitor.svh"`include "apb_sequencer.svh"`include "apb_agent.svh"`include "apb_seq.svh"endpackage: apb_agent_pkgagent 有一個(gè)配置對象,可用于定義:1、agent的拓?fù)浣涌凇?/span>UVM agent中有一個(gè)類型為UVM_ACTIVE_PASSIVE_e的變量,UVM_ACTIVE會構(gòu)建sequencer 和driver,UVM_PASSIVE則不會。此參數(shù)默認(rèn)情況下為UVM_ACTIVE,當(dāng)然也可以不去使用。
2、virtual interface句柄配置對象還會包含一個(gè)driver 和monitor需要使用的?virtual interface句柄。配置對象在Testcase中構(gòu)造和配置,并將virtual interface賦值給agent中的virtual interface。?3、子組件的行為配置對象還可以包含影響agent 的行為的其他變量。例如,在apb agent的配置對象中,有一些變量可以設(shè)置哪些內(nèi)存地址是有效的。
class apb_agent_config extends uvm_object;`uvm_object_utils(apb_agent_config)virtual?apb_if?APB;?uvm_active_passive_enum active = UVM_ACTIVE;bit has_functional_coverage = 0;bit has_scoreboard = 0;int no_select_lines = 1;logic[31:0] start_address[15:0];logic[31:0] range[15:0];extern function new(string name = "apb_agent_config");endclass: apb_agent_configfunction
apb_agent_config::new(string name = "apb_agent_config");super.new(name);endfunction一旦構(gòu)建了agent的子組件,就需要連接它們。通常需要的連接有:1、Monitor analysis port到agent's analysis port
2、?sequencer的seq_item_pull_export到driver的seq_item_pull_port3、將agent配置對象中的virtual interface賦值給driver?和monitor?中virtual interfaces句柄
上述連接方式只是一個(gè)示例,具體項(xiàng)目可能有所不同,但是本質(zhì)上是一樣的。
以下示例了apb agent 的 build phase和 connect phase:
class apb_agent extends uvm_component;`uvm_component_utils(apb_agent)apb_agent_config m_cfg;uvm_analysis_port #(apb_seq_item) ap;apb_monitor m_monitor;apb_sequencer m_sequencer;apb_driver m_driver;apb_coverage_monitor m_fcov_monitor;extern function new(string name = "apb_agent", uvm_component parent = null);extern function void build_phase( uvm_phase phase );extern function void connect_phase( uvm_phase phase );endclass: apb_agent
function apb_agent::new(string name = "apb_agent", uvm_component parent = null);super.new(name, parent);endfunctionfunction void apb_agent::build_phase( uvm_phase phase );if( !uvm_config_db #( apb_agent_config )::get(this,"apb_agent_config",m_cfg) ) `uvm_error(...)m_monitor = apb_monitor::type_id::create("m_monitor", this);if(m_cfg.active == UVM_ACTIVE) begin m_driver = apb_driver::type_id::create("m_driver", this); m_sequencer = apb_sequencer::type_id::create("m_sequencer", this);endif(m_cfg.has_functional_coverage) begin m_fcov_monitor = apb_coverage_monitor::type_id::create("m_fcov_monitor", this);endendfunction:?build_phasefunction void apb_agent::connect_phase( uvm_phase phsae );m_monitor.APB = m_cfg.APB;ap = m_monitor.ap;if(m_cfg.active == UVM_ACTIVE) begin m_driver.seq_item_port.connect(m_sequencer.seq_item_export); m_driver.APB = m_cfg.APB;endif(m_cfg.has_functional_coverage) begin m_monitor.ap.connect(m_fcov_monitor.analysis_export);?end?endfunction:?connect_phase 




