Synthesis of Finite State Machines for Programmable Devices