mirror of https://codeberg.org/topola/topola.git
specctra: various fixes to import
This commit is contained in:
parent
22ad92db54
commit
77c0fa2272
|
|
@ -46,6 +46,15 @@ impl Default for PointWithRotation {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl PointWithRotation {
|
||||||
|
pub fn from_xy(x: f64, y: f64) -> Self {
|
||||||
|
Self {
|
||||||
|
pos: (x, y).into(),
|
||||||
|
rot: 0.0,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fn _tangent(center: Point, r1: f64, r2: f64) -> Result<CanonicalLine, ()> {
|
fn _tangent(center: Point, r1: f64, r2: f64) -> Result<CanonicalLine, ()> {
|
||||||
let epsilon = 1e-9;
|
let epsilon = 1e-9;
|
||||||
let dr = r2 - r1;
|
let dr = r2 - r1;
|
||||||
|
|
|
||||||
|
|
@ -198,8 +198,7 @@ impl SpecctraDesign {
|
||||||
.network
|
.network
|
||||||
.nets
|
.nets
|
||||||
.iter()
|
.iter()
|
||||||
// flatten the nested iters into a single stream of tuples
|
.filter_map(|net_pin_assignments| {
|
||||||
.flat_map(|net_pin_assignments| {
|
|
||||||
// resolve the id so we don't work with strings
|
// resolve the id so we don't work with strings
|
||||||
let net = board
|
let net = board
|
||||||
.layout()
|
.layout()
|
||||||
|
|
@ -208,14 +207,18 @@ impl SpecctraDesign {
|
||||||
.netname_net(&net_pin_assignments.name)
|
.netname_net(&net_pin_assignments.name)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
// take the list of pins
|
net_pin_assignments.pins.as_ref().and_then(|pins| {
|
||||||
// and for each pin id output (pin id, net id)
|
// take the list of pins
|
||||||
net_pin_assignments
|
// and for each pin output (pin name, net id)
|
||||||
.pins
|
Some(pins
|
||||||
.names
|
.names
|
||||||
.iter()
|
.iter()
|
||||||
.map(move |pinname| (pinname.clone(), net))
|
.map(move |pinname| (pinname.clone(), net))
|
||||||
|
)
|
||||||
|
})
|
||||||
})
|
})
|
||||||
|
// flatten the nested iters into a single stream of tuples
|
||||||
|
.flatten()
|
||||||
.collect::<HashMap<String, usize>>();
|
.collect::<HashMap<String, usize>>();
|
||||||
|
|
||||||
// add pins from components
|
// add pins from components
|
||||||
|
|
@ -236,7 +239,7 @@ impl SpecctraDesign {
|
||||||
|
|
||||||
for pin in &image.pins {
|
for pin in &image.pins {
|
||||||
let pinname = format!("{}-{}", place.name, pin.id);
|
let pinname = format!("{}-{}", place.name, pin.id);
|
||||||
let net = pin_nets.get(&pinname).unwrap();
|
let net = pin_nets.get(&pinname).copied();
|
||||||
|
|
||||||
let padstack = self.pcb.library.find_padstack_by_name(&pin.name).unwrap();
|
let padstack = self.pcb.library.find_padstack_by_name(&pin.name).unwrap();
|
||||||
|
|
||||||
|
|
@ -250,7 +253,7 @@ impl SpecctraDesign {
|
||||||
pin.point_with_rotation(),
|
pin.point_with_rotation(),
|
||||||
circle.diameter / 2.0,
|
circle.diameter / 2.0,
|
||||||
layer,
|
layer,
|
||||||
*net,
|
net,
|
||||||
Some(pinname.clone()),
|
Some(pinname.clone()),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
@ -265,7 +268,7 @@ impl SpecctraDesign {
|
||||||
rect.x2,
|
rect.x2,
|
||||||
rect.y2,
|
rect.y2,
|
||||||
layer,
|
layer,
|
||||||
*net,
|
net,
|
||||||
Some(pinname.clone()),
|
Some(pinname.clone()),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
@ -278,7 +281,7 @@ impl SpecctraDesign {
|
||||||
&path.coords,
|
&path.coords,
|
||||||
path.width,
|
path.width,
|
||||||
layer,
|
layer,
|
||||||
*net,
|
net,
|
||||||
Some(pinname.clone()),
|
Some(pinname.clone()),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
@ -291,7 +294,7 @@ impl SpecctraDesign {
|
||||||
&polygon.coords,
|
&polygon.coords,
|
||||||
polygon.width,
|
polygon.width,
|
||||||
layer,
|
layer,
|
||||||
*net,
|
net,
|
||||||
Some(pinname.clone()),
|
Some(pinname.clone()),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
@ -306,8 +309,7 @@ impl SpecctraDesign {
|
||||||
.layout()
|
.layout()
|
||||||
.drawing()
|
.drawing()
|
||||||
.rules()
|
.rules()
|
||||||
.netname_net(&via.net)
|
.netname_net(&via.net);
|
||||||
.unwrap();
|
|
||||||
|
|
||||||
let padstack = self.pcb.library.find_padstack_by_name(&via.name).unwrap();
|
let padstack = self.pcb.library.find_padstack_by_name(&via.name).unwrap();
|
||||||
|
|
||||||
|
|
@ -321,7 +323,9 @@ impl SpecctraDesign {
|
||||||
let layer = get_layer(&board, &circle.layer);
|
let layer = get_layer(&board, &circle.layer);
|
||||||
Self::add_circle(
|
Self::add_circle(
|
||||||
&mut board,
|
&mut board,
|
||||||
PointWithRotation::default(),
|
// TODO: refactor?
|
||||||
|
// should this call take PointWithRotation?
|
||||||
|
PointWithRotation::from_xy(via.x, via.y),
|
||||||
PointWithRotation::default(),
|
PointWithRotation::default(),
|
||||||
circle.diameter / 2.0,
|
circle.diameter / 2.0,
|
||||||
layer,
|
layer,
|
||||||
|
|
@ -333,7 +337,7 @@ impl SpecctraDesign {
|
||||||
let layer = get_layer(&board, &rect.layer);
|
let layer = get_layer(&board, &rect.layer);
|
||||||
Self::add_rect(
|
Self::add_rect(
|
||||||
&mut board,
|
&mut board,
|
||||||
PointWithRotation::default(),
|
PointWithRotation::from_xy(via.x, via.y),
|
||||||
PointWithRotation::default(),
|
PointWithRotation::default(),
|
||||||
rect.x1,
|
rect.x1,
|
||||||
rect.y1,
|
rect.y1,
|
||||||
|
|
@ -348,7 +352,7 @@ impl SpecctraDesign {
|
||||||
let layer = get_layer(&board, &path.layer);
|
let layer = get_layer(&board, &path.layer);
|
||||||
Self::add_path(
|
Self::add_path(
|
||||||
&mut board,
|
&mut board,
|
||||||
PointWithRotation::default(),
|
PointWithRotation::from_xy(via.x, via.y),
|
||||||
PointWithRotation::default(),
|
PointWithRotation::default(),
|
||||||
&path.coords,
|
&path.coords,
|
||||||
path.width,
|
path.width,
|
||||||
|
|
@ -361,7 +365,7 @@ impl SpecctraDesign {
|
||||||
let layer = get_layer(&board, &polygon.layer);
|
let layer = get_layer(&board, &polygon.layer);
|
||||||
Self::add_polygon(
|
Self::add_polygon(
|
||||||
&mut board,
|
&mut board,
|
||||||
PointWithRotation::default(),
|
PointWithRotation::from_xy(via.x, via.y),
|
||||||
PointWithRotation::default(),
|
PointWithRotation::default(),
|
||||||
&polygon.coords,
|
&polygon.coords,
|
||||||
polygon.width,
|
polygon.width,
|
||||||
|
|
@ -385,8 +389,7 @@ impl SpecctraDesign {
|
||||||
.layout()
|
.layout()
|
||||||
.drawing()
|
.drawing()
|
||||||
.rules()
|
.rules()
|
||||||
.netname_net(&wire.net)
|
.netname_net(&wire.net);
|
||||||
.unwrap();
|
|
||||||
|
|
||||||
Self::add_path(
|
Self::add_path(
|
||||||
&mut board,
|
&mut board,
|
||||||
|
|
@ -429,7 +432,7 @@ impl SpecctraDesign {
|
||||||
pin: PointWithRotation,
|
pin: PointWithRotation,
|
||||||
r: f64,
|
r: f64,
|
||||||
layer: usize,
|
layer: usize,
|
||||||
net: usize,
|
maybe_net: Option<usize>,
|
||||||
maybe_pin: Option<String>,
|
maybe_pin: Option<String>,
|
||||||
) {
|
) {
|
||||||
let circle = Circle {
|
let circle = Circle {
|
||||||
|
|
@ -441,7 +444,7 @@ impl SpecctraDesign {
|
||||||
FixedDotWeight {
|
FixedDotWeight {
|
||||||
circle,
|
circle,
|
||||||
layer,
|
layer,
|
||||||
maybe_net: Some(net),
|
maybe_net,
|
||||||
},
|
},
|
||||||
maybe_pin.clone(),
|
maybe_pin.clone(),
|
||||||
);
|
);
|
||||||
|
|
@ -456,13 +459,13 @@ impl SpecctraDesign {
|
||||||
x2: f64,
|
x2: f64,
|
||||||
y2: f64,
|
y2: f64,
|
||||||
layer: usize,
|
layer: usize,
|
||||||
net: usize,
|
maybe_net: Option<usize>,
|
||||||
maybe_pin: Option<String>,
|
maybe_pin: Option<String>,
|
||||||
) {
|
) {
|
||||||
let poly = board.add_poly(
|
let poly = board.add_poly(
|
||||||
SolidPolyWeight {
|
SolidPolyWeight {
|
||||||
layer,
|
layer,
|
||||||
maybe_net: Some(net),
|
maybe_net,
|
||||||
}
|
}
|
||||||
.into(),
|
.into(),
|
||||||
maybe_pin.clone(),
|
maybe_pin.clone(),
|
||||||
|
|
@ -476,7 +479,7 @@ impl SpecctraDesign {
|
||||||
r: 0.5,
|
r: 0.5,
|
||||||
},
|
},
|
||||||
layer,
|
layer,
|
||||||
maybe_net: Some(net),
|
maybe_net,
|
||||||
},
|
},
|
||||||
poly,
|
poly,
|
||||||
);
|
);
|
||||||
|
|
@ -487,7 +490,7 @@ impl SpecctraDesign {
|
||||||
r: 0.5,
|
r: 0.5,
|
||||||
},
|
},
|
||||||
layer,
|
layer,
|
||||||
maybe_net: Some(net),
|
maybe_net,
|
||||||
},
|
},
|
||||||
poly,
|
poly,
|
||||||
);
|
);
|
||||||
|
|
@ -498,7 +501,7 @@ impl SpecctraDesign {
|
||||||
r: 0.5,
|
r: 0.5,
|
||||||
},
|
},
|
||||||
layer,
|
layer,
|
||||||
maybe_net: Some(net),
|
maybe_net,
|
||||||
},
|
},
|
||||||
poly,
|
poly,
|
||||||
);
|
);
|
||||||
|
|
@ -509,7 +512,7 @@ impl SpecctraDesign {
|
||||||
r: 0.5,
|
r: 0.5,
|
||||||
},
|
},
|
||||||
layer,
|
layer,
|
||||||
maybe_net: Some(net),
|
maybe_net,
|
||||||
},
|
},
|
||||||
poly,
|
poly,
|
||||||
);
|
);
|
||||||
|
|
@ -520,7 +523,7 @@ impl SpecctraDesign {
|
||||||
FixedSegWeight {
|
FixedSegWeight {
|
||||||
width: 1.0,
|
width: 1.0,
|
||||||
layer,
|
layer,
|
||||||
maybe_net: Some(net),
|
maybe_net,
|
||||||
},
|
},
|
||||||
poly,
|
poly,
|
||||||
);
|
);
|
||||||
|
|
@ -530,7 +533,7 @@ impl SpecctraDesign {
|
||||||
FixedSegWeight {
|
FixedSegWeight {
|
||||||
width: 1.0,
|
width: 1.0,
|
||||||
layer,
|
layer,
|
||||||
maybe_net: Some(net),
|
maybe_net,
|
||||||
},
|
},
|
||||||
poly,
|
poly,
|
||||||
);
|
);
|
||||||
|
|
@ -540,7 +543,7 @@ impl SpecctraDesign {
|
||||||
FixedSegWeight {
|
FixedSegWeight {
|
||||||
width: 1.0,
|
width: 1.0,
|
||||||
layer,
|
layer,
|
||||||
maybe_net: Some(net),
|
maybe_net,
|
||||||
},
|
},
|
||||||
poly,
|
poly,
|
||||||
);
|
);
|
||||||
|
|
@ -550,7 +553,7 @@ impl SpecctraDesign {
|
||||||
FixedSegWeight {
|
FixedSegWeight {
|
||||||
width: 1.0,
|
width: 1.0,
|
||||||
layer,
|
layer,
|
||||||
maybe_net: Some(net),
|
maybe_net,
|
||||||
},
|
},
|
||||||
poly,
|
poly,
|
||||||
);
|
);
|
||||||
|
|
@ -563,7 +566,7 @@ impl SpecctraDesign {
|
||||||
coords: &[structure::Point],
|
coords: &[structure::Point],
|
||||||
width: f64,
|
width: f64,
|
||||||
layer: usize,
|
layer: usize,
|
||||||
net: usize,
|
maybe_net: Option<usize>,
|
||||||
maybe_pin: Option<String>,
|
maybe_pin: Option<String>,
|
||||||
) {
|
) {
|
||||||
// add the first coordinate in the wire path as a dot and save its index
|
// add the first coordinate in the wire path as a dot and save its index
|
||||||
|
|
@ -575,7 +578,7 @@ impl SpecctraDesign {
|
||||||
r: width / 2.0,
|
r: width / 2.0,
|
||||||
},
|
},
|
||||||
layer,
|
layer,
|
||||||
maybe_net: Some(net),
|
maybe_net,
|
||||||
},
|
},
|
||||||
maybe_pin.clone(),
|
maybe_pin.clone(),
|
||||||
);
|
);
|
||||||
|
|
@ -595,7 +598,7 @@ impl SpecctraDesign {
|
||||||
r: width / 2.0,
|
r: width / 2.0,
|
||||||
},
|
},
|
||||||
layer,
|
layer,
|
||||||
maybe_net: Some(net),
|
maybe_net,
|
||||||
},
|
},
|
||||||
maybe_pin.clone(),
|
maybe_pin.clone(),
|
||||||
);
|
);
|
||||||
|
|
@ -607,7 +610,7 @@ impl SpecctraDesign {
|
||||||
FixedSegWeight {
|
FixedSegWeight {
|
||||||
width,
|
width,
|
||||||
layer,
|
layer,
|
||||||
maybe_net: Some(net),
|
maybe_net,
|
||||||
},
|
},
|
||||||
maybe_pin.clone(),
|
maybe_pin.clone(),
|
||||||
);
|
);
|
||||||
|
|
@ -624,13 +627,13 @@ impl SpecctraDesign {
|
||||||
coords: &[structure::Point],
|
coords: &[structure::Point],
|
||||||
width: f64,
|
width: f64,
|
||||||
layer: usize,
|
layer: usize,
|
||||||
net: usize,
|
maybe_net: Option<usize>,
|
||||||
maybe_pin: Option<String>,
|
maybe_pin: Option<String>,
|
||||||
) {
|
) {
|
||||||
let poly = board.add_poly(
|
let poly = board.add_poly(
|
||||||
SolidPolyWeight {
|
SolidPolyWeight {
|
||||||
layer,
|
layer,
|
||||||
maybe_net: Some(net),
|
maybe_net,
|
||||||
}
|
}
|
||||||
.into(),
|
.into(),
|
||||||
maybe_pin.clone(),
|
maybe_pin.clone(),
|
||||||
|
|
@ -644,7 +647,7 @@ impl SpecctraDesign {
|
||||||
r: width / 2.0,
|
r: width / 2.0,
|
||||||
},
|
},
|
||||||
layer,
|
layer,
|
||||||
maybe_net: Some(net),
|
maybe_net,
|
||||||
},
|
},
|
||||||
// TODO: This manual retagging shouldn't be necessary, `.into()` should suffice.
|
// TODO: This manual retagging shouldn't be necessary, `.into()` should suffice.
|
||||||
//GenericIndex::new(poly.petgraph_index()).into(),
|
//GenericIndex::new(poly.petgraph_index()).into(),
|
||||||
|
|
@ -660,7 +663,7 @@ impl SpecctraDesign {
|
||||||
r: width / 2.0,
|
r: width / 2.0,
|
||||||
},
|
},
|
||||||
layer,
|
layer,
|
||||||
maybe_net: Some(net),
|
maybe_net,
|
||||||
},
|
},
|
||||||
// TODO: This manual retagging shouldn't be necessary, `.into()` should suffice.
|
// TODO: This manual retagging shouldn't be necessary, `.into()` should suffice.
|
||||||
poly,
|
poly,
|
||||||
|
|
@ -673,7 +676,7 @@ impl SpecctraDesign {
|
||||||
FixedSegWeight {
|
FixedSegWeight {
|
||||||
width,
|
width,
|
||||||
layer,
|
layer,
|
||||||
maybe_net: Some(net),
|
maybe_net,
|
||||||
},
|
},
|
||||||
// TODO: This manual retagging shouldn't be necessary, `.into()` should suffice.
|
// TODO: This manual retagging shouldn't be necessary, `.into()` should suffice.
|
||||||
poly,
|
poly,
|
||||||
|
|
|
||||||
|
|
@ -80,12 +80,17 @@ impl SpecctraMesadata {
|
||||||
.map(|(index, layer)| (index, layer.name.clone())),
|
.map(|(index, layer)| (index, layer.name.clone())),
|
||||||
);
|
);
|
||||||
|
|
||||||
// keeping this as a separate iter pass because it might be moved into a different struct later?
|
// assign IDs to all nets named in pcb.network
|
||||||
let net_netname = BiHashMap::from_iter(
|
let net_netname = BiHashMap::from_iter(
|
||||||
pcb.network
|
pcb.network
|
||||||
.classes
|
.classes
|
||||||
.iter()
|
.iter()
|
||||||
.flat_map(|class| &class.nets)
|
.flat_map(|class| &class.nets)
|
||||||
|
.chain(
|
||||||
|
pcb.network.nets
|
||||||
|
.iter()
|
||||||
|
.map(|net| &net.name)
|
||||||
|
)
|
||||||
.enumerate()
|
.enumerate()
|
||||||
.map(|(net, netname)| (net, netname.clone())),
|
.map(|(net, netname)| (net, netname.clone())),
|
||||||
);
|
);
|
||||||
|
|
|
||||||
|
|
@ -87,6 +87,8 @@ pub struct Structure {
|
||||||
pub boundary: Boundary,
|
pub boundary: Boundary,
|
||||||
#[vec("plane")]
|
#[vec("plane")]
|
||||||
pub planes: Vec<Plane>,
|
pub planes: Vec<Plane>,
|
||||||
|
#[vec("keepout")]
|
||||||
|
pub keepouts: Vec<Keepout>,
|
||||||
pub via: ViaNames,
|
pub via: ViaNames,
|
||||||
#[vec("grid")]
|
#[vec("grid")]
|
||||||
pub grids: Vec<Grid>,
|
pub grids: Vec<Grid>,
|
||||||
|
|
@ -104,6 +106,7 @@ impl<R: std::io::BufRead> ReadDsn<R> for Structure {
|
||||||
layers: tokenizer.read_named_array("layer")?,
|
layers: tokenizer.read_named_array("layer")?,
|
||||||
boundary: tokenizer.read_named("boundary")?,
|
boundary: tokenizer.read_named("boundary")?,
|
||||||
planes: tokenizer.read_named_array("plane")?,
|
planes: tokenizer.read_named_array("plane")?,
|
||||||
|
keepouts: tokenizer.read_named_array("keepout")?,
|
||||||
via: tokenizer.read_named("via")?,
|
via: tokenizer.read_named("via")?,
|
||||||
grids: tokenizer.read_named_array("grid")?,
|
grids: tokenizer.read_named_array("grid")?,
|
||||||
rules: tokenizer.read_named_array("rule")?,
|
rules: tokenizer.read_named_array("rule")?,
|
||||||
|
|
@ -331,7 +334,7 @@ pub struct Network {
|
||||||
pub struct NetPinAssignments {
|
pub struct NetPinAssignments {
|
||||||
#[anon]
|
#[anon]
|
||||||
pub name: String,
|
pub name: String,
|
||||||
pub pins: Pins,
|
pub pins: Option<Pins>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(ReadDsn, WriteSes, Debug)]
|
#[derive(ReadDsn, WriteSes, Debug)]
|
||||||
|
|
@ -481,9 +484,9 @@ pub struct Via {
|
||||||
#[anon]
|
#[anon]
|
||||||
pub name: String,
|
pub name: String,
|
||||||
#[anon]
|
#[anon]
|
||||||
pub x: i32,
|
pub x: f64,
|
||||||
#[anon]
|
#[anon]
|
||||||
pub y: i32,
|
pub y: f64,
|
||||||
pub net: String,
|
pub net: String,
|
||||||
pub r#type: String,
|
pub r#type: String,
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue