05Verification
Wire two half adders into a full adder
Problem
Intended behavior. full_adder adds three 1-bit inputs a, b, and cin
and reports the 2-bit result as {cout, sum}. It is built from two instances of
the provided half_adder: the first adds a and b, the second adds that
partial sum to cin, and cout is set when either half adder produced a carry.
Current behavior. The starter compiles and prints all eight input
combinations. Several rows are wrong: for a=0 b=1 cin=0 the adder reports a
total of 0, and for a=1 b=1 cin=1 it reports 2 instead of 3.
Your task. half_adder itself is correct. Find the faulty port connection in
full_adder and fix it without changing either module's ports.
Diagnose
Draw the two instances as boxes. For each named connection .port(net), write
the net on the matching input or output of the box. Then trace one failing row
through your drawing and see which input never reaches the second half adder.
Before running the fix, predict the corrected table: {cout, sum} should read
as the binary count of ones among a, b, and cin. Change one connection,
run, and compare all eight rows with your table. Then explain why the compiler
could not catch the mistake: every net in the faulty list exists and has the
right width, so the wiring was legal but meant something else.
Completion check
- All eight combinations of
a,b, andcingive{cout, sum}equal to their arithmetic sum, regardless of the order in which inputs change. - The output still depends on all three inputs through the two
half_adderinstances. half_adderand the port lists stay unchanged.
Progressive hints
Hint 1
In every failing row b is 1. Ask whether b can influence sum at all in
the current wiring.
Hint 2
The internal net s1 is driven by the first instance. Find where, if anywhere,
it is read.
Hint 3
The second half adder should combine the first one's partial sum with cin.
Compare that with the nets connected to its two inputs.
Transfer experiment
Predict the table if the two instances' .carry connections were exchanged. Then
explain why this swap leaves every row unchanged. Would exchanging the two
input nets of either half adder also leave the result unchanged? Use the
commutativity of OR, XOR, and AND to justify your predictions.