|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?注册
×
本帖最后由 418478935 于 2011-6-21 01:05 编辑
我仿照王金明的那本书的例子做了一个二级流水线的十六进制加法器,
可是为什么会有这样的问题:就是最后的输出时,进位始终为0,请各位高手帮我看下,
多谢各位了 ,下面是代码
module adder16(a,b,cin,clk,sum,cout);
input[15:0] a,b;
input cin;
input clk;
output[15:0] sum;
output cout;
reg[15:0] sum;
reg cout;
reg[15:0] temp_a,temp_b;
reg temp_cin;
reg[7:0] first_sum;
reg first_cout;
reg[7:0] first_a,first_b;
always @(posedge clk)
begin
temp_a<=a;temp_b<=b;temp_cin<=cin;
end
always @(posedge clk)
begin
{first_cout,first_sum}<=temp_a[7:0]+temp_b[7:0]+temp_cin;
first_a<=temp_a[15:8];
first_b<=temp_b[15:8];
end
always @(posedge clk)
begin
{cout,sum}<={first_a+first_b+first_cout,first_sum};
end
endmodule
|
|