I have a periodic external pulse signal. My FPGA generates a pulse signal with the same frequency by a state machine. I want to align the phases of the two pulses. I managed to achieve perfect alignment with an external PLL (Phase Detector within FPGA) by using the VCO output as the MCLK to the FPGA (Cyclone III). But I can't think of a good way to implement the whole circuit in the FPGA. Any suggestion is appreciated.
Depends on the external signal frequency and frequency range. There are many ways to implement a digital PLL in the FPGA. For fast signal PLL dynamic fast shift is a possible option.