Before we start exploring, programming and using technical subjects, I think it’s wise to get to know the MEGA65 system setup and its concepts. This will help provide context while exploring and also during troubleshooting.
To start, let’s look at the main components of the system. The MEGA65 is a machine that is structured in a layered manner:
Let’s discuss these layers from bottom to top.
FPGA Hardware
What is a FPGA? FPGA is short for field-programmable gate array. It is an integrated circuit that can be altered (reprogrammed) to impersonate other integrated circuits (or a collection of them). This means that the hardware can appear and behave as we want it to. As a result, the motherboard in the MEGA65 does not contain a lot of ICs:
To be fair, the MEGA65 has three FPGAs in its system:
- Main FPGA. (Xilinx Artix-7)
- FPGA for various electronic functions. (Altera MAX10)
- FPGA for keyboard logic (Lattice). This FPGA is located on the keyboard itself.
For us, the Main FPGA is the important one we want to talk about.
Being FPGA based is a different approach to what we are used to with retro computers: A motherboard with lots of sockets and chips (ICs) laid out on it, as seen here on a Commodore 64 motherboard:
For example, if the FPGA on the MEGA65 motherboard would need to impersonate a Commodore 64, these chips would be defined in the configuration file (know as a core file) and applied to the FPGA chip. A dedicated example of a Commodore 64 in an FPGA is the Ultimate 64.
Which brings us to:
FPGA Cores
The FPGA configuration is called a core, and the MEGA65 has support for 8 of these cores. This means that the MEGA65 system can impersonate different types of hardware, as long as this configuration fits in a core slot and the configured hardware plays nice with the MEGA65 hardware, like keyboard, video output, joystick ports and so on.
Taking again the Commodore 64 as an example, there is a custom core available that will turn the MEGA65 into a fully compatible Commodore 64. You can also try ZX Spectrum, Gameboy, and Arcade Machines cores, like Galaga and Xevious.
Core files can be downloaded and added to a slot in flash memory. As the flash memory supports 8 slots, there is high potential for this machine to be the best hobby computer out there. Slot 0 is reserved for the factory core so let’s not mess with that one. Effectively, 7 slots are available for other cores. During boot, you can hold the NO SCROLL key and select the slot you want.
Hypervisor
We return to the MEGA65 hardware configuration. The next component in the list is the hypervisor, called HYPPO. HYPPO is part of the MEGA65 core, you will not be able to use it when running alternative cores.
What’s a hypervisor? If you turn to the internet, you will read that a hypervisor is a piece of software that will enable a computer to run what is called virtual machines. HYPPO though, is a limited hypervisor and more like an advanced task and system manager and provider of services.
When do we see this hypervisor in action? When booting the machine, when configuring the machine and when freezing the machine. Also, it can react to events in the MEGA65, like crashes, or when receiving files over the network or JTAG debugger serial port. Also, certain key combinations will trigger a hypervisor reaction, like starting a debugging monitor/console.
Here we see the hypervisor booting. Holding CTRL allows you to inspect this screen.
The hypervisor also provides services that can be used in programs, including our own. These hypervisor interactions will be explored and discussed in the posts to come, but I want to mention one here because it also influences the system and will be used regularly throughout the posts on this blog.
Freezer Program
Traditionally, a freezer is a cartridge in the back of a computer, which was able to halt the computer, and run an application (like a menu to launch other tools) independent from the state of the computer. This behaviour is like one of the Commodore 64 cartridges of old, where you pressed a button on the cartridge itself. Closing the freezer program would return control to the computer.
In the MEGA65 though, the hypervisor reacts to the RESTORE key being pressed and takes over: it freezes the machine state, puts the CPU in hypervisor mode and loads the freezer system program which is located on the SD card. The Freezer program itself uses hypervisor services to provide its tools and features, like access to the SD card and various utilities and tools.
Any changes made in the Freezer to video settings, CPU modes etc. are all temporary. If you need permanent changes, go into the hypervisor configuration utility upon boot (hold the ALT key) and set your defaults there.
Pressing the HELP key in the Freezer will start the MEGA Info tool and show the versions of various MEGA65 components, like hardware, board revision, ROM, loaded FPGA core, etc. This can be essential information when troubleshooting software and hardware
The Freezer also has options to save or load a machine state. What is not shown on the screen (but in the manual) is that you need to use the ARROW keys (left and right) to select the active state slot, and then press save, or load if the slot does contain a saved state. This is extremely handy for debugging: returning to a known faulty state to repeat or try other solutions.
So, the hardware is in place, the hypervisor is booting the system for us, and then?
Operating System ROM
Just like other computers, the MEGA65 needs an operating system (known as the KERNEL) and an environment to run programs in (BASIC). This functionality is provided by a ROM file called MEGA65.ROM on the SD card. The hypervisor loads this file into memory and then makes this area of memory read-only, effectively simulating a ROM chip mapped to computer memory, as we are used to in the machines of old.
As the ROM is now a file, and not a physical chip, we can have another fun feature of the hypervisor: multiple ROM files on one system. During boot the hypervisor can be instructed to load another ROM file than the default. This makes it possible to test different or experimental operating systems, or play with your own version without disrupting a stable system.
Software
The topmost layer in the system. On top of the operating system we run our programs. Which we will make OURSELVES! This used to be the only flexible part of a computer, but no longer!
Concluding
Having multiple layers makes the MEGA65 system a very flexible system. Where traditionally the only flexible part of a computer was the user software running on it, it is now possible to modify all the different layers of the system which can make your MEGA65 a modified or completely different machine if you want it to.
This series of posts will focus on the MEGA65 experience itself though and alternate cores will not be the focus of these posts, but who knows what other people in the community will come up with? I’m excited!
I hoped you liked this post about the concepts and buildup of the system. I think it’s good to know these things moving forward. If you have any questions or recommendations please share them in the comments below or look me up on Mastodon or the MEGA65 Discord.
Thanks for now, and see you in the next post!
Leave a Reply