Usage of $testplusargs in randomization constraint of variable in sequence

Hi, I have a sequence with two random variables. I want to control the the randomization of one variable based on testplusargs. The second variable depends on first variable. How to randomize the first variable to take up the value based on testplusargs and make sure the same value is used for second variable’s constraint too ?

We need more details. Where are these two random variables located? When are they going to get randomized? What is it you need to control? How is the first variable used in a constraint? Why are you not using configuration objects for this?

Hi Dave,

Both these variables are random variables present in a read-write sequence. The first variable is the start address that is used as the first address while sending writes/reads to slave. The second variable is kind of address queue that stores walking ones addresses starting at the ‘start_addr’ variable. So,’’’queue[i] == start_addr | (1<<i)’’’

These get randomized when we call the base sequence using uvm_do from base test. We use override at runtime to replace the base sequence with read write sequence.
The first variable start addr should be based on which memory region is specified in testplusargs. For ex: +MEM_REGION0, then start addr should be REGION0_BASE_ADDR.

It would help to show a little bit of code. I don’t see anything random with the problem as you have stated it.

Do you mean something like

class base_seq;;
  rand bit [31:0];
 ...
endclass
class read_write_seq extends base_seql;
  parameter REGION0_BASE_ADDR = 'h123_0000;
  constraint c {$test$plusargs("+MEM_REGION0") 
                -> start_addr[31:16] == REGION0_BASE_ADDR[31:16];
                }
endclass

Yes, right. But when I try to use testplusargs inside the constraint I see the following error:
“System function calls are not yet implemented in constraints.
Remove the function call or if possible replace it with an integral state
variable assigned in pre_randomize().”

In case the variable only depends on testplusargs and hence not random I could have used pre_randomize. How to proceed in this case ?

You have run into a tool specific issue. However, I think it is a good idea for efficiency’s sake to read the command line once and store it in a non-random state variable.