Binary encoder has 2n input lines and n-bit output lines. VHDL Code for 4 to 2 encoder can be designed both in structural and behavioral modelling.