mirror of https://codeberg.org/topola/topola.git
autorouter: sort by pairwise total detour lengths before autorouting
This commit is contained in:
parent
33206567e3
commit
c9d99c2c1f
|
|
@ -88,20 +88,25 @@ impl<M: AccessMesadata> Autorouter<M> {
|
||||||
todo!();
|
todo!();
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn compare(&mut self, selection: &PinSelection) -> Result<CompareDetours, AutorouterError> {
|
pub fn compare_detours(
|
||||||
self.compare_ratlines(self.selected_ratlines(selection))
|
|
||||||
}
|
|
||||||
|
|
||||||
fn compare_ratlines(
|
|
||||||
&mut self,
|
&mut self,
|
||||||
ratlines: Vec<EdgeIndex<usize>>,
|
selection: &PinSelection,
|
||||||
) -> Result<CompareDetours, AutorouterError> {
|
) -> Result<CompareDetours, AutorouterError> {
|
||||||
|
let ratlines = self.selected_ratlines(selection);
|
||||||
let ratline1 = *ratlines
|
let ratline1 = *ratlines
|
||||||
.get(0)
|
.get(0)
|
||||||
.ok_or(AutorouterError::NeedExactlyTwoRatlines)?;
|
.ok_or(AutorouterError::NeedExactlyTwoRatlines)?;
|
||||||
let ratline2 = *ratlines
|
let ratline2 = *ratlines
|
||||||
.get(1)
|
.get(1)
|
||||||
.ok_or(AutorouterError::NeedExactlyTwoRatlines)?;
|
.ok_or(AutorouterError::NeedExactlyTwoRatlines)?;
|
||||||
|
self.compare_detours_ratlines(ratline1, ratline2)
|
||||||
|
}
|
||||||
|
|
||||||
|
pub(super) fn compare_detours_ratlines(
|
||||||
|
&mut self,
|
||||||
|
ratline1: EdgeIndex<usize>,
|
||||||
|
ratline2: EdgeIndex<usize>,
|
||||||
|
) -> Result<CompareDetours, AutorouterError> {
|
||||||
CompareDetours::new(self, ratline1, ratline2)
|
CompareDetours::new(self, ratline1, ratline2)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -136,7 +141,7 @@ impl<M: AccessMesadata> Autorouter<M> {
|
||||||
(source_dot, target_dot)
|
(source_dot, target_dot)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn selected_ratlines(&self, selection: &PinSelection) -> Vec<EdgeIndex<usize>> {
|
pub(super) fn selected_ratlines(&self, selection: &PinSelection) -> Vec<EdgeIndex<usize>> {
|
||||||
self.ratsnest
|
self.ratsnest
|
||||||
.graph()
|
.graph()
|
||||||
.edge_indices()
|
.edge_indices()
|
||||||
|
|
|
||||||
|
|
@ -240,9 +240,18 @@ impl<M: AccessMesadata> Invoker<M> {
|
||||||
#[debug_requires(self.ongoing_command.is_none())]
|
#[debug_requires(self.ongoing_command.is_none())]
|
||||||
fn dispatch_command(&mut self, command: &Command) -> Result<Execute, InvokerError> {
|
fn dispatch_command(&mut self, command: &Command) -> Result<Execute, InvokerError> {
|
||||||
match command {
|
match command {
|
||||||
Command::Autoroute(selection) => Ok::<Execute, InvokerError>(Execute::Autoroute(
|
Command::Autoroute(selection) => {
|
||||||
self.autorouter.autoroute(selection)?,
|
let mut ratlines = self.autorouter.selected_ratlines(selection);
|
||||||
)),
|
ratlines.sort_unstable_by(|a, b| {
|
||||||
|
let mut compare_detours =
|
||||||
|
self.autorouter.compare_detours_ratlines(*a, *b).unwrap();
|
||||||
|
let (al, bl) = compare_detours.finish(&mut self.autorouter).unwrap();
|
||||||
|
PartialOrd::partial_cmp(&al, &bl).unwrap()
|
||||||
|
});
|
||||||
|
Ok::<Execute, InvokerError>(Execute::Autoroute(
|
||||||
|
self.autorouter.autoroute_ratlines(ratlines)?,
|
||||||
|
))
|
||||||
|
}
|
||||||
Command::PlaceVia(weight) => {
|
Command::PlaceVia(weight) => {
|
||||||
Ok::<Execute, InvokerError>(Execute::PlaceVia(self.autorouter.place_via(*weight)?))
|
Ok::<Execute, InvokerError>(Execute::PlaceVia(self.autorouter.place_via(*weight)?))
|
||||||
}
|
}
|
||||||
|
|
@ -250,7 +259,7 @@ impl<M: AccessMesadata> Invoker<M> {
|
||||||
self.autorouter.remove_bands(selection)?,
|
self.autorouter.remove_bands(selection)?,
|
||||||
)),
|
)),
|
||||||
Command::CompareDetours(selection) => Ok::<Execute, InvokerError>(
|
Command::CompareDetours(selection) => Ok::<Execute, InvokerError>(
|
||||||
Execute::CompareDetours(self.autorouter.compare(selection)?),
|
Execute::CompareDetours(self.autorouter.compare_detours(selection)?),
|
||||||
),
|
),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue