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!();
|
||||
}
|
||||
|
||||
pub fn compare(&mut self, selection: &PinSelection) -> Result<CompareDetours, AutorouterError> {
|
||||
self.compare_ratlines(self.selected_ratlines(selection))
|
||||
}
|
||||
|
||||
fn compare_ratlines(
|
||||
pub fn compare_detours(
|
||||
&mut self,
|
||||
ratlines: Vec<EdgeIndex<usize>>,
|
||||
selection: &PinSelection,
|
||||
) -> Result<CompareDetours, AutorouterError> {
|
||||
let ratlines = self.selected_ratlines(selection);
|
||||
let ratline1 = *ratlines
|
||||
.get(0)
|
||||
.ok_or(AutorouterError::NeedExactlyTwoRatlines)?;
|
||||
let ratline2 = *ratlines
|
||||
.get(1)
|
||||
.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)
|
||||
}
|
||||
|
||||
|
|
@ -136,7 +141,7 @@ impl<M: AccessMesadata> Autorouter<M> {
|
|||
(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
|
||||
.graph()
|
||||
.edge_indices()
|
||||
|
|
|
|||
|
|
@ -240,9 +240,18 @@ impl<M: AccessMesadata> Invoker<M> {
|
|||
#[debug_requires(self.ongoing_command.is_none())]
|
||||
fn dispatch_command(&mut self, command: &Command) -> Result<Execute, InvokerError> {
|
||||
match command {
|
||||
Command::Autoroute(selection) => Ok::<Execute, InvokerError>(Execute::Autoroute(
|
||||
self.autorouter.autoroute(selection)?,
|
||||
)),
|
||||
Command::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) => {
|
||||
Ok::<Execute, InvokerError>(Execute::PlaceVia(self.autorouter.place_via(*weight)?))
|
||||
}
|
||||
|
|
@ -250,7 +259,7 @@ impl<M: AccessMesadata> Invoker<M> {
|
|||
self.autorouter.remove_bands(selection)?,
|
||||
)),
|
||||
Command::CompareDetours(selection) => Ok::<Execute, InvokerError>(
|
||||
Execute::CompareDetours(self.autorouter.compare(selection)?),
|
||||
Execute::CompareDetours(self.autorouter.compare_detours(selection)?),
|
||||
),
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue