---
title: High-Speed FPGA Photon Counter for Time-of-Flight Measurements on Red Pitaya
description: Real-time 250 MHz FPGA photon counter & time-of-flight system on Red Pitaya developed by Johns Hopkins University researcher Dr. Mangesh Bhattarai.
image: https://content.redpitaya.com/hubfs/blog%20featured%20image%20-%202026-10-28T120617.627.jpg
---

[![Red Pitaya](https://content.redpitaya.com/hubfs/raw_assets/public/Red_Pitaya_November_2021/images/redpitaya-logo-des.svg "Red Pitaya")](https://redpitaya.com/)

[![Red Pitaya](https://content.redpitaya.com/hubfs/raw_assets/public/Red_Pitaya_November_2021/images/redpitaya-logo.svg "Red Pitaya")](https://redpitaya.com/)

- Products

    - [STEMlab 125-14 Gen 2](https://redpitaya.com/stemlab-125-14-gen2/)

          - [STEMlab 125-14](https://redpitaya.com/stemlab-125-14/)
          - [SIGNALlab 250-12](https://redpitaya.com/signallab-250-12/)
          - [SDRlab 122-16](https://redpitaya.com/sdrlab-122-16/)
          - [STEMlab TI (Texas Instruments)](https://redpitaya.com/stemlab-ti-texas-instruments/)
          - [Multi-channel Solutions](https://redpitaya.com/multi-channel-solutions/)
          - [Accessories](https://redpitaya.com/accessories/)
- [Applications](https://redpitaya.com/applications/)
- Documentation

    - [Technical Documentation](https://redpitaya.com/documentation/)
    - [Teaching materials](https://redpitaya.com/teaching-materials/)
    - [Student projects](https://redpitaya.com/student-projects/)
    - [User forum](https://forum.redpitaya.com/)
- [About](https://redpitaya.com/about-us/)

    - [History](https://redpitaya.com/history/)

          - [Distributors](https://redpitaya.com/distibutors-red-pitaya/)
- [Blog](https://content.redpitaya.com/blog)

[Shop](https://redpitaya.com/shop/)

- [ACADEMIA](https://redpitaya.com/academia/)
- [RADIO AMATEURS](https://redpitaya.com/radio-amateurs/)

- [Home](https://redpitaya.com/)
- Products

    - [STEMlab 125-10](https://redpitaya.com/stemlab-125-10/)

          - [STEMlab 125-14](https://redpitaya.com/stemlab-125-14/)
          - [SIGNALlab 250-12](https://redpitaya.com/signallab-250-12/)
          - [SDRlab 122-16](https://redpitaya.com/sdrlab-122-16/)
          - [Accessories](https://redpitaya.com/accessories/)
- [Applications](https://redpitaya.com/applications/)
- [Resources](https://redpitaya.com/documentation/)
- [Shop](https://redpitaya.com/shop/)
- [About](https://redpitaya.com/about-us/)
- [Blog](https://content.redpitaya.com/blog)
- [Compare](https://redpitaya.com/compare/)
- [Login / Register](https://redpitaya.com/my-account/)

### Red Pitaya Blog

[Home](https://redpitaya.com) » [Case study](https://content.redpitaya.com/blog/tag/case-study)  »

[Case study](https://content.redpitaya.com/blog/tag/case-study)

# High-Speed FPGA Photon Counter for Time-of-Flight Measurements on Red Pitaya

- Posted by ![Red Pitaya Technical Editorial Team](https://content.redpitaya.com/hubfs/Red-pitaya-fav-ikona.png) [Red Pitaya Technical Editorial Team](https://redpitaya.com/Red-Pitaya-Blog-team/) , November 24, 2026

![](https://content.redpitaya.com/hubfs/blog%20featured%20image%20-%202026-10-28T120617.627.jpg)

High-precision time-of-flight (ToF) experiments and quantum optics rely on ultra-fast, deterministic photon signal discrimination. In research environments—such as atomic, molecular, and optical (AMO) physics labs—capturing low-level signals from photomultiplier tubes (PMTs) requires deterministic, real-time hardware discrimination without missed pulses or dead-time losses.

Developed by [**Dr. Mangesh Bhattarai**](https://github.com/manbhattarai), a Postdoctoral Researcher in the Department of Physics and Astronomy at Johns Hopkins University, this open-source project presents a complete **hardware photon discrimination and counting system** built on the **Red Pitaya STEMlab 125-14** (Xilinx Zynq-7010 SoC) platform.

**Key Takeaways**

- **High-Rate Real-Time Counting:** The module performs high-speed photon counting at an FPGA clock rate of 250 MHz, logging up to 255 counts per 10 µs bin (equivalent to 25.5 Mcps) before the 8-bit bin accumulator overflows.
- **Custom Clock Domain Crossing (CDC):** Employs a custom-designed FIFO buffer to bridge data between the 125 MHz ADC clock and 250 MHz FPGA logic domain seamlessly.
- **Flexible Software Control Plane:** Directly read/write registers over AXI GPIO using provided C drivers (counter\_clock.c) for threshold configuration and bin extraction.
- **In-System Experimental Validation:** Tested and verified in an active atomic physics setup at Johns Hopkins University for laser-triggered time-of-flight photon discrimination.

## Executive Summary: Real-Time ToF Hardware Architecture

The module performs high-speed photon counting in a 250 MHz FPGA clock domain, with an 8-bit counter capable of recording up to 255 events per 10 µs bin (equivalent to 25.5 Mcps before overflow). Built for time-of-flight routines triggered by external pulse sources (e.g., a 10 Hz YAG laser trigger), the system logs hit counts into **3,000 discrete time bins** with a temporal resolution of **10 µs per bin**.

## Core Technical Architecture

- **14-Bit Threshold Discrimination:** Evaluates incoming RF pulse shapes (e.g., negative pulses from PMTs) on RF Input 1 using FPGA-based threshold comparison, with a 14-bit threshold configured via AXI GPIO registers.
- **Dual Clock Domains & Custom FIFO:** To demonstrate system robustness, the FPGA processing fabric runs at **250 MHz**—twice the 125 MHz ADC sampling rate. Data transfer across clock domains is managed by a custom-designed FIFO equipped with AXI GPIO-readable full/empty status flags.
- **AXI GPIO & C Software Plane:** A lightweight C program interfaces with memory-mapped AXI GPIO registers (0x4120\_0000 to 0x4127\_FFFF) to set thresholds, select pulse widths, and retrieve bin counts via an indexed register handshake (Bin\_no address write and Count\_value readback).
- **Hardware Output Monitoring:** Generates real-time diagnostic 3.3V LVCMOS pulses on DIO5\_N upon threshold hits and streams an analog representation of the 3,000-bin histogram via RF Output 1 (DAC OUT1) at ~5.86 MS/s for continuous oscilloscope monitoring.

![blog featured image - 2026-10-28T120503.301](https://content.redpitaya.com/hs-fs/hubfs/blog%20featured%20image%20-%202026-10-28T120503.301.jpg?width=1920&height=1000&name=blog%20featured%20image%20-%202026-10-28T120503.301.jpg)

## Hardware Verification & Performance Metrics

The architecture was validated directly inside an active physics experimental setup at Johns Hopkins University.

| **Specification** | **Benchmark / Hardware Value** |
| --- | --- |
| **FPGA Core Clock** | 250 MHz (Derived from ADC clock) |
| **Maximum Event Counting Rate** | Up to 25.5 Mcps per bin (limited by 8-bit RAM word width: 255 counts / 10 µs bin before overflow) |
| **Bin Resolution & Acquisition Depth** | 3,000 Time Bins @ 10 µs / bin (30 ms total acquisition window) |
| **Signal Thresholding** | 14-bit unsigned threshold comparison logic |
| **Discriminator Output Width** | Configurable: 8 ns, 16 ns, 32 ns, or 64 ns |
| **Target FPGA Hardware** | Red Pitaya STEMlab 125-14 (xc7z010clg400-1) |

**Links & Resources**

- **Source Code & Repository:** [Pulse-Discriminator-Counter on GitHub](https://github.com/manbhattarai/Pulse-Discriminator-Counter)
- **Developer Profile:** [Dr. Mangesh Bhattarai on GitHub](https://github.com/manbhattarai)

 

---

## Frequently Asked Questions: Red Pitaya Photon Counter Hardware

**1. Who developed this project and what is its primary application?**

The system was designed and tested by **Dr. Mangesh Bhattarai**, Postdoctoral Researcher at Johns Hopkins University, for real-time photon signal discrimination and time-of-flight measurements in atomic, molecular, and optical (AMO) physics setups.

**2. Why run the FPGA logic at 250 MHz when the Red Pitaya ADC runs at 125 MHz?**

Operating the FPGA logic fabric at 250 MHz demonstrates asynchronous clock domain crossing (CDC) while operating within the tighter 4.0 ns timing budget of the faster clock domain. A custom asynchronous FIFO transfers the 14-bit ADC sample stream across the 125 MHz ADC clock and the 250 MHz FPGA domain, exposing empty/full status flags over AXI GPIO to manage clock domain crossing safely.

**3. How is time-of-flight data extracted from the Red Pitaya?**

An external trigger signal on DIO4\_P gates the counting sequence across up to 3,000 discrete time bins (10 µs per bin); in the published RTL, acquisition remains enabled while the trigger remains asserted. Upon completion, a C program (counter\_clock.c) queries memory addresses over AXI GPIO to extract bin counts.

### About the Red Pitaya Team

 The Red Pitaya Technical Editorial Team is a cross-functional group of technical communicators and product specialists. By synthesizing insights from our hardware developers and global research partners, we provide verified, high-value content that bridges the gap between open-source innovation and industrial-grade precision.

 Our mission is to make advanced instrumentation accessible to engineers, researchers, and educators worldwide.

##### Categories

- [academia (47)](https://content.redpitaya.com/blog/tag/academia)

##### Recent Posts

- [![What’s New in Red Pitaya OS 3.00: Ubuntu 24.04 LTS, Universal Calibration & Upgraded APIs](https://content.redpitaya.com/hs-fs/hubfs/blog%20featured%20image%20-%202026-11-16T152338.982.jpg?width=767&name=blog%20featured%20image%20-%202026-11-16T152338.982.jpg)](https://content.redpitaya.com/blog/red-pitaya-os-3-00-features-and-update-guide)
  
  [What’s New in Red Pitaya OS 3.00: Ubuntu 24.04 LTS, Universal Calibration & Upgraded APIs](https://content.redpitaya.com/blog/red-pitaya-os-3-00-features-and-update-guide)
  
   November 16, 2026
- [![I Tested Red Pitaya Copilot by Building a Partial Discharge Signal Simulator](https://content.redpitaya.com/hs-fs/hubfs/blog%20featured%20image%20-%202026-11-16T150518.094.jpg?width=767&name=blog%20featured%20image%20-%202026-11-16T150518.094.jpg)](https://content.redpitaya.com/blog/testing-red-pitaya-copilot-partial-discharge-simulator)
  
  [I Tested Red Pitaya Copilot by Building a Partial Discharge Signal Simulator](https://content.redpitaya.com/blog/testing-red-pitaya-copilot-partial-discharge-simulator)
  
   November 16, 2026
- [![STEMlab 125-14 PRO Z7020 Gen 2: The Ultimate Open-Source FPGA Platform for Rapid Prototyping](https://content.redpitaya.com/hs-fs/hubfs/blog%20featured%20image%20-%202026-10-06T145728.288.jpg?width=767&name=blog%20featured%20image%20-%202026-10-06T145728.288.jpg)](https://content.redpitaya.com/blog/stemlab-125-14-pro-z7020-gen2-fpga-prototyping)
  
  [STEMlab 125-14 PRO Z7020 Gen 2: The Ultimate Open-Source FPGA Platform for Rapid Prototyping](https://content.redpitaya.com/blog/stemlab-125-14-pro-z7020-gen2-fpga-prototyping)
  
   November 10, 2026

##### Subscribe to our newsletter

![Red Pitaya](https://content.redpitaya.com/hubfs/raw_assets/public/Red_Pitaya_November_2021/images/redpitaya-logo-wh.svg "Red Pitaya")

An open-source solution for hobbyists, professors,  
 radio amateurs and industrial clients.

**Red Pitaya**  
Velika pot 21,  
5250 Solkan  
Slovenia, Europe  
Phone: +386 30 322 719  
Email: [info@redpitaya.com](mailto:info@redpitaya.com)

**Red Pitaya US**  
TX, Dallas - Downtown Republic Center  
325 N. St. Paul Street  
Suite 3100  
Dallas, Texas, 75202  
United States of America  
IMPORTANT: This address does not accept RMAs  
Phone: (888) 637-2706  
Email: [US.office@redpitaya.com](mailto:US.office@redpitaya.com)

- Customer Service 
    - [Customer Support](https://redpitaya.com/customer-support/)
    - [Shipping & Returns](https://redpitaya.com/shipping-returns/)
    - [Contact us](https://redpitaya.com/contact-us/)
    - [Cookie Policy](https://redpitaya.com/cookie-policy/)
- SLO 
    - [O nas](https://redpitaya.com/o-nas/)
    - [Pogoji poslovanja](https://redpitaya.com/pogoji-poslovanja/)
    - [Politika zasebnosti](https://redpitaya.com/politika-zasebnosti/)
    - [Politika piškotkov](https://redpitaya.com/politika-piskotkov/)

##### Follow Us

<https://www.facebook.com/redpitayaspark/> <https://twitter.com/RedPitayaCom> <https://www.youtube.com/c/RedPitayaTV> <https://www.linkedin.com/company/red-pitaya> <https://www.instagram.com/redpitayacom>

#### Subscribe to our newsletter

Get notified about new SW features & updates, news about latest community projects & events and new Red Pitaya products & discounts

[Subscribe](https://go.redpitaya.com/cs/c/?cta_guid=36ccbdc0-0344-49c4-aa91-aa67cf437c09&signature=AAH58kHkxFYTAKU-ILQzHI1jlrdI_co0RA&placement_guid=a24cb732-1dfb-4d0a-8c52-aa6851ce9102&click=556cfaee-eee4-48e4-95e7-c483a4f78883&hsutk=537e15e740555d2fd6a1c1ad931d2b6f&canon=https%3A%2F%2Fredpitaya.com%2Fabout-us%2F&utm_referrer=https%3A%2F%2Fredpitaya.com%2Fcompare%2F&portal_id=7715357&redirect_url=APefjpGj5Dm9poAAzHFGh4S6pJ-2TvNzBdwZZlfbr7toxfw-epFUtzEHOKToHx0i2TYYr39srj9aSERdntJBh8lJqoSXL-pUF2gwhYvOW6IMm28hQVmhYML2AIbbIRrr3YaoyJkZQ0iRxq-uHlFt66i3_8XpQpXT_M2zF9fS7t0f6hlBjGBJ7X_aXDrhBwXcEAqwoWWleG4uxonSGOR-BBp3tpKcySXYELTGHeGn5Yo61r3xrFvqFP5P6BxVwxTi51_ceW9uBzOMvA1rYz4BsIhLSF8n4bhcHqJTvhibH_laJrjDNdEUUrU&__hstc=72355340.537e15e740555d2fd6a1c1ad931d2b6f.1635738083317.1635738083317.1635746314170.2&__hssc=72355340.5.1635746314170&__hsfp=530052575&contentType=standard-page)

**Red Pitaya**  2025 All Rights Reserved.

- [Privacy Policy](https://redpitaya.com/privacy-policy/)
- [Terms of Use](https://redpitaya.com/terms-of-use/)

```json
{
  "@context" : "https://schema.org",
  "@type" : "BlogPosting",
  "author" : {
    "@type" : "Person",
    "name" : "Red Pitaya Technical Editorial Team",
    "url" : "https://content.redpitaya.com/blog/author/red-pitaya-technical-editorial-team"
  },
  "dateModified" : "2026-11-24T09:00:00.382Z",
  "datePublished" : "2026-11-24T09:00:00.000Z",
  "headline" : "High-Speed FPGA Photon Counter for Time-of-Flight Measurements on Red Pitaya",
  "image" : [ "https://content.redpitaya.com/hubfs/blog%20featured%20image%20-%202026-10-28T120617.627.jpg" ],
  "mainEntityOfPage" : {
    "@id" : "https://content.redpitaya.com/blog/high-speed-fpga-photon-counter-for-time-of-flight-measurements-on-red-pitaya",
    "@type" : "WebPage"
  },
  "publisher" : {
    "@type" : "Organization",
    "logo" : {
      "@type" : "ImageObject",
      "url" : "https://content.redpitaya.com/hubfs/Red-pitaya-logo.jpg"
    },
    "name" : "Red Pitaya d.o.o."
  }
}
```