#!/usr/bin/env bash # SPDX-License-Identifier: MIT # Rung 0: the tables. The decode table and dispatch regenerated from the reference's # _decode.py must equal src/decode.rs and src/dispatch.rs; then every table the core # decodes with (all 65,536 encodings' handler, plan, load-use registers, slot-illegal and # interrupt flags, their disassembly at 4n and 4n + 2, every pipeline class and plan, the # on-chip register map) must equal the reference's, line for line; then cargo test. # BIN: another build of sh2-trace to judge (scripts/seeded_faults.py uses it). set -euo pipefail source "$(dirname "$0")/env.sh" require_reference CACHE="$ROOT/external/reference-cache/${SH2_PYTHON_PIN:0:12}" mkdir -p "$CACHE" if [ -z "${BIN:-}" ]; then "$REFERENCE_PYTHON" "$ROOT/scripts/gen_decode.py" "$SH2_PYTHON" --check build BIN="$ROOT/target/release/sh2-trace" fi [ -f "$CACHE/tables.txt" ] || nice -n 19 "$REFERENCE_PYTHON" "$ROOT/scripts/tables_reference.py" "$SH2_PYTHON" "$CACHE/tables.txt" OUT=${OUT:-"$ROOT/external/ours/main"} mkdir -p "$OUT" "$BIN" --tables "$OUT/tables.txt" if cmp -s "$CACHE/tables.txt" "$OUT/tables.txt"; then echo "rung 0 tables: $(wc -l < "$CACHE/tables.txt") lines identical (65,536 encodings, 30 classes, 512 on-chip addresses)" else echo "rung 0 tables: DIFFERENT"; diff "$CACHE/tables.txt" "$OUT/tables.txt" | head -5; exit 1 fi