Altera's DRAM Controller with UniPHY
The clocks are used as follows:

pll_ref_clk = The clock which is fed in to the input of the PLL. This has to match whatever setting you have in the IP core so that the correct memory clock frequency will be generated.

afi_clk = This is the clock used for the Avalon-MM interface. There is a corresponding reset signal afi_reset which is synchronous (on Deassert I think) with afi_clk.

afi_half_clk = This is optional and is enabled by a parameter on the IP core. Basically this is a clock synchronous to afi_clk but at half the frequency.

So when you are interfacing the Avalon-MM interface you should be using the afi_clk for your logic.



The frequency of the clocks is dependent on your IP core settings. Basically you specify the memory frequency which is the clock speed used for the physical memory. There is then a parameter which allows you to select a mode of operation for the Avalon-MM interface. You have the following options:

Full Rate = The Avalon-MM interface operates at the same frequency as the memory. For DDR RAM, you have data clocked on both edges, but internally you cannot do that, so to achieve the same data rate, the output interface is twice the width of the memory.

Half Rate = The clock frequency of the Avalon-MM interface is half the frequency of the memory. Consequently the output interface is now quadruple the width of the memory.

Quarter Rate = You get the pattern by now. Quarter the clock frequency, so data width is 8 times the width of the memory.

These different rate settings allow you to run the memory much faster than the core logic of the FPGA can run at (the periphery of the FPGA is much faster than the core). So for example you can have a 32bit 800MHz DDR chip which presents itself internally as a 200MHz 256bit wide data bus.



As to why they were using the PLL reference clock for the Nios processor in the reference design, who knows. There are many little mistakes here and there that you will find with the documentation and example designs from Altera.