Struct WriteFifo

Source
pub struct WriteFifo<T: NativeFpgaType> { /* private fields */ }
Expand description

A FIFO that can be written to.

Implementations§

Source§

impl<T: NativeFpgaType + 'static> WriteFifo<T>

Source

pub const fn new(address: u32) -> Self

Source

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();
Source

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);
Source

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.

Trait Implementations§

Source§

impl<T: NativeFpgaType> Fifo for WriteFifo<T>

Source§

fn address(&self) -> u32

Source§

fn start(&mut self, session: &Session) -> Result<(), FPGAError>

Begins DMA data transfer between the FPGA target and the host computer. This method is optional. This method is optional as the DMA is automatically started when you attempt to read or write. Read more
Source§

fn stop(&mut self, session: &Session) -> Result<(), FPGAError>

Stops the DMA data transfer between the FPGA target and the host computer. This method deletes all data from the host memory and FPGA parts of the FIFO. Read more
Source§

fn configure( &mut self, session: &Session, requested_depth: usize, ) -> Result<usize, FPGAError>

Specifies the capacity, or depth, in elements of the host FIFO of the DMA channel. The new depth is implemented when the next FIFO Start, FIFO Read, or FIFO Write method executes. Before the new depth is set, the driver empties all data from the host memory and FPGA FIFO. Read more
Source§

fn get_peer_to_peer_fifo_endpoint( &self, session: &Session, ) -> Result<u32, FPGAError>

Auto Trait Implementations§

§

impl<T> Freeze for WriteFifo<T>

§

impl<T> RefUnwindSafe for WriteFifo<T>
where T: RefUnwindSafe,

§

impl<T> Send for WriteFifo<T>
where T: Send,

§

impl<T> Sync for WriteFifo<T>
where T: Sync,

§

impl<T> Unpin for WriteFifo<T>
where T: Unpin,

§

impl<T> UnwindSafe for WriteFifo<T>
where T: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.