# raster-gpu/raster-ii architecture

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

- Interactive diagram: https://gitdiagram.com/raster-gpu/raster-ii
- Repository: https://github.com/raster-gpu/raster-ii

## Overview

- A Scala-based “core” located in src/main/scala. This contains:
– General processing modules (e.g., PatternGenerator.scala and Raster.scala)
– A display submodule (under src/main/scala/display) that implements key functionalities such as block handling (Bc1Block.scala), compression/decompression (Bc1Compressor.scala and Bc1Decompressor.scala), display control (DisplayController.scala) and video generation (VideoGenerator.scala)

- A simulation environment found in the sim directory that includes a C++ file (sim/sim.cpp) and a Makefile. This is likely used to test, validate, or benchmark the behavior of the design components.

- A hardware synthesis section in the synth folder—specifically tailored for the ULX3S FPGA board (as seen by the tmds_encoder.v, top.v, and associated constraint file ulx3s.lpf). This indicates that the project not only simulates raster processing but is also meant to be synthesized and deployed on actual hardware.

- Ancillary files and configurations such as build.sbt, Makefiles, and infrastructure files (flake.lock, flake.nix, etc.) that support building, formatting, and deploying both the Scala and hardware design components.

##### Main Components
a. Scala Software Core:
- Core logic modules (Raster.scala, PatternGenerator.scala) that drive the overall functionality.
- Submodule components (Bc1Block, Bc1Compressor, Bc1Decompressor, DisplayController, VideoGenerator) responsible for handling and processing display data.
b. Simulation Environment:
- The simulation module (sim/sim.cpp and associated Makefile) for testing and verification.
c. Hardware Synthesis Components:
- Verilog-based modules (top.v, tmds_encoder.v) along with the supporting FPGA synthesis scripts (raster.tcl, ulx3s.lpf) present in the synth/ulx3s directory.
d. Build and Deployment Infrastructure:
- Build scripts and configuration files (build.sbt, Makefile, flake.lock, flake.nix, etc.) that enable consistent project builds and integration.

##### Component Relationships and Data Flows
- That these display modules may feed into hardware modules (for instance, video generation might translate into signals handled by the tmds_encoder in the hardware block).
- Simulation environment as a parallel testing or verification pathway that consumes/compares outputs from the core components.
- A build/integration pipeline showing how configuration files, build scripts, and documentation support both the simulation and synthesis flows.

##### Architectural Patterns and Technologies
- Separation of concerns between software (Scala) and hardware (Verilog-based synthesis).
- Implicit MVC or modular patterns within the Scala codebase where core logic (model) and display control (view/controller) interact.
- Recognize the cross-domain integration: while software simulates and orchestrates display logic, hardware synthesis ensures deployment on an FPGA (in this case, ULX3S).

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Build and Deployment Infrastructure"
        buildInfra["Build and Deployment Infrastructure"]:::build
    end

    subgraph "Software/System Logic (Scala)"
        rasterCore["Scala Core - Raster/Pattern Generation"]:::scala
        displayModule["Display Module - Compression/Decompression & Control"]:::display
    end

    subgraph "Hardware Synthesis"
        hwSynth["Hardware Synthesis - FPGA Verilog Modules"]:::hardware
    end

    simulation["Simulation Environment - C++ Testing Framework"]:::simulation

    %% Relationships
    buildInfra -->|"build"| rasterCore
    buildInfra -->|"build"| simulation
    rasterCore -->|"displayData"| displayModule
    displayModule -->|"videoSignal"| hwSynth
    simulation -.->|"feedback"| rasterCore

    %% Click Events
    click rasterCore "https://github.com/raster-gpu/raster-ii/tree/main/src/main/scala"
    click displayModule "https://github.com/raster-gpu/raster-ii/tree/main/src/main/scala/display"
    click simulation "https://github.com/raster-gpu/raster-ii/tree/main/sim"
    click hwSynth "https://github.com/raster-gpu/raster-ii/tree/main/synth/ulx3s"
    click buildInfra "https://github.com/raster-gpu/raster-ii/blob/main/build.sbt"

    %% Styles
    classDef scala fill:#cce5ff,stroke:#004085,stroke-width:2px;
    classDef display fill:#d4edda,stroke:#155724,stroke-width:2px;
    classDef simulation fill:#fff3cd,stroke:#856404,stroke-width:2px,stroke-dasharray: 5 5;
    classDef hardware fill:#f8d7da,stroke:#721c24,stroke-width:2px,stroke-dasharray: 3 3;
    classDef build fill:#e2e3e5,stroke:#6c757d,stroke-width:2px;
```
