zl程序教程

您现在的位置是:首页 >  其它

当前栏目

4bit超前进位加法器电路

电路
2023-09-14 09:10:03 时间

4bit超前进位加法器电路

题目描述
采用门级描述方式,实现此4bit超前进位加法器,接口电路如下:
在这里插入图片描述

`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
);

    and ad3(ad3_o,A_in[3],B_in[3]),
        ad2(ad2_o,A_in[2],B_in[2]),
        ad1(ad1_o,A_in[1],B_in[1]),
    ad0(ad0_o,A_in[0],B_in[0]),//G
    
        ad4(ad4_o,xr3_o,CO3),
        ad5(ad5_o,xr2_o,CO2),
        ad6(ad6_o,xr1_o,CO1),
        ad7(ad7_o,xr0_o,C_1);
    
    xor xr3(xr3_o,A_in[3],B_in[3]),
        xr2(xr2_o,A_in[2],B_in[2]),
        xr1(xr1_o,A_in[1],B_in[1]),
    xr0(xr0_o,A_in[0],B_in[0]),//P
    
        S3(S[3],xr3_o,CO3),
        S2(S[2],xr2_o,CO2),
        S1(S[1],xr1_o,CO1),
    S0(S[0],xr0_o,C_1);//S
    
    or co1(CO1,ad0_o,ad7_o),
       co2(CO2,ad1_o,ad6_o),
       co3(CO3,ad2_o,ad5_o),
       co4(CO,ad3_o,ad4_o);
endmodule

知识点

`timescale 1ns / 1ps
// Description: 
// 超前进位加法器,主要解决全加器进位位依赖低位的问题(加法器位宽较大时组合逻辑时延长。
//          C(i+1) = G(i)+P(i)C(i)
//            其中 G = AB P= A+B ,G成为生成信号(generate),P成为传播信号(propagate)
 
module Carry_Lookahead_Adder(
input   [3:0]       A           ,
input   [3:0]       B           ,
input               Cin         ,
output  [3:0]       S           ,
output              Cout
    );
 
wire c1,c2,c3;
//  超前进位算法
assign c1 = (A[0]&B[0]) |((A[0]+B[0])&Cin) ;
assign c2 = (A[1]&B[1]) |((A[1]+B[1])&c1 ) ;
assign c3 = (A[2]&B[2]) |((A[2]+B[2])&c2 ) ;
assign Cout = (A[3]&B[3])|((A[3]+B[3])&c3 ) ;
// 各位的值还是需要全加器,超前进位加法器解决的只是进位问题
assign S = {A[3]^B[3]^c3,A[2]^B[2]^c2,A[1]^B[1]^c1,A[0]^B[0]^Cin}; 
endmodule