2015-12-17 13:50:59 -05:00
|
|
|
module oh_bin2gray (/*AUTOARG*/
|
|
|
|
// Outputs
|
2016-01-10 13:33:31 -05:00
|
|
|
gray,
|
2015-12-17 13:50:59 -05:00
|
|
|
// Inputs
|
2016-01-10 13:33:31 -05:00
|
|
|
bin
|
2015-12-17 13:50:59 -05:00
|
|
|
);
|
|
|
|
|
|
|
|
//###############################################################
|
|
|
|
//# Interface
|
|
|
|
//###############################################################
|
2016-01-10 13:33:31 -05:00
|
|
|
input [DW-1:0] bin; //binary encoded input
|
|
|
|
output [DW-1:0] gray; //gray encoded output
|
2015-12-17 13:50:59 -05:00
|
|
|
|
2016-01-10 13:33:31 -05:00
|
|
|
parameter DW = 64; //width of converter
|
2015-12-17 13:50:59 -05:00
|
|
|
|
|
|
|
//###############################################################
|
|
|
|
//# BODY
|
|
|
|
//###############################################################
|
2016-01-10 13:33:31 -05:00
|
|
|
reg [DW-1:0] gray;
|
|
|
|
integer i;
|
|
|
|
|
|
|
|
always @*
|
|
|
|
begin
|
|
|
|
gray[DW-1] = bin[DW-1];
|
|
|
|
for (i=0; i<(DW-1); i=i+1)
|
|
|
|
gray[i] = bin[i] ^ bin[i+1];
|
|
|
|
end
|
2015-12-17 13:50:59 -05:00
|
|
|
endmodule // oh_bin2gray
|
|
|
|
|
|
|
|
|