# digital-eda/digital-ide architecture

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

- Interactive diagram: https://gitdiagram.com/digital-eda/digital-ide
- Repository: https://github.com/digital-eda/digital-ide

## Overview

##### Main Components
- VS Code Extension Interface: Represented by files in the “src” directory (e.g., src/extension.ts) and global configuration files.
- Netlist and Viewer Modules: Functions for netlist rendering and viewer integration, evident in “src/function/dide-netlist” and “resources/dide-viewer.”
- Simulation & Testing Components: Includes simulation setup and testbench handling under “src/function/sim.”
- Additional Utility Modules: Logging, global helpers, internationalization (i18n), and configuration management (config directory with various .json files).

##### Relationships & Interactions
- The VS Code extension acts as the “front door” by interfacing with the VS Code API.
- When a user opens an HDL file, the extension routes the file to the Language Service, which in turn uses the Rust parser modules to provide smart diagnostics, auto-completion, and linting (see src/function/lsp).
- The documentation module listens for certain types of comments or code annotations in HDL files, triggering the generation of interactive documentation (with support from resources/dide-doc assets).
- For simulation tasks, the simulation component (src/function/sim) gathers file and project info via the file system modules and then interfaces with external tools (Vivado, ModelSim, Icarus Verilog as mentioned in the README) via configurable linter and simulation layers.
- The netlist renderer and waveform (VCD) renderer manage visualization tasks, leveraging both front-end assets (CSS, images, resources) and back-end logic from the corresponding src function folders.
- Global managers (src/manager) help coordinate tasks like project configuration, third-party tool integration, and structured file parsing.

##### Architectural Patterns and Design Principles
- Modular Design: The system is clearly organized into function-specific modules (documentation, netlist, simulation, LSP, tree view, etc.) promoting separation of concerns.
- Plugin Architecture: Since this is a VS Code extension, it extends the editor’s functionality through defined extension endpoints (commands, status bar items, file watchers).
- Client-Server Interactions for LSP: The language service is implemented as a separate process or module that interacts with the extension layer, following the Language Server Protocol design paradigm.
- Use of External Resources: There is significant usage of external resource files (CSS, images, static VHDL libraries) that support the UI/UX of the plugin’s output.

##### Relevant Technologies, Frameworks, or Libraries
- VS Code Extension API: Underlying the entire system, allowing integration with the editor.
- TypeScript & JavaScript: For the bulk of the extension’s logic (located in src/).
- Rust Parser for HDL: Although files indicate TypeScript, the README mentions a rewritten parser in Rust that promises better performance.
- CSS/HTML/JS Assets for Renderers: For documentation, netlist, and waveform renderers.
- Build & Test Infrastructure: Configuration files like package.json, webpack.config.js, and numerous configuration JSONs facilitate build and deployment.

##### Elements
- Individual labeled components such as:
- Extension Core Interface (with VS Code APIs)
- Language Service/Parser (highlighting the Rust integration)
- Documentation Generator (Wavedrom and other renderers)
- Netlist Renderer and Viewer
- Simulation Handler/Integration Module
- File System and Resource Manager
- Global Utilities (configuration, internationalization, etc.)
- External Tools / Third-party Simulators (Vivado, ModelSim, Icarus Verilog)
- Annotations on key architectural decisions, like adherence to the LSP model or modular separation of different concerns.

## Diagram (Mermaid)

```mermaid
graph TD
    %% VS Code Extension Layer
    subgraph "VS Code Extension Layer"
        ext["Extension Core Interface"]:::ui
    end

    %% Language Processing Module
    subgraph "Language Processing"
        LSP["Language Service (LSP)"]:::backend
        HDLParser["HDL Parser (Rust)"]:::backend
    end

    %% Documentation Module
    subgraph "Documentation Module"
        DocGen["Documentation Generator"]:::render
        DocRes["Documentation Assets"]:::render
    end

    %% Visualization Module
    subgraph "Visualization Module"
        NetlistRen["Netlist Renderer"]:::render
        NetlistRes["Netlist Resources"]:::render
        ViewerInt["Viewer Integration"]:::render
        ViewerRes["Viewer Resources"]:::render
    end

    %% Simulation Module
    subgraph "Simulation Module"
        Sim["Simulation Handler"]:::backend
        FS["File System Manager"]:::backend
        ExtSim["External Simulators"]:::external
    end

    %% Global Management
    subgraph "Global Management"
        Global["Global Utilities"]:::config
        ConfigFiles["Configuration Files"]:::config
        Manager["Project & Tool Manager"]:::backend
    end

    %% Connections between Modules
    ext -->|"processes"| LSP
    ext -->|"detectsAnnotations"| DocGen
    ext -->|"triggersSimulation"| Sim
    ext -->|"visualizesDesign"| NetlistRen
    ext -->|"integratesView"| ViewerInt

    LSP -->|"uses"| HDLParser

    DocGen -->|"accesses"| DocRes
    NetlistRen -->|"fetches"| NetlistRes
    ViewerInt -->|"fetches"| ViewerRes

    Sim -->|"readsFiles"| FS
    Sim -->|"invokes"| ExtSim

    Global -->|"configures"| ext
    Manager -->|"manages"| LSP
    Manager -->|"manages"| Sim
    Global -->|"with"| ConfigFiles

    %% Click Events for Component Mapping
    click ext "https://github.com/digital-eda/digital-ide/blob/main/src/extension.ts"
    click LSP "https://github.com/digital-eda/digital-ide/tree/main/src/function/lsp"
    click HDLParser "https://github.com/digital-eda/digital-ide/tree/main/src/hdlParser"
    click DocGen "https://github.com/digital-eda/digital-ide/tree/main/src/function/dide-doc"
    click DocRes "https://github.com/digital-eda/digital-ide/tree/main/resources/dide-doc"
    click NetlistRen "https://github.com/digital-eda/digital-ide/tree/main/src/function/dide-netlist"
    click NetlistRes "https://github.com/digital-eda/digital-ide/tree/main/resources/dide-netlist"
    click ViewerInt "https://github.com/digital-eda/digital-ide/tree/main/src/function/dide-viewer"
    click ViewerRes "https://github.com/digital-eda/digital-ide/tree/main/resources/dide-viewer"
    click Sim "https://github.com/digital-eda/digital-ide/tree/main/src/function/sim"
    click FS "https://github.com/digital-eda/digital-ide/tree/main/src/hdlFs"
    click Global "https://github.com/digital-eda/digital-ide/tree/main/src/global"
    click ConfigFiles "https://github.com/digital-eda/digital-ide/tree/main/config"
    click Manager "https://github.com/digital-eda/digital-ide/tree/main/src/manager"

    %% Styles
    classDef ui fill:#bbdefb,stroke:#0d47a1,stroke-width:2px;
    classDef backend fill:#c8e6c9,stroke:#1b5e20,stroke-width:2px;
    classDef render fill:#fff9c4,stroke:#f57f17,stroke-width:2px;
    classDef config fill:#ffe0b2,stroke:#e65100,stroke-width:2px;
    classDef external fill:#ffccbc,stroke:#bf360c,stroke-width:2px;
```
