Costas loop design and implementation