DIY Fpu Unit for STFM

Troubles with your machine? Just want to speak about the latest improvements? This is the place!

Moderators: Mug UK, Zorro 2, spiny, Greenious, Moderator Team

tcat
Obsessive compulsive Atari behavior
Obsessive compulsive Atari behavior
Posts: 145
Joined: Fri May 03, 2013 6:00 am

DIY Fpu Unit for STFM

Post by tcat »

Hi,

I was wondering how FPU unit works on ATARI. I can only guess that while $A000, A-line instructions used for graphics, some kind of $F000, F-line instructions possibly used for FP maths?

I have only a limited info, and that is on h/w register.
$FFFA40 - status register
$FFFA40 - command register
$FFFA40 - condition register
$FFFA40 - operands regsiter
I can imagine some operands are written to a h/w register, then main processor is stalled, and only resumed to fetch maths result from another h/w register. The idea is that FPU get the result computed faster than the main processor, correct?

How could I assemble a very simple FPU DIY kit for STFM (ideally mimicking MC68881). I am no hardware talent, but with some guidance I would like to give it a try.

Many thanks
Tomas
Last edited by tcat on Mon Sep 30, 2019 1:36 pm, edited 1 time in total.

User avatar
frank.lukas
Hardware Guru
Hardware Guru
Posts: 1891
Joined: Tue Jan 29, 2008 5:33 pm
Location: Germany

Re: DIY Fpu Unit for STFM - possible?

Post by frank.lukas »

May be have a look at the Mega STE Schematics ...
fancy Atari Musik anDA Dance "Agare Hinu Harukana" 1998 ATARI http://www.youtube.com/watch?v=JX10fxb5eYE

czietz
Hardware Guru
Hardware Guru
Posts: 1170
Joined: Tue May 24, 2016 6:47 pm

Re: DIY Fpu Unit for STFM - possible?

Post by czietz »

OK, you're mixing two thing up, I think. First, F-line instructions are indeed used for FPU on CPUs that have a coprocessor interface, starting with the 68020. So on the TT -- when equipped with a FPU -- floating point math will be done via F-line instructions.

However, the 68000 doesn't have a coprocessor interface. That's why Atari designed the SFP004 add-on card which uses the hardware registers that you mention. Software would need a special floating point math library that interfaced with the FPU via these registers. There is some description (in German!) in the Atari Profibuch. However, the official source of information, the "SFP004 Developer's Kit" seems to be lost.

Or does anyone here have it?

czietz
Hardware Guru
Hardware Guru
Posts: 1170
Joined: Tue May 24, 2016 6:47 pm

Re: DIY Fpu Unit for STFM - possible?

Post by czietz »

This is a library (incl. C/ASM source code), albeit without much documentation, for the SFP004: http://atariftp.czietz.de/pub/atari/Pro ... sfp004.lzh. There's also a guide to "Add a 68881 numeric processor to your ST" on http://atari4ever.free.fr/.

joska
Hardware Guru
Hardware Guru
Posts: 4624
Joined: Tue Oct 30, 2007 2:55 pm
Location: Florø, Norway
Contact:

Re: DIY Fpu Unit for STFM - possible?

Post by joska »

tcat wrote:How could I assemble a very simple FPU DIY kit for STFM (ideally mimicking MC68881).
Before you do that - are you doing this just for fun or because you expect software to run faster? Because there is almost no software out there that use the FPU on 68000 Ataris. I used to have a Mega STE with FPU, and the only software I can remember that used the FPU was POVray.
Jo Even

VanillaMiNT - Firebee - Falcon060 - Milan060 - Falcon040 - MIST - Mega ST - STM - STE - Amiga 600 - Sharp MZ700 - MSX - Amstrad CPC - C64

User avatar
Frank B
Atari God
Atari God
Posts: 1025
Joined: Wed Jan 04, 2006 1:28 am
Location: Boston

Re: DIY Fpu Unit for STFM - possible?

Post by Frank B »

czietz wrote:OK, you're mixing two thing up, I think. First, F-line instructions are indeed used for FPU on CPUs that have a coprocessor interface, starting with the 68020. So on the TT -- when equipped with a FPU -- floating point math will be done via F-line instructions.

However, the 68000 doesn't have a coprocessor interface. That's why Atari designed the SFP004 add-on card which uses the hardware registers that you mention. Software would need a special floating point math library that interfaced with the FPU via these registers. There is some description (in German!) in the Atari Profibuch. However, the official source of information, the "SFP004 Developer's Kit" seems to be lost.

Or does anyone here have it?
I believe lattice c can target it...

tcat
Obsessive compulsive Atari behavior
Obsessive compulsive Atari behavior
Posts: 145
Joined: Fri May 03, 2013 6:00 am

Re: DIY Fpu Unit for STFM - possible?

Post by tcat »

Hi All,

Thank you for ample input, processing ... 1 of 100% of understanding here:-)

@czietz
There's also a guide to "Add a 68881 numeric processor to your ST" on http://atari4ever.free.fr/
The `fpu68881.zip' contains *.IMG files, what application can open them?

@joska
Before you do that - are you doing this just for fun or because you expect software to run faster?
Mainly fun and proof of concept, as I have TOS 1.04, I fitted myself a blitter chip, so my confidence went high slightly and motivated me to FPU kit thoughts.
I naivelly thought using a suitable stub, all FPU calls to $F000 instructions, in existing apps for TT machines and the like, and apps using ATARI `LIBF' (math.h) library, can be diverted to `SFP004' library on STFM machines?

Can software sense FPU unit presense, similarly as with the A-line and blitter? E.G. Will `GEM-Bench' sense it?

@frank b.
I believe `lattice c' can target it...
I have also found `SFP004.MOD' with Megamax Modula-2 system, I may start with this, and the M/C library mentioned therein, plus `FPU004 Atari Kit', should it be recovered, have to ask Loney Pursel, as he is the ATARI docs librarian.

GFA-Basic 3.6TT seems targeting mostly MC68020 and higher, but perhaps with some stubs can work with `FPU004' too?

Many thanks so far.
Tomas

joska
Hardware Guru
Hardware Guru
Posts: 4624
Joined: Tue Oct 30, 2007 2:55 pm
Location: Florø, Norway
Contact:

Re: DIY Fpu Unit for STFM - possible?

Post by joska »

tcat wrote:Can software sense FPU unit presense, similarly as with the A-line and blitter?
It can, but it doesn't necessary do that.
tcat wrote: E.G. Will `GEM-Bench' sense it?
No, GEMbench use a different approach. It has loadable modules, one for 68000 machines and one for 020+. It will use whichever module you specify. Wrong module = crash.
Jo Even

VanillaMiNT - Firebee - Falcon060 - Milan060 - Falcon040 - MIST - Mega ST - STM - STE - Amiga 600 - Sharp MZ700 - MSX - Amstrad CPC - C64

tcat
Obsessive compulsive Atari behavior
Obsessive compulsive Atari behavior
Posts: 145
Joined: Fri May 03, 2013 6:00 am

Re: DIY Fpu Unit for STFM - possible?

Post by tcat »

Hi,

I have converted `CIRCUIT.IMG' file (which appears some GEM VDI RLE encoded raster file), to a plain PNG. It shows how MC6800 connects to FPU through some address decoding logic. Has anyone attempted to design a suitable daughter PCB layout for ST?
CIRCUIT.PNG
Is MC68000 socketed in STFM machines?

Many thanks.
Tomas
You do not have the required permissions to view the files attached to this post.

User avatar
troed
Atari God
Atari God
Posts: 1456
Joined: Mon Apr 30, 2012 6:20 pm
Location: Sweden

Re: DIY Fpu Unit for STFM - possible?

Post by troed »

tcat wrote: Is MC68000 socketed in STFM machines?
Very seldomly. Unfortunately not the easiest IC to extract in one piece for socketing either. Needs proper equipment.

The diagram you extracted, does it exist on http://www.dev-docs.org ? If not, it would be great to see it there :)

tcat
Obsessive compulsive Atari behavior
Obsessive compulsive Atari behavior
Posts: 145
Joined: Fri May 03, 2013 6:00 am

Re: DIY Fpu Unit for STFM - possible?

Post by tcat »

Hi,
@troed, thank you, will do.

Anyone having a datasheet on MC68881?
Many thanks
Tomas

czietz
Hardware Guru
Hardware Guru
Posts: 1170
Joined: Tue May 24, 2016 6:47 pm

Re: DIY Fpu Unit for STFM - possible?

Post by czietz »

The 68881 user manual is on dev-docs: http://www.dev-docs.org/docs/htm/search.php?find=68881

tcat
Obsessive compulsive Atari behavior
Obsessive compulsive Atari behavior
Posts: 145
Joined: Fri May 03, 2013 6:00 am

Re: DIY Fpu Unit for STFM - possible?

Post by tcat »

Hi,

Looking into `sfp004' library (thank you czietz, Loney), and reading MC68881 manual, I realise how little understanding do I have.
I took the example of SIN(x). It seems coded for some GNU/C/ASM compiler, can be possibly also ported to an ST assembler.

Code: Select all

# FUNCTION:     SIN(X)
#
# base =        0xfffa50
#      the fpu addresses are taken relativ to "base":
comm =   -6
resp =  -16
zahl =    0

        .globl _sin
.text
.even
_sin:
        lea     0xfffa50,a0
        movew   #0x540e,a0@(comm)       | specify function
        cmpiw   #0x8900,a0@(resp)       | check
        movel   a7@(4),a0@              | load arg_hi
        movel   a7@(8),a0@              | load arg_low
        movew   #0x7400,a0@(comm)       | result to d0
# wait
        .long   0x0c688900, 0xfff067f8
        movel   a0@,d0
        movel   a0@,d1
        rts
Questions:
>>>>>>

According to MC68881 manual, FPU has got eight FP0..FP7 float registers 80 bits each!!!
But we move only two long words (2x32 bits) for argument `x'.
movel a7@(4),a0@ | load arg_hi
movel a7@(8),a0@ | load arg_low
Where do I find result of SIN() operation, as this is only a word, and what triggers the FPU command execution?
movew #0x7400,a0@(comm) | result to d0
I thought, MC68000 is stalled when FPU works, but it seems waiting, what do these two longs do?
# wait
.long 0x0c688900, 0xfff067f8
This could possibly be the result of SIN(x), but why is it moved twice, to d0, and then to d1, and is only 32bits each?
movel a0@,d0
movel a0@,d1
Many thanks
Tomas

LuigiThirty
Atari maniac
Atari maniac
Posts: 97
Joined: Sat Sep 03, 2016 12:20 am

Re: DIY Fpu Unit for STFM - possible?

Post by LuigiThirty »

It looks like the 68000 communicates with the FPU using some registers at $FFFA50.
$FFFFFA40 r/w Status register
$FFFFFA4A r/w Command register
$FFFFFA4E r/w CCR register
$FFFFFA50 r/w Operation register
movel a7@(4),a0@ | load arg_hi
movel a7@(8),a0@ | load arg_low
This is sending a 64-bit number to the FPU using the operation register.
movew #0x7400,a0@(comm) | result to d0
I think this is telling the FPU to execute the command stored in the command register.
# wait
.long 0x0c688900, 0xfff067f8
This is a CMP/BEQ 0xF8 combo. A delay loop waiting for whatever the CMP is. I don't have an assembler in front of me unfortunately, but it should read:

0C68 8900 FFF0
67F8
movel a0@,d0
movel a0@,d1
This would be fetching the 64-bit result from the operation register and placing it in d0 and d1.

tcat
Obsessive compulsive Atari behavior
Obsessive compulsive Atari behavior
Posts: 145
Joined: Fri May 03, 2013 6:00 am

Re: DIY Fpu Unit for STFM - possible?

Post by tcat »

Hi Luigi,

Many thanks this helps a lot.
I am still confused by `@' sign in the instructions' field.
movel a0@,d0
movel a0@,d1
Does it mean this?
move.l (a0)+,d0
move.l (a0),d1
Many thanks.
Tomas

tcat
Obsessive compulsive Atari behavior
Obsessive compulsive Atari behavior
Posts: 145
Joined: Fri May 03, 2013 6:00 am

Re: DIY Fpu Unit for STFM - possible?

Post by tcat »

Hi Luigi,

Actually I may have got it. CPU 68000 has only 16-bit data bus, while FPU 68881 has 32-bit data bus. So to read 64-bit number, we need to access the bus twice in succession.
move.l (a0),d0 ; read lower 32bits from fp0 register
move.l (a0),d1 ; read upper 32bits from fp0 register
Correct?

Wait for result loop is documnented in `muldf3', recoding to normal ST assembly
.wait: cmpi.w #$8900, resp(a0)
beq.s .wait
base equ $fffa50
comm equ -6 ; command register offset
resp equ -16 ; response register offset
result equ 0 ; result (operand) register offset
Tomas

LuigiThirty
Atari maniac
Atari maniac
Posts: 97
Joined: Sat Sep 03, 2016 12:20 am

Re: DIY Fpu Unit for STFM - possible?

Post by LuigiThirty »

MOVE.L is always a 32-bit operation. I would have to guess (not familiar with the FPU hardware) that there's hardware logic that advances a buffer when the FPU is returning a 64-bit result. Reading once grabs the first 32 bits, reading again grabs the second 32 bits.

tcat
Obsessive compulsive Atari behavior
Obsessive compulsive Atari behavior
Posts: 145
Joined: Fri May 03, 2013 6:00 am

Re: DIY Fpu Unit for STFM - possible?

Post by tcat »

Hi,

My STFM programming manual says on exception vectors:
$000028 - LineA: to use with Blitter `$Axxx.w'
$00002C - LineF: internally used by AES `$Fxxx.w'

I was hoping to use LineF for FPU commands, is there a way?
Many thanks
Tomas

LuigiThirty
Atari maniac
Atari maniac
Posts: 97
Joined: Sat Sep 03, 2016 12:20 am

Re: DIY Fpu Unit for STFM - possible?

Post by LuigiThirty »

You would need to install an exception handler at $2C that reads the Line-F command (encoded in the last 12 bits of the opcode) and triggers the correct FPU command sequence in the library.

czietz
Hardware Guru
Hardware Guru
Posts: 1170
Joined: Tue May 24, 2016 6:47 pm

Re: DIY Fpu Unit for STFM - possible?

Post by czietz »

Note that TOS 1.00 - 1.04 use Line-F for their own purposes. You'd have to upgrade your ST to TOS 2.06 to even be able to use the Line-F handler for floating point math. Also, likely you won't find any software compiled for 68000 that uses Line-F for floating point instructions. Software that uses Line-F for FPU will always expect at least a 68020, so it might not even run on a 68000.

tcat
Obsessive compulsive Atari behavior
Obsessive compulsive Atari behavior
Posts: 145
Joined: Fri May 03, 2013 6:00 am

Re: DIY Fpu Unit for STFM - possible?

Post by tcat »

Note that TOS 1.00 - 1.04 use Line-F for their own purposes.
Hi,
Yes now I see, my TOS is 1.04, so I would stick with SFP004 lib. The author of DIY FPU kit, comments on ganing some 1400% on CAD like software runing on MEGA ST (= STFM with detached processor, keyboard). While exploring MM2 SFP004 builtin support, might it be also worth adapting GFA-LIB for SFP004, if not a silly idea?
Tomas

tcat
Obsessive compulsive Atari behavior
Obsessive compulsive Atari behavior
Posts: 145
Joined: Fri May 03, 2013 6:00 am

Re: DIY Fpu Unit for STFM - possible?

Post by tcat »

Hi,

In the CPU-FPU wiring diagram `74HCxx' ICs are used for address decode. Can these be safely replaced with `74LSxx' ones?

Many thanks
Tomas

tcat
Obsessive compulsive Atari behavior
Obsessive compulsive Atari behavior
Posts: 145
Joined: Fri May 03, 2013 6:00 am

Re: DIY Fpu Unit for STFM - possible?

Post by tcat »

Hi,

Reviving the topic, after getting all the components. 74HCxx in DIL, and MC68881 in PLCC.

EDIT
Trying to make a simple PCB design with KiCad tool...

I have just found 68PLCC socket footpprint in the KiCad lib.
Cannot not find the FPU symbol file, though. So I am wondering, how does MC68881 pinout map over 68PLCC socket?

Many thanks in advance
Tomas

User avatar
Greenious
Hardware Guru
Hardware Guru
Posts: 1462
Joined: Sat Apr 24, 2004 5:39 pm
Location: Sweden

Re: DIY Fpu Unit for STFM - possible?

Post by Greenious »

68882PP2.gif
https://www.nxp.com/docs/en/package-inf ... 882PP.html

You can also find it in the datasheets for the FPU over at dev-docs.
You do not have the required permissions to view the files attached to this post.
Updated my guides as of june 28th, 2016. Check'em out and feedback!
http://www.atari-forum.com/viewtopic.php?t=5040

tcat
Obsessive compulsive Atari behavior
Obsessive compulsive Atari behavior
Posts: 145
Joined: Fri May 03, 2013 6:00 am

Re: DIY Fpu Unit for STFM - possible?

Post by tcat »

Hi Greenious,

Thank you, here is the component symbol, I created in `KiCad', clockwise rotatated, and some pins slashed. When tied to PLCC68 `socket' footprint, then I hope Pin1 FPU will match Socket Pin1, Pin2 - Pin2, ..., 68 - 68.
mc6881-symbol.png
PLCC68-socket.png
Many thanks
Tomas
You do not have the required permissions to view the files attached to this post.

Post Reply

Return to “Hardware”