I need to write constraint where in the values between two beats cannot collide, the value of two beats can be less than the two beats in front of it or the values of the two beats can be greater than the two beats which are behind.
The request for getting the above beats come at variable times.
Trying to explain the problem statement:
req1 at time 10
return beat 0 can be at time 20
return beat 1 can be at time 17
req 2 at time 12
return beat 0 can be at time 13
return beat 1 can be at time 14
req 3 at time 15
return beat 0 can be at time 25
return beat 1 can be at time 30
req 4 at time 17
return beat 0 can be at time 22
return beat 1 can be at time 24
req 5 at time 23
return beat 0 can be at time 35
return beat 1 can be at time 32
As it can be seen two beat returns from different request do not interleave but the two beats can come still be out of order with respect to the train of input req:
I have tried writing a function call, but this is not working as per needed:
This generates all the beats in order, it swap between beat 0 and beat 1 ,what am I missing for making the beats out of order, I tried several examples but failed!
The below code is functional with in order beats and it can swap between beat0 and beat1
NO_OF_BEATS = 2
int beat[NO_OF_BEATS]
int acc[NO_OF_BEATS];
int req;
function beat_delay(ref int req, ref int beat [NO_OF_BEATS], ref int acc[NO_OF_BEATS]);
std::randomize (beat) with{
foreach(beat[i]){
foreach(acc[j]){
(! (int'(req+beat[i] )inside {acc}));
int'(req+beat[i]) > acc[j];
beat[i] dist {[5:10] := 20, [11:200] := 70, [201:500] := 10};
}
}
};
endfunction
beat_delay(req, beat, acc);
foreach(acc[i])begin
acc[i] = req+ beat[i];
end