In my design, I want to design a CPU DDR interface. FPGA is as the slave device which is considered as DDR chip by CPU. Can I use a MIG IP to generate the DDR interface, keep the PHY and change the upper code?
If so, how can I generate the initialization signals?
This has easy accessibility through the AXI interface that allows for external access to the MIG. If your CPU is a Zynq device or a Microblaze architecture you can easily connect via the AXI interface to access DDR in this manner. There is also a Application/User interface version that you could use to connect to a custom IP if you did not want to utilize an AXI interface (though most of our IP is AXI-based so would be best off to use that).
Alternatively, you can also create a custom controller on top of a PHY-only design, but note that this is quite difficult and there is not much/any support Xilinx can provide above what is documented in PG150. This would be a design effort completely on your end to work from the PHY upwards. Again, since this would be much more difficult I would suggest using the AXI interface version unless you have a specific design need that our controller cannot meet. The PHY Only interface is described starting on page 161.