#!/usr/bin/env bash # SPDX-License-Identifier: MIT # Rung 0 (the reference's rung 0: the bus schedule is WDC's): the opcode table # equals the reference's, and the reference's own rung 0 states (its # tests/test_schedule.py generator and seeds, 200 states for every opcode in # emulation mode and in native mode with each M/X pair: 256,000 instructions) # run on both cores with every cycle's address, value and eight pins, the # final registers and the memory identical. The reference's lines are cached # per pin ($REFERENCE_CACHE/rung0-200.txt). set -euo pipefail source "$(dirname "$0")/env.sh" require_reference export W65C816_PYTHON nice -n 19 cargo build --release -q --manifest-path "$ROOT/Cargo.toml" "$REFERENCE_PYTHON" "$ROOT/scripts/check_tables.py" "$ROOT/target/release/trace" states="$ROOT/external/rung0" if [ ! -s "$states/ff.n11.json" ]; then nice -n 19 "$REFERENCE_PYTHON" -I "$ROOT/scripts/rung0_states.py" "$states" --states 200 fi expected="$REFERENCE_CACHE/rung0-200.txt" mkdir -p "$REFERENCE_CACHE" if [ ! -s "$expected" ]; then nice -n 19 "$REFERENCE_PYTHON" -I "$ROOT/scripts/reference_sst.py" "$states" --out "$expected" --jobs "${JOBS:-3}" fi nice -n 19 "$ROOT/target/release/sst" "$states" --dump "$ROOT/external/rung0.rust.txt" --jobs "${JOBS:-4}" if cmp -s "$expected" "$ROOT/external/rung0.rust.txt"; then echo "rung 0: passed, $(wc -l < "$expected") states, every cycle identical to the reference's" else cmp "$expected" "$ROOT/external/rung0.rust.txt" || true echo "rung 0: FAILED (the first differing line names the case)" exit 1 fi