The value at output AQ increases by 1 with each pulse at the input Tr.
You can define the maximum count number with the parameter EV, and when this maximum count value is reached the output Q goes to 1.
The parameter M is used to decide whether when AQ reaches EV the counter is reset to start from the beginning or whether the counter remains at the maximum value. By default M causes a loop, to set the counter to stop at the maximum value set M to 1.
A pulse at the input R causes the counter to be reset to zero.