// Convolutional Encoder for UMTS system with rate 1/2 and constraint 
// length K=9
/*working very will*/
module conv_encoder_K_9(data_out, data_in, clk, reset);
    
       output [1:0] data_out;
       input  data_in, clk, reset;

       reg [7:0] shift_reg;
       reg [1:0] mod_out;
       reg a1, a2, n1, or_out;

       always @ (posedge clk)
       if(!reset)
        begin
          shift_reg = 8'b0;
          mod_out = 2'b00;
        end
       else
        begin
         
             // Module 2 output
             mod_out[0] = (data_in ^ shift_reg[3]) ^ (shift_reg[4] ^ shift_reg[5]) ^ (shift_reg[7]);
             mod_out[1] = (data_in ^ shift_reg[0]) ^ (shift_reg[2] ^ shift_reg[4]) ^ (shift_reg[5] ^ shift_reg[6]) ^                                          (shift_reg[7]);

             shift_reg[7:1] <= shift_reg[6:0];
             shift_reg[0] <= data_in; 
         end        
        assign data_out = mod_out;
endmodule