Module 5: Observation and Checking | Lesson 44

Analysis Ports

Learn how UVM monitors broadcast observed transactions to scoreboards, coverage collectors, subscribers, and other verification components using analysis ports.

Learning objectives

  • Explain what a uvm_analysis_port does and when to use it.
  • Create an analysis port for a specific transaction type.
  • Publish observed transactions with write().
  • Connect an analysis port to one or more consumers.
  • Understand why analysis ports are useful for broadcasting observations.
  • Distinguish the monitor's publishing role from the consumer's checking or coverage role.
  • Debug common analysis-port connection and transaction-flow problems.

Step 1: Why analysis ports?

In Lesson 43, we learned that TLM allows UVM components to communicate using transactions instead of raw DUT signals.

An analysis port is one of the most common ways to publish observed transactions from a monitor.

The typical flow is:

DUT interface
  |
  v


Monitor
|
| bus_transaction
v
Analysis Port
|
+--------> Scoreboard
|
+--------> Coverage
|
+--------> Subscriber

The important feature is that one analysis port can send the same observation to multiple consumers.

Core idea: An analysis port is commonly used to broadcast observed transactions to interested verification components.

This is especially useful because a monitor should not need to know whether its transactions are being used for checking, coverage, logging, or another form of analysis.

Step 2: The basic analysis port

An analysis port is parameterized by the transaction type it publishes.

uvm_analysis_port #(bus_transaction) analysis_port;

The parameter tells UVM what kind of object will be sent through the port.

For a monitor, the port is normally created in the constructor:

class bus_monitor extends uvm_monitor;

`uvm_component_utils(bus_monitor)

virtual bus_if vif;

uvm_analysis_port #(bus_transaction)
    analysis_port;

function new(
    string name = "bus_monitor",
    uvm_component parent = null
);
    super.new(name, parent);

    analysis_port =
        new("analysis_port", this);
endfunction


endclass

Notice that the analysis port belongs to the monitor. The monitor is the producer of observed transactions.

Step 3: Publishing a transaction

Once the monitor has detected a real protocol transfer, it creates an observed transaction and publishes it with write().

bus_transaction observed;


observed =
bus_transaction::type_id::create("observed");

observed.write = vif.write;
observed.addr  = vif.addr;
observed.data  = vif.data;

analysis_port.write(observed);

The call:

analysis_port.write(observed);

means, conceptually:

"This transaction has been observed.


Any connected analysis consumers may process it."

The monitor does not need to call the scoreboard directly.

That separation is important for reusable verification environments.

Step 4: The consumer receives the transaction

An analysis consumer provides a write() implementation that handles the transaction.

A simple consumer might look like this:

class bus_checker extends uvm_component;

`uvm_component_utils(bus_checker)

uvm_analysis_imp #(bus_transaction, bus_checker)
    analysis_imp;

function new(
    string name = "bus_checker",
    uvm_component parent = null
);
    super.new(name, parent);

    analysis_imp =
        new("analysis_imp", this);
endfunction

function void write(bus_transaction t);

    `uvm_info("CHECK",
        $sformatf(
            "Received transaction:\n%s",
            t.sprint()),
        UVM_MEDIUM)

endfunction


endclass

The consumer's write() function is called when the connected analysis port publishes a transaction.

For this lesson, focus on the communication pattern rather than memorizing every TLM class:

Monitor


|
| analysis_port.write(transaction)
v
Consumer
|
| write(transaction)
v
Checking / processing
Important: The monitor publishes the transaction. The consumer decides what that transaction means for checking, coverage, logging, or another purpose.

Step 5: Connect the analysis port

The producer and consumer must be connected during connect_phase().

function void connect_phase(uvm_phase phase);

super.connect_phase(phase);

monitor.analysis_port.connect(
    checker.analysis_imp
);


endfunction

The architecture is therefore:

build_phase()
|
+-- create monitor
+-- create checker
|
v


connect_phase()
|
+-- analysis_port.connect(analysis_imp)
|
v
run_phase()
|
+-- monitor observes transfer
+-- monitor creates transaction
+-- monitor calls write()
+-- checker receives transaction

Remember the phase rule from earlier lessons:

Create first. Connect second. Run third.

Step 6: One producer, multiple consumers

This is where analysis ports become especially powerful.

Suppose a monitor produces:

bus_transaction

Three different components may be interested in the same observation:

  • A scoreboard wants to check correctness.
  • A coverage collector wants to measure exercised behavior.
  • A subscriber wants to record or summarize transactions.

The architecture can be:

                    +----> Scoreboard
                |


Monitor ---> Analysis Port
|
+----> Coverage
|
+----> Subscriber

The monitor does not need three different publishing mechanisms.

It simply publishes:

analysis_port.write(observed);

Each connected consumer receives the observation.

Why this matters: one observation can support several independent verification activities without modifying the monitor.

Step 7: Analysis ports are for observations

Analysis ports are particularly well suited to information that flows outward from an observing component.

A common pattern is:

Monitor


|
| observed transaction
v
Analysis Port
|
+--> Scoreboard
+--> Coverage
+--> Subscriber
+--> Logger

Compare this with the stimulus path:

Sequence


|
v
Sequencer
|
v
Driver
|
v
DUT

These are different directions and different responsibilities.

Path Purpose
Sequence → Driver Generate and deliver stimulus
Monitor → Analysis Port Publish observed behavior
Analysis Port → Scoreboard Provide transactions for checking
Analysis Port → Coverage Provide transactions for measurement

Step 8: Complete monitor example

Here is the basic pattern assembled into one monitor.

class bus_monitor extends uvm_monitor;

`uvm_component_utils(bus_monitor)

virtual bus_if vif;

uvm_analysis_port #(bus_transaction)
    analysis_port;

function new(
    string name = "bus_monitor",
    uvm_component parent = null
);
    super.new(name, parent);

    analysis_port =
        new("analysis_port", this);
endfunction

task run_phase(uvm_phase phase);

    bus_transaction observed;

    forever begin

        @(posedge vif.clk);

        if (vif.reset)
            continue;

        if (vif.valid && vif.ready) begin

            observed =
                bus_transaction::type_id::create(
                    "observed");

            observed.write = vif.write;
            observed.addr  = vif.addr;
            observed.data  = vif.data;

            `uvm_info("MON",
                $sformatf(
                    "Publishing:\n%s",
                    observed.sprint()),
                UVM_MEDIUM)

            analysis_port.write(observed);

        end

    end

endtask


endclass

The monitor still follows the three responsibilities from Lesson 41:

  1. Observe the interface.
  2. Reconstruct the transaction.
  3. Publish the transaction.

The analysis port is simply the publishing mechanism.

Step 9: What should the monitor publish?

A good analysis-port design depends on good transaction design.

The monitor should publish a meaningful transaction representing the protocol operation it observed.

For example:

WRITE


addr = 8'h20
data = 8'hAA

is usually more useful to downstream components than publishing every signal involved in the handshake.

The monitor should not normally publish incomplete information simply because some signal changed.

Lesson 42 established the rule:

Publish one transaction for one meaningful protocol observation.

The analysis port then distributes that completed observation.

Step 10: Analysis port versus direct function calls

A beginner might ask why the monitor cannot simply call a scoreboard method directly:

scoreboard.check(observed);

It can be done in a small testbench, but it creates tight coupling.

The monitor would need to know exactly which scoreboard object exists.

With an analysis port:

analysis_port.write(observed);

the monitor only knows that it is publishing an observation.

The environment decides who receives it.

Direct call Analysis port
Monitor knows the consumer Monitor publishes without knowing specific consumers
More tightly coupled More loosely coupled
Usually one specific destination Can support multiple analysis consumers
Harder to reuse Better suited to reusable UVM architecture

Step 11: Debugging analysis ports

If a scoreboard receives no transactions, debug the path one boundary at a time.

DUT transfer
|
v


Monitor detects it?
|
v
Transaction created?
|
v
analysis_port.write() called?
|
v
Port connected?
|
v
Consumer write() called?
|
v
Checker processes transaction?

Add temporary messages at both ends.

In the monitor:

`uvm_info("MON",
$sformatf(
    "Publishing:\n%s",
    observed.sprint()),
UVM_MEDIUM)

In the consumer:

`uvm_info("CHECK",
$sformatf(
    "Received:\n%s",
    t.sprint()),
UVM_MEDIUM)

Interpret the results:

  • No MON message: investigate DUT activity or monitor sampling.
  • MON message but no CHECK message: investigate the TLM connection.
  • CHECK message with wrong data: investigate transaction reconstruction or sampling.
  • CHECK receives correct data but reports failure: investigate checker/reference-model logic.
Debugging rule: Find the first boundary where the transaction stops being correct. Do not start by rewriting the entire scoreboard.

Common mistakes

  • Forgetting to construct the analysis port: declaration alone is not enough.
  • Forgetting the connection: publishing a transaction does nothing useful if no consumer is connected.
  • Using incompatible transaction types: the producer and consumer must agree on the TLM transaction type.
  • Publishing incomplete transactions: make sure the monitor has reconstructed the complete observation.
  • Checking inside the monitor: keep observation and checking separate when practical.
  • Calling a scoreboard directly: this creates unnecessary coupling.
  • Assuming an analysis port is a DUT handshake: it is a UVM transaction communication mechanism.
  • Debugging only the consumer: trace the transaction from the monitor through the connection.

Analysis port mental model

          OBSERVATION
           |
           v
        Monitor
           |
           | write(transaction)
           v
   +-------------------+
   |  Analysis Port    |
   +-------------------+
      /       |       \
     /        |        \
    v         v         v


Scoreboard  Coverage  Subscriber
|         |         |
Check    Measure    Process

Think of the analysis port as a broadcast point for transaction observations.

The monitor publishes once. Multiple consumers can independently use that observation.

What comes next?

Now that you understand how an analysis port publishes transactions, the next question is:

How do I create a reusable UVM component whose main job is to receive and process those transactions?

That is the purpose of the next lesson: Subscribers.

You will use the same analysis-port mechanism to build a component dedicated to receiving transactions and performing useful analysis, such as coverage collection, statistics, or simple checks.

Try it yourself

Build a monitor-to-consumer analysis-port connection.

  1. Create a bus_monitor containing a uvm_analysis_port #(bus_transaction).
  2. Create a simple consumer with a uvm_analysis_imp.
  3. Implement the consumer's write(bus_transaction t) method.
  4. Connect the monitor's analysis port to the consumer during connect_phase().
  5. Generate three DUT transfers.
  6. Verify that the monitor publishes all three transactions.
  7. Verify that the consumer receives all three transactions.

Challenge: Add a second consumer. The same monitor should publish each transaction once, while both consumers independently receive the observation.

Key takeaways

  • uvm_analysis_port is a common mechanism for publishing observed transactions.
  • The analysis port is parameterized by the transaction type it carries.
  • The monitor publishes an observation with analysis_port.write(transaction).
  • Consumers receive the transaction through a compatible analysis implementation.
  • Connections are normally established during connect_phase().
  • One analysis port can distribute an observation to multiple consumers.
  • Analysis ports reduce coupling between monitors and downstream verification components.
  • The monitor observes and publishes; the consumer decides how to process the observation.
  • When debugging, trace the transaction from the DUT transfer to the monitor, port, connection, and consumer.

Core mental model

Publish once, analyze many times.
The monitor observes the DUT, creates a transaction, and publishes it through an analysis port. Scoreboards, coverage collectors, subscribers, and other consumers can independently use the same observation.