Skip to main content

pcb_toolkit/differential/
types.rs

1use serde::{Deserialize, Serialize};
2
3/// Differential pair protocol presets with target Zdiff.
4///
5/// Data extracted from Saturn PCB Toolkit binary at offset 0x783121.
6#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
7pub enum DiffProtocol {
8    Ddr2ClkDqs,
9    Ddr3ClkDqs,
10    Ddr4ClkDqs,
11    Usb2x,
12    Usb3x,
13    Lvds,
14    Hdmi,
15    Sata,
16    Ethernet,
17    DisplayPort,
18    DisplayPortEaglelake,
19    DisplayPortCalpella,
20    PcieGen1,
21    PcieGen2,
22    PcieGen3,
23    PcieGen4,
24    SsrxSstx,
25    Custom,
26}
27
28impl DiffProtocol {
29    /// Target differential impedance (Ohms) for this protocol.
30    pub fn target_zdiff(self) -> Option<f64> {
31        match self {
32            Self::Ddr2ClkDqs | Self::Ddr3ClkDqs => Some(100.0),
33            Self::Ddr4ClkDqs => Some(80.0),
34            Self::Usb2x => Some(90.0),
35            Self::Usb3x => Some(90.0),
36            Self::Lvds | Self::Hdmi | Self::Sata | Self::Ethernet => Some(100.0),
37            Self::DisplayPort => Some(100.0),
38            Self::DisplayPortEaglelake | Self::DisplayPortCalpella => Some(85.0),
39            Self::PcieGen1 => Some(100.0),
40            Self::PcieGen2 | Self::PcieGen3 | Self::PcieGen4 => Some(85.0),
41            Self::SsrxSstx => Some(85.0),
42            Self::Custom => None,
43        }
44    }
45}
46
47/// Result of a differential impedance calculation.
48#[derive(Debug, Clone, Serialize, Deserialize)]
49pub struct DifferentialResult {
50    /// Differential impedance (Ohms). Zdiff = 2 × Zodd.
51    pub zdiff: f64,
52    /// Single-ended impedance (Ohms).
53    pub zo: f64,
54    /// Odd-mode impedance (Ohms).
55    pub zodd: f64,
56    /// Even-mode impedance (Ohms).
57    pub zeven: f64,
58    /// Backward coupling coefficient Kb.
59    pub kb: f64,
60    /// Coupling coefficient in dB.
61    pub kb_db: f64,
62}