HLS
Block Preview

Introduction

The MCA HLS block implements a complete digital pulse processing chain for Multi-Channel Analyzer applications. It combines four key processing stages in a single optimized HLS core:

  1. Fast Trapezoidal Trigger: Derivative-based trigger using a short trapezoidal filter with peak detection
  2. Slow Trapezoidal Shaper: High-resolution energy measurement with integrated deconvolution
  3. Baseline Restorer: Moving average baseline calculation with trigger-based hold
  4. Energy Sampler: Samples the trapezoidal output at the flat-top for energy measurement

The block uses Xilinx HLS for efficient FPGA implementation, achieving II=1 (one sample per clock cycle) throughput.

Pin Description

DATA_IN Input 16 bit BIT VECTOR
16-bit input signal from the ADC. Connected to the preamplifier output.
Default: Must be connected
POLARITY Input 1 bit BIT

Signal polarity selection.

  • 1: Positive polarity (signal increases on pulse)
  • 0: Negative polarity (signal inverted internally)
Default: 1
OFFSET Input 16 bit BIT VECTOR
16-bit digital offset added to the input signal. Used for DC level adjustment.
Default: 0
THRS Input 32 bit BIT VECTOR
32-bit trigger threshold. Applied to the derivative of the fast trapezoidal output. Higher values reduce noise triggers but may miss small pulses.
Default: 256
TRIG_K Input 16 bit BIT VECTOR
16-bit fast trapezoidal peaking time (rise time in clock cycles). Shorter values give faster trigger response. Typical range: 4-32 samples.
Default: 6
TRIG_M Input 16 bit BIT VECTOR
16-bit fast trapezoidal total shaping parameter. Must be >= TRIG_K. Flat-top = TRIG_M - TRIG_K. Typical range: 8-64 samples.
Default: 8
TRAP_K Input 16 bit BIT VECTOR
16-bit slow trapezoidal peaking time (rise time in clock cycles). Longer values provide better noise filtering. Typical range: 64-2048 samples.
Default: 256
TRAP_M Input 16 bit BIT VECTOR
16-bit slow trapezoidal total shaping parameter. Must be >= TRAP_K. Flat-top = TRAP_M - TRAP_K. Should accommodate charge collection time variations.
Default: 266
DECONV_M Input 24 bit BIT VECTOR
24-bit deconvolution coefficient for pole-zero cancellation. Calculated as: M = int(256 / (exp(Ts/tau) - 1)) where Ts is sampling period and tau is preamplifier decay time. Shared between trigger and energy trapezoids.
Default: 31872
TRAP_GAIN Input 24 bit BIT VECTOR
24-bit gain coefficient for the slow trapezoidal output. 16-bit fractional part (Q8.16 format). Default 0x010000 = gain of 1.0.
Default: 65536
BL_LEN Input 4 bit BIT VECTOR
4-bit baseline averaging length exponent. Baseline window = 2^BL_LEN samples. Larger values provide more stable baseline but slower response. Example: BL_LEN=8 means 256-sample average.
Default: 8
BL_INIB Input 16 bit BIT VECTOR
16-bit baseline inhibit time in clock cycles. After each trigger, baseline calculation is frozen for this duration. Should be longer than pulse duration to prevent contamination.
Default: 4096
SAMPLE_POS Input 16 bit BIT VECTOR
16-bit energy sampling position in clock cycles after trigger. Optimal value: TRAP_K + (TRAP_M - TRAP_K) / 2. Should sample at the center of the flat-top region.
Default: 264
TIMETAG Input 64 bit BIT VECTOR
64-bit timestamp input. Captured when energy is sampled and output on TIMESTAMP.
RUN_CFG Input 1 bit BIT
TR_RESET Input 1 bit BIT
EXT_TRIGGER Input 1 bit BIT
EXT_TRIGGER_SELECTOR Input 4 bit BIT VECTOR
CLK Input 1 bit BIT
System clock input. All internal operations are synchronous to the rising edge.
Default: Default Board Clock
RESET Input 1 bit BIT
Synchronous reset. Clears all internal delay lines, accumulators, and state.
Default: Default Board Reset
DATA_OUT Output 16 bit BIT VECTOR
16-bit delayed input signal output. Delayed by (TRIG_K + TRIG_M) samples for alignment monitoring.
ENERGY Output 32 bit BIT VECTOR
32-bit energy output. Valid when ENERGY_DV is high. Represents baseline-subtracted trapezoidal amplitude at sampling position.
ENERGY_STROBE Output 1 bit BIT
TRIGGER_OUT Output 1 bit BIT
BASELINE_HOLD Output 1 bit BIT
TIMESTAMP Output 64 bit BIT VECTOR
64-bit timestamp output. Captured value of TIMETAG input at trigger time.
TR_INHIBIT_TRIGGER Output 1 bit BIT
TRIGGER_DELTA_MON Output 32 bit BIT VECTOR
32-bit trigger derivative monitor. Shows the difference signal used for threshold comparison. Useful for threshold optimization.
TRIGGER_TRAP_MON Output 32 bit BIT VECTOR
32-bit fast trapezoidal output monitor. Shows the output of the trigger trapezoidal filter.
TRAP_MON Output 32 bit BIT VECTOR
32-bit slow trapezoidal output monitor. Shows the raw energy trapezoidal output before baseline subtraction.
TRAP_BL_MON Output 32 bit BIT VECTOR
BL_MON Output 32 bit BIT VECTOR
32-bit baseline monitor. Shows the current baseline value calculated by the baseline restorer.
RUN(1) CFG(0) 1 bit

Run/Configure mode control.

  • 0: Configuration mode - parameters can be changed, processing reset
  • 1: Run mode - active processing
RESET(1) RUN(0) 1 bit
Trigger reset control. When set to 1, inhibits trigger generation for baseline settling. Useful after parameter changes or baseline disturbances.
EXT_TRIG 1 bit
External trigger input. Used according to EXT_SEL mode selection.
EXT_SEL 4 bit

4-bit external trigger mode selector.

  • 0: Internal trigger only
  • 1: External trigger only
  • 2: Internal AND External
  • 3: Internal AND NOT External
ENERGY_DV 1 bit
Energy data valid strobe. HIGH for one clock cycle when a new energy value is available.
TRIGGER 1 bit
Trigger output pulse. HIGH for one clock cycle when a valid trigger is detected.
BL_HOLD 1 bit
Baseline hold indicator. HIGH when baseline calculation is inhibited (during pulse processing).
TR_TR 1 bit
Trigger inhibit indicator. HIGH when trigger is inhibited due to TR_RESET or baseline settling.
TRAP-BL_MON 32 bit
32-bit baseline-subtracted trapezoidal monitor. Shows (TRAP - BASELINE) for energy measurement verification.

Properties

Property window

Max shaper samples PRE_LEN

This parameters configure the number of samples used by the trapezoidal. It impact of the RAM memory usage in the FPGA

Maximum number of samples supported by the slow trapezoidal delay lines. Determines the maximum values for TRAP_K and TRAP_M parameters. Impacts FPGA RAM usage. Available values: 128, 256, 512, 1024, 2048, 4096, 8192, 16384, default 2048.

Default: 2048

Options: 128 256 512 1024 2048 4096 8192 16384

Max trigger shaper samples TRIGGER_PRE_LEN

This parameters configure the number of samples used by the trigger trapezoidal. It impact of the RAM memory usage in the FPGA

Maximum number of samples supported by the fast trapezoidal delay lines. Determines the maximum values for TRIG_K and TRIG_M parameters. Impacts FPGA RAM usage. Available values: 128, 256, 512, 1024, 2048, 4096, 8192, 16384, default 2048.

Default: 2048

Options: 128 256 512 1024 2048 4096 8192 16384

Max baseline samples BASELINE_PRE_LEN
Maximum number of samples supported by the baseline moving average. Determines the maximum value for 2^BL_LEN. Impacts FPGA RAM usage. Available values: 128, 256, 512, 1024, 2048, 4096, 8192, 16384, default 2048.

Default: 2048

Options: 128 256 512 1024 2048 4096 8192 16384

Usage

Signal Flow Diagram

MCA diagram


Processing Stages Detail

Stage 1: Fast Trapezoidal Trigger

The fast trapezoidal filter generates a trigger signal when a pulse is detected. It uses:

  • Short peaking time (TRIG_K) for fast response
  • Short flat-top (TRIG_M) for quick detection
  • Derivative-based threshold comparison

The trigger is generated when the derivative of the trapezoidal output crosses the THRS threshold and then the signal reaches its peak (derivative crosses zero from positive to negative).

Advantages of derivative-based triggering:

  • Does not require prior baseline calculation
  • Immune to baseline shifts and DC offset
  • Fast response time

Stage 2: Slow Trapezoidal Shaper

The slow trapezoidal filter provides high-resolution energy measurement:

  • Longer peaking time (TRAP_K) for better noise filtering
  • Appropriate flat-top (TRAP_M) for ballistic deficit compensation
  • Integrated deconvolution (pole-zero cancellation) using DECONV_M
  • Output gain adjustment with TRAP_GAIN

Trapezoidal Algorithm (Jordanov-Knoll):

$$ d^k[n] = x[n] - x[n-k] $$

$$ d^{k,l}[n] = d^k[n] - d^k[n-l] $$

$$ p[n] = p[n-1] + d^{k,l}[n] $$

$$ r[n] = p[n] + M \cdot d^{k,l}[n] $$

$$ s[n] = s[n-1] + r[n] $$

where:

  • $k$ = peaking time (TRAP_K)
  • $l$ = k + flat-top (TRAP_M)
  • $M$ = deconvolution coefficient (DECONV_M)

Stage 3: Baseline Restorer

Calculates the DC baseline of the trapezoidal output using a moving average:

$$ \text{baseline}[n] = \frac{1}{2^{\text{BL_LEN}}} \sum_{i=0}^{2^{\text{BL_LEN}}-1} \text{trap}[n-i] $$

When a trigger occurs, the baseline calculation is held (frozen) for BL_INIB clock cycles to prevent pulse contamination.


Stage 4: Energy Sampler

Samples the baseline-subtracted trapezoidal signal at the optimal position:

$$ \text{energy} = \text{trap}[\text{trigger_time} + \text{SAMPLE_POS}] - \text{baseline} $$

The SAMPLE_POS parameter should be set to sample at the center of the flat-top region:

$$ \text{SAMPLE_POS} = \text{TRAP_K} + \frac{\text{TRAP_M} - \text{TRAP_K}}{2} $$


Calculating the Deconvolution Coefficient (DECONV_M)

The deconvolution coefficient removes the exponential tail from preamplifier signals:

$$ M = \frac{256}{e^{T_s / \tau} - 1} $$

where:

  • $T_s$ is the sampling period (1 / clock_frequency)
  • $\tau$ is the preamplifier decay time constant
  • The factor 256 comes from the internal fixed-point scaling (8-bit shift)

Example calculation (Python):

python
  import math

clock_freq = 125e6      # 125 MHz
tau = 50e-6             # 50 µs preamplifier decay time

Ts = 1.0 / clock_freq   # 8 ns
M = int(256 / (math.exp(Ts / tau) - 1))
# Result: M = 1599744 (0x186A00)
  

For typical systems:

  • f_clock = 125 MHz, τ = 50 µs: DECONV_M ≈ 0x186A00
  • f_clock = 250 MHz, τ = 100 µs: DECONV_M ≈ 0x18A7E0

Input Delay Line

The input signal to the slow trapezoidal shaper is delayed by (TRIG_K + TRIG_M) samples. This ensures that the energy measurement window is properly aligned with the trigger timing:

  Trigger fires at time T when pulse peak is detected
      |
      v
[----TRIG_K+TRIG_M delay----][----TRAP_K rise----][---flat-top---][----fall----]
                             ^
                             |
                        Slow trap starts processing here
  

External Trigger Modes

The EXT_SEL input controls trigger source selection:

EXT_SEL Trigger Source
0 Internal trigger only
1 External trigger only (EXT_TRIG)
2 Internal AND External (coincidence)
3 Internal AND NOT External (anti-coincidence)

Timing and Latency

  • Total processing latency: 13 clock cycles from input to energy output
  • Throughput: 1 sample per clock cycle (II=1)
  • Trigger to energy delay: Configurable via SAMPLE_POS

Typical Applications

  • Gamma-ray spectroscopy with HPGe detectors
  • X-ray fluorescence (XRF) analysis
  • Nuclear physics experiments
  • Portable radiation detection systems
  • Multi-detector coincidence systems