19 UVM Subscriber

uvm_subscriber 类提供与analysis port连接的analysis export。顾名思义,它订阅广播器,即analysis port来接收broadcasted transactions。

  1. uvm_subscriber 派生自 uvm_component 并在类中添加了analysis_export端口。
  2. 用户定义的subscriber派生自 uvm_subscriber,必须定义 write 方法(write 方法是在 uvm_subscriber 类中声明的纯虚方法)。analysis_export提供外部组件对 write 方法的访问。
  3. 由于uvm_subscriber内置有analysis_export,因此一般用于实现功能覆盖率监控。

uvm_subscriber类定义:

virtual class uvm_subscriber #(type T=int) extends uvm_component;

  typedef uvm_subscriber #(T) this_type;
  uvm_analysis_imp #(T, this_type) analysis_export;
  
  function new (string name, uvm_component parent);
    super.new(name, parent);
    analysis_export = new("analysis_imp", this);
  endfunction
  
  pure virtual function void write(T t);
endclass

1 uvm_subscriber class hierarchy

19 UVM Subscriber_第1张图片

2 UVM subscriber example

19 UVM Subscriber_第2张图片

在下面的例子中,一个功能覆盖率monitor被创建,派生自uvm_subscriber类。 

class func_cov extends uvm_subscriber #(seq_item);
  covergroup cg;
  ...
  endgroup

  function void write (seq_item req);
    ...
    cg.sample();
  endfunction
endclass

// Env class connects broadcaster and subscriber class using analysis port connection.
class env extends uvm_env;
  `uvm_component_utils(env)
  agent agt;
  func_cov fc;
 
  function new(string name = "env", uvm_component parent = null);
    super.new(name, parent);
  endfunction
  
  function void build_phase(uvm_phase phase);
    super.build_phase(phase);
    agt = agent::type_id::create("agt", this);
    fc = func_cov::type_id::create("fc", this);
  endfunction
  
  function void connect_phase(uvm_phase phase);
    agt.mon.item_collect_port.connect(fc.analysis_export); // Here, Monitor behaves as a broadcaster.
  endfunction
endclass

你可能感兴趣的:(UVM,vlsiverify_uvm)