use compact_str::CompactString;
#[derive(Debug)]
pub struct SDF {
pub header: SDFHeader,
pub cells: Vec<SDFCell>
}
#[derive(Debug)]
pub struct SDFHeader {
pub sdf_version: CompactString,
pub design_name: Option<CompactString>,
pub date: Option<CompactString>,
pub vendor: Option<CompactString>,
pub program: Option<CompactString>,
pub program_version: Option<CompactString>,
pub hier_divider: char,
pub voltage: Option<SDFValue>,
pub process: Option<CompactString>,
pub temperature: Option<SDFValue>,
pub timescale: f32
}
mod path;
pub use path::{ SDFPath, SDFBus };
#[derive(Debug)]
pub struct SDFPort {
pub port_name: CompactString,
pub bus: SDFBus
}
#[derive(Debug)]
pub enum SDFValue {
None,
Single(f32),
Multi(Option<f32>, Option<f32>, Option<f32>)
}
#[derive(Debug)]
pub struct SDFCell {
pub celltype: CompactString,
pub instance: Option<SDFPath>,
pub delays: Vec<SDFDelay>,
}
#[derive(Debug)]
pub struct SDFDelayInterconnect {
pub a: SDFPath,
pub b: SDFPath,
pub delay: Vec<SDFValue>
}
#[derive(Debug)]
pub struct SDFDelayIOPath {
pub a: SDFPortSpec,
pub b: SDFPort,
pub retain: Option<Vec<SDFValue>>,
pub delay: Vec<SDFValue>
}
#[derive(Debug)]
pub enum SDFDelay {
Interconnect(SDFDelayInterconnect),
IOPath(SDFIOPathCond, SDFDelayIOPath)
}
#[derive(Debug)]
pub enum SDFIOPathCond {
None,
Cond(Vec<(SDFPort, bool)>),
CondElse
}
#[derive(Debug)]
pub struct SDFPortSpec {
pub edge_type: SDFPortEdge,
pub port: SDFPort
}
#[derive(Debug)]
pub enum SDFPortEdge {
None,
Posedge, Negedge,
T01, T10, T0Z, TZ1, T1Z, TZ0
}
mod sdfpest;
impl SDF {
#[inline]
pub fn parse_str(s: &str) -> Result<SDF, String> {
sdfpest::parse_sdf(s)
}
}