HLS
Block Preview

Introduction

The Trapezoidal Shaper FP block implements a recursive digital trapezoidal filter based on the Jordanov-Knoll algorithm (1994). This filter transforms exponentially decaying signals from charge-sensitive preamplifiers into trapezoidal waveforms, which are optimal for pulse-height analysis.

The block includes integrated pole-zero compensation (deconvolution) using the M coefficient, eliminating the need for a separate deconvolution stage.

This is a floating-point implementation that provides high accuracy for the deconvolution coefficient M and the gain G.

Pin Description

IN Input 16 bit BIT VECTOR
16-bit input signal from the ADC. Typically connected to the preamplifier output (possibly via a baseline restorer).
Default: Must be connected
PK Input 16 bit BIT VECTOR
16-bit peaking time parameter (k). Specifies the rise time of the trapezoidal output in clock cycles. Larger values provide better noise rejection but slower response. Default: 256 (0x0100).
Default: 256
FT Input 16 bit BIT VECTOR
16-bit flat-top time parameter. Specifies the duration of the flat-top in clock cycles. Should be set to accommodate charge collection time variations. Default: 10 (0x000A).
Default: 10
M Input 32 bit BIT VECTOR
32-bit floating-point deconvolution coefficient. Calculated as: M = 1 / (exp(Ts/tau) - 1) where Ts is sampling period and tau is preamplifier decay time. IEEE 754 single-precision format.
G Input 32 bit BIT VECTOR
32-bit floating-point gain coefficient. Scales the output amplitude for optimal dynamic range. IEEE 754 single-precision format. Typical starting value: 1.0 (0x3F800000).
BASELINE Input 16 bit BIT VECTOR
16-bit baseline value to subtract from input. Should be the DC level of the input signal. Default: 0.
Default: 0
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
SHAPER_OUT Output 16 bit BIT VECTOR
16-bit shaped output signal. Contains the trapezoidal waveform. The amplitude at the flat-top is proportional to the input pulse energy.
DV Output 1 bit BIT
Data valid output. HIGH when the shaper is actively processing data.

Properties

Property window

Shaping Size ShapingSize

Set the maximum number of samples supported by the MCA. This will affect the trapezoidal shaper and the baseline restorer

Maximum number of samples supported by the delay lines. Determines the maximum values for PK and FT parameters. Must be larger than max(PK, PK+FT). Available values: 1024, default 1024.

Default: 1024

Options: 1024

Usage

Filter Structure

Trapezoidal filter block diagram

The figure shows the recursive structure of the trapezoidal filter:

  • RS1: First running sum stage with delay k (peaking time)
  • RS2: Second running sum stage with delay l (flat-top time)
  • DEC: Deconvolution stage with coefficient M and accumulator
  • ACC: Final accumulator for output generation

Algorithm Overview

The trapezoidal shaper processes the input signal through four stages:

Stage 1 - First Difference (d^k)

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

This implements a moving-average filter (boxcar) with window size k. The parameter k is the peaking time in clock cycles.

Stage 2 - Second Difference (d^{k,l})

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

This creates the flat-top portion of the trapezoid. The parameter l = k + FT, where FT is the flat-top duration in clock cycles.

Stage 3 - Deconvolution with M coefficient

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

The M coefficient performs pole-zero cancellation of the preamplifier decay.

Stage 4 - Final Accumulation with Gain

$$ s[n] = s[n-1] + G \cdot r[n] $$

The gain G compensates for the amplitude reduction and provides output scaling.


Calculating the M Coefficient

The deconvolution coefficient M must be matched to the preamplifier decay time constant τ:

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

where:

  • $T_s$ is the sampling period (1 / clock_frequency)
  • $\tau$ is the preamplifier decay time constant

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 = 1.0 / (math.exp(Ts / tau) - 1)
# Result: M ≈ 6249.0
  

For typical systems:

  • f_clock = 65 MHz, τ = 2 µs: M ≈ 33
  • f_clock = 125 MHz, τ = 50 µs: M ≈ 6249
  • f_clock = 250 MHz, τ = 100 µs: M ≈ 24999

Calculating the Gain G

The gain G is typically set to normalize the output amplitude:

$$ G = \frac{\text{desired_output_scale}}{k} $$

A common starting value is G = 1.0, then adjusted empirically for optimal dynamic range.


Trapezoidal Shape Parameters

The output waveform shape is determined by:

  • Rise time: k clock cycles (set by PK input)
  • Flat-top duration: FT clock cycles (set by FT input)
  • Fall time: k clock cycles (symmetric with rise time)

Total shaping time = 2k + FT clock cycles


Advantages of Trapezoidal Shaping

  1. Noise Reduction: Optimal signal-to-noise ratio for both series and parallel noise components
  2. Ballistic Deficit Control: Adjustable flat-top compensates for charge collection time variations
  3. High Count Rate: Faster shaping times compared to Gaussian shapers
  4. Pile-up Rejection: Well-defined pulse boundaries simplify pile-up detection

Timing and Latency

  • Processing latency: 13 clock cycles from input to output
  • Throughput: 1 sample per clock cycle (fully pipelined)

Typical Applications

  • Gamma-ray spectroscopy with HPGe detectors
  • X-ray spectroscopy with SDD detectors
  • Multi-Channel Analyzer (MCA) front-end
  • Nuclear physics pulse processing