Gate-level emulation of an Intel 4004 in 4004 bytes of C

(nicholas.carlini.com)

54 points | by mad a day ago ago

7 comments

  • kazinator 20 hours ago ago

    A cool fact about the 4004 is that the Busicom calculator project it was used in actually used the 4004 to interpret a more capable virtual machine, in whose machine code the calculator app was actually written. Intel did not quite build a general-purpose processor in whose instruction set the application was written directly.

  • vrighter 13 hours ago ago

    As soon as you changed any gate layouts, it stopped being a gate level emulation of a 4004.

    It's just a 4004 emulator (with extra steps). The gate level simulation is of a different device that emulates a 4004.

    To be fair, the whole program is amazing as a logic simulator implementation, I'm just nitpicking.

  • rep_lodsb 19 hours ago ago

    I hate to be this critical, but this is not emulating the actual 4004.

    It's a logic circuit simulator that takes in a compressed representation of something and runs it, with an I/O mechanism that emulates the Busicom calculator hardware (keyboard and printer).

    Still impressive for the size of the code, but the "CPU" is nothing like a 4004, or any real microprocessor.

  • dmitrygr a day ago ago

    This is beautiful.

    • hyperhello a day ago ago

      This is beyond spaghetti code.

      • 0points 14 hours ago ago

        Why don't you take a moment to understand what you just commented on, maybe you will learn something today.