awooter: cargo fmt

This commit is contained in:
Lofty 2022-11-26 17:11:18 +00:00
parent f1a4848c0f
commit 2a18fe58c6

View File

@ -1,4 +1,8 @@
use std::{collections::HashMap, ptr::NonNull, sync::{atomic::AtomicUsize, Mutex}}; use std::{
collections::HashMap,
ptr::NonNull,
sync::{atomic::AtomicUsize, Mutex},
};
use colored::Colorize; use colored::Colorize;
use indicatif::{ProgressBar, ProgressStyle}; use indicatif::{ProgressBar, ProgressStyle};
@ -113,7 +117,6 @@ fn find_partition_point(
(x, y, ne, se, sw, nw) (x, y, ne, se, sw, nw)
} }
/// finds the y location a line would be split at if you split it at a certain x location /// finds the y location a line would be split at if you split it at a certain x location
/// ///
/// the function assumes the line goes on forever in both directions, and it truncates the actual coordinate /// the function assumes the line goes on forever in both directions, and it truncates the actual coordinate
@ -158,7 +161,6 @@ enum Segment {
Northwest, Northwest,
} }
// A big thank you to @Spacecat-chan for fixing my broken and buggy partition code. // A big thank you to @Spacecat-chan for fixing my broken and buggy partition code.
fn partition_nets( fn partition_nets(
ctx: &npnr::Context, ctx: &npnr::Context,
@ -253,7 +255,10 @@ fn partition_nets(
} }
} }
log_info!(" Out of {} candidate pips:\n", candidates.to_string().bold()); log_info!(
" Out of {} candidate pips:\n",
candidates.to_string().bold()
);
log_info!(" {} are north-bound\n", north.to_string().bold()); log_info!(" {} are north-bound\n", north.to_string().bold());
log_info!(" {} are east-bound\n", east.to_string().bold()); log_info!(" {} are east-bound\n", east.to_string().bold());
log_info!(" {} are south-bound\n", south.to_string().bold()); log_info!(" {} are south-bound\n", south.to_string().bold());
@ -304,10 +309,17 @@ fn partition_nets(
// but doing so gives lifetime errors, and you can't describe // but doing so gives lifetime errors, and you can't describe
// lifetimes in a closure, as far as I can tell. // lifetimes in a closure, as far as I can tell.
let arcs = nets.users_by_name(*name).unwrap().iter().flat_map(|sink| { let arcs = nets
.users_by_name(*name)
.unwrap()
.iter()
.flat_map(|sink| {
let sink = unsafe { sink.as_ref().unwrap() }; let sink = unsafe { sink.as_ref().unwrap() };
ctx.sink_wires(net, sink).into_iter().map(move |sink_wire| (sink, sink_wire)) ctx.sink_wires(net, sink)
}).flat_map(|(sink, sink_wire)| { .into_iter()
.map(move |sink_wire| (sink, sink_wire))
})
.flat_map(|(sink, sink_wire)| {
let sink_loc = sink.cell().unwrap().location(); let sink_loc = sink.cell().unwrap().location();
let sink_is_north = sink_loc.x < x; let sink_is_north = sink_loc.x < x;
let sink_is_east = sink_loc.y < y; let sink_is_east = sink_loc.y < y;
@ -342,7 +354,6 @@ fn partition_nets(
pip_uses.push(*name); pip_uses.push(*name);
let selected_pip = *selected_pip; let selected_pip = *selected_pip;
explored_pips.fetch_add(pips.len(), std::sync::atomic::Ordering::SeqCst); explored_pips.fetch_add(pips.len(), std::sync::atomic::Ordering::SeqCst);
explored_pips.fetch_add(pips.len(), std::sync::atomic::Ordering::SeqCst);
let pip_loc = ctx.pip_location(selected_pip); let pip_loc = ctx.pip_location(selected_pip);
let src_to_pip = ((source.x, source.y), (pip_loc.x, pip_loc.y)); let src_to_pip = ((source.x, source.y), (pip_loc.x, pip_loc.y));
@ -451,20 +462,42 @@ fn partition_nets(
((horiz_loc.x, horiz_loc.y), (sink_loc.x, sink_loc.y)), ((horiz_loc.x, horiz_loc.y), (sink_loc.x, sink_loc.y)),
) )
}; };
let (seg1, seg2, seg3) = match (source_is_north, source_is_east, horiz_is_east) { let (seg1, seg2, seg3) = match (source_is_north, source_is_east, horiz_is_east)
(true, true, true) => (Segment::Northeast, Segment::Southeast, Segment::Southwest), {
(true, true, false) => (Segment::Northeast, Segment::Northwest, Segment::Southwest), (true, true, true) => {
(true, false, true) => (Segment::Northwest, Segment::Northeast, Segment::Southeast), (Segment::Northeast, Segment::Southeast, Segment::Southwest)
(true, false, false) => (Segment::Northwest, Segment::Southwest, Segment::Southeast), }
(false, true, true) => (Segment::Southeast, Segment::Northeast, Segment::Northwest), (true, true, false) => {
(false, true, false) => (Segment::Southeast, Segment::Southwest, Segment::Northwest), (Segment::Northeast, Segment::Northwest, Segment::Southwest)
(false, false, true) => (Segment::Southwest, Segment::Southeast, Segment::Northeast), }
(false, false, false) => (Segment::Southwest, Segment::Northwest, Segment::Northeast), (true, false, true) => {
(Segment::Northwest, Segment::Northeast, Segment::Southeast)
}
(true, false, false) => {
(Segment::Northwest, Segment::Southwest, Segment::Southeast)
}
(false, true, true) => {
(Segment::Southeast, Segment::Northeast, Segment::Northwest)
}
(false, true, false) => {
(Segment::Southeast, Segment::Southwest, Segment::Northwest)
}
(false, false, true) => {
(Segment::Southwest, Segment::Southeast, Segment::Northeast)
}
(false, false, false) => {
(Segment::Southwest, Segment::Northwest, Segment::Northeast)
}
}; };
part_diag.fetch_add(1, std::sync::atomic::Ordering::SeqCst); part_diag.fetch_add(1, std::sync::atomic::Ordering::SeqCst);
vec![(seg1, src_to_mid1), (seg2, mid1_to_mid2), (seg3, mid2_to_dst)] vec![
(seg1, src_to_mid1),
(seg2, mid1_to_mid2),
(seg3, mid2_to_dst),
]
} }
}).collect::<Vec<_>>(); })
.collect::<Vec<_>>();
for (segment, arc) in arcs { for (segment, arc) in arcs {
match segment { match segment {
@ -478,7 +511,10 @@ fn partition_nets(
progress.finish_and_clear(); progress.finish_and_clear();
log_info!(" {} pips explored\n", explored_pips.get_mut().to_string().bold()); log_info!(
" {} pips explored\n",
explored_pips.get_mut().to_string().bold()
);
let north = ne.len() + nw.len(); let north = ne.len() + nw.len();
let south = se.len() + sw.len(); let south = se.len() + sw.len();
@ -696,7 +732,10 @@ fn route(ctx: &mut npnr::Context) -> bool {
.into_iter() .into_iter()
.all(|x| x == 0) .all(|x| x == 0)
{ {
log_info!("{}\n", "Found no arcs crossing partition boundaries.".green()); log_info!(
"{}\n",
"Found no arcs crossing partition boundaries.".green()
);
} else { } else {
println!("{}", "found arcs crossing partition boundaries!".yellow()); println!("{}", "found arcs crossing partition boundaries!".yellow());
println!("count in ne: {}", invalid_arcs_in_ne.to_string().bold()); println!("count in ne: {}", invalid_arcs_in_ne.to_string().bold());