Trait substrate::block::Block

source ·
pub trait Block: Serialize + DeserializeOwned + Hash + Eq + Send + Sync + Any {
    type Io: Io;

    // Required methods
    fn id() -> ArcStr;
    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(Serialize, Deserialize, Debug, Clone, Hash, PartialEq, Eq)]
pub struct Inverter {
    strength: usize,
}

impl Block for Inverter {
    type Io = InverterIo;

    fn id() -> arcstr::ArcStr {
        arcstr::literal!("inverter")
    }

    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 id() -> ArcStr

A crate-wide unique identifier for this block.

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).

Object Safety§

This trait is not object safe.

Implementations on Foreign Types§

source§

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

§

type Io = <T as Block>::Io

source§

fn id() -> ArcStr

source§

fn name(&self) -> ArcStr

source§

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

Implementors§