Saturn MiSTer Core Optimizations Overcome Chock-Full FPGA

The Saturn MiSTer core’s most requested feature is finally here: the FPGA device’s LEDs now mimic an actual Saturn’s power and disc read lights.

OK, maybe that isn’t the most requested feature, but it is one of the improvements found in a set of updates to the core uploaded Thursday to the project’s GitHub. More importantly, the core’s been optimized to make it easier to compile into a usable build after compilation proved difficult the previous month because of how large the core is.

None of these updates are available on the main branch of the MiSTer, accessible when users run “update_all,” which was last updated in October. Instead, they’re in “unstable nightlies” cores that can be downloaded from the unstable nightlies channel on the MiSTer Discord server.

There are separate builds for MiSTers with a single RAM chip and those with dual RAM chips because the core is able to offload some functions to the extra memory afforded by dual RAM setups to free up some of its onboard resources.

That’s important because those onboard resources are at their breaking point. The Saturn core is using nearly all of the adaptive logic modules available on the MiSTer’s hardware platform, the DE-10 Nano. That gives programs like Quartus fits when trying to build it into a usable RBF file.

Zet-sensei, who works closely with Saturn core developer Sergiy “SRG320” Dvodnenko to test updates, made it clear how tough it is to build the core now. “It’s quite difficult, indeed,” he said. “My computer wants to die.”

According to the project’s GitHub, these are the updates that Dvodnenko made this week:

  • SH:
    • rework the exceptions (sstests)
    • fix the decoding of an invalid LRU (sstests)
    • fix associative purge for cache (sstests)
    • fix vector for the reset exeption
    • fix DRAM space recognition
    • some optimization
  • VDP1, VDP2:
    • some optimization
  • SMPC:
    • fix the INTBACK optimal time for different vertical resolution (Primal Rage regression)
    • latch the parameter for the INTBACK command earlier (Crusader – No Remorse freeze)
    • fix MD_ID precedence in stunner/nothing detection
  • Miscellaneous:
    • Fix emulated controllers.
    • Lightgun: reset the registers to prevent using BRAM as a shift register
    • Use LEDs to indicate disc and save activity.
    • fix ST-V compilation

The improvements come more than a month since the last time Dvodnenko updated the core on April 3. That update proved particularly difficult for compilation, with the community simply unable to successfully make a single RAM build and barely able to make a dual RAM one.

“In short, SRG320 worked tirelessly on it; it was exhausting for him,” Zet-sensei said. “Now let’s enjoy the Saturn core once more, and thank him.”

Dvodnenko first released a playable build of the core to the public in May 2022 and has updated it many times since then. It was first added to the main MiSTer branch in October 2023, indicating that it was mature enough to be available to all MiSTer users rather than as an optional core that had to be added manually.

Anyone interested in supporting Dvodnenko can do so at his Patreon.

The MiSTer is a field-programmable gate array, a chip that can be changed by programming it to physically emulate retro video game consoles. It includes an SD card reader from which “cores” and games can be loaded.

The cores are the programming that tells the FPGA chip how to configure itself to reproduce the performance of a console. There are cores for a wide array of consoles, from the Atari 2600 to the PlayStation — and, of course, the Saturn.

LED feature squeezes in

The LED feature actually came after an off-hand question by Kanel in the MiSTer Discord, who said, “In the PlayStation core, when accessing disk (SD or pendrive at least) the yellow led lights up. It isn’t happening with the Saturn core, right? Any plans for implementing it @srg320?”

The red, yellow and green LEDs on a MiSTer Pi.

While many in the Discord dismissed Kanel’s request as superfluous, arguing that the core is already too full, it did successfully bring the light functionality to Dvodnenko’s attention.

“I haven’t really looked into how LEDs work,” Dvodnenko said. “In fact, yesterday was the first time I’d ever paid attention to LEDs in all the years I’ve been using MiSTer.”

Just a week later, the MiSTer’s on-board LEDs now imitate a model 1 Saturn’s power and disc read lights — using the MiSTer’s red and yellow LEDs, respectively — as well as indicate when it’s saving data with the green LED.

“Sometimes it’s nice to know if the thing is accessing data, or is it just frozen,” said Zakk, a member of the MiSTer Discord.

Some members of the community joked about the LED functionality actually being implemented, but Kanel is keeping receipts.

“Smile while you can,” Kanel said. “The day I catch one of you answering somebody ‘check if the yellow light is up to see if it’s working or frozen’ or ‘check the green light to see if the save status has been registered correctly’ I’m gonna charge you with one coin; half for SRG320 and half for moral compensation.”

Compilation difficulties

The last time SHIRO! wrote about the core was March 20. At the time, users had difficulty building the single RAM core because it was trying to use more resources than the MiSTer’s hardware platform, the DE-10 Nano, has.

Over the next two weeks, there was a smattering of updates, and the compilation problem only got worse.

Those updates issued between March 22 and April 3 were:

  • SH core:
    • fix interrupt-blocking instructions (sh2test, scutest).
    • fix the determination of data fetch instructions (sh2test)
  • SH7604:
    • some fixes from Jotego.
    • fix interrupt priority (sh2test)
  • VDP1:
    • minor optimization.
  • Miscellaneous:
    • Add option to load the disc without resetting.
    • core modules comply with verilator linter
    • verilator lint OK
    • Pad code optimization.

On March 26, one MiSTer user, TheJesusFish, struggled to get a successful compilation of the core.

A screenshot of Saturn core compilation attempts by TheJesusFish.

“The Saturn core is not well,” TheJesusFish said. “I did 100 compilations. These are the builds that succeeded.”

He then posted the screenshot at the right, adding, “seed 6 is, in fact, the winner.”

When someone on the Discord server asked if there was space left on the core to use modern controllers’ right analog sticks as analog shoulder buttons — the MiSTer doesn’t support analog shoulder buttons for any core yet — Dvodnenko shot it down with a stark assessment.

“There isn’t any free space,” he said. “Rather, I need to free up some space to improve the compilation. If I can’t find a way to free up space, I’ll have to remove some features.”

Another person on the server lamented the fate of their own requested feature. “That sucks. I’m guessing that means there’s no room to add cheat support for Saturn?” they asked.

“It seems like you don’t realize how serious the situation is,” Dvodnenko replied. “It may even be necessary to remove features that have already been added.”

“We are in a dire situation,” Zet-sensei said.

At the time on April 1, Zet-sensei said the single RAM core was using 99% of the DE10 Nano’s adaptive logic modules, or ALMs, while the dual RAM core was using 98% of them.

A screenshot of birdybro’s dual RAM Saturn Core compilation showing the DE-10 Nano’s ALMs are at 99% capacity.

A person on the server named birdybro checked and found similar numbers, posting the screenshot on the right.

“Current default numbers for my own reference since I was curious,” birdybro said. “That’s from the dual SDRAM build … this is honestly really shocking that this even compiles, simply stunning.”

But the update on April 3 proved to be too much for the DE-10 Nano. Zakk reported at the time that both dual and single RAM nightly builds failed, prompting the community to attempt manual builds.

“I have a [compiled the] dual RAM core,” Zet-sensei said at the time. “I removed the VDP1 Blur mesh option and done some compile optimizations on the single RAM version. I’m waiting a final compilation within the next 30 minutes.”

But that effort failed. “I give up for the single RAM one,” he said.

Dual light guns almost on the chopping block

Apparently searching for ways to fit the core within the DE-10 Nano’s available ALMs again, Dvodnenko posed a question: “How necessary is support of two virtual light guns?”

That caused a lot of consternation among users who would miss using two light guns in games like Virtua Cop 1 and 2 and House of the Dead.

“No one is deleting anything yet. Just a question,” he said. “But the fact remains that the virtual light gun’s code needs to be optimized.”

A screenshot from Dvodnenko showing the ALMs used by some of the Saturn core’s elements, including its light gun code.

ElectronAsh originally wrote the MiSTer’s light gun code. He chimed in with some thoughts on optimization.

“I can’t imagine there’s much of a saving to be made with the light gun stuff, but I could be wrong,” ElectronAsh said. “It really is a small bit of code / logic, but then [SRG320] is very good at that stuff. It’s just the core itself is so massive now. … Having said that, ~133 ALMs (roughly 351 Logic Elements in old-skool Cyclone speak) is still a fair bit, for what it’s doing. For one thing, there are probably more efficient ways to generate the crosshair.”

Dvodnenko clarified that he meant the combination of two light gun modules into one to save ALMs. “The first thing that comes to mind is combining two identical modules into one,” he said. “That way, you can use just one set of h/v counters and possibly some calculations.”

About a month later, dual light gun functionality remains in the core. Its code apparently got an optimization to “reset the registers to prevent using BRAM as a shift register.” It remains to be seen if further optimizations can be made or the feature will be cut in favor of other improvements to the core.

About the author

Danthrax

Danthrax is a member of the SHIRO! Media Group, writing stories for the website when Saturn news breaks and helping to manage the group's social media accounts. While he was a Sega Genesis kid in the '90s, he didn't get a Saturn until 2018. It didn't take him long to fall in love with the console's library as well as the fan translation and homebrew scene. He contributed heavily to the Bulk Slash and Stellar Assault SS fan localizations, and he's helped as an editor on several other Saturn and Dreamcast fan projects such as Cotton 2, Rainbow Cotton and Sakura Wars Columns 2.

Be the first to comment

Leave a comment

Your email address will not be published.


*