RTL Design · Medium · Verilog, SystemVerilog, VHDL

Leading-Zero Counter

Count the number of leading zeros in an 8-bit value.

Task

Return count=8 for an all-zero input; otherwise count zeros before the highest set bit.

Examples

Constraints

What this problem is testing

A strong answer translates the requirement into synthesizable state and combinational logic, states reset and update semantics precisely, and handles boundary conditions rather than only the nominal case.

Interview habit: before coding, state reset behavior, the state that must be stored, and the conditions that update each output.

Verification plan

Common mistakes

Interview follow-up questions

Concepts to review

leading-zero, priority

Open Leading-Zero Counter in the HDLForge interactive editor.

Related problems

Explore the RTL Design Practice & Interview Preparation hub.

Continue practising