Logic phase shift detection
XOR both signals, the pulse train and the state one. Use this result as the clock for a positive edge trigger latch and the state signal as the value to latch. In state A the latch output is high and in state B the latch output is low.