# gasmith/cosmac_bios architecture

> Architecture diagram of the GitHub repository gasmith/cosmac_bios, 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/gasmith/cosmac_bios
- Repository: https://github.com/gasmith/cosmac_bios

## Overview

##### Main Components

a) Hardware Layer:
- RAM (0x0000-0x7fff)
- EEPROM (0x8000-0xffff)
- EF3 Pin (UART receive)
- Q Pin (UART transmit)
- 4MHz Clock

b) Software Components:
- Stage 1 Loader
- BIOS Core
- Bit-banged UART Implementation
- EEPROM Programming Interface
- Memory Management
- Register Management

**[Hardware Layer]**
- ↑↓
**[Memory Management Layer]**
- ↑↓
**[BIOS Core Layer]**
- ↑↓
**[Interface Layer]**

##### Key Elements to Highlight

a) Memory Map (show as a side panel):
- 0x0000: Initial PC & Loader Target
- 0x0100: Toggled-in Loader Target
- 0x7fff: Stack (downward growth)
- 0x8000: EEPROM Loader Entry
- 0xfb00: BIOS Start
- 0xff00: BIOS VFT
- 0xfffc: BIOS Version
- 0xfffe: BIOS Checksum

b) Register Allocation (show as a side panel):
- R0-R7: System Registers
- R8-RF: General Purpose

- Bidirectional communication between UART and external world
- Stack growth direction
- Bootstrap process flow
- Memory access patterns

##### Final BIOS initialization

b) UART Implementation:
- Timing-critical nature (2400 baud)
- Half-duplex operation
- Pin connections

##### Component Relationships

- UART ↔ External Interface
- Memory Management ↔ Hardware
- BIOS Core ↔ Memory Management
- Bootstrap Process ↔ EEPROM

##### Technical Details

- Clock speed: 4MHz
- Baud rate: 2400
- Memory sizes
- Checksum verification points

##### BIOS core functionality

Use standardized symbols:
- Rectangles: Software components
- Diamonds: Decision points

Remember to indicate the test framework's position in the architecture, as it's a significant part of the project structure based on the file tree.

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph "External Interface"
        EXTERNAL[External World]
    end

    subgraph "Interface Layer"
        MONITOR["Monitor Interface"]:::monitor
        BOOTSTRAP["Bootstrap Utilities"]:::bootstrap
        CKSUM["Checksum Tools"]:::cksum
        TEST["Test Framework"]:::test
    end

    subgraph "BIOS Core Layer"
        BIOSCORE["BIOS Core"]:::bios
        UART["UART Implementation"]:::uart
        MATH["Math Operations"]:::math
        STR["String Operations"]:::str
    end

    subgraph "Memory Management Layer"
        MEMSTACK["Memory/Stack Manager"]:::memstack
        EEPROM_IF["EEPROM Interface"]:::eeprom
        BOOT["Bootstrap Components"]:::boot
    end

    subgraph "Hardware Layer"
        RAM["RAM (0x0000-0x7fff)"]
        EEPROM["EEPROM (0x8000-0xffff)"]
        EF3["EF3 Pin (UART RX)"]
        QPIN["Q Pin (UART TX)"]
        CLOCK["4MHz Clock"]
        BLINK["Hardware Interface"]:::hwinterface
    end

    %% Relationships
    EXTERNAL <--> MONITOR
    EXTERNAL <--> UART
    
    MONITOR --> BIOSCORE
    BOOTSTRAP --> BOOT
    CKSUM --> BIOSCORE
    TEST --> BIOSCORE
    
    BIOSCORE --> UART
    BIOSCORE --> MATH
    BIOSCORE --> STR
    BIOSCORE --> MEMSTACK
    
    UART --> EF3
    UART --> QPIN
    
    MEMSTACK --> RAM
    MEMSTACK --> EEPROM
    EEPROM_IF --> EEPROM
    BOOT --> RAM
    BOOT --> EEPROM
    
    BLINK --> QPIN

    %% Memory Map Note
    classDef memmap fill:#f9f,stroke:#333,stroke-width:2px
    MEMMAP["Memory Map
    0x0000: Initial PC
    0x0100: Loader Target
    0x7fff: Stack
    0x8000: EEPROM Entry
    0xfb00: BIOS Start
    0xff00: BIOS VFT
    0xfffc: Version
    0xfffe: Checksum"]:::memmap

    %% Styling
    classDef monitor fill:#f96,stroke:#333
    classDef bootstrap fill:#fc9,stroke:#333
    classDef cksum fill:#9cf,stroke:#333
    classDef test fill:#9f9,stroke:#333
    classDef bios fill:#6f9,stroke:#333
    classDef uart fill:#ff9,stroke:#333
    classDef math fill:#9ff,stroke:#333
    classDef str fill:#f9f,stroke:#333
    classDef memstack fill:#69f,stroke:#333
    classDef eeprom fill:#96f,stroke:#333
    classDef boot fill:#f69,stroke:#333
    classDef hwinterface fill:#999,stroke:#333

    %% Click Events
    click MONITOR "https://github.com/gasmith/cosmac_bios/blob/main/minimon.asm"
    click BOOTSTRAP "https://github.com/gasmith/cosmac_bios/blob/main/bootstrap.py"
    click CKSUM "https://github.com/gasmith/cosmac_bios/blob/main/cksum.py"
    click TEST "https://github.com/gasmith/cosmac_bios/tree/main/test"
    click BIOSCORE "https://github.com/gasmith/cosmac_bios/blob/main/bios.asm"
    click UART "https://github.com/gasmith/cosmac_bios/blob/main/inc/tx.asm"
    click MATH "https://github.com/gasmith/cosmac_bios/blob/main/inc/mul.asm"
    click STR "https://github.com/gasmith/cosmac_bios/blob/main/inc/str.asm"
    click MEMSTACK "https://github.com/gasmith/cosmac_bios/blob/main/inc/stack.asm"
    click EEPROM_IF "https://github.com/gasmith/cosmac_bios/blob/main/inc/eeprom.asm"
    click BOOT "https://github.com/gasmith/cosmac_bios/blob/main/loader.asm"
    click BLINK "https://github.com/gasmith/cosmac_bios/blob/main/blinkenlights.asm"
```
