Learn
0/8
0/6
0/6
0/6
0/6
Practice
Tank Level Decoder (K-Map)
A rainwater tank needs a drain pump at levels 10 to 15 and a low-level warning at levels 0 to 3.
Implement both outputs with gates, using a Karnaugh map to simplify them.
The 4-bit input level_i runs from 0 (empty) to 15 (full).
Optional practice if you already use K-maps comfortably.
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_i | in | 4-bit vector | Tank fill level, 0 to 15 |
pump_o | out | 1 bit | Drain pump on |
low_o | out | 1 bit | Low-level warning |
Behavior
pump_oandlow_omatch their truth-table columns for every one of the 16 input values; the testbench sweeps them all- The outputs are pure functions of
level_i: no state, no clock
Constraints
OPERATORS: build each output from individual bits of
level_iusing onlyand,or, andnot; no arithmetic and no comparisons.
- Use the largest legal K-map groups. The hints can help if you cannot simplify a group further.
- The tests check the truth table. Check the grouping on your own map as well.
Loading editor...
Click Run to execute your code. Output will appear here.