题解 | #4bit超前进位加法器电路#
4bit超前进位加法器电路
https://www.nowcoder.com/practice/4d5b6dc4bb2848039da2ee40f9738363
`timescale 1ns/1ns module lca_4( input [3:0] A_in , input [3:0] B_in , input C_1 , output wire CO , output wire [3:0] S ); wire co1,co2,co3,co4; add inst1(.a(A_in[0]), .b(B_in[0]), .cin(C_1), .co(co1), .s(S[0])); add inst2(.a(A_in[1]), .b(B_in[1]), .cin(co1), .co(co2), .s(S[1])); add inst3(.a(A_in[2]), .b(B_in[2]), .cin(co2), .co(co3), .s(S[2])); add inst4(.a(A_in[3]), .b(B_in[3]), .cin(co3), .co(CO), .s(S[3])); endmodule module add( input a, input b, input cin, output co, output s ); wire g; wire p; assign g = a&b; assign p = a^b; assign s = p^cin; assign co = g | (p&cin); endmodule#verilog刷题#