Problems

5. Leading zero count

EasyWrite the moduleAbout 15 minFree
combinationalleading zerospriority

Count the zeros at the top of an 8-bit value, before the first 1 when reading from bit 7 down.

lz is that count. When d is all zeros, lz is 8. There is no clock and no reset.

Ports

Module lzc8

PortDirBitsWhat it is
din8The value to inspect.
lzout4Number of leading zeros, 0 to 8.

Example

d = 0001_0110: three zeros come before the first 1, so lz = 3. d = 1000_0000 gives lz = 0; d = 0000_0001 gives lz = 7.

Stuck? . Sign in to save your progress. You can solve the free problems without an account.

Veriloglzc8.v
14px
Loading the editor…

Submit your answer to have it graded. The hidden test runs on the server; you see whether it passes and, if not, the first case it gets wrong.

Leading zero count: Verilog interview question | breadboardhub