Struct libreda_pnr::db::FlatView
source · [−]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
sourceimpl<'a, N> FlatView<'a, N> where
N: HierarchyBase,
impl<'a, N> FlatView<'a, N> where
N: HierarchyBase,
Trait Implementations
sourceimpl<'a, N> HierarchyBase for FlatView<'a, N> where
N: HierarchyBase,
impl<'a, N> HierarchyBase for FlatView<'a, N> where
N: HierarchyBase,
type NameType = <N as HierarchyBase>::NameType
type NameType = <N as HierarchyBase>::NameType
Type for names of cells, instances, etc.
type CellId = <N as HierarchyBase>::CellId
type CellId = <N as HierarchyBase>::CellId
Cell/module identifier type.
type CellInstId = Vec<<N as HierarchyBase>::CellInstId, Global>
type CellInstId = Vec<<N as HierarchyBase>::CellInstId, Global>
Cell instance identifier type.
sourcepub fn cell_by_name(
&self,
name: &str
) -> Option<<FlatView<'a, N> as HierarchyBase>::CellId>
pub fn cell_by_name(
&self,
name: &str
) -> Option<<FlatView<'a, N> as HierarchyBase>::CellId>
Find a cell by its name.
Return the cell with the given name. Returns None
if the cell does not exist. Read more
sourcepub fn cell_instance_by_name(
&self,
parent_cell: &<FlatView<'a, N> as HierarchyBase>::CellId,
name: &str
) -> Option<<FlatView<'a, N> as HierarchyBase>::CellInstId>
pub fn cell_instance_by_name(
&self,
parent_cell: &<FlatView<'a, N> as HierarchyBase>::CellId,
name: &str
) -> Option<<FlatView<'a, N> as HierarchyBase>::CellInstId>
Find a cell instance by its name.
Returns None
if the name does not exist. Read more
sourcepub fn cell_name(
&self,
cell: &<FlatView<'a, N> as HierarchyBase>::CellId
) -> <FlatView<'a, N> as HierarchyBase>::NameType
pub fn cell_name(
&self,
cell: &<FlatView<'a, N> as HierarchyBase>::CellId
) -> <FlatView<'a, N> as HierarchyBase>::NameType
Get the name of the cell.
sourcepub fn cell_instance_name(
&self,
cell_inst: &<FlatView<'a, N> as HierarchyBase>::CellInstId
) -> Option<<FlatView<'a, N> as HierarchyBase>::NameType>
pub fn cell_instance_name(
&self,
cell_inst: &<FlatView<'a, N> as HierarchyBase>::CellInstId
) -> Option<<FlatView<'a, N> as HierarchyBase>::NameType>
Get the name of the cell instance.
sourcepub fn parent_cell(
&self,
cell_instance: &<FlatView<'a, N> as HierarchyBase>::CellInstId
) -> <FlatView<'a, N> as HierarchyBase>::CellId
pub fn parent_cell(
&self,
cell_instance: &<FlatView<'a, N> as HierarchyBase>::CellInstId
) -> <FlatView<'a, N> as HierarchyBase>::CellId
Get the ID of the parent cell of this instance.
sourcepub fn template_cell(
&self,
cell_instance: &<FlatView<'a, N> as HierarchyBase>::CellInstId
) -> <FlatView<'a, N> as HierarchyBase>::CellId
pub fn template_cell(
&self,
cell_instance: &<FlatView<'a, N> as HierarchyBase>::CellInstId
) -> <FlatView<'a, N> as HierarchyBase>::CellId
Get the ID of the template cell of this instance.
sourcepub fn for_each_cell<F>(&self, f: F) where
F: FnMut(<FlatView<'a, N> as HierarchyBase>::CellId),
pub fn for_each_cell<F>(&self, f: F) where
F: FnMut(<FlatView<'a, N> as HierarchyBase>::CellId),
Call a function on each cell of the netlist.
sourcepub fn for_each_cell_instance<F>(
&self,
cell: &<FlatView<'a, N> as HierarchyBase>::CellId,
f: F
) where
F: FnMut(<FlatView<'a, N> as HierarchyBase>::CellInstId),
pub fn for_each_cell_instance<F>(
&self,
cell: &<FlatView<'a, N> as HierarchyBase>::CellId,
f: F
) where
F: FnMut(<FlatView<'a, N> as HierarchyBase>::CellInstId),
Call a function on each instance in this cell.
sourcepub fn for_each_cell_dependency<F>(
&self,
cell: &<FlatView<'a, N> as HierarchyBase>::CellId,
f: F
) where
F: FnMut(<FlatView<'a, N> as HierarchyBase>::CellId),
pub fn for_each_cell_dependency<F>(
&self,
cell: &<FlatView<'a, N> as HierarchyBase>::CellId,
f: F
) where
F: FnMut(<FlatView<'a, N> as HierarchyBase>::CellId),
Call a function for each cell that is a child of this cell
.
sourcepub fn for_each_dependent_cell<F>(
&self,
cell: &<FlatView<'a, N> as HierarchyBase>::CellId,
f: F
) where
F: FnMut(<FlatView<'a, N> as HierarchyBase>::CellId),
pub fn for_each_dependent_cell<F>(
&self,
cell: &<FlatView<'a, N> as HierarchyBase>::CellId,
f: F
) where
F: FnMut(<FlatView<'a, N> as HierarchyBase>::CellId),
Call a function for each cell that directly depends on cell
.
sourcepub fn for_each_cell_reference<F>(
&self,
cell: &<FlatView<'a, N> as HierarchyBase>::CellId,
f: F
) where
F: FnMut(<FlatView<'a, N> as HierarchyBase>::CellInstId),
pub fn for_each_cell_reference<F>(
&self,
cell: &<FlatView<'a, N> as HierarchyBase>::CellId,
f: F
) where
F: FnMut(<FlatView<'a, N> as HierarchyBase>::CellInstId),
Iterate over all instances of this cell
, i.e. instances that use this cell as
a template. Read more
sourcepub fn num_child_instances(
&self,
cell: &<FlatView<'a, N> as HierarchyBase>::CellId
) -> usize
pub fn num_child_instances(
&self,
cell: &<FlatView<'a, N> as HierarchyBase>::CellId
) -> usize
Get the number of cell instances inside the cell
.
sourcefn each_cell_vec(&self) -> Vec<Self::CellId, Global>
fn each_cell_vec(&self) -> Vec<Self::CellId, Global>
Get a Vec
of all cell IDs in this netlist.
sourcefn each_cell_instance_vec(
&self,
cell: &Self::CellId
) -> Vec<Self::CellInstId, Global>
fn each_cell_instance_vec(
&self,
cell: &Self::CellId
) -> Vec<Self::CellInstId, Global>
Get a Vec
of the IDs of all instances in this cell.
sourcefn each_cell_instance(
&self,
cell: &Self::CellId
) -> Box<dyn Iterator<Item = Self::CellInstId>, Global>
fn each_cell_instance(
&self,
cell: &Self::CellId
) -> Box<dyn Iterator<Item = Self::CellInstId>, Global>
Iterate over all instances in a cell.
sourcefn each_cell_dependency_vec(
&self,
cell: &Self::CellId
) -> Vec<Self::CellId, Global>
fn each_cell_dependency_vec(
&self,
cell: &Self::CellId
) -> Vec<Self::CellId, Global>
Get a Vec
of each cell that is a child of this cell
.
sourcefn each_cell_dependency(
&'a self,
cell: &Self::CellId
) -> Box<dyn Iterator<Item = Self::CellId> + 'a, Global>
fn each_cell_dependency(
&'a self,
cell: &Self::CellId
) -> Box<dyn Iterator<Item = Self::CellId> + 'a, Global>
Iterate over all cells that are instantiated in this cell
.
sourcefn num_cell_dependencies(&self, cell: &Self::CellId) -> usize
fn num_cell_dependencies(&self, cell: &Self::CellId) -> usize
Count all cells that are dependencies of cell
.
sourcefn each_dependent_cell_vec(
&self,
cell: &Self::CellId
) -> Vec<Self::CellId, Global>
fn each_dependent_cell_vec(
&self,
cell: &Self::CellId
) -> Vec<Self::CellId, Global>
Get a Vec
of each cell that directly depends on cell
.
sourcefn each_dependent_cell(
&'a self,
cell: &Self::CellId
) -> Box<dyn Iterator<Item = Self::CellId> + 'a, Global>
fn each_dependent_cell(
&'a self,
cell: &Self::CellId
) -> Box<dyn Iterator<Item = Self::CellId> + 'a, Global>
Iterate over each cell that directly depends on cell
.
sourcefn num_dependent_cells(&self, cell: &Self::CellId) -> usize
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
.
sourcefn each_cell_reference_vec(
&self,
cell: &Self::CellId
) -> Vec<Self::CellInstId, Global>
fn each_cell_reference_vec(
&self,
cell: &Self::CellId
) -> Vec<Self::CellInstId, Global>
Get a Vec
with all cell instances referencing this cell.
sourcefn each_cell_reference(
&self,
cell: &Self::CellId
) -> Box<dyn Iterator<Item = Self::CellInstId>, Global>
fn each_cell_reference(
&self,
cell: &Self::CellId
) -> Box<dyn Iterator<Item = Self::CellInstId>, Global>
Iterate over all instances of this cell
, i.e. instances that use this cell as
a template. Read more
sourcefn num_cell_references(&self, cell: &Self::CellId) -> usize
fn num_cell_references(&self, cell: &Self::CellId) -> usize
Count all instantiations of cell
.
sourcefn get_chip_property(&self, key: &Self::NameType) -> Option<PropertyValue>
fn get_chip_property(&self, key: &Self::NameType) -> Option<PropertyValue>
Get a property of the top-level chip data structure.
sourcefn get_cell_property(
&self,
cell: &Self::CellId,
key: &Self::NameType
) -> Option<PropertyValue>
fn get_cell_property(
&self,
cell: &Self::CellId,
key: &Self::NameType
) -> Option<PropertyValue>
Get a property of a cell.
sourcefn get_cell_instance_property(
&self,
inst: &Self::CellInstId,
key: &Self::NameType
) -> Option<PropertyValue>
fn get_cell_instance_property(
&self,
inst: &Self::CellInstId,
key: &Self::NameType
) -> Option<PropertyValue>
Get a property of a cell instance.
Auto Trait Implementations
impl<'a, N> RefUnwindSafe for FlatView<'a, N> where
N: RefUnwindSafe,
impl<'a, N> Send for FlatView<'a, N> where
N: Sync,
impl<'a, N> Sync for FlatView<'a, N> where
N: Sync,
impl<'a, N> Unpin for FlatView<'a, N>
impl<'a, N> UnwindSafe for FlatView<'a, N> where
N: RefUnwindSafe,
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcepub fn borrow_mut(&mut self) -> &mut T
pub fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> HierarchyReferenceAccess for T where
T: HierarchyBase,
impl<T> HierarchyReferenceAccess for T where
T: HierarchyBase,
sourcefn each_cell_ref(&self) -> Box<dyn Iterator<Item = CellRef<'_, Self>>, Global>
fn each_cell_ref(&self) -> Box<dyn Iterator<Item = CellRef<'_, Self>>, Global>
Iterate over all cell objects.
sourcefn cell_instance_ref(&self, inst_id: &Self::CellInstId) -> CellInstRef<'_, Self>
fn cell_instance_ref(&self, inst_id: &Self::CellInstId) -> CellInstRef<'_, Self>
Get a cell instance object by its ID.
sourceimpl<N> HierarchyUtil for N where
N: HierarchyBase,
impl<N> HierarchyUtil for N where
N: HierarchyBase,
sourcefn is_top_level_cell(&self, cell: &Self::CellId) -> bool
fn is_top_level_cell(&self, cell: &Self::CellId) -> bool
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
sourcefn is_leaf_cell(&self, cell: &Self::CellId) -> bool
fn is_leaf_cell(&self, cell: &Self::CellId) -> bool
Check if the cell is a leaf cell. This is done by checking that this cell contains no other cell instances. Read more