Language…
8 users online:  Atari2.0, drkrdnk, Enan63, futhark, gr8fulAF, GRIMMKIN, kasoku,  Nanako - Guests: 253 - Bots: 445
Users: 64,795 (2,377 active)
Latest user: mathew

An 8-bit CPU implemented in Verilog: Chipmunk

Inspired by FL4SHK I made my own CPU, except whereas his takes inspiration from the Gameboy's CPU, mine takes inspiration from the 6502.

His is too big to fit into the PowerPak's FPGA, but I explicitly kept mine small enough to fit, with the goal of using it as a coprocessor for NES demos.

While a lot of things take one more cycle than the 6502 does, I currently have it running at 21Mhz and it should be able to run at 42Mhz if I can figure out how to use the FPGA's clock doubler. The main obstacle that restricts its usefulness is the fact that the PowerPak's FPGA only has 3KB of block RAM, and block RAM is the only storage I could have used for the program. 3KB is still useful, though. In the context of the PowerPak I do currently have a problem where sometimes writes fail to happen, and I think I have some timing issues that I don't know how to resolve yet.

It's MIT licensed, and uses very few resources, so it should be easy to incorporate into any FPGA project that needs a small processor.

Instruction set. As you can see, the main difference my CPU has is the ability to leave out the parameter, where it's assumed to be zero. ADD and SUB also exist.

Diagram of the state machine

CPU test running on my NES

GitHub repository

nesdev thread

You definatly put a lot of work into this....tbh though I'm not entirely sure what it is exactly. O.o
Layout by LDA during C3.
FPGAs are reprogrammable logic chips, that can simulate any other chip or system that they have enough resources for (including something as complex as an entire NES).

It's different from emulation because the chip is actually doing the same stuff the original did in hardware, rather than using software to do it.

NES flash carts have them because NES cartridges are extremely diverse hardware-wise, and the one in the sd2snes can be programmed to act like the different coprocessors that SNES games had, allowing those games to be played.

Of course you're not restricted to only remaking things that actually exist, so FL4SHK and I decided to make something new.

It's kind of hard to explain because this is all pretty abstract, but if you were using an FPGA to make a custom computer or game console or whatever you could use my or FL4SHK's CPU to be the CPU part of it.
This is preety cool.
So could you technically make an enhanced NES game that can only run on the NES Powerpak?
Originally posted by Final Theory
So could you technically make an enhanced NES game that can only run on the NES Powerpak?

In the NES community, if someone makes special hardware, and then actually releases a worthwhile game that needs it, then emulator developers (and people making mapper files for flashcarts) usually do add support for the new hardware so that their emulators can play the new game. Mappers 28, 29, 30, 31 and 218 all originated in homebrew projects.

That's not likely to happen for Chipmunk though since it would cost too much to put onto a cartridge (you'd need an FPGA, and the price for those are usually in the double digits, whereas the parts for the new designs people actually make tend to be a few dollars or less) and it would require a lot of effort from emulator developers. If you really wanted to release a game with a coprocessor, you'd probably use a cheap ARM microcontroller.

So yeah, this probably isn't going to be supported anywhere except the PowerPak, and you could make a fancy game that only works on the PowerPak but with the amount of effort that goes into NES game it wouldn't make a lot of sense to spend that time and only have a really limited audience left to enjoy your work.

It'd be cool to make some tech demos with this though, and that's really what it's for. I was trying to make a 60 fps Conway's Life before I ran into the timing issues that I'm going to have to fix (waiting until I actually get a standalone FPGA board so I can diagnose it better).
Quote
That's not likely to happen for Chipmunk though since it would cost too much to put onto a cartridge (you'd need an FPGA, and the price for those are usually in the double digits, whereas the parts for the new designs people actually make tend to be a few dollars or less) and it would require a lot of effort from emulator developers. If you really wanted to release a game with a coprocessor, you'd probably use a cheap ARM microcontroller.

So yeah, this probably isn't going to be supported anywhere except the PowerPak, and you could make a fancy game that only works on the PowerPak but with the amount of effort that goes into NES game it wouldn't make a lot of sense to spend that time and only have a really limited audience left to enjoy your work.


I've thought about this before and I'm still debating on whether a special game that needs special hardware is worth it or not.

Yes, it will be more expensive, but it has a gimmick that other games do not have, its special in the sense that it won't run on original hardware without special chips. Some hardcore collectors would pay the extra cash because it makes a good collectors item. When you offer something different you might get more attention. Everyone will know that its your game that needs special hardware and won't work on a regular cart.

I also want to know if that new NES game "A winner is you" (music tracks)would work on an emulator. Because I'm sure it has a special mapper that from what I understand is pretty new.
You might be able to do some Mode-7 like effects with it.
Originally posted by Final Theory
I also want to know if that new NES game "A winner is you" (music tracks)would work on an emulator. Because I'm sure it has a special mapper that from what I understand is pretty new.

That's just this (the raw sound register getting written repeatedly in a loop) with a big ROM. The interface for getting that much ROM would need to be implemented but that's all.

Originally posted by Drex
You might be able to do some Mode-7 like effects with it.

Have you seen Cosmic Epsilon? That effect is pretty Mode-7 like, but pretty low resolution.

With a different custom PowerPak thing you could probably pull off real Mode-7. You'd have a much smaller amount of RAM for graphics and the tilemap though, since there's only 3KB, and you'd be limited to 4 colors. The small RAM amount is also about the only thing in the way of using it for polygons.
Is there no way to have VRAM and your CPU in the Power Pack at the same time?
Originally posted by Drex
Is there no way to have VRAM and your CPU in the Power Pack at the same time?

The PowerPak's VRAM and the CPU can easily coexist, it's just that the FPGA doesn't have full access to the VRAM.

It's just there to control what banks are visible to the NES, so the NES is in direct control of a lot of the VRAM's address pins and all the FPGA can really do is pick what 1KB chunk the PPU's current access goes to. This is enough for all currently existing NES games.

You can't really go around modifying VRAM yourself if you can't control the address the RAM chip gets. All of the other RAM chips on the PowerPak are the same way, so I had to use the RAM that's actually in the FPGA, which is tiny.
Originally posted by NovaSquirrel
since it would cost too much to put onto a cartridge (you'd need an FPGA, and the price for those are usually in the double digits

Haha whoops, turns out prices really have gone down that much.

InfiniteNesLives has a cartridge board design he's putting together that's supposed to include like 8MB of program storage, any amount of storage past that via an SD card if you want, and an FPGA big enough to fit both Chipmunk and a lot of other fancy features. A good enough FPGA is like $7 or less, and apparently this whole thing would be cheap enough for releases. You would get a lot more than 3KB for the program too.

So yeah, there's a possibility that Chipmunk could actually see some use in the future.