
Inside the die of Intel's 8087 coprocessor chip, root of modern floating point - ingve
http://www.righto.com/2018/08/inside-die-of-intels-8087-coprocessor.html
======
kens
I plan to write more about the 8087. Are there any topics that you (HN
readers) would be most interested in?

~~~
tropo
Explain why they wasted effort and silicon on insanity:

The 80-bit format has an explicit 1, unlike the normal IEEE float and double.

The chip has BCD support.

There was that idea that the OS would emulate an infinite FP stack via an
exception handler.

There was that idea that the OS would emulate more exponent bits via an
exception handler messing with the exponents.

The exceptions for imprecise results seem so useless.

We got an 80-bit format, but no 16-bit or 128-bit format. Don't we like powers
of two?

~~~
kens
Many of your questions are discussed in detail in "The 8087 Primer" [1] but
I'll give a quick summary. (I'm not defending their design decisions, just
providing what I've read.)

> The 80-bit format has an explicit 1, unlike the normal IEEE float and
> double.

Apparently the explicit 1 made the hardware much simpler, and with 80 bits it
doesn't cost you much to have an explicit 1.

(To explain for others: in the normal float format, the first bit of the
mantissa is assumed to be a 1, so this bit is not explicitly stored. This
gains you a "free" bit of precision. But then you needs special handling for
zero and denormalized numbers because the first bit isn't a 1. The 8087 stores
numbers internally using the 80 bit format for increased accuracy. The 80 bit
format stores the first bit explicitly, whether it is a 0 or 1.)

> The chip has BCD support.

BCD was a big thing in the 1970s; look at all the effort in the 6502 for BCD
support, for instance. My hypothesis is that cheap memory killed off the
benefit of packing two digits in a byte.

> We got an 80-bit format, but no 16-bit or 128-bit format.

They did a lot of mathematical analysis to decide that 80 bits for the
internal number format would result in accurate 64 bit results. Something
about losing lots of bits of accuracy during exponentiation, so you want extra
bits the size of the exponent.

> Don't we like powers of two?

Looking at old computers has shown me that word sizes that are powers of two
are really just a custom, not a necessity. In the olden days, if your missile
needed 19 bits of accuracy to hit its target, you'd build a computer with 19
bit words. And if your instruction set fit in 11 bits, you'd use 11 bit
instructions. Using bytes and larger powers of two for words became popular
after Stretch and the IBM 360, but other sizes work just fine.

[1]
[https://archive.org/details/8087primer00palm](https://archive.org/details/8087primer00palm)

~~~
simonbyrne
> They did a lot of mathematical analysis to decide that 80 bits for the
> internal number format would result in accurate 64 bit results. Something
> about losing lots of bits of accuracy during exponentiation, so you want
> extra bits the size of the exponent.

I'm not sure if it was the reason, but 80-bit intermediate values lets you
compute pow(x,y) as exp(y*log(x)) to full precision for the full range of
64-bit floats.

~~~
caf
This is likely a big part of it, as the OP has indicated elsethread that a
table of log constants are used by the 8087 for calculating logarithms and
exponentiations.

------
breakbread
Can anyone recommend a good article or video (preferably video) that gets into
how CPUs work at a somewhat fundamental level? Ideally geared towards someone
who's generally familiar with computing concepts and not a total layman.

~~~
ghaff
I haven't personally gotten around to taking it, but there's a Computer
Architecture MOOC from MIT on edX.

[https://www.edx.org/course/computation-
structures-2-computer...](https://www.edx.org/course/computation-
structures-2-computer-mitx-6-004-2x)

~~~
Dylan16807
So that's part two of the 6.004 course. I'd highly recommend part one also, at
least lectures 3 onward.

The course starts with making analog transistors and tweaking them into
handling digital data. Then making gates and combining them into state
machines and ALUs and slowly putting together the pieces of a full CPU.

The last third is adding caches, pipelining, virtual memory, multiprocessing,
etc. It's useful too.

------
bogomipz
I so seldom think at this level I had a couple questions about the following
passage that I'm hoping someone could answer:

>"The transistor can be viewed as a switch, allowing current to flow between
two diffusion regions called the source and drain. The transistor is
controlled by the gate, made of a special type of silicon called polysilicon.
A high signal voltage on the gate lets current flow between the source and
drain, while a low signal voltage blocks current flow."

If current flows from the source to the drain, is the source terminal
hardwired to the power rail and always receiving some nominal voltage? Also
does the voltage applied to the gate in order to turn the switch on come from
the drain of a neighboring transistor? Basically wired in a series?

I always see MOSFET transistors depicted in isolation and then the
conventional logic gate shapes used when depicting specific circuits like
adder, mux etc. I find it tough to visualize how the gate, source and drain
terminals in transistors as they are depicted in this picture physically
interconnect to form the logic gate. Is there a separate metal layer for each
of source, gate, drain and ground?

~~~
kens
On a chip, there's really no difference between the source and drain. The
source/drain can be connected to ground, another transistor or power as
needed.

Look at the diagram of an inverter in the article, and it should make it
clearer how gates are constructed. A NOR gate is similar to the inverter, but
with two input transistors in parallel, so either one can pull the output low.
A NAND gate has two input transistors in series, so they must both be on to
pull the output low.

There's a single metal layer in the 8087 (but many metal layers in modern
chips). The transistor can be wired however works best for the layout, with
polysilicon or metal. If a transistor's source is connected to a neighboring
drain, the silicon regions can just be merged and no wiring is needed.

~~~
bogomipz
Thanks for pointing that diagram out, I should have spent more time staring at
it. Indeed it makes the gate construction clearer. Cheers.

------
appspark
Thanks for the great article. And I found a ton of other interesting stuff
that will keep me reading for some time.

------
forkandwait
Has a similar, very cool, reverse engineering analysis been done with
peripheral heavy microcontrollers?

------
mewse-hn
Didn't they just release the 8086?

~~~
kens
I thought you were just being random, but it turns out that Intel recently
released the "Core i7-8086K processor" in honor of the 40th anniversary of the
8086 processor. Is that what you're referring to?

~~~
mewse-hn
Yeah, I was joking but I think someone thought I was legitimately confused and
downmodded me

~~~
Dylan16807
They might not have thought it was funny enough.

------
skookumchuck
It's too bad that 80 bit precision has been abandoned.

~~~
eigenloss
We have quad-floats (128-bit) now which seem to work alright.

~~~
eigenloss
...except in Rust, frustratingly.

------
mchahn
I've read that the main reason the 8087 was produced was to standardize the
floating point algorithms. Software in those days had notorious FP algorithm
problems. I'll try to find a reference for that.

------
bitL
Wasn't Intel 8087 based on AMD 9511? I always thought Intel was responsible
for x86 and AMD for x87 and x64.

~~~
kens
Intel licensed the Am9511 as the Intel 8231. The 8087 was a new design
developed by Intel.

~~~
bitL
Ah OK, I vaguely remembered x87 as the reason for why Intel was willing to
license x86 to AMD and it seems like it was in fact about 8087 predecessor
that Intel licensed from AMD...

