Accumulator
- Updated2025-01-28
- 10 minute(s) read
Accumulates or decrements x. This function supports multi-channel operations and feedback scaling.
This function supports only Boolean arrays and scalar values of integer and fixed-point data types.

Dialog Box Options
| Parameter | Description |
|---|---|
| Fixed-Point Configuration | Specifies the encodings and word lengths of the input x and the output s. The fractional word length of the output s always is equal to that of the input x.
|
| Accumulator settings | Contains settings for the accumulator.
|
| Reset | Contains options for resetting the internal registers of this function to 0.
|
| Configuration Feedback | Displays information about how this function executes. This information is based on the configuration options you specify. |
Inputs/Outputs
x
—
Specifies the data to add to or subtract from the value of s. If x is a fixed-size Boolean array, the first array element represents the least-significant bit (LSB) and the last element represents the most-significant bit (MSB). A value of x applies to one channel only.Refer to the Details Details section for an example of using this function in a multi-channel application.
is sub? (F)
—
Specifies whether this function performs subtraction or addition. If is sub? is TRUE, this function calculates s – x. If is sub? is FALSE, this function calculates s + x. Use this terminal to change the operation of this function programmatically. The default value is FALSE.
load (F)
—
Specifies whether to start a new accumulation from 0. The default value is FALSE, which means this function adds x to, or subtracts x from, the previous value of s. If load is TRUE, this function ignores any previous value of s and begins a new accumulation by loading the value of x. Use this terminal to start a new accumulation by setting load to TRUE. Then, set load to FALSE for as long as you want a single value of s to accumulate. To restart accumulation, set load to TRUE again. In multi-channel applications, this parameter affects the channel whose data is coming into the input terminal x on the clock cycle you change the value of load. For example, if you are accumulating two channels for eight clock cycles, you could restart accumulation on channel 1 during the third clock cycle, when you receive the second value of channel 1. This change does not affect the accumulation of channel 2.
enable (T)
—
Specifies whether this function operates on the value of the x input terminal. The default value is TRUE, which means this function reads the current value of x and uses it in accumulation. If enable is FALSE, this function ignores x and does nothing. Use this terminal to operate on only valid values of x. For example, you can wire the output valid output terminal of a High Throughput Math function to this input terminal. In this situation, the accumulator operates only if the High Throughput Math function produces a value result. In multi-channel applications, this parameter affects the channel whose data is coming into the input terminal x on the clock cycle you change the value of enable. For example, if you are accumulating two channels for eight clock cycles, x receives data from channel 1 during the first, third, fifth, and seventh clock cycles. You could skip the second value of channel 1 by setting enable to FALSE during the third clock cycle and setting it back to TRUE during the fifth clock cycle. This change does not affect channel 2.
carry-in/inverted borrow-in (F)
—
Specifies whether this function accounts for an extra least-significant bit (LSB). For example, the LSB could come from the bit pattern of the carry-out/inverted borrow-out terminal of an upstream Accumulator function. The default value of carry-in/inverted borrow-in is FALSE, which means this function computes s – x – 1(LSB) if is sub? is TRUE or s + x if is sub? is FALSE. If carry-in/inverted borrow-in is TRUE, this function computes s – x if is sub? is TRUE or s + x + 1(LSB) if is sub? is FALSE.
carry-out/inverted borrow-out
—
Returns TRUE if the data type of s cannot represent the result of an unsigned addition operation. This terminal returns FALSE if the data type of s cannot represent the result of an unsigned subtraction operation. In this situation, this function wraps the value of s. LabVIEW displays this terminal only if the encoding is Unsigned. If you cascade this function, you can use this terminal to specify whether a downstream function carries or borrows a value. To specify that a downstream function uses this value, wire the carry-out/inverted borrow-out output terminal to the carry-in/inverted borrow-in input terminal of the downstream function. Returns TRUE if the encoding is Signed and the theoretical computed value of s exceeds the valid range of the data type of s. In this situation, this function wraps the value of s. Note If you cascade functions, you must use unsigned functions in the intermediate operations. Then set the encoding of the final function to the encoding you want for the entire cascaded operation.
s
—
Returns the result this function computes. This result depends on not only the value of x, but also the values of any Boolean input terminals LabVIEW displays. For example, s accumulates only while load is FALSE and enable is TRUE. A value of s applies to one channel only. In multi-channel applications, s accumulates separately for each channel. Refer to the Details section for an example of using this function in a multi-channel application. This function applies the Wrap overflow mode to s in any of the following situations:
|
Multi-channel Operation
This function always takes one cycle to compute a value of s. This function maintains separate internal values of s for each channel. This behavior has implications for multi-channel applications. For example, consider the following six data samples from a two-channel data acquisition operation:
| Data Sample Number | Channel 1 | Channel 2 |
|---|---|---|
| 1 | 6 | 8 |
| 2 | 44 | 5 |
| 3 | 2 | 3 |
To interleave this data, create a one-dimensional array with the following values: [6 8 44 5 2 3]. Then wire one element per clock cycle to the x input of the Accumulator function, as the following figure shows:
The previous figure executes the Accumulator function for seven clock cycles. the accumulator function takes in x values from channel 1 during clock cycles 1, 3, and 5. Because of the one-cycle latency, the function returns accumulated s values for channel 1 during clock cycles 2, 4, and 6.
For channel 2, the function takes in x values during clock cycles 2, 4, and 6. The function returns accumulated s values for channel 2 during clock cycles 3, 5, and 7. This behavior means that for each cycle the function takes in an x value from channel 1, the function returns an s value for channel 2.
If the function computes s + x, the following table shows the operation of this VI in detail.
| Clock cycle | Input x | Explanation of x | Output s | Explanation of s |
|---|---|---|---|---|
| 1 | 6 | Channel 1, data sample number 1 | – | The function does not return a result during the first clock cycle because the function takes one clock cycle to execute. |
| 2 | 8 | Channel 2, data sample number 1 | 6 (the accumulation of channel 1) | Although this clock cycle takes input data from channel 2, the function returns data it received during the previous clock cycle. This data was from channel 1, when s was 0 and x was 6, so this function returns 6 in s. |
| 3 | 44 | Channel 1, data sample number 2 | 8 (the accumulation of channel 2) | Although this clock cycle takes input data from channel 1, the function returns data it received during the previous clock cycle. This data was from channel 2, when s was 0 and x was 8, so this function returns 8 in s. |
| 4 | 5 | Channel 2, data sample number 2 | 50 (the accumulation of channel 1) | s = 6 from clock cycle 2, x = 44 from clock cycle 3 |
| 5 | 2 | Channel 1, data sample number 3 | 13 (the accumulation of channel 2) | s = 8 from clock cycle 3, x = 5 from clock cycle 4 |
| 6 | 3 | Channel 2, data sample number 3 | 52 (the accumulation of channel 1) | s = 50 from clock cycle 4, x = 2 from clock cycle 5 |
| 7 | – | There is no more data from channel 1 | 16 (the accumulation of channel 2) | s = 13 from clock cycle 5, x = 3 from clock cycle 6 |
Simulation Export Details
This node can increase simulation run time significantly when used in conjunction with downloading, stopping, or running the FPGA VI.
Examples
Refer to the following example files included with LabVIEW FPGA Module.
- labview\examples\CompactRIO\FPGA Fundamentals\FPGA Math and Analysis\High-Throughput Math\Multi-Channel Averaging\Multi-Channel Averaging.lvproj
- labview\examples\R Series\FPGA Fundamentals\FPGA Math and Analysis\High-Throughput Math\Multi-Channel Averaging\Multi-Channel Averaging.lvproj
- labview\examples\CompactRIO\FPGA Fundamentals\FPGA Math and Analysis\High-Throughput Math\Long Width Calculation\Long Width Calculation.lvproj
- labview\examples\R Series\FPGA Fundamentals\FPGA Math and Analysis\High-Throughput Math\Long Width Calculation\Long Width Calculation.lvproj
x
—
is sub? (F)
—
carry-out/inverted borrow-out
—
s
—