32位进位选择加法器_4位超前进位加法器级联 实现32位加法器

一个四位超前进位加法器

module 

8个4位超前进位加法器

module adder32(a,b,cin,s,cout);
    input [31:0] a;//被加数
	input [31:0] b;//加数
	input cin;//进位输入
	output [31:0] s;//和
	output cout;//进位输出
	wire [6:0] carry;//级联进位
	PA4 u0(a[3:0],b[3:0],cin,s[3:0],carry[0]);
    PA4 u1(a[7:4],b[7:4],carry[0],s[7:4],carry[1]);
    PA4 u2(a[11:8],b[11:8],carry[1],s[11:8],carry[2]);
    PA4 u3(a[15:12],b[15:12],carry[2],s[15:12],carry[3]);
    PA4 u4(a[19:16],b[19:16],carry[3],s[19:16],carry[4]);
    PA4 u5(a[23:20],b[23:20],carry[4],s[23:20],carry[5]);
    PA4 u6(a[27:24],b[27:24],carry[5],s[27:24],carry[6]);
    PA4 u7(a[31:28],b[31:28],carry[6],s[31:28],cout);
endmodule

仿真代码

`timescale 1ns / 1ps
module test_adder32();
    reg clk_1Hz;
    reg [31:0]a,b;
    reg cin;
    wire [31:0]s;
    wire cout;
    adder32 u(a,b,cin,s,cout);
    always #100 clk_1Hz = ~clk_1Hz;
    initial
    begin
        clk_1Hz=0;
        #200;
        a=32'h00100100;b=32'h00110011;cin=1'b0;
        #200;
        a=32'h00111100;b=32'h00110011;cin=1'b1;
        #200;
        a=32'h00100100;b=32'h00110011;cin=1'b1;
        #200;
        a=32'h00100101;b=32'h00110111;cin=1'b0;
    end
endmodule

仿真波形图

v2-7c2d48fa4d24c9e3fcad5aa11ffae1cd_b.jpg

RTL实现

v2-97d780988c500a008b8b760395cd30f1_b.jpg

综合

v2-88b2eb2da6ee60d4a6bc4f69a85fa2ce_b.jpg
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值