AcqRel's Factorio Yosys Project Puts a Fully-Functional RISC-V Core in the Popular Sandbox Game
Linking to your HDL project via Yosys, this Factorio extension means you can design actual hardware and implement it in-game.
Pseudonymous tinkerer "AcqRel" has taken the game Factorio to a dramatic new conclusion: the ability to compile and run a soft-core RISC-V processor in-game, thanks to a backend connecting it to the Yosys open synthesis suite.
"Ever played Factorio and thought 'I wish my factory had a RISC-V core,'"developer Frans Skarman writes of the effort, in a Mastodon post which brought the project to our attention. "Introducing Factorio Yosys! This is a project of a friend of mine not on Mastodon, so all credit to him. He built a full Yosys backend for Factorio that can now compile a RISC-V core."
Unveiled during a crowdfunding campaign in 2013 and officially launched in 2020, Wube Software's Factorio sees the player building, managing, and automating a factory in order to build and launch a rocket — after which the game is considered beaten, though can still be played as a sandbox. A number of in-game technologies can be researched to assist with the mission, though microprocessors implementing the RISC-V architecture aren't usually among them.
In the case of Factorio Yosys, the game is linked to the free and open Yosys synthesis suite that in turn can ingest hardware design language (HDL) projects — including a functional 32-bit RISC-V soft-core processor. "On the technical side, this is a super impressive project," Skarman says. "He formally verified parts of the flow and it does a whole bunch of optimizations to make the circuits surprisingly compact. It also worked on the first try with this RISC-V core! (I found more bugs in the core than he did in the compiler :D)"
Performance, as you might expect, can be an issue: with the game locked to a maximum framerate of 60 frames per second, the processor runs at just 1.82Hz — though this can be accelerated, Skarman notes, by uncapping the game's framerate. "And, of course, this is arbitrary HDL," Skarman adds, "so you can do other cool stuff [like] a working snake game!"
More information is available in Skarman's Mastodon thread, while AcqRel's source code has been published on Sourcehut under an unspecified license.