- 2075 Asoj · 4 marks
Half subtractor using HDL
Short answer
A half subtractor subtracts B from A, giving difference D = A XOR B and borrow Bo = A'B. In Verilog dataflow: assign D = A ^ B; assign Bo = ~A & B; gate-level uses xor and and primitives.
Design half subtractor circuit using HDL.
A half subtractor subtracts one bit B from another bit A and gives a Difference (D) and a Borrow (Bo).
| A | B | D | Bo |
|---|---|---|---|
| 0 | 0 | 0 | 0 |
| 0 | 1 | 1 | 1 |
| 1 | 0 | 1 | 0 |
| 1 | 1 | 0 | 0 |
A --+--[XOR]------------ D
B --+--|
A --[NOT]--[AND]-------- Bo
B ---------|
Verilog HDL description
// Half subtractor: gate-level (structural) model
module half_sub_gate (input A, B, output D, Bo);
wire An; // complement of A
xor g1 (D, A, B); // D = A XOR B
not g2 (An, A); // An = A'
and g3 (Bo, An, B); // Bo = A'B
endmodule
// Same circuit: dataflow model
module half_sub_df (input A, B, output D, Bo);
assign D = A ^ B; // difference
assign Bo = ~A & B; // borrow
endmodule
Test bench (simulation)
module tb;
reg A, B; wire D, Bo;
half_sub_df uut (A, B, D, Bo);
initial begin
$monitor("A=%b B=%b D=%b Bo=%b", A, B, D, Bo);
{A,B} = 2'b00; #10 {A,B} = 2'b01;
#10 {A,B} = 2'b10; #10 {A,B} = 2'b11;
#10 $finish;
end
endmodule
Simulation output matches the truth table, e.g. A=0 B=1 D=1 Bo=1 and A=1 B=1 D=0 Bo=0.
✓ Answer checked by Claude Opus 5.5 (high effort)
Related questions
- Half adder/subtractor; 1's and 2's complement subtraction · Digital Logic, chapter 5
- Full subtractor from half subtractors · Digital Logic, chapter 5
- 2-bit fast adder; full subtractor from half subtractors · Digital Logic, chapter 5
- Full subtractor using decoder; combinational circuit · Digital Logic, chapter 4
- HDL and 2-to-4 decoder in HDL · Digital Logic, chapter 2
- Full subtractor using a 1:4 DEMUX · Digital Logic, chapter 4 · asked 6×
- Equivalent circuit and half-load efficiency of 50 kVA transformer · Electrical Machines I, chapter 2
- Design: 250 m head plant, 66 kV double circuit · Power Plant Design, chapter 4 · asked 13×
- Establishing requirements for circuit design · Instrumentation II, chapter 7 · asked 4×
- Technical dilemmas in circuit design · Instrumentation II, chapter 7