Logic Code
Project LinkLogic Code is a text-based logic circuit language I created from my fascination with digital electronics during my EEE days. Inspired by tools like Logisim but wanting something more scalable than visual diagrams, I built Logic Code using Nearley.js and Moo.js. It lets you write circuits as text, create reusable modules, and connect signals like wires — making it easier to build and manage complex logic systems through clean, structured code.
- NodeJS
- Nearley.js
- Moo.js
- C++
- Logic Circuit
- Simulation
The Story Behind Logic Code
Coming from an Electrical & Electronics Engineering background, I’ve always been fascinated by how simple logic gates, when combined thoughtfully, can perform incredibly complex computations. During my college days, one of the tools that shaped this curiosity was Logisim by Dr. Carl Burch — an amazing visual logic circuit simulator that allowed students to build circuits by dragging and dropping gates and wires.
But as I continued exploring digital design, I began feeling the limitations of visual tools. While great for experimentation, they become difficult to scale. Managing large circuits, reusing components, or building modular designs becomes cumbersome when everything is drawn manually.
I always wondered:
“What if logic circuits could be written?” Not in a traditional programming language, but in a simple, expressive, text-based format
a place where circuits behave like code, modules behave like functions, and connections behave like variable assignments.
This idea stayed with me for years. Eventually, I decided to turn it into a real tool — and that’s how Logic Code was born.
What is Logic Code?
Logic Code is a text-based logic circuit language that allows you to define circuits exactly the way you think about them — using clean, simple, readable code.
Instead of dragging gates onto a canvas, you write logic, define modules, wire connections, reuse components, and build complex circuits using a textual representation.
It combines the clarity of code with the conceptual purity of digital logic.
A few examples of what you can do:
- Define gates as text
- Connect signals like wires
- Create reusable modules (like full adders, ALUs, encoders, decoders, etc.)
- Build complex logic systems in an organized, version-controlled, scalable way
This opens up possibilities that visual tools struggle with — structure, reuse, organization, maintainability, and collaboration.
Technical Foundation
Logic Code is powered by:
- Nearley.js — a powerful parsing toolkit
- Moo.js — a tokenizer for building clean, structured syntax
- A custom-designed grammar for defining logic circuits
- A fully modular interpreter that evaluates your textual circuit definitions
- A simple, expressive syntax inspired by the concepts of signals, wires, and modules
This makes Logic Code:
- Easy to parse
- Easy to extend
- Easy to integrate into other tools
- Capable of simulating logic in a structured, scalable way
Why Text-Based Logic?
Visual tools are amazing for beginners, but when circuits grow:
- Reusability becomes difficult
- Diagrams get cluttered
- Sharing or collaborating is hard
- Version controlling a visual circuit file is chaotic
- Debugging larger modules becomes messy
Logic Code solves these by treating circuits like code:
- You can import and reuse modules
- You can manage everything in text files
- You can version control entire circuits using Git
- You can scale to very large designs
- You can automate testing and simulation
It’s logic design reimagined for modern workflows.
Impact
Logic Code brings a new approach to learning and building logic circuits. It bridges the gap between educational circuit tools and modern code-driven design methodologies.
Students, hobbyists, and digital design learners can:
- Understand logic better
- Visualize circuits in a structured way
- Build complex systems without visual clutter
- Explore low-level design concepts in a code-like environment
It’s especially helpful for anyone who loves both coding and digital electronics.
Documentation
Full documentation, syntax examples, and tutorials can be found here: