Skip to content

1. What is MiSTer2MEGA65

sy2002 edited this page May 5, 2022 · 10 revisions
  • MiSTer2MEGA65 (M2M) is a framework to simplify the porting of MiSTer cores to the MEGA65.

  • The Commodore 64 for MEGA65 core was made using M2M while the GameBoy for MEGA65 core was made with an earlier preliminary version of M2M. Have a look at the Alternative MEGA65 cores website to learn more.

  • MiSTer2MEGA65 is also a great starting point to create new cores for the MEGA65 from scratch, because it takes care of many nitty-gritty details, further explained below.

  • MiSTer2MEGA65 comes with a fully-featured demo core (example design) for the MEGA65 to get started learning M2M but also to get started learning more about FPGA development using VHDL in general.

  • MiSTer2MEGA65 is abbreviated as M2M.

Why do I need MiSTer2MEGA65?

You don't. It is absolutely possible to port MiSTer cores and other cores to the MEGA65 without using M2M. An example for that is the great ZX Spectrum core for the MEGA65 (zxuno4mega65).

What MiSTer2MEGA65 does is to simplify and accelerate the process of porting MiSTer cores by providing you with a standardized approach and a standardized set of tools.

Learn more on YouTube about the difference between the MiSTer and the MEGA65 and why MiSTer2MEGA65 might make sense for you to use.

In a nutshell: MiSTer also uses a framework. Additionally to the FPGA, MiSTer uses an ARM processor running Linux to perform various tasks to support the core such as device I/O (keyboard, controllers, ...), displaying an on-screen-menu, loading ROMs, and mounting disk-images as floppy- or hard-drives. Since the MEGA65 is a "pure-play" FPGA-based system - without an ARM co-processor and without Linux - the basic idea of M2M is to replace the MiSTer framework by an equivalent MEGA65-specific solution.

What does the MiSTer2MEGA65 framework do?

The M2M framework abstracts away a lot of the hardware details of the MEGA65:

  • Keyboard
  • HDMI audio and video output
  • SD card (FAT32) access
  • MEGA65's hardware ports such as 3.5mm audio-out, joysticks, expansion port, ...
  • HyperRAM

That means that when porting a core, you can focus on the core-specific details and user experience without needing to reinvent the wheel.


  • Vivado template project that enables you to create a bitstream for the MEGA65 including the necessary port mappings and constraints
  • Support for MEGA65 Release 2 and Release 3 machines (aka R2 and R3)
  • Controllers for the MEGA65 hardware
  • Drop-in replacements for various RAM types that MiSTer uses
  • Display timings
  • 3.5mm audio jack support (encode LPCM to PDM)
  • HDMI video (720p @ 50 Hz and 60 Hz) and audio support (sample LPCM with 48 kHz and transmit it via HDMI)
  • SD card and FAT32 support
  • Load BIOS ROMs and cartridge ROMs and the likes before starting the MiSTer core
  • Easy to use infrastructure to map the disk-drives, HDs, etc. of the MiSTer core to MEGA65's SD card and/or to its floppy disk drive
  • Control the MiSTer core (start, stop, reset, pause, ...)
  • On-Screen-Menu (overlay) that offers configuration options and file system functionality for the MiSTer core while it is running
  • Scaling and video filters
  • Audio filters

How does MiSTer2MEGA work?

M2M is an "FPGA-only" or "pureplay FPGA" solution. This means, that no additional computing and/or operating system resources outside of what we can put into the FPGA are used.

Instead, M2M provides you with an abstraction layer that replaces the Quartus/Intel specific modules and resources that MiSTer uses with Vivado/Xilinx compatible versions. Examples for that are clocking resources, IO, and RAMs/ROMs. Also more high-level functions such as converting a PAL, VGA or similar "retro" video stream into HDMI. Moreover, M2M features a built-in 16-bit System-on-a-Chip (SoC) called QNICE, which provides support for FAT32 formatted SD cards and an on-screen-menu.

M2M works by providing a ready-to-build VHDL module structure in which you can embed your MiSTer core. It does not matter, if the core you want to port is made using VHDL, Verilog, System Verilog or a mixed-bag of all of these.

To port a core from MiSTer to the MEGA65, "all you have to do" is to put the MiSTer core into the right module of this structure, wire the input/outputs correctly and provide the correct clocks. Then you provide RAMs/ROMs and configure the behavior of the MEGA65 "Shell": What options does your on-screen menu offer? Do you need to mount drives or to load ROMs? Help system? Core control?

What are the design principles of MiSTer2MEGA65?

The MEGA65 does have some significant ROM/RAM constraints compared to the MiSTer: There is the RAM that is contained in the FPGA and there are 8 MB up to 16 MB of relatively slow HyperRAM. This is why MiSTer2MEGA65 strives to be a total bean counter when it comes to saving/preserving ROM/RAM space. The goal is to leave as much of this precious resources to the actual MiSTer core as possible.

Design goals of MiSTer2MEGA65

  1. Simplify and speed-up the porting of MiSTer cores to the MEGA65 by providing a standardized approach (methodology) and toolkit (framework).

  2. Do not force anybody to program QNICE directly but instead provide an abstraction layer via a QNICE ROM that can be configured directly from the VHDL or Verilog layer. (But do allow direct QNICE programming for those who want maximum control over the user interface experience.)

  3. Small QNICE ROM/RAM footprint preferred over programmer's convenience and execution speed (the on-screen-menu including the end user experience should be snappy though).

  4. Modular architecture: You only pay for what you use.

  5. Flexible architecture: We will start small and grow over time. But that means we need to go the last mile when it comes to avoiding architectural dead ends.


At the core of the MiSTer2MEGA65 philosophy is this simple but sometimes not so simple to implement idea:

Avoid touching the original!

That means: Avoid touching the MiSTer core you are porting and avoid touching as well the MiSTer2MEGA65 framework and QNICE.

The reason for that is simple: You want to easily be able to update to newer versions of the MiSTer core, the MiSTer2MEGA65 framework and QNICE. Always document each and everything (even the smallest changes) that you are applying in one of these three modules in doc/m2m/

What is the "Shell", what do you mean by "firmware"?

Shell and firmware are sometimes used as synonyms but there are some subtle differences: The "firmware" in the context of M2M is the complete ROM that is used by the QNICE SoC. It contains QNICE's operating system called "Monitor", various support functions and the "Shell".

The "Shell" on the other hand is a convenient implementation of a user interface and file I/O layer that makes sure, that you do not need to learn a lot of details around QNICE to port a core: Nearly everything can be configured using two VHDL files: config.vhd and globals.vhd.

In other words: The Shell is part of the firmware but it is not the firmware.

You can use the Shell to focus on your Verilog/VHDL code and avoid QNICE programming. Alternatively, you can do it the other way round and avoid the Shell and create your own user interface and core control automation instead.

Look and feel of the Shell

The first two demo-pictures in the C64 core's are giving you a first impression how the Shell looks: The first image called "Core Menu" shows you the C64 core's on-screen-menu that appears, when you press Help while the core is running: Use it to mount drives, configure the core and learn more. The second image called "Disk mounting / file browser" demonstrates the file browser used to mount disk images or to load ROMs (at other cores).

Can you explain the meaning of the various files and folders?

Directory Explanation
M2M MiSTer2MEGA65 framework
M2M/QNICE QNICE System-on-a-Chip
M2M/font Font used by the start- and help-screens and the on-screen-menu
M2M/rom Software part of the M2M framework: M2M firmware and the Shell
M2M/vhdl Hardware part of the M2M framework: MEGA65 controllers, hardware abstractions, rendering pipeline
M2M/video_filters Selected MiSTer video filters converted to the M2M video filter format
CORE This is "your" directory. The place where your port is located. Learn more about the sub-structure below
CORE/<MiSTer fork> Create a Git submodule that points to the fork of the MiSTer core that you are porting; freely choose a name for this folder depending on how you named your MiSTer fork
CORE/m2m-rom Top-level file of the firmware to give you control over all aspects and the actual .rom file of the firmware
CORE/vhdl All M2M files that you need to change/enhance for your core plus all additional files that your core needs
doc Documentation of your port as well as recommended MiSTer2MEGA65 standard documentation plus all assets for GitHub (e.g. images)
File Explanation
AUTHORS Add yourself and everyone who contributed to the core, including MiSTer, MiST, and other authors
LICENSE M2M is licensed under GPL 3.0 Shown by GitHub when somebody browses your repository; make sure to update

What is the best way to proceed from here?

We highly encourage you to follow the track and continue with First Steps from here and after your worked through the "First Steps" (including the tutorial) we recommend to continue with all the tutorials that are part of the "Hello World" Tutorial.