9 ms·
Inside the die of Intel's 8087 coprocessor chip, root of modern floating point
- kens 8y agoI plan to write more about the 8087. Are there any topics that you (HN readers) would be most interested in?
- valarauca1 8y agoGreat article. If you could over the 8008 and 4004 that'd be awesome :D
- kens 8y agoI've taken die photos of the 8008 and written some articles about it: http://www.righto.com/search/label/8008 http://www.righto.com/search/label/8008 There's a bunch of stuff on the 4004 at 4004.com
- teh_klev 8y agoAnything really, it's always good stuff :)
- simonbyrne 8y agoI'd be keen to know more about how the transcendental instructions worked.
- kens 8y agoI plan to write about that, but the short answer is that the 8087 computes transcendental functions using CORDIC. The chip contains constants atan(2^0), ..., atan(2^-15). It operates a bit at a time using these constants to compute tan and arctan. It doesn't natively support sine and cosine, but these can be computed from the tangent. Likewise, the constants log2(1+2^(-2)), ..., log2(1+2^(-15)) are used for logarithm and exponentiation. https://en.wikipedia.org/wiki/CORDIC https://en.wikipedia.org/wiki/CORDIC Edit: the constant ROM is the vertical stripe in the lower left in the die photo. You can see each bit in the ROM as a green or purple rectangle: https://lh3.googleusercontent.com/-7S_Q0bzu-7A/W3RDsZwprvI/AAAAAAABTmQ/mUZVqFspfJEzvXyFJdQtA1AOBdKcCFDJACHMYBhgL/w9999/stripped.jpg https://lh3.googleusercontent.com/-7S_Q0bzu-7A/W3RDsZwprvI/A...
- deleted 8y ago[deleted]
- cmroanirgo 8y ago> It doesn't natively support sine and cosine, but these can be computed from the tangent. I'd not ever looked into it, but that neatly explains the existence of the sincos instruction.
- bonzini 8y agosincos is useful in general. Rotations for example often need sine and cosine of the same angle. Because transcendental functions are implemented as a microcode loop, a sincos instruction lets you cut in half the loop overhead. If the overhead were 50% (e.g. 100 cycles arithmetic and 50 cycles overhead) you could cut sincos to 250 cycles, for an overhead of only 25%.
- userbinator 8y agoCORDIC is itself a very interesting algorithm due to its conceptual simplicity: a vector rotation using successive approximations. When stripped down to its essentials, it forms the basis of a surprisingly simple circle-drawing algorithm: https://nbickford.wordpress.com/2011/04/03/the-minsky-circle-algorithm/ https://nbickford.wordpress.com/2011/04/03/the-minsky-circle... (Previously also discussed here at https://news.ycombinator.com/item?id=15266331 https://news.ycombinator.com/item?id=15266331 )
- dabockster 8y agoWhat kind of chiller you have to use to cool it. EDIT: Oh, I'm thinking of the new 8086k. Never mind.
- tropo 8y agoExplain 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?
- simonbyrne 8y agoI recall seeing a comment by Will Kahan that 80-bit bit was intended as an intermediate step: the intention was to eventually go to 128-bit. Also this was still early days: up until this point, fast floating point was the domain of much more expensive machines. No one had any idea what would be useful in consumer level hardware.
- kens 8y agoMany 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
- duskwuff 8y agoThe interaction between the 8087 and the host CPU. From what I understand, the way this works is kind of strange...
- dan_hawkins 8y agoThe basic idea was that FP instruction generated interrupt and set external bus to a specific state. If there was no HW FPU interrupt handler could emulate FPU in software. If there was FPU it would use CPU's dedicated signal to get activated and then read CPU bus to get details about opcode and parameters and execute it.
- pwg 8y agoI heard somewhere (long long ago, no references to point towards) that some portion of the 8087 used tri-valued logic (3 valued, as in base-3 numbers). If that was the case then an article geared towards that part of the chip design would be interesting.
- kens 8y agoI'm pretty sure there's no base-3 used in the 8087. On the other hand, multiplication is essentially base-4. It uses the standard shift-and-add cycle but multiplies by a pair of bits each step so it goes twice as fast. There are some clever tricks to make this work.
- userbinator 8y agoI think that commenter may have confused it with the 2-bit-per-cell ROM that it has: https://en.wikipedia.org/wiki/Multi-level_cell#Multi-level_cell https://en.wikipedia.org/wiki/Multi-level_cell#Multi-level_c... "For example the Intel 8087 used two-bits-per-cell technology, and in 1980 was one of the first devices on the market to use multi-level ROM cells.[9][10]" ...and indeed I thought this article would have a mention of it. Certainly interested in any more exploration you can do about that.
- pwg 8y agoThat is very likely what I was remembering. As I said, this was long ago (as in 30+ years ago) so I very well may have been remembering this multi-level ROM setup and mixing it up with three valued logic. I do concur that this would be an interesting topic for another post.
- kens 8y agoI read out the constants from the ROM earlier and it was just a normal ROM, so I was skeptical about your comment. But what do you know, I just took a closer look at the microcode ROM and there are indeed 4 different transistor sizes! I hadn't even noticed, so thanks for mentioning this. This will be annoying if I try to visually read out the microcode values since I'll need to examine each transistor closely. It was quick to read out the constant ROM since I just needed to glance to see if a transistor was present or not. Here's a photo of a 7x5 region of the microcode ROM to help the discussion. The transistors (representing bits) are where the vertical polysilicon lines cross the pinkish doped silicon. Note that the "neck" is full-width, narrowed, very narrow, or entirely gone (no transistor), corresponding to the 4 values. Image link: https://photos.app.goo.gl/pUsZSs3rx45Ry7U1A https://photos.app.goo.gl/pUsZSs3rx45Ry7U1A
- Severian 8y agoFWIW, your blog is amazing. I really like the links you provide in the footnotes for additional information.
- brandmeyer 8y agoThanks for doing this! What did they use microcode for in the 8087? How were the functional units on the die arranged? It looks like that column above and to the right of the "8087" logo could be a shifter. How many metal layers under the transistors are there for routing around the die?
- kens 8y agoI'm still figuring out the microcode. It looks like about 4K x 16 bits. The functional units are arranged with the 64-bit mantissa datapath at the bottom and the 16-bit exponent on top. The mantissa functional units have the constants at the left, then the bidirectional shifter, then the ALU, then a 2-bit and 1-bit shifter (for multiplication, etc), then three temporary registers, then register buffers and finally the 8 stack registers. The most significant bit is at the bottom. (Which is backwards to how it is stored with the most significant bit next to the exponent.) You are correct that above the 8087 logo (to the left and a fair bit to the right) is a shifter. Above is a 0-8 bit shifter and to the right is 0/8/16/.../64 bit shifter. Combined, they allow any bit shift. It's bidirectional (with buffers/drivers on both sides), so you put the bits through one way to shift left and the other way to shift right. (Shifting is a big part of floating point. For instance, to add or subtract, you need to shift the numbers so the decimal points line up. And then you need to shift the results to be normalized.) As far as layers: The bottom is silicon and doped silicon. The polysilicon for wiring / gates is above. On top is a single layer of metal. The metal and polysilicon are used for routing. Typically metal is mostly vertical and polysilicon is mostly horizontal or vice versa, but there are lots of exceptions. Metal is preferred for long routes (and power) because it has much lower resistance.
- brandmeyer 8y ago> [The shifter is] bidirectional (with buffers/drivers on both sides), so you put the bits through one way to shift left and the other way to shift right. Wait, really? I'm used to seeing mux circuits like the following, which incur a wee bit of gate delay per stage. http://www.vlsitechnology.org/html/cells/vsclib013/mxi2.html http://www.vlsitechnology.org/html/cells/vsclib013/mxi2.html http://www.vlsitechnology.org/html/cells/vsclib013/mxn2.html http://www.vlsitechnology.org/html/cells/vsclib013/mxn2.html
- substrateBias 8y agoI feel like there was a lot of heavy bias toward the substrate in this write-up. I was hoping for more detail on the sequence of events, as operations cascade through the transistor architecture, to resolve input values to a result. For example, if arithmetic operations are fairly objective, why is microcode needed in between the processor logic and the user-facing pinouts? Or is the microcode not adjustable firmware, but rather a fixed set of routing options to engage components appropriately for a given operation?
- kens 8y agoYes, this article was 100% focused on the substrate bias generator, since I wanted to start with a self-contained piece. I realize it's a bit of a strange focus, but hopefully it was interesting. As far as the microcode, I'm not sure I understand your question. The microcode is fixed firmware, stepping the 8087 through the procedure for complex operations such as logarithm. Essentially, the microcode has mini-programs that the 8087 runs to perform its functions. I'm still researching how the microcode is actually implemented.
- fapjacks 8y agoI'm interested in everything you write about. Thank you!
- appspark 8y agoThanks for the great article. And I found a ton of other interesting stuff that will keep me reading for some time.
- mewse-hn 8y agoDidn't they just release the 8086?
- kens 8y agoI 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 8y agoYeah, I was joking but I think someone thought I was legitimately confused and downmodded me
- Dylan16807 8y agoThey might not have thought it was funny enough.
- mianos 8y agoI wonder if the i7 8650 is a similar homage to the VAX?
- brian-armstrong 8y agoThe 8087 is like the 8086 but 1 MHz faster.
- bitL 8y agoWasn't Intel 8087 based on AMD 9511? I always thought Intel was responsible for x86 and AMD for x87 and x64.
- breakbread 8y agoCan 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.
- hinkley 8y agoMight want to look at some books used for entry level computer engineering classes? Computer Organization and Design by Hennessy and Patterson used to be a standard, if not the standard. The 4th edition is 7 years old now, but if an article about the 8087 caught your eye...
- jamesmcm 8y agoThe Nand2Tetris course covers the fundamentals of the Von Neumann architecture using an ALU (though programs are read from ROM). Modern chips are obviously far more complicated than that though.
- Koshkin 8y agohttp://visual6502.org/ http://visual6502.org/ https://www.youtube.com/results?search_query=how+cpu+works https://www.youtube.com/results?search_query=how+cpu+works https://en.wikipedia.org/wiki/Central_processing_unit#Structure_and_implementation https://en.wikipedia.org/wiki/Central_processing_unit#Struct...
- ghaff 8y agoI 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-mitx-6-004-2x https://www.edx.org/course/computation-structures-2-computer...
- Dylan16807 8y agoSo 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.
- forkandwait 8y agoHas a similar, very cool, reverse engineering analysis been done with peripheral heavy microcontrollers?
- deleted 8y ago[deleted]
- skookumchuck 8y agoIt's too bad that 80 bit precision has been abandoned.
- bogomipz 8y agoI 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?
- acqq 8y agoIt's all good known: https://www.allaboutcircuits.com/textbook/digital/chpt-3/cmos-gate-circuitry/ https://www.allaboutcircuits.com/textbook/digital/chpt-3/cmo...
- bogomipz 8y agoWhat a great resource! Thanks.
- kens 8y agoOn 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.
- mchahn 8y agoI'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.