Module shift8
错误记录
表示端口是不带范围的,端口是a,b,开始时误以为端口是a【15:0】这种导致错误;
在最后一句计算sum时又忘了添加assign
You are given a module 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
module performs 16-bit a + b + cin, while your module performs 32-bit
a + b). add16add16Connect the modules together as shown in the diagram below. The
provided module has the following declaration: add16module add16 ( input[15:0] a, input[15:0] b, input cin, output[15:0]
sum, output cout );
module top_module(
input [31:0] a,
input [31:0] b,
output [31:0] sum
);
wire wire_0;
wire [15:0] sum_low,sum_high;
add16 add16_low(.a(a[15:0]),.b(b[15:0]),.sum(sum_low),.cin(0),.cout(wire_0));
add16 add16_high(.a(a[31:16]),.b(b[31:16]),.sum(sum_high),.cin(wire_0));
assign sum={sum_high,sum_low};
endmodule