pcb_toolkit/differential/
types.rs1use serde::{Deserialize, Serialize};
2
3#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
5pub enum DiffProtocol {
6 Ddr2ClkDqs,
7 Ddr3ClkDqs,
8 Ddr4ClkDqs,
9 Usb2x,
10 Usb3x,
11 Lvds,
12 Hdmi,
13 Sata,
14 Ethernet,
15 DisplayPort,
16 DisplayPortEaglelake,
17 DisplayPortCalpella,
18 PcieGen1,
19 PcieGen2,
20 PcieGen3,
21 PcieGen4,
22 SsrxSstx,
23 Custom,
24}
25
26impl DiffProtocol {
27 pub fn target_zdiff(self) -> Option<f64> {
29 match self {
30 Self::Ddr2ClkDqs | Self::Ddr3ClkDqs => Some(100.0),
31 Self::Ddr4ClkDqs => Some(80.0),
32 Self::Usb2x => Some(90.0),
33 Self::Usb3x => Some(90.0),
34 Self::Lvds | Self::Hdmi | Self::Sata | Self::Ethernet => Some(100.0),
35 Self::DisplayPort => Some(100.0),
36 Self::DisplayPortEaglelake | Self::DisplayPortCalpella => Some(85.0),
37 Self::PcieGen1 => Some(100.0),
38 Self::PcieGen2 | Self::PcieGen3 | Self::PcieGen4 => Some(85.0),
39 Self::SsrxSstx => Some(85.0),
40 Self::Custom => None,
41 }
42 }
43}
44
45#[derive(Debug, Clone, Serialize, Deserialize)]
47pub struct DifferentialResult {
48 pub zdiff: f64,
50 pub zo: f64,
52 pub zodd: f64,
54 pub zeven: f64,
56 pub kb: f64,
58 pub kb_db: f64,
60 pub kb_term: f64,
62 pub kb_term_db: f64,
64}
65
66pub fn kb_terminated(kb: f64) -> f64 {
72 if kb.abs() < 1e-15 {
73 return 0.0;
74 }
75 (1.0 - (1.0 - kb * kb).sqrt()) / kb
76}