reda_sp/model/components/
mosfet.rs1use std::collections::HashMap;
2use derive_builder::Builder;
3use reda_unit::{Length, Number};
4
5use crate::ToSpice;
6
7#[derive(Debug, Clone, Builder)]
8#[builder(setter(strip_option, into))]
9pub struct MosFET {
10 pub name: String, pub drain: String, pub gate: String, pub source: String, pub bulk: String, pub model_name: String, pub length: Length, pub width: Length, #[builder(default)]
19 pub parameters: HashMap<String, Number>,
20}
21
22impl ToSpice for MosFET {
23 fn to_spice(&self) -> String {
24 let mut line = format!(
25 "M{} {} {} {} {} {} L={} W={}",
26 self.name,
27 self.drain,
28 self.gate,
29 self.source,
30 self.bulk,
31 self.model_name,
32 self.length,
33 self.width
34 );
35 for (k, v) in &self.parameters {
36 line.push_str(&format!(" {}={}", k, v));
37 }
38 line
39 }
40}
41
42#[derive(Debug, Clone)]
43pub enum MOSFETKind {
44 NMOS,
45 PMOS,
46}