The number of zero bits before the first one, reading a fixed-width binary representation from its most significant bit. The all-zero -bit input has count . Thus , and ; the width is part of the definition.
For leading-zero count, inspect a word's bytes from most significant to least significant. Every zero byte contributes eight; the first nonzero byte contributes its table value in the title. If all bytes are zero, a word of width contributes . Defining the zero table entry explicitly makes the all-zero argument a regular case rather than an out-of-range logarithm.
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.
Articles by others on the same topic
There are currently no matching articles.