//定义单位全加器
module add1 (input a,input b, input cin,output sum, output cout);
reg [1:0] temp;
always@(*) begin
temp=a+b+cin;
sum=temp[0];
cout=temp[1];
end
endmodule
//定义单位全加器(真值表法)
module add1 ( input a, input b, input cin, output sum, output cout );
assign sum = a ^ b ^ cin;
assign cout = a&b | a&cin | b&cin;
endmodule