Add IGMP Multicast Joiner and PTP Slave Core (IEEE 1588v2, Layer 3).#199
Merged
enjoy-digital merged 11 commits intomasterfrom Apr 2, 2026
Merged
Add IGMP Multicast Joiner and PTP Slave Core (IEEE 1588v2, Layer 3).#199enjoy-digital merged 11 commits intomasterfrom
enjoy-digital merged 11 commits intomasterfrom
Conversation
Add LiteEthIGMPJoiner that periodically sends IGMPv2 Membership Reports for configured multicast groups via the IP crossbar. This allows switches with IGMP snooping to forward multicast traffic (e.g. PTP) to this port. The joiner uses a simple 3-state FSM (WAIT/SEND/GAP) with pre-computed payloads via combinational Case lookup.
Test checksum computation, FSM hang-free operation (single and multi-group), and end-to-end IGMP packet content verification at PHY output level.
Add with_igmp, igmp_groups and igmp_interval parameters to LiteEthIPCore and LiteEthUDPIPCore, following the same pattern as ICMP. When enabled, the IGMP joiner is instantiated inside the core, running in the same clock domain as the IP crossbar and avoiding external CDC complexity.
Add LiteEthPTP, a complete PTP Slave implementation for Layer 3 (UDP/IPv4) with: - TSU with 48-bit seconds / 32-bit nanoseconds and addend-based tick accumulation - TX/RX packetization with depacketizer and timeout recovery - Pipelined clock servo with phase correction and frequency trim - E2E and P2P delay mechanisms - Outlier detection and seconds-boundary correction - Snapshot-based monitoring with common and debug CSR variants
test_ptp.py (27 tests): HDL simulation tests covering TSU (counting, rollover, offset, addend), RX (depacketization, field extraction, rejection, timeout), TX (packetization, P2P mode), and top-level integration (E2E exchange lock, timeout, domain filtering, error counting). test_ptp_servo.py (89 tests): pure-Python mirrors of the servo algorithms covering signed delta computation, outlier detection, coarse step, frequency trim, exchange validity classification, queued Sync skip logic, seconds adjustment, addend clamping, shadow addend, TSU tick/offset race, and servo convergence.
Minimal SoC with Etherbone, PTP slave, and IGMP multicast support. Provides a self-contained bench for testing PTP on the Arty without the full digilent_arty target complexity. Usage: python3 bench/arty_ptp.py --build --load python3 bench/arty_ptp.py --build --load --ptp-debug python3 bench/arty_ptp.py --build --load --p2p
RemoteClient-based PTP monitor with: - Table-style output with periodic column headers - Color-coded phase error, lock status, and servo flags - Optional debug fields (timestamps, offsets, frequency step) - Summary statistics (min/max/avg phase and delay) - CSV export and matplotlib plotting Usage: python3 bench/test_ptp.py --count 100 python3 bench/test_ptp.py --count 100 --debug python3 bench/test_ptp.py --count 100 --plot --csv-out data.csv
Document how to configure and run ptp4l as a PTP master for testing the bench design, including the required config file and monitor commands.
Use a dedicated sys_eth PLL output (same frequency as sys) for the PTP core and UDP ports. This avoids crossing from sys to eth_rx through the async FIFO on every packet, reducing Delay_Req/Resp latency to match the original digilent_arty design.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This pull request adds PTP (IEEE 1588v2) Slave support to LiteEth, along with IGMP multicast group management required for switch compatibility. It introduces an
LiteEthIGMPJoinermodule for multicast group registration and a completeLiteEthPTPSlave core with TSU, clock servo, protocol FSM, and monitoring — all operating over Layer 3 (UDP/IPv4) transport. This enables microsecond-level clock synchronization over standard Ethernet infrastructure using software timestamping on the master side.All changes are fully backward compatible — IGMP and PTP are disabled by default and existing designs are unaffected.
Summary of Features
1. IGMP Multicast Group Joiner (
core/igmp)LiteEthIGMPJoinerPeriodically sends IGMPv2 Membership Reports for configured multicast groups via the IP crossbar. Allows switches with IGMP snooping to forward PTP (or other) multicast traffic to the FPGA port.
Core Integration
with_igmp,igmp_groups,igmp_interval) inLiteEthIPCore,LiteEthUDPIPCore, andadd_etherbone.2. PTP Slave Core (
core/ptp)TSU (Time Stamping Unit)
48-bit seconds / 32-bit nanoseconds timestamp counter with addend-based tick accumulation. Supports offset correction (phase/seconds adjust) and coarse step for initial lock.
TX/RX Packet Handling
Packetizer for Delay_Req/Pdelay_Req transmission with TSU TX latch on first byte. Depacketizer with PTP header/body extraction, version/domain validation, and timeout-based deadlock recovery.
Clock Servo
Protocol Control FSM
Manages the full E2E/P2P exchange sequence (WAIT_SYNC → WAIT_FUP → SEND_DELAY_REQ → WAIT_DELAY_RESP → SERVE → LOCKED). Handles master IP learning, sequence ID tracking, peer/requester validation, stale Sync skip, and announce timeout.
Snapshot-based Monitor
Coherent CSR snapshots of PTP state (phase, delay, addend, timestamps, servo flags) for Etherbone reads. Common and debug CSR variants.
Delay Mechanisms
End-to-End (E2E) and Peer-to-Peer (P2P) delay measurement supported, selectable at runtime.
3. Bench Design and Test Utility
bench/arty_ptp.pyMinimal Etherbone + PTP Slave design for Arty A7 with IGMP, dedicated
sys_ethclock domain for PTP isolation, andptp4lmaster configuration instructions in the file header.bench/test_ptp.pyRemoteClient-based PTP monitor with:
Validation
Validated on Arty A7 with
ptp4lmaster (software timestamping, E2E, UDP/IPv4). Steady-state phase error ±200–900ns (limited by host-side software timestamp jitter).Unit test coverage (120 tests total):
test/test_igmp.py— 4 tests: checksum verification, FSM hang-free operation (single/multi-group), end-to-end IGMP packet content at PHY output.test/test_ptp.py— 27 HDL simulation tests: TSU (counting, rollover, offset, addend), RX (depacketization, field extraction, rejection, timeout), TX (packetization, P2P mode), top-level integration (E2E exchange lock, timeout, domain filtering, error counting).test/test_ptp_servo.py— 89 pure-Python tests: signed delta computation, outlier detection, coarse step, frequency trim, exchange validity, queued Sync skip, seconds adjustment, addend clamping, shadow addend, TSU tick/offset race, servo convergence.