# slyhark-dev/qrs-detector-cyclone-v architecture

> Architecture diagram of the GitHub repository slyhark-dev/qrs-detector-cyclone-v, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-09). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/slyhark-dev/qrs-detector-cyclone-v
- Repository: https://github.com/slyhark-dev/qrs-detector-cyclone-v

## Overview

This repository implements a causal ECG QRS detector and heart-rate classifier for a Cyclone V FPGA, with MATLAB tooling to prepare MIT-BIH data and evaluate RTL results. The principal workflow runs from sampled ECG input through filtering, QRS detection, RR/rate classification, and board outputs. MATLAB’s documented batch workflow supplies vectors and annotations to RTL simulation, then compares and aggregates results. The README documents module roles and workflow, but no source excerpts were provided, so internal call details beyond those documented are not asserted.

Main entry points: [`ecg_matlab/generate_vhdl_vectors_batch.m`](https://github.com/slyhark-dev/qrs-detector-cyclone-v/blob/main/ecg_matlab/generate_vhdl_vectors_batch.m) (Vector generation), [`ecg_arrhythmia/tb_batch_ecg.vhd`](https://github.com/slyhark-dev/qrs-detector-cyclone-v/blob/main/ecg_arrhythmia/tb_batch_ecg.vhd) (RTL batch simulation), [`ecg_arrhythmia/qrs_detector.vhd`](https://github.com/slyhark-dev/qrs-detector-cyclone-v/blob/main/ecg_arrhythmia/qrs_detector.vhd) (QRS detector), [`ecg_matlab/download_mitbih_records.m`](https://github.com/slyhark-dev/qrs-detector-cyclone-v/blob/main/ecg_matlab/download_mitbih_records.m) (Record download)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_rtl["FPGA signal pipeline"]
  node_input["Input register<br/>[ecg_input.vhd]"]
  node_filter["Moving average<br/>[ecg_filter.vhd]"]
  node_bandpass["Bandpass filter<br/>[ecg_filter_bp.vhd]"]
  node_qrs["QRS detector<br/>[qrs_detector.vhd]"]
  node_rr["RR calculator<br/>[rr_calculator.vhd]"]
  node_classifier["Rate classifier<br/>[classifier.vhd]"]
  node_output["Display outputs<br/>[output_ctrl.vhd]"]
  node_top["ECG top entity<br/>[top_ecg.vhd]"]
  node_rom[("Demo ECG memory<br/>[ecg_rom.vhd]")]
end

subgraph group_matlab["Data and validation"]
  node_mitbih[("MIT-BIH records")]
  node_download["Record download"]
  node_vectors["Vector generation"]
  node_batch["RTL batch simulation<br/>[tb_batch_ecg.vhd]"]
  node_compare["Detection comparison"]
  node_report["Protocol reports<br/>[report_table3.m]"]
  node_rate_validation["Rate validation"]
  node_agreement["BPM agreement<br/>[bland_altman_bpm.m]"]
end

subgraph group_studies["Analysis and ablations"]
  node_emulate["RTL emulation<br/>[emulate_rtl.m]"]
  node_ablation["Filter ablation"]
  node_sweeps["Parameter studies"]
  node_romgen["ROM generation<br/>[generate_ecg_rom.m]"]
end

node_ecg_source(("ECG samples"))
node_board["DE1-SoC board"]
node_physionet["PhysioNet"]

node_ecg_source -->|"supplies samples"| node_input
node_input -->|"feeds samples"| node_filter
node_filter -->|"filters signal"| node_qrs
node_bandpass -.->|"filters signal"| node_qrs
node_qrs -->|"provides peaks"| node_rr
node_rr -->|"provides heart rate"| node_classifier
node_classifier -->|"provides class"| node_output
node_top -->|"targets"| node_board
node_romgen -->|"generates memory"| node_rom
node_download -->|"downloads records"| node_physionet
node_download -->|"obtains records"| node_mitbih
node_mitbih -->|"provides data"| node_vectors
node_vectors -->|"supplies test vectors"| node_batch
node_batch -->|"writes detections"| node_compare
node_compare -->|"supplies counts"| node_report
node_batch -->|"validates classifier"| node_rate_validation
node_batch -->|"supplies hardware rates"| node_agreement
node_vectors -->|"supplies vectors"| node_emulate
node_emulate -->|"checks RTL output"| node_batch
node_vectors -->|"supplies vectors"| node_ablation
node_vectors -->|"supplies vectors"| node_sweeps

click node_input "https://github.com/slyhark-dev/qrs-detector-cyclone-v/blob/main/ecg_arrhythmia/ecg_input.vhd"
click node_filter "https://github.com/slyhark-dev/qrs-detector-cyclone-v/blob/main/ecg_arrhythmia/ecg_filter.vhd"
click node_bandpass "https://github.com/slyhark-dev/qrs-detector-cyclone-v/blob/main/ecg_arrhythmia/ecg_filter_bp.vhd"
click node_qrs "https://github.com/slyhark-dev/qrs-detector-cyclone-v/blob/main/ecg_arrhythmia/qrs_detector.vhd"
click node_rr "https://github.com/slyhark-dev/qrs-detector-cyclone-v/blob/main/ecg_arrhythmia/rr_calculator.vhd"
click node_classifier "https://github.com/slyhark-dev/qrs-detector-cyclone-v/blob/main/ecg_arrhythmia/classifier.vhd"
click node_output "https://github.com/slyhark-dev/qrs-detector-cyclone-v/blob/main/ecg_arrhythmia/output_ctrl.vhd"
click node_top "https://github.com/slyhark-dev/qrs-detector-cyclone-v/blob/main/ecg_arrhythmia/top_ecg.vhd"
click node_rom "https://github.com/slyhark-dev/qrs-detector-cyclone-v/blob/main/ecg_arrhythmia/ecg_rom.vhd"
click node_download "https://github.com/slyhark-dev/qrs-detector-cyclone-v/blob/main/ecg_matlab/download_mitbih_records.m"
click node_vectors "https://github.com/slyhark-dev/qrs-detector-cyclone-v/blob/main/ecg_matlab/generate_vhdl_vectors_batch.m"
click node_batch "https://github.com/slyhark-dev/qrs-detector-cyclone-v/blob/main/ecg_arrhythmia/tb_batch_ecg.vhd"
click node_compare "https://github.com/slyhark-dev/qrs-detector-cyclone-v/blob/main/ecg_matlab/compare_vhdl_batch.m"
click node_report "https://github.com/slyhark-dev/qrs-detector-cyclone-v/blob/main/ecg_matlab/report_table3.m"
click node_rate_validation "https://github.com/slyhark-dev/qrs-detector-cyclone-v/blob/main/ecg_matlab/validate_rate_classifier.m"
click node_agreement "https://github.com/slyhark-dev/qrs-detector-cyclone-v/blob/main/ecg_matlab/bland_altman_bpm.m"
click node_emulate "https://github.com/slyhark-dev/qrs-detector-cyclone-v/blob/main/ecg_matlab/emulate_rtl.m"
click node_ablation "https://github.com/slyhark-dev/qrs-detector-cyclone-v/blob/main/ecg_matlab/ablation_bandpass_v2.m"
click node_sweeps "https://github.com/slyhark-dev/qrs-detector-cyclone-v/blob/main/ecg_matlab/sweep_floor_fixed_cal.m"
click node_romgen "https://github.com/slyhark-dev/qrs-detector-cyclone-v/blob/main/ecg_matlab/generate_ecg_rom.m"

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_input,node_filter,node_bandpass,node_qrs,node_rr,node_classifier,node_output,node_top,node_rom toneBlue
class node_mitbih,node_download,node_vectors,node_batch,node_compare,node_report,node_rate_validation,node_agreement toneAmber
class node_emulate,node_ablation,node_sweeps,node_romgen toneMint
class node_ecg_source,node_board,node_physionet toneIndigo
```

## Components

### FPGA signal pipeline

- [Input register](https://github.com/slyhark-dev/qrs-detector-cyclone-v/blob/main/ecg_arrhythmia/ecg_input.vhd): `ecg_arrhythmia/ecg_input.vhd`
- [Moving average](https://github.com/slyhark-dev/qrs-detector-cyclone-v/blob/main/ecg_arrhythmia/ecg_filter.vhd): `ecg_arrhythmia/ecg_filter.vhd`
- [Bandpass filter](https://github.com/slyhark-dev/qrs-detector-cyclone-v/blob/main/ecg_arrhythmia/ecg_filter_bp.vhd): `ecg_arrhythmia/ecg_filter_bp.vhd`
- [QRS detector](https://github.com/slyhark-dev/qrs-detector-cyclone-v/blob/main/ecg_arrhythmia/qrs_detector.vhd): `ecg_arrhythmia/qrs_detector.vhd`
- [RR calculator](https://github.com/slyhark-dev/qrs-detector-cyclone-v/blob/main/ecg_arrhythmia/rr_calculator.vhd): `ecg_arrhythmia/rr_calculator.vhd`
- [Rate classifier](https://github.com/slyhark-dev/qrs-detector-cyclone-v/blob/main/ecg_arrhythmia/classifier.vhd): `ecg_arrhythmia/classifier.vhd`
- [Display outputs](https://github.com/slyhark-dev/qrs-detector-cyclone-v/blob/main/ecg_arrhythmia/output_ctrl.vhd): `ecg_arrhythmia/output_ctrl.vhd`
- [ECG top entity](https://github.com/slyhark-dev/qrs-detector-cyclone-v/blob/main/ecg_arrhythmia/top_ecg.vhd): `ecg_arrhythmia/top_ecg.vhd`
- [Demo ECG memory](https://github.com/slyhark-dev/qrs-detector-cyclone-v/blob/main/ecg_arrhythmia/ecg_rom.vhd): `ecg_arrhythmia/ecg_rom.vhd`

### Data and validation

- **MIT-BIH records**
- [Record download](https://github.com/slyhark-dev/qrs-detector-cyclone-v/blob/main/ecg_matlab/download_mitbih_records.m): `ecg_matlab/download_mitbih_records.m`
- [Vector generation](https://github.com/slyhark-dev/qrs-detector-cyclone-v/blob/main/ecg_matlab/generate_vhdl_vectors_batch.m): `ecg_matlab/generate_vhdl_vectors_batch.m`
- [RTL batch simulation](https://github.com/slyhark-dev/qrs-detector-cyclone-v/blob/main/ecg_arrhythmia/tb_batch_ecg.vhd): `ecg_arrhythmia/tb_batch_ecg.vhd`
- [Detection comparison](https://github.com/slyhark-dev/qrs-detector-cyclone-v/blob/main/ecg_matlab/compare_vhdl_batch.m): `ecg_matlab/compare_vhdl_batch.m`
- [Protocol reports](https://github.com/slyhark-dev/qrs-detector-cyclone-v/blob/main/ecg_matlab/report_table3.m): `ecg_matlab/report_table3.m`
- [Rate validation](https://github.com/slyhark-dev/qrs-detector-cyclone-v/blob/main/ecg_matlab/validate_rate_classifier.m): `ecg_matlab/validate_rate_classifier.m`
- [BPM agreement](https://github.com/slyhark-dev/qrs-detector-cyclone-v/blob/main/ecg_matlab/bland_altman_bpm.m): `ecg_matlab/bland_altman_bpm.m`

### Analysis and ablations

- [RTL emulation](https://github.com/slyhark-dev/qrs-detector-cyclone-v/blob/main/ecg_matlab/emulate_rtl.m): `ecg_matlab/emulate_rtl.m`
- [Filter ablation](https://github.com/slyhark-dev/qrs-detector-cyclone-v/blob/main/ecg_matlab/ablation_bandpass_v2.m): `ecg_matlab/ablation_bandpass_v2.m`
- [Parameter studies](https://github.com/slyhark-dev/qrs-detector-cyclone-v/blob/main/ecg_matlab/sweep_floor_fixed_cal.m): `ecg_matlab/sweep_floor_fixed_cal.m`
- [ROM generation](https://github.com/slyhark-dev/qrs-detector-cyclone-v/blob/main/ecg_matlab/generate_ecg_rom.m): `ecg_matlab/generate_ecg_rom.m`

### Other components

- **ECG samples**
- **DE1-SoC board**
- **PhysioNet**

## Connections

- ECG samples → Input register: supplies samples (evidence: `README.md`)
- Input register → Moving average: feeds samples (evidence: `README.md`)
- Moving average → QRS detector: filters signal (evidence: `README.md`)
- Bandpass filter → QRS detector: filters signal (evidence: `README.md`)
- QRS detector → RR calculator: provides peaks (evidence: `README.md`)
- RR calculator → Rate classifier: provides heart rate (evidence: `README.md`)
- Rate classifier → Display outputs: provides class (evidence: `README.md`)
- ECG top entity → DE1-SoC board: targets (evidence: `README.md`)
- ROM generation → Demo ECG memory: generates memory (evidence: `README.md`)
- Record download → PhysioNet: downloads records (evidence: `README.md`)
- Record download → MIT-BIH records: obtains records (evidence: `README.md`)
- MIT-BIH records → Vector generation: provides data (evidence: `README.md`)
- Vector generation → RTL batch simulation: supplies test vectors (evidence: `README.md`)
- RTL batch simulation → Detection comparison: writes detections (evidence: `README.md`)
- Detection comparison → Protocol reports: supplies counts (evidence: `README.md`)
- RTL batch simulation → Rate validation: validates classifier (evidence: `README.md`)
- RTL batch simulation → BPM agreement: supplies hardware rates (evidence: `README.md`)
- Vector generation → RTL emulation: supplies vectors (evidence: `README.md`)
- RTL emulation → RTL batch simulation: checks RTL output (evidence: `README.md`)
- Vector generation → Filter ablation: supplies vectors (evidence: `README.md`)
- Vector generation → Parameter studies: supplies vectors (evidence: `README.md`)
