Theory:
A Gray to Binary code converter is a tool or algorithm that translates a number represented in Gray code into its equivalent binary representation, using the principle of exclusive OR (XOR) operations.
Block diagram:
Truth Table:
Boolean expression:
b2=g2
b1=(g2^g1)
b0=g2^(g1^g0)
Verilog code:
module gb(g2,g1,g0,
b2,b1,b0);
input g2,g1,g0;
output b2,b1,b0;
assign b2=g2;
assign b1=(g2^g1);
assign b0=g2^(g1^g0);
endmodule
Test bench:
module gb_tb;
reg g2;
reg g1;
reg g0;
wire b2;
wire b1;
wire b0;
gb uut (
.g2(g2),
.g1(g1),
.g0(g0),
.b2(b2),
.b1(b1),
.b0(b0)
);
initial begin
g2 = 0;g1 = 0;g0 = 0;#100;
g2 = 0;g1 = 0;g0 = 1;#100;
g2 = 0;g1 = 1;g0 = 0;#100;
g2 = 0;g1 = 1;g0 = 1;#100;
g2 = 1;g1 = 0;g0 = 0;#100;
g2 = 1;g1 = 0;g0 = 1;#100;
g2 = 1;g1 = 1;g0 = 0;#100;
g2 = 1;g1 = 1;g0 = 1;#100;
end
endmodule
Output:
Pin assignment:
input g2->pin 86
input g1->pin 90
input g0->pin 94
output b2->pin 20
output b1->pin 26
output b0->pin 28
RTL schematic view:
Device utilization summary:
Timing analysis: