Design a combinational circuit with four inputs and four outputs that converts a 4bit binary number into the equivalent 4bit Gray code.
Design a combinational circuit with four inputs and four outputs that converts a 4bit binary number into the equivalent 4bit Gray code.
SIMULATION
RTL ANALYSIS
VERILOG CODE
module obj2exp_5( input A,B,C,D, output G1,G2,G3,G4 );
assign G1=A;
assign G2=(A^B);
assign G3=(B^C);
assign G4=(C^D);
endmodule
TESTBENCH CODE
module obj2exp_5_tb();
reg A,B,C,D;
wire G1,G2,G3,G4;
obj2exp_5 tab(A,B,C,D,G1,G2,G3,G4);
initial begin
A=0;B=0;C=0;D=0;
#100
A=0;B=0;C=0;D=1;
#100
A=0;B=0;C=1;D=0;
#100
A=0;B=0;C=1;D=1;
#100
A=0;B=1;C=0;D=0;
#100
A=0;B=1;C=0;D=1;
#100
A=0;B=1;C=1;D=0;
#100
A=0;B=1;C=1;D=1;
#100
A=1;B=0;C=0;D=0;
#100
A=1;B=0;C=0;D=1;
#100
A=1;B=0;C=1;D=0;
#100
A=1;B=0;C=1;D=1;
#100
A=1;B=1;C=0;D=0;
#100
A=1;B=1;C=0;D=1;
#100
A=1;B=1;C=1;D=0;
#100
A=1;B=1;C=1;D=1;
#100
$stop;
end
endmodule
Post a Comment
Post a Comment