# riscv-software-src/riscv-unified-db architecture

> Architecture diagram of the GitHub repository riscv-software-src/riscv-unified-db, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-01-12). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/riscv-software-src/riscv-unified-db
- Repository: https://github.com/riscv-software-src/riscv-unified-db

## Overview

##### Main Components
- Core Database Layer
- IDL (Interface Definition Language) Compiler
- Multiple Backend Generators
- Configuration Management System
- Schema Validation Layer

##### Component Details and Relationships

a. Core Database Layer
- Represents the central repository of RISC-V specifications
- Contains extensions, instructions, CSRs, and documentation
- To: Schema Validation Layer, Backend Generators

b. IDL Compiler
- Processes formal specifications
- Handles AST generation and symbol tables
- To: Core Database Layer, Backend Generators

c. Backend Generators
- HTML Documentation Generator
- PDF Generator
- Configuration-specific Generator
- Extension Documentation Generator
- To: Core Database Layer, Configuration Management

d. Configuration Management System
- Handles different RISC-V configurations
- Manages implementation-specific options
- To: Core Database Layer, Backend Generators

e. Schema Validation Layer
- Validates YAML specifications
- Ensures data integrity
- To: Core Database Layer

##### Data Flow Representation

- Input flow: Raw specifications → Schema Validation → Core Database
- Processing flow: Core Database → IDL Compiler → Backend Generators
- Output flow: Backend Generators → Generated Artifacts

##### Key Integration Points

- Configuration Management ↔ Backend Generators
- Core Database ↔ IDL Compiler
- Schema Validation ↔ Core Database

##### Additional Elements

- Input Sources (YAML files, IDL specifications)
- Output Artifacts (HTML docs, PDFs, ISA manuals)
- External Tools Integration points

##### Implementation Notes

Annotations for:
- Ruby-based implementation
- Container-based deployment options
- YAML/JSON schema validation
- Antora documentation integration

- Clear hierarchical layout
- Proper component relationships
- Consistent styling
- Exportable formats

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph Input
        YAML[("YAML Files")]
        IDLSpec[("IDL Specifications")]
    end

    subgraph "Schema Validation"
        SchemaVal[("Schema Validation")]:::validation
        CoreSchema["Core Schemas"]:::validation
        CompSchema["Component Schemas"]:::validation
    end

    subgraph "Core Database"
        CoreDB[("Central Repository")]:::database
        Extensions["Extensions"]:::database
        CSRs["CSRs"]:::database
        Instructions["Instructions"]:::database
        ISADefs["ISA Definitions"]:::database
    end

    subgraph "IDL Processing"
        IDLComp["IDL Compiler"]:::processing
        Grammar["Grammar Parser"]:::processing
        AST["AST Implementation"]:::processing
        SymTable["Symbol Table"]:::processing
    end

    subgraph "Configuration Management"
        ConfigMgmt["Configuration Manager"]:::config
        BaseConfig["Base Configurations"]:::config
        Validation["Config Validation"]:::config
    end

    subgraph "Backend Generation"
        CertGen["Certificate Generator"]:::backend
        HTMLDoc["HTML Documentation"]:::backend
        PDFGen["PDF Generator"]:::backend
        ManualGen["Manual Generator"]:::backend
    end

    subgraph Output
        Docs[("Documentation")]
        PDFs[("PDFs")]
        Manuals[("ISA Manuals")]
    end

    %% Relationships
    YAML --> SchemaVal
    IDLSpec --> IDLComp
    SchemaVal --> CoreDB
    CoreSchema --> SchemaVal
    CompSchema --> SchemaVal
    
    CoreDB --> Extensions
    CoreDB --> CSRs
    CoreDB --> Instructions
    CoreDB --> ISADefs
    
    IDLComp --> Grammar
    IDLComp --> AST
    IDLComp --> SymTable
    
    CoreDB <--> IDLComp
    
    ConfigMgmt --> BaseConfig
    ConfigMgmt --> Validation
    
    ConfigMgmt --> |Configuration| CertGen
    ConfigMgmt --> |Configuration| HTMLDoc
    ConfigMgmt --> |Configuration| PDFGen
    ConfigMgmt --> |Configuration| ManualGen
    
    CertGen --> Docs
    HTMLDoc --> Docs
    PDFGen --> PDFs
    ManualGen --> Manuals

    %% Click Events
    click CoreDB "https://github.com/riscv-software-src/riscv-unified-db/tree/main/arch"
    click Extensions "https://github.com/riscv-software-src/riscv-unified-db/tree/main/arch/ext"
    click CSRs "https://github.com/riscv-software-src/riscv-unified-db/tree/main/arch/csr"
    click Instructions "https://github.com/riscv-software-src/riscv-unified-db/tree/main/arch/inst"
    click ISADefs "https://github.com/riscv-software-src/riscv-unified-db/tree/main/arch/isa"
    click IDLComp "https://github.com/riscv-software-src/riscv-unified-db/tree/main/lib/idl"
    click Grammar "https://github.com/riscv-software-src/riscv-unified-db/blob/main/lib/idl/idl.treetop"
    click AST "https://github.com/riscv-software-src/riscv-unified-db/blob/main/lib/idl/ast.rb"
    click SymTable "https://github.com/riscv-software-src/riscv-unified-db/blob/main/lib/idl/symbol_table.rb"
    click CertGen "https://github.com/riscv-software-src/riscv-unified-db/tree/main/backends/certificate_doc"
    click HTMLDoc "https://github.com/riscv-software-src/riscv-unified-db/tree/main/backends/cfg_html_doc"
    click PDFGen "https://github.com/riscv-software-src/riscv-unified-db/tree/main/backends/ext_pdf_doc"
    click ManualGen "https://github.com/riscv-software-src/riscv-unified-db/tree/main/backends/manual"
    click ConfigMgmt "https://github.com/riscv-software-src/riscv-unified-db/tree/main/cfgs"
    click Validation "https://github.com/riscv-software-src/riscv-unified-db/blob/main/cfgs/config_validation.rb"
    click BaseConfig "https://github.com/riscv-software-src/riscv-unified-db/tree/main/cfgs"
    click SchemaVal "https://github.com/riscv-software-src/riscv-unified-db/tree/main/schemas"
    click CoreSchema "https://github.com/riscv-software-src/riscv-unified-db/blob/main/schemas/schema_defs.json"
    click CompSchema "https://github.com/riscv-software-src/riscv-unified-db/tree/main/schemas"

    %% Styling
    classDef database fill:#3498db,stroke:#2980b9,color:white
    classDef processing fill:#2ecc71,stroke:#27ae60,color:white
    classDef backend fill:#e67e22,stroke:#d35400,color:white
    classDef config fill:#9b59b6,stroke:#8e44ad,color:white
    classDef validation fill:#e74c3c,stroke:#c0392b,color:white

    %% Legend
    subgraph Legend
        DB[("Database Component")]:::database
        PROC["Processing Component"]:::processing
        BACK["Backend Component"]:::backend
        CONF["Configuration Component"]:::config
        VAL[("Validation Component")]:::validation
    end
```
