欢迎光临散文网 会员登陆 & 注册

HDLbits-Module add

2023-06-13 17:12 作者:业精于勤而荒于嬉哦  | 我要投稿


Adder 1:module_add

You are given a module add16 that performs a 16-bit addition. Instantiate two of them to create a 32-bit adder. One add16 module computes the lower 16 bits of the addition result, while the second add16 module computes the upper 16 bits of the result, after receiving the carry-out from the first adder. Your 32-bit adder does not need to handle carry-in (assume 0) or carry-out (ignored), but the internal modules need to in order to function correctly. (In other words, the add16 module performs 16-bit a + b + cin, while your module performs 32-bit a + b).


您将获得一个执行 16 位加法的模块 add16。实例化其中两个以创建一个 32 位加法器。一个 add16 模块计算加法结果的低 16 位,而第二个 add16 模块在接收到第一个加法器的进位后计算结果的高 16 位。您的 32 位加法器不需要处理进位(假设为 0)或进位(忽略),但内部模块需要才能正常工作。(换句话说,add16 模块执行 16 位 a + b + cin,而您的模块执行 32 位 a + b)。

module top_module(

    input [31:0] a,

    input [31:0] b,

    output [31:0] sum

);

    wire cout1;

     add16  ins1( a[15:0],  b[15:0],  1'b0, sum[15:0], cout1 ); 

     add16  ins2( a[31:16],  b[31:16],  cout1, sum[31:16], ); 

   

endmodule


HDLbits-Module add的评论 (共 条)

分享到微博请遵守国家法律