I've been working on a VGA controller on a DE2 for a while and I can't get the sync to work right. When I connect this to a monitor, the monitor says "out of range" meaning it's getting the signal, but the sync timing seems to be wrong. For the clock, I'm sending a 50 MHz clock through a PLL that brings it down to 25MHz and the resolution is 640 x 480. Can anyone recommend anything to fix it?
Its difficult to find the cause of error by going through your source code. Have you tried to simulate it ? When the monitor says "out of range" does it refers to Vsync or Hsync ? It may be possible that the Vsync or Hsync is being counted wrong. But this can only be checked through simulation.
One more thing. I would suggest you to use DCM instead of PLL for generating clock freq. DCM can support a min of 25 MHz, so it should not be a problem.