I have a uvm_sequence subclass with random constraints which need to access some of the runtime behavior knobs present in the config object for the sequencer which will run it:
class my_seq extends uvm_sequence#(my_tr);
my_config cfg;
rand bit foo;
constraint c {
if( cfg.always_use_foo ) foo == 1;
}
/* ... body(), etc ... */
endclass
My problem is that the sequence needs to be randomized before I send it to the sequencer but it doesn't know what sequencer it will run on when I randomize it. Normally I would get the config object from the uvm_config_db at the beginning of the sequence's run phase, but in this case I want to base my random constraint on information on the config object.
my_seq p = my_seq::type_id::create();
assert( p.randomize() ); // <-- can't randomize here because p.cfg hasn't been set, and p doesn't know what sequencer will run it
p.start( some_sequencer );
I know I can just set p.cfg before I randomize it, but I'm looking for some way for this to happen automatically, similar to when I get the config object in body() it can automatically retrieve it from the sequencer on which the sequence is running.
Unfortunately sequences don't seem to have any kind of pre-run setup which configures the sequencer the way sequence_items do:
start_item(tr);
assert( tr.randomize() ); // <-- tr knows what its sequencer is already because of start_item()
finish_item(tr);