6 ms·
Conditions in the Intel 8087 floating-point chip's microcode
- kens 9mo agoAuthor here if anyone has questions...
- farseer 9mo agoIs there 8087 IP available in verilog etc?
- kens 9mo agoAs far as I know, you can't get the 8087 itself as an IP block. You can get generic IEEE-754 floating-point as an IP block, e.g. from AMD: https://www.amd.com/en/products/adaptive-socs-and-fpgas/intellectual-property/floating_pt.html https://www.amd.com/en/products/adaptive-socs-and-fpgas/inte...
- pwdisswordfishy 9mo agoIPv6 has seriously gone too far.
- hnthrowaway0315 9mo agoHi kens, thanks for the knowledge sharing all these years. Can you please confirm this one? From Wikipedia, it says that 8087 uses CORDIC algorithm. Does that mean that it's the same (but different speed) as what I'd implement the functions in software, except in microcode (which has more granularity than usual assembly code)? I found it a bit surprising that as a 45-year old chip, there is no public information of its microcode. I guess hardware is indeed much more secret than software.
- kens 9mo agoYes, the 8087 uses CORDIC. I extracted the constants from the 8087's internal constant ROM and they are arctangent and log values for the CORDIC algorithm. You can implement the same functions in software, which is what floating-point emulation libraries did back then. There's almost no public information on the 8087 microcode, but I'm working on that :-)
- hnthrowaway0315 9mo agoThanks Ken, appreciate the work!
- dapperdrake 9mo agoThank you for the deep dive.
- mschaef 9mo agoThank you. As always.
- dboreham 9mo agoUntil I read this I did not know that 1970s microprocessors had register renaming. Feel a little cheated, thinking for all those years that they were actually moving the bits.
- peterfirefly 9mo agoHow do you think the EXX and EX AF,AF' instructions work on the Z80?
- avadodin 9mo agoAnd EX DE, HL
- WalterBright 9mo agoE to the u, du dx, E to the x, dx!
- avadodin 9mo agoI must admit I do not know what you are referencing here, sir, but it is always a pleasure to run into your comments on HN. So much positive compiler-dad energy.
- WalterBright 9mo agoIt's the MIT song! At least it used to be, it was a long time ago. > always a pleasure to run into your comments on HN. Wow what a nice compliment! Makes my day!
- kens 9mo agoIf you feel cheated now, wait until you find out that the ALU in the 8-bit Z80 was just 4 bits. :-)
- mschaef 9mo ago
- 0xsn3k 9mo agosuper cool! i wonder how difficult it would be to recreate the entire chip at logic gate level in, say, VHDL or Verilog
- kens 9mo agoIt would be difficult, but not impossible. The main problem is tracing out all the circuitry, which is very time-consuming and error-prone. Trust me on this :-) The second problem is that converting the circuitry to Verilog is straightforward, but converting it to usable Verilog is considerably more difficult. If you model the circuit at the transistor level in Verilog, you won't be able to do much with the model. You want a higher-level model, which requires converting the transistors into gates, registers, and so forth. Most of this is easy, but some conversions require a lot of thought. The next issue is that you would probably want to use the Verilog in an FPGA. A lot of the 8087's circuitry isn't a good match for an FPGA. The 8087 uses a lot of dynamic logic and pass transistors. Things happen on both clock edges, so it will take some work to map it onto edge-trigger flip-flops. Moreover, a key part of the 8087 is the 64-bit shifter, built from bidirectional pass transistors, which would need to be redesigned, probably with a bunch of logic gates. The result is that you'd end up more-or-less reimplementing the 8087 rather than simply translating it to Verilog.
- 0xsn3k 9mo agoah, i see, thanks for the insight! do you have any advice on how one might get started with IC reverse-engineering? i think it would be interesting to reimplement these chips in a way that's at least inspired by the original design
- kens 9mo agoHow to get started reverse engineering? That's a big topic for a HN comment, but in brief... Either get a metallurgical microscope and start opening up chips, or look at chip photos from a site like Zeptobars. Then start tracing out simple chips and see how transistors are constructed, and then learn how larger circuits are built up. This works well for chips from the 1970s, but due to Moore's Law, it gets exponentially more difficult for newer chips. I also have a video from Hackaday Supercon on reverse engineering chips: https://www.youtube.com/watch?v=TKi1xX7KKOI https://www.youtube.com/watch?v=TKi1xX7KKOI
- WalterBright 9mo agoI've always thought the 8087 was a marvelous bit of engineering. I never understood why it didn't get much respect in the software business. For example, when Microsoft was making Win64, I caught wind that they were not going to save the x87 state during a context switch, which would have made use of the x87 impractical with Win64. I got upset about that, and contacted Microsoft and convinced them to support it. But the deprecation of the x87 continued, as Microsoft C did not provide an 80 bit real type. Back in the late 80's, Zortech C/C++ was the first compiler to fully implement NaN in the C math library.
- Cold_Miserable 9mo agox87 should have been killed off. It would have forced lazy game developers to use SSE around the 2005 era.
- WalterBright 9mo agoGame floating point precision doesn't matter much - speed does. But if you're doing numerical analysis, it does matter.
- kstrauser 9mo agoI’d agree that the engineering was brilliant (but 68882 gang represent!). Its ISA was so un-x86-like, though, as it was basically an RPN calculator. X86 had devs manipulating registers. X87 had them pushing operands and running ops that implicitly popped them and pushed the result back on the stack. That’s not better or worse, just different. However, I can imagine devs of the days saying hey, uh, Intel, can we do math the same way we do everything else? (Which TBH is how you’d end up with an opcode for a hardware-accelerated bubble sort or something, because Intel sure does love them some baroque ISAs.)
- WalterBright 9mo agoEh, as far as compiler backends go, the RPN stack was worse. I thought the X86_64 instruction set was a giant kludge-fest, so I was looking forward to implement the AArch64 code generator. Turns out it is just as kludgy, but at right angles. For example, all the wacky ways of simply loading a constant into a register!