Designing encoder in a receiver must be done before designing Viterbi decoder inside a transmitter since output of the encoder will become input of the Viterbi decoder.
A polynomial description of a convolutional encoder describes the connections among shift registers and modulo-2 adders. The figure beside depicts a convolutional encoder that has one input, two outputs, and two shift registers. The convolutional encoder produces two bits encoded information for each bit of input information, so it is called as a rate 1/2 encoder.
Equations of the 1/2 encoder are as follow:
Y[0] = X[n] XOR X[n-1]
Y[1] = X[n] XOR X[n-1] XOR X[n-2]
The following are Verilog coding for 1/2 code rate encoder that comprises two D Flip-Flops and XOR gates.