# How to pass a task output values from interface into the monitor?

**URL:** <https://verificationacademy.com/forums/t/how-to-pass-a-task-output-values-from-interface-into-the-monitor/40330>\
**Category:** UVM\
**Tags:** UVM, UVM-monitor\
**Created:** [April 30, 2022, 10:22am UTC](https://verificationacademy.com/forums/t/how-to-pass-a-task-output-values-from-interface-into-the-monitor/40330 "2022-04-30T10:22:10Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![UVM\_LOVE](https://verificationacademy.com/forums/user_avatar/verificationacademy.com/uvm_love/32/1684_2.png) [@UVM\_LOVE](https://verificationacademy.com/forums/u/UVM_LOVE)\
**Post date:** [April 30, 2022, 10:22am UTC](https://verificationacademy.com/forums/t/how-to-pass-a-task-output-values-from-interface-into-the-monitor/40330/1 "2022-04-30T10:22:10Z")

</div>

Dear All,

I was made a simple task to collect output values from DUT in the Interface.  
I just want to pass the collected values from monitor to the scoreboard.  
this is interface

```verilog

interface apb_interface();
  bit	pclk;
  bit	presetn;
  bit	[9:0] paddress;
  bit	[31:0] pwdata;
  bit	pselect;
  bit	pready;
  bit	penable;
  bit	[31:0] preaddata;
  bit	wr_rdenable;

task send_to_dut(input	bit [9:0] addr, 
						bit [31:0] wdata	);
//	@(posedge pclk)
		paddress <= addr;
		pwdata <= wdata;
$display("called_send_to_dut task\n");
endtask

task collect_data(output bit [9:0] addr,
						  bit [31:0] wdata,
						  bit [31:0] rdata);

		addr = paddress;
		wdata = pwdata;
		rdata = preaddata;
$display("called_collect_data task rdata:%02h = preaddata:%02h;\n", rdata, preaddata);
endtask

endinterface

```

this is monitor.

```verilog

class apb_monitor extends uvm_monitor;

	`uvm_component_utils(apb_monitor)

	virtual apb_interface vapb_intf;

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

uvm_analysis_port #(apb_sequence_item) my_mon_port;

virtual function void build_phase(uvm_phase phase);
	super.build_phase(phase);
	my_mon_port = new ("my_mon_port", this);
   if (! uvm_config_db #(virtual apb_interface) :: get (this, "", "virtualapb_intf", vapb_intf)) begin
      `uvm_fatal (get_type_name (), "Monitor Didn't get handle to virtual interface virtualapb_intf")
    end
endfunction	

virtual task run_phase(uvm_phase phase);
	forever begin
		apb_sequence_item apb_rx = apb_sequence_item::type_id::create("apb_sequence_item");
		@(posedge vapb_intf.pclk)
		
	    vapb_intf.collect_data(apb_rx.address, apb_rx.data, apb_rx.acc);
      
      `uvm_info(get_type_name(), $sformatf("Value from Monitor!! => apb_rx.address:%0h, apb_rx.data:%0h, apb_rx.acc:%0h", apb_rx.address, apb_rx.data , apb_rx.acc), UVM_LOW)
      
		apb_rx.wr_en <= vapb_intf.penable;
       
		my_mon_port.write(apb_rx);
	end
endtask

endclass

```

Problem is the difference between collected data from interface and received data from monitor.

When I print the log out as the blow, I was expected apb\_rx.acc is 87 not 01.

**rdata:87 = preaddata:87**  
UVM\_INFO apb\_monitor.sv(31) @ 25: uvm\_test\_top.apb\_environment.apb\_agent.monitor [apb\_monitor] Value from Monitor!! =\> apb\_rx.address:82, apb\_rx.data:05, **apb\_rx.acc:01**

Could you guide me how do I get the value correctly in monitor? why does “apb\_rx._" value differ from "vapb\_intf._”?  
How do I get the same correct value from a task(collect\_data.rdata) and interface apb\_rx.acc?

For your understand my problem, I make a link [Edit code - EDA Playground](https://edaplayground.com/x/VzLC)

Thank you in advance.

---

<div class="post-metadata">

**Author:** ![cgales](https://verificationacademy.com/forums/letter_avatar_proxy/v4/letter/c/ccd318/32.png) [@cgales](https://verificationacademy.com/forums/u/cgales)\
**Post date:** [May 2, 2022, 12:28pm UTC](https://verificationacademy.com/forums/t/how-to-pass-a-task-output-values-from-interface-into-the-monitor/40330/2 "2022-05-02T12:28:11Z")

</div>

_In reply to [UVM\_LOVE](https://verificationacademy.com/forums/t/how-to-pass-a-task-output-values-from-interface-into-the-monitor/40330):_

The interface task ‘collect\_data()’ has the outputs of addr, wdata and rdata. The monitor is run\_phase() is calling ‘collect\_data()’ with addr, data and acc.

You are not matching the task variable types.
