The Making of Fantasy-1: Part 1
This is the first part of the on-going series that serves as a log of the process of the hobby project of Fantasy-1.
It started this way…
Before this project, I had worked on a hobby project of a Nintendo Entertainment System (NES) emulator. That project was never finished, although the CPU part is almost done. It can run some test suite for the ancient 6502 CPU but not finish all of the tests, and I’ve never get to the part of graphics, sound and input/output.
Later in my work I needed to learn about computer architecture and stuff like that, and I came to know about this memory-memory architecture that someone attempted before. A memory-memory architecture is one that has only memory operands in the instructions. It’s not how real world machines are built these days and remains only of academic interest, as far as I know.
Around the same time I read about the fantasy consoles, projects that people build to mimic old-school game consoles but no actual machines were built like how these projects describe. These consoles more or less try to provide the look and feel of the NES or SNES era game consoles. And there are games written for them.
All of the above resulted in an idea that I can roll my own fantasy console and it can use this memory-memory architecture. This is going to be a fantasy architecture, and memory-memory architectures are not practical, perfect for a computer architecture fantasy.
And it’s appropriately and lazily named Fantasy-1.
Initial Ideas
This is an old-school game console that probably looks like the NES or SNES that hook up to the CRT TV in the living room. So the CPU is probably only 16-bit and the memory was not going to be very big. I had no particular ideas about how input / output is going to be handled but I decided that part can be left until later. At first I thought the screen resolution could stay at 320×240 but later I decided to bump it up to VGA. I decided to let it have 24-bit color depth so the image may look more vibrant.
Next I thought about the instructions. Since there is no register, all the load and store stuff is not needed. For a start, I decided to begin with basic arithmetic instruction: addition, subtraction, multiplication and division. Each operation has a byte and a word variant, since this is a 16-bit architecture. No float point is provided.
The instruction format is simple, the lower bits are the opcodes and the rest of the bits are divided into the source operand and the destination operand. To save bits, I chose a format that is more akin to the x86 format instead of the ARM-like format in which the destination is explicitly expressed. Each operand will be specified with the full address, and if this thing eventually is used to do 64-bit stuff, that instruction is going to be very, very long. Not cool.
With these bits in place, I started coding.
未开放评论