Prev Problem
Next Problem

17. Binary to Gray Code Converter

Back To All Submissions
Previous Submission
Next Submission

Solving Approach

How do you plan to solve it?

 

 

Code

/*Write your code here*/
module bin2gray4(

input  [3:0] bin_in,
output [3:0] gray_out
);

wire bit0, bit1, bit2, bit3;

assign bit0 = bin_in[3];
assign bit1 = bin_in[3] ^ bin_in[2];
assign bit2 = bin_in[2] ^ bin_in[1];
assign bit3 = bin_in[1] ^ bin_in[0];


assign gray_out = {bit0,bit1,bit2,bit3};

endmodule
Was this helpful?
Upvote
Downvote