def gray2bin(d_word,b_width):
bits_in = to_bin(d_word,b_width)<EOL>bits_out = np.zeros(b_width,dtype=np.int)<EOL>for k, bit_k in enumerate(bits_in):<EOL><INDENT>if k > <NUM_LIT:0>:<EOL><INDENT>bits_out[k] = bit_k^bits_out[k-<NUM_LIT:1>]<EOL><DEDENT>else:<EOL><INDENT>bits_out[k] = bit_k<EOL><DEDENT><DEDENT>return from_bin(bits_out)<EOL>
Convert gray encoded binary words to integer bit words via
Gray decoding starting from the MSB to the LSB

Mark Wickert November 2018