mirror of
https://github.com/myhdl/myhdl.git
synced 2024-12-14 07:44:38 +08:00
45a769d82d
--HG-- branch : 0.8-dev
38 lines
518 B
Verilog
38 lines
518 B
Verilog
// File: bin2gray.v
|
|
// Generated by MyHDL 0.8dev
|
|
// Date: Fri Dec 21 15:02:38 2012
|
|
|
|
|
|
`timescale 1ns/10ps
|
|
|
|
module bin2gray (
|
|
B,
|
|
G
|
|
);
|
|
// Gray encoder.
|
|
//
|
|
// B -- input intbv signal, binary encoded
|
|
// G -- output intbv signal, gray encoded
|
|
// width -- bit width
|
|
|
|
input [7:0] B;
|
|
output [7:0] G;
|
|
reg [7:0] G;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
always @(B) begin: BIN2GRAY_LOGIC
|
|
integer i;
|
|
reg [9-1:0] Bext;
|
|
Bext = 9'h0;
|
|
Bext = B;
|
|
for (i=0; i<8; i=i+1) begin
|
|
G[i] = (Bext[(i + 1)] ^ Bext[i]);
|
|
end
|
|
end
|
|
|
|
endmodule
|