1 Answers
//GRAY TO BIN
module GRAY_BIN(g,b);
input [3:0] g;
output [3:0] b;
assign b[3]=g[3];
assign b[2]=g[3]^g[2];
assign b[1]=g[3]^g[2]^g[1];
assign b[0]=g[3]^g[2]^g[1]^g[0];
endmodule
//TB
module Gray_BIn_tf;
// Inputs
reg [3:0] g;
// Outputs
wire [3:0] b;
// Instantiate the Unit Under Test (UUT)
GRAY_BIN uut (
.g(g),
.b(b)
);
initial begin
// Initialize Inputs
g = 0;
// Wait 100 ns for global reset to finish
#100;
// Add stimulus here
g=4’b1000;
#100;
g=4’b1001;
#100;
g=4’b1001;
#100;
g=4’b1010;
#100;
end
endmodule