I have a class to be randomized which instantiates ~20 random classes. This is quite taxing on the constraint solver and actually for most tests we only require a subset of these to be randomized (different subset for each test) so what I’m trying to do is use an enable array (one bit per config) and then in pre_randomize() I look at the enable and set config.rand_mode(0) if the corresponding enable bit is 0.
Problem is setting rand_mode(0) on a class doesn’t seem to disable all constraints in the class and so I get constraint solver errors. What I’m trying to achieve is effectively not declaring the class as a rand class which I thought was what rand_mode(0) would do, is there any way to do this? We could randomize each enabled config individually one by one but then we would lose the ability to cross constrain across multiple enabled configs.
Any help much appreciated.
function void top_env_cfg::pre_randomize();
super.pre_randomize();
// Turn off randomization for any configs that are not enabled to speed up randomization
foreach(en_sub_cfg[cfg])
if(en_sub_cfg[cfg] == 0)
begin
`uvm_info(get_name(), $sformatf("Disabling rand for cfg %0d", cfg), UVM_LOW)
sub_cfg__base_cfg_h[cfg].rand_mode(0);
end
endfunction: pre_randomize