How to implement more than 1 Analysis Implementation Ports in a Class in UVM

Hi All,

In this post, we will discuss about how to include more than 1 Analysis Implementation Port in a Class in UVM.

Analysis Ports are used for many purposes like Coverage Collection, Received/Transmitted Packet Checking. And sometimes, you may need to take coverage on different packets (so you will require different analysis implementation ports) and you do not want to define 2 different class, just for coverage.

So if there are more than 1 (suppose 2) analysis implementation ports in a class, then obvious (and the first also !!!) question arises in the mind is that, how to implement 2 write methods in the same class.

Well, in UVM, we have 2 different methods to address the problem.


Method - 1 : Use "imp" Suffix defined via Macro

  • Declare Macro `uvm_analysis_imp_decl(<Postfix>) outside of the component. This macro adds post-fix to the analysis implementation port class name and associated write method.
  • Instantiate Analysis Implementation Port with uvm_analysis_imp_<Postfix> class name.
  • Implement write_<Postfix> method.
 Now Example,

`uvm_analysis_imp_decl(_port1)
`uvm_analysis_imp_decl(_port2)

class x extends uvm_component;
  // Other Stuff, like registering in Factory, new method

  uvm_analysis_imp_port1 #(packet1, x) a1;
  uvm_analysis_imp_port2 #(packet2, x) a2;

  virtual function void write_port1 (packet1 p);
    // Write Method for a1 Analysis Implementation Port
  endfunction : write_port1

  virtual function void write_port2 (packet2 p);
    // Write Method for a2 Analysis Implementation Port
  endfunction : write_port2
endclass : x


Method - 2 : Use Analysis FIFO

  • Declare Analysis Export Ports & Analysis FIFOs.
  • Connect Analysis Exports to the Analysis FIFOs in connect_phase.
  • run_phase must pull data from Analysis FIFOs, for further processing.
 Now Example,

class x extends uvm_component;
  // Other Stuff, like registering in Factory, new method

  uvm_tlm_analysis_fifo #(packet1) port1_fifo;
  uvm_tlm_analysis_fifo #(packet2) port2_fifo;
  uvm_analysis_export #(packet1) a1;
  uvm_analysis_export #(packet2) a2;

  function void connect_phase (uvm_phase phase);
    // Analysis Exports will connect to the analysis_export of FIFOs
    a1.connect(port1_fifo.analysis_export);
    a2.connect(port2_fifo.analysis_export);
  endfunction : connect_phase

  task run_phase (uvm_phase phase);
    // Pull data from FIFOs for further processing
    port1_fifo.get(p1);
    port2_fifo.get(p2);
  endfunction : connect_phase
endclass : x

Comments

Popular posts from this blog

SystemVerilog Event Regions

Standard Cell Based ASIC Design Flow

Verilog Event Regions