#!/usr/bin/env python3 """Elaborate the netlist-derived Verilog of the GPU and the DSP under Verilator. This is the first step of the Verilog referee (docs/validation.md, "The netlist as a referee"): it proves that each processor "island" stands alone as a top module with no missing cell, so a single-instruction testbench can be built around it. It builds nothing and writes nothing (``--lint-only``). Islands checked: - ``mister-dsp`` ``_j_dsp`` in the MiSTer core (rtl/Jerry + rtl/jaguar_common) - ``mister-gpu`` ``_graphics`` in the MiSTer core (rtl/Tom + rtl/jaguar_common): the GPU with its gateway, local RAM and the Blitter - ``torlus-gpu`` ``graphics`` in JagNetlists (verilog/tom + verilog/base): the gate-for-gate translation of the netlist python -I scripts/lint_referee.py --oss ../sm83-python/reference/build/oss-cad-suite Verilator comes from an oss-cad-suite bundle (the family keeps one under sm83-python and 65816-python's reference/build); this script does not fetch it. The MiSTer RAM cells have an Altera branch and a plain one: ``SIMULATION`` selects the plain one. """ from __future__ import annotations import argparse import subprocess import sys import time from pathlib import Path ROOT = Path(__file__).resolve().parents[1] MISTER = ROOT / "reference" / "src" / "Jaguar_MiSTer" / "rtl" TORLUS = ROOT / "reference" / "src" / "JagNetlists" / "verilog" QUIET = ["-Wno-fatal", "-Wno-lint", "-Wno-style", "-Wno-TIMESCALEMOD", "-Wno-MODDUP"] STOPPED = ( "lint_referee.py is retired (2026-11-25, decisions L4 and L5): its islands are the\n" "MiSTer RTL (GPL-2.0, not fetched since 2026-11-24) and JagNetlists' Verilog (no\n" "licence, not kept since 2026-11-25). A Verilog referee is owed as a run-only tool\n" "in emu-tools-gpl whose output this repository reads (docs/provenance.md)." ) def islands() -> dict[str, tuple[Path, list[str]]]: common = sorted(str(p) for p in (MISTER / "jaguar_common").glob("*.v")) jerry = [str(MISTER / "Jerry" / name) for name in ("j_dsp.v", "j_dsp_ram.v", "j_sinerom.v", "raa016a.v")] tom = sorted(str(p) for p in (MISTER / "Tom").glob("*.v")) torlus = sorted(str(p) for p in (TORLUS / "tom").glob("*.v")) torlus += sorted(str(p) for p in (TORLUS / "base").glob("*.v")) return { "mister-dsp": (MISTER, ["-DSIMULATION", "-I.", "-Ijaguar_common", "--top-module", "_j_dsp", *jerry, *common]), "mister-gpu": (MISTER, ["-DSIMULATION", "-I.", "-Ijaguar_common", "--top-module", "_graphics", *tom, *common]), "torlus-gpu": (TORLUS, ["-I.", "-Ibase", "-Itom", "--top-module", "graphics", *torlus]), } def main() -> int: parser = argparse.ArgumentParser(description=__doc__.split("\n\n")[0]) parser.add_argument("--oss", type=Path, required=True, help="an oss-cad-suite directory") parser.add_argument("island", nargs="*", help="default: all three") args = parser.parse_args() raise SystemExit(STOPPED) verilator = args.oss / "bin" / "verilator" failures = 0 todo = islands() for name in args.island or todo: cwd, arguments = todo[name] started = time.monotonic() result = subprocess.run( [str(verilator), "--lint-only", *QUIET, *arguments], cwd=cwd, capture_output=True, text=True, check=False, ) errors = [line for line in result.stderr.splitlines() if line.startswith("%Error")] sources = sum(1 for a in arguments if a.endswith(".v")) print(f"{name}: {sources} files, {len(errors)} error(s), " f"{time.monotonic() - started:.1f} s") for line in errors[:10]: print(" " + line[:200]) failures += bool(errors) return 1 if failures else 0 if __name__ == "__main__": sys.exit(main())