case语句实现一位半加器用Verilog HDL
时间: 2024-06-04 07:12:12 浏览: 143
VHDL的例代码,例如二选一,半加器
module half_adder(A, B, SUM, CARRY);
input A, B;
output SUM, CARRY;
// case statement to implement half adder logic
case({A,B})
2'b00: begin
SUM = 1'b0;
CARRY = 1'b0;
end
2'b01: begin
SUM = 1'b1;
CARRY = 1'b0;
end
2'b10: begin
SUM = 1'b1;
CARRY = 1'b0;
end
2'b11: begin
SUM = 1'b0;
CARRY = 1'b1;
end
endcase
endmodule
阅读全文