Skip to content

Commit fa30e3e

Browse files
authored
fold large mos devices for sky130 commercial pdk (#43)
1 parent 041a0ec commit fa30e3e

File tree

1 file changed

+26
-8
lines changed
  • pdks/sky130_commercial_pdk/src

1 file changed

+26
-8
lines changed

pdks/sky130_commercial_pdk/src/mos.rs

+26-8
Original file line numberDiff line numberDiff line change
@@ -34,19 +34,37 @@ impl Sky130CommercialPdk {
3434
}
3535

3636
pub(crate) fn mos_schematic(ctx: &mut SchematicCtx, params: &MosParams) -> Result<()> {
37+
use std::fmt::Write;
3738
let mos_db = ctx.mos_db();
3839
let name = &mos_db.get_spec(params.id)?.name;
3940
// TODO correctly handle nf and m.
4041
// The sky130 pdk uses w and l in microns.
4142
// So we must divide by 1_000 to convert nanometers to microns.
42-
ctx.set_spice(format!(
43-
"M0 d g s b {} w={:.3} l={:.3} nf={} mult={}",
44-
name,
45-
params.w as f64 / 1_000.0,
46-
params.l as f64 / 1_000.0,
47-
params.nf,
48-
params.m,
49-
));
43+
// The max allowed width of a single transistor is 100um, so we fold
44+
// larger transistors into several 100um segments plus one smaller segment containing
45+
// the leftover width.
46+
let mut spice = String::new();
47+
let n_extra = params.w / 100_000;
48+
let l = params.l as f64 / 1_000.0;
49+
let nf = params.nf;
50+
let m = params.m;
51+
52+
for i in 1..=n_extra {
53+
writeln!(
54+
&mut spice,
55+
"M{i} d g s b {name} w=100.0 l={l:.3} nf={nf} mult={m}"
56+
)
57+
.expect("failed to write to string");
58+
}
59+
60+
let w = (params.w % 100_000) as f64 / 1_000.0;
61+
writeln!(
62+
&mut spice,
63+
"M0 d g s b {name} w={w:.3} l={l:.3} nf={nf} mult={m}"
64+
)
65+
.expect("failed to write to string");
66+
67+
ctx.set_spice(spice);
5068
Ok(())
5169
}
5270
}

0 commit comments

Comments
 (0)