How to use tlm_analysis_fifo?

In my case, I have a packet in monitor need to be sent to scoreboard and in the scoreboard, I would send the packet into different tlm_analysis_fifos depends on the content of the packet.

I am confused which ports should I use in this path on each boundary and how to connect them together. I checked the scoreboard in the cookbook, it only shows how to connect the analysis port directory the analysis export to the FIFO which is not suitable for my case.


If these FIFOs are all inside the same scoreboard, then you can instantiate the uvm_tlm_analysis_fifo’s inside your scoreboard. Then have a write method in your scoreboard do the selective writes to your analysis fifos.

class my_scoreboard extends uvm_scoreboard;
function new (string name, uvm_component parent);, parent);

uvm_analysis_imp #(my_transaction1, my_scoreboard) analysis_export; // connects to monitor

// these could be the same transaction types
uvm_tlm_analysis_fifo #(my_transaction2) fifo1;
uvm_tlm_analysis_fifo #(my_transaction3) fifo2;

function build_phase(uvm_phase phase);
  analysis_export = new("analysis_imp", this);
  fifo1 = new("fifo1",this);
  fifo2 = new("fifo2",this);

function void write (my_transaction1 t1);
  if (t1.something)
      // might need to create or clone t2
      // might need to create or clone t3

// other scoreboard code that get()s transactions from the fifos.


In reply to dave_59:

Hi Dave:

Thank you for you reply and great example code. Problem solved.

In reply to Enzo Chi:

Hi Dave,

Does this write function always get called automatically? I added a $display message there, but it seems never get into it …

I have hooked another analysis port to the analysis_fifo in my env …


In reply to nickbayshore:

Not sure what you mean by “automatically”

The write function in the scoreboard gets called if you have properly connected the analysis port of the monitor, and the monitor calls analysis_port.write()

In reply to dave_59:

Hi Dave,

Thanks for your reply. Here is my code like, the 1) works but 2) doesn’t work. Basically I have to add another analysis port, connect this analysis port to the monitor first, and then the write gets called, but if I connect the analysis fifo to the monitor directly, the write didn’t gets called … Does it make sense?

  1. `uvm_analysis_imp_decl(_abc)

uvm_analysis_imp_abc abc_export; —> Define another

uvm_tlm_analysis_fifo abc_fifo;

monitor.a_port.connect(scoreboard.abc_export); —> Connect to this ap

function void write_abc (input my_transaction1 t1); —> This one get called. Note it uses write_abc
if (t1.something)

  1. uvm_tlm_analysis_fifo abc_fifo;

    monitor.a_port.connect(m_tbuf_scoreboard.abc_fifo.analysis_export); → connect to the fifo directly

function void write (input my_transaction1 t1); —> Didn’t get called
if (t1.something)

In reply to nickbayshore:

Does anyone know why I have to add another analysis port in 1) to get it work? i.e. why can’t just connect the monitor to the analysis fifo directly? Thanks!

In reply to nickbayshore:

Hi Dave,

Did you get what I mean now? Do you have idea why the write() didn’t get call when connecting the monitor analysis port to the analysis fifo directly? Thanks!

Sir,i have one doubt i am new to uvm beginer
If the analysis port is directly connected to analysis export means what is the need of
analysis_imp and uvm_analysis_tlm_fifo ?

In reply to baladevi:

On the same hierarchy Level you can connect only ports with exports. If you are changing the level you can connect ports with ports and exports with exports.
An analysis_imp is the last in the chain of analysis exports which has to provide the write-method.
a uvm_analysis_tlm_fifo is an unbounded TLM fifo.

In reply to chr_sue:

Why we cannot connect port to port at the same hierarchy level but can connect at different hierarchy level?
The same is valid for export also…??

In reply to chr_sue:

If I declare an analysis_export in scoreboard is it necessary to override WRITE method or is it implicitly taken care of?

In reply to piyushpatel123:

It’s always Port connects to Export at the top level of the connection. Then it’s port-to-port or export-to-export depending on which side of the connection you’re on. Suppose your monitor was 3-levels of hierarchy and your subscriber was 2-levels down. Then your connections would be


In reply to nickbayshore:

2)nd case

1)uvm_tlm_analysis_fifo abc_fifo;
3) monitor.a_port.connect(m_tbuf_scoreboard.abc_fifo.analysis_export); --> connect to the fifo directly
5)function void write (input my_transaction1 t1); ---> Didn't get called
6)if (t1.something)

I cannot understand, why you think that 1st write function (line 5) should be called? Who is the owner of that write?
Mainly the communication between the ports is done by following way:
where the port/export part can be as many as user wants.
And port can use write task and implementation should implement that write task.
in other words
port.write(tlm) → imp: (function write() …)

Now in your example you connect port to export. And than use write (line 5).
So it wont be called, because there is no imp port in that chain.
When you connect to subscriber, it internally has imp port, which implements write functions in it.