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

Decoder with Enable Logic

MediumVerilog / SystemVerilogBuild

Memory mapped systems and peripheral buses require address decoding to select specific devices. A standard decoder always drives one output high, which can cause bus contention or unintended writes if the device should not be active. To prevent this, system decoders incorporate a chip select or enable signal that safely forces all outputs low when the device is idle.

This module decodes a 3-bit binary input into an 8-bit output vector. It includes an active-high enable signal. When the enable signal is asserted, exactly one bit of the output corresponding to the binary value of the input is driven high. When the enable signal is deasserted, all output bits are forced to zero regardless of the input value.

| Signal | Direction | Width | Description | |--------|-----------|-------|-------------| | en | input | 1 | Active-high enable signal; output is 8'b00000000 when low | | sel | input | 3 | Binary selection input | | out | output | 8 | Decoded output; one-hot when en is 1, all zeros when en is 0 |

Constraints

  • The circuit is purely combinational; no clock or reset signals are used.
  • The output must be exactly 8'b00000000 when en is 0, overriding any value on sel.
  • The output must be strictly one-hot when en is 1.

Topics

CombinationalDecoderAddress Decoding

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