Z80 Space-Time Productions Single Board Computer
Technical Support Information

AMD's Am9511 Arithmetic Processor


Although I can't really confirm, I suspect this was the first ever "Math Coprocessor". It is really a micro-processor within itself, having a set of opcodes, registers and internal micro-code rom that allows this chip to mathematically manipulate bytes of data within it's memory, which is organized as machine stacks. Data coming from the outside world is "pushed" into the processor and each successive byte pushes the former down one notch. Once the command is issued to the command register, the results can be "popped" off the stack back to the requesting device, generally the board's CPU.

This chip can handle math in 3 main formations:

  • 16-bit wide signed integers.
  • 32-bit wide signed integers.
  • 32-bit floating point number representations.

In 16-bit signed integer mode, numbers from -32768 thru +32767 can be used. For operations not requiring larger values, these execute the fastest.

For numbers which are still integers yet require larger values, a 32-bit wide signed integer can process values from -2,147,483,648 to +2,147,483,647. This is referred to as "double precision". Execution times for these format math problems take longer to execute than 16-bit, but are significantly faster and carry more accuracy in digits than their floating point equivalents. Because of the number of bits, integers with exacting accuracy can be used.

32-bit floating point values are handled on a vastly different format. 4 bytes of information are used, the MSB is the Exponent of the number. D7 contains the sign of the Mantissa or last 3 bytes, and D6 contains the sign of the Exponent. Therefore, exponents can have the value of -64 to +63. The Mantissa is "normalized" so that it becomes a value from 0.5 (or 0.0 depending on the processor) to 1.0.

The Mantissa is then multiplied by 2 raised to the exponent to create working value. However all the internal math is done with the numbers in this format.

What exactly is a floating point number?
Well, they can be anything basically, your normal use numbers:
10.95
4
200,021
3.14159
4 x 10-6
0.003
2100.59, and so on.

More on it's usage:
Avogadro's number is 602,250,000,000,000,000,000,000. In scientific notation, this would be represented as +6.0225 x 1023. In normalized mode, this would be 0.60225 x 1024, where the Mantissa is now between 0.5 and 1.0 in value.

The value for π or Pi as it's called is an infinitely cycling decimal value which starts with 3.141592654 and continues indefinitely. This value can be represented in floating point notation. However, it is important to note here that with 4 bytes of information, 3 for the Mantissa digits following the decimal lose accuracy as they simply can't all be represented in such a small place. The Am9511 contains its own representation of π internally for operations.

How exactly does this work? The mantissa is normalized, that is the resulting binary value is rotated so the top-most bit of the mantissa is "1". Each time the value has to be rotated to the left, the exponent is decremented so that that value remains correct.

In the case of the Am9511, the top-most bit of the mantissa has the value 0.5, the next bit is half of that, or 0.25. The next bit 0.125, next is 0.0625 and so forth. For every "1" in the mantissa you add that value.

For example the floating point number 10.000 would render as $04 $A0 $00 $00.
The exponent byte holds +4. The mantissa is $A0, or 1010 0000.
Using the values 0.5 + 0.125 you get 0.625. 2 raised to the 4th power is 16.
16 times 0.625 = 10.
This is how floating point numbers are stored in the Am9511.


List of Commands

16-bit Integer (Fixed Point)

  • SSUB - Subtract (Int16)
  • SADD - Add (Int16)
  • SDIV - Divide (Int16)
  • SMUL - Multiply Lower (Int16)
  • SMUU - Multiply Upper (Int16)
  • CHSS - Sign Change (Int16)

32-bit Integer (Fixed Point)

  • CHSD - Sign Change (Int32)
  • DADD - Add (Int32)
  • DSUB - Subtract (Int32)
  • DMUL - Multiply Lower (Int32)
  • DMUU - Multiply Upper (Int32)
  • DDIV - Divide (Int32)

32-bit Floating Point Operations

  • FADD - ADD (Float 32)
  • FSUB - Subtract (Float 32)
  • FMUL - Multiply (Float 32)
  • FDIV - Divide (Float 32)
  • CHSF - Sign Change (Float 32)
  • SQRT - Square Root (Float 32)
  • SIN - Sine (Float 32)
  • COS - Cosine (Float 32)
  • TAN - Tangent (Float 32)
  • ACOS - Inverse Cosine (Float 32)
  • ASIN - Inverse Sine (Float 32)
  • ATAN - Inverse Tangent (Float 32)
  • PWR - Compute XY
  • EXP - Exponent ex (Float 32)
  • LOG - Logarithm (Float 32)
  • LN - Natural Logarithm (Float 32)

Conversion Operations, Push, Pop and Exchanges

  • FIXD - Convert (Float 32) to (Int32)
  • FIXS - Convert (Float 32) to (Int16)
  • FLTD - Convert (Int32) to (Float 32)
  • FLTS - Convert (Int16) to (Float 32)
  • PTOS - Push 16-bit TOS onto stack
  • POPS - Pop 16-bit stack
  • PTOD - Push 32-bit TOS onto stack
  • PTOF - Push 32-bit TOS onto stack (same as PTOD)
  • POPD - Pop 32-bit stack
  • POPF - Pop 32-bit stack (same as POPD)
  • PUPI - Push 32-bit FP π PI onto TOS
  • NOP - No OPeration
  • XCHD - Exchange 32-bit TOS and NOS
  • XCHF - Exchange 32-bit TOS and NOS (same as XCHD)
  • XCHS - Exchange 16-bit TOS and NOS


PDF Documentation for the Am9511

AMD 9511 Datasheet [PDF format] [598kBytes].

AMD Am9511 Floating Point Manual [PDF Format] [4.31MBytes].
This contains FP information for the Am9511 and Am9512, also some 8080 assembly and BASIC code for use with the IC.

AMD 9511 Algorithm Details Manual [PDF Format] [1.63MBytes].


Simple Test Program

Here's the 9511 TEST PROGRAM from the MCB2 manual (see Documentation page) This loads the Am9511 with 2 each 16-bit operands and commands a 16-bit multiply operation, then retrieves the results. This uses the Monitor program to interact.

9511 TEST PROGRAM

THIS PROGRAM USES THE CDL/TDL/STP MONITOR TO TEST THE 9511 HIGH SPEED ARITHMETIC CHIP.

O AND I ARE MONITOR INPUT AND OUTPUT COMMANDS.

CR IS A "RETURN" KEYSTROKE

O7C,03 CR (LSB) ; LOAD FIRST BYTE OF FIRST 16 BIT WORD
O7C,00 CR (MSB) ; SECOND BYTE OF FIRST WORD
07C,02 CR (LSB) ; LOAD FIRST BYTE OF SECOND WORD
07C,00 CR (MSB) ; SECOND BYTE OF SECOND WORD
07D,6E CR       ; MULTIPLY AND SAVE LOW ORDER RESULTS
I7C CR 00 (MSB) ; THE MSB OF THE RESULT
I7C CR 06 (LSB) ; THE LSB OF THE RESULT

Notes: I tried this out on my board with the Am9511, it works as advertised - a simple arithmetic test. It does the job of verifying the basic functionality of the chip with your MCB. By changing the command byte issued to port $7D, you can also try a 16-bit addition, subtraction, and division.


Software Downloads:

MATHPAK1.ASM - This is a 2,336 byte program that occupies a 4K rom from $2000-$2FFF in IC-23 on the Space-Time Productions MCB.
MathPak1 contains a set of jump vectors at the start of the rom which provides conversions between ASCII scientific notation, large integer and hexadecimal number formats and the Am9511 4-byte {32-bit} format, both to and from. These are followed by several utility routines that compare floating point and integer numbers, and a routine to format the numbers. These are followed by vectors to the common math functions.

Notes:

Each vector JPs to a routine, and each has required parameters which should be set in the registers prior to entry. You must set the proper registers prior to entry, or you'll get unexpected results.

There are hardware-specific parameters at the start of the ASM file. These are set for this Z80 MCB, and will have to be changed to conform to your hardware configuration.

Additionally, the locations used conform to BASIC2 for this board so machine calls can be made from BASIC to the Am9511 for calculations.

There is a demo program which will run simple calculations on Floating Point numbers, internally using calls to the routines of MathPak1.

I make no claims to fame regarding MathPak1. It borrows heavily from the 1978 DAI Computer's conversion and mathematics eproms, I have substituted Z80-specific commands where possible, created hardware-specific pre-processor commands to interact with the Am9511 on my platform, and altered a ton of stuff to make it as portable to other Z80 systems as possible. This makes MathPak a derivative work of the DAI Computer, and it is offered only as an experimental package for the hobbyist and not for product development.

AM9511.ASM - This is a storefront program I created for the Am9511, offering a set of subroutines to carry 16-bit integer, 32-bit integer, and 32-bit floating point numbers in 2-byte and 4-byte format in and out of the Am9511. There are no ASCII conversion routines included, however it does offer the 16-bit math portion not incorporated in the DAI Computer, which assigned all integers as 32-bit.

What about BASIC using the Am9511?
Good question. I've looked over the math portion of Nascom's Z80 BASIC in some detail. While it seems quite possible to recode BASIC (once again) and use function calls to the Am9511 for its math functions, there are some signficant hurdles for me. BASIC utilizes the same FPREG registers to process both INT and FP numbers, and uses certain bits within the Exponent byte to indicate the difference between them, and it doesn't conform to Am9511 4-byte formats. Also, the order in which parameters are sent to the Am9511 is critical, especially in FP division, log(x), exp(x), and so forth. Making a smooth interchange of information between BASIC and the MathPak would be a tricky task for my not-so-great level of programming expertise.

I want to take a moment to acknowledge the programming prowess of David Collier and his amazing 8080 coding on the DAI Computer. Reading the PDF files of the source code is quite impressive.


Space-Time Productions Am9511 Hardware

Implementation of the Am9511 Arithmetic Processor on the Space-Time Productions MCB is done using I/O mapping and /PAUSE -> /WAIT timing and control. Address line AB0 is tied to the Control/Data input so that I/O address $7C connects the Z80 databus to the Am9511 Data Register, $7D connects the Z80 databus to the Am9511 Command Register. The /PAUSE signal which is output from the Am9511 is tied to the Z80's /WAIT input pin so that when the Am9511 is processing an instruction, the Z80 goes into a "hold" mode where the last instruction is ended, and the processor doesn't execute the next program step until the /WAIT signal is released.

While there are disadvantages to this design, it uncomplicates the usage by allowing the Z80 code to function quite transparently to the Am9511. Once the Z80 writes the Command Word into the Am9511, the /PAUSE signal causes the Z80 to /WAIT and then when released, the Z80 simply reads the results of the function or calculation back in. Although wait times of only a few clock cycles, all the way up thru a full 1.3 millisecond (depending on the gravity of the calculation involved), the Z80 code simply sees it as feeding the arguments into the Am9511, commanding the calculation take place, then "immediately" reading the results back. In actuality, the Z80 has coasted while the Am9511 performed the calculation, but it allows linear programming to be used.

While there are other hardware methods to connect the Am9511, they complicate the code in that a calculation is requested, but the processor must have some pre-determined tasks it can handle without the results of that calculation while it waits for the outcome. I've not seen example code for this method, but I can imagine it might be somewhat arduous. The end-of-calculation pin could be monitored by an input port of a p8255, but the Z80 would have to continue on with its program without the needed work of the Am9511. This is probably one of the earliest forms of parallel processing, but it leaves the programmer entirely responsible for the tasks at hand while waiting.

This chip tends to run rather warm when compared to the other ICs on the MCB board, especially so when the board is being overclocked. It has a +12 Volt input pin as well as a +5 Volt input pin. Measure your power supplies carefully, as a few tenths of a volt over will cause the chip to heat up to the point where it can burn to the touch. Yes, I did do this. I dialed in the +12 and +5 to as accurate as I could get them by measuring the delivered voltage at the chip(s). The Am9511 still runs warm, but not hot enough to harm anyone. I'm thinking the addition of some heat sink paste and a sizeable sink might be in order to get the chip to last a long time. These chips at this writing vary but run around $85-$120 USD.


Pinout of the Am9511 with Signal Directions


Excerpt from Space-Time Schematic showing MCB connections


That's all I have at the moment, be sure to send your comments and questions via email on the contact section of my site. Thanks!


Copyright © 2004 -

Other information credited to its sources.
This site is not affiliated with any mentioned businesses, people or organizations.
The sole purpose is to provide interesting technical information, and is not intended to infringe anyone's copyrights nor to derive funds that would otherwise be their property.