This lab demonstrates how to acquire and process signals using an all‐in‐one MCA (Multi‐Channel Analyzer) IP core featuring trapezoidal filters for both fast triggering and slow energy measurement. The block also includes baseline restoration, optional deconvolution for exponential signals, and a built‐in histogramming interface.


1. Overview

MCA Block in Sci‐Compiler

The MCA HLS block integrates every stage needed for pulse processing:

  • Trigger Trapezoid: A fast trapezoidal filter to detect pulses quickly.
  • Energy Trapezoid: A slower trapezoidal filter to measure signal energy.
  • Baseline Restorer: Maintains a stable baseline by averaging the signal.
  • Deconvolution: Corrects for the exponential decay typically found in detector signals (e.g., HPGe).
  • Gain & Offset: Allows digital scaling and offset correction.
  • Output: The block provides a final ENERGY value (32 bits) and a TRIGGER signal.

No separate blocks (pileup rejectors, baseline calculators, etc.) are required. You simply feed the DATA_IN from an ADC source, configure the trapezoid parameters, and start collecting pulses in the Spectrum module.


2. Block Diagram

Below is the MCA block diagram in Sci‐Compiler, along with the register file that sets all relevant parameters:

Block Diagram
Block Diagram

Key Inputs

  • DATA_IN (16 bits): Raw ADC data.
  • POLARITY (1 bit): 1 for positive pulses, 0 for negative pulses.
  • OFFSET (32 bits): Digital offset added/subtracted post‐polarity inversion.
  • THRS (26 bits): Threshold for triggering on the Trigger Trapezoid.
  • TRIG_K, TRIG_M (16 bits each): Peaking time and flat‐top length for the Trigger Trapezoid.
  • TRAP_K, TRAP_M (16 bits each): Peaking time and flat‐top length for the Energy Trapezoid.
  • DECONV_M (24 bits): Deconvolution coefficient based on detector decay time (tau).
  • GAIN (24 bits): Scaling factor for the final energy readout.
  • BL_LEN (4 bits): Sets the moving average length (2^BL_LEN) for baseline restoration.
  • BL_INIB (16 bits): Number of samples after a trigger in which the baseline update is inhibited.
  • SAMPLE_POS (16 bits): Where (in samples) to measure the trapezoid peak after the trigger.

Key Outputs

  • ENERGY (32 bits): Measured energy from the trapezoidal filter.
  • ENERGY DV (1 bit): Strobe (Data Valid) when a new energy value is available.
  • TRIGGER (1 bit): Trigger output (also handy for timestamping).
  • BL_HOLD (1 bit): Indicates the baseline restorer is locked out during the pulse.
  • TRAP_MON, TRAP‐BL_MON, BL_MON, etc.: Monitoring waveforms for diagnostic use.

Note: The MCA does not implement pileup rejection. If needed, build it around ENERGY DV to measure time intervals between consecutive triggers.


3. Typical Settings for a 50µs Exponential Input

For a 50 µs exponential decay input, typical register values might include:

Settings for 50µs Exponential
Settings for 50µs Exponential

  • DECONV_M is derived from
    \[{DECONV_M} \approx \lfloor 256 / (e^{(T_{clk}/\tau)} - 1)\rfloor\]
    where \(\tau\) is 50 µs, \(T_{clk}\) is the acquisition clock period (e.g., 8 ns).
  • TRAP_K and TRAP_M set the shaping time + flat top.
  • BL_INIB is typically at least 2 × (TRAP_K + TRAP_M) to avoid baseline corruption during long pulses.

Every time you change any parameter of the MCA block you MUST set the RUN_CFG register to 0, set the parameters and than set the RUN_CFG register to 1. This is mandatory to avoid any issue (instability with trigger and energy trapezoidal) with the MCA block.


4. Oscilloscope Signals

  1. Channel 1 (Blue): Input Signal (raw or offset‐adjusted).
  2. Channel 2 (Green): Trigger Trapezoid. is the fast trapezoid for trigger.
  3. Channel 3 (Cyan): Energy Trapezoid. is the energy trapezoid.
  4. Channel 4 (Magenta): Energy Trapezoid Minus Baseline.

The digital lines are,in order:

  1. Trigger
  2. Sampling point (energy measurement instant)
  3. Baseline Inhibit (baseline restorer lockout)
  • The “digital lines” show when the system triggers, the sample is taken, and the baseline is inhibited.

Oscilloscope signals
Oscilloscope signals

Zoom on Trigger Trapezoid

Zoom trapezio del trigger
Zoom trapezio del trigger

Here you can see how the trapezoid quickly rises, crosses threshold, and fires the Trigger output.


5. Energy Spectrum

After the MCA block detects and processes pulses, it outputs an ENERGY value that can be sent to a Spectrum module for histogramming:

Spettro CO-60
Spettro CO-60

Here, we see a Co‐60 spectrum with two main peaks near ~3000 and ~3500 in the channel axis (representing the 1.17 MeV and 1.33 MeV gamma lines, respectively). The horizontal axis shows the digital “channel” of the integrated energy, and the vertical axis shows counts (number of pulses) in each channel.


6. Key Internal Parameters

  • Trigger Trapezoid
    Defined by \(TRIG_K\) (peaking time) and \(TRIG_M\) (peaking + flat top). Produces a fast‐rising trapezoid for quick detection.

  • Energy Trapezoid
    Defined by \(TRAP_K\) (peaking time) and \(TRAP_M\) (peaking + flat top). Slower shaping for accurate amplitude measurement.

  • Deconvolution ((DECONV_M))
    Reduces exponential tail by applying a digital transform. Properly set this to match the detector’s decay constant.

  • Baseline Restorer
    A moving average of length \(2^{BL_LEN}\) calculates the baseline. The system ignores pulses for \(BL_INIB\) samples after a trigger to avoid corruption.

  • Energy Readout
    Sampled at \(SAMPLEPOS\) (in clock cycles after the trigger). A typical setting might be: \[ \text{Sample Position} \approx TRAP_K + 0.8 \times (\text{flat top length}). \]

7. Achitecture of the MCA IP Block

MCA IP is implemented using High-Level Synthesis (HLS) The code implements trapezoidal filtering, baseline restoration, and energy sampling (PHA chain). We can represent this design conceptually with a block diagram, then explain how each stage processes the incoming samples.


7.1. Block Diagram

Below is a simple diagram illustrating the data flow among the main functions:

    flowchart LR
    A["adc_data"] --> B[/"HLSDPP_trapezio (Trapezoidal Filter)"/]
    B -->|i_trap| C[/"HLSDPP_baseline_restorer (Baseline Restorer)"/]
    C -->|i_baseline_out, i_baseline_hold| D["HLSDPP_energysampler (Energy Sampler)"]
    D -->|trap_minus_baseline , energy , timestamp | E["Outputs / Next Stage"]
    A -->F["fast trigger"]
    F -->|trigger_out| D
    F -->|trigger_out| C
  

Key Functions / Blocks:

  1. HLSDPP_trapezio:

    • Performs trapezoidal filtering on the incoming ADC samples to produce a smoothed or shaped signal (i_trap).
    • Accepts various parameters (e_k, e_m, e_MDec, e_G) used for the trapezoid lengths, multipliers, and scaling.
    • Outputs a trigger signal (trig_to_energy) indicating when a valid pulse is detected.
  2. HLSDPP_baseline_restorer:

    • Estimates and updates the baseline in real-time from the trapezoidal output (i_trap).
    • Holds the baseline constant if a trigger is active or during a “dead time” period.
    • Outputs the current baseline estimate (i_baseline_out) and a hold flag (i_baseline_hold).
  3. HLSDPP_energysampler:

    • Subtracts the baseline from the trapezoidal output to get the net pulse amplitude (trap_minus_baseline).
    • Provides the final “energy” value that can be stored or processed further.
    • Manages timing/pileup rejection (sample_delay, pileup_inib) and outputs a strobe (i_energy_strobe) plus a timestamp (i_timestamp_out).

7.2. Mathematical Explanation of the Trapezoidal Filter & Baseline Restoration

7.2.1 Trapezoidal Filtering (HLSDPP_trapezio)

  1. Delay and Subtraction
    The code maintains internal circular buffers (delay1, delay2) of size \( k \) and \( m \). At each new sample \( x[n] \):

    • It computes an intermediate difference \( s_1(n) = x[n] - x[n - k] \).
    • Then a second difference \( s_2(n) = s_1(n) - s_1(n - m) \).

    Conceptually: \[ s_1(n) = x[n] - x[n - k] \\ s_2(n) = s_1(n) - s_1(n - m) \]

  2. Accumulations
    The partial sums \( \text{acc1}, \text{acc2} \) integrate these differences over time: \[ \text{acc1}(n) = \text{acc1}(n-1) + s_2(n) \\ \text{acc2}(n) = \text{acc2}(n-1) + \bigl((\text{acc1}(n) « 8) + M \times s_2(n)\bigr) \] Then the final trapezoidal signal \( s_4(n) \) is scaled and offset (by \( G \)) before being output:

    \[ \text{trapezoid}(n) = \frac{\text{acc2}(n) » 24 \times G}{2^{16}} . \]

  3. Trigger Logic
    The function also passes a trigger signal (trigger_sig) through a small pipeline for alignment, producing a trigger_out used by subsequent stages.

7.2.2 Baseline Restoration (HLSDPP_baseline_restorer)

The trapezoidal output often exhibits a “DC” offset or drift. The baseline restorer:

  1. Maintains a moving sum (\( \text{BL_ACCUMULATOR}\)) of trapezoidal samples in a circular buffer.
  2. Subtracts the oldest sample in the buffer when a new sample arrives to keep a running total of \( \text{baseline_len} \) samples: \[ \text{BL_ACCUMULATOR}(n) = \text{BL_ACCUMULATOR}(n - 1) + \bigl(t(n) - t(n - \text{baseline_len})\bigr) \]
  3. The output baseline is this accumulator divided by \( 2^{\text{baseline_len}} \), effectively computing an average over the specified length: \[ \text{baseline_out}(n) = \frac{\text{BL_ACCUMULATOR}(n)}{2^{\text{baseline_len}}} \]
  4. If a trigger arrives, it temporarily holds the baseline constant, preventing rapid updates during pulses or dead time.

7.2.3 Energy Sampler (HLSDPP_energysampler)

Once we have the trapezoidal output and baseline estimate:

  1. Pulse Subtraction:
    \[ \text{trap_minus_baseline}(n) = \text{trapezoidal}(n) - \text{baseline}(n) \]
  2. Timing and Pileup Rejection:
    A small state machine ensures we only latch the final amplitude at the appropriate delay (\( e\_sample\_delay \)) after the trigger, and also handles multiple pulses that might overlap (pileup rejection).
  3. Energy Output:
    The final amplitude becomes the “energy” measurement. A strobe (energy_strobe) indicates valid data, and timestamp logs the moment the measurement was taken.

7.3 Filter Summary

This HLS code implements a trapezoidal filter for pulse shaping, baseline restoration for drift correction, and an energy sampler for extracting a final measurement akin to a Multichannel Analyzer (MCA) approach. By combining these stages:

  1. Trapezoidal Filter: Shapes the input pulse to reduce noise and highlight the region of interest.
  2. Baseline Restorer: Maintains a stable reference level.
  3. Energy Sampler: Captures the net pulse amplitude, performing timing/pileup checks.

The result is a robust digital pulse-processing chain suitable for high-rate radiation detection and spectroscopy.