A new design methodology for the design of optimal spread-spectrum sequences for asynchronous code-division multiple access (A-CDMA) and chip-synchronous CDMA (CS-CDMA) systems is proposed. We derive general results on the partial auto-correlation function of the optimal spreading sequences for CS-CDMA and A-CDMA systems with respect to the minimization of the average bit error rate under the standard-Gaussian-approximation condition without assuming the spreading sequences as independent stationary random processes. Based on the ergodic theory, a practical implementation of the optimal spreading sequence by using chaotic dynamical systems with Lebesgue spectrum is provided and the corresponding system performance is analyzed.