fpgas retro hardware post

This commit is contained in:
Wouter Groeneveld 2023-11-27 11:11:32 +01:00
parent 33606f1dec
commit 69c038e38d
4 changed files with 44 additions and 1 deletions

View File

@ -7,7 +7,7 @@ aliases:
subtitle: Writing Psm Assembly test-first, because why wouldn't you?
categories:
- programming
tags: [ 'unit testing', 'assembly', 'picoblaze']
tags: [ 'unit testing', 'assembly', 'fpga', 'picoblaze']
---
To continue our [unit testing tradition](/tags/unit-testing/), each time I land on a new language or piece of technology, I carefully assess whether it's possible to write tests first. Unsurprisingly, even in Assembly it's possible. My recent foray into the digital electronics world has let me to write instructions for the [Xilinx PicoBlaze](https://www.xilinx.com/products/intellectual-property/picoblaze.html) 6 FPGA microcontroller. This Assembly dialect, written in "Psm(4)" files, is destined for a different architecture. That means linking and leaning on Google Test using C++ isn't possible.

View File

@ -3,6 +3,7 @@ title: "My Personal Game Of The Year Awards"
date: '2022-12-14T17:02:00+01:00'
tags:
- games
- goty
- lists
- yearnote
categories:

View File

@ -0,0 +1,42 @@
---
title: "FPGAs And The Renaissance Of Retro Hardware"
date: 2023-11-27T10:12:00+01:00
categories:
- retro
tags:
- hardware
- fpga
---
Almost every few weeks, a new and exciting retro hardware project is announced. These are truly great times for retro computing enthusiasts. How come these hobby projects explore in popularity lately, besides the obvious growth in demand and the availability of crowdfunding platforms such as Kickstarter that at least partially remove the stress of funding? One answer could be the rapid evolution and availability of FPGA chips.
An FPGA or _Field Programmable Gate Array_ is a chip that can be "programmed in the field"---unlike a typical ASIC or _Application-Specific Integrated Circuit_ chip that is engineered to do only one thing. This means that if you get your hands on an FPGA board, you can flash the chip on it to act like a Game Boy. Or a Mega Drive. Or a Commodore 64. Or anything else you can possibly think of, within the limits of that particular board.
Xilinx, one of the most popular manufacturers of such chips, [sells development and evaluation kits](https://www.xilinx.com/products/boards-and-kits/device-family/nav-artix-7.html) at very acceptable prices, depending on the power of the chip you're after. If you're just looking to mess around with the FPGA concept, you can treat yourself with a very hackable [PYNQ board](http://www.pynq.io/). These boards come with all manner of trinkets---8 DMA channels, high-and low-bandwidth controllers, an FPA comparable to the above Artix-7, 512 MB DDR3---and are specifically built for rapid prototyping and teaching. We use them at our faculty to introduce students to various concepts of digital electronic design.
Even if you're not that technical, I'm sure you've at least heard of the term "FPGA", as it has the tendency to pop up everywhere, especially in groups discussing retro computing. Why? Because you don't need a powerful FPGA chip to emulate an old embedded 8-bit CPU. In other words: slap an FPGA on a board, flash it to perfectly emulate your favorite retro hardware, and you've got yourself a beefed up Game Boy/Commodore/Whatever! A few examples of FPGA-enabled retro hardware projects I've encountered in the last few years:
- [Mega 65](https://mega65.org/), a realization of the C65 but running 40x faster;
- [ZX Spectrum Next](https://www.specnext.com/), the next generation ZX Spectrum with backwards compatibility for old accessories including tape recorders;
- Anything that [Analogue.co](https://www.analogue.co/) puts out: The [Analogue Pocket](/post/2022/04/analogue-pocket/), The Mega ST, ...;
- The [MiSTer](https://www.retrorgb.com/mister.html) project used to perfectly emulate and/or upscale analog signals;
- [GC Loader](https://gc-loader.com/), the DVD drive replacement for the GameCube;
- In ever-increasing emulation GitHub Projects targeting Xilinx FPGA boards [such as this NES one](https://github.com/zf3/nes260).
![](../mega65board.jpg "The Mega65 board housing a Xilinx Artix-7 chip (in the middle).")
Most of these projects are open-source inviting an endless horde of retro enthusiasts hacking away and building/improving upon emulation systems. For example, the Analogue Pocket was initially made to perfectly emulate Game Boy family games, but the community already developed an impressive amount of what they call "cores" that suddenly turn your Pocket into a handheld (S)NES, Mega Drive, or anything your heart desires---usually derived from earlier MiSTer work.
Most hardware that's perfectly emulated right now has been fully reverse-engineered, with ample of documentation available. We now perfectly know how the Game Boy internally works, which as a software engineer I can use to write software that emulates the system and is able to boot `.GB` ROMs, but my colleagues as hardware engineers can use to program an FPGA so that the system is emulated in hardware instead of in software. The difference for the Game Boy happens to be minimal because our ASIC hardware---the CPU and RAM in your PC---is more than powerful enough, and Game Boy emulators have been around for twenty plus years.
However, for other either more finicky (think CPU cycle timing, vertical/horizontal refresh rates, RTC clocks, ...) or more demanding systems, FPGAs usually outperform software emulation as being closer to the bare metal eliminates a lot of latency and makes it easier to implement specific components. Of course, companies like Analogue love to convince us that their FPGA-based game consoles have nothing to do with the laden concept "emulation", but instead perfectly reimplement the original hardware design, tossing in additional and more modern bells and whistles.
If you were to play the NES game _Mario Bros. 3_ on your official NES Mini, you would be playing it through a software emulator on an Allwinner R16 4x Cortex A7 ASIC system-on-a-chip with 256 MB DDR3 RAM running on 512 MB flash storage. That quad core is, in essence, a conventional mini-computer that's more than powerful enough to emulate 8-bit systems. But if you were to play _Mario Bros. 3_ using an FPGA core on the MiSTer or the Analogue Pocket, that software layer is absent: its hardware behaves exactly like the original NES did.
For those interested in slight latency differences of specific hardware systems, YouTube has got you covered, hosting a plethora of [MiSTer FPGA vs Mednafen emulation](https://www.youtube.com/watch?v=StqrUPawyJI)-alike videos, in this case taking a close look at PC Engine/TurboGrafx 16 software vs. hardware emulation. I honestly don't think I would notice the difference when playing.
---
These useless software vs. hardware emulation debates do neglect one important aspect: new (old?) FPGA-based retro hardware is more than just recreating the old CPU core. It's about the physicality of the hardware itself. It's about plugging in that dusty cart you so carefully preserved all these years. It's about seeing if that Spectrum tape still works and getting excited by the pressure of the authentic-feeling keyboard that comes with the device. It's about [retrobrighting](https://en.wikipedia.org/wiki/Retrobright) your old plastic case to compare old with new! It's about the hackability of the new (old?) system that comes with a thick BASIC or PASCAL-like programming manual that is supposed to reinvigorate eighties bedroom game programming.
Happy FPGA hacking/playing!

Binary file not shown.

After

Width:  |  Height:  |  Size: 133 KiB