This example is a slightly modified version of the  currently available on Altera's website. It still only functions (out of the box) on a Stratix II 2s60 (non-RoHS) development kit, but the design has been rebuilt in 9.0sp2 and Software Build Tools (command line flow) support has been added.
Hardware Design Specifications
Board support: Nios Development Board, Stratix® II edition (non-RoHS)
Instructions are provided for porting the design to your board
Device support: Stratix II devices only because of PLL reconfiguration features
Not supported on Stratix II EP2S15 because of memory requirements
The concept of the design is to shift the phase delay of the clock connecting to the offchip memory (an SDRAM for this design) across a "window" of time, record the phase delays where the memory tests successfully and then choose the middle area of that "success window" as the "ideal" SDRAM clock phase shift.
Full instructions are included in "readme.txt" in the top-level of the design example.