Learn

Practice

Tank Level Decoder (K-Map)

A rainwater tank reports its fill level on a 4-bit bus level (l3 l2 l1 l0, 0 = empty, 15 = full). The control board needs two outputs, specified by the table below: a drain pump that runs when the tank is nearly full, and a low-level warning. Plot each output column on a 4×4 Karnaugh map, read off the minimal groups, and implement the result as gates.

Truth Table

Levell3 l2 l1 l0pumplowLevell3 l2 l1 l0pumplow
00000018100000
10001019100100
200100110101010
300110111101110
401000012110010
501010013110110
601100014111010
701110015111110

Interface

PortDirectionTypeDescription
levelin4-bit vectorTank fill level, 0 to 15
pumpout1 bitDrain pump on
lowout1 bitLow-level warning

Behavior

  • pump and low match their truth-table columns for every one of the 16 input values; the testbench sweeps them all
  • The outputs are pure functions of level: no state, no clock

Constraints

OPERATORS

build each output from individual bits of level using only and, or, not (&, |, ~); no arithmetic, no comparisons.

  • Implement the K-map result: low is a single two-literal term, and pump is two two-literal terms ORed. The testbench can only check values, but anything bigger means your groups are too small.
Loading editor...

Click Run to execute your code. Output will appear here.