int32 i
int32 o
frac32.s.map prob
bool32 on
int32_t val;
int ntrig;
int latch;
int mtrig;
int ptrig;
int pval;
val = (int32_t)(GenerateRandomNumber()) >> 4;
ntrig = 0;
latch = 0;
ptrig = 0;
pval = 0;
mtrig = 0;
// change
if ((pval != inlet_i) & (!ptrig)) {
pval = inlet_i;
ptrig = 1;
} else {
ptrig = 0;
}
// prob
if ((ptrig > 0) && !ntrig) {
val = (int32_t)(GenerateRandomNumber()) >> 4;
ntrig = 1;
} else if (!(ptrig > 0))
ntrig = 0;
// latch
if (((param_prob > val) > 0) && !mtrig) {
latch = inlet_i;
mtrig = 1;
}
if (!((param_prob > val) > 0))
mtrig = 0;
outlet_o = ((param_prob > val) > 0) ? latch : inlet_i;