HBLbits_Verilog Basic_Module addsub
module top_module(
input [31:0] a,
input [31:0] b,
input sub,
output [31:0] sum
);
//module add16 ( input[15:0] a, input[15:0] b, input cin, output[15:0] sum, output cout );
wire [31:0] b1;
wire cout1,cout2;
add16 u1( a[15:0], b1[15:0], sub, sum[15:0], cout1 );
add16 u2( a[31:16], b1[31:16], cout1, sum[31:16], cout2 );
always @(*)
case (sub)
1'b0: b1=b;
1'b1: b1=b ^ 32'hffff_ffff;
endcase
endmodule
input [31:0] a,
input [31:0] b,
input sub,
output [31:0] sum
);
//module add16 ( input[15:0] a, input[15:0] b, input cin, output[15:0] sum, output cout );
wire [31:0] b1;
wire cout1,cout2;
add16 u1( a[15:0], b1[15:0], sub, sum[15:0], cout1 );
add16 u2( a[31:16], b1[31:16], cout1, sum[31:16], cout2 );
always @(*)
case (sub)
1'b0: b1=b;
1'b1: b1=b ^ 32'hffff_ffff;
endcase
endmodule
沒有留言:
張貼留言