// This example implements a full adder using a truth table // to describe the logic functions. This is a very useful // method for many functions // Note that we use a 2-bit bus for the sum and carry output module fullAdder( input a, input b, input c, output [1:0] out); // Sum, Carry wire [2:0] in = {a,b,c}; // make in a 3-bit bus connected to a, b, c assign out = (in == 3'b000) ? 2'b00 : (in == 3'b001) ? 2'b01 : (in == 3'b010) ? 2'b01 : (in == 3'b011) ? 2'b10 : (in == 3'b100) ? 2'b01 : (in == 3'b101) ? 2'b10 : (in == 3'b110) ? 2'b10 : (in == 3'b111) ? 2'b11 : 0; endmodule