This is to add the restart mechanism for auto-negotiation under 1000BASE-X, as well as fixing some incorrect logic in my original SGMII implementation on the PCS. The missing restart mechanism is most likely the root cause for issue https://github.com/m-labs/artiq/issues/1562.
Changes
Removes fsm_init that enables writing tx_config_reg only after the auto-negotiation state machine has started; the PCS should start transmitting in the beginning before setting the ACK bit of tx_config_reg.
Not only should the PCS start transmitting, but it also should transmit blank config_reg as a "breaklink" mechanism as specified by the state diagram of the 1000BASE-X standard (Fig. 37-6, Section 3, IEEE Std 802.3-2002).
The logic involving detection of ability match and acknowledgement match (lines 438-447) has been re-written as simple as possible, similar to what it was before SGMII was implemented (b0b5ee954fe553f46952711c6e2dbee4b1412089).
Adds linkdown signal to automatically restart auto-negotiation.
Detection of link up should differ between 1000BASE-X and SGMII modes: the prior simply needs the config_reg to be non-zero, while the latter needs the MSB of config_reg to be 1.
Cross-domain crossing should now be properly handled - the ability detected from reading rx_config_reg in the RX domain needs to be written to the tx_config_reg in the TX domain, especially for SGMII mode that encodes the link speed to the config_reg.
Summary
This is to add the restart mechanism for auto-negotiation under 1000BASE-X, as well as fixing some incorrect logic in my original SGMII implementation on the PCS. The missing restart mechanism is most likely the root cause for issue https://github.com/m-labs/artiq/issues/1562.
Changes
fsm_init
that enables writing tx_config_reg only after the auto-negotiation state machine has started; the PCS should start transmitting in the beginning before setting the ACK bit of tx_config_reg.linkdown
signal to automatically restart auto-negotiation.Reference Materials