mirror of
https://github.com/aolofsson/oh.git
synced 2025-01-30 02:32:53 +08:00
3168228174
(Work in progress, not tested)
31 lines
749 B
Verilog
31 lines
749 B
Verilog
module oh_bin2gray (/*AUTOARG*/
|
|
// Outputs
|
|
gray,
|
|
// Inputs
|
|
bin
|
|
);
|
|
|
|
//###############################################################
|
|
//# Interface
|
|
//###############################################################
|
|
input [DW-1:0] bin; //binary encoded input
|
|
output [DW-1:0] gray; //gray encoded output
|
|
|
|
parameter DW = 64; //width of converter
|
|
|
|
//###############################################################
|
|
//# BODY
|
|
//###############################################################
|
|
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
|
|
endmodule // oh_bin2gray
|
|
|
|
|