Testbench/Agent(从The Agent Build Phase开始)

上一篇 / 下一篇  2018-09-18 10:24:07

        The Agent Build Phase     

        在agent的build phase中发生的操作由其配置对象的内容确定。method中的第一个操作是获取对配置对象的引用。然后,从这点来说,测试适当的配置字段以确定它们是否应该被构造。

        【此处需一幅图】
 
        此规则的例外情况是始终构建的monitor,因为无论agent是active还是passive,都会使用它。
 
        The Agent Connect Phase
      
        一旦构建了agent的子组件,就需要连接它们。 通常需要的连接是:
  • Monitor analysis port to the agent's analysis port
  • The sequencer's seq_item_pull_export to the driver's seq_item_pull_port (If the agent is active).
  • Any agent analysis sub-components analysis exports to the monitor's analysis port
  • 将driver和monitor中的虚拟接口分配给配置对象中的虚拟接口

        Notes:
        1.可以从monitor的analysis port为agent的analysis port句柄分配指针。这节省了必须在agent中构建单独的analysis port对象。
        2.在agent中为driver和monitor分配虚拟接口,这就不需要这些子组件具有配置表查找的代价了。

        apb agent的以下代码说明了配置对象如何确定在build phase和connect phase期间发生的情况:

        //
        // Class Description:
        //
        //
        class apb_agent extends uvm_component;

        // UVM Factory Registration Macro
        //
        `uvm_component_utils(apb_agent)

        //------------------------------------------
        // Data Members
        //------------------------------------------
        apb_agent_config m_cfg;
        //------------------------------------------
        // Component Members
        //------------------------------------------
        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;        

        //------------------------------------------
        // Methods
        //------------------------------------------

        // Standard UVM Methods:
        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);
        endfunction

        function void apb_agent::build_phase( uvm_phase phase );
             if( !uvm_config_db #( apb_agent_config )::get(this,"apb_agent_config",m_cfg) ) `uvm_error(...)
             // Monitor is always present
             m_monitor = apb_monitor::type_id::create("m_monitor", this);
             // Only build the driver and sequencer if active
             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);
             end
             if(m_cfg.has_functional_coverage) begin
                   m_fcov_monitor = apb_coverage_monitor::type_id::create("m_fcov_monitor", this);
             end

         endfunction: build_phase

         function void apb_agent::connect_phase( uvm_phase phsae );
              m_monitor.APB = m_cfg.APB;
              ap = m_monitor.ap;
              // Only connect the driver and the sequencer if active
              if(m_cfg.active == UVM_ACTIVE) begin
                   m_driver.seq_item_port.connect(m_sequencer.seq_item_export);
                   m_driver.APB = m_cfg.APB;
              end
              if(m_cfg.has_functional_coverage) begin
                   m_monitor.ap.connect(m_fcov_monitor.analysis_export);
              end

         endfunction: connect_phase

         在块级测试平台示例中agent的构建过程可以遵循此处APB agent的构建过程:

         (可以从网站http://verificationacademy.com/uvm-ovm在线下载源代码示例

TAG:

 

评分:0

我来说两句

显示全部

:loveliness: :handshake :victory: :funk: :time: :kiss: :call: :hug: :lol :'( :Q :L ;P :$ :P :o :@ :D :( :)

日历

« 2018-10-22  
 123456
78910111213
14151617181920
21222324252627
28293031   

数据统计

  • 访问量: 11657
  • 日志数: 48
  • 建立时间: 2018-09-03
  • 更新时间: 2018-10-12

RSS订阅

Open Toolbar