Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

PCAP - Position Capture

Position capture has the capability to capture anything that is happening on the pos_bus or bit_bus. It listens to ENABLE, GATE and CAPTURE signals, and can capture the value at capture, sum, sum of squared values, min and max.

Fields

NameTypeDescription
ENABLEbit_muxAfter arm, when high start capture, when low disarm
GATEbit_muxAfter enable, only process gated values if high
TRIGbit_muxOn selected edge capture current value and gated data
TRIG_EDGEparam enumWhich edge of capture input signal triggers capture
SHIFT_SUMparam uint 8Shift sum/samples data, use if > 2**32 samples required in sum/average
ACTIVEbit_outData capture in progress
TS_STARText_out timestampTimestamp of first gate high in current capture relative to enable
TS_ENDext_out timestampTimestamp of last gate high +1 in current capture relative to enable
TS_TRIGext_out timestampTimestamp of capture event relative to enable
GATE_DURATIONext_out samplesNumber of gated samples in the current capture
BITS0ext_out bits 0Quadrant 0 of bit_bus
BITS1ext_out bits 1Quadrant 1 of bit_bus
BITS2ext_out bits 2Quadrant 2 of bit_bus
BITS3ext_out bits 3Quadrant 3 of bit_bus
HEALTHread enumWas last capture successful?

Arming

To start off the block an arm signal is required with a write to *PCAP.ARM=. The active signal is raised immediately on ARM, and dropped either on *PCAP.DISARM:

Arming and soft disarm

Or on the falling edge of ENABLE:

Arming and hard disarm

Capturing fields

Capturing fields is done by specifying a series of WRITE addresses. These are made up of a mode in the bottom 4 bits, and an index in the 6 bits above them. Indexes < 32 refer to entries on the pos_bus, while indexes >= 32 are extra entries specific to PCAP, like timestamps and number of gated samples. The values sent via the WRITE register are written from the TCP server, so will not be visible to end users.

Data is ticked out one at a time from the DATA attribute, then sent to the TCP server over DMA, before being sent to the user. It is reconstructed into a table in each of the examples below for ease of reading.

The following example shows PCAP being configured to capture the timestamp when CAPTURE goes high (0x24 is the bottom 32-bits of TS_CAPTURE).

Capture timestamp
Row0x240
02
16

Pos bus capture

As well as general fields like the timestamp, any pos_bus index can be captured. Pos bus fields have multiple modes that they can capture in.

Mode 0 - Value

This gives an instantaneous capture of value no matter what the state of GATE:

Capture pos bus entry 5 Value
Row0x50
020
1100
26

Mode 1 - Difference

This is mainly used for something like an incrementing counter value. It will only count the differences while GATE was high:

Capture pos bus entry 11 Difference
Row0xB1
010
1-5

Mode 2/3 - Sum Lo/Hi

Mode 2 is the lower 32-bits of the sum of all samples while GATE was high:

Capture pos bus entry 3 Sum
Row0x32
06
121
2206

Mode 2 and 3 together gives the full 64-bits of sum, needed for any sizeable values on the pos_bus:

Capture pos bus entry 2 Sum large values
Row0x220x23
010737418240
1-10737418240
2-21474836482
3-1073741824-1
4-1073741824-2

If long frame times (> 2**32 SAMPLES, > 30s), are to be used, then SHIFT_SUM can be used to shift both the sum and SAMPLES field by up to 8-bits to accomodate up to 125 hour frames. This example demonstrates the effect with smaller numbers:

Capture pos bus entry 9 Sum shifted
Row0x920x260
0401
1361
2-131
300

Mode 4/5 - Min/Max

Both of these modes calculate statistics on the value while GATE is high.

Mode 4 produces the min of all values or zero if the gate was low for all of the current capture:

Capture pos bus entry 8 Min
Row0x84
010
120
221
32147483647

Mode 5 produces the max of all values in a similar way:

Capture pos bus entry 4 Max
Row0x45
020
120
222
3-2147483648

Mode 6/7/8 - Sum of Squared values Lo/Mid/Hi

Mode 6/7/8 is only implemented when target supports pcap_std_dev fpga option.

Mode 6, 7 and 8 together gives the full 96-bits of sum of squared values needed for any sizeable values on the pos_bus.

Mode 6 is the lower 32-bits while GATE was high, Mode 7 is the middle 32-bits, and Mode 8 is the higher 32-bits:

Capture pos bus entry 2 Sum^2
Row0x260x270x28
01800
117600
2842949672881

If long frame times (> 2**32 SAMPLES, > 30s), are to be used, then SHIFT_SUM can be used to shift both the sum of squared values and SAMPLES field by up to 8-bits to accomodate up to 125 hour frames:

Capture pos bus entry 2 Sum^2 Samples shifted
Row0x260x270x280x260
09001
188003
24429496729204

Number of samples

There is a SAMPLES field that can be captured that will give the number of clock ticks that GATE was high during a single CAPTURE. This field allows the TCP server to offer “Mean” as a capture option, dividing “Sum” by SAMPLES to get the mean value of the field during the capture period. It can also be captured separately to give the gate length:

Capture gate length
Row0x260
04
13
22
30

Timestamps

As well as the timestamp of the capture signal, timestamps can also be generated for the start of each capture period (first gate high signal) and end (the tick after the last gate high). These are again split into two 32-bit segments so only the lower bits need to be captured for short captures. In the following example we capture TS_START (0x20), TS_END (0x22) and TS_CAPTURE (0x24) lower bits:

Capture more timestamps
Row0x2000x2200x240
0044
1489
2111313
3-1-116

Bit bus capture

The state of the bit bus at capture can also be captured. It is split into 4 quadrants of 32-bits each. For example, to capture signals 0..31 on the bit bus we would use BITS0 (0x27):

Capture bit bus quadrant 0
Row0x270
00
14
220
316

By capturing all 4 quadrants (0x27..0x2A) we get the whole bit bus:

Capture bit bus all quadrants
Row0x2700x2800x2900x2A0
04000
146710886400
2467108864032
3102867108864032

Triggering options

ENABLE and GATE are level triggered, with ENABLE used for marking the start and end of the entire acquisition, and GATE used to accept or reject samples within a single capture from the acquisition. CAPTURE is edge triggered with an option to trigger on rising, falling or both edges.

Triggering on rising is the default, explored in the preceding examples. Triggering on falling edge would be used if you have a gate signal that marks the capture boundaries and want sum or difference data within. For example, to capture the amount POS[1] changes in each capture gate we could connect GATE and CAPTURE to the same signal:

Gate and capture signals the same
Row0x11
010
1-9

Another option would be a gap-less acquisition of sum while gate is high with capture boundaries marked with a toggle of CAPTURE:

Gap-less sum
Row0x12
030
1178
239
30

Error conditions

The distance between capture signals must be at least the number of 32-bit capture fields. If 2 capture signals are too close together HEALTH will be set to 1 (Capture events too close together).

In this example there are 3 fields captured (TS_CAPTURE_L, TS_CAPTURE_H, SAMPLES), but only 2 clock ticks between the 2nd and 3rd capture signals:

Capture too close together
Row0x2400x2500x260
0100
1500