1 Answers
//BIN TO GRAY
module BIN_GRAY(g,b);
input [2:0] b; //3-bits 0,1,2
output wire [2:0] g;
assign g[2]=b[2];
assign g[1]=b[2]^b[1];
assign g[0]=b[1]^b[0];
//TEST BENCH
module bin_Gray_tb;
// Inputs
reg [2:0] b;
// Outputs
wire [2:0] g;
// Instantiate the Unit Under Test (UUT)
BIN_GRAY uut (
.g(g),
.b(b)
);
initial begin
// Initialize Inputs
b = 0;
// Wait 100 ns for global reset to finish
#100;
// Add stimulus here
b=3’b001;
#100;
b=3’b010;
#100;
b=3’b100;
#100;
end
endmodule