use libreda_db::prelude as db;
use std::collections::HashSet;
#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
pub enum PlacementStatus {
Fixed,
Movable,
Ignore,
}
pub trait PlacementProblem<C: db::L2NBase> {
fn fused_layout_netlist(&self) -> &C;
fn top_cell(&self) -> C::CellId;
fn placement_region(&self) -> Vec<db::SimpleRPolygon<C::Coord>>;
fn soft_blockages(&self) -> Vec<db::SimpleRPolygon<C::Coord>> {
vec![]
}
fn initial_position(&self, cell_instance: &C::CellInstId) -> db::SimpleTransform<C::Coord>;
fn placement_status(&self, cell_instance: &C::CellInstId) -> PlacementStatus;
fn cell_outline(&self, cell: &C::CellId) -> Option<db::Rect<C::Coord>>;
fn cell_instance_outline(&self, cell_instance: &C::CellInstId) -> Option<db::Rect<C::Coord>> {
let template = self.fused_layout_netlist().template_cell(cell_instance);
self.cell_outline(&template)
}
fn net_weight(&self, _net: &C::NetId) -> f64 {
1.0
}
fn get_fixed_instances(&self) -> HashSet<C::CellInstId> {
self.fused_layout_netlist()
.each_cell_instance(&self.top_cell())
.filter(|inst| self.placement_status(inst) == PlacementStatus::Fixed)
.collect()
}
fn get_movable_instances(&self) -> HashSet<C::CellInstId> {
self.fused_layout_netlist()
.each_cell_instance(&self.top_cell())
.filter(|inst| self.placement_status(inst) == PlacementStatus::Movable)
.collect()
}
}