Hacker News new | past | comments | ask | show | jobs | submit login
Show HN: Gameslab, a FPGA powered handheld game console (craigjb.com)
406 points by craigjb on Dec 25, 2019 | hide | past | favorite | 50 comments

That’s a seriously cool project.

I love that retro game emulation has spawned this massive culture of super complicated and roundabout ways to replicate $50 consoles. It’s everything I love about DIY projects in general.


I actually didn't originally intend it to be for retro game emulation, more for experimenting with custom hardware for each game and with 3D acceleration hardware. But, the idea of putting retro emulators in the FPGA fabric is so easy.

In fact, over the holidays, I'm working on porting some of the MiSTer FPGA retro emulators to the Gameslab: https://github.com/MiSTer-devel/Main_MiSTer/wiki

This seems Just the sort of thing that I need to make a physical version of my fantasy console.

It's 64k ram 8-bit avr instruction set and a blitter doing a variety of data formats. It's not quite ready for prime-time yet, but you can see some of it online. The virtual hardware registers can be seen at https://k8.fingswotidun.com/static/docs/io_registers.html It might be quite amenable to something like this.

How does your blitter compare to the Amiga blitter? http://amigadev.elowar.com/read/ADCD_2.1/Hardware_Manual_gui...

It's quite different for a number of reasons.

The read area and the write area are separate spaces. It is strictly main RAM to frame buffer.

It is pixel based instead of bit-planes, so a lot of the features of the Amiga blitter aren't required. The minterms , multiple sources and the shifter were great for masking and sliding the bits to the right place, but once you go to chunky pixels they aren't so useful.

It does pixel format conversions to convert various compact data forms to colour graphics. 8 pixels per byte in 2 colours, 4 pixels per byte in 4 colours, 3 pixels per byte (where each 3 pixel block can have 4 colours from one of 4 micropalettes), 2 pixels per byte in 16 colours.

It supports Cell modes were it can decode cells of pixels from data, mode 0 has 3x3 blocks described in two bytes each. Cells may have any two of 16 colours. mode 1 is quite similar to the NES tiled graphics mode with 8x8 cells chosen by index to a table and individually coloured and flipped.

I don't have a line drawing option but I was wondering about having some registers to accumulate with each pixel written and if the accumulators overflow the X or Y pixel position increments. It would add some rudimentary skewing for little cost.

A lot of it comes down to the fact that the blitter is doing much of the job of the display hardware in other systems. The frame buffer is the output device with no smarts at all.

For those interested in that, Analogue will release the Analogue Pocket, a FGPA handheld console too. It will play Gameboy and Gameboy Advance games and you will be able to develop for it. There will be 1 FGPA to emulate the console and one another for development.

Analogue does great products usually so I can't wait for it.

(I'm not affiliated at all with them, I just love their products).

I'm worried the Analogue Pocket will be hard to get. At the bottom of the page[1], it says "Limited quantities will be available". If that means it will be limited like the NT and NT Mini were, that will be very disappointing.

[1] https://www.analogue.co/pocket/

Craig's project is awesome! Had a chance to interview him about it: https://theamphour.com/469-an-interview-with-craig-j-bishop/

Thanks Chris! I didn't know you hang out on HN too :P

You're slowly becoming a software guy after all...

Someone had mentioned Contextual Electronics as a way to learn KiCad, so I got a notification about that. But yes, I also hang out here from time to time :-)

Congrats on getting it done.

Just mastering Ki-CAD is an accomplishment. I learned circuit design with P-CAD. And it was anything else but intuitive. Playing around with Ki-CAD reminded my of thise days.

Can you recommend a good Ki-CAD tutorial?

Can you elaborate a little bit on the mistakes you made and what led to the choices you made? E.g. first time read about Das U-Boot.

Thanks! There was definitely a lot of learning involved--I wrote up some here: https://craigjb.com/2019/12/04/gameslab-fails/

To be honest, I really don't know a good KiCad tutorial. I kind of just banged myself against it until I learned. But, I had previous experience with Eagle, Altium, and Cadence Allegro.

Das U-Boot is the embedded bootloader and is pretty standard for embedded ARM systems (and others! https://github.com/u-boot/u-boot/tree/master/arch).

On a dev-board prototype before, I had also used Buildroot (https://buildroot.org) to create the minimal root filesystem image. This time around, I decided to use Debian since it makes installing packages I want much easier. For example, I can just apt-get install the USB wifi firmware packages instead of hunting them down and including in a manually generated image. It's still using a custom compiled kernel though, since I have custom drivers for things like the graphics hardware.

I'm trying to use Rust for as much as possible (I like Rust a lot). The STM32L0 runs rust, I bodged together a framebuffer driver in Rust, and the games in userspace are also in Rust. I'll post about the Rust framebuffer driver at some point.

Thanks a lot! I love that you are using Rust.

Yeah, Rust is great! I've used it on several production projects for work, but not for extensive embedded work before this. Embedded Rust is getting better and better!

Shout out to the Real Time For the Masses project (it's an RTOS) I used: https://github.com/rtfm-rs/cortex-m-rtfm

Here's a good KiCad tutorial:


(first video of a series of 10)

Look up Contextual Electronics on YouTube

KiCad isn’t that hard. There is one tool for schematic entry and another for layout. The most confusing thing for me was part and their footprint management. I ended creating myParts libraries for my own parts in each project. KiCad 5 is really great software with lots of examples.

Can you simulate/calculate how voltages and signals behave in Ki-CAD or do you need pen and paper or an entirely different tool to achieve that? What does the entire workflow look like, not jut the circuit layout design?

P.S: I'm the ultimate noob on these topics.

There are plugins that can do that. It's called spice[1].

[1] https://en.wikipedia.org/wiki/SPICE

> The FPGA fabric means that games and apps can bring their own unique hardware to load into the fabric.

Curious, can you both execute code on the FPGA and simultaneously write other parts of it? Or do you have to write it in one go, than "start it"? And in the latter case, can you write it incrementally or do you have to erase it first?

Your question is hard to understand. FPGA logic fabric must be loaded at once. There is a method called partial reconfiguration, one can swap pieces of the logic design on the fly, but it’s probably not the case here.

Partial reconfiguration is supported by the Zynq SoC's FPGA.

It's weird to see someone refer to a zynq as a FPGA.

Every time I've been involved with one, it's been basically a CPU with various accelerators for specific functions done in the fabric, with the design being CPU-forward. I've never seen anyone approach them from a FPGA-forward angle. Interesting!

The Zynq is definitely an FPGA. It is an FPGA with a hardened ARM core. 10 years ago, they had FPGAs with hardened PowerPC cores. Now that ARM has taken over, it makes sense.

I've seen a split. Some people are looking for CPU acceleration. Others say Zynq effectively covers the case where FPGA designs include a soft-core anyway for high-level control, so why not make it a hard block.

Wow, this was quite a treat to read! Do you have any recommendations to learn more about FPGA (and maybe not Verilog/VHDL, I'm thinking more about a SCALA based language). I always start with beginners tutorial but I always get super bored. Something about making LED drivers makes me really unmotivated.

Thanks! I always recommend getting hands-on for learning more about FPGAs. FPGA boards are cheaper than ever, and you have all different ones now. I'd say get a Lattice ECP5 based board (like this year's Hackaday Supercon badge). The open-source symbiflow toolchain works for these (Xilinx 7-series will be soon!).

With regard to Verilog/VHDL, you'll have to learn at least verilog at some point, but I stay away as much as I can. SpinalHDL (based on Scala) is my goto. Some people like the Python based ones like migen, but I like me some strong typing.

I have a couple of blog posts about starting to put together a Gameboy CPU on craigjb.com (not finished yet).

Thank you for the response! I'm definitely going to check out your Gameboy posts! Any other projects you recommend similar to that? I really like the idea of building something I can use.

The ZipCPU tutorials section is also great! They include verilog, using verilator (for simulation), and formal verification. And, personally, I think learning formal verification early is great, since it will probably be used more and more.

It's verilog, but you're going to have to learn some anyway. All of the new-generation HDLs compile down to verilog, which then goes into the various synthesis tools.


Was there a reason you decided to use SpinalHDL instead of Chisel?

This is awesome. The case fabrication looks great. What materials and fabrication process did you use? I'm particularly interested to hear more details of how you made such a pro looking design.

Thanks! I did a video talking about the case a bit more: https://craigjb.com/2019/12/06/gameslab-case/

I had it fabricated for me by a company by Front Panel Express. In a DIY audiophile forum I saw people using them, and if they're good enough for audiophile gear, probably good enough for me :P

Thanks! Love the video. I love the brushed and beveled panel. I'll definitely look at something like this for some of my designs.

A little late on the draw here, but this is a serious contender for submission of the decade IMO. FPGAs are one of the last frontiers of computing that I'm curious about, as the realtime requirements of audio processing make GPUs somewhat of a non-starter for this particular application of grid computing. Really impressed at seeing this level of thoroughness and polish. Congratulations!

I just ported my 3D engine to Raspberry, the latest (4) has a new, really good GPU! I'm looking forward to something like the compute module for the Raspberry 4 because then the mods community will port it to their handhelds, only problem is power, it uses ~5W so you need a huge battery!

I don't think 5W is too far off from what this thing draws under load. I have a 10,000mAh ~4.2V battery in it, and I get about 10 hours of life. The battery is clunky, 9.6mm thick, since it was originally intended for external phone battery packs.

This is an amazing Show HN. The best bit was “I did this because I'm lazy” I suspect not somehow. I did wonder why those chips were so expensive? I have a super limited knowledge of hardware so I was unable to figure it out exactly. Thanks again and I can’t wait for more write ups.

FPGAs with large fabric are expensive because they're more useful than smaller FPGAs and because the number of viable chips that come from the fabrication process is smaller, meaning they are literally more rare and harder to make successfully. The most expensive FPGA devices can cost more than USD$30,000 per device (per chip.)

This is one of the coolest hardware projects I've seen! Can't wait to see the next post.

"Or, a Gameboy emulator could load a Gameboy’s CPU and peripherals into the FPGA fabric to “become” a Gameboy rather than emulating it in software."

Basically the holy grail of emulation... Not-emulation.

> STM32L0 onboard runs embedded Rust firmware

First time I’ve seen a real project using this.

How far is embedded rust away from “prime time” you think?

Also, the STM32 is a system supervisor, did it really need an RTOS?

Yeah! Embedded Rust on STM32* right now is pretty good! A lot of consolidation has happened in the device crates and HAL crates recently, so I'm adjusting a bit. But, it's looking good.

I'm actually working on a post about restarting my firmware using the latest and greatest (I started working on this firmware over a year ago).

I used the RFTM real-time OS (RTOS) because it's super light-weight and handy for checking at compile time that my interrupt handlers don't cause conflicts. It's really a nice framework for any event-based firmware (a big chunk).

This is amazing, I look forward to more posts! I'm trying to get into more hardware projects, stuff like this is very inspiring. Thanks!

Very cool. It would be incredible to see what some professional game devs could do with FPGA acceleration.

Not really a whole lot. FPGAs work best where you have precise timing requirements or really wide signals.

Most game engines are about throughput and I don't think you'd see a lot of use for them, heck we had a hard enough time using the PS3 back when I was in the industry and that wasn't nearly as wide as a FPGA can be.

Yeah, I was going to mention the PS3 too. It was the most unique hardware of the generation and definitely took the longest for devs to adjust to and learn to leverage fully.

a lot of old games rely on clock timing to do game timing. Modern generations less so, but still people rely on fixed clocks

You are a genius, and I am glad that there are many geniuses like u, to make our world more fun!

Good work!

This is insanely cool, and must have been a massive undertaking! Awesome

This is absolutely nuts! Congrats!

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact