Codiode

The Incomplete Case Latch

EasyVerilog / SystemVerilogBuildFree6 solved

If a combinational block doesn't assign an output in every case, the output has to remember its old value, and synthesis builds a latch to do that. Nobody wanted that latch.

A custom instruction decoder maps a 4-bit binary-coded decimal input into an 8-bit control signal. The input has 16 possible binary states, but only the values 0 through 9 are valid instructions. The hardware must explicitly drive the output to zero for the 6 invalid states to guarantee that a purely combinational circuit is synthesized.

The module computes the following mapping:

  • sel = 0 outputs 8'h01
  • sel = 1 outputs 8'h02
  • sel = 2 outputs 8'h04
  • sel = 3 outputs 8'h08
  • sel = 4 outputs 8'h10
  • sel = 5 outputs 8'h20
  • sel = 6 outputs 8'h40
  • sel = 7 outputs 8'h80
  • sel = 8 outputs 8'hAA
  • sel = 9 outputs 8'h55
  • All other values of sel (10 through 15) output 8'h00
Signal Direction Width Description
sel input 4 Selection input representing a decimal value from 0 to 15
out output 8 Decoded control signal; invalid inputs must output zero

Constraints

  • The circuit must be purely combinational.
  • No clock or reset signals are present.
  • The output must be exactly 8'h00 for inputs 10, 11, 12, 13, 14, and 15.

Topics

CombinationalLatchesSynthesisCase Statement

Solve this problem

Write the module in Verilog, SystemVerilog or VHDL. Your submission is compiled and simulated against the problem's testbench. You get the waveform back, not a stored answer.

Free to solve. A Codiode account keeps your progress.

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.

Part of Synthesis Intuition

Problem 1 of 25 in the Synthesis Intuition track.

Related problems

Browse all problems · Verilog practice problems · Learning tracks

Solve this on a laptopSend yourself the link and continue there.