Trait libreda_db::hierarchy::traits::HierarchyEdit
source · pub trait HierarchyEdit: HierarchyBase {
// Required methods
fn create_cell(&mut self, name: Self::NameType) -> Self::CellId;
fn remove_cell(&mut self, cell_id: &Self::CellId);
fn create_cell_instance(
&mut self,
parent_cell: &Self::CellId,
template_cell: &Self::CellId,
name: Option<Self::NameType>
) -> Self::CellInstId;
fn remove_cell_instance(&mut self, inst: &Self::CellInstId);
fn rename_cell_instance(
&mut self,
inst: &Self::CellInstId,
new_name: Option<Self::NameType>
);
fn rename_cell(&mut self, cell: &Self::CellId, new_name: Self::NameType);
// Provided methods
fn set_chip_property(&mut self, key: Self::NameType, value: PropertyValue) { ... }
fn set_cell_property(
&mut self,
cell: &Self::CellId,
key: Self::NameType,
value: PropertyValue
) { ... }
fn set_cell_instance_property(
&mut self,
inst: &Self::CellInstId,
key: Self::NameType,
value: PropertyValue
) { ... }
}
Expand description
Edit functions for a hierarchical flyweight structure like a netlist or a cell-based layout.
Required Methods§
sourcefn create_cell(&mut self, name: Self::NameType) -> Self::CellId
fn create_cell(&mut self, name: Self::NameType) -> Self::CellId
Create a new and empty cell template. A cell template can be be instantiated in other cells.
Example
use libreda_db::prelude::*;
let mut chip = Chip::new();
let my_cell = chip.create_cell("myCell".into());
assert_eq!(chip.num_cells(), 1);
assert_eq!(chip.cell_by_name("myCell"), Some(my_cell));
sourcefn remove_cell(&mut self, cell_id: &Self::CellId)
fn remove_cell(&mut self, cell_id: &Self::CellId)
Remove a cell and all the instances of it.
Example
use libreda_db::prelude::*;
let mut chip = Chip::new();
let top = chip.create_cell("TOP".into());
assert_eq!(chip.num_cells(), 1);
chip.remove_cell(&top);
assert_eq!(chip.num_cells(), 0);
sourcefn create_cell_instance(
&mut self,
parent_cell: &Self::CellId,
template_cell: &Self::CellId,
name: Option<Self::NameType>
) -> Self::CellInstId
fn create_cell_instance( &mut self, parent_cell: &Self::CellId, template_cell: &Self::CellId, name: Option<Self::NameType> ) -> Self::CellInstId
Create a new instance of template_cell
in parent_cell
.
Recursive instantiation is forbidden and might panic.
Example
use libreda_db::prelude::*;
let mut chip = Chip::new();
let top = chip.create_cell("TOP".into());
let sub = chip.create_cell("SUB".into());
// Create two instances of "SUB" inside "TOP".
let inst1 = chip.create_cell_instance(&top, &sub, Some("sub1".into())); // Create named instance.
let inst2 = chip.create_cell_instance(&top, &sub, None); // Create unnamed instance.
assert_eq!(chip.num_child_instances(&top), 2);
assert_eq!(chip.num_cell_references(&sub), 2);
sourcefn remove_cell_instance(&mut self, inst: &Self::CellInstId)
fn remove_cell_instance(&mut self, inst: &Self::CellInstId)
Remove cell instance if it exists.
Example
use libreda_db::prelude::*;
let mut chip = Chip::new();
let top = chip.create_cell("TOP".into());
let sub = chip.create_cell("SUB".into());
// Create two instances of "SUB" inside "TOP".
let inst1 = chip.create_cell_instance(&top, &sub, Some("sub1".into())); // Create named instance.
let inst2 = chip.create_cell_instance(&top, &sub, None); // Create unnamed instance.
assert_eq!(chip.num_child_instances(&top), 2);
assert_eq!(chip.num_cell_references(&sub), 2);
chip.remove_cell_instance(&inst2);
assert_eq!(chip.num_child_instances(&top), 1);
assert_eq!(chip.num_cell_references(&sub), 1);
sourcefn rename_cell_instance(
&mut self,
inst: &Self::CellInstId,
new_name: Option<Self::NameType>
)
fn rename_cell_instance( &mut self, inst: &Self::CellInstId, new_name: Option<Self::NameType> )
Change the name of a cell instance.
Clears the name when None
is passed.
Panics
Panics if an instance with this name already exists in the parent cell.
sourcefn rename_cell(&mut self, cell: &Self::CellId, new_name: Self::NameType)
fn rename_cell(&mut self, cell: &Self::CellId, new_name: Self::NameType)
Provided Methods§
sourcefn set_chip_property(&mut self, key: Self::NameType, value: PropertyValue)
fn set_chip_property(&mut self, key: Self::NameType, value: PropertyValue)
Set a property of the top-level chip data structure..
sourcefn set_cell_property(
&mut self,
cell: &Self::CellId,
key: Self::NameType,
value: PropertyValue
)
fn set_cell_property( &mut self, cell: &Self::CellId, key: Self::NameType, value: PropertyValue )
Set a property of a cell.
sourcefn set_cell_instance_property(
&mut self,
inst: &Self::CellInstId,
key: Self::NameType,
value: PropertyValue
)
fn set_cell_instance_property( &mut self, inst: &Self::CellInstId, key: Self::NameType, value: PropertyValue )
Set a property of a cell instance.