FPGA之流水线算法实现八位加法器

1.普通方法实现八位加法器

/*******************8位加法器(非流水线)***********************/
module adder_nonpipe(cout, sum, ina, inb, cin, enable);

output cout;
output [7:0] sum;
input [7:0] ina, inb;
input cin, enable;

reg cout;
reg [7:0] sum;
reg [7:0] tempa, tempb;
reg tempc;

always @(posedge enable)
begin
    tempa = ina;
    tempb = inb;
    tempc = cin;
end

always @(posedge enable)
begin
    {cout,sum} = tempa + tempb + tempc;
end

endmodule

2.流水线方法实现八位加法器

/*******************8位2级流水加法器*************************/
module adder_pipeline(cout, sum, ina, inb, cin, enable);

output cout;
output [7:0] sum;
input [7:0] ina, inb;
input cin, enable;

reg cout;
reg [7:0] sum;

reg [3:0] tempa, tempb, firsts;
reg firstc;
always @(posedge enable)
begin
    {firstc,firsts} = ina[3:0] + inb[3:0] + cin;
    tempa = ina[7:4];     
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值