Below is the VHDL code for 4bit binary to gray code converter. It can done here by using dataflow modelling. You can use the modelling to reverse the conversion eg. Gray to Binary conversion.
CODE FOR 4 BIT Binary To Gray Converter
Multiplexer is simply a data selector.It has multiple inputs and one output.Any one of the input line is transferred to output depending on the control signal.