Create a full adder. A full adder adds three bits (including carry-in) and produces a sum and carry-out.
Expected solution length: Around 2 lines.
1、第一种,拼接:
module top_module(
input a, b, cin,
output cout, sum );
assign {cout,sum} = a + b + cin;
endmodule
2、第二种,分开:
module top_module(
input a, b, cin,
output cout, sum );
assign sum = a^b^cin;
assign cout = a&b | a&cin | b&cin; // assign cout = (a&b&cin)+(a&b&~cin)+(~a&b&cin)+
// (a&~b&cin); 卡诺图化简
endmodule