#!/usr/bin/env bash # SPDX-License-Identifier: MIT # Rung 0 (the reference's rung 0: every opcode's bus schedule): the handler and opcode # tables equal the reference's, and the reference's own rung 0 states (its # tests/test_bus_schedule.py generator and seeds: 300 states for each of the 254 opcodes # but SLEEP and STOP, 76,200 steps) run on both cores with every cycle's kind, address, # value and dummy flag, the final registers and the memory identical. The reference's # lines are cached per pin ($REFERENCE_CACHE/rung0.txt). set -euo pipefail source "$(dirname "$0")/env.sh" require_reference nice -n 19 cargo build --release -q --manifest-path "$ROOT/Cargo.toml" "$REFERENCE_PYTHON" -I "$ROOT/scripts/check_tables.py" "$ROOT/target/release/trace" states="$ROOT/external/rung0" if [ ! -s "$states/fe.json" ]; then nice -n 19 "$REFERENCE_PYTHON" -I "$ROOT/scripts/rung0_states.py" "$states" fi expected="$REFERENCE_CACHE/rung0.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