Learn
0/8
0/6
0/6
0/6
0/6
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
| Level | l3 l2 l1 l0 | pump | low | Level | l3 l2 l1 l0 | pump | low | |
|---|---|---|---|---|---|---|---|---|
| 0 | 0000 | 0 | 1 | 8 | 1000 | 0 | 0 | |
| 1 | 0001 | 0 | 1 | 9 | 1001 | 0 | 0 | |
| 2 | 0010 | 0 | 1 | 10 | 1010 | 1 | 0 | |
| 3 | 0011 | 0 | 1 | 11 | 1011 | 1 | 0 | |
| 4 | 0100 | 0 | 0 | 12 | 1100 | 1 | 0 | |
| 5 | 0101 | 0 | 0 | 13 | 1101 | 1 | 0 | |
| 6 | 0110 | 0 | 0 | 14 | 1110 | 1 | 0 | |
| 7 | 0111 | 0 | 0 | 15 | 1111 | 1 | 0 |
Interface
| Port | Direction | Type | Description |
|---|---|---|---|
level | in | 4-bit vector | Tank fill level, 0 to 15 |
pump | out | 1 bit | Drain pump on |
low | out | 1 bit | Low-level warning |
Behavior
pumpandlowmatch 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:
lowis a single two-literal term, andpumpis 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.