SN74HCS138 address-decoding witness checker
==========================================

Run these commands beside decode_witness.py with Python 3.9 or later.
The checker uses Python's standard library.

    python3 decode_witness.py model
    python3 decode_witness.py template > my-observations.csv
    python3 decode_witness.py example > my-constructed-example.csv
    python3 decode_witness.py check my-observations.csv
    python3 decode_witness.py check constructed-example.csv
    python3 -m unittest -v test_decode_witness.py

model writes JSON with 32 calculated predictions. Each outputs array lists
eight logic bits in order Y0 through Y7. The two CSV commands cover the eight
required combinations of ignored or window and 2, 3, 10 or 11. Use a copy of
observations-blank.csv or generate your own template. The example contains
synthetic 0.000 V and 4.500 V values and every row is marked constructed.

For measurements you performed, enter reported in record_kind and enter
Fluke87VMAX_6VDC in meter_profile if you used that meter in its manual 6 V DC
range. Enter all 17 voltage readings per row and answer both procedure flags
with yes or no. Leave unavailable readings or metadata empty. Preserve the CSV
header and all columns. Trial IDs use 1 to 32 ASCII letters, digits, underscores
or hyphens. Each ID and phase/word pair appears at most once. Rows may be
reordered. Keep earlier trials as separate files when repeating a worksheet.

Use UTF-8 with or without its leading byte-order mark and a file of at most
1,048,576 bytes. Phase, word, ID and enum values use exact spelling. Only the
word tokens 2, 3, 10 and 11 are accepted. Use an empty field for a blank.
Whitespace-only values and leading or trailing padding are format errors.
Voltages use at least one ASCII digit and may include a sign and decimal
point. The limits are nine fractional digits, 32 characters and a
magnitude of 1000 V. Scientific notation and nonfinite values are invalid.

The worksheet screens both supply readings at 4.45 to 4.55 V with at most
0.020 V difference. The terminal display domain is -0.020 V through the start
supply reading plus 0.020 V. If the start reading is blank, the upper display
bound is unavailable. The checker retains comparisons based on the readings
it has. In-domain readings up to 0.300 V count as LOW and readings from 4.200 V
count as HIGH. Values in between are ambiguous. Output-state comparison waits
for known and correct word and enable states. Supply, flag and terminal display
violations still appear in the row reasons.

The check command writes a JSON analysis report to standard output.

    0  All eight constructed witnesses are consistent, or all eight
       reported witnesses are consistent.
    1  At least one known worksheet mismatch.
    2  File, encoding, CSV or field-format error. No rows are accepted.
    3  Incomplete, ambiguous or mixed-kind worksheet with no known mismatch.

Check observations-blank.csv for an example of exit 3 and
constructed-example.csv for an example of exit 0. Command-line help and
invocation errors use argparse text with its usual exit codes 0 and 2.

The screens are worksheet rules for this static exercise. Every analysis and
model report sets physical_verified to false. Reported rows reflect the
operator's stated measurements. Consistency checks cover the supplied static
readings and the specified eight-pair worksheet. The 32 calculated states
cover the complete four-bit model.
