题解 | #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 [3:0] g;//生成进位项 wire [3:0] p;//传播进位项 wire C3; assign g = A_in & B_in; assign p = A_in ^ B_in; assign C3 = g[3] | (p[3]&(g[2] | (p[2]&(g[1] | (p[1]&(g[0] | (p[0]&C_1))))))); assign S[0] = p[0] ^ C_1; assign S[1] = p[1] ^ (g[0] | (p[0]&C_1)); assign S[2] = p[2] ^ (g[1] | (p[1]&(g[0] | (p[0]&C_1)))); assign S[3] = p[3] ^ (g[2] | (p[2]&(g[1] | (p[1]&(g[0] | (p[0]&C_1)))))); //assign C2 = g[2] | (p[2]&(g[1] | (p[1]&(g[0] | (p[0]&C_1))))); //assign C1 = g[1] | (p[1]&(g[0] | (p[0]&C_1))); //assign C0 = g[0] | (p[0]&C_1); assign CO = C3; endmodule
超前进位的特点就是深度浅,运行速度快。但是面积大,比较复杂。可以直接根据输入比特进行计算,不需要中间变量