FPGAs Aren't Magic
FPGAs Aren't Magic2019-12-27 07:22:49
Note: this article was originally written on February 6th, 2018. I tried to present an unbiased look that expresses the pros and cons of each approach, but it seems that the underlying message was lost.
The original intent of this article was to express that whether coding in Verilog for FPGAs, or C++ for PCs, these languages are both Turing-complete. That is to say, there is absolutely nothing that one can do that the other cannot. It's only a matter of computational resources and energy cost.
The reason for writing this article originally was that I felt software emulators were given an undue bad rap for the purpose of marketing a product. I can state objectively that software emulation today is more accurate than the best FPGA cores. In fact with new projects such as MiSTer, a more collaborative open-source approach to FPGA emulator development has emerged, and we are now combining our resources and sharing our work.
I am a proponent of both FPGAs and software emulators. All I ask is that each approach is given the respect they each deserve.
Recently, there's been a lot of news hype around the Analogue Super Nt. And unfortunately, sites like Polygon are putting out glorified press releases instead of reporting factual information. So I'd like to dispel some dangerous misrepresentations now before they spread further.
- FPGA devices are emulators too
- nothing inherently makes FPGAs more accurate than software emulation
- latency is caused by host operating systems, not by choice of programming language
- the Analogue CEO is selling you a product; so expect hyped marketing claims
As immediate evidence that the Super Nt is not perfect, the initial hardware release ships with a bug that causes Rendering Ranger to be unplayable. I am sure it will be fixed soon, but it demonstrates right away that the Super Nt is not a perfect clone of the SNES.
I have nothing against the Analogue Super Nt. I think it's a great product. In fact, I'll start by conveying by what I perceive as its benefits.
Over software emulators:
- reduced latency as a result of being a single-purpose device with no OS overhead
- lower power consumption at the same degree of accuracy as a software equivalent
- lower cost of ownership if one does not already own a capable PC
- instant-on capability
Over real hardware:
- HDMI output bypasses the need for expensive XRGBs or analog-RGB CRTs
But it also has its limitations:
- it costs $190; about five times what a real SNES goes for
- it runs at 60hz instead of the proper 60.09hz of a real SNES
- it can run at 60.09hz, but only with either frame-dropping or tearing
- no support for video filters, save states, real-time rewind, netplay, etc
- playing homebrew, hacks, translations, MSU1 games, etc requires an expensive flash cartridge
- cannot be used as a debugger for homebrew, ROM hacks, speedruns, etc
- if one has a PC: this takes up additional space, a power outlet, and an HDMI port
And of course, higan has its own limitations, in addition to the four things above which the Super Nt does better, it also:
- is incredibly slow
- has a complex user interface
- requires copyrighted firmware to run games containing DSP coprocessors
- is missing some software features of other emulators (netplay and rewind)
The way I see it: there's no such thing as perfection. Everything has its pros and cons. And everyone is going to have different priorities and values. It's a *good* thing that both the Super Nt and higan exist. We can coexist cooperatively instead of competing with one another.
All emulation works the same way: we study the original hardware, read documentation and datasheets, develop test code to run on hardware to verify our claims, and then implement the results in source code.
The end product attempts to provide a faithful recreation of the original hardware. The accuracy of this recreation is bounded by raw processing power: that is to say, more accurate emulation requires more resources.
There are those that will take shortcuts, and Chrisopher Taber, the CEO of Analogue, brought those emulators up in the Polygon article.
But absent from the article was any mention of software emulators that are serious about emulation: projects like higan (SNES), BlastEm (Genesis), gambatte (Game Boy Color), mGBA (Game Boy Advance), etc.
Instead, you have the following quotes:
"No matter how hard the (software emulator) developers try, the games will never sound exactly the same as the browning lump of plastic in your closet. Slight imperfections mar even the best emulators: the audio will bleep out for a second, or a sprite will flicker when it should fade."
"Mention the word "emulator" to him, and he'll immediately rev up his proselytizing process."
These quotes are deeply unfair. higan currently has zero known emulator bugs, despite us having tested the entire SNES library with it. No audio drop-outs, no sprite flickering instead of fading, nothing.
There are no examples provided in the article pointing to any issues with higan, because for more than a decade, I've fixed any and all reported SNES emulation bugs within days of them being reported to me.
Of course, it's not perfect. And neither is the Super Nt. You see, the Super Nt is not a real SNES. It is not a perfect transistor-level replication of the original hardware. It is prone to the same bugs, and goes through the same bug-fixing and improvement process as higan does. The Super Nt will never be the same as the browning lump of plastic in your closet, either. Yet this isn't mentioned in the article.
FPGAs, or field-programmable gate arrays, are components that are programmed through code written in languages such as Verilog or VHDL. This code tells the component how to operate, in the same way that C++ instructs a general purpose CPU how to operate.
How these two differ behind the scenes (logic gates versus microcode) is irrelevant to the end result: replicating the original hardware experience. Setting efficiency aside, there is absolutely nothing an FPGA can do that cannot be done in software. And indeed, there is nothing the Super Nt does that higan does not.
FPGAs may be inherently more parallel, which is beneficial for resource usage, but modern CPUs are really, really good about context switching. Software emulators can and do verifiably simulate down to the tiniest possible clock cycle, the parallel nature of real hardware simply by using more resources.
If you believe that HDLs such as Verilog are magic, consider that automated translators exist to transform C code into it. They just don't tend to operate as well in larger-scale applications. Yet.
In both cases, emulator developers are transforming their knowledge of how the original SNES works into source code that attempts to mimic their operation. Given equal knowledge of the original hardware and absolutely masterful potential, an FPGA implementation and a PC software implementation will be equally accurate.
In the case of higan, I've spent thirteen years working full-time on increasing my understanding of the SNES hardware, and refining my emulation of it. I've worked with dozens of people over the years to help me in this goal. The Super Nt has been in development for roughly one year. Furthermore, I consider its lead developer, Kevin Horton, a friend. We work together and share information. I'm in the credits on the Super Nt device for a reason: emulation is built on the shoulders of giants. The Super Nt is possible in part by higan, which was possible in part by Snes9X, etc. And indeed, the relationship is mutually beneficial: findings from Kevin have already made their way into higan.
An emulator is not measured by any one bug or lack thereof: it's the total sum of years of testing, validation, and tens of thousands of unique behaviors all operating together correctly in harmony. These things take time.
I don't want to write an article critical of the Super Nt itself, nor of its lead engineer. But I am very distressed at how Chris' words in this story paint all software emulators as inferior to his product, ostensibly for marketing reasons. Even if that isn't his intention, that's how this article reads.
The one area where the Super Nt will absolutely beat traditional emulators is in latency: how long it takes between when you press a button on the gamepad until you see and hear the result of said action on the screen.
The reason for this is once again not magic: the Super Nt runs without an operating system in the way. Yet when you run an emulator on your desktop, it has to share resources with a thousand other processes that also want access to your video card, your sound card, your input devices, etc. This time sharing results in added latency. A software emulator can reasonably expect to get within 30-50ms of the latency of a pure hardware approach.
But again, it's not magic: there is nothing preventing an emulator written in C from running on bare metal, without an operating system in the way. It isn't done only because the demand isn't there to produce a robust real-time kernel environment that gives software emulators direct ownership access to all hardware resources. And thus, emulator developers cannot bypass the need to share these resources. Yet.
But indeed, if latency is your primary concern, I concede that FPGA devices are currently the way to go. Software emulation latency is almost imperceptible these days with the advent of adaptive sync, WASAPI/ASIO, 1000hz USB polling, etc, but it cannot be eliminated so long as users wish to run emulators right alongside their web browsers and photo editors.
The best software emulators claim to reach within 8ms of real hardware latency, and with all the above in higan I myself can perceive no difference to my real hardware, however I do not have the equipment to verify such claims, so I will leave that to another discussion.
Chris is eager to tell you a story about his deep love for retro gaming. And I believe he is sincere.
But he is not the first to take SNES emulation accuracy seriously: I've been doing that since 2004.
But he is not in it to preserve the hardware for future generations: he's in it for the profit. His product is necessarily closed source. When the last Analogue Super Nt dies of old age, it will be a distant memory. It is a black box, just like the original SNES consoles.
I'm not going to begrudge someone for wanting to earn a living. But you need to understand: Polygon's article is nothing more than a product advertisement, devoid of any and all actual journalism and fact-checking. I am going to take issue with my life's work being misrepresented, as it has been here.
These clone consoles that take physical cartridges bypass the need to emulate the hardware that exists inside of game cartridges. Game cartridges will one day fail just as game consoles will. And when they do, the Super Nt will not help you play SuperFX games like Yoshi's Island, or SA-1 games like Super Mario RPG.
Software emulation preserves the complete environments in digital form, not just the base systems. Those are meaningless without any content for them.
A very important point in fairness to mention is that Kevin Horton has promised to release detailed timing documentation on his findings while developing the Super Nt product.
THAT is preservation. And that is extraordinarily commendable, and we should all be deeply appreciative of Chris, Kevin, et al when this happens.
Without the Super Nt, we wouldn't have this documentation in the future.
Yes, I wrote this piece because the Super Nt press intentionally neglects my own work. And on that note, here's the bottom line: The Super Nt is not more accurate than higan is. And if you claim otherwise ... then I say to you, prove it.
This is also not to say that higan is more accurate than the Super Nt is! Only time will tell. And given the personalities of Kevin and I, it's extremely likely that the moment any issue is observed in either of our products, we'll be fixing it as soon as possible. And hopefully, helping each other with that.
But this truly isn't just about me: it's about the inevitability of seeing this claim that FPGAs are inherently superior in accuracy to software emulators repeated for more systems in the future if we don't set the record straight now.
The Super Nt is a fine product, produced by a fine engineer: but please stop with the grandstanding accuracy boasts. They're patently false, devoid of any evidence of said claims, and they're disparaging to the people doing the real work of preserving our gaming history.
Permalink • 1 Comment
Mark2020-03-06 02:33:43So refreshing to hear from someone who can actually put hardware (FPGA) emulation into perspective! For too long it has been regarded as.. well, as you put it, "magic".
I'm not going to nitpick every word of your article, but as someone who has experience in both hardware and software emulation, and formal qualifications in both areas of engineering, you've got it right for the most part. And like you, I'm not taking anything away from FPGA emulation when I say that. I just don't like people claiming it to be what it isn't.