pub struct WriteFifo<T: NativeFpgaType> { /* private fields */ }
Expand description
A FIFO that can be written to.
Implementations§
Source§impl<T: NativeFpgaType + 'static> WriteFifo<T>
impl<T: NativeFpgaType + 'static> WriteFifo<T>
pub const fn new(address: u32) -> Self
Sourcepub fn write(
&mut self,
session: &impl FifoInterface<T>,
timeout: Option<Duration>,
data: &[T],
) -> Result<usize, FPGAError>
pub fn write( &mut self, session: &impl FifoInterface<T>, timeout: Option<Duration>, data: &[T], ) -> Result<usize, FPGAError>
Write to the FIFO from the provided buffer. The size of the write is determined by the size of the data slice.
The timeout can be None
to indicate an infinite timeout or a Duration
to indicate a timeout.
Returns the number of elements free in the FIFO.
§Example
use std::time::Duration;
let session = Session::new("main.lvbitx", "sig", "RIO0").unwrap();
let mut fifo = WriteFifo::<u64>::new(1);
let buffer = [0u64; 10];
let remaining = fifo.write(&session, Some(Duration::from_millis(100)), &buffer).unwrap();
Sourcepub fn get_write_region<'d, 's: 'd>(
&'d mut self,
session: &'s impl FifoInterface<T>,
elements: usize,
timeout: Option<Duration>,
) -> Result<(FifoWriteRegion<'s, 'd, T>, usize), FPGAError>
pub fn get_write_region<'d, 's: 'd>( &'d mut self, session: &'s impl FifoInterface<T>, elements: usize, timeout: Option<Duration>, ) -> Result<(FifoWriteRegion<'s, 'd, T>, usize), FPGAError>
Provides a way to get a reference to the write region of the FIFO.
This enables you to write into the FIFO buffer without an additional copy.
This function returns a write region. This contains a view of the data in the DMA driver. It also returns the number of elements remaining in the buffer.
The timeout can be None
to indicate an infinite timeout or a Duration
to indicate a timeout.
To write to the FPGA you must overwrite the elements in the region and then drop it.
§Example
let session = Session::new("main.lvbitx", "sig", "RIO0").unwrap();
let mut fifo = WriteFifo::<u64>::new(1);
let (write_region, remaining) = fifo.get_write_region(&session, 1000, None).unwrap();
// Do something with the data in the write region.
write_region.elements[0] = 1;
// Drop the write region to commit the data back to the DMA driver.
drop(write_region);
Sourcepub fn space_available(
&self,
session: &impl FifoInterface<T>,
) -> Result<usize, FPGAError>
pub fn space_available( &self, session: &impl FifoInterface<T>, ) -> Result<usize, FPGAError>
Returns the number of elements free to write. Warning: This achieves this by writing zero elements to the FIFO so it will start the FIFO if stopped.