use serde::{Deserialize, Serialize};
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
pub enum DiffProtocol {
Ddr2ClkDqs,
Ddr3ClkDqs,
Ddr4ClkDqs,
Usb2x,
Usb3x,
Lvds,
Hdmi,
Sata,
Ethernet,
DisplayPort,
DisplayPortEaglelake,
DisplayPortCalpella,
PcieGen1,
PcieGen2,
PcieGen3,
PcieGen4,
SsrxSstx,
Custom,
}
impl DiffProtocol {
pub fn target_zdiff(self) -> Option<f64> {
match self {
Self::Ddr2ClkDqs | Self::Ddr3ClkDqs => Some(100.0),
Self::Ddr4ClkDqs => Some(80.0),
Self::Usb2x => Some(90.0),
Self::Usb3x => Some(90.0),
Self::Lvds | Self::Hdmi | Self::Sata | Self::Ethernet => Some(100.0),
Self::DisplayPort => Some(100.0),
Self::DisplayPortEaglelake | Self::DisplayPortCalpella => Some(85.0),
Self::PcieGen1 => Some(100.0),
Self::PcieGen2 | Self::PcieGen3 | Self::PcieGen4 => Some(85.0),
Self::SsrxSstx => Some(85.0),
Self::Custom => None,
}
}
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct DifferentialResult {
pub zdiff: f64,
pub zo: f64,
pub zodd: f64,
pub zeven: f64,
pub kb: f64,
pub kb_db: f64,
pub kb_term: f64,
pub kb_term_db: f64,
}
pub fn kb_terminated(kb: f64) -> f64 {
if kb.abs() < 1e-15 {
return 0.0;
}
(1.0 - (1.0 - kb * kb).sqrt()) / kb
}