Repository navigation
clock/intel, liblitedram: ALTPLL dynamic phase shift and SDRAM clock phase leveling at boot (SDR). - #2756
Merged
Conversation
…ock phase leveling (SDR). IntelClocking.expose_dpa(clkout): ALTPLL PHASESTEP/PHASEUPDOWN/PHASECOUNTERSELECT/ PHASEDONE on one output (MAX 10, Cyclone IV, Cyclone 10 LP). Quartus chooses its own VCO, so with DPA the VCO search is limited to whole-picosecond steps and the step is pinned (VCO_FREQUENCY_CONTROL = MANUAL_PHASE): dpa_steps() is the hardware's step count. IntelPLLPhaseStepper: CSR control (dir/step/busy/position/steps). liblitedram: sdram_clk_phase_leveling(), run by sdram_init() and sdram_cal when the SoC has a sdram_clk_phase module: JEDEC init and a write/read check at every step over one SDRAM clock, the phase to the middle of the longest window. Tested on a DE10-Lite (HalfRateGENSDRPHY, 142.86 MHz CL3): from a 0 degree build, window of 34/56 steps, phase moved +148 degrees, memtest OK. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This was referenced Nov 3, 2026
Merged
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.
SDR SDRAM on Intel FPGAs (LiteDRAM
GENSDRPHY/HalfRateGENSDRPHY) gets its SDRAM clock from an ALTPLL output, usually at a hand-picked static phase. That phase sets both the command setup/hold at the SDRAM and where read data lands at the FPGA's capture registers. Its working window depends on the frequency, the CAS latency, the board and the placement. Example on a DE10-Lite at 142.86 MHz CL3: two builds of different designs, with different VCOs, put the window at 45-326° and 38-251°. A table of phases per frequency doesn't hold up.This PR lets the BIOS find the phase at boot.
Gateware (
litex/soc/cores/clock/intel_common.py)IntelClocking.expose_dpa(clkout, cd="sys"): the ALTPLL dynamic phase shift of one output (PHASESTEP/PHASEUPDOWN/PHASECOUNTERSELECT/PHASEDONE,SCANCLKfromcd). Same name as the ECP5/Gowin APIs. Enabled on MAX 10, Cyclone IV and Cyclone 10 LP (altpll_dpa).VCO_FREQUENCY_CONTROL = "MANUAL_PHASE"/VCO_PHASE_SHIFT_STEP;dpa_steps()then matches the hardware: 142.86 MHz → VCO 1000 MHz, 125 ps, 56 steps. The fit report confirms the VCO and step.IntelPLLPhaseStepper(pll): CSRsdir,step(one step per write: PHASESTEP held until PHASEDONE goes low, done when it is back high, with a timeout),busy,position,steps.BIOS (liblitedram)
sdram_clk_phase_leveling()runs insdram_init()when the SoC has asdram_clk_phasemodule, and fromsdram_cal.Usage (target):
Tested
test/cores/test_clock.py:dpa_steps()× step = period, the ALTPLL parameters, error cases;test/cores483 passed,test/build223 passed,test/software57 passed.test/sochas the same 15 failures as master: CPU integration tests for toolchains not installed here, andtest_serialboot_abort_recovers_and_loads.HalfRateGENSDRPHYat 142.86 MHz CL3 with phy/gensdrphy: Fix HalfRateGENSDRPHY read data pairing at CL3. litedram#460), Quartus 23.1. The bitstream deliberately starts at 0°, which fails at that frequency:reboot(PLL phase kept) and fromsdram_cal, the scan starts at step 23, finds the same window and stays there. The 4 MiB memtest passes afterwards.Written by an AI agent (Claude Code), supervised by Florent Kermarrec.
🤖 Generated with Claude Code