That's right. The signals across the different clock domain is the designer guarantee that can work correctly.So you must to modify the code. The gray code is the general purpose method to do the signal across two different
clock domain. I hope it can help your reference.