# Research on Clock Synchronization of Data Acquisition Based on NoC
## 4 The Implementation of Clock Synchronization
### The Implementation of PTP
In the forwarding process, the transparent clock node forwards the clock message to the corresponding destination node by identifying the destination address in the message. In the process of transmitting the message to the transparent clock node, when the address in the message is detected as 4'b1111 (sync and follow_up packets) request signals req_to_e and req_to_w are sent to the slave clock node in the east and west directions, respectively. Then, when the transparent clock node receives grant_from_e and grant_from_w signals from the slave clock node in the east and west, it sends the message to the corresponding node, as shown in Figure 10.  
For example, when transparent clock node 8 selects the message output from the slave clock node (node 9) in the east, it receives the clock message after shaking hands with the  
Figure 10: The state transfer of the transparent node. In the process of sending clock messages from the east and west clock nodes to the transparent clock node, when the transparent clock node receives the request signal req_from_x (e/w) from the east and west slave clock nodes at the same time, fixed priority is adopted to output the message from the east slave clock node first. east direction node. Then, transparent clock node 8 generates the request signal req_to_e_n and assigns the request signal req_to_n of the node, and then, sends it to master clock node 5. After successful handshake with master node 5, the message from the east slave node (node 9) will be output. When the message output of the slave node (node 7) in the west direction is selected, it follows the same steps, except that the generated req_to_w_n request signal is assigned to the request signal req_to_n of the node. When a destination address other than 1111 is identified, it will shake hands with the corresponding node and forward its clock message according to the specific address. The implementation of the slave node  
The slave clock PTP synchronization module is responsible for receiving sync, follow_up, and delay_resp messages sent by the master clock node, and sending delay_req messages to the master clock node. In the SYNC state of the master node, the slave clock node shakes hands with the transparent clock node or the master node, and then, receives the sync message and records the timestamp of T2 at the received time with the slave clock's time axis. Next, in the FOLLOW state of the master node, the follow_up message is received again through a handshake, and the T1 timestamp in the message is read. Then, in the DELAY_REQ state of the master node, a delay_req message is sent to the master node by handshake, and the sending time T3 is recorded. Finally, the delay_resp message sent by the master node is received by handshake, and the T4 timestamp in the message is read. After obtaining the four timestamps of T1, T2, T3, and T4, Equations (1)-(8) are used to calculate the clock offset between the master and slave nodes, and then, the clock offset is subtracted from the slave clock to achieve the coarse synchronization.