# harsha-vardhan-r/synthbite16 architecture

> Architecture diagram of the GitHub repository harsha-vardhan-r/synthbite16, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-04-05). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/harsha-vardhan-r/synthbite16
- Repository: https://github.com/harsha-vardhan-r/synthbite16

## Overview

##### Main Components
- Assembler (Compiler) Module – This is implemented in a single C++ source file (main.cpp) and built using CMake (see the Assembler directory and its CMakeLists.txt). Its job is to take an input assembly program and produce an output binary/ROM file.
- SynthBite16 Simulation – The hardware design is provided as a Logisim circuit file (SynthBite16.circ). The ROM produced by the assembler is loaded into this simulated computer.
- Documentation & Examples – Files like Docs.txt, LOOKUP.txt, and examples/ directory illustrate the instruction set, usage, and program examples to guide the user.
- Supporting & Build Infrastructure – This includes configuration files (in .vscode, .idea) and build directories for the CMake and ninja build systems.

##### Relationships and Flow
- User writes a program in the assembly language as per the instruction set detailed in Docs.txt.
- The Assembler processes the file and produces a binary output (RAM file) that follows the ROM/ROM.txt structure.
- This assembled binary is then loaded into the SynthBite16 Logisim circuit (SynthBite16.circ) to simulate the 16-bit computer.
- The simulation is executed in Logisim-evolution where the computer’s registers, clock settings (with the simulation recommended to start from a low clock value), stack operations, and instruction executions are observed.
- An optional feedback loop exists where the user can test, find bugs, and then modify the source assembly or even tweak the assembler code.

##### Architectural Patterns and Technologies
- Monolithic Assembler: The assembler is simple and self-contained (a single C++ file) but leverages CMake for building and can be extended if necessary.
- Hardware Simulation: The project uses Logisim-evolution as an external simulator. The .circ file captures the digital hardware design and maps exactly how the 38 instructions, addressing modes, and register stack operate.
- Clear Separation: There is a clear separation between the “software” side (writing and compiling programs) and the “hardware” simulation side (emulating the computer via a circuit file).

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Main Flow
    A("Assembly Source Code"):::source
    A --> AS_Main

    subgraph "Assembler Module (C++/CMake)"
        AS_Main("Assembler Module"):::assembler
        A_CMake("Build Config"):::assembler
        AS_Main -.-> A_CMake
    end

    AS_Main --> BR("Binary ROM/RAM File"):::binary
    BR --> SIM("SynthBite16 Simulation (Logisim .circ)"):::simulation

    %% Supporting Components
    subgraph "Documentation"
        DOC1("Docs.txt"):::doc
        DOC2("LOOKUP.txt"):::doc
        DOC1 --> DOC2
    end

    EX("Examples Directory"):::examples

    subgraph "Supporting Infrastructure"
        VSC("VS Code Config"):::infra
        CMB("CMake Build Directory"):::infra
        VSC --> CMB
    end

    %% Advisory / Support Relationships (dotted lines)
    A -.-> DOC1
    A -.-> EX
    AS_Main -.-> VSC

    %% Click Events
    click AS_Main "https://github.com/harsha-vardhan-r/synthbite16/blob/main/Assembler/main.cpp"
    click A_CMake "https://github.com/harsha-vardhan-r/synthbite16/blob/main/Assembler/CMakeLists.txt"
    click SIM "https://github.com/harsha-vardhan-r/synthbite16/blob/main/SynthBite16.circ"
    click DOC1 "https://github.com/harsha-vardhan-r/synthbite16/blob/main/Docs.txt"
    click DOC2 "https://github.com/harsha-vardhan-r/synthbite16/blob/main/LOOKUP.txt"
    click EX "https://github.com/harsha-vardhan-r/synthbite16/tree/main/examples/"
    click VSC "https://github.com/harsha-vardhan-r/synthbite16/blob/main/.vscode"
    click CMB "https://github.com/harsha-vardhan-r/synthbite16/tree/main/Assembler/cmake-build-debug"

    %% Styles
    classDef source fill:#ADD8E6,stroke:#333,stroke-width:2px;
    classDef assembler fill:#90EE90,stroke:#333,stroke-width:2px;
    classDef binary fill:#FFB6C1,stroke:#333,stroke-width:2px;
    classDef simulation fill:#AFEEEE,stroke:#333,stroke-width:2px;
    classDef doc fill:#FFDAB9,stroke:#333,stroke-width:2px;
    classDef examples fill:#E6E6FA,stroke:#333,stroke-width:2px;
    classDef infra fill:#F0E68C,stroke:#333,stroke-width:2px;
```
