题解 | #全加器#
全加器
https://www.nowcoder.com/practice/d04c046febb74e72949baee9aa99d958
`timescale 1ns/1ns module add_half( input A , input B , output wire S , output wire C ); assign S = A ^ B; assign C = A & B; endmodule /***************************************************************/ module add_full( input A , input B , input Ci , output wire S , output wire Co ); wire S_tmp, C_tmp1,C_tmp2; add_half u_add_half1( .A(A) , .B(B) , .S(S_tmp) , .C(C_tmp1) ); add_half u_add_half2( .A(S_tmp) , .B(Ci) , .S(S) , .C(C_tmp2) ); assign Co = C_tmp1 | C_tmp2; endmodule