A nuclear spectrum generator for semiconductor X-ray detectors is designed in this paper. It outputs step ramp signals with random distribution in amplitude and time according to specified reference spectrum. The signals are similar to the signals from an actual semiconductor X-ray detector, and can be use to check spec- trum response characteristics of an X-ray fluorometer. This helps improving energy resolution of the X-ray fluorometer. The spectrum generator outputs step ramp signals satisfying the probability density distribution function of any given reference spectrum in amplitude through sampling on the basis of 32-bit randomizer. The system splits 1024 interval segmentation of the time that the step ramp signals appear, and calculates the ap- pearance probability of step ramp signals in different intervals and the average time between the time intervals, by random sampling. The step ramp signals can meet the rule of exponential distribution in time. Test results of the spectrum generator show that the system noise is less than 2.43 mV, the output step ramp signals meet the Poisson distribution in counting rate and the probability density distribution function of the reference spectrum in amplitude. The counting rate of the output step ramp signals can be adjusted. It meets the rule of the output signals from semiconductor X-ray detectors, such as Si-pin detector and silicon drift detector.