uvm_driver——老司机带带我

文件:
src/comps/uvm_driver.svh
类:
uvm_driver

  uvm_driver继承(C++中叫继承)自uvm_component,其中定义了两个Ports:seq_item_port,driver一般用这个接口向sequencer索要sequence。rsp_port,driver向相应的sequencer发送response。uvm_seq_item_pull_port在TLM中介绍。在user_driver中会实现死循环,将收到sequence拆解成interface的信号,从而将transaction转换成信号层。

typedef class uvm_sequence_item;

//------------------------------------------------------------------------------
//
// CLASS: uvm_driver #(REQ,RSP)
//
// The base class for drivers that initiate requests for new transactions via
// a uvm_seq_item_pull_port. The ports are typically connected to the exports of
// an appropriate sequencer component.
//
// This driver operates in pull mode. Its ports are typically connected to the
// corresponding exports in a pull sequencer as follows:
//
//|    driver.seq_item_port.connect(sequencer.seq_item_export);
//|    driver.rsp_port.connect(sequencer.rsp_export);
//
// The ~rsp_port~ needs connecting only if the driver will use it to write
// responses to the analysis export in the sequencer.
//
//------------------------------------------------------------------------------

class uvm_driver #(type REQ=uvm_sequence_item,
                   type RSP=REQ) extends uvm_component;


  // Port: seq_item_port
  //
  // Derived driver classes should use this port to request items from the
  // sequencer. They may also use it to send responses back.

  uvm_seq_item_pull_port #(REQ, RSP) seq_item_port;

  uvm_seq_item_pull_port #(REQ, RSP) seq_item_prod_if; // alias

  // Port: rsp_port
  //
  // This port provides an alternate way of sending responses back to the
  // originating sequencer. Which port to use depends on which export the
  // sequencer provides for connection.

  uvm_analysis_port #(RSP) rsp_port;

  REQ req;
  RSP rsp;

  // Function: new
  //
  // Creates and initializes an instance of this class using the normal
  // constructor arguments for <uvm_component>: ~name~ is the name of the
  // instance, and ~parent~ is the handle to the hierarchical parent, if any.

  function new (string name, uvm_component parent);
    super.new(name, parent);
    seq_item_port    = new("seq_item_port", this);
    rsp_port         = new("rsp_port", this);
    seq_item_prod_if = seq_item_port;
  endfunction // new

  const static string type_name = "uvm_driver #(REQ,RSP)";

  virtual function string get_type_name ();
    return type_name;
  endfunction

endclass

参考文献:

1 Java 继承. http://www.runoob.com/java/java-inheritance.html.

2 C++ 继承. http://www.runoob.com/cplusplus/cpp-inheritance.html

3 UVM中的driver组件. http://www.cnblogs.com/-9-8/p/4487881.html

原文地址:https://www.cnblogs.com/dpc525/p/7907038.html