Advertisement
Guest User

Untitled

a guest
Sep 25th, 2013
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. component gray2bin "convert a gray-code input to binary";
  2.  
  3. pin in unsigned in "gray code in";
  4. pin out unsigned out "gray code out";
  5.  
  6. license "GPL";
  7. author "andy pugh";
  8. function _;
  9.  
  10. ;;
  11.  
  12. u32 mask;
  13. u32 num = in;
  14. for(mask = num >> 1 ; mask != 0 ; mask = mask >> 1){
  15. num ^= mask;
  16. }
  17. out = num;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement