# arc-instruments/libarc2 architecture

> Architecture diagram of the GitHub repository arc-instruments/libarc2, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-27). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/arc-instruments/libarc2
- Repository: https://github.com/arc-instruments/libarc2

## Overview

libarc2 is a low-level Rust interface for ArC TWO hardware: it builds and executes board instructions, manages onboard result memory, and supports channel configuration, reads, and pulsing. The principal workflow is a Rust consumer calling the Instrument API, which prepares instructions and registers, executes them through BeastLink, and retrieves measurement data from FPGA memory. The excerpts establish these core interactions; detailed internal sequencing for some read and pulse operations is not shown.

Main entry points: [`src/instrument.rs`](https://github.com/arc-instruments/libarc2/blob/master/src/instrument.rs) (Instrument operations), [`src/instructions.rs`](https://github.com/arc-instruments/libarc2/blob/master/src/instructions.rs) (Instruction encoding), [`src/registers.rs`](https://github.com/arc-instruments/libarc2/blob/master/src/registers.rs) (Register encoding), [`src/macros.rs`](https://github.com/arc-instruments/libarc2/blob/master/src/macros.rs) (Voltage helpers)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_api["Instrument API"]
  node_instrument["Instrument operations<br/>[instrument.rs]"]
  node_channels["Channel setup<br/>[instrument.rs]"]
  node_measurements["Read and pulse<br/>[instrument.rs]"]
end

subgraph group_commands["Command Encoding"]
  node_commands["Instruction encoding<br/>[instructions.rs]"]
  node_registers["Register encoding<br/>[registers.rs]"]
  node_macros["Voltage helpers<br/>[macros.rs]"]
end

subgraph group_state["Board State"]
  node_memory[("FPGA memory manager<br/>[memory.rs]")]
end

node_consumer(("Rust consumer"))
node_beastlink["BeastLink FPGA interface"]

node_consumer -->|"calls"| node_instrument
node_instrument -->|"configures"| node_channels
node_instrument -->|"provides"| node_measurements
node_instrument -->|"processes"| node_commands
node_instrument -->|"uses"| node_registers
node_instrument -->|"allocates and reads"| node_memory
node_instrument -->|"uses"| node_macros
node_commands -->|"serializes"| node_registers
node_instrument -.->|"communicates via"| node_beastlink

click node_instrument "https://github.com/arc-instruments/libarc2/blob/master/src/instrument.rs"
click node_channels "https://github.com/arc-instruments/libarc2/blob/master/src/instrument.rs"
click node_measurements "https://github.com/arc-instruments/libarc2/blob/master/src/instrument.rs"
click node_commands "https://github.com/arc-instruments/libarc2/blob/master/src/instructions.rs"
click node_registers "https://github.com/arc-instruments/libarc2/blob/master/src/registers.rs"
click node_macros "https://github.com/arc-instruments/libarc2/blob/master/src/macros.rs"
click node_memory "https://github.com/arc-instruments/libarc2/blob/master/src/memory.rs"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_instrument,node_channels,node_measurements toneBlue
class node_commands,node_registers,node_macros toneAmber
class node_memory toneMint
class node_consumer,node_beastlink toneIndigo
```

## Components

### Instrument API

- [Instrument operations](https://github.com/arc-instruments/libarc2/blob/master/src/instrument.rs): `src/instrument.rs`
- [Channel setup](https://github.com/arc-instruments/libarc2/blob/master/src/instrument.rs): `src/instrument.rs`
- [Read and pulse](https://github.com/arc-instruments/libarc2/blob/master/src/instrument.rs): `src/instrument.rs`

### Command Encoding

- [Instruction encoding](https://github.com/arc-instruments/libarc2/blob/master/src/instructions.rs): `src/instructions.rs`
- [Register encoding](https://github.com/arc-instruments/libarc2/blob/master/src/registers.rs): `src/registers.rs`
- [Voltage helpers](https://github.com/arc-instruments/libarc2/blob/master/src/macros.rs): `src/macros.rs`

### Board State

- [FPGA memory manager](https://github.com/arc-instruments/libarc2/blob/master/src/memory.rs): `src/memory.rs`

### Other components

- **Rust consumer**
- **BeastLink FPGA interface**

## Connections

- Rust consumer → Instrument operations: calls (evidence: `README.md`)
- Instrument operations → Channel setup: configures (evidence: `src/instrument.rs`)
- Instrument operations → Read and pulse: provides (evidence: `src/instrument.rs`)
- Instrument operations → Instruction encoding: processes (evidence: `src/instrument.rs`)
- Instrument operations → Register encoding: uses (evidence: `src/instrument.rs`)
- Instrument operations → FPGA memory manager: allocates and reads (evidence: `src/instrument.rs`)
- Instrument operations → Voltage helpers: uses (evidence: `src/instrument.rs`)
- Instruction encoding → Register encoding: serializes (evidence: `src/instructions.rs`)
- Instrument operations → BeastLink FPGA interface: communicates via (evidence: `README.md`)
