Skip to content

Commit

Permalink
add cell port constructor, consuming must connect setter (#52)
Browse files Browse the repository at this point in the history
  • Loading branch information
rahulk29 authored Oct 18, 2024
1 parent 83de94c commit 1b5af4e
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions substrate/src/layout/cell.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1007,6 +1007,21 @@ impl CellPort {
}
}

pub fn with_shapes(
id: impl Into<PortId>,
layer: LayerKey,
shapes: impl IntoIterator<Item = Shape>,
) -> Self {
let mut map = HashMap::with_capacity(1);
let mut entry = map.entry(layer).or_insert_with(Vec::new);
entry.extend(shapes);
Self {
id: id.into(),
shapes: map,
must_connect: Default::default(),
}
}

pub fn with_element(id: impl Into<PortId>, elem: Element) -> Self {
let mut shapes = HashMap::with_capacity(1);
shapes.insert(elem.layer.layer(), vec![elem.into_inner()]);
Expand Down Expand Up @@ -1037,6 +1052,11 @@ impl CellPort {
self
}

pub fn must_connect(mut self, must_connect: impl Into<MustConnect>) -> Self {
self.set_must_connect(must_connect);
self
}

/// Returns the ID of the port.
#[inline]
pub fn id(&self) -> &PortId {
Expand Down

0 comments on commit 1b5af4e

Please sign in to comment.