Crates.io | ni-fpga-interface-build |
lib.rs | ni-fpga-interface-build |
version | 0.1.0 |
source | src |
created_at | 2023-10-23 14:08:57.297031 |
updated_at | 2023-10-23 14:08:57.297031 |
description | Provide the ability to access an NI FPGA application from Rust |
homepage | |
repository | https://github.com/WiresmithTech/ni-fpga-interface |
max_upload_size | |
id | 1011349 |
size | 64,966 |
NI FPGA Interface for Rust
This crate is designed to make it easy to talk to a LabVIEW FPGA.
ni-fpga-interface-build
crate as a build dependency and ni-fpga-interface
as a normal dependency. fn main() {
let mut fpga_c_interface = ni_fpga_interface_build::FpgaCInterface::from_custom_header(
"../fpga_c_interface/NiFpga_Main.h",
);
fpga_c_interface.build();
}
mod fpga_defs {
include!(concat!(env!("OUT_DIR"), "/NiFpga_Main.rs"));
}
ni-fpga-interface
APIs to access the FPGA.See the examples folder for some fully worked examples including build support.
These are the features supported and planned.
Native types are the standard integer types as well as singles and double floats.
Feature | Supported |
---|---|
Registers for native types | ✅ |
Registers for FXP numbers | planned |
Registers for clusters | TBC |
DMA for native types | ✅ |
DMA FIFO controls | ✅ |
IRQs | ✅ |
Session Control | ✅ |
Multi-threading | ✅ |
pattern for multi-fpga support | planned |
dynamic interface for multi-fpga support | planned |
The principle behind this approach is going to be to use as much of the generated C as possible instead of pre-building against the expected interface.
This should make us as version independent as possible and reduce the complexity where NI have already solved problems in the generated C code.
It may take time but this builds through 3 layers of abstraction:
flowchart
subgraph LabVIEW
C[FPGA C Interface]
LV[LabVIEW FPGA] --generates--> C
end
subgraph Build Support
C --bindgen--> Types[FPGA Definitions]
C --cc--> Obj[Compiled NI FPGA Interface]
end
Obj --links--> Wrapper[Safe Generic Wrapper]
Types --mod import--> Direct[Your Code with Direct interface]
Wrapper --mod import--> Direct
Types --generator--> Specific[FPGA Interface Module]
Wrapper --generator--> Specific
Specific --> App[Your Code Using Custom Interface]
The diagram shows the key components and targeted workflow. Names will probably change.
There are 3 key components to this project:
We will need to support fixed point and clusters which come in as custom types in C.
This needs some code generation as part of the build support to enable a safe wrapper for these types.
Cross-compilation should be a first-class consideration to ensure this is easy to use against a compactRIO target.
I have tested the examples build against x64 and armv7 LinuxRT targets.
I'm going to start with this as a single crate but it may make sense to split it later.