# cmu-safari/dram-bender architecture

> Architecture diagram of the GitHub repository cmu-safari/dram-bender, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-08). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/cmu-safari/dram-bender
- Repository: https://github.com/cmu-safari/dram-bender

## Overview

DRAM Bender is an FPGA-based programmable memory-testing platform for DDR4 DIMMs and HBM2. A user runs a test application, which builds a DRAM Bender instruction program; the host API sends it over PCIe and receives results. The repository also includes Python bindings, QUAC-TRNG research code, XDMA driver layers, and U200 DDR4 PHY simulation models. The README documents the product workflow; sampled API and driver references support the implementation links. FPGA logic beyond the listed U200 simulation headers is not represented because its source was not provided.

Main entry points: [`sources/api/prog.cpp`](https://github.com/cmu-safari/dram-bender/blob/master/sources/api/prog.cpp) (Program Builder), [`sources/api/platform.cpp`](https://github.com/cmu-safari/dram-bender/blob/master/sources/api/platform.cpp) (Platform I/O), [`sources/apps/QUAC-TRNG/src/observe.cpp`](https://github.com/cmu-safari/dram-bender/blob/master/sources/apps/QUAC-TRNG/src/observe.cpp) (QUAC-TRNG), [`sources/api/pySoftMC/pySoftMC.cpp`](https://github.com/cmu-safari/dram-bender/blob/master/sources/api/pySoftMC/pySoftMC.cpp) (Python Bindings)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_host["Host API"]
  node_python["Python Bindings<br/>[pySoftMC.cpp]"]
  node_platform["Platform I/O<br/>[platform.cpp]"]
  node_board["Board Interface<br/>[board.cpp]"]
  node_program["Program Builder<br/>[prog.cpp]"]
  node_instruction["Instruction Encoder<br/>[instruction.cpp]"]
end

subgraph group_tests["Test Applications"]
  node_tests["Memory Tests<br/>[read_write.cpp]"]
  node_hbmtest["HBM Test<br/>[read_write.cpp]"]
  node_retention["Retention Test<br/>[retention.cpp]"]
  node_sanity["Sanity Check<br/>[sanity.cpp]"]
  node_quac["QUAC-TRNG<br/>[observe.cpp]"]
  node_quacutil["QUAC Sequences<br/>[util.cpp]"]
end

subgraph group_transport["PCIe Transport"]
  node_xdmaapi["XDMA API<br/>[libxdma_api.h]"]
  node_userspace["User XDMA Library<br/>[libxdma.c]"]
  node_kernel["Kernel DMA Engine<br/>[libxdma.c]"]
  node_sgdma["SGDMA Endpoint<br/>[cdev_sgdma.h]"]
end

subgraph group_fpga["U200 PHY Models"]
  node_phyinit["RDIMM PHY Init"]
  node_phywrap["Simulator Wrappers<br/>[phy_rdimm_x8_dual]"]
  node_physc["SystemC PHY Ports"]
  node_simsc["Vendor PHY Ports"]
end

node_user(("Test User"))
node_pcie{{"PCIe Device"}}
node_dram[("DDR4 DIMM")]

node_user -->|"runs"| node_tests
node_user -->|"runs"| node_hbmtest
node_user -.->|"runs"| node_retention
node_user -.->|"runs"| node_sanity
node_user -->|"runs"| node_quac
node_tests -->|"builds"| node_program
node_hbmtest -->|"builds"| node_program
node_retention -->|"builds"| node_program
node_sanity -->|"builds"| node_program
node_quac -.->|"uses sequences"| node_quacutil
node_quac -.->|"builds"| node_program
node_python -->|"exposes"| node_program
node_python -->|"exposes"| node_platform
node_program -->|"encodes with"| node_instruction
node_platform -->|"serializes"| node_program
node_platform -->|"uses"| node_board
node_platform -->|"transfers over"| node_pcie
node_pcie -->|"uses driver"| node_xdmaapi
node_xdmaapi -->|"provides API"| node_userspace
node_userspace -.->|"submits transfers"| node_kernel
node_kernel -->|"uses endpoint"| node_sgdma
node_pcie -.->|"reaches FPGA memory"| node_dram
node_phyinit -->|"includes"| node_physc
node_phywrap -->|"includes"| node_simsc

click node_tests "https://github.com/cmu-safari/dram-bender/blob/master/sources/apps/Smalltest/read_write.cpp"
click node_hbmtest "https://github.com/cmu-safari/dram-bender/blob/master/sources/apps/Smalltest_HBM/read_write.cpp"
click node_retention "https://github.com/cmu-safari/dram-bender/blob/master/sources/apps/RetentionTest/retention.cpp"
click node_sanity "https://github.com/cmu-safari/dram-bender/blob/master/sources/apps/SanityCheck/sanity.cpp"
click node_quac "https://github.com/cmu-safari/dram-bender/blob/master/sources/apps/QUAC-TRNG/src/observe.cpp"
click node_quacutil "https://github.com/cmu-safari/dram-bender/blob/master/sources/apps/QUAC-TRNG/src/util.cpp"
click node_python "https://github.com/cmu-safari/dram-bender/blob/master/sources/api/pySoftMC/pySoftMC.cpp"
click node_platform "https://github.com/cmu-safari/dram-bender/blob/master/sources/api/platform.cpp"
click node_board "https://github.com/cmu-safari/dram-bender/blob/master/sources/api/board.cpp"
click node_program "https://github.com/cmu-safari/dram-bender/blob/master/sources/api/prog.cpp"
click node_instruction "https://github.com/cmu-safari/dram-bender/blob/master/sources/api/instruction.cpp"
click node_xdmaapi "https://github.com/cmu-safari/dram-bender/blob/master/sources/xdma_driver/include/libxdma_api.h"
click node_userspace "https://github.com/cmu-safari/dram-bender/blob/master/sources/xdma_driver/libxdma/libxdma.c"
click node_kernel "https://github.com/cmu-safari/dram-bender/blob/master/sources/xdma_driver/xdma/libxdma.c"
click node_sgdma "https://github.com/cmu-safari/dram-bender/blob/master/sources/xdma_driver/xdma/cdev_sgdma.h"
click node_phyinit "https://github.com/cmu-safari/dram-bender/blob/master/projects/U200/U200.ip_user_files/mem_init_files/phy_rdimm_x8_dual.h"
click node_phywrap "https://github.com/cmu-safari/dram-bender/tree/master/projects/U200/U200.ip_user_files/sim_scripts/phy_rdimm_x8_dual"
click node_physc "https://github.com/cmu-safari/dram-bender/blob/master/projects/U200/U200.ip_user_files/mem_init_files/phy_rdimm_x8_dual_sc.h"
click node_simsc "https://github.com/cmu-safari/dram-bender/blob/master/projects/U200/U200.ip_user_files/sim_scripts/phy_rdimm_x8_dual/activehdl/phy_rdimm_x8_dual_sc.h"

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_python,node_platform,node_board,node_program,node_instruction,node_user toneBlue
class node_tests,node_hbmtest,node_retention,node_sanity,node_quac,node_quacutil,node_dram toneAmber
class node_xdmaapi,node_userspace,node_kernel,node_sgdma toneMint
class node_phyinit,node_phywrap,node_physc,node_simsc toneRose
class node_pcie toneIndigo
```

## Components

### Host API

- [Python Bindings](https://github.com/cmu-safari/dram-bender/blob/master/sources/api/pySoftMC/pySoftMC.cpp): `sources/api/pySoftMC/pySoftMC.cpp`
- [Platform I/O](https://github.com/cmu-safari/dram-bender/blob/master/sources/api/platform.cpp): `sources/api/platform.cpp`
- [Board Interface](https://github.com/cmu-safari/dram-bender/blob/master/sources/api/board.cpp): `sources/api/board.cpp`
- [Program Builder](https://github.com/cmu-safari/dram-bender/blob/master/sources/api/prog.cpp): `sources/api/prog.cpp`
- [Instruction Encoder](https://github.com/cmu-safari/dram-bender/blob/master/sources/api/instruction.cpp): `sources/api/instruction.cpp`

### Test Applications

- [Memory Tests](https://github.com/cmu-safari/dram-bender/blob/master/sources/apps/Smalltest/read_write.cpp): `sources/apps/Smalltest/read_write.cpp`
- [HBM Test](https://github.com/cmu-safari/dram-bender/blob/master/sources/apps/Smalltest_HBM/read_write.cpp): `sources/apps/Smalltest_HBM/read_write.cpp`
- [Retention Test](https://github.com/cmu-safari/dram-bender/blob/master/sources/apps/RetentionTest/retention.cpp): `sources/apps/RetentionTest/retention.cpp`
- [Sanity Check](https://github.com/cmu-safari/dram-bender/blob/master/sources/apps/SanityCheck/sanity.cpp): `sources/apps/SanityCheck/sanity.cpp`
- [QUAC-TRNG](https://github.com/cmu-safari/dram-bender/blob/master/sources/apps/QUAC-TRNG/src/observe.cpp): `sources/apps/QUAC-TRNG/src/observe.cpp`
- [QUAC Sequences](https://github.com/cmu-safari/dram-bender/blob/master/sources/apps/QUAC-TRNG/src/util.cpp): `sources/apps/QUAC-TRNG/src/util.cpp`

### PCIe Transport

- [XDMA API](https://github.com/cmu-safari/dram-bender/blob/master/sources/xdma_driver/include/libxdma_api.h): `sources/xdma_driver/include/libxdma_api.h`
- [User XDMA Library](https://github.com/cmu-safari/dram-bender/blob/master/sources/xdma_driver/libxdma/libxdma.c): `sources/xdma_driver/libxdma/libxdma.c`
- [Kernel DMA Engine](https://github.com/cmu-safari/dram-bender/blob/master/sources/xdma_driver/xdma/libxdma.c): `sources/xdma_driver/xdma/libxdma.c`
- [SGDMA Endpoint](https://github.com/cmu-safari/dram-bender/blob/master/sources/xdma_driver/xdma/cdev_sgdma.h): `sources/xdma_driver/xdma/cdev_sgdma.h`

### U200 PHY Models

- [RDIMM PHY Init](https://github.com/cmu-safari/dram-bender/blob/master/projects/U200/U200.ip_user_files/mem_init_files/phy_rdimm_x8_dual.h): `projects/U200/U200.ip_user_files/mem_init_files/phy_rdimm_x8_dual.h`
- [Simulator Wrappers](https://github.com/cmu-safari/dram-bender/tree/master/projects/U200/U200.ip_user_files/sim_scripts/phy_rdimm_x8_dual): `projects/U200/U200.ip_user_files/sim_scripts/phy_rdimm_x8_dual`
- [SystemC PHY Ports](https://github.com/cmu-safari/dram-bender/blob/master/projects/U200/U200.ip_user_files/mem_init_files/phy_rdimm_x8_dual_sc.h): `projects/U200/U200.ip_user_files/mem_init_files/phy_rdimm_x8_dual_sc.h`
- [Vendor PHY Ports](https://github.com/cmu-safari/dram-bender/blob/master/projects/U200/U200.ip_user_files/sim_scripts/phy_rdimm_x8_dual/activehdl/phy_rdimm_x8_dual_sc.h): `projects/U200/U200.ip_user_files/sim_scripts/phy_rdimm_x8_dual/activehdl/phy_rdimm_x8_dual_sc.h`

### Other components

- **Test User**
- **PCIe Device**
- **DDR4 DIMM**

## Connections

- Test User → Memory Tests: runs (evidence: `README.md`)
- Test User → HBM Test: runs (evidence: `README.md`)
- Test User → Retention Test: runs
- Test User → Sanity Check: runs
- Test User → QUAC-TRNG: runs (evidence: `README.md`)
- Memory Tests → Program Builder: builds (evidence: `sources/apps/Smalltest/read_write.cpp`)
- HBM Test → Program Builder: builds (evidence: `sources/apps/Smalltest_HBM/read_write.cpp`)
- Retention Test → Program Builder: builds (evidence: `sources/apps/RetentionTest/retention.cpp`)
- Sanity Check → Program Builder: builds (evidence: `sources/apps/SanityCheck/sanity.cpp`)
- QUAC-TRNG → QUAC Sequences: uses sequences
- QUAC-TRNG → Program Builder: builds
- Python Bindings → Program Builder: exposes (evidence: `sources/api/pySoftMC/pySoftMC.cpp`)
- Python Bindings → Platform I/O: exposes (evidence: `sources/api/pySoftMC/pySoftMC.cpp`)
- Program Builder → Instruction Encoder: encodes with (evidence: `sources/api/prog.cpp`)
- Platform I/O → Program Builder: serializes (evidence: `sources/api/platform.cpp`)
- Platform I/O → Board Interface: uses (evidence: `sources/api/platform.cpp`)
- Platform I/O → PCIe Device: transfers over (evidence: `README.md`)
- PCIe Device → XDMA API: uses driver (evidence: `README.md`)
- XDMA API → User XDMA Library: provides API (evidence: `sources/xdma_driver/libxdma/libxdma.c`)
- User XDMA Library → Kernel DMA Engine: submits transfers
- Kernel DMA Engine → SGDMA Endpoint: uses endpoint (evidence: `sources/xdma_driver/xdma/libxdma.c`)
- PCIe Device → DDR4 DIMM: reaches FPGA memory
- RDIMM PHY Init → SystemC PHY Ports: includes (evidence: `projects/U200/U200.ip_user_files/mem_init_files/phy_rdimm_x8_dual.h`)
- Simulator Wrappers → Vendor PHY Ports: includes (evidence: `projects/U200/U200.ip_user_files/sim_scripts/phy_rdimm_x8_dual/activehdl/phy_rdimm_x8_dual.h`)
