Simultaneous fabrication of periphery and memory cells