Update the problem details below.
A Half Subtractor is a combinational circuit that subtracts one 1-bit binary input (b) from another (a). It produces two outputs:
In this tutorial, you will design a half subtractor using Verilog and test it with all input combinations.
The half subtractor handles subtraction of two bits only — it cannot handle borrow from a previous stage (that’s why it’s half).
Difference Equation: D = a ⊕ b
D = a ⊕ b
Borrow Equation: B = (~a) & b (Borrow is needed when a = 0 and b = 1.)
B = (~a) & b
a = 0
b = 1
half_subtractor
a
b
diff
borrow
assign diff = a ^ b;
assign borrow = (~a) & b;
testbench
00
01
10
11
a, b, diff, borrow
diff = a ⊕ b
borrow = (~a) & b
a - b
Nothing to preview yet. Start typing in the editor...
Enter the expected output as valid JSON format that will be used to verify student submissions.