Show HN: I made a little digital circuit simulator that operates on PNGs (github.com)
This is a little toy project of mine that lets you simulate digital logic graphs. It was inspired by Minecraft's Redstone and the Piet esolang.
It's got some serious drawbacks-- you write circuits as PNGs and simulate them with a Python interface. It's slow to run and slow to experiment with. And it is certainly difficult to use for people with any kind of color blindness. But despite that, I hope this can still be a fun toy!
53 comments
[ 5.5 ms ] story [ 120 ms ] threadI'm sure you're aware, but here's some other related works I'm a fan of.
https://esolangs.org/wiki/Turing_Paint
https://esolangs.org/wiki/Piet
https://esolangs.org/wiki/Drawfuck
https://charperbonaroo.github.io/bls/#0
Also, is this the same as the 2015 'bitmap logic simulator'? I found this while reworking reso awhile back: https://realhet.wordpress.com/2015/09/02/bitmap-logic-simula...
I’m rewriting it to Unity and there I can run the 8 bit cpu from that blog with about 14000 ticks per second.
We’re planning to create a game around it with few dozen of levels, including controlling robots, traffic lights, a bowling pin sorter and tanks/units in a tiny top-down shooter (where programs from players play against each other).
Edit: if you download the cpu image from the blog and upload it to the game, you can see it run. It’s visually a bit broken because the game in its current state isn’t really designed to have such a big canvas, but it runs perfectly fine.
Edit 2: the CPU running in unity web build here: https://charperbonaroo.github.io/microengineer-build/
An idea I had (but never finished) was to let Reso interface with GPIO pins (say, on a Raspberry Pi) so people could interface their virtual circuits with their real circuits. I think that'd be really cool (if that is possible with Unity)
Interfacing with real hardware is a neat idea, I wonder what people would do with it
FWIW, I can't figure what to do on the "ride the line" level. I don't understand what the motors do exactly (powering both motors simultaneously makes the car go sideways) and what the sensors are sensing.
That logo however is the most repulsive piece of artwork I've seen in a long time.
(I am sorry for being blunt)
It shows the four basic logic gates, a one-bit adder, and simple digital clocks. I'll add these to the git repo in a bit!
There's lots of interesting circuit simulators on the web now, but has anyone ever seen a toy/simple simulator for VLSI devices? Something where you could draw in metal/poly/whatever layers to create and simulate transistors?
[0]: https://store.steampowered.com/app/693700/Prime_Mover/
[1]: Scare quotes because these things are ultimately games, not realistic simulations. Not that there's anything wrong with that.
[2]: https://github.com/brejc8/ComPressure (FOSS!), https://store.steampowered.com/app/1528120/ComPressure/
If someone made that, I assume it'd use some computer vision to identify the individual components and the connections between them. After that, each component would need to have their individual simulator. (Unless x-rays can see individual semiconductors?)
In the summer of 2009, working from a single 6502, we exposed the silicon die, photographed its surface at high resolution and also photographed its substrate. Using these two highly detailed aligned photographs, we created vector polygon models of each of the chip's physical components - about 20,000 of them in total for the 6502. These components form circuits in a few simple ways according to how they contact each other, so by intersecting our polygons, we were able to create a complete digital model and transistor-level simulation of the chip.
This model is very accurate and can run classic 6502 programs, including Atari games. By rendering our polygons with colors corresponding to their 'high' or 'low' logic state, we can show, visually, exactly how the chip operates: how it reads data and instructions from memory, how its registers and internal busses operate, and how toggling a single input pin (the 'clock') on and off drives the entire chip to step through a program and get things done.
http://www.visual6502.org/
Thanks for building this, contributing to the "marketplace of ideas", and inspiring others.
Isn't this the crux of the NSO Group exploit on Iphones?
(Also, how did you get a post with both text and a link? I didn’t know it was possible.)
Re submission: The submit box says "title and link or text". Must be an inclusive OR, because it gave me no problems.
(I also have JavaScript disabled, so if they block it client side, I haven't noticed.)
It's by a friend who initiatally built a digital circuit simulator and then turned it into a GitHub like collaborative website.
Wired-Logic uses a GIF as output.
Interesting take on making AND and XOR gates, makes it a bit more colorful.
I haven't looked at the source, but I bet it's massively parallel, at the pixel level? (I do see you say it's "not a cellular automaton", though...)
If so, I wonder how difficult it would be to port this to GPU, either writing CUDA yourself, or maybe even using PyTorch.
If PyTorch, you might be able to make it differentiable (by changing ANDs to MULs and such). What would be achieved by making the simulation differentiable I don't know. But surely you'd come up with something interesting. Given how much effort has gone into developing architectures whose gradients don't explode, my guess is you'd run into difficulties, but maybe you could even learn programs that model various sequences.
The main point would just be to run it on the GPU, though.
Regarding differentiation, the logic gates could look like a differential equation. Between iterations, input nodes amass a binary vector from adjacent wires, and pass them onto adjacent output nodes. So, mapping {0,1}^n --> {0, 1}, you could write them all in terms of some periodic function. (E.g. xor implemented with sin, or implemented with a sigmoid made from a quarter of a sin, etc.)
Either way, yeah! There is plenty of room to speed this up