pub mod vcd;
use std::io;
#[derive(Debug, Eq, PartialEq)]
pub enum TraceValue {
Bool(bool),
U32(u32),
U64(u64),
U128(u128),
}
#[derive(Debug, Eq, PartialEq)]
pub enum TraceValueType {
Bool,
U32,
U64,
U128,
}
impl TraceValueType {
pub(crate) fn from_bit_width(bit_width: u32) -> TraceValueType {
if bit_width == 1 {
TraceValueType::Bool
} else if bit_width <= 32 {
TraceValueType::U32
} else if bit_width <= 64 {
TraceValueType::U64
} else if bit_width <= 128 {
TraceValueType::U128
} else {
unreachable!()
}
}
}
pub trait Trace {
type SignalId;
fn push_module(&mut self, name: &'static str) -> io::Result<()>;
fn pop_module(&mut self) -> io::Result<()>;
fn add_signal(
&mut self,
name: &'static str,
bit_width: u32,
type_: TraceValueType,
) -> io::Result<Self::SignalId>;
fn update_time_stamp(&mut self, time_stamp: u64) -> io::Result<()>;
fn update_signal(&mut self, signal_id: &Self::SignalId, value: TraceValue) -> io::Result<()>;
}