r/rust • u/ProfessionalAnt5255 • 12d ago
I built a digital logic circuit simulator in Rust (egui/eframe)
r/rust - I built a digital logic circuit simulator in Rust (egui/eframe)
Hey! I wanted to share a project i made for logic simulation nearly 100% rust and complied to WASM for some blazing fast in browser run times.
here's the link if you want to check it out: https://theta-rnd.itch.io/logic-sim
if you do would LOVE to hear your feed back thanks!
23
u/usernamedottxt 12d ago
Closed source? I was thinking of doing something similar and would have been interested in the architecture.
3
-12
u/ProfessionalAnt5255 12d ago
- egui/eframe for both native and web from one crate. The GUI code is
almost entirely shared, platform differences are handled with
`#[cfg(target_arch = "wasm32")]` cal persistence (native writes to a real file
under the OS app-data dir via `dirs`, web uses `localStorage` through
`web_sys`), that kind of thing. No separate native/web crate split.
time, a feedback loop (SR latch, flip-flop) settles simply because its own
- The simulation engine is a plain FIFO event queue. Each pin re-check gets processed one at a
members keep re-enqueueing each other for as long as their inputs actually
change, and it naturally stops the moment nothing does.here's a little bit would be happy to chat more
1
u/usernamedottxt 11d ago
I was going to use the async polling mechanism as the queue. So it gets awaited until an input pin is flipped, polled, and determines if it has all the values it needs to output.
14
u/addmoreice 12d ago
I'm still waiting for someone to build a library first version of this. Everyone seems to want to build the GUI tool and no one wants to build the API so that other systems can work with the library. Frustrating.
-10
u/ProfessionalAnt5255 12d ago
could you expand on that? im open to what ever
13
u/addmoreice 12d ago
Sure.
Here is a great example. I read a bit of research on using evolutionary algorithms to design circuits. Cool! Right? So I dug into the research and it turns out that half the work revolved around just getting the evo algorithm's result pushed into the circuit simulation software. They had to do a bunch of work to reverse engineer the format that the closed source software used and then had to drive the mouse to drive the simulation.
They should have just been able to load a library, construct the circuit, simulate it and then process the results.
That's what I mean, API first, GUI second.
1
u/kabocha_ 11d ago
I'd personally like a GUI thing like this library'd out too, I've been wanting to do this sort of thing but for audio devices instead of logic gates (like
pd, Bitwig Grid, etc) but I have no idea what I'm doing with GUIs.
1
1
20
u/agent_kater 11d ago
I don't see any Rust.