substrate::block

Trait Block

Source
pub trait Block:
    Hash
    + Eq
    + Send
    + Sync
    + Any {
    type Io: Io;

    // Required method
    fn io(&self) -> Self::Io;

    // Provided method
    fn name(&self) -> ArcStr { ... }
}
Expand description

A block that can be instantiated by Substrate.

§Examples

#[derive(Io, Clone, Default, Debug)]
pub struct InverterIo {
    pub vdd: InOut<Signal>,
    pub vss: InOut<Signal>,
    pub din: Input<Signal>,
    pub dout: Output<Signal>,
}

#[derive(Debug, Clone, Hash, PartialEq, Eq)]
pub struct Inverter {
    strength: usize,
}

impl Block for Inverter {
    type Io = InverterIo;

    fn name(&self) -> arcstr::ArcStr {
        arcstr::format!("inverter_{}", self.strength)
    }

    fn io(&self) -> Self::Io {
        Default::default()
    }
}

Required Associated Types§

Source

type Io: Io

The ports of this block.

Required Methods§

Source

fn io(&self) -> Self::Io

Returns a fully-specified instance of this cell’s Io.

Provided Methods§

Source

fn name(&self) -> ArcStr

A name for a specific parametrization of this block.

Instances of this block will initially be assigned this name, although Substrate may need to change the name (e.g. to avoid duplicates).

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementations on Foreign Types§

Source§

impl<T: Block> Block for Arc<T>

Source§

type Io = <T as Block>::Io

Source§

fn name(&self) -> ArcStr

Source§

fn io(&self) -> Self::Io

Implementors§

Source§

impl<B: Block, S: Schema> Block for ConvertSchema<B, S>

Source§

type Io = <B as Block>::Io