# auto-arch-tournament

> An autonomous loop that evolves a RISC-V CPU, verified before every merge

- Category: AI Coding / Autonomous Coding Agents
- Language: SystemVerilog
- Repository: https://github.com/FeSens/auto-arch-tournament
- Canonical page: https://ai-tldr.dev/tools/auto-arch-tournament/
- Updated: 2026-04-29

## In short

auto-arch-tournament is an autonomous research loop pointed at hardware instead of software. It sits in the Autonomous Coding Agents category of the AI Coding tools and is open-source, written in SystemVerilog. To get started: install the toolchain.

## Overview

auto-arch-tournament is an autonomous research loop pointed at hardware instead of software. Each round, a coding agent proposes a microarchitectural hypothesis for a SystemVerilog RV32IM CPU, implements it in an isolated git worktree, and then runs it through a verification gauntlet: riscv-formal, Verilator co-simulation, and three-seed FPGA place-and-route. Only a hypothesis that beats the current champion on CoreMark/MHz gets merged, which is what keeps the loop from drifting into changes that look clever and measure worse.

The repository is multi-core by design. Every architecture lives under `cores/<name>/` with its own RTL, tests, log and `core.yaml`, and `make loop TARGET=<name>` runs the loop on one core at a time on a dedicated `core-<name>` branch inside its own worktree — so two cores can iterate in parallel without colliding on the git index. Within a round the work is split between a hypothesis agent, which writes a schema-validated YAML proposal after reading the source RTL, recent log entries, `LESSONS.md`, `CORE_PHILOSOPHY.md` and `core.yaml`, and an implementation agent that edits the RTL.

The published run that produced `cores/v1/` from `cores/baseline/` tried 73 hypotheses over 9 hours 51 minutes and accepted 10. The champion went from 301.04 iter/s (2.226 CoreMark/MHz, 135 MHz) to 577.76 iter/s (2.908 CoreMark/MHz, 199 MHz) — a 92% fitness gain with 40% fewer LUTs — with accepted winners including a backward-branch taken predictor, a cold multi-cycle DIV/REM unit, a one-deep store retirement slot and several I-fetch replay predictors. Setup is macOS-only for now and needs a coding-agent CLI; Codex is the default and Claude Code is supported with `AGENT=claude`.

## What it does

- A full propose → implement → verify → merge loop, where only measured improvements over the reigning champion are kept
- Verification gauntlet on every candidate: riscv-formal, Verilator co-simulation and 3-seed FPGA place-and-route
- Multi-core repository layout — each architecture under `cores/<name>/` with its own RTL, tests, log and `core.yaml`
- Isolated git worktrees on per-core branches, so several cores can iterate in parallel without stomping each other
- Configurable per-target fitness goals (`LUT=`, `COREMARK=`) and parallel candidate slots per round (`K=`)
- `setup.sh` fetches the whole toolchain — Verilator, OSS CAD Suite (yosys, nextpnr-himbaechel, sby, bitwuzla) and a RISC-V cross compiler — reusing anything already on PATH

## Getting started

The project is macOS-only at present. Install the toolchain once, then drive everything through the Makefile — every core-touching target requires an explicit TARGET.

1. Install the toolchain

   One-time setup that fetches Verilator, the OSS CAD Suite, the riscv-none-elf cross compiler and a few Python dependencies into .toolchain/.

```bash
bash setup.sh
```

2. Smoke-test one round

   Runs a single round in a single slot so you can watch the pipeline end to end. You also need a coding-agent CLI installed; Codex is the default.

```bash
make next TARGET=v1
```

3. Run the tournament

   N sets the number of rounds and K the parallel candidate slots per round. Fitness goals can be set per target.

```bash
make loop TARGET=v1 N=10
make loop TARGET=v1 N=10 K=3
make loop TARGET=v1 N=10 LUT=3000 COREMARK=400
make loop TARGET=v1 N=10 AGENT=claude
```

4. Fork your own core and read the results

   Start a new architecture from the locked baseline, then summarise what the loop accepted and rejected.

```bash
make loop TARGET=mycore BASE=baseline N=10
make report TARGET=v1
```

## When to use it

- Run an overnight optimisation tournament on your own RTL core and wake up to only the changes that passed formal checks and synthesis
- Study how an agent-driven design loop behaves when every merge is gated by a hard, measurable fitness function
- Iterate on several microarchitectures in parallel, each on its own branch and worktree
- Use it as a worked template for agent loops in other verifiable domains, where a verifier — not the model — decides what is kept

## Version history

- 2026-04-29: AI/TLDR covered the project's Show HN. The published run tried 73 hypotheses in 9h51m and lifted the champion core from 301.04 iter/s (2.226 CoreMark/MHz) to 577.76 iter/s (2.908 CoreMark/MHz), a 92% fitness gain with 40% fewer LUTs.
