accu_sat

Saturating accumulator. Adds input to accumulator on trigger. Reset clears the accumulator to zero.
Author: Johannes Taelman
License: BSD
Github: math/accu_sat.axo

Inlets

bool32.rising trigger

bool32.rising reset

frac32 input

Outlets

frac32 output

Declaration
int ntrig;
int rtrig;
int accu;
Init
ntrig = 0;
rtrig = 0;
accu = 0;
Control Rate
if ((inlet_trig > 0) && !ntrig) {
  accu += inlet_i;
  ntrig = 1;
  accu = __SSAT(accu, 28);
}
if (!(inlet_trig > 0))
  ntrig = 0;
if ((inlet_rst > 0) && !rtrig) {
  accu = 0;
  rtrig = 1;
}
if (!(inlet_rst > 0))
  rtrig = 0;
outlet_o = accu;

Privacy

© 2024 Zrna Research