Synchronizing FPGA VIs and Host VIs Using Interrupts (FPGA Interface)

LabView FPGA Interface

Synchronizing FPGA VIs and Host VIs Using Interrupts (FPGA Interface)

Some FPGA targets allow you to generate interrupts from the FPGA VI to notify the host VI of events, such as data being ready, an error occurring, or a task finishing. Refer to the specific FPGA target hardware documentation for information about whether the FPGA target supports interrupts.

Waiting for and Acknowledging a Single Interrupt

Complete the following steps to wait for and acknowledge a single interrupt in a host VI.

  1. Open a reference to the FPGA VI or bitfile that generates interrupts.
  2. Place the Invoke Method function on the block diagram of the host VI in the data flow where you want the host VI to wait for interrupts from the FPGA VI. Be sure to wire the FPGA VI Reference In input.

     Place  Find
  3. Right-click the Invoke Method function and select Method»Wait on IRQ from the shortcut menu.
  4. Right-click the IRQ Number(s) input on the Invoke Method function and select Create»Constant from the shortcut menu. You also can create a control.
  5. Enter the value of the logical interrupt you selected in the FPGA VI.
  6. Wire the Timeout input if you want to specify the maximum time the host VI waits for the interrupt before continuing the data flow. By default, the host VI does not wait for an interrupt to occur and returns only interrupts already set by the FPGA VI. You also can wire a constant with a value of –1 to wait indefinitely for an interrupt. If you use the Timeout input, you can use the Timed Out output to determine whether the host VI continued data flow due to the timeout occurring or to the receipt of an interrupt. If a timeout occurs, the Timed Out output returns TRUE.
  7. Right-click the IRQ(s) Asserted output on the Invoke Method function and select Create»Indicator from the shortcut menu. LabVIEW creates a numeric indicator. A value of –1 indicates that the interrupt was not received.
  8. Place the Invoke Method function on the block diagram of the host VI in the data flow where you want the host VI to acknowledge the interrupt from the FPGA VI. Place the Invoke Method function in a Case Structure if you want the function to execute only when the host VI receives an interrupt. If you wire a Boolean constant of TRUE to the Wait Until Cleared input of the Interrupt VI, place the Invoke Method function in the data flow where you want to tell the Interrupt VI to stop waiting. Be sure to wire the FPGA VI Reference In input of the Invoke Method function.

     Place  Find
  9. Right-click the Invoke Method function and select Method»Acknowledge IRQ from the shortcut menu. Use the Acknowledge IRQ method to acknowledge the logical interrupt returned by the Wait on IRQ method.
  10. Wire the IRQ(s) Asserted output of the Wait on IRQ method directly to the IRQ Number(s) input of the Acknowledge IRQ method.

Waiting for and Acknowledging Multiple Interrupts

Complete the following steps to wait for and acknowledge multiple interrupts in a host VI.

  1. Open a reference to the FPGA VI or bitfile that generates interrupts.
  2. Place the Invoke Method function on the block diagram of the host VI in the data flow where you want the host VI to wait for interrupts from the FPGA VI. Be sure to wire the FPGA VI Reference In input.

     Place  Find
  3. Right-click the Invoke Method function and select Method»Wait on IRQ from the shortcut menu.
  4. Place an Array Constant on the block diagram. An array includes an index display on the left, an element display on the right, and an optional label.

     Place  Find
  5. Place a Numeric Constant in the array.

     Place  Find

  6. Using the Positioning tool, expand the array constant to the number of interrupts needed.
  7. Enter the values of the logical interrupts.
  8. Wire the array constant to the IRQ Number(s) input.
  9. Wire the Timeout input if you want to specify the maximum time the host VI waits for the interrupt before continuing the data flow. By default, the host VI does not wait for an interrupt to occur and returns only interrupts already set by the FPGA VI. You also can wire a constant with a value of –1 to wait indefinitely for an interrupt. If you use the Timeout input, you can use the Timed Out output to determine whether the host VI continued data flow due to the timeout occurring or to the receipt of an interrupt. If a timeout occurs, the Timed Out output returns TRUE.
  10. Right-click the IRQ(s) Asserted output on the Invoke Method function and select Create»Indicator from the shortcut menu. LabVIEW creates an array indicator. The IRQ(s) Asserted front panel indicator displays the number(s) of the interrupts the FPGA target asserts. An empty array indicates that no interrupts were received.
  11. Place the Invoke Method function on the block diagram of the host VI in the data flow where you want the host VI to acknowledge the interrupts from the FPGA VI. Place the Invoke Method function in a Case Structure if you want the function to execute only when the host VI receives an interrupt. If you wire a Boolean constant of TRUE to the Wait Until Cleared input of the Interrupt VI, place the Invoke Method function in the data flow where you want to tell the Interrupt VI to stop waiting. Be sure to wire the FPGA VI Reference In input of the Invoke Method function.

     Place  Find
  12. Right-click the Invoke Method function and select Method»Acknowledge IRQ from the shortcut menu. Use the Acknowledge IRQ method to acknowledge the logical interrupts returned by the Wait on IRQ method.
  13. Wire the IRQ(s) Asserted output of the Wait on IRQ method directly to the IRQ Number(s) input of the Acknowledge IRQ method.