bool32.rising trigger
bool32.rising reset
bool32.rising rnd
int32 count
int32 max
int32 stage
int32 stages
int32 normal
int32 normax
bool32.pulse nxt
bool32.pulse carry pulse
int32 total
int32 min
int32 max
int32 quant
bool32.mom rnd
int ntrig;
int rtrig;
int count;
int32_t max[64];
int i;
int stage;
int k;
int strig;
int32_t random;
int RND;
int32_t MAX;
int pk;
count = 0;
ntrig = 0;
rtrig = 0;
// max[0]== (int32_t)(GenerateRandomNumber()% 8)+1;
// for(i=1;i<64;i++){
// max[i] = (int32_t)(GenerateRandomNumber()% 8)+1+max[i-1];
// }
RND = 1;
int32_t width = param_max - param_min + 1;
outlet_c = 0;
if ((inlet_trig > 0) && !ntrig) {
count += 1;
if (count >= param_total) {
count = 0;
outlet_c = 1;
stage = 0;
MAX = max[0];
}
ntrig = 1;
} else if (!(inlet_trig > 0))
ntrig = 0;
if ((inlet_r > 0) && !rtrig) {
count = 0;
rtrig = 1;
} else if (!(inlet_r > 0))
rtrig = 0;
int rnd = inlet_rnd + param_rnd + RND;
if ((rnd > 0) && !strig) {
RND = 0;
max[0] = (int32_t)(GenerateRandomNumber());
max[0] = max[0] - max[0] / width * width;
max[0] = max[0] < 0 ? max[0] + width : max[0];
max[0] = ((((max[0] + param_min) / param_quant) * param_quant));
for (i = 1; i < 64; i++) {
max[i] = (int32_t)(GenerateRandomNumber());
max[i] = max[i] - max[i] / width * width;
max[i] = max[i] < 0 ? max[i] + width : max[i];
max[i] =
((((max[i] + param_min) / param_quant) * param_quant)) + max[i - 1];
}
strig = 1;
} else if (!(rnd > 0)) {
strig = 0;
}
int32_t Stages;
stage = 0;
k = 0;
for (i = 0; i < 64; i++) {
if (param_total > max[i]) {
Stages = i + 1;
}
}
outlet_stages = Stages;
stage = 0;
k = 0;
for (i = 0; i < 64; i++) {
if (count >= max[i]) {
stage = max[i];
k = i;
}
}
outlet_count = count - stage;
if (!(k == pk)) {
MAX = (max[k + 1] - max[k]) > (param_total - count) ? (param_total - count)
: (max[k + 1] - max[k]);
}
if (count == 0) {
MAX = max[0];
}
outlet_max = MAX;
outlet_stage = k;
outlet_nxt = (!(k == pk));
outlet_normal = count;
outlet_normax = param_total;
pk = k;