External constraint fail

class plusarg_cfg extends mt_uvm_object;

plusarg_int TEST = new();
plusarg_bit TEST_BIT = new();
plusarg_logic TEST LOGIC = new();
plusarg_real TEST_REAL = new();

constraint c_int_test1 {
TEST.m_value == 1000;
}

`uvm_object_utils_begin(plusarg_cfg)
`uvm_object_utils_end

function new(string name="plusarg_cfg");
super. new (name) ;
endfunction

function void init();
this. randomize_cfg();
`uvm info("RNDM-PL", $sformatf("PLUSARGS : TEST = %0d, TEST_BIT = %0b, TEST_LOGIC = %0h, TEST_SWITCH = %0b, TEST_REAL = %0f, TEST_ENUM = %s", TEST.m_value, TEST_BIT.m_bit_value, TEST_LOGIC.m_value,
TEST_SWITCH.m_value, TEST_REAL.m_value, TEST_ENUM.m_value.name()), UVM_NONE)
endfunction

function void randomize_cfg();
`uvm_info("PL_CFG", $sformatf("Calling PL_CFG"), UVM_NONE)
void' ( randomize (TEST) );
//TEST.randomize();//Notice : we are not doing std :: randomize or this. randomize or TEST. randomize() .TEST. randomize cannot see external constraints but randomize(TEST) can
void' (randomize(TEST_BIT));
void' (randomize(TEST_LOGIC));
void' (randomize (TEST_REAL));

endfunction

endclass

Hi,

in the above class I have multiple classes instantiated with a varibale called m_value defined in them that is unique to the class and I want to for example use the constraint on the plusarg_int TEST variable. it works for the TEST class but for some reason the other randomization calls are failing in the randomize_cfg class. I get the following errors

*void’ (randomize (TEST_BIT) ) ;

xmsim: *W, SVRNDF (plusarg_cfg.sv, 31|18): The randomize method call failed. The unique id of the failed randomize call is 1.
Observed simulation time : 0 FS + 9.
xmsim: *W, RNDOCS: These constraints and variables contribute to the set of conflicting constraints (view the extended help for this message using ‘xmhelp xmsim RNDOCS’ for guidelines on how
debug the issue) :

In plusarg_cfg. sv
( TEST.m_value == 1000 )*

Any pointers here?

In reply to cropty:

It would help if you showed us a complete example stripping out the UVM.

Since you are calling this.randomize(), the constraint c_int_test1 must be satified regardless of which variable is being randomized.

In reply to dave_59:
Hi Dave,

Thanks for the reply. The crux of the code is in the original post
Below I am showing what plusarg_int class contents are.(every other plusarg_* class has a rand variable ,‘m_value’, declared.)


class plusarg_int extends plusarg_base;
   rand int m_value;
  ....
endclass

The rand value is declared in this class and the constraint is applied outside.
you are correct that the this.randomize() considers the constraint.

An issue arises lets say when I call the randomize in the below seq:
randomize(TEST_BIT);
randomize(TEST);

instead of

randomize(TEST);
randomize(TEST_BIT);

I have a feeling that TEST.m_value is getting randomized twice in the above case and that creates a conflict. I could be wrong.

In reply to cropty:

Wrong. The problem is unless randomize(TEST) gets called first, the constraint c_int_test1 cannot be met. Remember that active constraint must always be met regardless of which variables are being randomized.

You may want to rethink your approach how variables and constraints are organized. You haven’t provided any information why you need to randomize your variables separately.

In reply to dave_59:
Hi Dave,

I’ll give you a gist of what i am trying to achieve with this framework.

I am parsing the plusargs for our test and if the same plusarg as the name of the plusarg class object is found then I want to use the plusarg value instead of random.

The problem in the above setup is when we dont find the plusarg I want to use the plusarg class object with the rand variable inside of it randomized and the user can use a constraint if possible and hence the separation of the class with the random variable inside of it and the constraint.