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.


icon

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.
  • x Type—Specifies the fixed-point configuration of the x input terminal.
    • Signed—Specifies that this terminal is signed.
    • Unsigned—Specifies that this terminal is unsigned.
    • Word length—Specifies the word length of this terminal.
  • s Type—Specifies the fixed-point configuration of the s output terminal.
    • Signed—Specifies that s is signed. LabVIEW dims this option and matches the encoding of x.
    • Unsigned—Specifies that s is unsigned. LabVIEW dims this option and matches the encoding of x.
    • Word length—Specifies the word length of s. The value must be greater than or equal to the Word length of x. This function sets the integer word length of s internally to keep the fractional word length of s the same as the fractional word length of x.

      For example, if the data type of x is <+, 8, 3>, the fractional word length is 5 bits. If you set the Word length of s to 11 bits, this function sets the integer word length of s to 6 bits internally. This setting maintains a fractional word length of 5 bits in both x and s.

Accumulator settings Contains settings for the accumulator.
  • Feedback down scaling—Specifies the number of bits by which this function right-shifts the bit pattern of s before accumulating/decrementing s by x. This binary shift is an efficient way to divide s by 2^n automatically, where n is the value of this control.

    The value of Feedback down scaling must be less than the Word length of s or 64 bits, whichever value is smaller. The default value is 0 bits, which specifies no shift.

    For example, a value of 3 bits is equivalent to dividing s by 2^3, or 8, before accumulating/decrementing s by x.

  • Number of channels—Specifies the number of channels of data on which this function operates. This function stores data from separate channels in separate internal registers. If you specify more than 1 channel, you must interleave values that you send to the x input terminal. The default value is 1 channel. Refer to the Details section for an example of using this function in a multi-channel application.
  • Register overflow—Specifies whether this function adds an internal register before the overflow output terminal. By default, this checkbox does not contain a checkmark, which means this function returns the overflow result one clock cycle before the value of s.

    To return the value of overflow during the same clock cycle as the value of s, place a checkmark in this checkbox.

    LabVIEW displays this option only if x and s are Signed.

  • Register carry-out/inverted borrow-out—Specifies whether this function adds an internal register before the carry-out/inverted borrow-out output terminal. By default, this checkbox does not contain a checkmark, which means this function returns the carry-out/inverted borrow-out result one clock cycle before the value of s. This situation is helpful if you are cascading Accumulator functions and do not want any delay between the carry-out/inverted borrow-out terminal of this function and the carry-in/inverted borrow-in terminal of the downstream function.

    To return the value of carry-out/inverted borrow-out during the same clock cycle as the value of s, place a checkmark in this checkbox.

    LabVIEW displays this option only if x and s are Unsigned.

Reset Contains options for resetting the internal registers of this function to 0.
  • First call—Specifies that this function resets on the first call of the FPGA VI during an execution. This option uses a few more FPGA resources than the Compile or load option does.
  • Compile or load—Specifies that this function resets when the FPGA VI compiles or when the FPGA VI loads onto the FPGA. This function does not reset if you invoke the Reset method. This option uses fewer FPGA resources than the First call option does.

    Use this option to maintain an accumulated value of s between runs of the FPGA VI.

Configuration Feedback Displays information about how this function executes. This information is based on the configuration options you specify.

Inputs/Outputs

  • cunkn.png 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.

  • cbool.png is sub? (F)

    Specifies whether this function performs subtraction or addition. If is sub? is TRUE, this function calculates sx. 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.

  • cbool.png 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.

  • cbool.png 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.

  • cbool.png 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 sx – 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 sx if is sub? is TRUE or s + x + 1(LSB) if is sub? is FALSE.

  • ibool.png 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.

  • overflow

    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.
  • iunkn.png 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:
    • overflow returns TRUE
    • is sub? is TRUE and carry-out/inverted borrow out returns FALSE
    • is sub? is FALSE and carry-out/inverted borrow out returns TRUE
  • 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.

    Note You must read values of s during the clock cycle the function returns that value. In the example below, you must read the final value of s from channel 1 during the sixth clock cycle. During the seventh clock cycle, this function overwrites this final value of s with the final value from 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