pub struct FlatView<'a, N> { /* private fields */ }
Expand description

Wrapper around a netlist which provides an on-the-fly flat view of a certain cell. The presented view is flattened until leaf cells. Internally this works by using component IDs that are actually paths through the hierarchy.

Names are constructed by concatenating the names of the path elements with a separator string in between.

Example

use libreda_db::prelude::{Chip, HierarchyBase, HierarchyEdit, FlatView};

// Create a simple hierarchy.
let mut chip = Chip::new();
let top = chip.create_cell("TOP".into());
let intermediate = chip.create_cell("INTERMEDIATE".into());
let leaf1 = chip.create_cell("LEAF1".into());
let leaf2 = chip.create_cell("LEAF2".into());

// The intermediate cell contains two instances of leaf1 and one instance of leaf2.
chip.create_cell_instance(&intermediate, &leaf1, Some("leaf1_inst1".into()));
chip.create_cell_instance(&intermediate, &leaf1, Some("leaf1_inst2".into()));
chip.create_cell_instance(&intermediate, &leaf2, Some("leaf2_inst1".into()));

// Create two instances of the intermediate cell in the TOP cell.
chip.create_cell_instance(&top, &intermediate, Some("intermediate1".into()));
chip.create_cell_instance(&top, &intermediate, Some("intermediate2".into()));

// Create the flat view.

let flat = FlatView::new_with_separator(&chip, ":".to_string());
let flat_top = flat.cell_by_name("TOP").expect("TOP not found in flat view.");
// There are 2 instances of the intermediate cell which contains 3 leaf cells,
// so now the flattened top should contain 2*3 instances.
assert_eq!(flat.num_child_instances(&flat_top), 2*3);

// Get a cell instance with the path string.
let inst = flat.cell_instance_by_name(&flat_top, "intermediate1:leaf1_inst1").expect("Instance not found.");
// Instance names are assembled from the path.
assert_eq!(flat.cell_instance_name(&inst).unwrap().as_str(), "intermediate1:leaf1_inst1");

// There should be 4 instances of the LEAF1 cell now.
assert_eq!(flat.each_cell_reference(&leaf1).count(), 2*2);

Implementations

Create a new flat view of base. Use “/” as a path separator in names.

Create a new flat view of base. Use a custom path separator in concatenated names.

Trait Implementations

Type for names of cells, instances, etc.

Cell/module identifier type.

Cell instance identifier type.

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

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

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. Read more

Get the number of cell instances inside the cell.

Get the number of cell templates.

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. Read more

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.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Check if the cell is a top level cell. This is done by checking that no other cells have an instance of this cell. Read more

Check if the cell is a leaf cell. This is done by checking that this cell contains no other cell instances. Read more

Iterate over all top level cells.

Iterate over all leaf cells, i.e. cells which contain no other cells.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.