We perform 3D modeling of earthquake generation of the Xianshuihe fault, southwestern China, which is a highly active strike-slip fault with a length of about 350 km, in order to understand earthquake cycles and segmentations for a long-term forecasting and earthquake nucleation process for a short-term forecasting. Historical earthquake data over the last 300 years indicates repeated periods of seismic activity, and migration of large earthquake along the fault during active seismic periods. To develop the 3-D model of earthquake cycles along the Xianshuihe fault, we use a rate- and state-dependent friction law. After analyzing the result, we find that the earthquakes occur in the reoccurrence intervals of 400-500 years. The earthquake firstly occurs in the middle part of the fault in the year of 372. Then the second earthquake in the year of 858 occurs only along the main part of the fault but not the 0-100km part. After two earthquake cycles, the fault has been divided into 3 segments, which means since the third earthquake cycle, earthquake ruptures only occur in some parts of the fault, but not the whole fault line. This may be caused by the shape of the fault which has some bending parts. After comparison of the slip velocity at different depths, we find that the largest slip velocity occurs at the depth of 10km which is the exact depth of the seismic zone where fast rupture occurs.