In this way the mode can be used to control sets of constraints.
Hi Dave,
I have tried running the above code in the simulator every time i ran mode is taking the value 0 and starting addr is 30 , ending addr is 32 and my_addr is 20
what is the significance of my_exc_array i didn’t understand. The question is my_addr is should be in the reange of start-addr & end_addr right ?
I had a typo in my code that I corrected (missing{}'s around the range). but once corrected it works for me. You’ll have to ask the original author of this question, but I believe they wanted either my_addr to be inside the start_/end_range or inside my_exc_array.
module top;
class A;
bit [31:0] my_exc_array[$] = {'h1234, 'h5678, 'hABCD, 'hFFFF};
rand enum {Range, Array} mode;
rand bit [31:0] my_addr;
rand bit [31:0] start_addr;
rand bit [31:0] end_addr;
constraint my_cons {
mode dist { Range:=1, Array:=1};
mode == Array -> my_addr inside {my_exc_array};
mode == Range -> { my_addr inside {[start_addr:end_addr]};
end_addr > start_addr; }
}
endclass
A a = new;
initial repeat(20) begin
assert(a.randomize());
$displayh(a.mode.name,, a.my_addr);
end
endmodule
@dave_59 . Can u please review the above solution with randcase ? I am receiving an error that we cannot use random variables range_wt, array_wt. Can u please help me understand the reason ?
I am looking for a scalable solution where there are multiple ranges and multiple exec_arrays and the distribution is not uniform
Calling a user defined function within a constraint is very restrictive. The solver determines variable ordering by looking solely at function arguments, not inside the function. You probably want to call the function in post_randomize()
There are a number of memory manager algorithms you can search for.