Programmable Devices
CPLDs, FPGAs, SoC FPGAs, Configuration, and Transceivers
20688 Discussions

Acessing Data on GMII

Altera_Forum
Honored Contributor II
1,054 Views

Hi folks, 

 

at the moment i am planning the architecture of the project of my final thesis. I want to implement a Timestamping-Unit(TSU) for the PTP-Protokoll (IEEE1588).  

The ptp i want to set on the top of an udp-Stack (nichie). The main issue at this topic is where to place the TSU.  

There are two possibilities: 

 

1. niosII -> TSU -> MAC -> PHY 

- easier to implement 

- not as precisely as the second one 

2. niosII -> MAC -> TSU -> PHY 

- difficult to implement 

- more precisely  

- better solution if it works 

 

In my opinion the first one is easier to implement, i have only to implement an avalon-Interface. There are a lot of howtos/walkthroughs etc. The problem at the first solution is, that the time is recorded on a much higher layer than in the second solution. The closer the line, the better the precision of the Timestamp.  

 

The main issue of the second solution is, how to connect the TSU to GMII/RGMII. Also the TSU have to extract some information in the packets change it and recalculate the CRC-s and rebuild the Packet. 

 

My question is now, have anybody of you experience in accessing/listening /change data at GMII/RGMII ? Can u serve me some Howto's,Walkthroughs,Examples etc.?  

 

best regards 

 

mooresstudent
0 Kudos
4 Replies
Altera_Forum
Honored Contributor II
310 Views

You don't have to modify the packets to implement PTP, you just have to timestamp them. I think that the only application that would require to modify the packets in a PTP 2.0 compliant Ethernet switch. 

You are right that the second possibility is the most accurate. One way to do it is to monitor the (R)GMII signals to detect if a PTP sync packet is being sent or received. The TSU would need to detect the preamble and SFD to timestamp the packet, and then read the other bytes to check if the packet is IP, UDP, and on the correct port number. It isn't too difficult to do. It can then report the timestamp to the software layer. 

I have made a PTP implementation on Nios, but unfortunately I can't share it here as it is my company's IP. For the software side you can have a look at this project: http://ptpd.sourceforge.net/doc.html
0 Kudos
Altera_Forum
Honored Contributor II
310 Views

I am very sorry to respond only now, but i was away for the last 3 days. 

 

Hm maybe my understanding isn't right,please correct me if i am wrong. 

In my opinion i have to change the timestamp only in the Sync-packet if the device acts as master and sending this sync packet. If i timestamp it at NIOSII i got an jitter in the delay ? For most accuracy i have to stamp it near the line.  

 

I agree with you Daixiwen, that i only have to timestamp the incomming of packets (there are no need of modification in the packet). But at sending the tsu have to modify the timestamp and CRC packets. Do I miss a point ? 

 

But back to my main question; do u have any examples of accessing the gmii or is it really as easy as i think it is. And the second question how to u deliver the timestamps to nios ? Through a memory fifo or via attaching the timestamp to the pakets. 

 

best regards
0 Kudos
Altera_Forum
Honored Contributor II
310 Views

You need a combination of hardware and software. What we did is to have a hardware counter that runs on a fast clock. We inspect the MII interface, sample the value of the counter at the beginning of the packet and place the timestamp value in a FIFO. The contents of the FIFO can be read back through an Avalon MM interface, so the software can read it back. 

You also need to store a bit more information in the FIFO with each timestamp so that the software can know which timestamp comes from which packet, but I think you got the main idea. 

 

You don't need to modify the packets contents because the timestamp that you need to place in the sync packet is the timestamp of the previous packet. The software has plenty of time to read the timestamp value and prepare the next sync packet to send, and you can use the regular UDP/IP stack to generate the packet. 

 

And yes, reading a GMII interface is really easy. The packet starts when the data valid signal is asserted, and then you read the preamble, SFD (timestamping point), Ethernet header, IP header, UDP header, UDP data. Our VHDL module reads all the packet contents to detect if it is a UDP packet, on the expected port, and puts the timestamp in the FIFO only if it is a PTP sync packet, together with an ID number that can let the software know which packet the timestamp came from.
0 Kudos
Altera_Forum
Honored Contributor II
310 Views

Thank you very much, for your patience. The partioning in hardware and software was clear, also the combination of the ID and the Timestamp.  

But at beginning of the thread i missed the point, that i have only to send the timestamp of the last packet. Now i reread some Papers, and now it is clear. Thank you for the enlightenment.  

The next step will be to build a testenviroment, and then build a filtermodule like you mentioned previously. 

 

best regards 

mooresstudent
0 Kudos
Reply