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

Parity Generator Reduction Operator

EasyVerilog / SystemVerilogBuild

Error detection schemes like parity checking require XORing wide data buses together. A naive approach using sequential operations or cascaded gates can result in deep logic levels that severely degrade timing performance. Reduction operators in Verilog instruct the synthesis tool to build highly optimized, balanced gate trees automatically.

The module computes the even and odd parity of a 32-bit input vector. Even parity means the parity bit is set to 1 if the input data contains an odd number of 1s; this ensures the total number of 1s across the data and parity bit is even. Odd parity is the exact opposite; the bit is set to 1 if the input data contains an even number of 1s.

| Signal | Direction | Width | Description | |--------|-----------|-------|-------------| | data_in | input | 32 | Data word to calculate parity for | | parity_even | output | 1 | Even parity bit; 1 when data_in has an odd number of 1s | | parity_odd | output | 1 | Odd parity bit; 1 when data_in has an even number of 1s |

Constraints

  • The design must be strictly combinational
  • Do not use clocks or resets
  • Do not use for loops or manually cascaded XOR gates
  • The output parity_odd must always be the logical inverse of parity_even

Topics

Combinational LogicOperatorsSynthesis Intuition

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