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

Continuous versus Procedural Assignment

EasyVerilog / SystemVerilogBuild

Hardware engineers frequently inherit legacy code containing massive single-line continuous assignments that are nearly impossible to read or debug. Breaking these monolithic equations down into procedural blocks using intermediate variables is essential for maintaining clean and understandable RTL.

The legacy codebase contains a continuous assignment that computes an 8-bit output based on four 8-bit inputs: assign out = (((a & b) | (~c & d)) ^ (a + c)) + (b > d ? 8'hFF : 8'h00);. To improve readability and debuggability, this logic must be rewritten inside a procedural block.

The computation breaks down into the following intermediate steps: • Compute term1 as the bitwise AND of a and b. • Compute term2 as the bitwise AND of the bitwise NOT of c with d. • Compute mask as the bitwise OR of term1 and term2. • Compute sum as the arithmetic addition of a and c. • Compute cond as 8'hFF if b is strictly greater than d, and 8'h00 otherwise. • Compute the final out by bitwise XORing mask and sum, then adding cond.

This is a purely combinational circuit. The output out must reflect changes to the inputs immediately without any clock or reset delays.

| Signal | Direction | Width | Description | |--------|-----------|-------|-------------| | a | input | 8 | First operand | | b | input | 8 | Second operand | | c | input | 8 | Third operand | | d | input | 8 | Fourth operand | | out | output | 8 | Final computed result |

Constraints

  • The circuit is purely combinational; there is no clock or reset.
  • All inputs and outputs are exactly 8 bits wide.
  • Standard Verilog arithmetic wrap-around applies to all additions.
  • The final output must logically match the legacy equation exactly.

Topics

CombinationalProcedural AssignmentSystemVerilog

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