DIY Fpu Unit for STFM - possible?

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

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

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

DIY Fpu Unit for STFM - possible?

Postby tcat » Sat Jan 27, 2018 9:22 am

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

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

Re: DIY Fpu Unit for STFM - possible?

Postby frank.lukas » Sat Jan 27, 2018 9:24 am

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: 593
Joined: Tue May 24, 2016 6:47 pm

Re: DIY Fpu Unit for STFM - possible?

Postby czietz » Sat Jan 27, 2018 9:40 am

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: 593
Joined: Tue May 24, 2016 6:47 pm

Re: DIY Fpu Unit for STFM - possible?

Postby czietz » Sat Jan 27, 2018 9:47 am

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: 3877
Joined: Tue Oct 30, 2007 2:55 pm
Location: Florø, Norway
Contact:

Re: DIY Fpu Unit for STFM - possible?

Postby joska » Sat Jan 27, 2018 10:21 am

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

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

User avatar
Frank B
Atari Super Hero
Atari Super Hero
Posts: 959
Joined: Wed Jan 04, 2006 1:28 am
Location: Boston

Re: DIY Fpu Unit for STFM - possible?

Postby Frank B » Sat Jan 27, 2018 11:16 am

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: 106
Joined: Fri May 03, 2013 6:00 am

Re: DIY Fpu Unit for STFM - possible?

Postby tcat » Sat Jan 27, 2018 5:02 pm

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: 3877
Joined: Tue Oct 30, 2007 2:55 pm
Location: Florø, Norway
Contact:

Re: DIY Fpu Unit for STFM - possible?

Postby joska » Sat Jan 27, 2018 8:47 pm

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

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: 106
Joined: Fri May 03, 2013 6:00 am

Re: DIY Fpu Unit for STFM - possible?

Postby tcat » Sun Jan 28, 2018 6:49 pm

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: 1341
Joined: Mon Apr 30, 2012 6:20 pm
Location: Sweden

Re: DIY Fpu Unit for STFM - possible?

Postby troed » Sun Jan 28, 2018 8:09 pm

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: 106
Joined: Fri May 03, 2013 6:00 am

Re: DIY Fpu Unit for STFM - possible?

Postby tcat » Mon Jan 29, 2018 9:57 am

Hi,
@troed, thank you, will do.

Anyone having a datasheet on MC68881?
Many thanks
Tomas

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

Re: DIY Fpu Unit for STFM - possible?

Postby czietz » Mon Jan 29, 2018 10:59 am

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: 106
Joined: Fri May 03, 2013 6:00 am

Re: DIY Fpu Unit for STFM - possible?

Postby tcat » Mon Jan 29, 2018 5:20 pm

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 freak
Atari freak
Posts: 74
Joined: Sat Sep 03, 2016 12:20 am

Re: DIY Fpu Unit for STFM - possible?

Postby LuigiThirty » Mon Jan 29, 2018 5:43 pm

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: 106
Joined: Fri May 03, 2013 6:00 am

Re: DIY Fpu Unit for STFM - possible?

Postby tcat » Mon Jan 29, 2018 6:16 pm

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: 106
Joined: Fri May 03, 2013 6:00 am

Re: DIY Fpu Unit for STFM - possible?

Postby tcat » Mon Jan 29, 2018 6:56 pm

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 freak
Atari freak
Posts: 74
Joined: Sat Sep 03, 2016 12:20 am

Re: DIY Fpu Unit for STFM - possible?

Postby LuigiThirty » Mon Jan 29, 2018 7:39 pm

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: 106
Joined: Fri May 03, 2013 6:00 am

Re: DIY Fpu Unit for STFM - possible?

Postby tcat » Mon Jan 29, 2018 8:13 pm

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 freak
Atari freak
Posts: 74
Joined: Sat Sep 03, 2016 12:20 am

Re: DIY Fpu Unit for STFM - possible?

Postby LuigiThirty » Mon Jan 29, 2018 8:31 pm

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: 593
Joined: Tue May 24, 2016 6:47 pm

Re: DIY Fpu Unit for STFM - possible?

Postby czietz » Mon Jan 29, 2018 8:40 pm

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: 106
Joined: Fri May 03, 2013 6:00 am

Re: DIY Fpu Unit for STFM - possible?

Postby tcat » Tue Jan 30, 2018 7:40 am

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: 106
Joined: Fri May 03, 2013 6:00 am

Re: DIY Fpu Unit for STFM - possible?

Postby tcat » Tue Mar 06, 2018 8:40 pm

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


Social Media

     

Return to “Hardware”

Who is online

Users browsing this forum: Bing [Bot] and 3 guests