mirror of https://codeberg.org/topola/topola.git
refactor(autorouter/autorouter): Store terminating dots in configuration instead of ratsnest
This commit is contained in:
parent
87f63fd96f
commit
d896fe7322
|
|
@ -4,6 +4,7 @@
|
||||||
|
|
||||||
use std::collections::BTreeMap;
|
use std::collections::BTreeMap;
|
||||||
|
|
||||||
|
use derive_getters::Getters;
|
||||||
use geo::{point, Distance, Euclidean, Point};
|
use geo::{point, Distance, Euclidean, Point};
|
||||||
use petgraph::graph::NodeIndex;
|
use petgraph::graph::NodeIndex;
|
||||||
use rstar::{Envelope, RTreeObject, AABB};
|
use rstar::{Envelope, RTreeObject, AABB};
|
||||||
|
|
@ -46,6 +47,7 @@ pub struct AnterouterPlan {
|
||||||
pub ratline_terminating_schemes: BTreeMap<(RatlineUid, FixedDotIndex), TerminatingScheme>,
|
pub ratline_terminating_schemes: BTreeMap<(RatlineUid, FixedDotIndex), TerminatingScheme>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Getters)]
|
||||||
pub struct Anterouter {
|
pub struct Anterouter {
|
||||||
plan: AnterouterPlan,
|
plan: AnterouterPlan,
|
||||||
}
|
}
|
||||||
|
|
@ -60,7 +62,9 @@ impl Anterouter {
|
||||||
autorouter: &mut Autorouter<impl AccessMesadata>,
|
autorouter: &mut Autorouter<impl AccessMesadata>,
|
||||||
recorder: &mut BoardEdit,
|
recorder: &mut BoardEdit,
|
||||||
options: &AnterouterOptions,
|
options: &AnterouterOptions,
|
||||||
) {
|
) -> BTreeMap<(RatlineUid, FixedDotIndex, usize), FixedDotIndex> {
|
||||||
|
let mut terminating_dot_map = BTreeMap::new();
|
||||||
|
|
||||||
// PERF: Unnecessary clone.
|
// PERF: Unnecessary clone.
|
||||||
for (ratline, layer) in self.plan.layer_map.clone().iter() {
|
for (ratline, layer) in self.plan.layer_map.clone().iter() {
|
||||||
let endpoint_indices = ratline.ref_(autorouter).endpoint_indices();
|
let endpoint_indices = ratline.ref_(autorouter).endpoint_indices();
|
||||||
|
|
@ -77,14 +81,10 @@ impl Anterouter {
|
||||||
.get(&(*ratline, endpoint_dots.0))
|
.get(&(*ratline, endpoint_dots.0))
|
||||||
{
|
{
|
||||||
match terminating_scheme {
|
match terminating_scheme {
|
||||||
TerminatingScheme::ExistingFixedDot(terminating_dot) => autorouter
|
TerminatingScheme::ExistingFixedDot(terminating_dot) => {
|
||||||
.ratsnests
|
terminating_dot_map
|
||||||
.on_principal_layer_mut(ratline.principal_layer)
|
.insert((*ratline, endpoint_dots.0, *layer), *terminating_dot);
|
||||||
.assign_terminating_dot_to_ratvertex(
|
}
|
||||||
endpoint_indices.0,
|
|
||||||
*layer,
|
|
||||||
*terminating_dot,
|
|
||||||
),
|
|
||||||
TerminatingScheme::Fanout => self.anteroute_fanout(
|
TerminatingScheme::Fanout => self.anteroute_fanout(
|
||||||
autorouter,
|
autorouter,
|
||||||
recorder,
|
recorder,
|
||||||
|
|
@ -93,6 +93,7 @@ impl Anterouter {
|
||||||
endpoint_dots.0,
|
endpoint_dots.0,
|
||||||
*layer,
|
*layer,
|
||||||
options,
|
options,
|
||||||
|
&mut terminating_dot_map,
|
||||||
),
|
),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -103,14 +104,10 @@ impl Anterouter {
|
||||||
.get(&(*ratline, endpoint_dots.1))
|
.get(&(*ratline, endpoint_dots.1))
|
||||||
{
|
{
|
||||||
match terminating_scheme {
|
match terminating_scheme {
|
||||||
TerminatingScheme::ExistingFixedDot(terminating_dot) => autorouter
|
TerminatingScheme::ExistingFixedDot(terminating_dot) => {
|
||||||
.ratsnests
|
terminating_dot_map
|
||||||
.on_principal_layer_mut(ratline.principal_layer)
|
.insert((*ratline, endpoint_dots.1, *layer), *terminating_dot);
|
||||||
.assign_terminating_dot_to_ratvertex(
|
}
|
||||||
endpoint_indices.1,
|
|
||||||
*layer,
|
|
||||||
*terminating_dot,
|
|
||||||
),
|
|
||||||
TerminatingScheme::Fanout => self.anteroute_fanout(
|
TerminatingScheme::Fanout => self.anteroute_fanout(
|
||||||
autorouter,
|
autorouter,
|
||||||
recorder,
|
recorder,
|
||||||
|
|
@ -119,10 +116,13 @@ impl Anterouter {
|
||||||
endpoint_dots.1,
|
endpoint_dots.1,
|
||||||
*layer,
|
*layer,
|
||||||
options,
|
options,
|
||||||
|
&mut terminating_dot_map,
|
||||||
),
|
),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
terminating_dot_map
|
||||||
}
|
}
|
||||||
|
|
||||||
fn anteroute_fanout(
|
fn anteroute_fanout(
|
||||||
|
|
@ -134,6 +134,7 @@ impl Anterouter {
|
||||||
source_dot: FixedDotIndex,
|
source_dot: FixedDotIndex,
|
||||||
target_layer: usize,
|
target_layer: usize,
|
||||||
options: &AnterouterOptions,
|
options: &AnterouterOptions,
|
||||||
|
terminating_dot_map: &mut BTreeMap<(RatlineUid, FixedDotIndex, usize), FixedDotIndex>,
|
||||||
) {
|
) {
|
||||||
let mut ratline_delta: Point = ratline.ref_(autorouter).line_segment().delta().into();
|
let mut ratline_delta: Point = ratline.ref_(autorouter).line_segment().delta().into();
|
||||||
|
|
||||||
|
|
@ -172,6 +173,7 @@ impl Anterouter {
|
||||||
target_layer,
|
target_layer,
|
||||||
CardinalDirection::nearest_from_vector(ratline_delta),
|
CardinalDirection::nearest_from_vector(ratline_delta),
|
||||||
options,
|
options,
|
||||||
|
terminating_dot_map,
|
||||||
)
|
)
|
||||||
.is_ok()
|
.is_ok()
|
||||||
{
|
{
|
||||||
|
|
@ -207,6 +209,7 @@ impl Anterouter {
|
||||||
target_layer,
|
target_layer,
|
||||||
CardinalDirection::nearest_from_vector(ratline_delta),
|
CardinalDirection::nearest_from_vector(ratline_delta),
|
||||||
options,
|
options,
|
||||||
|
terminating_dot_map,
|
||||||
)
|
)
|
||||||
.is_ok()
|
.is_ok()
|
||||||
{
|
{
|
||||||
|
|
@ -224,6 +227,7 @@ impl Anterouter {
|
||||||
target_layer,
|
target_layer,
|
||||||
OrdinalDirection::nearest_from_vector(ratline_delta),
|
OrdinalDirection::nearest_from_vector(ratline_delta),
|
||||||
options,
|
options,
|
||||||
|
terminating_dot_map,
|
||||||
)
|
)
|
||||||
.is_ok()
|
.is_ok()
|
||||||
{
|
{
|
||||||
|
|
@ -241,6 +245,7 @@ impl Anterouter {
|
||||||
target_layer,
|
target_layer,
|
||||||
OrdinalDirection::nearest_from_vector(ratline_delta),
|
OrdinalDirection::nearest_from_vector(ratline_delta),
|
||||||
options,
|
options,
|
||||||
|
terminating_dot_map,
|
||||||
)
|
)
|
||||||
.is_ok()
|
.is_ok()
|
||||||
{
|
{
|
||||||
|
|
@ -261,6 +266,7 @@ impl Anterouter {
|
||||||
target_layer: usize,
|
target_layer: usize,
|
||||||
preferred_compass_direction: impl CompassDirection,
|
preferred_compass_direction: impl CompassDirection,
|
||||||
options: &AnterouterOptions,
|
options: &AnterouterOptions,
|
||||||
|
terminating_dot_map: &mut BTreeMap<(RatlineUid, FixedDotIndex, usize), FixedDotIndex>,
|
||||||
) -> Result<(), ()> {
|
) -> Result<(), ()> {
|
||||||
if self
|
if self
|
||||||
.anteroute_fanout_on_bbox_in_direction(
|
.anteroute_fanout_on_bbox_in_direction(
|
||||||
|
|
@ -273,6 +279,7 @@ impl Anterouter {
|
||||||
target_layer,
|
target_layer,
|
||||||
preferred_compass_direction,
|
preferred_compass_direction,
|
||||||
options,
|
options,
|
||||||
|
terminating_dot_map,
|
||||||
)
|
)
|
||||||
.is_ok()
|
.is_ok()
|
||||||
{
|
{
|
||||||
|
|
@ -297,6 +304,7 @@ impl Anterouter {
|
||||||
target_layer,
|
target_layer,
|
||||||
counterclockwise_turning_cardinal_direction,
|
counterclockwise_turning_cardinal_direction,
|
||||||
options,
|
options,
|
||||||
|
terminating_dot_map,
|
||||||
)
|
)
|
||||||
.is_ok()
|
.is_ok()
|
||||||
{
|
{
|
||||||
|
|
@ -317,6 +325,7 @@ impl Anterouter {
|
||||||
target_layer,
|
target_layer,
|
||||||
clockwise_turning_cardinal_direction,
|
clockwise_turning_cardinal_direction,
|
||||||
options,
|
options,
|
||||||
|
terminating_dot_map,
|
||||||
)
|
)
|
||||||
.is_ok()
|
.is_ok()
|
||||||
{
|
{
|
||||||
|
|
@ -342,6 +351,7 @@ impl Anterouter {
|
||||||
target_layer: usize,
|
target_layer: usize,
|
||||||
direction: impl Into<Point>,
|
direction: impl Into<Point>,
|
||||||
options: &AnterouterOptions,
|
options: &AnterouterOptions,
|
||||||
|
terminating_dot_map: &mut BTreeMap<(RatlineUid, FixedDotIndex, usize), FixedDotIndex>,
|
||||||
) -> Result<(), ()> {
|
) -> Result<(), ()> {
|
||||||
let (via, dots) = self.place_fanout_via_on_bbox_in_direction(
|
let (via, dots) = self.place_fanout_via_on_bbox_in_direction(
|
||||||
autorouter,
|
autorouter,
|
||||||
|
|
@ -353,6 +363,7 @@ impl Anterouter {
|
||||||
target_layer,
|
target_layer,
|
||||||
direction,
|
direction,
|
||||||
options,
|
options,
|
||||||
|
terminating_dot_map,
|
||||||
)?;
|
)?;
|
||||||
|
|
||||||
let layer = source_dot
|
let layer = source_dot
|
||||||
|
|
@ -401,6 +412,7 @@ impl Anterouter {
|
||||||
target_layer: usize,
|
target_layer: usize,
|
||||||
direction: impl Into<Point>,
|
direction: impl Into<Point>,
|
||||||
options: &AnterouterOptions,
|
options: &AnterouterOptions,
|
||||||
|
terminating_dot_map: &mut BTreeMap<(RatlineUid, FixedDotIndex, usize), FixedDotIndex>,
|
||||||
) -> Result<(GenericIndex<ViaWeight>, Vec<FixedDotIndex>), ()> {
|
) -> Result<(GenericIndex<ViaWeight>, Vec<FixedDotIndex>), ()> {
|
||||||
let source_layer = autorouter
|
let source_layer = autorouter
|
||||||
.board()
|
.board()
|
||||||
|
|
@ -460,10 +472,7 @@ impl Anterouter {
|
||||||
.layer()
|
.layer()
|
||||||
})
|
})
|
||||||
.unwrap();
|
.unwrap();
|
||||||
autorouter
|
terminating_dot_map.insert((ratline, source_dot, target_layer), *terminating_dot);
|
||||||
.ratsnests
|
|
||||||
.on_principal_layer_mut(ratline.principal_layer)
|
|
||||||
.assign_terminating_dot_to_ratvertex(ratvertex, target_layer, *terminating_dot);
|
|
||||||
Ok((via, dots))
|
Ok((via, dots))
|
||||||
} else {
|
} else {
|
||||||
Err(())
|
Err(())
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,7 @@ use geo::Point;
|
||||||
use petgraph::graph::NodeIndex;
|
use petgraph::graph::NodeIndex;
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use spade::InsertionError;
|
use spade::InsertionError;
|
||||||
use std::collections::BTreeSet;
|
use std::collections::{BTreeMap, BTreeSet};
|
||||||
use thiserror::Error;
|
use thiserror::Error;
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
|
|
@ -137,6 +137,7 @@ impl<M: AccessMesadata> Autorouter<M> {
|
||||||
self,
|
self,
|
||||||
PlanarAutoroutePreconfigurerInput {
|
PlanarAutoroutePreconfigurerInput {
|
||||||
ratlines: self.selected_planar_ratlines(selection, options.principal_layer),
|
ratlines: self.selected_planar_ratlines(selection, options.principal_layer),
|
||||||
|
terminating_dot_map: BTreeMap::new(),
|
||||||
},
|
},
|
||||||
options,
|
options,
|
||||||
)
|
)
|
||||||
|
|
@ -196,7 +197,7 @@ impl<M: AccessMesadata> Autorouter<M> {
|
||||||
active_layer,
|
active_layer,
|
||||||
allowed_edges,
|
allowed_edges,
|
||||||
ratlines.into_iter().filter_map(|ratline| {
|
ratlines.into_iter().filter_map(|ratline| {
|
||||||
let (origin, destination) = ratline.ref_(self).terminating_dots();
|
let (origin, destination) = ratline.ref_(self).endpoint_dots();
|
||||||
|
|
||||||
if navmesh
|
if navmesh
|
||||||
.as_ref()
|
.as_ref()
|
||||||
|
|
|
||||||
|
|
@ -48,12 +48,16 @@ impl MultilayerAutorouteExecutionStepper {
|
||||||
) -> Result<Self, AutorouterError> {
|
) -> Result<Self, AutorouterError> {
|
||||||
let mut anterouter = Anterouter::new(configuration.plan);
|
let mut anterouter = Anterouter::new(configuration.plan);
|
||||||
let mut anteroute_edit = BoardEdit::new();
|
let mut anteroute_edit = BoardEdit::new();
|
||||||
anterouter.anteroute(autorouter, &mut anteroute_edit, &options.anterouter);
|
let terminating_dot_map =
|
||||||
|
anterouter.anteroute(autorouter, &mut anteroute_edit, &options.anterouter);
|
||||||
|
|
||||||
Ok(Self {
|
Ok(Self {
|
||||||
planar: PlanarAutorouteReconfigurator::new(
|
planar: PlanarAutorouteReconfigurator::new(
|
||||||
autorouter,
|
autorouter,
|
||||||
configuration.planar,
|
PlanarAutoroutePreconfigurerInput {
|
||||||
|
terminating_dot_map,
|
||||||
|
..configuration.planar
|
||||||
|
},
|
||||||
options.planar,
|
options.planar,
|
||||||
)?,
|
)?,
|
||||||
anteroute_edit,
|
anteroute_edit,
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@
|
||||||
//
|
//
|
||||||
// SPDX-License-Identifier: MIT
|
// SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
use std::ops::ControlFlow;
|
use std::{collections::BTreeMap, ops::ControlFlow};
|
||||||
|
|
||||||
use specctra_core::mesadata::AccessMesadata;
|
use specctra_core::mesadata::AccessMesadata;
|
||||||
|
|
||||||
|
|
@ -49,6 +49,7 @@ impl MultilayerAutorouteReconfigurator {
|
||||||
plan: planner.plan().clone(),
|
plan: planner.plan().clone(),
|
||||||
planar: PlanarAutoroutePreconfigurerInput {
|
planar: PlanarAutoroutePreconfigurerInput {
|
||||||
ratlines: input.ratlines.clone(),
|
ratlines: input.ratlines.clone(),
|
||||||
|
terminating_dot_map: BTreeMap::new(),
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
let reconfigurer = MultilayerReconfigurer::new(autorouter, input.ratlines, &options);
|
let reconfigurer = MultilayerReconfigurer::new(autorouter, input.ratlines, &options);
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@
|
||||||
//! Manages autorouting of ratlines in a layout, tracking status and processed
|
//! Manages autorouting of ratlines in a layout, tracking status and processed
|
||||||
//! routing steps.
|
//! routing steps.
|
||||||
|
|
||||||
use std::ops::ControlFlow;
|
use std::{collections::BTreeMap, ops::ControlFlow};
|
||||||
|
|
||||||
use derive_getters::Getters;
|
use derive_getters::Getters;
|
||||||
|
|
||||||
|
|
@ -14,7 +14,7 @@ use crate::{
|
||||||
edit::{BoardDataEdit, BoardEdit},
|
edit::{BoardDataEdit, BoardEdit},
|
||||||
AccessMesadata,
|
AccessMesadata,
|
||||||
},
|
},
|
||||||
drawing::{band::BandTermsegIndex, graph::PrimitiveIndex},
|
drawing::{band::BandTermsegIndex, dot::FixedDotIndex, graph::PrimitiveIndex},
|
||||||
geometry::{edit::Edit, primitive::PrimitiveShape},
|
geometry::{edit::Edit, primitive::PrimitiveShape},
|
||||||
graph::MakeRef,
|
graph::MakeRef,
|
||||||
layout::LayoutEdit,
|
layout::LayoutEdit,
|
||||||
|
|
@ -32,6 +32,30 @@ use super::{
|
||||||
#[derive(Clone, Debug)]
|
#[derive(Clone, Debug)]
|
||||||
pub struct PlanarAutorouteConfiguration {
|
pub struct PlanarAutorouteConfiguration {
|
||||||
pub ratlines: Vec<RatlineUid>,
|
pub ratlines: Vec<RatlineUid>,
|
||||||
|
pub terminating_dot_map: BTreeMap<(RatlineUid, FixedDotIndex, usize), FixedDotIndex>,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl PlanarAutorouteConfiguration {
|
||||||
|
pub fn ratline_terminating_dots(
|
||||||
|
&self,
|
||||||
|
autorouter: &Autorouter<impl AccessMesadata>,
|
||||||
|
ratline_index: usize,
|
||||||
|
) -> (FixedDotIndex, FixedDotIndex) {
|
||||||
|
let ratline = self.ratlines[ratline_index];
|
||||||
|
let endpoint_dots = ratline.ref_(autorouter).endpoint_dots();
|
||||||
|
let layer = ratline.ref_(autorouter).layer();
|
||||||
|
|
||||||
|
(
|
||||||
|
*self
|
||||||
|
.terminating_dot_map
|
||||||
|
.get(&(ratline, endpoint_dots.0, layer))
|
||||||
|
.unwrap_or(&endpoint_dots.0),
|
||||||
|
*self
|
||||||
|
.terminating_dot_map
|
||||||
|
.get(&(ratline, endpoint_dots.1, layer))
|
||||||
|
.unwrap_or(&endpoint_dots.1),
|
||||||
|
)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Debug)]
|
#[derive(Clone, Debug)]
|
||||||
|
|
@ -83,9 +107,7 @@ impl PlanarAutorouteExecutionStepper {
|
||||||
return Err(AutorouterError::NothingToRoute);
|
return Err(AutorouterError::NothingToRoute);
|
||||||
};
|
};
|
||||||
|
|
||||||
let (origin, destination) = configuration.ratlines[0]
|
let (origin, destination) = configuration.ratline_terminating_dots(autorouter, 0);
|
||||||
.ref_(autorouter)
|
|
||||||
.terminating_dots();
|
|
||||||
let mut router = Router::new(autorouter.board.layout_mut(), options.router);
|
let mut router = Router::new(autorouter.board.layout_mut(), options.router);
|
||||||
|
|
||||||
Ok(Self {
|
Ok(Self {
|
||||||
|
|
@ -121,9 +143,9 @@ impl PlanarAutorouteExecutionStepper {
|
||||||
|
|
||||||
autorouter.board.apply_edit(&board_edit.reverse());
|
autorouter.board.apply_edit(&board_edit.reverse());
|
||||||
|
|
||||||
let (origin, destination) = self.configuration.ratlines[index]
|
let (origin, destination) = self
|
||||||
.ref_(autorouter)
|
.configuration
|
||||||
.terminating_dots();
|
.ratline_terminating_dots(autorouter, index);
|
||||||
let mut router = Router::new(autorouter.board.layout_mut(), self.options.router);
|
let mut router = Router::new(autorouter.board.layout_mut(), self.options.router);
|
||||||
|
|
||||||
self.route = Some(router.route(
|
self.route = Some(router.route(
|
||||||
|
|
@ -169,9 +191,9 @@ impl<M: AccessMesadata> Step<Autorouter<M>, Option<BoardEdit>, PlanarAutorouteCo
|
||||||
))));
|
))));
|
||||||
}
|
}
|
||||||
|
|
||||||
let (origin, destination) = self.configuration().ratlines[self.curr_ratline_index]
|
let (origin, destination) = self
|
||||||
.ref_(autorouter)
|
.configuration
|
||||||
.terminating_dots();
|
.ratline_terminating_dots(autorouter, self.curr_ratline_index);
|
||||||
|
|
||||||
let Some(ref mut route) = self.route else {
|
let Some(ref mut route) = self.route else {
|
||||||
// May happen if stepper was aborted.
|
// May happen if stepper was aborted.
|
||||||
|
|
@ -226,7 +248,9 @@ impl<M: AccessMesadata> Step<Autorouter<M>, Option<BoardEdit>, PlanarAutorouteCo
|
||||||
self.curr_ratline_index += 1;
|
self.curr_ratline_index += 1;
|
||||||
|
|
||||||
if let Some(new_ratline) = self.configuration.ratlines.get(self.curr_ratline_index) {
|
if let Some(new_ratline) = self.configuration.ratlines.get(self.curr_ratline_index) {
|
||||||
let (origin, destination) = new_ratline.ref_(autorouter).terminating_dots();
|
let (origin, destination) = self
|
||||||
|
.configuration
|
||||||
|
.ratline_terminating_dots(autorouter, self.curr_ratline_index);
|
||||||
let mut router = Router::new(autorouter.board.layout_mut(), self.options.router);
|
let mut router = Router::new(autorouter.board.layout_mut(), self.options.router);
|
||||||
|
|
||||||
self.dissolve_route_stepper_and_push_layout_edit();
|
self.dissolve_route_stepper_and_push_layout_edit();
|
||||||
|
|
|
||||||
|
|
@ -2,21 +2,25 @@
|
||||||
//
|
//
|
||||||
// SPDX-License-Identifier: MIT
|
// SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
use std::collections::BTreeSet;
|
use std::collections::{BTreeMap, BTreeSet};
|
||||||
|
|
||||||
use derive_getters::{Dissolve, Getters};
|
use derive_getters::{Dissolve, Getters};
|
||||||
use enum_dispatch::enum_dispatch;
|
use enum_dispatch::enum_dispatch;
|
||||||
use petgraph::algo::tarjan_scc;
|
use petgraph::algo::tarjan_scc;
|
||||||
use specctra_core::mesadata::AccessMesadata;
|
use specctra_core::mesadata::AccessMesadata;
|
||||||
|
|
||||||
use crate::autorouter::{
|
use crate::{
|
||||||
planar_autoroute::PlanarAutorouteConfiguration, ratline::RatlineUid, scc::Scc, Autorouter,
|
autorouter::{
|
||||||
PlanarAutorouteOptions,
|
planar_autoroute::PlanarAutorouteConfiguration, ratline::RatlineUid, scc::Scc, Autorouter,
|
||||||
|
PlanarAutorouteOptions,
|
||||||
|
},
|
||||||
|
drawing::dot::FixedDotIndex,
|
||||||
};
|
};
|
||||||
|
|
||||||
#[derive(Clone, Debug)]
|
#[derive(Clone, Debug)]
|
||||||
pub struct PlanarAutoroutePreconfigurerInput {
|
pub struct PlanarAutoroutePreconfigurerInput {
|
||||||
pub ratlines: BTreeSet<RatlineUid>,
|
pub ratlines: BTreeSet<RatlineUid>,
|
||||||
|
pub terminating_dot_map: BTreeMap<(RatlineUid, FixedDotIndex, usize), FixedDotIndex>,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct PresortParams {
|
pub struct PresortParams {
|
||||||
|
|
@ -102,6 +106,7 @@ impl PreconfigurePlanarAutoroute for SccIntersectionsAndLengthRatlinePlanarAutor
|
||||||
|
|
||||||
PlanarAutorouteConfiguration {
|
PlanarAutorouteConfiguration {
|
||||||
ratlines: presorted_ratlines,
|
ratlines: presorted_ratlines,
|
||||||
|
terminating_dot_map: input.terminating_dot_map,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@
|
||||||
//
|
//
|
||||||
// SPDX-License-Identifier: MIT
|
// SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
use std::ops::ControlFlow;
|
use std::{collections::BTreeMap, ops::ControlFlow};
|
||||||
|
|
||||||
use specctra_core::mesadata::AccessMesadata;
|
use specctra_core::mesadata::AccessMesadata;
|
||||||
|
|
||||||
|
|
@ -95,12 +95,7 @@ impl<M: AccessMesadata> Step<Autorouter<M>, Option<BoardEdit>, PlanarReconfigura
|
||||||
return Ok(ControlFlow::Break(None));
|
return Ok(ControlFlow::Break(None));
|
||||||
};
|
};
|
||||||
|
|
||||||
match self.stepper.reconfigure(
|
match self.stepper.reconfigure(autorouter, configuration) {
|
||||||
autorouter,
|
|
||||||
PlanarAutorouteConfiguration {
|
|
||||||
ratlines: configuration,
|
|
||||||
},
|
|
||||||
) {
|
|
||||||
Ok(result) => {
|
Ok(result) => {
|
||||||
return Ok(ControlFlow::Continue(ReconfiguratorStatus::Reconfigured(
|
return Ok(ControlFlow::Continue(ReconfiguratorStatus::Reconfigured(
|
||||||
result,
|
result,
|
||||||
|
|
|
||||||
|
|
@ -8,17 +8,12 @@ use enum_dispatch::enum_dispatch;
|
||||||
use itertools::{Itertools, Permutations};
|
use itertools::{Itertools, Permutations};
|
||||||
use specctra_core::mesadata::AccessMesadata;
|
use specctra_core::mesadata::AccessMesadata;
|
||||||
|
|
||||||
use crate::{
|
use crate::autorouter::{
|
||||||
autorouter::{
|
planar_autoroute::{PlanarAutorouteConfiguration, PlanarAutorouteExecutionStepper},
|
||||||
planar_autoroute::{PlanarAutorouteConfiguration, PlanarAutorouteExecutionStepper},
|
planar_preconfigurer::SccIntersectionsAndLengthRatlinePlanarAutoroutePreconfigurer,
|
||||||
planar_preconfigurer::SccIntersectionsAndLengthRatlinePlanarAutoroutePreconfigurer,
|
ratline::RatlineUid,
|
||||||
ratline::RatlineUid,
|
scc::Scc,
|
||||||
scc::Scc,
|
Autorouter, PlanarAutorouteOptions,
|
||||||
Autorouter, PlanarAutorouteOptions,
|
|
||||||
},
|
|
||||||
drawing::graph::MakePrimitiveRef,
|
|
||||||
geometry::{GenericNode, GetLayer},
|
|
||||||
graph::MakeRef,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#[enum_dispatch]
|
#[enum_dispatch]
|
||||||
|
|
@ -27,12 +22,12 @@ pub trait MakeNextPlanarAutorouteConfiguration {
|
||||||
&mut self,
|
&mut self,
|
||||||
autorouter: &mut Autorouter<impl AccessMesadata>,
|
autorouter: &mut Autorouter<impl AccessMesadata>,
|
||||||
stepper: &PlanarAutorouteExecutionStepper,
|
stepper: &PlanarAutorouteExecutionStepper,
|
||||||
) -> Option<Vec<RatlineUid>>;
|
) -> Option<PlanarAutorouteConfiguration>;
|
||||||
}
|
}
|
||||||
|
|
||||||
#[enum_dispatch(MakeNextPlanarAutorouteConfiguration)]
|
#[enum_dispatch(MakeNextPlanarAutorouteConfiguration)]
|
||||||
pub enum PlanarAutorouteReconfigurer {
|
pub enum PlanarAutorouteReconfigurer {
|
||||||
RatlineCuts(RatlineCutsPlanarAutorouteReconfigurer),
|
//RatlineCuts(RatlineCutsPlanarAutorouteReconfigurer),
|
||||||
SccPermutations(SccPermutationsPlanarAutorouteReconfigurer),
|
SccPermutations(SccPermutationsPlanarAutorouteReconfigurer),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -59,7 +54,7 @@ impl PlanarAutorouteReconfigurer {
|
||||||
|
|
||||||
pub struct SccPermutationsPlanarAutorouteReconfigurer {
|
pub struct SccPermutationsPlanarAutorouteReconfigurer {
|
||||||
sccs_permutations_iter: Skip<Permutations<std::vec::IntoIter<Scc>>>,
|
sccs_permutations_iter: Skip<Permutations<std::vec::IntoIter<Scc>>>,
|
||||||
initial_configuration: PlanarAutorouteConfiguration,
|
preconfiguration: PlanarAutorouteConfiguration,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl SccPermutationsPlanarAutorouteReconfigurer {
|
impl SccPermutationsPlanarAutorouteReconfigurer {
|
||||||
|
|
@ -76,7 +71,7 @@ impl SccPermutationsPlanarAutorouteReconfigurer {
|
||||||
|
|
||||||
Self {
|
Self {
|
||||||
sccs_permutations_iter: sccs.into_iter().permutations(sccs_len).skip(1),
|
sccs_permutations_iter: sccs.into_iter().permutations(sccs_len).skip(1),
|
||||||
initial_configuration: preconfiguration,
|
preconfiguration,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -86,12 +81,12 @@ impl MakeNextPlanarAutorouteConfiguration for SccPermutationsPlanarAutorouteReco
|
||||||
&mut self,
|
&mut self,
|
||||||
autorouter: &mut Autorouter<impl AccessMesadata>,
|
autorouter: &mut Autorouter<impl AccessMesadata>,
|
||||||
_stepper: &PlanarAutorouteExecutionStepper,
|
_stepper: &PlanarAutorouteExecutionStepper,
|
||||||
) -> Option<Vec<RatlineUid>> {
|
) -> Option<PlanarAutorouteConfiguration> {
|
||||||
let scc_permutation = self.sccs_permutations_iter.next()?;
|
let scc_permutation = self.sccs_permutations_iter.next()?;
|
||||||
let mut ratlines = vec![];
|
let mut ratlines = vec![];
|
||||||
|
|
||||||
for scc in scc_permutation {
|
for scc in scc_permutation {
|
||||||
for ratline in self.initial_configuration.ratlines.iter() {
|
for ratline in self.preconfiguration.ratlines.iter() {
|
||||||
if scc.node_indices().contains(
|
if scc.node_indices().contains(
|
||||||
&autorouter
|
&autorouter
|
||||||
.ratsnests()
|
.ratsnests()
|
||||||
|
|
@ -114,7 +109,10 @@ impl MakeNextPlanarAutorouteConfiguration for SccPermutationsPlanarAutorouteReco
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Some(ratlines)
|
Some(PlanarAutorouteConfiguration {
|
||||||
|
ratlines,
|
||||||
|
..self.preconfiguration.clone()
|
||||||
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -122,7 +120,7 @@ pub struct RatlineCutsPlanarAutorouteReconfigurer {
|
||||||
//sccs: Vec<Vec<NodeIndex<usize>>>,
|
//sccs: Vec<Vec<NodeIndex<usize>>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl RatlineCutsPlanarAutorouteReconfigurer {
|
/*impl RatlineCutsPlanarAutorouteReconfigurer {
|
||||||
pub fn new(
|
pub fn new(
|
||||||
_autorouter: &mut Autorouter<impl AccessMesadata>,
|
_autorouter: &mut Autorouter<impl AccessMesadata>,
|
||||||
_ratlines: Vec<RatlineUid>,
|
_ratlines: Vec<RatlineUid>,
|
||||||
|
|
@ -134,16 +132,19 @@ impl RatlineCutsPlanarAutorouteReconfigurer {
|
||||||
}*/
|
}*/
|
||||||
Self {}
|
Self {}
|
||||||
}
|
}
|
||||||
}
|
}*/
|
||||||
|
|
||||||
impl MakeNextPlanarAutorouteConfiguration for RatlineCutsPlanarAutorouteReconfigurer {
|
/*impl MakeNextPlanarAutorouteConfiguration for RatlineCutsPlanarAutorouteReconfigurer {
|
||||||
fn next_configuration(
|
fn next_configuration(
|
||||||
&mut self,
|
&mut self,
|
||||||
autorouter: &mut Autorouter<impl AccessMesadata>,
|
autorouter: &mut Autorouter<impl AccessMesadata>,
|
||||||
stepper: &PlanarAutorouteExecutionStepper,
|
stepper: &PlanarAutorouteExecutionStepper,
|
||||||
) -> Option<Vec<RatlineUid>> {
|
) -> Option<Vec<RatlineUid>> {
|
||||||
let curr_ratline = stepper.configuration().ratlines[*stepper.curr_ratline_index()];
|
let curr_ratline = stepper.configuration().ratlines[*stepper.curr_ratline_index()];
|
||||||
let terminating_dots = curr_ratline.ref_(autorouter).terminating_dots();
|
let terminating_dots = stepper
|
||||||
|
.configuration()
|
||||||
|
.terminating_dots
|
||||||
|
.get(&(curr_ratline,));
|
||||||
let bands_cut_by_ratline: Vec<_> = autorouter
|
let bands_cut_by_ratline: Vec<_> = autorouter
|
||||||
.board()
|
.board()
|
||||||
.layout()
|
.layout()
|
||||||
|
|
@ -182,4 +183,4 @@ impl MakeNextPlanarAutorouteConfiguration for RatlineCutsPlanarAutorouteReconfig
|
||||||
|
|
||||||
Some(ratlines)
|
Some(ratlines)
|
||||||
}
|
}
|
||||||
}
|
}*/
|
||||||
|
|
|
||||||
|
|
@ -99,41 +99,6 @@ impl<'a, M: AccessMesadata> RatlineRef<'a, M> {
|
||||||
(source_dot, target_dot)
|
(source_dot, target_dot)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn terminating_dots(&self) -> (FixedDotIndex, FixedDotIndex) {
|
|
||||||
let (source, target) = self
|
|
||||||
.autorouter
|
|
||||||
.ratsnests()
|
|
||||||
.on_principal_layer(self.uid.principal_layer)
|
|
||||||
.graph()
|
|
||||||
.edge_endpoints(self.uid.index)
|
|
||||||
.unwrap();
|
|
||||||
|
|
||||||
let source_dot = self
|
|
||||||
.autorouter
|
|
||||||
.ratsnests()
|
|
||||||
.on_principal_layer(self.uid.principal_layer)
|
|
||||||
.graph()
|
|
||||||
.node_weight(source)
|
|
||||||
.unwrap()
|
|
||||||
.layer_terminating_dots
|
|
||||||
.get(&self.layer())
|
|
||||||
.copied()
|
|
||||||
.unwrap_or(self.endpoint_dots().0);
|
|
||||||
let target_dot = self
|
|
||||||
.autorouter
|
|
||||||
.ratsnests()
|
|
||||||
.on_principal_layer(self.uid.principal_layer)
|
|
||||||
.graph()
|
|
||||||
.node_weight(target)
|
|
||||||
.unwrap()
|
|
||||||
.layer_terminating_dots
|
|
||||||
.get(&self.layer())
|
|
||||||
.copied()
|
|
||||||
.unwrap_or(self.endpoint_dots().1);
|
|
||||||
|
|
||||||
(source_dot, target_dot)
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn layer(&self) -> usize {
|
pub fn layer(&self) -> usize {
|
||||||
self.autorouter
|
self.autorouter
|
||||||
.ratsnests()
|
.ratsnests()
|
||||||
|
|
|
||||||
|
|
@ -9,11 +9,7 @@ use std::{
|
||||||
|
|
||||||
use enum_dispatch::enum_dispatch;
|
use enum_dispatch::enum_dispatch;
|
||||||
use geo::Point;
|
use geo::Point;
|
||||||
use petgraph::{
|
use petgraph::{data::Element, graph::EdgeIndex, prelude::StableUnGraph};
|
||||||
data::Element,
|
|
||||||
graph::{EdgeIndex, NodeIndex},
|
|
||||||
prelude::StableUnGraph,
|
|
||||||
};
|
|
||||||
use spade::{handles::FixedVertexHandle, HasPosition, InsertionError, Point2};
|
use spade::{handles::FixedVertexHandle, HasPosition, InsertionError, Point2};
|
||||||
use specctra_core::mesadata::AccessMesadata;
|
use specctra_core::mesadata::AccessMesadata;
|
||||||
|
|
||||||
|
|
@ -54,7 +50,6 @@ impl From<RatvertexNodeIndex> for crate::layout::NodeIndex {
|
||||||
pub struct RatvertexWeight {
|
pub struct RatvertexWeight {
|
||||||
vertex: RatvertexNodeIndex,
|
vertex: RatvertexNodeIndex,
|
||||||
pub pos: Point,
|
pub pos: Point,
|
||||||
pub layer_terminating_dots: BTreeMap<usize, FixedDotIndex>,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl GetTrianvertexNodeIndex<RatvertexNodeIndex> for RatvertexWeight {
|
impl GetTrianvertexNodeIndex<RatvertexNodeIndex> for RatvertexWeight {
|
||||||
|
|
@ -191,11 +186,7 @@ impl Ratsnest {
|
||||||
return Ok(());
|
return Ok(());
|
||||||
}
|
}
|
||||||
|
|
||||||
triangulation.add_vertex(RatvertexWeight {
|
triangulation.add_vertex(RatvertexWeight { vertex, pos })?;
|
||||||
vertex,
|
|
||||||
pos,
|
|
||||||
layer_terminating_dots: BTreeMap::new(),
|
|
||||||
})?;
|
|
||||||
Ok(())
|
Ok(())
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -230,19 +221,6 @@ impl Ratsnest {
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn assign_terminating_dot_to_ratvertex(
|
|
||||||
&mut self,
|
|
||||||
node_index: NodeIndex<usize>,
|
|
||||||
layer: usize,
|
|
||||||
terminating_dot: FixedDotIndex,
|
|
||||||
) {
|
|
||||||
self.graph
|
|
||||||
.node_weight_mut(node_index)
|
|
||||||
.unwrap()
|
|
||||||
.layer_terminating_dots
|
|
||||||
.insert(layer, terminating_dot);
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn assign_layer_to_ratline(&mut self, ratline_index: EdgeIndex<usize>, layer: usize) {
|
pub fn assign_layer_to_ratline(&mut self, ratline_index: EdgeIndex<usize>, layer: usize) {
|
||||||
self.graph.edge_weight_mut(ratline_index).unwrap().layer = layer;
|
self.graph.edge_weight_mut(ratline_index).unwrap().layer = layer;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,7 @@ use topola::{
|
||||||
graph::{GetMaybeNet, MakePrimitiveRef, PrimitiveIndex},
|
graph::{GetMaybeNet, MakePrimitiveRef, PrimitiveIndex},
|
||||||
primitive::MakePrimitiveShape,
|
primitive::MakePrimitiveShape,
|
||||||
},
|
},
|
||||||
geometry::{shape::MeasureLength, GenericNode, GetLayer},
|
geometry::{shape::MeasureLength, GenericNode},
|
||||||
graph::{GetIndex, MakeRef},
|
graph::{GetIndex, MakeRef},
|
||||||
router::{navmesh::Navmesh, RouterOptions},
|
router::{navmesh::Navmesh, RouterOptions},
|
||||||
specctra::{design::SpecctraDesign, mesadata::SpecctraMesadata},
|
specctra::{design::SpecctraDesign, mesadata::SpecctraMesadata},
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue