# prabinpanta0/digital-logic-circuits-fundamentals architecture

> Architecture diagram of the GitHub repository prabinpanta0/digital-logic-circuits-fundamentals, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-07-15). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/prabinpanta0/digital-logic-circuits-fundamentals
- Repository: https://github.com/prabinpanta0/digital-logic-circuits-fundamentals

## Overview

##### Project type and purpose
- This is a modular Lua‐based simulation library for fundamental digital logic circuits and arithmetic operations.
- Its primary goal is educational: to demonstrate how basic gates compose into adders, multipliers, and subtractors.

##### File structure
- Top-level files:
- gates_2inputs.lua – basic 2-input gate implementations (AND, OR, NOT, XOR)
- gates_3inputs.lua – extended 3-input gates
- half_adder.lua, full_adder.lua – elementary adders
- multi-bit_adder.lua, multi-bit_multiplier.lua, multi-bit_sub.lua – composite multi-bit arithmetic modules
- No frontend/backend split—this is a library of modules.
- No deployment or build scripts—each file runs under Lua.

##### README insights
- Confirms the layering: basic gates → half/full adder → multi-bit circuits.
- Emphasizes modularity, truth-table validation, and reusability.
- Outlines future components, indicating an extensibility pattern.

##### Main components & dependencies
a. Base Layer:
- Basic Gates Module (gates_2inputs.lua)
- Extended Gates Module (gates_3inputs.lua)
b. Adder Layer:
- Half Adder (half_adder.lua) → depends on 2-input gates
- Full Adder (full_adder.lua) → depends on half_adder + gates_2inputs
c. Multi-bit Arithmetic Layer:
- Multi-bit Adder (multi-bit_adder.lua) → chains full adders
- Multi-bit Multiplier (multi-bit_multiplier.lua) → uses multi-bit adder + shift-and-add logic
- Multi-bit Subtractor (multi-bit_sub.lua) → two’s complement + multi-bit adder

##### Relationships & interactions
- Data/Control Flow: input bit arrays feed into base gates → adder circuits → multi-bit arithmetic modules.

##### Architectural patterns & principles
- Layered architecture: foundational gates at bottom, composite circuits above.
- Modular design: each file exposes a Lua table/module for reuse.
- Single-responsibility: each file focuses on one circuit type.

##### Technologies & environment
- Lua runtime (no external frameworks)
- Modules communicate via returned tables of functions

- Clear rectangles labeled with file names and module roles

##### Final advice
- Be exhaustive: represent each .lua module as a distinct component.
- Modular reuse: show how gates feed into adders and adders into multi-bit circuits.
- A title (“Digital Logic Simulation Library Architecture”) and a brief caption to clarify purpose.

## Diagram (Mermaid)

```mermaid
flowchart TD
    README["README.md"]:::external

    subgraph "Multi-bit Arithmetic Layer"
        MB_Adder["multi-bit_adder.lua"]:::purple
        MB_Multiplier["multi-bit_multiplier.lua"]:::purple
        MB_Subtractor["multi-bit_sub.lua"]:::purple
    end

    subgraph "Adder Layer"
        HalfAdder["half_adder.lua"]:::blue
        FullAdder["full_adder.lua"]:::blue
    end

    subgraph "Base Gate Layer"
        Gates2["gates_2inputs.lua"]:::green
        Gates3["gates_3inputs.lua"]:::green
    end

    README --> Gates2
    README --> Gates3
    Gates2 --> HalfAdder
    Gates2 --> FullAdder
    Gates3 --> FullAdder
    HalfAdder --> FullAdder
    FullAdder --> MB_Adder
    MB_Adder --> MB_Multiplier
    MB_Adder --> MB_Subtractor

    subgraph "Legend"
        LegendBase["Base Gate Modules"]:::green
        LegendAdder["Adder Circuits"]:::blue
        LegendComposite["Multi-bit Arithmetic"]:::purple
    end

    click Gates2 "https://github.com/prabinpanta0/digital-logic-circuits-fundamentals/blob/main/gates_2inputs.lua"
    click Gates3 "https://github.com/prabinpanta0/digital-logic-circuits-fundamentals/blob/main/gates_3inputs.lua"
    click HalfAdder "https://github.com/prabinpanta0/digital-logic-circuits-fundamentals/blob/main/half_adder.lua"
    click FullAdder "https://github.com/prabinpanta0/digital-logic-circuits-fundamentals/blob/main/full_adder.lua"
    click MB_Adder "https://github.com/prabinpanta0/digital-logic-circuits-fundamentals/blob/main/multi-bit_adder.lua"
    click MB_Multiplier "https://github.com/prabinpanta0/digital-logic-circuits-fundamentals/blob/main/multi-bit_multiplier.lua"
    click MB_Subtractor "https://github.com/prabinpanta0/digital-logic-circuits-fundamentals/blob/main/multi-bit_sub.lua"
    click README "https://github.com/prabinpanta0/digital-logic-circuits-fundamentals/blob/main/README.md"

    classDef green fill:#ccffcc,stroke:#333,stroke-width:1px
    classDef blue fill:#cce5ff,stroke:#333,stroke-width:1px
    classDef purple fill:#e5ccff,stroke:#333,stroke-width:1px
    classDef external fill:#f5f5f5,stroke:#333,stroke-dasharray:5 5,stroke-width:1px
```
