2023-01-11 10:13:09 +00:00
|
|
|
/**
|
|
|
|
* Computes the sum of two bits.
|
|
|
|
*/
|
|
|
|
|
|
|
|
`default_nettype none
|
|
|
|
module HalfAdder(
|
2024-10-17 18:36:58 +00:00
|
|
|
input a, //1-bit input
|
|
|
|
input b, //1-bit inpur
|
|
|
|
output sum, //Right bit of a + b
|
|
|
|
output carry //Lef bit of a + b
|
2023-01-11 10:13:09 +00:00
|
|
|
);
|
|
|
|
|
2024-10-17 18:36:58 +00:00
|
|
|
// Put your code here:
|
|
|
|
Xor XOR(a, b, sum);
|
|
|
|
And AND(a, b, carry);
|
2023-01-11 10:13:09 +00:00
|
|
|
endmodule
|