Thanks @artvvb
Another aspect that I've noticed about the example code, it assumes that the decoder will always land at a detent position where A=1 and B=1 ("idle" state).
If you have an encoder which doesn't have detents or the encoder has, say, 30 detents and 15 positions, the logic may not function properly. In either case, it's unlikely (50% at best) that the encoder will rest in the "idle" state.
I appreciate that the code was written specifically for the Pmod part, but maybe it could have been more universal to use the circular logic (below) as opposed to the L-R strategy in the example?
Just a thought!