We propose and numerically validate an all-optical scheme to generate a train of optical pulses. Modulation of a continuous wave with a periodic binary temporal phase pattern followed by a spectral phase shaping enables us to obtain ultrashort pulse trains. An ideal step phase profile as well as a profile arisen from a bandwidth-limited device are investigated. Analytical guidelines describing pulse trains formation and their characteristics are provided.