pub trait Interface: Sized {
    type Fwd: Copy;
    type Bwd: Copy;

    // Provided methods
    unsafe fn fsm<E: Interface, S: Copy>(
        self,
        _init_state: S,
        _f: impl Fn(Self::Fwd, E::Bwd, S) -> (E::Fwd, Self::Bwd, S)
    ) -> E { ... }
    fn comb<E: Interface>(self, m: impl FnOnce(Self) -> E) -> E { ... }
}
Expand description

Interface trait.

Required Associated Types§

source

type Fwd: Copy

Forward signal.

source

type Bwd: Copy

Backward signal.

Provided Methods§

source

unsafe fn fsm<E: Interface, S: Copy>( self, _init_state: S, _f: impl Fn(Self::Fwd, E::Bwd, S) -> (E::Fwd, Self::Bwd, S) ) -> E

A generic FSM combinator.

We assume that the function f is combinational logic. The returned egress payload and ingress resolver are immediately propagated, and the state is updated to the returned next state from the next cycle.

Safety

When using this combinator, you need to guarantee that it satisfies the specification of the interface’s protocol.

In particular, for a hazard interface I<H, D>, you must follow the specification described in the “Safety” section of I::fsm.

How it is compiled?

In the HazardFlow compiler, the fsm function is not actually executed (which would lead to a panic).

Instead, the HazardFlow compiler captures the High-level IR generated by the Rust compiler and extracts information about the ingress/egress/state types (Self, E, S) and the arguments (init_state, f) of the fsm function.

Using this information, the HazardFlow compiler generates the corresponding Verilog code.

Type parameters
  • Self: The ingress interface type.
  • E: The egress interface type.
  • S: The state type.
Parameters
  • self: The ingress interface.
  • init_state: The initial state.
    • Whenever rst signal is turned on, the state will be initialized to this value.
    • For example, set init_state as None for a state with an Option<_> type.
  • f: Output calculation and state transition logic. If let (ep, ir, s_next) = f(ip, er, s),
    • ip: The ingress payload.
    • er: The egress resolver.
    • s: The current state.
    • ep: The egress payload.
    • ir: The ingress resolver.
    • s_next: The next state.
source

fn comb<E: Interface>(self, m: impl FnOnce(Self) -> E) -> E

Combines the module to the given interface and returns the egress interface.

Object Safety§

This trait is not object safe.

Implementations on Foreign Types§

source§

impl Interface for ()

§

type Bwd = ()

§

type Fwd = ()

source§

impl<If1: Interface> Interface for (If1,)

§

type Fwd = (<If1 as Interface>::Fwd,)

§

type Bwd = (<If1 as Interface>::Bwd,)

source§

impl<If1: Interface, If2: Interface> Interface for (If1, If2)

§

type Fwd = (<If1 as Interface>::Fwd, <If2 as Interface>::Fwd)

§

type Bwd = (<If1 as Interface>::Bwd, <If2 as Interface>::Bwd)

source§

impl<If1: Interface, If2: Interface, If3: Interface> Interface for (If1, If2, If3)

§

type Fwd = (<If1 as Interface>::Fwd, <If2 as Interface>::Fwd, <If3 as Interface>::Fwd)

§

type Bwd = (<If1 as Interface>::Bwd, <If2 as Interface>::Bwd, <If3 as Interface>::Bwd)

source§

impl<If1: Interface, If2: Interface, If3: Interface, If4: Interface> Interface for (If1, If2, If3, If4)

§

type Fwd = (<If1 as Interface>::Fwd, <If2 as Interface>::Fwd, <If3 as Interface>::Fwd, <If4 as Interface>::Fwd)

§

type Bwd = (<If1 as Interface>::Bwd, <If2 as Interface>::Bwd, <If3 as Interface>::Bwd, <If4 as Interface>::Bwd)

source§

impl<If1: Interface, If2: Interface, If3: Interface, If4: Interface, If5: Interface> Interface for (If1, If2, If3, If4, If5)

§

type Fwd = (<If1 as Interface>::Fwd, <If2 as Interface>::Fwd, <If3 as Interface>::Fwd, <If4 as Interface>::Fwd, <If5 as Interface>::Fwd)

§

type Bwd = (<If1 as Interface>::Bwd, <If2 as Interface>::Bwd, <If3 as Interface>::Bwd, <If4 as Interface>::Bwd, <If5 as Interface>::Bwd)

source§

impl<If1: Interface, If2: Interface, If3: Interface, If4: Interface, If5: Interface, If6: Interface> Interface for (If1, If2, If3, If4, If5, If6)

§

type Fwd = (<If1 as Interface>::Fwd, <If2 as Interface>::Fwd, <If3 as Interface>::Fwd, <If4 as Interface>::Fwd, <If5 as Interface>::Fwd, <If6 as Interface>::Fwd)

§

type Bwd = (<If1 as Interface>::Bwd, <If2 as Interface>::Bwd, <If3 as Interface>::Bwd, <If4 as Interface>::Bwd, <If5 as Interface>::Bwd, <If6 as Interface>::Bwd)

source§

impl<If1: Interface, If2: Interface, If3: Interface, If4: Interface, If5: Interface, If6: Interface, If7: Interface> Interface for (If1, If2, If3, If4, If5, If6, If7)

§

type Fwd = (<If1 as Interface>::Fwd, <If2 as Interface>::Fwd, <If3 as Interface>::Fwd, <If4 as Interface>::Fwd, <If5 as Interface>::Fwd, <If6 as Interface>::Fwd, <If7 as Interface>::Fwd)

§

type Bwd = (<If1 as Interface>::Bwd, <If2 as Interface>::Bwd, <If3 as Interface>::Bwd, <If4 as Interface>::Bwd, <If5 as Interface>::Bwd, <If6 as Interface>::Bwd, <If7 as Interface>::Bwd)

source§

impl<If1: Interface, If2: Interface, If3: Interface, If4: Interface, If5: Interface, If6: Interface, If7: Interface, If8: Interface> Interface for (If1, If2, If3, If4, If5, If6, If7, If8)

§

type Fwd = (<If1 as Interface>::Fwd, <If2 as Interface>::Fwd, <If3 as Interface>::Fwd, <If4 as Interface>::Fwd, <If5 as Interface>::Fwd, <If6 as Interface>::Fwd, <If7 as Interface>::Fwd, <If8 as Interface>::Fwd)

§

type Bwd = (<If1 as Interface>::Bwd, <If2 as Interface>::Bwd, <If3 as Interface>::Bwd, <If4 as Interface>::Bwd, <If5 as Interface>::Bwd, <If6 as Interface>::Bwd, <If7 as Interface>::Bwd, <If8 as Interface>::Bwd)

source§

impl<If1: Interface, If2: Interface, If3: Interface, If4: Interface, If5: Interface, If6: Interface, If7: Interface, If8: Interface, If9: Interface> Interface for (If1, If2, If3, If4, If5, If6, If7, If8, If9)

§

type Fwd = (<If1 as Interface>::Fwd, <If2 as Interface>::Fwd, <If3 as Interface>::Fwd, <If4 as Interface>::Fwd, <If5 as Interface>::Fwd, <If6 as Interface>::Fwd, <If7 as Interface>::Fwd, <If8 as Interface>::Fwd, <If9 as Interface>::Fwd)

§

type Bwd = (<If1 as Interface>::Bwd, <If2 as Interface>::Bwd, <If3 as Interface>::Bwd, <If4 as Interface>::Bwd, <If5 as Interface>::Bwd, <If6 as Interface>::Bwd, <If7 as Interface>::Bwd, <If8 as Interface>::Bwd, <If9 as Interface>::Bwd)

source§

impl<If1: Interface, If2: Interface, If3: Interface, If4: Interface, If5: Interface, If6: Interface, If7: Interface, If8: Interface, If9: Interface, If10: Interface> Interface for (If1, If2, If3, If4, If5, If6, If7, If8, If9, If10)

§

type Fwd = (<If1 as Interface>::Fwd, <If2 as Interface>::Fwd, <If3 as Interface>::Fwd, <If4 as Interface>::Fwd, <If5 as Interface>::Fwd, <If6 as Interface>::Fwd, <If7 as Interface>::Fwd, <If8 as Interface>::Fwd, <If9 as Interface>::Fwd, <If10 as Interface>::Fwd)

§

type Bwd = (<If1 as Interface>::Bwd, <If2 as Interface>::Bwd, <If3 as Interface>::Bwd, <If4 as Interface>::Bwd, <If5 as Interface>::Bwd, <If6 as Interface>::Bwd, <If7 as Interface>::Bwd, <If8 as Interface>::Bwd, <If9 as Interface>::Bwd, <If10 as Interface>::Bwd)

source§

impl<If1: Interface, If2: Interface, If3: Interface, If4: Interface, If5: Interface, If6: Interface, If7: Interface, If8: Interface, If9: Interface, If10: Interface, If11: Interface> Interface for (If1, If2, If3, If4, If5, If6, If7, If8, If9, If10, If11)

§

type Fwd = (<If1 as Interface>::Fwd, <If2 as Interface>::Fwd, <If3 as Interface>::Fwd, <If4 as Interface>::Fwd, <If5 as Interface>::Fwd, <If6 as Interface>::Fwd, <If7 as Interface>::Fwd, <If8 as Interface>::Fwd, <If9 as Interface>::Fwd, <If10 as Interface>::Fwd, <If11 as Interface>::Fwd)

§

type Bwd = (<If1 as Interface>::Bwd, <If2 as Interface>::Bwd, <If3 as Interface>::Bwd, <If4 as Interface>::Bwd, <If5 as Interface>::Bwd, <If6 as Interface>::Bwd, <If7 as Interface>::Bwd, <If8 as Interface>::Bwd, <If9 as Interface>::Bwd, <If10 as Interface>::Bwd, <If11 as Interface>::Bwd)

source§

impl<If1: Interface, If2: Interface, If3: Interface, If4: Interface, If5: Interface, If6: Interface, If7: Interface, If8: Interface, If9: Interface, If10: Interface, If11: Interface, If12: Interface> Interface for (If1, If2, If3, If4, If5, If6, If7, If8, If9, If10, If11, If12)

§

type Fwd = (<If1 as Interface>::Fwd, <If2 as Interface>::Fwd, <If3 as Interface>::Fwd, <If4 as Interface>::Fwd, <If5 as Interface>::Fwd, <If6 as Interface>::Fwd, <If7 as Interface>::Fwd, <If8 as Interface>::Fwd, <If9 as Interface>::Fwd, <If10 as Interface>::Fwd, <If11 as Interface>::Fwd, <If12 as Interface>::Fwd)

§

type Bwd = (<If1 as Interface>::Bwd, <If2 as Interface>::Bwd, <If3 as Interface>::Bwd, <If4 as Interface>::Bwd, <If5 as Interface>::Bwd, <If6 as Interface>::Bwd, <If7 as Interface>::Bwd, <If8 as Interface>::Bwd, <If9 as Interface>::Bwd, <If10 as Interface>::Bwd, <If11 as Interface>::Bwd, <If12 as Interface>::Bwd)

source§

impl<If: Interface, const N: usize> Interface for [If; N]

§

type Bwd = Array<<If as Interface>::Bwd, N>

§

type Fwd = Array<<If as Interface>::Fwd, N>

Implementors§