frac32 in1
frac32 in2
frac32 sum
bool32 out
bool32 inv
frac32.u.map.gain Gain1
frac32.u.map.gain Gain2
frac32.s.map Offset
frac32.u.map Hysteresis
bool32 cmp
int32_t diff;
int32_t hyst;
bool prevstate;
bool state;
prevstate = 0;
state = 0;
diff = (___SMMUL(param_Gain1, inlet_in1) << 1) -
(___SMMUL(param_Gain2, inlet_in2) << 1) + param_Offset;
if (!prevstate) // if previous state is zero (signal1<signal2)
hyst = param_Hysteresis; // set the comparation term to the positive value
else
hyst = -param_Hysteresis; // set te comparation term to the negative value
prevstate = state;
if (diff > hyst)
state = 1;
else
state = 0;
disp_cmp = state;
outlet_out = state;
outlet_inv = !state;
outlet_sum = diff;