Generating Unique Random Values for Array.
[Supported in IEEE 1800-2012]
1). Randomizing all 32 members of array ,each member with 16 bit width
class random_unique_array_c;
rand bit [15:0] uniq_arr [31:0];
constraint unique_cnstnt {unique {uniq_arr };}
endcalss : random_unique_array_c
2). Randomizing all 32 members of array ,each member with 16 bit width, with exclusion of some values.
class random_unique_array_c;
rand bit [15:0] uniq_arr [31:0];
bit [15:0] exclude_val [ ] = {3,6,9};
constraint unique_cnstnt {unique {uniq_arr,exclude_val,12 };} //uniq_arr will not have values
endcalss : random_unique_array_c //3,6,9,12
For more info see IEEE 1800-2012 LRM section 18.5.5 "Uniqueness constraints"
[Supported in IEEE 1800-2012]
1). Randomizing all 32 members of array ,each member with 16 bit width
class random_unique_array_c;
rand bit [15:0] uniq_arr [31:0];
constraint unique_cnstnt {unique {uniq_arr };}
endcalss : random_unique_array_c
2). Randomizing all 32 members of array ,each member with 16 bit width, with exclusion of some values.
class random_unique_array_c;
rand bit [15:0] uniq_arr [31:0];
bit [15:0] exclude_val [ ] = {3,6,9};
constraint unique_cnstnt {unique {uniq_arr,exclude_val,12 };} //uniq_arr will not have values
endcalss : random_unique_array_c //3,6,9,12
For more info see IEEE 1800-2012 LRM section 18.5.5 "Uniqueness constraints"
No comments:
Post a Comment