Override seq called `uvm_do_with not getting constraint value

I have a sequence class which calls another class subseq like:

task body();
sub_seq sub_seq_1;
 `uvm_do(sub_seq_1,{m_write_data = 0xabcd})
endtask

I have to override sub_seq, so I am extending it.

sub_seq_ext extends sub_seq;
..
rand bit[31:0] m_write_data;
task body();
`uvm_info(get_name(),$sformatf("m_write_data %0h:",m_write_data),UVM_LOW)
endtask

....
endclass

I have override the sub_seq by set_type_override_by_type in base test.


class base_test extends uvm_test;
....
  function void start_of_simulation_phase(uvm_phase phase);
       begin
        `uvm_info("SEQ_OVERRIDE","Overriding sequence ",UVM_LOW)
        sub_seq :: type_id :: set_type_override(sub_seq_ext :: get_type());

    end
....

endclass

I am seeing that it is calling override seq’s body but it is not taking the constraint value (0xabcd). it gives a random number.

Any idea of possibly what went wrong here?

In reply to vineet_sharma:

With at least two typos in your example, I’m surprised you see any numbers.

  • Need to use uvm_do_with instead of uvm_do to add inline constraints.
  • sub_seq_ext::body should call super.body(), or you need to provide the complete functionality of body().
  • Should not declare m_write_data in sub_seq_ext.

In reply to dave_59:

Thanks Dave, after removing the m_write_data in sub_seq_ext it is working fine.
sorry for the typo, it was `uvm_do_with.
I am still not clear with what went wrong with m_write_data declared in extended class?

In reply to vineet_sharma:

You should never add class properties in the extended class with the same name that exist in the base class. This creates two variables with same name and you uvm_do_with constraint gets applied to the one visible in the sub_seq class. The uvm_info statement in the sub_seq_ext class prints the unconstraint variable.