pub struct SPISlave<const N: usize> {
    pub clock: Signal<In, Clock>,
    pub wires: SPIWiresSlave,
    pub disabled: Signal<In, Bit>,
    pub busy: Signal<Out, Bit>,
    pub data_inbound: Signal<Out, Bits<N>>,
    pub start_send: Signal<In, Bit>,
    pub data_outbound: Signal<In, Bits<N>>,
    pub bits: Signal<In, Bits<16>>,
    pub continued_transaction: Signal<In, Bit>,
    pub transfer_done: Signal<Out, Bit>,
    /* private fields */
}
Expand description

The SPISlave is mostly meant for testing the [SPIMaster], but you can use it to implement a SPI endpoint in the FPGA if you want to. This SPISlave is not very robust, so be cautious with using it. In particular, with a very badly behaved SPI master, it may not operate as expected.

Fields§

§clock: Signal<In, Clock>

The clock driving the SPISlave

§wires: SPIWiresSlave

The bus connecting us to the [SPIMaster] or an external SPI bus.

§disabled: Signal<In, Bit>

Raise thie disabled signal if you want the SPISlave to ignore the wires signals.

§busy: Signal<Out, Bit>

Indicates the SPISlave is busy (typically, receiving data from the [SPIMaster].

§data_inbound: Signal<Out, Bits<N>>

Data received from the [SPIMaster] is output on these wires.

§start_send: Signal<In, Bit>

Assert for a single cycle to latch the data to be sent back to the [SPIMaster] on the MISO line. Latches data_outbound,bits and continued_transaction when asserted.

§data_outbound: Signal<In, Bits<N>>

Data destined for the [SPIMaster] on the next transaction.

§bits: Signal<In, Bits<16>>

Number of bits to send. Capped at 16 bits (which corresponds to 64K bits on the send - not realistic).

§continued_transaction: Signal<In, Bit>

Set this to true to indicate that the next transaction will be continued from this one (i.e., do not hangup at the end).

§transfer_done: Signal<Out, Bit>

A flag that indicates the inbound data is valid.

Implementations§

source§

impl<const N: usize> SPISlave<N>

source

pub fn new(config: SPIConfig) -> Self

Generate a new SPISlave with the given SPIConfig

Arguments
  • config: The SPIConfig that configures the slave receiver.

returns: SPISlave<{ N }>

Examples

See [ADS868XSimulator] for an example of how a SPISlave can be used.

Trait Implementations§

source§

impl<const N: usize> Block for SPISlave<N>

source§

fn connect_all(&mut self)

Connects the internal signals of the circuit - used to initialize the circuit
source§

fn update_all(&mut self)

Propogate changes from inputs to outputs within the circuit
source§

fn has_changed(&self) -> bool

Returns true if anything in the circuit has changed (outputs or internal state)
source§

fn accept(&self, name: &str, probe: &mut dyn Probe)

The visitor pattern - allows a circuit to be probed by a Probe struct.
source§

impl<const N: usize> Logic for SPISlave<N>

source§

fn update(&mut self)

source§

fn connect(&mut self)

source§

fn hdl(&self) -> Verilog

source§

fn timing(&self) -> Vec<TimingInfo, Global>

Auto Trait Implementations§

§

impl<const N: usize> RefUnwindSafe for SPISlave<N>

§

impl<const N: usize> Send for SPISlave<N>

§

impl<const N: usize> Sync for SPISlave<N>

§

impl<const N: usize> Unpin for SPISlave<N>

§

impl<const N: usize> UnwindSafe for SPISlave<N>

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere 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 Twhere 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.

§

impl<T> Pointable for T

§

const ALIGN: usize = mem::align_of::<T>()

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
source§

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

§

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 Twhere U: TryFrom<T>,

§

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.