Xilinx
Block Preview

Introduction

The block computes, on every clock, the sliding-window cross correlation

$$ R[n] = \sum_{i=0}^{\text{WIN_LEN}-1} X[n-i] \cdot Y[n-i-\text{LAG}] $$

using a moving-sum implementation. Only one MAC is required regardless of window length: at each clock a new product X[n] * Y[n-LAG] is added to the accumulator and the product that leaves the window (WIN_LEN clocks earlier) is subtracted.

Both LAG and WIN_LEN are runtime input pins so the same synthesized IP can serve many use cases. Their maximum values (LagMax, WindowMax) are compile-time properties that size the two internal BRAMs (Y delay line and product ring buffer).

Pin Description

X_IN Input InputSize bit BIT VECTOR
First signed input sample. Width = InputSize.
Default: Must be connected
Y_IN Input InputSize bit BIT VECTOR
Second signed input sample. Width = InputSize.
Default: Must be connected
LAG Input 9 bit BIT VECTOR
Runtime delay (samples) applied to Y before the multiplication. Range: 0 .. LagMax. Width = ceil(log2(LagMax+1)) bits, unsigned. Treat as ap_stable: change slowly compared to the sample rate to avoid transient artefacts in R_OUT.
Default: Must be connected
WIN_LEN Input 11 bit BIT VECTOR
Runtime accumulation window length (samples). Range: 1 .. WindowMax. Width = ceil(log2(WindowMax+1)) bits, unsigned. Treat as ap_stable.
Default: Must be connected
RESET Input 1 bit BIT
Synchronous reset of the accumulator. Active high.
Default: Default Board Reset
CLK Input 1 bit BIT
Clock. All logic operates on the rising edge.
Default: Default Board Clock
R_OUT Output AccumBits bit BIT VECTOR
Current sliding-sum cross correlation value. Width = AccumBits, signed.

Properties

Property window

Input Bit Width InputSize

Bit width of the signed X and Y input samples

Bit width of X and Y (signed). 4..32 bits. The internal product width is 2*InputSize bits.

Default: 16

Range: 4 – 32

Max Lag (LAG_MAX) LagMax

Maximum runtime value of LAG. Sizes the Y delay line (BRAM).

Maximum runtime value of the LAG pin. Sizes the Y delay-line BRAM to LagMax + 1 entries of InputSize bits. Trade-off: larger LagMax allows more delay flexibility but consumes more BRAM.

Default: 256

Options: 16 32 64 128 256 512 1024 2048 4096

Max Window (WIN_MAX) WindowMax

Maximum runtime value of WIN_LEN. Sizes the product ring buffer (BRAM).

Maximum runtime value of the WIN_LEN pin. Sizes the product ring-buffer BRAM to WindowMax entries of 2*InputSize bits. This is normally the biggest BRAM in the IP.

Default: 1024

Options: 64 128 256 512 1024 2048 4096 8192 16384

Accumulator Bits AccumBits

Bit width of the R_OUT accumulator (signed).

Bit width of the R_OUT accumulator (signed). Must be wide enough to hold the worst-case sum: AccumBits >= 2*InputSize + ceil(log2(WindowMax)) to prevent overflow.

Default: 48

Range: 16 – 96

Functional description

Sliding-sum update

The classic direct-form cross correlation requires WIN_LEN MACs to compute every output sample. The moving-sum variant folds it to a single MAC per clock:

$$ R[n] = R[n-1] + X[n],Y[n-\text{LAG}] - X[n-W],Y[n-W-\text{LAG}] $$

where $W = \text{WIN_LEN}$. The two subtractions and the new product are independent, so the design pipelines to II = 1.

Memory

  • Y delay line: BRAM of depth LagMax + 1, holds the last LagMax + 1 samples of Y so Y[n - LAG] can be read at any runtime lag.
  • Product ring buffer: BRAM of depth WindowMax, holds the last WindowMax products so the “old” product that must be removed from the window can be read at any runtime WIN_LEN.

The accumulator is a single register of AccumBits bits.

Warm-up

For the first WIN_LEN samples after a reset the ring buffer holds zeros (BRAM is zero-initialised), so R_OUT grows monotonically until the window is full. After that, the sliding sum tracks the current window exactly.

Reset

A high RESET on any clock clears the accumulator to zero (but does not clear the delay lines). Typical usage: hold RESET high while startup logic brings LAG and WIN_LEN to their intended values, then release.