Struct ReadFifo

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

A FIFO that can be read from.

Implementations§

Source§

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

Source

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

Source

pub fn read( &mut self, session: &impl FifoInterface<T>, timeout: Option<Duration>, data: &mut [T], ) -> Result<usize, FPGAError>

Read from the FIFO into the provided buffer. The size of the read 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 still to be read.

§Example
use std::time::Duration;

let session = Session::new("main.lvbitx", "sig", "RIO0").unwrap();
let mut fifo = ReadFifo::<u64>::new(1);
let mut buffer = [0u64; 10];
let remaining = fifo.read(&session, Some(Duration::from_millis(100)), &mut buffer).unwrap();
Source

pub fn get_read_region<'d, 's: 'd>( &'d mut self, session: &'s impl FifoInterface<T>, elements: usize, timeout: Option<Duration>, ) -> Result<(FifoReadRegion<'s, 'd, T>, usize), FPGAError>

Provides a mechanism to read from the FIFO without copying the data.

This function returns a read 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 = ReadFifo::<u64>::new(1);
let (read_region, remaining) = fifo.get_read_region(&session, 1000, None).unwrap();
// Do something with the data in the read region.
println!("{:?}", read_region.elements);
// Drop the read region to commit the data back to the DMA driver.
drop(read_region);
Source

pub fn elements_available( &self, session: &impl FifoInterface<T>, ) -> Result<usize, FPGAError>

Returns the number of elements available to read.

Warning: This achieves this by reading zero elements from the FIFO so it will start the FIFO if stopped.

Trait Implementations§

Source§

impl<T: NativeFpgaType> Fifo for ReadFifo<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 ReadFifo<T>

§

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

§

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

§

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

§

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

§

impl<T> UnwindSafe for ReadFifo<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.