Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/abstract' into routing-api
Browse files Browse the repository at this point in the history
  • Loading branch information
rohanku committed Dec 30, 2023
2 parents 5d86b7d + 350cb20 commit 46a43f9
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 5 deletions.
32 changes: 32 additions & 0 deletions libs/atoll/src/grid.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
//! Uniform routing grids and layer stacks.
use crate::{PointState, RoutingDir};
use grid::Grid;
use num::integer::{div_ceil, div_floor};
use serde::{Deserialize, Serialize};
use std::any::Any;
use std::collections::HashMap;
Expand Down Expand Up @@ -282,6 +283,37 @@ impl<'a, L: AtollLayer> LayerSlice<'a, L> {
);
self.stack.layer(layer)
}

/// Expands a rectangle in physical coordinates to LCM units.
pub fn expand_to_lcm_units(&self, rect: Rect) -> Rect {
let xmin = div_floor(rect.left(), self.lcm_unit_width());
let xmax = div_ceil(rect.right(), self.lcm_unit_width());
let ymin = div_floor(rect.bot(), self.lcm_unit_height());
let ymax = div_ceil(rect.top(), self.lcm_unit_height());
Rect::from_sides(xmin, ymin, xmax, ymax)
}

/// Shrinks a rectangle in physical coordinates to LCM units.
pub fn shrink_to_lcm_units(&self, rect: Rect) -> Option<Rect> {
let xmin = div_ceil(rect.left(), self.lcm_unit_width());
let xmax = div_floor(rect.right(), self.lcm_unit_width());
let ymin = div_ceil(rect.bot(), self.lcm_unit_height());
let ymax = div_floor(rect.top(), self.lcm_unit_height());
Rect::from_sides_option(xmin, ymin, xmax, ymax)
}

/// Converts a point in LCM units to a point in physical units.
pub fn lcm_to_physical(&self, pt: Point) -> Point {
Point::new(pt.x * self.lcm_unit_width(), pt.y * self.lcm_unit_height())
}

/// Converts a rectangle in LCM units to a point in physical units.
pub fn lcm_to_physical_rect(&self, rect: Rect) -> Rect {
Rect::new(
self.lcm_to_physical(rect.lower_left()),
self.lcm_to_physical(rect.upper_right()),
)
}
}

/// A fixed-size routing grid.
Expand Down
11 changes: 6 additions & 5 deletions pdks/sky130pdk/src/atoll/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,7 @@ impl Layout<Sky130Pdk> for NmosTile {
) -> substrate::error::Result<Self::LayoutData> {
let stack = cell.ctx.get_installation::<LayerStack<PdkLayer>>().unwrap();
let grid = RoutingGrid::new((*stack).clone(), 0..2);
let slice = stack.slice(0..2);

let tracks = (0..self.nf + 1)
.map(|i| {
Expand Down Expand Up @@ -219,8 +220,6 @@ impl Layout<Sky130Pdk> for NmosTile {
self.w,
);
cell.draw(Shape::new(cell.ctx.layers.diff, diff))?;
let nsdm = diff.expand_all(130);
cell.draw(Shape::new(cell.ctx.layers.nsdm, nsdm))?;

let poly = Rect::from_sides(
gates[0].left(),
Expand Down Expand Up @@ -249,9 +248,11 @@ impl Layout<Sky130Pdk> for NmosTile {
cell.draw(Shape::new(cell.ctx.layers.licon1, cut))?;
}

let pwell = cell.bbox().unwrap();
cell.draw(Shape::new(cell.ctx.layers.pwell, pwell))?;
io.b.push(IoShape::with_layers(cell.ctx.layers.pwell, pwell));
let bbox = cell.bbox().unwrap();
let lcm_bbox = slice.lcm_to_physical_rect(slice.expand_to_lcm_units(bbox));
cell.draw(Shape::new(cell.ctx.layers.nsdm, lcm_bbox))?;
cell.draw(Shape::new(cell.ctx.layers.pwell, lcm_bbox))?;
io.b.push(IoShape::with_layers(cell.ctx.layers.pwell, lcm_bbox));

Ok(())
}
Expand Down

0 comments on commit 46a43f9

Please sign in to comment.