1. 19

  2. 3

    Obviously the author is having a ton of fun, so it’s all good, but I was trying to think what was needed at the core of it all.

    Since the package was about simulating analog and digital circuits what should be needed in principle is a simulation of the Arduino board itself, rather than a C++ interpreter.

    I wonder how much effort it would have been to write a Atmel AVR microcontroller emulator + arduino circuit board simulator. A proper emulator would then simply ingest the output of avr-gcc and execute it, feeding into the arduino board simulation, causing pins to change voltage etc etc.

    This approach would have the advantage that over time the author could then add hardware effects (like parasitic capacitance etc etc.) that is more in keeping with the actual goals of an analog/digital circuit emulator.

    Heck, he could then allow users to crack open the AVR itself and measure pin voltages of individual components and this would be awesome, because it would be like peeking into a working micro-controller in real time.

    1. 2

      Is there enough specification that you could make an AVR microcontroller emulator, and would it fall foul of Atmel’s user agreements? If so, that probably would have been a project of similar (maybe even less) complexity, though I suspect it would have been pretty tricky to convince Apple to allow for running avr-gcc on iDevices. JITs are a no-fly zone for iPad/iPhone applications, except for the JS VM used by WebKit, which is why an interpreter is used here. (I think C# gets through because it can be pre-compiled, but I honestly don’t know all the details)

      1. 1

        A quick search brings up a bunch, including one written in LaTeX, so I’m assuming that there is enough documentation to make a digital emulator, and there must be spec sheets for the hardware with capacitances, rise and fall times, high and low voltages and other electrical characteristics that would help someone make a physical simulation of the interface pins.

    2. 5

      Well that’s a weird trend. Two articles in two days about people writing half-assed C++ compilers. By these low standards, every graduating CS student at my university wrote a C++ compiler.

      Don’t get me wrong, I think they’re interesting projects, I just don’t think it’s correct to call them C++ when they’re missing almost all of the features.

      1. 5

        Walter Bright is the only person on this planet who can claim to have written a C++ compiler: https://www.digitalmars.com/