I have below constraint in my test but it failed at sim_run when solving it… I know it’s not correct but have no idea how to implement it…
class my_item extends uvm_object;
rand bit [17:0] my_addr;
rand bit [3:0] size[4];
rand bit [17:0] base[4];
rand bit [17:0] gen_addr;
constraint my_cons {
foreach (base[i])
is_my_decode(base[i]) == 0; // is_my_decode is a known function
foreach (base[i])
is_ip_domain(base[i]) == 1; // is_ip_domain is a known function
gen_addr inside {my_gen_addr}; // my_gen_addr is a known array
my_addr dist { gen_addr :/ 1 ,
[base[0]:base[0]+size[0]] :/1 ,
[base[1]:base[1]+size[1]] :/1 ,
[base[2]:base[2]+size[2]] :/1 ,
[base[3]:base[3]+size[3]] :/1 };
}
endclass : my_item
From my understanding, the reason of the failure is as described below (please correct me if I am wrong)
First, the base will be solved with below expression:
my_addr dist { gen_addr :/ 1 ,
[base[0]:base[0]+size[0]] :/1 ,
[base[1]:base[1]+size[1]] :/1 ,
[base[2]:base[2]+size[2]] :/1 ,
[base[3]:base[3]+size[3]] :/1 };
And then the results will be input to is_my_decode and is_ip_domain function. If any of the function call return false, my constraint is failed.
Thank you for any help !