386 Too Much Horsepower? Try A 186, In An FPGA!

Typically when we hear the term “System-on-Chip” bandied around, our mind jumps straight to modern ARM-based processors that drive smartphones and embedded devices around us. Coming a little bit more out of left field is [Jamie]’s 80186 core, that runs on Intel FPGAs.

[Jamie] ran the core through a few vintage PC benchmarks.
[Jamie] has implemented the entire set of 80186 instructions in Verilog, and included some of the undocumented instructions too. This sort of attention to detail is important – real world parts don’t always meet the original specifications on paper, and programmers can come to rely on this. The key to compatibility is understanding how things perform in the real world, not just on the spec sheet.

Not content to simply simulate a CPU, all the necessary peripherals for a complete working system have been worked into the design as well. There’s RAM, a UART, as well as CGA graphics and a PS/2 controller that is necessary if you’d like to actually use any sort of human input device.

[Jamie] has released the code under a GPL licence, and it’s available at GitHub. It’s a good basis if you want to play around with what was once a commercial CPU at a logic level. The development guide is also available if you need to really drill down into the details. It’s a cool project, and makes a great contrast to [Jamie]’s previous work – the Oldland 32-bit core.

 

 

45 thoughts on “386 Too Much Horsepower? Try A 186, In An FPGA!

  1. “[Jamie] has implemented the entire set of 80186 instructions in Verilog, and included some of the undocumented instructions too.”

    Good way to see what happens when one intentionally breaks something.

  2. I was under the assumption that the XT was a 8086, then the next line of microcomputer processors was the 80286.
    I thought that the 80186 line was used in Ford EECv3 ECU’s in mid and late 80’s consumer fuel objected vehicles.

    1. The 80186 saw very limited use in PCs. AFAIK no common DOS software used any of the extra features of the 80186, it was used just like an 8086.

      The 80286 brought support for extended memory, which soon ended hardware expanded memory. EMS became emulated as part of XMS. The 80286 had “protected mode” that could handle more RAM and do other things, but Microsoft operating systems never used it because the CPU could not drop back to real/standard mode without a hard reset. IBM designed the PC/AT to be able to hard reset the CPU without rebooting the rest of the computer, but Microsoft chose to not take advantage of that ability. (Did any OS?)

      If there had been a 208 protected mode version of Windows, it would have required all device drivers to support it. Likely would not have been able to rely on DOS drivers loaded during boot, unless DOS itself was modified to kick immediately into protected mode and drivers for things like CD-ROMs, mice, and soundcards would have had to be written for that mode. Then to be able to run an old style DOS program would have required suspending the Windows environment to a file, restarting the CPU and booting DOS, while retaining the RAM contents – if that was required to pick up where Windows left off when the DOS program would be ended. Would be far easier to have written an XP style OS from scratch for 286 protected mode, switch to that mode first thing then stay in it until shutting down.

      Microsoft probably could have done that, but with all the DOS software still in use and supported, and new DOS software still being produced after 1995, the OS would’ve faced a big battle for acceptance. Would’ve had to dual boot between it and plain old DOS instead of running Windows 3.x on top of DOS and being able to launch DOS programs from Windows, then immediately pop back to Windows when exiting the DOS program. (Nevermind that a lot of people did dual boot DOS and Windows 9x, a 286 protected mode Windows would’ve brought that in a few years sooner.)

      Surprising that I’ve not heard of anyone writing a 286 protected mode OS. Seems like it’d be just the thing for someone to do, just because it’s possible and unexplored programming ground.

      1. OS/2 1.x worked in 286 protected mode, and took advantage of the ability to return from protected to real mode implemented by IBM. It was used for the DOS compatibility mode (which worked great until the DOS program tried to have direct access to the hardware, because the 286 lacks a virtual86 mode like the one available in the 386, so the main kernel won’t be able to detect modifications in the hardware state made by the DOS program).

        Also, it seems that there were versions of windows 2.x that were able to take advantage from the 286 protected mode https://en.wikipedia.org/wiki/Windows_2.1x

    2. The intent of the 80186 was for embedded use, certainly not for “IBM PC” clones.

      But there were some. Radio Shack had a laptop, and maybe a desktop. Slicer was a mall company, they made single board 8088 boards (you had to put it in a case), and thy had an 80186 board. There were others, generally exotic.

      The problem was that the on board peripherals were in the wrong place. So an ‘IBM PC” clone needed the serial port at this location and the DMA controller at tat location, etc. But the 80186 had them at other locations.

      That was fine so long as everything went through the BIOS (which was the point, the BIOS allowed different hardware without needing to adapt MS-DOS). But things hadn’t ben around for long because the BIOS was bypassed, because directly controlling hardware was faster. That’s when “IBM compatible” meant the hardware had to be the same, too, and the exotic computers that sometimes had better features fell by the wayside.

      I seem to recall that one of the NEC microprocessors, something like the NEC-20 or -30 included the few extra 80186 instructions, but nine f the peripheral hardware.

      Michael

      1. If anybody want to look it up the name is NEC V20 and V30. They were 8088 and 8086 socket compatible but faster at the same clock frequency – not much but it made a real difference for some software. They weren’t 100% 8086 compatible though as they implemented the documented instruction set so e.g. the SALC instruction that was undocumented from 1978 to 1995(!) wasn’t included.

        1. The V20 and V30 actually had the 188 and 186 instructions as well as their own. They were faster for at least 2 reasons. They used a hard-wired multiplier and gave the BIU its own ALU so the BIU could do its own address calculations without needing to use the ALU in the execution unit.

          The V33A took things further by not multiplexing the data and address lines. I’d like to see someone maybe do a V20 on an FPGA and then modify it to be a “V23A,” (ie., a V33A clone retrofitted for 8088 compatibility) and maybe adding a few 286 instructions. Then I’d like to see them try putting that in an IBM 5160 or very similar clone (that uses discrete glue logic and not the large Faraday IC) by removing a couple of chips and running cables from the FPGA board. That would remove multiplexing and allow the board to be clocked faster (though you might need to use faster versions of the DMA, PIC, and PIT chips). Then to boost performance even more, I’d try to use BRAM as the main memory and remove all the DRAM and DRAM cards.

          As a final way of boosting a 5160, I’d rewrite the ROM. If your homemade “V23A” runs some instructions faster (ie., not cycle accurate), it is possible the machine won’t post. So if that is an issue, you’d either need to rewrite the ROM to allow for faster instructions, or add some logic to the FPGA to artificially slow instructions down until the first NMI assertion (ie., the end of POST). While working with a disassembled BIOS, you could then optimize it, remove unnecessary NOPs, and correct the visual artifacts bug. Original IBMs would often display some snow if a V20 or other non-8088 were used. That is due to a malformed loop for syncing with V-Blank. And you could rewrite the Int 10h handler to be more efficient.

          So all in all, you’d be adding instructions, adding an adder to the BIU, removing multiplexing, integrating the memory into the FPGA, maybe overclocking the board and removing DRAM refresh (if using BRAM or SRAM), and rewriting the ROM to be more efficient and stable.

    3. A notable computer with a 80186 was the Philips :YES. MS-DOS compatible, and it did use the features of the 80186 chip. However, even being MS-DOS compatible, it was NOT IBM-PC compatible. I.e. software that relied on the actual PC hardware (many games) did not work.

      A clever group of people actually made an extension card that made the :YES almost 100% IBM-PC compatible. Also adding an 8-Bit ISA bus, allowing to add a Hercules or CGA card.

    4. The 80186 was the embedded CPU from the era when you didn’t mind putting 20 extra chips on a PCB to get code into a CPU and signals back out before there were any of the heavy lifting micro-controllers of today like RISC/ARM/AVR.

      1. LGPL, which allows linking, would be more suitable than GPL for an FPGA core.

        I have released IP under BSD-type licenses, but that might be considered too permissive for some.

          1. I love the GPL, but [Allan H] is right, the GPL without modification is not a good choice for FPGAs. Synthesizers automatically pull in all sorts of closed vendor libraries like clock buffers, block rams, IO pin modules, etc. into the final design. Given that GPL3 says “‘Object code’ means any non-source form of a work.”, my decidedly non lawyer-y opinion is that it’s generally impossible to have a GPL compliant FPGA bitstream even if everything you provide is open-source. The non-optional presence of FPGA vendor components violate the license.

      2. Sorry, I may have misinterpreted your comment. If you meant actual software, such as the BIOS code that this project seems to have, then GPL is suitable. If, OTOH, you meant the synthesisable Verilog source code, it’s not software, and GPL is not suitable.

  3. When/after downloading quartus the build script aborts:

    The command ‘/bin/sh -c cd /tmp && wget -q $MIRROR$QUARTUS && wget -q $MIRROR$QUARTUS_UPDATE && chmod +x $QUARTUS_UPDATE && for DEV_FILE in $DEVICE_FILES; do wget -q $MIRROR$DEV_FILE; done && chmod +x $QUARTUS && ./$QUARTUS –mode unattended –installdir /opt/altera/ && rm /tmp/* /opt/altera/uninstall -rf’ returned a non-zero code: 8

    :(

    tried twice :)

    Maybe there is a quartus project I can open from the IDE…

        1. how do I add a new target ? I duplicated the de0-cv, configured it as a max10, re-run the cmake but I don’t seem to find any synthesis files. Any hints on how to do something like this are greatly appreciated !

  4. the only time maybe that a system is too much power is for google’s image captchas.

    my experience: i was having problems solving nicehash implementation of the image captcha it would keep giving me more and more challenges and even try again the sound clip did not work because it thought i had a bot going.

    so i launched quicktime player 2 to record the screen and started recording the screen.

    bingo i was able to solve the captcha.

    why i wanted to record the screen was to show the folks of nicehash that there was a problem with their overzealous schizoidally paranoid security.

    it looks like since quicktime’s poor efficiency in handling video meant that the recorder bogged down the cpu to the poing that the captcha was able to solve.

    so maybe you could run a cpu bogging process or it maybe possible to underclock by switching out the oscillator crystal or dont use the turbo mode

  5. Can I just say, that this is an impressive project, but the documentation is what makes this really shine.

    I have seen hundreds of projects lined to blogs and videos that basically result in the eventual:
    “I made a thing, so here is a photo and a paragraph and some files with code in them.”

    To make a project, then properly document it, and then host it out properly and not on some obscure free domain service so other people can access it for longer than a year is really amazing and is almost becoming rare.

Leave a Reply to RetepVCancel reply

Please be kind and respectful to help make the comments section excellent. (Comment Policy)

This site uses Akismet to reduce spam. Learn how your comment data is processed.