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

Show 29 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; 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

Type for names of cells, instances, etc.

Cell/module identifier type.

Cell instance identifier type.

Required Methods

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

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

Get the name of the cell.

Get the name of the cell instance.

Get the ID of the parent cell of this instance.

Get the ID of the template cell of this instance.

Call a function on each cell of the netlist.

Call a function on each instance in this cell.

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

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

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

Get the number of cell instances inside the cell.

Get the number of cell templates.

Provided Methods

Get a Vec of all cell IDs in this netlist.

Iterate over all cells.

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

Iterate over all instances in a cell.

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

Iterate over all cells that are instantiated in this cell.

Count all cells that are dependencies of cell.

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

Iterate over each cell that directly depends on cell.

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

Get a Vec with all cell instances referencing this cell.

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

Count all instantiations of cell.

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

Get a property of a cell.

Get a property of a cell instance.

Implementors