Write a verilog code for BIN(binary) TO EXCESS3?

All QuestionsCategory: VerilogWrite a verilog code for BIN(binary) TO EXCESS3?
Chetan Shidling Staff asked 5 years ago

I need code.

1 Answers
Chetan Shidling Staff answered 5 years ago

//BIN TO EXCESS3

module Bin_excess(b,e);
input [2:0] b;
output wire [2:0] e;
assign e[2]=b[0]|b[1]|b[2];
assign e[1]=b[2]|~(b[1]^b[0]);
assign e[0]=~b[0];
endmodule

//TEST BENCH

module BIN_EXCESS3_tb;

// Inputs

reg [2:0] b;

// Outputs

wire [2:0] e;

// Instantiate the Unit Under Test (UUT)

Bin_excess uut (
.b(b),
.e(e)
);
initial begin

// Initialize Inputs

b = 0;

// Wait 100 ns for global reset to finish

#100;

// Add stimulus here

b=3’b000;
#100;
b=3’b001;
#100;
b=3’b010;
#100;
b=3’b011;
#100;
end

endmodule