Prev Problem
Next Problem

17. Binary to Gray Code Converter

Back To All Submissions
Previous Submission
Next Submission

Binary <-> Gray conversion go BRRRRRRR

 

 

Code

module bin2gray4(
    input [3:0] bin_in,
    output reg [3:0] gray_out
);
always @(*) begin
    gray_out = {bin_in[3], (bin_in[3] ^ bin_in[2]),  (bin_in[2] ^ bin_in[1]),  (bin_in[1] ^ bin_in[0])};
end

endmodule
Was this helpful?
Upvote
Downvote