I appreciate having the feedback with your resolution. It's often the simple things are escape our analysis when things don't work the way we expect. No matter how long you engage in software or FPGA development the little, seemingly innocuous, details are likely to bite you..
I have this sense that if you keep describing what you did you will answer your own question. I don't have enough information yet to help. [I confess that I haven't bothered to read through your code]
Verbalizing problems, if you go into enough detail, is often a fairly reliably way to resolve them. Sometimes it helps to have someone throw in a good question or two.