FPU for the MiSTer Minimig core
Posted: Fri Mar 18, 2022 9:49 am
I have been looking into FPU options for a long time. Overall it does not seem to be that important on the MiSTer, because even if we implement FPU for the Amiga of AO486 core, the CPU speeds are not fast enough to run the types of games or software that makes use of FPU.
But I might be wrong and either way its still interesting if we could get FPU support, just for the sake of it. Many MiSTer cores are based on emulators, especially open source emulators. So my idea is that looking into software FPU emulators, we could probably find a way to add FPU support to the Minimig core in some way.
It could probably be put directly in the core, but first I hope to look into using the existing ARM FPU. I found an Amiga software FPU solution that is open source:
https://github.com/nonarkitten/femu
I am thinking it should be possible to then implement this into MiSTer Main, making it capable of translating Amiga FPU calls to ARM FPU calls.
FEMU is written in Assembly and I already had some trouble learning C given how my main programming language is C#, but the main thing to understand about C coming from C# is pointers and I got some help with that on the MiSTer Discord. MiSTer Main is written in C. Assembly is quite different though from C and C#. It was never meant to be humanly readable, I think its even called machine code. Otherwise it at least is very close to machine code, which also is why its as effective and fast as it is. If you want code to be highly optimized and with a small as possible footprint, Assembly is the way to go.
FPUs have always been problematic though. Whether its x86 or 68k, there are several different types of FPUs and each of them having different calls and operations that does thing differently. Same with ARM for that matter... well, at least an ARM FPU is different from x86 and 68k FPUs, but I am pretty sure different ARM FPUs also have different calls and operations.
I am making this post because I hope to find others interesting in following progress for this and hopefully also helping in some way?
I hope to find some Amiga software that is used to test FPUs, that might help test things. But another shortcoming for me is I am not experienced with FPGA cores and how to develop them, or how to make them communicate with MiSTer Main. I have begun looking into it though and have done a few experiments already. I helped a bit with the PSX and AO486 core. Well, with the PSX core it was on the MiSTer Main side, but I did get a change added to the AO486 core as well. It probably could not be any simpler than the change I added, but it worked and made a meaningful change adding support for more disk image types. But still I have next to no experience on the core side and I hope someone might be able to help add a way for the 020 core to have a special version of it that supports FPU calls. The 020 supports the MC68882 CPU expansion, so if the hardware sees it as that, that ought to be a good starting point.
If no one can help do that, it will probably be a long time before I can begin the work in any way. I will try to keep building up my knowledge of MiSTer development both on the Main and the FPGA side and eventually I might be able to do something like this. First I think I will look into CD audio support. That is what I helped with on the PSX core a bit.
But I might be wrong and either way its still interesting if we could get FPU support, just for the sake of it. Many MiSTer cores are based on emulators, especially open source emulators. So my idea is that looking into software FPU emulators, we could probably find a way to add FPU support to the Minimig core in some way.
It could probably be put directly in the core, but first I hope to look into using the existing ARM FPU. I found an Amiga software FPU solution that is open source:
https://github.com/nonarkitten/femu
I am thinking it should be possible to then implement this into MiSTer Main, making it capable of translating Amiga FPU calls to ARM FPU calls.
FEMU is written in Assembly and I already had some trouble learning C given how my main programming language is C#, but the main thing to understand about C coming from C# is pointers and I got some help with that on the MiSTer Discord. MiSTer Main is written in C. Assembly is quite different though from C and C#. It was never meant to be humanly readable, I think its even called machine code. Otherwise it at least is very close to machine code, which also is why its as effective and fast as it is. If you want code to be highly optimized and with a small as possible footprint, Assembly is the way to go.
FPUs have always been problematic though. Whether its x86 or 68k, there are several different types of FPUs and each of them having different calls and operations that does thing differently. Same with ARM for that matter... well, at least an ARM FPU is different from x86 and 68k FPUs, but I am pretty sure different ARM FPUs also have different calls and operations.
I am making this post because I hope to find others interesting in following progress for this and hopefully also helping in some way?
I hope to find some Amiga software that is used to test FPUs, that might help test things. But another shortcoming for me is I am not experienced with FPGA cores and how to develop them, or how to make them communicate with MiSTer Main. I have begun looking into it though and have done a few experiments already. I helped a bit with the PSX and AO486 core. Well, with the PSX core it was on the MiSTer Main side, but I did get a change added to the AO486 core as well. It probably could not be any simpler than the change I added, but it worked and made a meaningful change adding support for more disk image types. But still I have next to no experience on the core side and I hope someone might be able to help add a way for the 020 core to have a special version of it that supports FPU calls. The 020 supports the MC68882 CPU expansion, so if the hardware sees it as that, that ought to be a good starting point.
If no one can help do that, it will probably be a long time before I can begin the work in any way. I will try to keep building up my knowledge of MiSTer development both on the Main and the FPGA side and eventually I might be able to do something like this. First I think I will look into CD audio support. That is what I helped with on the PSX core a bit.