The Advanced Wakefield Experiment (AWAKE) aims at studying the proton-driven plasma wakefield acceleration technique for the first time. The testing facility, currently being built at CERN, uses the proton beam at a momentum of 400 GeV/c from the Super Proton Synchrotron (SPS) to accelerate an electron beam to the GeV scale over 10 m of plasma. In order to achieve such an acceleration gradient, the reference signal of the low-level RF (LLRF) system controlling the proton beam must keep in-phase with the reference signal used to generate the electron beam and plasma (laser). Even though the SPS LLRF system is located about 3 km away from the laser and electron beam electronics, the phase drift between the three references has been specified to be in the sub-picosecond range. In order to cope with the experiment requirements, we have developed a custom VME board and a digital control system embedded in a FPGA to compensate for the phase drift between the reference signals at both ends of the optical links. In this work, we present the results of the study developed to analyze the expected phase drift, the selected method to compensate it and the performance of the first prototypes of the board. The use of a very precise phase detector and digitally controlled delay lines, both in the level of tens of femtoseconds allow tracking the phase drifts and compensate for them with a very high precision. Measurements of the achieved precision in the developed module have shown to be in the sub-picosecond range, as demanded by the experiment requirements.