Hacker News new | ask | show | jobs
by Unical-A 55 days ago
Chip Builder is a brilliant concept for teaching low-level logic. How did you handle the gate simulations? Is it a custom engine or are you using something like a logic circuit library under the hood?
1 comments

Thanks a lot!

I have created my own engine for testing the simulations in TypeScript. There is no external logic circuit library under the hood.

The simulation itself is tick-based with a light event-driven flavor. Each tick I compute an evaluation order using a topological sort of the circuit graph (based on wire connections). Then I iterate through components in that order, gathering inputs from connected wires. Each component runs an evaluate() function, producing outputs and a nextState. Outputs propagate through wires immediately within the same tick.