Advertisement
Guest User

Untitled

a guest
Jul 31st, 2015
217
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.61 KB | None | 0 0
  1. module error_correction(
  2. input [6:0]IN,
  3. output [6:0]OUT
  4. );
  5.  
  6. wire s1,s2,s3;
  7.  
  8. assign s1 = IN[6]^IN[5]^IN[4]^IN[2];
  9. assign s2 = IN[6]^IN[5]^IN[3]^IN[1];
  10. assign s3 = IN[6]^IN[4]^IN[3]^IN[0];
  11. assign OUT= COR(IN,{s1,s2,s3});
  12.  
  13. function [6:0]COR;
  14. input [6:0]in;
  15. input [2:0]q;
  16.  
  17. case(q)
  18. 3'b111:COR = {~in[6],in[5:0]};
  19. 3'b110:COR = {in[6],~in[5],in[4:0]};
  20. 3'b101:COR = {in[6:5],~in[4],in[3:0]};
  21. 3'b011:COR = {in[6:4],~in[3],in[2:0]};
  22. 3'b100:COR = {in[6:3],~in[2],in[1:0]};
  23. 3'b010:COR = {in[6:2],~in[1],in[0]};
  24. 3'b001:COR = {in[6:1],~in[0]};
  25. 3'b000:COR = in;
  26. endcase
  27. endfunction
  28.  
  29. endmodule
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement