超前进位加法器

在实时信号处理中,常常要用到多位数字量的加法运算,但串行加法器速度较慢,超前进位加法器则能满足要求,且结构并不复杂。现在普遍使用的并行加法器是超前进位加法器,只是在几个全加器的基础上增加了一个超前进位形成逻辑,以减少由于逐步进位信号的传递所造成的时延。
  具体的算法为:
      S[i] = x[i] ^ y[i] ^ C[i];
     C[i] = G[i-1] + P[i-1] * C[i-1];
其中: G[i] = x[i] * y[i]

      P[i] = x[i] + y[i]

module adder_4bits_parallel(a,b,c_in,sum,c_out);
input [3:0] a;
input [3:0] b;
input        c_in;
output [3:0] sum;
output      c_out;

wire [3:0] G, P;
wire [3:0] C;

assign G[0] = a[0] & b[0];
assign P[0] = a[0] | b[0];
assign C[0] = G[0] | (P[0] & c_in);//a和b的当前位都为1或者a和b有一个为1且进位为1则当前位产生进位
assign sum[0] = a[0] ^ b[0] ^ c_in;

assign G[1] = a[1] & b[1];
assign P[1] = a[1] | b[1];
assign C[1] = G[1] | (P[1] & C[0]);
assign sum[1] = a[1] ^ b[1] ^ C[0];

assign G[2] = a[2] & b[2];
assign P[2] = a[2] | b[2];
assign C[2] = G[2] | (P[2] & C[1]);
assign sum[2] = a[2] ^ b[2] ^ C[1];

assign G[3] = a[3] & b[3];
assign P[3] = a[3] | b[3];
assign C[3] = G[3] | (P[3] & C[2]);
assign sum[3] = a[3] ^ b[3] ^ C[2];
    
assign c_out = C[3];

endmodule

转载于:https://www.cnblogs.com/shengansong/archive/2011/05/23/2054374.html

你可能感兴趣的:(超前进位加法器)