That “slip” is inherent to the ping pong design that I specified. Assuming 4 steps - 1,2,3|4,3,2|1,2,3| . . .
Yes there are 4 total steps, but the “phrase” is effectively 3 steps, not 4.
I think more than worrying about how to implement something, you first need to be clear and precise about what you are trying to achieve.
I suspect you want the ping pong pattern to repeat the 1s/last step each time. In other words - 1,2,3,4|4,3,2,1|1,2,3,4| . . .
That requires a different implementation. Perhaps the easiest is to switch which step is used to trigger the direction change. If moving forward, then change direction on step 1. If moving backward, then change direction on the last step. But you can’t change direction the first time you reach the trigger step. Instead the first time it is reached you need to arm the direction change. Then the next time it actually triggers the direction flip flop. Also, use the original clock signal to trigger the flip flop, not the falling edge trigger.
So if moving forward at the last step and the direction change is already armed, then the next forward step trigger moves to step 1. The First gate is ANDed with the triggering gate, and the direction is immediately switched at the flip flop. This redirects the triggering clock to the backward trigger, and step one is immediately left and the sequencer goes back to the last step. So the step one was so fast, it is virtually skipped, and the last step is effectively repeated. Upon re-entry to the last step, it must arm the direction change so that the next time the last step is entered, it changes back to forward. etc.
In summary, the trick to make things work depends on the pattern you want.
ping pong, do not repeat first/last step:
- If forward, then Last changes direction. If backward, then First changes direction.
- change direction on triggering clock falling edge to prevent immediate exiting of the step
ping pong, do repeat first/last steps:
- if forward, then First changes direction. If backward, then Last changes direction.
- The first time the triggering step is reached, arm the direction change. Only change direction on the second entry.
- change direction on the leading edge of the triggering clock so the step is exited immediately, almost as if it was never fired, and the previous step is effectively repeated.