Programming Overview
- Updated2025-10-09
- 3 minute(s) read
The LabVIEW FPGA application programming interface (API) is inherently different from other NI-Serial (for instance, VISA) and C-Series module APIs. Instead of I/O nodes, Read Byte and Write Byte methods on the FPGA I/O Method Node are used for data transfer.
Property nodes can dynamically change the module configuration. Additionally, most module configuration can be done directly from the Project Explorer Window before compiling and running a VI by right-clicking the appropriate module and selecting Properties. If using a non-standard baud rate, this configuration panel may also be used to calculate the appropriate Baud Rate Divider and Baud Rate Prescaler to write using property nodes.
All four ports on the module share one interface to the FPGA target which has a bandwidth of approximately 128 KB/s. This shared interface can be an important consideration when transferring large amounts of data at high rates. Because of the shared interface to the module, the module is only accessed by one LabVIEW FPGA node at a time. If there is more than one node present on the FPGA VI block diagram that will execute simultaneously, the LabVIEW FPGA Module will automatically arbitrate access to the module with a fair, round-robin arbitration scheme for port-specific property and method nodes. General module property nodes such as Serial #, Module ID# and Vendor ID# have a lower priority in the arbitration scheme.
In order to understand when this consideration of a shared interface should come into play, it is important to distinguish between port baud rate (baud) and data throughput rate (bytes per second). The baud rate is the rate of electrical transitions (including overhead such as start, stop, and parity bits), whereas the data throughput rate is how fast actual data is passed to and from the application, or in this case, the FPGA.
The maximum data throughput rate for a given baud rate can be calculated by dividing the baud rate by the total number of bits in the serial message. For example, a common configuration might be 1 start bit, 8 data bits, and 1 stop bit, which adds to 10 total bits. A 9600 baud setup with this configuration could then support up to 960 (9600 divided by 10) data messages (bytes) per second. A serial port with a baud rate of 921,600 baud using this same configuration would average 92.2 KB/s in data throughput, and so on.
If the sum of the baud rates of all four ports is greater than 500,000 baud, this shared interface may begin to limit performance. Consider a configuration with all four ports operating at 460,800 baud. This setup has a maximum data throughput of 46.08 KB/s per port. The application can simultaneously read and write data at 46.08 KB/s to one port or 23.04 KB/s to two ports without any latency. However, attempting to read and write two ports at 46.08 KB/s could introduce some latency, depending on transfer sizes.
For reference, if all four ports have baud rates up to 115,200 baud, the module will function correctly for any data throughput rate. Most serial applications do not use the full bandwidth of a given baud rate transferring a large continuous block of data. Furthermore, NI 987x C-series modules feature individual 64-byte UART FIFO buffers for each port, which allow for small surges in transmit and receive data. Finally, if timeouts do occur at high baud rates, increasing the timeout value or decreasing the number of other module accesses (such as property nodes) may help reduce the timeouts.