CodiodeCodiode
Home
Problem Solving
Skill Tracks
My Assignments
Contests
Leaderboard
Community
Settings
Codiode/Problems/Combinational Logic

Reduction AND NAND

MediumVerilog / SystemVerilogBuild

Determining if all bits in a wide bus are asserted is a frequent requirement in digital design. Hardware systems use this logic to detect a terminal count in a timer, verify a fully populated bitmask, or confirm that all parallel subsystems have asserted their ready signals. Manually coding massive logical AND chains is brittle and unmaintainable when bus widths change.

This module evaluates a parameterised input bus and asserts a flag when every bit in the bus is high. It also produces a complementary flag that is asserted when any bit in the bus is low. Both outputs must dynamically scale with the parameterised width without requiring code modifications.

This is a purely combinational circuit. Changes on the input must immediately reflect on the outputs without requiring a clock or reset.

Parameters

| Parameter | Default | Description | |-----------|---------|-------------| | WIDTH | 8 | The bit width of the input bus |

Ports

| Signal | Direction | Width | Description | |--------|-----------|-------|-------------| | in | input | WIDTH | Parameterised input bus | | all_ones | output | 1 | Asserted high when all bits of in are 1 | | not_all_ones | output | 1 | Asserted high when at least one bit of in is 0 |

Constraints

  • The design must be purely combinational with no latches or flip-flops
  • The design must support any WIDTH greater than 1
  • Do not use procedural loops to iterate through the bits

Topics

combinationalreductionverilog

Solve this problem

Write the module in Verilog, SystemVerilog or VHDL. Your submission is compiled and simulated against a real testbench — you get the waveform back, not a stored answer.

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

Sign in to solveSee what Pro unlocks

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.

Related problems

  • Single Continuous AssignmentEasy
  • Basic Vector ConcatenationEasy
  • Ternary Operator MuxEasy
  • Underscores for ReadabilityEasy
  • Left Hand Side ConcatenationEasy
  • Inout Port MechanicsEasy
  • Explicit Binary LiteralsEasy
  • Vector Port EndiannessEasy

Browse all problems · Learning tracks