LOGICSIM - A new Graphical Logic Circuit Simulator

222 views
Skip to first unread message

Patrick Jackson

unread,
Jan 19, 2025, 1:20:35 AM1/19/25
to Altair-Duino
I was going to wait a bit before sharing this, but I'm just so excited! I JUST transferred control over to the SIO2 board so you can launch this over terminal but use the built in keyboard on the geoff terminal to control things. If you want everything local, its a simple as changing the base port in the initialization function for my Geoffterm library!

Here's a pic:


It looks way better without the terrible night glow XD

Right now it doesn't simulate :(, but I'm working on that tonight and tomorrow, and then after having all control (text output is split between the built in display and the serial terminal), and the simulation down, and a couple qol addons like scaling the canvas, I think it will be good enough to release to the public!

You can add and remove devices, right now you have signals (in and out), and gates, or gates. More gates just mean a few more lines of code. I'm going to add an xor gate after this to make a half adder!

You can shift through the devices with '<' and '>', you can move each one around and scale each one individually. The text on the screen really helps to determine which devices are which, but I want to make a scrolling list in case the user adds a ton of devices.

Wires you see are "airwires", they are direct connections between devices and are actually each a struct that you can add ( haven't come up with a good way of selecting them for deletion) that is the actual connection between each device.

Obviously this is quite a proof of concept, but I really want this to be a thing!
I also jumpered the terminal to run at 115200, the drawing is faster than the default 9600 but its still slow XD

Build size right now is around 18.7kb using aztec C, I forsee this shrinking a bit when I remove all of printf/sprintf with my own.
Any ideas for shrinking things and making things more optimized for size/speed are always welcome!

geofterm.zip
logicsim.zip

Flavio Villanustre

unread,
Jan 19, 2025, 2:10:38 AM1/19/25
to Patrick Jackson, Altair-Duino
Amazing work! I may be stating the obvious here, but you really only need AND and Inverter gates to implement any circuit (an OR gate is just an AND gate with inverted inputs and output, for example). You could just implement these two and keep the size smaller, at the expense of more complexity on the circuits (less abstraction to the user).

Alternatively, you could represent everything as truth tables (any logic circuit is isomorphic to a -possibly very large- truth table), if this makes the code more compact (this is how FPGAs are programmed).

But I really like your graphical display, there! What terminal emulator are you using? Is that a Tek?

Thanks,

Flavio



--
You received this message because you are subscribed to the Google Groups "Altair-Duino" group.
To unsubscribe from this group and stop receiving emails from it, send an email to altair-duino...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/altair-duino/172beb8e-ac12-4e26-82a3-8d60d082f982n%40googlegroups.com.

Patrick Jackson

unread,
Jan 19, 2025, 2:40:13 AM1/19/25
to Altair-Duino
Oh no, no Tek, I really really want one though! I'm using the built-in Geoff terminal https://geoffg.net/terminal.html. The altairduino comes with a more modern design with usb instead of ps2, and I think a few extra jumpers for color and such.
I know many of the users here have foregone the builtin terminal for other more powerful and capable boards, a guy here has one that can display full color bitmaps and has a full color BBS software for it!

Setting up the circuit as a truth table - that's an idea! I had an idea where you could set up the devices and connect them up completely via text and then hit something like Ctrl-R to render the screen in one go.

I'll see what I can do! Currently fighting my _scanf function, it works the first time you use it and then gives absolute garbage after XD

Flavio Villanustre

unread,
Jan 19, 2025, 4:24:53 AM1/19/25
to Patrick Jackson, Altair-Duino
Ah, yes, I have one of those little standalone vt52/ANSI terminals and use it on green too (I played with the color jumpers but couldn't get a convincing and readable amber to work, so green is good enough). 

I'd like to try your code when you release it. It would be very cool to have circuit simulation on an Altair!

Flavio

Message has been deleted

Patrick Jackson

unread,
Jan 21, 2025, 11:37:28 PM1/21/25
to Altair-Duino
JUST figured out that atof wasn't working because I need to do:

extern double atof()

but for some reason, atoi worked just fine!

On Sunday, January 19, 2025 at 12:47:29 PM UTC-5 John Galt wrote:
very nice.

:-)

Patrick Jackson

unread,
Jan 22, 2025, 8:17:09 AM1/22/25
to Altair-Duino

Patrick Jackson

unread,
Jan 23, 2025, 1:05:33 AM1/23/25
to Altair-Duino
I got it working with multiple gates! Just need to clean up the user process and add a couple other QoL improvements and then I think I can put the code on github with a clean conscience!

Patrick Jackson

unread,
Jan 24, 2025, 12:57:30 AM1/24/25
to Altair-Duino

Flavio Villanustre

unread,
Jan 24, 2025, 1:51:10 AM1/24/25
to Patrick Jackson, Altair-Duino
Patrick, this is very impressive! I will try it in the morning building a little 4 bit adder or something simple like that. 

BTW, I looked at the GitHub repo and didn't see an option to export the circuit. Is that possible in the current version? And if it is, is it also possible to import a saved circuit?

Flavio

Patrick Jackson

unread,
Jan 24, 2025, 8:34:18 AM1/24/25
to Altair-Duino
Ah yes, the final piece of the puzzle! No, you can't save/load yet, but I'll start working on that tonight!

Flavio Villanustre

unread,
Jan 24, 2025, 8:41:13 AM1/24/25
to Patrick Jackson, Altair-Duino
Well, you could save every action and then replay it, but there would be a lot of noise as you move the gates around. Saving breadcrumbs to reconstruct state in this manner is equivalent to a "zipper" in functional programming. Of course, it's better if you capture the position and connection of all gates and just save the final state :)

Flavio

Patrick Jackson

unread,
Jan 24, 2025, 9:42:44 AM1/24/25
to Altair-Duino
Yeah, I think I'll just save the Device and Cnxtion arrays and then that's really all you need.

It would be really interesting if I could export natively to the Falstad applet... XD
This totally wasn't the inspiration for the project!

Patrick Jackson

unread,
Mar 11, 2025, 12:46:53 AM3/11/25
to Altair-Duino
There's a new version!
This one, I am changing it to a vi-like command system so that you don't have to wait for the entire thing to redraw after adding/removing something.
I am keeping the old version, because once I am able to flash the Geoff terminal with the graphical patch, I'll edit THAT one to support erasing/redrawing individual elements so we can have 2 separate but functionally equal versions; one with the patch support and one without.
Saving/loading, while not existent as of writing this (I'll pop it back in, custom filenames included), will be 100% compatible between the versions.
Here's a couple pictures demonstrating the new system:

20250311_002607.jpg20250311_002615.jpg
A breakdown:
MD: Change Mode to Device. [C]nxtion and [V]ideo exist
I: Insert new Device. Default type is still Signal.
EX20EY40: Switch to submode Edit and change the X and Y coordinates of the selected Device. Default Device is last one Inserted. Remember, default XY is still 100/100
I: Insert new Device
ETa: Edit selected Device and change its [T]ype to [a]nd. The chars to denote Devices are still the same as the old version.
EX70EY10: Edit selected Device's X/Y coordinates. Remember, selected by default is the most recently Inserted Device
MC: Change Mode to [C]nxtion
I0:2:1 - Insert new Cnxtion ( we are now in Cnxtion mode ) and attach it to source Device 0, target Device 2, and port 1 on target Device
I1:2:2 - Same as before but just attach it to the next Signal
R: Rerender the screen

Not shown is 'Q' to quit, and 'S100' to Select Device or Cnxtion 100

I'm adding the 'X' to delete selected Device or Cnxtion, and then I want to do something like a 'sfilename' to save the circuit and 'ofilename' to open a circuit.
This would possibly also enable me to edit existing Cnxtions easier(?) because I could render the sidebar as Device lists in Device mode and Cnxtions in Cnxtion mode. I'd love to figure out a simple scrolling system for the sidebar for when you have more Devices/Cnxtions than you have vertical screen space!

Patrick Jackson

unread,
Mar 11, 2025, 1:18:20 AM3/11/25
to Altair-Duino
The new binary is up on git under the vi branch, as well as its source code.
I seem to be having some problems with the code...I'm getting wild bugs where if I do a string of Devices, hit Enter, then a string of Cnxtions, then enter, I get wild problems like Devices changing locations, types getting corrupted, etc
Reply all
Reply to author
Forward
0 new messages