Codiode

Leading Zero Detector

MediumLogic CircuitBuild

Floating point normalization and instruction decoding rely on finding the most significant set bit in a word. The leading zero detector computes how many positional shifts are required to align a mantissa in arithmetic logic units.

The circuit accepts an 8-bit input D and outputs a 3-bit value Z representing the count of consecutive zeros starting from the most significant bit, D[7]. If all bits in D are zero, Z must output 7.

D[7:0] Z
1xxxxxxx 0
01xxxxxx 1
001xxxxx 2
0001xxxx 3
00001xxx 4
000001xx 5
0000001x 6
00000001 7
00000000 7

Constraints

  • Combinational logic only.
  • Do not use sequential elements or clocks.

Topics

arithmeticpriority-encoderdatapath

Solve this problem

Place the gates, wire them up and watch the signals settle. Every submission runs on the same simulation engine that grades it.

This problem is part of Codiode Pro. The statement above is free to read.

The circuit builder and code editor need a desktop screen. On a phone, read the problem here and open it on a laptop to solve.

Part of Interview Circuit

Problem 25 of 29 in the Interview Circuit track.

Related problems

Browse all problems · Arithmetic circuit and ALU design problems · Digital logic design practice problems · Learning tracks

Solve this on a laptopSend yourself the link and continue there.