aboutsummaryrefslogtreecommitdiffstats
path: root/src/hal/components/gray2bin.comp
blob: afbe4f673d45d079ae8b9a5eff1ef95c15a2b980 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
component gray2bin "convert a gray-code input to binary";
description """Converts a gray-coded number into the corresponding binary value""";
pin in unsigned in "gray code in";
pin out unsigned out "binary code out";
license "GPL";
author "Andy Pugh";
function _ nofp;
;;
unsigned int mask;
out = in;
for(mask = in >> 1 ; mask != 0 ; mask = mask >> 1){
    out ^= mask;
}
bues.ch cgit interface