1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59
// Copyright (c) 2020-2021 Thomas Kramer.
// SPDX-FileCopyrightText: 2022 Thomas Kramer
//
// SPDX-License-Identifier: AGPL-3.0-or-later
//! Trait definitions for layouts fused with netlists.
#![allow(missing_docs)] // Necessary because portrait does not generate docs.
pub mod util;
use super::traits::*;
/// Helper trait which constrains [`trait@L2NBase`] for such that ID types
/// are [`Send`] and [`Sync`] as commonly used for parallel algorithms.
#[portrait::make]
pub trait L2NBaseMT: L2NBase + LayoutBaseMT + NetlistBaseMT {}
impl<L> L2NBaseMT for L where L: L2NBase + LayoutBaseMT + NetlistBaseMT {}
/// Defines ID types of a netlist and layout.
/// Implemented automatically.
pub trait L2NIds: LayoutIds + NetlistIds {}
impl<LN> L2NIds for LN where LN: LayoutIds + NetlistIds {}
/// Fused layout and netlist view.
/// This trait makes the link between netlist elements and layout elements.
#[portrait::make]
pub trait L2NBase: LayoutBase + NetlistBase {
/// Iterate over all shapes that are marked to belong to the specified net.
fn shapes_of_net(&self, net_id: &Self::NetId) -> Box<dyn Iterator<Item = Self::ShapeId> + '_>;
/// Iterate over all shapes that are part of the pin.
fn shapes_of_pin(&self, pin_id: &Self::PinId) -> Box<dyn Iterator<Item = Self::ShapeId> + '_>;
/// Get the net of a shape.
fn get_net_of_shape(&self, shape_id: &Self::ShapeId) -> Option<Self::NetId>;
/// Get the pin that belongs to the shape (if any).
fn get_pin_of_shape(&self, shape_id: &Self::ShapeId) -> Option<Self::PinId>;
}
/// Fused layout and netlist view.
/// This trait makes the link between netlist elements and layout elements.
#[portrait::make]
pub trait L2NEdit: L2NBase + LayoutEdit + NetlistEdit {
/// Create the link between a circuit pin and its shapes in the layout.
/// Return the current pin.
fn set_pin_of_shape(
&mut self,
shape_id: &Self::ShapeId,
pin: Option<Self::PinId>,
) -> Option<Self::PinId>;
/// Set the net of a shape.
/// Return the current net.
fn set_net_of_shape(
&mut self,
shape_id: &Self::ShapeId,
net: Option<Self::NetId>,
) -> Option<Self::NetId>;
}