1
0
mirror of https://github.com/aolofsson/oh.git synced 2025-01-30 02:32:53 +08:00
oh/src/common/hdl/oh_bin2gray.v
Andreas Olofsson 7094173ae9 Reorg! Why?
- The top level directory was not scaling, too imposing
- Friendlier to download a repo and see a finite number of top level dirs
- We are just getting started...
2016-03-22 08:13:40 -04:00

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