Adder 2026-10-25
A Boolean circuit computing the sum of binary representations, possibly including input and output carry bits. Its delay depends on how carries are propagated; specifying an adder does not by itself imply constant circuit depth as the input width grows.
Hierarchical leading-zero counter 2026-10-25
For a block of bits, encode its count leading zeros result as a zero flag followed by low count bits . An all-zero block has ; otherwise . Two half-block encoders supply flags and low counts . Combine them using , , and for . A one-bit leaf has and no low count bits. Checking whether the upper half is nonzero, only the lower half is nonzero, or both halves are zero proves the formula.
All count bits are selected in parallel, so for circuit depth. The circuit size satisfies ; summing the work over levels gives . Sharing the all-zero flags avoids a serial adder along the critical path.
A subtract with carry instruction consumes the no-borrow carry flag. Its arithmetic is . Hence a low-limb
subs followed immediately by a high-limb sbcs propagates exactly the low subtraction's borrow.subs r0, r0, r2
sbcs r1, r1, r3It uses an ordinary 32-bit adder by complementing every bit of the subtrahend and adding the incoming arithmetic carry. For , the unreduced adder sum isIf this is , rearrangement gives . Thus both the result and outgoing no-borrow flag have the required meanings. With incoming arithmetic carry one this becomes ordinary subtraction.[ref]
Thumb 16-bit instruction set quick reference by Arm. Page 1, Add with carry and Subtract with carry: subtraction subtracts NOT C-bit
Use a hierarchical leading-zero counter. A block of bits returns a zero flag and low count bits : its count leading zeros result is the concatenation . Thus means that the block is entirely zero and ; otherwise and is its leading-zero count. A one-bit block needs just and no low count bits.
For a block of bits, run two such Boolean circuits on the upper and lower halves in parallel. Write their flags as and their low count bits as . SetThe last expression is a two-input multiplexer. When the upper half is nonzero, its count is already the answer and . When only the upper half is zero, supplies the contribution while the multiplexers supply the lower half's count. When both halves are zero, the answer is , representing . This special encoding avoids an adder on the critical path.
Each node adds constant circuit depth, even though it uses logic gates for its parallel multiplexers. HenceIndeed the internal-node work is bounded by a constant times , and the leaves add . Delay is and size is , counting fixed-fan-in logic gates and the usual wire fan-out model.
Subtract with carry 2026-10-24
With the ARM architecture family's no-borrow convention, subtract with carry forms . The same adder used for addition can form . If its output is , rearranging proves . Thus complementing the second operand implements both the result and the correctly chained borrow information.[ref]
