hamming decode how can i write a verilog code that will take an input of 7 bit word and detect the error using even parity and correct it

module Hamming_Decoder_MD3(H_word , error , correct);




input (6:0)H_word; //receiver msg
output (2:0)error; // calculate the error in the msg if occur
output (6:0)correct; // the coorect msg


integer P1 , P2 , P3; //to calculate the error
integer i; //used in for loop




always @(H_word) // check every bit in the 7 bit message
    begin//1
     if(H_word(0) ^ H_word(2) ^ H_word(4) ^ H_word(6))//check P1,D3,D5,D7
       begin//2
         assign P1 = 1;
       end//2
     else
      begin//3
        assign P1 = 0;
      end//3
    if(H_word(1) ^ H_word(2) ^ H_word(5) ^ H_word(6))//check P2,D3,D6,D7
       begin//4
         assign P2 = 1;
       end//4
       else
         begin//5
           assign P2 = 0;
         end//5
       if(H_word(3) ^ H_word(4) ^ H_word(5) ^ H_word(6))//check P3,D5,D6,D7
         begin//6
           assign P3 = 1;
         end//6
        else
          begin//7
            assign P3 = 0;
          end//7
 end//1
  

assign error = {P3 , P2 , P1}; // the error

endmodule

im new to verilog and my problem here how to detect the error first and then calculate the number that the error occurred and finally how to correct the message
i received the 7 bit message then i calculate the parity bit by XOR the corresponding data bit