# Critique My Logic Circuit Simulator

Discussion in 'General Electronics Chat' started by Alrecenk, May 2, 2011.

1. ### Alrecenk Thread Starter New Member

May 2, 2011
3
0
I've made a program that interprets the pixels in an image as logic gates, which allows you to design logic circuits in paint and then tweak and run them in my program. I don't really know all that much about circuit design. My background is more in high level computer science. I got started with playing with redstone in Minecraft, but found it quite slow (to build with and to execute), so I started trying to make something similar, but faster and easier to use. I'm curious what people who actually know something about logic circuit design think of the set-up, and what should be added to make it more useful or usable or fun. Here's the link to the program:
http://www.alrecenk.com/games/CircuitEditor/

The basic idea is that each pixel is interpreted as one of 7 blocks (by color obviously), which can each be either on or off (also indicated by color). It saves/loads both the types and states of blocks as PNG, but it does a sort of circuit compilation when opened in the program so that it can tick at a few kilohertz. I could probably make it faster, but so far it's been sufficient. The blocks are as follows (copied from the read-me):

Black : does nothing
White : Wire, turns on if connected to an output which is on
Red : Not, turns on if not connected to a wire that is on

Cyan : And, turns on if all connecting wires are on, also useful as a diode to prevent signals from feeding backwards from on OR or other operation

Blue : Output, turns on if a neighboring operation block is on (NOT,AND, or MEMOUT)

Green : Wire crossing, passes signals between left and right separately from signals going up and down. Neighbor positions are calculated as the first non-green block in each of the four directions. .This means green blocks can be placed between the interactions of any other blocks.

Yellow: Memory Input, Turns on if any neighboring wires are on

Purple: Memory Output, If connected to an on wire then it's value is set to the OR of all connecting memory inputs. Otherwise it holds it's value from the previous tick. Memory output blocks can also be used as switches when not connected to a memory input block.

Below is the fanciest circuit I've been able to make so far. It cycles between 4 8x8 images, by reading from a set of 32 8-bit registers.

2. ### tom66 Senior Member

May 9, 2009
2,613
214
That looks sweet. What language is it written in? Also, have you looked at Conway's Game of Life? That circuit you have designed is similar to one in the GoL... I remember seeing one of those in Golly, a GoL simulator... amazing what it did. (I believe it counted in hexadecimal.)

3. ### Alrecenk Thread Starter New Member

May 2, 2011
3
0
It's written in java (as is indicated by it being a jar). In theory it should work on linux and mac, but I've only done testing on a windows machine. I've seen the game of life before, but I'd never seen Golly. It's Wireworld rules are definitely the most similar thing to what I'm working on I've seen so far. It's still quite a bit different though. My program sends signals along the full length of a wire in one tick, and also has a few more than the bare minimum of blocks necessary. So, it should be able to get quite a bit more done per tick, and be a bit easier to use(of course I'm going to think it's easier to use, I made it )

However, I can't help but be impressed by the ridiculous tick speed of Golly. Apparently it hashes larger patterns to allow it to perform multiple ticks simultaneously, with the number of ticks growing exponentially. There has to be a limit to how well that works, or you would be able to design a computer in Wire-world that could run faster than the computer it was running on. I'm curious how the speed of my program compares, but I won't be able to make any meaningful measurements until I can make comparable circuits in both with enough complexity to be worth measuring. I don't expect I'd win right now, but I've still got a couple of tricks left.

On a side note: Multiplication!

4. ### tom66 Senior Member

May 9, 2009
2,613
214
Golly is very fast, and it is impressive. It's also written in C, but that shouldn't make a major difference with a JIT. Good work, I'll try and get it running soon. (I'm using Ubuntu, and Java is installed, so it should be easy.)

5. ### Alrecenk Thread Starter New Member

May 2, 2011
3
0
Being written in C would only make a difference if it's using GPU acceleration, inlined assembly, or some such, and I didn't get the impression that was the case. I did encounter some issues with the mouse and text not lining up in other OS's, but I think I've largely resolved those problems. I also got it up to about 8khz just by rearranging the threads to take better advantage of multi-core systems. I've also studied how Hashlife works, and while I don't think it can be applied to my rule-set (what with the non-local interactions), there is a limit to how well it works. Particularly in regard to computations because they lack the higher level time redundancy that hash-life utilizes. My approach is totally different, but I think it's possible to make my program competitive with Golly, for simulating circuits anyways.