diff options
Diffstat (limited to 'fpga/usrp3/lib/control/gray2bin.v')
-rw-r--r-- | fpga/usrp3/lib/control/gray2bin.v | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/fpga/usrp3/lib/control/gray2bin.v b/fpga/usrp3/lib/control/gray2bin.v new file mode 100644 index 000000000..c75ad80c6 --- /dev/null +++ b/fpga/usrp3/lib/control/gray2bin.v @@ -0,0 +1,25 @@ +// +// Copyright 2016 Ettus Research, a National Instruments Company +// +// SPDX-License-Identifier: LGPL-3.0-or-later +// +// +// Gray: {a,b,c,d} +// Bits: {a,a^b,a^b^c,a^b^c^d} +// +module gray2bin #( + parameter WIDTH = 8) +( + input [WIDTH-1:0] gray, + output reg [WIDTH-1:0] bin +); + + integer i; + always @(*) begin + bin[WIDTH-1] = gray[WIDTH-1]; + for (i = WIDTH-2; i >= 0; i = i - 1) begin + bin[i] = bin[i+1] ^ gray[i]; + end + end + +endmodule |