Files
CoCo3_Plus_MiSTer/verilator/tests/fujinet_boot.sh
Alan SterembergandClaude Opus 5.5 874f4f3083 Add Verilator simulation (ImGui + headless)
verilator/ runs the core on the host with the shared FM-7 / Apple-IIgs sim
framework: windowed (ImGui/SDL2) or --headless, typing on a frame schedule,
screenshots, text-screen dump, 6809 disassembly trace, floppy/SDC/cart/cassette,
and RS-232 Pak serial debugging (TXD decoder, RXD driver, pty bridge, ACIA
trace) with a minimal DriveWire server and a script to run the real FujiNet
daemon against the sim. See verilator/README.md.

- The VHDL the build uses (ROMs, RAMs, font) is converted to Verilog in
  verilator/rtl/; the VHDL CPU is not instantiated (CoCo3_CYC_ACC_6809).
- sdram2.sv is simulated with its own controller logic and an SDR chip model.
- run_tests.sh: boot, keyboard, disk, WIDTH 80 and HSCREEN tests, judged on
  the text screen and byte-for-byte against test-ref/ screenshots.

rtl/wd1793.sv: spt_addr and buff_wr are declared at module scope instead of
inside generate blocks. They are assigned outside those blocks; Quartus
accepted it, Verilator rejected spt_addr and silently split buff_wr into a
separate net. No change on the FPGA (FM-7 made the same fix).

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
2026-10-02 07:15:44 -04:00

52 lines
1.9 KiB
Bash
Executable File

#!/usr/bin/env bash
#
# Boot a FujiNet cart against the real FujiNet daemon (FujiNet-PC, the same code
# the MiSTer build runs on the HPS), bridged to the sim's RS-232 Pak by a pty.
#
# tests/fujinet_boot.sh FUJINET_DIST CART STOP_FRAME [extra sim args...]
#
# FUJINET_DIST a FujiNet-PC `make dist` directory for FUJINET_TARGET=COCO
# (fujinet binary + data/). A copy is made; the original is not
# touched.
# CONFIG env: fnconfig.ini to start from (default: FujiNet_MiSTer's
# config/fnconfig.ini). Only [Serial] port is changed.
#
# tests/fujinet_boot.sh ~/fn/dist ../../FujiNet_MiSTer/roms/HDBDW3L3_19200.CCC 400 \
# --fast-clocks
#
# Output in $OUT (default fujinet_boot/): sim.log, fujinet.log, screenshot.
set -u
cd "$(dirname "$0")/.."
[ $# -ge 3 ] || { sed -n 3,18p "$0"; exit 2; }
dist=$1; cart=$2; stop=$3; shift 3
config=${CONFIG:-../../FujiNet_MiSTer/config/fnconfig.ini}
out=${OUT:-fujinet_boot}
rm -rf "$out"; mkdir -p "$out/fn"
cp -R "$dist"/. "$out/fn/"
mkdir -p "$out/fn/SD"
./obj_dir/Vemu --headless --cart "$cart" --serial-pty --stop-at-frame "$stop" \
--screenshot "$stop" --screenshot-prefix "$out/shot" --ascii-end "$@" > "$out/sim.log" 2>&1 &
sim=$!
pty=
for _ in $(seq 1 100); do
pty=$(grep -o '/dev/ttys[0-9]*\|/dev/pts/[0-9]*' "$out/sim.log" | head -1)
[ -n "$pty" ] && break
sleep 0.1
done
[ -n "$pty" ] || { echo "sim did not open a pty"; kill $sim; exit 1; }
sed "s|^port=.*|port=$pty|" "$config" > "$out/fn/fnconfig.ini"
echo "sim on $pty; FujiNet config from $config"
( cd "$out/fn" && exec ./fujinet -c fnconfig.ini -s SD ) > "$out/fujinet.log" 2>&1 &
fn=$!
trap 'kill $sim $fn 2>/dev/null' INT TERM
wait $sim
kill $fn 2>/dev/null
echo "--- sim"
grep -E '^\||^Serial' "$out/sim.log" | grep -v '^| *|$'
echo "--- FujiNet (DriveWire lines)"
grep -a -i -E 'drivewire|op_|readex|read |sector|lsn|timeout|checksum|mount|serial' "$out/fujinet.log" | head -60