HBLbits_Verilog Basic_Module fadd
module add16 ( input[15:0] a, input[15:0] b, input cin, output[15:0] sum, output cout );
module add1 ( input a, input b, input cin, output sum, output cout );
top_module
— Your top-level module that contains two of...add16
, provided — A 16-bit adder module that is composed of 16 of...add1
— A 1-bit full adder module.
module top_module (
input [31:0] a,
input [31:0] b,
output [31:0] sum
);//
wire cin,cout1,cout2;
assign cin=1'b0;
add16 u1(a[15:0],b[15:0],cin,sum[15:0],cout1);
add16 u2(a[31:16],b[31:16],cout1,sum[31:16],cout2);
endmodule
module add1 ( input a, input b, input cin, output sum, output cout );
// Full adder module here
assign sum=a^b^cin;
assign cout=(a|cin)&(b|cin)&(a|b);
endmodule
沒有留言:
張貼留言