# psychogenic/microcotb architecture

> Architecture diagram of the GitHub repository psychogenic/microcotb, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2024-12-28). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/psychogenic/microcotb
- Repository: https://github.com/psychogenic/microcotb

## Overview

##### Main Components

a) Core Testing Framework Layer:
- Main microcotb components (Runner, Clock, Triggers, DUT base)
- Decorators subsystem (@cocotb.test, @parametrize)

b) Platform Abstraction Layer:
- Different platform implementations (RP2040, Raspberry Pi, FPGA)
- Platform detection and features management
- To hardware interaction components

c) Hardware Interface Layer:
- Various hardware connection methods (USB Bridge, GPIO, SPI)
- Signal monitoring and control paths
- VCD generation capabilities

##### Component Relationships

**[Test Scripts] → [microcotb Core Framework]**
- ↓
**[Platform Abstraction Layer] ←→ [Feature Detection]**
- ↓
**[Hardware Interface Layer] → [Physical Hardware]**

##### Detailed Component Breakdown

Core Framework (Center):
**┌─ microcotb Core ─────────────┐**
- Test Runner                │
- Clock Management          │
- Trigger System            │
- DUT Base Class            │
- Decorators                │
- ┘

Platform Layer (Middle):
**┌─ Platform Support ──────────┐**
- ┌─RP2040─┐ ┌─RasPi─┐ ┌─FPGA┐│
- MicroPy │ │GPIO   │ │USB  ││
- ┘ └───────┘ └─────┘│
- ┘

Hardware Interface (Bottom):
**┌─ Hardware Interface ────────┐**
- Signal Monitoring        │
- I/O Control             │
- VCD Generation          │
- Timing Management       │
- ┘

##### Special Features to Highlight
- Bidirectional communication paths
- Platform-specific optimizations
- VCD waveform generation capability
- Clock management system
- Trigger system (RisingEdge, FallingEdge, Timer)

##### Implementation Details
- Relationship between test decorators and runner
- How platform detection affects hardware interaction
- Signal monitoring paths
- Timing management system

**→ Data Flow**
**↔ Bidirectional Communication**
**□ Core Component**
**○ Platform-Specific Implementation**
**◇ Hardware Interface**

## Diagram (Mermaid)

```mermaid
graph TB
    %% Core Testing Framework Layer
    subgraph CoreFramework["Core Testing Framework"]
        Runner["Test Runner"]
        Clock["Clock Management"]
        Triggers["Trigger System"]
        DUTBase["DUT Base Class"]
        Decorators["Decorators System"]
    end

    %% Platform Abstraction Layer
    subgraph PlatformLayer["Platform Abstraction"]
        PlatformDetection["Platform Detection"]
        FeaturesManagement["Features Management"]
        
        subgraph Platforms["Platform Implementations"]
            RP2040["RP2040/MicroPy"]
            RaspberryPi["Raspberry Pi/GPIO"]
            DummyPlatform["Dummy Platform"]
        end
    end

    %% Hardware Interface Layer
    subgraph HardwareInterface["Hardware Interface"]
        SignalMonitoring["Signal Monitoring"]
        VCDGen["VCD Generation"]
        IOControl["I/O Control"]
        TimingMgmt["Timing Management"]
        StateTracking["State Tracking"]
    end

    %% Type System
    subgraph TypeSystem["Type System"]
        LogicTypes["Logic Types"]
        IOPortTypes["I/O Port Types"]
        ArrayTypes["Array Types"]
    end

    %% Relationships
    Runner --> PlatformDetection
    Clock --> TimingMgmt
    Triggers --> SignalMonitoring
    DUTBase --> IOControl
    
    PlatformDetection --> Platforms
    FeaturesManagement --> Platforms
    
    Platforms --> IOControl
    SignalMonitoring --> VCDGen
    IOControl --> StateTracking

    %% Click Events
    click Runner "https://github.com/psychogenic/microcotb/blob/main/src/microcotb/runner.py"
    click Clock "https://github.com/psychogenic/microcotb/blob/main/src/microcotb/clock.py"
    click Triggers "https://github.com/psychogenic/microcotb/tree/main/src/microcotb/triggers/"
    click DUTBase "https://github.com/psychogenic/microcotb/blob/main/src/microcotb/dut.py"
    click Decorators "https://github.com/psychogenic/microcotb/tree/main/src/microcotb/decorators/"
    
    click PlatformDetection "https://github.com/psychogenic/microcotb/blob/main/src/microcotb/platform/detection.py"
    click FeaturesManagement "https://github.com/psychogenic/microcotb/blob/main/src/microcotb/platform/features.py"
    click RP2040 "https://github.com/psychogenic/microcotb/tree/main/src/microcotb/platform/rp2040/"
    click RaspberryPi "https://github.com/psychogenic/microcotb/tree/main/src/microcotb_rpi/"
    click DummyPlatform "https://github.com/psychogenic/microcotb/tree/main/src/microcotb/platform/dummy/"
    
    click SignalMonitoring "https://github.com/psychogenic/microcotb/tree/main/src/microcotb/monitorable/"
    click VCDGen "https://github.com/psychogenic/microcotb/blob/main/src/microcotb/monitorable/vcd_writer.py"
    click IOControl "https://github.com/psychogenic/microcotb/blob/main/src/microcotb/ports/io.py"
    click TimingMgmt "https://github.com/psychogenic/microcotb/tree/main/src/microcotb/time/"
    click StateTracking "https://github.com/psychogenic/microcotb/blob/main/src/microcotb/monitorable/state_tracking.py"
    
    click LogicTypes "https://github.com/psychogenic/microcotb/blob/main/src/microcotb/types/logic.py"
    click IOPortTypes "https://github.com/psychogenic/microcotb/blob/main/src/microcotb/types/ioport.py"
    click ArrayTypes "https://github.com/psychogenic/microcotb/blob/main/src/microcotb/types/array.py"

    %% Styling
    classDef core fill:#a8d1f0
    classDef platform fill:#90EE90
    classDef hardware fill:#FFB366
    classDef type fill:#DDA0DD
    
    class Runner,Clock,Triggers,DUTBase,Decorators core
    class PlatformDetection,FeaturesManagement,RP2040,RaspberryPi,DummyPlatform platform
    class SignalMonitoring,VCDGen,IOControl,TimingMgmt,StateTracking hardware
    class LogicTypes,IOPortTypes,ArrayTypes type
```
