If you wish to support the Waffling Taylors, and the other shows in the network, you can over at Ko-fi.com/jayandjaymedia. However, supporting us is completely voluntary and not required at all.
Another way to support us is to shout out about us on social media or give us a rating on your podcatcher service of choice. The more people who listen to the show, the more shows we can do.
FPGAs are magic and hardware which runs them is traditionally more expensive than generic hardware with emulators installed on them. But why? Let’s find out.
This is The Waffling Taylors Raw with Jay, a series of shorter episodes of indefinite length. These episodes will cover shorter topics which don’t really fit well within the scope of the show, or topics that I want to cover in my own way. That’s not to say that we won’t cover these topics in the main show, but I’d like to take a whack at them here, first.
I can’t guarantee that all of these shorter episodes will always be as technical as this one. But I needed to a little deep in order to get the point across.
FPGAs are deeply technical, and while I wont go into too much detail
I’m all about using metaphor and analogy to get my point across
It’ll be worth having the show notes to hand, as I’ve added a whole bunch of links in there.
Anyway, let’s get to it.
FPGAs are Magic
As you just heard, FPGAs can be rather complex, and I want to try and explain their use in gaming through the use of analogy and metaphor.
There’s a wonderful quote from Science Fiction writer Arthur C. Clarke:
Any sufficiently advanced technology is indistinguishable from magic
This is part of his three laws, which he used to inform his writing.
He was writing about fantastical things like space travel and futurism, focussing on what could be. I don’t think any sci-fi writers of his day could credibly dream of a time when electronic components could actually change their composition at will, but that’s almost exactly what FPGAs can do.
Before we start, let’s clarify what FPGA stands for: “Field Programmable Gate Array.” Unless you have a background in electronic engineering, you might not know what that means. And, to tell the truth, I didn’t know what it meant when I first heard about them when I was at uni - back in 2004.
“Gate” here means logic gate. You know those computer chips
or "integrated circuits" to use their proper name
that everything seems to be made of these days? They are made up of millions of logic gates, which are made up of billions of transistors. A logic gate is an electronic component which can be used to do Boolean mathematics - this is ANDing, ORing, and NOTing inputs. Think of them as switches with two (or more) inputs, and that they calculate whether something is true or not.
Let’s look at an example. Suppose we have a logic gate for calculating whether we should take an umbrella with us. Our inputs might be “it is raining” and “I am outside”. If both of those inputs are true
i.e it is raining and I am outside
then the output of that logic gate would be “take an umbrella”. Because the two inputs are TRUE, the output should be TRUE. This is an AND gate.
Anyway, computer chips and FPGAs have millions of these gates in them.
The difference between the logic gates used in computers is that they are arranged in s specific order and never change. FPGAs are field-programmable, meaning that the way that they are arranged can be altered “in the field”
which just means, "whenever"
Imagine if you have a computer which could have more RAM simply by rebooting. That’s what FPGAs are.
I remember watching Hackers
yes, the "hack the planet!" movie
when it first came out, and there’s a pretty cool transition from the New York City skyline to a stylised circuit board. Cityscapes and circuit boards have a lot of things which cross over:
You can’t have buildings on top of each other, neither can you have chips on top of each other
not really true, but for the purposes of this podcast, "you can’t have chips on top of each other"
You can’t have roads which cross without some kind of controller, and the same with circuits
When a blockage happens (traffic), it slows everything else down
But what if you could re-arrange the city at will?
FPGAs and Emulation
A lot of companies use FPGAs in machines which are built to play older video games, like the hardware from Anlogue or the MiSTer project. They’re not just used in
what some people think of as overpriced
gaming hardware, they’re also used in the cloud a lot. Ingress (or entryways) into applications are usually controlled by firewalls which are created using FPGAs.
They’re used because the low level hardware can be controlled via software.
But that doesn’t actually explain how they work. Let’s use a metapor. Please remember that like all metaphors, it will fall apart if you think about it too much.
Imagine you have a Sega Mega Drive (or Genesis, if you will). The hardware inside it is tuned specifically to run applications from cartridges. It can only run whatever is supplied via the cartridge slots. 99.999% of the time, these are games. There are things like Game Genie, the 32X, the TV tuner, and Sega Net. But most of the time, the cartridges are games. Only when a cartridge is inserted will the console do anything. It has one use: run whatever is on the cartridge.
The hardware inside the Mega Drive/Genesis will only run applications on cartridges which were written for the Mega Drive/Genesis
again, let’s not talk about the 32x or Mega CD for now
meaning that if you were able to take the chips from a NES cartridge and put in into the shell of a Mega Drive cartridge, it would not run.
there’s a caveat here fro Master System games, but we won’t got into it right now
Now imagine if you could completely reconfigure this Mega Drive such that it was a NES, simply by powering it off and powering it back on again
like some sort of weird video game console/Transformer crossover, maybe?
but without using emulation, though. In this instance, the Mega Drive would become the NES. As in, all of the components would re-arrange themselves on the atomic level to become those found in the NES, the circuit boards would re-arrange themselves such that the chips fit, and the shell would turn grey and re-arrange itself.
It would be a NES
Let’s Talk About Emulation For a Second
In terms of software, emulation is when you write an application which pretends to be something else. The thing which is running the application remains the same, but the application itself is a software approximation of other thing.
Most gamers know this as video game console emulation. Think of things like the cores used in RetroArch, or applications like BSNES. With BNSES, you:
Open the application (BSNES, in this instance)
Load a ROM into BSNES
BSNES will read through the ROM and pretend to be a real SNES
The key word here is pretend. Nothing has actually changed on your computer - or phone, Raspberry Pi, or whatever you are running BSNES on - it is still running whatever operating system from before (albeit underneath BSNES), it can still browse the web, it can still play YouTube videos and open documents. It has some software running which is doing it’s best imitation of a SNES, and is showing you what that might look like on screen.
This is totally different to what FPGAs do in these newer retro consoles
like the Analogue and the MiSTer
What FPGAs are doing is they are re-configuring themselves to BE a SNES when they start up. Looking at the chips themselves, they effectively are a SNES. They’re not running software which pretends to be one, they are one
it’s a little more complicated than that, but that’s the gist of it
As analogies go this one will definitely fall to pieces if you think about it too much. But, in the words of Mario:
Here we go!
Imagine you walk into a fast food place, let’s call it WackMonad’s
which sounds really rude, but it actually isn’t
Everyone is wearing matching uniforms. The food served is from a very limited menu, compared to a swanky, sit-down restaurant with waiters. The tables are arranged in a very specific pattern. The walls will be painted specific colours. This building has one use: for you to buy and eat fast food.
The people there change uniforms?
The menu changes?
The layout changes?
But the cooking equipment and the ingredients stay the same. It’s still using the WackMonad’s cooking equipment, and it’s still using the same ingredients. But the things that you can buy have changed.
Is it still the same fast food restaurant?
That’s emulation, because:
The menu has changed (the applications you can run)
The uniforms and layout have changed (the user interface)
But the kitchen and ingredients stays the same (the hardware)
The building is torn down and rebuilt in a different shape
A different company rents the building
Completely different employees are hired and given completely different uniforms
A different menu is offered
The layout is different
The ingredients and kitchen are completely different
That’s FPGAs, because:
Rather than running the same hardware, it is torn down and recreated completely each time
The menu has changed (the FORMAT of games you can run
let’s say Mega Drive, NES, Jaguar, PlayStation
The uniforms have changed (the user interface of the console you are now running)
Rather than pretending that it’s something it’s not, for all intents and purposes it IS that thing. Our series of FPGAs is now a PlayStation. But our PC is still running Windows, which is running RetroArch, which is still running BSNES
or Beetle in this case
Beetle is a PlayStation emulator
Comparing Emulation to FPGAs
Software emulation is a translator from one set of instructions
Say Motorola 68k (for the Mega Drive/Genesis) to x86/x64 (for PC)
Without these translators, your computer wouldn’t be able to understand the instructions which are encoded into the ROMs for your favourite games. Each game is just a program which has been written for a very specific type of computer: a games console.
The emulator is built up of lots of different translators, split into modules. There is usually one translator per chip or hardware component in the target system
for example the CPU of the Mega Drive
The more chips or components there are in the console, the more translators required for the emulator
it doesn’t really map top that, but it’ll do for this argument
Some older games consoles are actually made up of components which don’t speak the same language, so you might end up with translators for the translators
for example, and sticking with the Mega Drive, the Yamaha YM2612 (the sound chip) "spoke" a different language to the CPU
You also need interpreters from one input type to another. Let’s say that you have a USB controller for your emulator, in that case you’re going to need some code which maps the button presses on that controller to what the console
in this case a Mega Drive
would be expecting. Luckily part of that work is done for you with device drivers, but only part of the work. You still need code which takes the device driver output and converts it to what the console would expect.
The X button on your USB controller will not output the same signal as the B button on a Mega Drive controller, I can guarantee you that.
You’ll also need a video compatibility layer. In our example, we’re using a Mega Drive. Well, the Mega Drive converted the digital signal from the frame buffer
which is a Yamaha YM7101
to an analogue signal, then modulated into an FM signal to be sent up to your TV - pretending to be a TV channel.
In an emulator, you don’t need this. You can take the frame buffer data and display it on screen, but only if you convert it to DirectX, OpenGL, Vulkan (used primarily on Linux-based machines), or Metal (used on MacOS machines).
And even then, you need some software which draws a window for you to put that video into. AND you have to do the same for the sound.
And all of that needs to run on top of an operating system. And if the operating system starts running slowly
or the graphics drivers
or the sound drivers
or the hard drive
or any part of the computer which is unrelated to the emulator, for that matter
then the emulator will suffer. Because the computer isn’t just running the game, it’s doing a complex juggling act in order to make it look like it’s doing a lot of things all at once
most of the time, computers are only ever doing on thing at time
but they switch between them so quickly that you’ll never notice
Whereas FPGAs don’t have to do any of that, because they are the chips. They don’t need any translation or interpretation of anything. They don’t need to convert each line of the game ROM into some other instruction set
instruction sets are the language of the CPU
Intel and AMD tend to use x86/x64, whereas the Motorola 68k used complex instruction set computer (or CISC)
because they already understand it all
again, it’s a more complex that than, but let’s not get bogged down by too many details
The only thing they need to do is map the controller in your hand to the controller that the console that it has become is expecting. Again, this is where device drivers come to the rescue.
They also don’t need to convert the frame buffer to analogue, then modulate it into FM, because the frame buffer is wired up to an HDMI port.
Comparing emulators to FPGAs is like comparing two conversations:
One which requires a translator
One where each party can speak the same languages
A translator will have to take what you say and convert that to another language. They need to watch for any non-verbal communication and idioms that you use, too. This will likely be error prone and very slow.
It’s slow because the translator has to wait until you have stopped talking, they have to take a moment to really understand what you have said
and perhaps ask questions for clarification
then convert that to another language, and then say it all.
It could be error prone because the translator has to understand everything that you have said
including any technical jargon
and be able to convert that into another language, and convey it all to another person without losing any detail.
Think about how difficult it must be to translate a medical conversation from British English to Tokyo or Standard Japanese. Also, Japanese medical jargon doesn’t tend to use Greek and Latin words
like we do in English
they use Japanese words. So the translator needs to know all of the medical terms that an English doctor might use, and what they mean, AND they need to know the Japanese equivalents.
Whereas, if you know the languages then you can do that yourself. Which means that it’s faster and less error prone.
It’s faster because you’re already thinking in a way which allows you to swap languages at will
Any multi-lingual person will tell you this is a real thing
seriously, after a bit of a run up, I can do this with English and Japanese
It’s also l ess error prone because you are the person doing the talking, so you fully understand what you are saying and what it means. You also likely understand the non-verbal communication and idioms to use, so you don’t have to convert them, either.
Admittedly, it takes longer to learn British English, Japanese, and the medical jargon of both languages. Which is why this, like all the other metaphors and analogies, breaks down if you think about it too hard.
Let’s Talk About Cost
Let’s compare the cost of emulators to FPGA based systems for a second. Let’s face it, a lot of people are going to choose the cheapest option when they want to play a video game
the Waffling Taylors do no condone piracy of any kind
First, let’s look at emulators. They are generally free to use
free and open source software is awesome, by the way
and most of the infrastructure around us is built on it
although they don’t always have to be free, but we won’t talk about the non-free onces
Most emulators (if not all) run on any kind of modern computer hardware, from powerful desktop PCs down to low power Raspberry Pi, including mobile phones.
They also run on almost any operating system, from Windows to MacOs and even most Linux distributions - a few even run on the Horizon, which is the code name for the Nintendo Switch operating system.
They sometimes require effort in setting them up, or they sometimes require non-free files like BIOS and system ROMs. They are mostly not 100% accurate, as everything is translated at run time. For example, it took until a few years ago for BSNES to hit 100% accurate.
Sometimes they can’t run at full speed, because the translation from one machine language to another takes CPU time and is slow to do. Most emulators can only run games for one specific format on one specific format. For example, an emulator for SNES on Windows can only play SNES games on Windows
Now let’s look at FPGA based systems. FPGAs are non-free to use - they need to be bought, a circuit needs to be designed, and they programmed.
The run only on hardware (circuits) that they are built for. You can’t “run” an FPGA inside your computer
at least not yet, or not without using an emulator
They tend to require zero effort and zero extra files or moving parts, once they have been assembled and programmed; other than sourcing the original games, that is.
The are almost always 100% accurate. This is because the FPGAs are the original hardware (for all intents and purposes). And because of that, they almost always run at full speed. In fact most FPGA based gaming systems have to be slowed down.
An FPGA based system like a MiSTer can run actually games from many different systems, because the chips can effectively “become” a different console or machine. A reboot is sometimes required in order to reconfigure the hardware, though.
One Last Metaphor
Let’s use one last metaphor before I stop talking about emulation and FPGAs.
Have you ever watched a TV broadcast or movie with a sign language interpretor on screen? Have you ever noticed that there is a slight pause between what the people are saying and what the signer is signing?
If you know any sign language, you’ll notice that the interpretor usually skips over details that they think are unimportant. This is because they are interpreting in real time, and must not fall out of time with what is being said. If they do fall out of time, they might become confused or miss something which was said.
Imagine that you could lip read with 100% accuracy
most deaf people can do this, and it’s really quite impressive
You wouldn’t have to rely on the interpretor hearing, understanding, translating, then actually signing. You would simply know what was being said.
BECAUSE YOU WOULD BE AN FPGA, RIGHT JAY?
Pretty much, Russel. Pretty much.
So, in closing:
Emulators are free (most of the time), but they are sometimes not accurate, or run at the same speed as the original hardware because they are translating everything in real time
Ryujinx, the Switch emulator, doesn’t do this
Keep an ear open for an episode of a different podcast for details on that
FPGAs have a cost, and are generally better at being the target hardware then emulators are
Jay loves to use metaphor and analogy
AND THAT PARTS OF THIS EPISODE AREN'T 100% ACCURATE, BECAUSE HE WANTED TO GET THE GENERAL POINT ACROSS RATHER THAN TEACH YOU EVERYTHING THERE IS TO KNOW ABOUT FPGAS. FOR THAT, YOU'LL HAVE TO TAKE AN ELECTRONIC ENGINEERING COURSE
So the next time someone is complaining about how much the MiSTer or Analogue devices cost, tell them that it’s a lot more complex than a “trivial” emulator
hopefully you can hear the bunny quotes around the word trivial, there
SHALL I START UP MY MEGA DRIVE CORE SO THAT WE CAN PLAY STREETS OF RAGE 2, JAY?