Uvm_event with parameter

Hi,

I want using uvm_event with argument to pass data between 2 agents.
the argument i need to pass is of uvm_sequence_item type.
i see that the argument should be uvm_object.
does it enough that um_sequence_item is inheritance uvm_object?
now i get an error that i’m not use uvm_object.
my seq_item is with arguments.
what is the best way to resolve it?

Thanks.

Shalom Brurya,

Since uvm_sequence_item inherits from uvm_object, try using the dynamic casting:
$cast(dst_var, src_var) task/function.
To downcast the uvm_object to your uvm_sequence_item.

Like in the example below:

event_e.wait_trigger_data(rx_data_uvm_object);
if !($cast(rx_data_uvm_seqeunce_item, rx_data_uvm_object)) 
    `uvm_fatal(get_name(),"downcast failed!")

The answer depends on which version of UVM is in use. In UVM 1.1d or earlier, the “data” argument written must be an object derived from uvm_object. You must retrieve the object into a uvm_object variable, then `$cast it back to your sequence item.

Starting with UVM 1.2, the type of the data argument is parameterized so you can avoid the downcasting.

1 Like

Thanks your answer.
Try to declare again.

in a agent i defined:

uvm_event_pool #(spi_qspi_seq_item#(QSPI_WIDTH,QSPI_XY_CONTROLLER)) xy2spi_item_e;

xy2spi_item_e = uvm_event_pool::get_global(“xy2spi_e”);
xy2spi_item_e.trigger(qspi_item);

in agent b, I defined:

uvm_event_pool #(spi_qspi_seq_item#(QSPI_WIDTH,QSPI_XY_CONTROLLER)) xy2spi_item_e;
xy2spi_item_e = uvm_event_pool::get_global(“xy2spi_e”);
xy2spi_item_e.wait_trigger();
$cast(item,xy2spi_item_e.get_trigger_data());
`uvm_info(get_name(),$psprintf(“qspi monitor: %p\n”,item),UVM_DEBUG)

I get an error:
Error-[MFNF] Member not found
…/verification//env/tsp_ref_model.sv, 102
“this.xy2spi_item_e.”
Could not find member ‘trigger’ in class ‘uvm_object_string_pool’, at
“/tools/Synopsys/vcs/U-2023.03-SP1//etc/uvm-1.2/base/uvm_pool.svh”, 248.

could you explain me the issue?

Thanks.

I’m surprised that was the only error you got.

uvm_event_pool is not parameterized, it is specialized to uvm_event#(uvm_object)
get_global("key") returns a handle to a uvm_event not the uvm_event_pool.

I suggest using the following

typedef uvm_event#(spi_qspi_seq_item#(QSPI_WIDTH,QSPI_XY_CONTROLLER)) spi_event_t;
typedef uvm_string_pool#(spi_event_t) spi_event_pool;
spi_event_t e;

e = spi_event_pool::get_global(“xy2spi_e”);

e.trigger(qspi_item);
...
e.wait_trigger();
item = e.get_trigger_data()

Sorry, the above only works in UVM IEEE 1800.2

For UVM 1.2

uvm_event e;
e = spi_event_pool::get_global(“xy2spi_e”);
...
assert($cast(item,e.get_trigger_data());

Thanks a lot.
it good now.
As you wrote, the definition caused to compilation error.

Thanks