Vampire V2.7 with FPU

The new Vampire firmware is released V2.7 which contains a Hardware FPU in the FPGA (some seldom 68881/68882 commands are still emulated, like the 68060/68040 also do) but nevertheless, thats very nice for my MUIMapparium (you remember the problem?). Of course I flashed directly the new version, first the bad news, it’s VERY unstable for me, it’s said it needs some soldering because there are some errors on the early Vampire cards which make the power supply to the FPGA bad… something like this and I’m affected with that … so it’s a little bit annoying to work with it because there are drawing errors on the screen and it crashes often. I reduced the screen resolution and ended all background program which made it much better. But nevertheless to really try it out I have to wait until someone fix my card. I can’t do that myself, most scary thing in the world a coder with a screwdriver let alone a soldering equipment :-P.
But this was not the topic of this post. I tried MUIMapparium FPU version on my new Vampire 2.7… good news it starts does not crash, bad news the map stays empty. The same Executable worked well with FEmu (I checked especially before I flashed the new one) on the old Gold 2 and still work in UAE. But the FPU calculation seems to work because the mouse pointer movement shows reasonable coordinates. I was a little bit surprised because even the GUI in the map window was gone. I checked the code ah yes there is a tiny floating point calculation, fine let’s see whats that. An my guess was right it is the floating point calculation, the Button size is calculated by the Font Size * 1.2 to have a little bit more space around it. After adding some debug output it seems that the floating point calculation works well but the rounding always return zero, so I wrote a little test program to test the rounding here the outputs of the testprogram in my setups:

Na? who spots the difference. Funny that only Round() have this problem but ceil, trunc, floor not. This also explains why MUIMapparium shows no maps at all, if all is rounded to 0. Ok I have to wait until they fix that… yeah I could replace all Round(a) by Floor(a+0.5) but why should I do that, here is clearly something broken in the FPGA.

You want to try on your own computer – Exe for m68k with FPU: TestFPU and the source: TestFPU.pas

@flype
The Round() on 68k always uses a helper for now, because FPC’s Round() is defined to return an int64 value (signed 64bit integer). This cannot be done by the hardware on 68k, so the code currently calls the round helper, which is a pretty big function, and depends on the IEEE bit-correct result of all operations, as it does some integer bit tricks on floats. (There could be some special cases added, when the expected integer result is less or equal to a 32bit signed int, but that’s beside the point now.)

What’s more worrying is the previous multiplication miscalculation by 1.3, which contains the following three instructions:

moveq.l #5,d2; fmove.w d2,fp2; fmul.d #1.3,fp2

I’d start with this, because Round’s internal implementation depend a lot on the implicit rounding behavior of the FPU (when loading to-from FPU registers), which seems to be clearly off, and without that working correctly, round would never work.

And the usual rant: there are several compiler testcases out there. Even UAE’s emulation has chunks of validation code. Either no one ever cared to run those, or they did too big corner cuts to squeeze the FPU in the FPGA. To be seen.

BTW, if it’s relevant, the FPC RTL enables overflow, operand error and division by zero exceptions, and uses round to nearest mode with default precision. (Which is extended, IIRC). It does so by loading 0x3400 into the FPCR. It currently compiles no 040/060 specific instructions, everything is ‘882 code only.

When Gunnar was asked the same question on IRC, he estimated next Core update in 1-2 weeks, giving people time to register. This time several people can get their boards whitelisted. Wether or not flype/the team can provide you a fix while waiting, thats up to them to answer. 🙂