Constraint turn off uvm_do_with

I have a sequence that uses axi transaction as it’s request type. Inside the transaction, there’s are many constraints defined.

In the body of the sequence, I have a uvm_do_with where I add specifics to the request (req.kind… req.start address, etc).

I would like to Turn off a particular constraint defined in the axi transaction, in my sequence.

How can I do this before/along with the uvm_do_with ?

Thanks.

In reply to UVM_learner6:

the constraint on a particular variable can be disabled by the following syntax

variable_name.constraint_mode(0);

In reply to UVM_learner6:

You can’t. You need a handle to the object to be able to enable/disable a constraint.

This is one reason that you should never use the `uvm_do macros and should implement the actual code necessary to send the sequence_item.

In reply to cgales:

In reply to UVM_learner6:
You can’t. You need a handle to the object to be able to enable/disable a constraint.
This is one reason that you should never use the `uvm_do macros and should implement the actual code necessary to send the sequence_item.

Could you help with how I can convert the uvm_do_with to actual code necessary to send the item?

In reply to UVM_learner6:

Read this chapter of the Verification Cookbook.

In reply to UVM_learner6:

In reply to cgales:
Could you help with how I can convert the uvm_do_with to actual code necessary to send the item?

In you body task of your sequence you have to create a handle/object of the seq_item.
In the next step you can switch off all conatraints in the seq_item by calling
<seq_item_object>. constraint_mode(0);
If the object name is req it would be reg.constraint_mode(0);
If you want to switch off only a specific constaring you can call:
<seq_item_object>.<constraint_name>.constraint_mode(0);

In reply to chr_sue:

In reply to UVM_learner6:
In you body task of your sequence you have to create a handle/object of the seq_item.
In the next step you can switch off all conatraints in the seq_item by calling
<seq_item_object>. constraint_mode(0);
If the object name is req it would be reg.constraint_mode(0);
If you want to switch off only a specific constaring you can call:
<seq_item_object>.<constraint_name>.constraint_mode(0);

I created an obj of the SI and then turned off the specific constraint.
This did not work, if I do this to turn off constraint before using uvm_do_with, it says “null object access”

In reply to UVM_learner6:

That’s correct what happens.
`uvm_do macros are creating an objetc are calling start_item, randomizing and calling finish_item.
Lööks like you have to to this explicitly without the uvm_do macro.