A method to generate a time for an autonomous driving vehicle, ADV, the method comprising: receiving, at a sensor unit, a global positioning system, GPS, pulse signal from a GPS sensor of the ADV, wherein the sensor unit is coupled to a plurality of sensors mounted on the ADV and a host system, wherein the host system is to perceive a driving environment surrounding the ADV based on sensor data obtained from the sensors and processed by a processing module of the sensor unit and to plan a path to autonomously drive the ADV based on perception data; receiving a first local oscillator signal from a local oscillator of the sensor unit; synchronizing the first local oscillator signal to the GPS pulse signal in real-time, including modifying the first local oscillator signal based on the GPS pulse signal; and generating a second oscillator signal based on the synchronized first local oscillator signal, wherein the second oscillator signal is provided to at least one of the sensors to be used as a clock signal to operate the sensor unit; wherein synchronizing the local oscillator comprises: generating a first counter having a first granularity using the local oscillator; monitoring the first counter to count a number of oscillations at the first granularity to reach a time interval of the GPS pulse signal, wherein each count represents an oscillation at the first granularity; calculating a first count value based on the monitored first counter at the first granularity; and modifying the first counter so that each count represents a fraction of an oscillation at the first granularity based on the calculated first count value to synchronize the local oscillator at the first granularity; wherein the method is characterized in that synchronizing the local oscillator further comprises: generating a second counter having a second granularity using the local oscillator; monitoring the second counter to count a number of oscillations at the second granularity to reach a time interval of the GPS pulse signal, wherein each count represents an oscillation at the second granularity; calculating a second count value based on the monitored second counter at the second granularity; and modifying the second counter so that each count represents a fraction of an oscillation at the second granularity based on the calculated second count value to synchronize the local oscillator at the second granularity. receiving, at a sensor unit, a global positioning system, GPS, pulse signal from a GPS sensor of the ADV, wherein the sensor unit is coupled to a plurality of sensors mounted on the ADV and a host system, wherein the host system is to perceive a driving environment surrounding the ADV based on sensor data obtained from the sensors and processed by a processing module of the sensor unit and to plan a path to autonomously drive the ADV based on perception data; receiving a first local oscillator signal from a local oscillator of the sensor unit; synchronizing the first local oscillator signal to the GPS pulse signal in real-time, including modifying the first local oscillator signal based on the GPS pulse signal; and generating a second oscillator signal based on the synchronized first local oscillator signal, wherein the second oscillator signal is provided to at least one of the sensors to be used as a clock signal to operate the sensor unit; generating a first counter having a first granularity using the local oscillator; monitoring the first counter to count a number of oscillations at the first granularity to reach a time interval of the GPS pulse signal, wherein each count represents an oscillation at the first granularity; calculating a first count value based on the monitored first counter at the first granularity; and modifying the first counter so that each count represents a fraction of an oscillation at the first granularity based on the calculated first count value to synchronize the local oscillator at the first granularity; wherein the method is characterized in that synchronizing the local oscillator further comprises: generating a second counter having a second granularity using the local oscillator; monitoring the second counter to count a number of oscillations at the second granularity to reach a time interval of the GPS pulse signal, wherein each count represents an oscillation at the second granularity; calculating a second count value based on the monitored second counter at the second granularity; and modifying the second counter so that each count represents a fraction of an oscillation at the second granularity based on the calculated second count value to synchronize the local oscillator at the second granularity.