Derive Macro substrate::io::layout::HardwareType
source · #[derive(HardwareType)]
Expand description
Derives LayoutType
for a struct.
§Examples
You can create your own layout types and use them as your layout IO to customize the API for accessing shapes within your port. This will work as long as the flattened lengths (i.e. the number of nets) of the original IO and the custom IO are the same.
#[derive(Io, Clone, Default)]
#[substrate(layout_type = "BufferIoLayout")]
pub struct BufferIo {
vdd: InOut<Signal>,
vss: InOut<Signal>,
din: Input<Signal>,
dout: Output<Signal>,
}
#[derive(layout::HardwareType, Clone)]
pub struct BufferIoLayout {
vdd: Port,
vss: Port,
din: ShapePort,
dout: ShapePort,
}
impl CustomHardwareType<BufferIo> for BufferIoLayout {
fn from_layout_type(_other: &BufferIo) -> Self {
Self {
vdd: Port,
vss: Port,
din: ShapePort,
dout: ShapePort,
}
}
}