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

The Don't Care Assignment

MediumVerilog / SystemVerilogBuild

Instruction decoders in embedded processors map binary opcodes to internal control signals. When an instruction set architecture leaves portions of the opcode space undefined, hardware engineers have a choice: force the control signals to zero, or assign them as don't cares. Assigning a literal zero forces the synthesis tool to instantiate logic gates to enforce that zero. Assigning a don't care allows the synthesizer to optimize the logic, treating the invalid states as whatever boolean value minimizes the total gate count.

The module acts as a specialized 3-to-5 one-hot decoder. It takes a 3-bit input and asserts exactly one of the five output bits for valid inputs 0 through 4. For inputs 5, 6, and 7, the module must output literal don't care values. This allows downstream synthesis tools to aggressively minimize the cell count.

| Signal | Direction | Width | Description | |--------|-----------|-------|-------------| | opcode | input | 3 | The binary instruction code | | signals | output | 5 | The decoded one-hot control signals, or don't cares for invalid opcodes |

Constraints

  • The circuit is strictly combinational; there is no clock or reset
  • For opcode values 0 through 4, signals must be one-hot, starting at 5'b00001 for opcode 0
  • For opcode values 5, 6, and 7, every bit of signals must evaluate to 1'bx

Topics

OptimizationCombinational LogicSynthesis 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
  • Basic Module PortsEasy

Browse all problems · Learning tracks