In reply to chr_sue:
I think I understand that. Do you believe it’s possible to write a macro that takes a sequence or sequence_item and is called from a sequence or somewhere else e.g. uvm_test?
It needs to accept either a SEQ_OR_ITEM
- a sequence : calling __seq.create, randomize, __seq.start
- sequence_item : calling **__seq.**create_item, **__seq.**start_item, randomize **__seq.**finish_item
In UVM1.2 the selection is done using $cast(__seq, SEQ_OR_ITEM)
It can be called from either
- sequence
- elsewhere e.g. test case
Here’s another attempt, unfortuately it doesn’t compile due to
Access to protected member ‘create_item’ in class ‘uvm_sequence_base’ is not allowed here.
`define uvm_do_from_test(SEQ_TYPE, SEQ_OR_ITEM, SEQR, PRIORITY, CONSTRAINTS) \
begin \
uvm_sequence_/base __seq; \
uvm_object_wrapper w_; \
w_ = SEQ_OR_ITEM.get_type(); \
if (!$cast(__seq,SEQ_OR_ITEM)) begin \
$cast(SEQ_OR_ITEM, __seq.create_item(w_, SEQR, `"SEQ_OR_ITEM`")); \
SEQ_OR_ITEM.start_item(SEQ_OR_ITEM, PRIORITY); \
end else SEQ_OR_ITEM = SEQ_TYPE::type_id::create(`"SEQ_OR_ITEM`"); \
if (!(SEQ_OR_ITEM.randomize() with CONSTRAINTS)) \
`uvm_fatal(get_type_name(),$sformatf("Sequence randomization failed")) \
if (!$cast(__seq,SEQ_OR_ITEM)) SEQ_OR_ITEM.finish_item(SEQ_OR_ITEM, PRIORITY); \
else __seq.start(SEQR, __seq, PRIORITY, 0); \
end