pub trait HierarchyBase: HierarchyIds {
    type NameType: Eq + Hash + From<String> + Into<String> + Clone + Borrow<String> + Borrow<str> + PartialOrd + Ord + Display + Debug;

Show 29 methods // Required methods fn cell_by_name(&self, name: &str) -> Option<Self::CellId>; fn cell_instance_by_name( &self, parent_cell: &Self::CellId, name: &str ) -> Option<Self::CellInstId>; fn cell_name(&self, cell: &Self::CellId) -> Self::NameType; fn cell_instance_name( &self, cell_inst: &Self::CellInstId ) -> Option<Self::NameType>; fn parent_cell(&self, cell_instance: &Self::CellInstId) -> Self::CellId; fn template_cell(&self, cell_instance: &Self::CellInstId) -> Self::CellId; fn for_each_cell<F>(&self, f: F) where F: FnMut(Self::CellId); fn for_each_cell_instance<F>(&self, cell: &Self::CellId, f: F) where F: FnMut(Self::CellInstId); fn for_each_cell_dependency<F>(&self, cell: &Self::CellId, f: F) where F: FnMut(Self::CellId); fn for_each_dependent_cell<F>(&self, cell: &Self::CellId, f: F) where F: FnMut(Self::CellId); fn for_each_cell_reference<F>(&self, cell: &Self::CellId, f: F) where F: FnMut(Self::CellInstId); fn num_child_instances(&self, cell: &Self::CellId) -> usize; fn num_cells(&self) -> usize; // Provided methods fn each_cell_vec(&self) -> Vec<Self::CellId> { ... } fn each_cell(&self) -> Box<dyn Iterator<Item = Self::CellId> + '_> { ... } fn each_cell_instance_vec( &self, cell: &Self::CellId ) -> Vec<Self::CellInstId> { ... } fn each_cell_instance( &self, cell: &Self::CellId ) -> Box<dyn Iterator<Item = Self::CellInstId> + '_> { ... } fn each_cell_dependency_vec(&self, cell: &Self::CellId) -> Vec<Self::CellId> { ... } fn each_cell_dependency<'a>( &'a self, cell: &Self::CellId ) -> Box<dyn Iterator<Item = Self::CellId> + 'a> { ... } fn num_cell_dependencies(&self, cell: &Self::CellId) -> usize { ... } fn each_dependent_cell_vec(&self, cell: &Self::CellId) -> Vec<Self::CellId> { ... } fn each_dependent_cell<'a>( &'a self, cell: &Self::CellId ) -> Box<dyn Iterator<Item = Self::CellId> + 'a> { ... } fn num_dependent_cells(&self, cell: &Self::CellId) -> usize { ... } fn each_cell_reference_vec( &self, cell: &Self::CellId ) -> Vec<Self::CellInstId> { ... } fn each_cell_reference( &self, cell: &Self::CellId ) -> Box<dyn Iterator<Item = Self::CellInstId> + '_> { ... } fn num_cell_references(&self, cell: &Self::CellId) -> usize { ... } fn get_chip_property(&self, key: &Self::NameType) -> Option<PropertyValue> { ... } fn get_cell_property( &self, cell: &Self::CellId, key: &Self::NameType ) -> Option<PropertyValue> { ... } fn get_cell_instance_property( &self, inst: &Self::CellInstId, key: &Self::NameType ) -> Option<PropertyValue> { ... }
}
Expand description

Most basic trait for the hierarchical flyweight pattern which is used to efficiently represent chip layouts and netlists.

Component relations

A netlist consists of cells which are templates for cell instances. Each cell may contain such instances of other cells.

The following diagram illustrates how this composition graph can be traversed using the functions defined by HierarchyBase.

                         each_cell_dependency
                     +---------------------------+
                     |                           |
                     +                           v
      +----------------+   each_dependent_cell  +------------------+
      |Circuit (Top)   |<----------------------+|Circuit (Sub)     |
      +----------------+                        +------------------+
      |+              ^|                        | ^   +            |
      ||each_instance ||                        | |   |            |
      ||              ||                        | |   |            |
      ||              |parent                   | |   |            |
      ||              ||                        | |   |            |
      ||+-----------+ ||                        | |   |            |
 +--> |>|Inst1 (Sub)|-+|                        | |   |            |
 |    ||+-----------+  |                        | |   |            |
 |    ||               |                        | |   |            |
 |    ||               |                        +-|---|------------+
 |    ||               |                          |   |
 |    ||+-----------+  |  template                |   |
 +--> |>|Inst2 (Sub)|+----------------------------+   |
 |    | +-----------+  |                              |
 |    |                |                              |
 |    |                |                              |
 |    +----------------+                              |
 |                                                    |
 |                         each_reference             |
 +----------------------------------------------------+

Example

Basic hierchy operations:

use libreda_db::chip::Chip;
use libreda_db::traits::{HierarchyBase, HierarchyEdit};

// Create a simple hierarchical structure.
let mut chip = Chip::new();
let top_cell = chip.create_cell("MyTopCell".into());
let sub_cell = chip.create_cell("MySubCell".into());
// Create an instance of `sub_cell` inside `top_cell`.
let inst = chip.create_cell_instance(&top_cell, &sub_cell, Some("inst1".into()));

// Get all cells.
assert_eq!(chip.each_cell().count(), 2);

// Iterate over child instances.
assert_eq!(chip.each_cell_instance(&top_cell).next().as_ref(), Some(&inst));

// Get the template of an instance.
assert_eq!(&chip.template_cell(&inst), &sub_cell);

// Get the parent of an instance.
assert_eq!(&chip.parent_cell(&inst), &top_cell);

Required Associated Types§

source

type NameType: Eq + Hash + From<String> + Into<String> + Clone + Borrow<String> + Borrow<str> + PartialOrd + Ord + Display + Debug

Type for names of cells, instances, etc.

Required Methods§

source

fn cell_by_name(&self, name: &str) -> Option<Self::CellId>

Find a cell by its name. Return the cell with the given name. Returns None if the cell does not exist.

source

fn cell_instance_by_name( &self, parent_cell: &Self::CellId, name: &str ) -> Option<Self::CellInstId>

Find a cell instance by its name. Returns None if the name does not exist.

source

fn cell_name(&self, cell: &Self::CellId) -> Self::NameType

Get the name of the cell.

source

fn cell_instance_name( &self, cell_inst: &Self::CellInstId ) -> Option<Self::NameType>

Get the name of the cell instance.

source

fn parent_cell(&self, cell_instance: &Self::CellInstId) -> Self::CellId

Get the ID of the parent cell of this instance.

source

fn template_cell(&self, cell_instance: &Self::CellInstId) -> Self::CellId

Get the ID of the template cell of this instance.

source

fn for_each_cell<F>(&self, f: F)where F: FnMut(Self::CellId),

Call a function on each cell of the netlist.

source

fn for_each_cell_instance<F>(&self, cell: &Self::CellId, f: F)where F: FnMut(Self::CellInstId),

Call a function on each instance in this cell.

source

fn for_each_cell_dependency<F>(&self, cell: &Self::CellId, f: F)where F: FnMut(Self::CellId),

Call a function for each cell that is a child of this cell.

source

fn for_each_dependent_cell<F>(&self, cell: &Self::CellId, f: F)where F: FnMut(Self::CellId),

Call a function for each cell that directly depends on cell.

source

fn for_each_cell_reference<F>(&self, cell: &Self::CellId, f: F)where F: FnMut(Self::CellInstId),

Iterate over all instances of this cell, i.e. instances that use this cell as a template.

source

fn num_child_instances(&self, cell: &Self::CellId) -> usize

Get the number of cell instances inside the cell.

source

fn num_cells(&self) -> usize

Get the number of cell templates.

Provided Methods§

source

fn each_cell_vec(&self) -> Vec<Self::CellId>

Get a Vec of all cell IDs in this netlist.

source

fn each_cell(&self) -> Box<dyn Iterator<Item = Self::CellId> + '_>

Iterate over all cells.

source

fn each_cell_instance_vec(&self, cell: &Self::CellId) -> Vec<Self::CellInstId>

Get a Vec of the IDs of all instances in this cell.

source

fn each_cell_instance( &self, cell: &Self::CellId ) -> Box<dyn Iterator<Item = Self::CellInstId> + '_>

Iterate over all instances in a cell.

source

fn each_cell_dependency_vec(&self, cell: &Self::CellId) -> Vec<Self::CellId>

Get a Vec of each cell that is a child of this cell.

source

fn each_cell_dependency<'a>( &'a self, cell: &Self::CellId ) -> Box<dyn Iterator<Item = Self::CellId> + 'a>

Iterate over all cells that are instantiated in this cell.

source

fn num_cell_dependencies(&self, cell: &Self::CellId) -> usize

Count all cells that are dependencies of cell.

source

fn each_dependent_cell_vec(&self, cell: &Self::CellId) -> Vec<Self::CellId>

Get a Vec of each cell that directly depends on cell.

source

fn each_dependent_cell<'a>( &'a self, cell: &Self::CellId ) -> Box<dyn Iterator<Item = Self::CellId> + 'a>

Iterate over each cell that directly depends on cell.

source

fn num_dependent_cells(&self, cell: &Self::CellId) -> usize

Count all cells that are directly dependent on cell, i.e. contain an instance of cell.

source

fn each_cell_reference_vec(&self, cell: &Self::CellId) -> Vec<Self::CellInstId>

Get a Vec with all cell instances referencing this cell.

source

fn each_cell_reference( &self, cell: &Self::CellId ) -> Box<dyn Iterator<Item = Self::CellInstId> + '_>

Iterate over all instances of this cell, i.e. instances that use this cell as a template.

source

fn num_cell_references(&self, cell: &Self::CellId) -> usize

Count all instantiations of cell.

source

fn get_chip_property(&self, key: &Self::NameType) -> Option<PropertyValue>

Get a property of the top-level chip data structure.

source

fn get_cell_property( &self, cell: &Self::CellId, key: &Self::NameType ) -> Option<PropertyValue>

Get a property of a cell.

source

fn get_cell_instance_property( &self, inst: &Self::CellInstId, key: &Self::NameType ) -> Option<PropertyValue>

Get a property of a cell instance.

Implementors§

source§

impl HierarchyBase for Chip<Coord>

source§

impl<'a, H: HierarchyBase + 'static> HierarchyBase for DBPerf<'a, H>

source§

impl<'a, N: HierarchyBase> HierarchyBase for FlatView<'a, N>

source§

impl<'a, T> HierarchyBase for LibraryWrapper<'a, T>where T: HierarchyBase,

source§

impl<'b, H> HierarchyBase for RegionSearchAdapter<'b, H>where H: LayoutBase + 'static, H::Coord: PrimInt + Signed + Debug,

source§

impl<'b, N, U> HierarchyBase for Undo<'b, N, U>where N: HierarchyBase,