1pub mod vcd;
4
5use std::io;
6
7#[derive(Debug, Eq, PartialEq)]
9pub enum TraceValue {
10 Bool(bool),
12 U32(u32),
14 U64(u64),
16 U128(u128),
18}
19
20#[derive(Debug, Eq, PartialEq)]
21pub enum TraceValueType {
22 Bool,
23 U32,
24 U64,
25 U128,
26}
27
28impl TraceValueType {
29 pub(crate) fn from_bit_width(bit_width: u32) -> TraceValueType {
30 if bit_width == 1 {
31 TraceValueType::Bool
32 } else if bit_width <= 32 {
33 TraceValueType::U32
34 } else if bit_width <= 64 {
35 TraceValueType::U64
36 } else if bit_width <= 128 {
37 TraceValueType::U128
38 } else {
39 unreachable!()
40 }
41 }
42}
43
44pub trait Trace {
45 type SignalId;
46
47 fn push_module(&mut self, name: &'static str) -> io::Result<()>;
48 fn pop_module(&mut self) -> io::Result<()>;
49 fn add_signal(
50 &mut self,
51 name: &'static str,
52 bit_width: u32,
53 type_: TraceValueType,
54 ) -> io::Result<Self::SignalId>;
55
56 fn update_time_stamp(&mut self, time_stamp: u64) -> io::Result<()>;
57 fn update_signal(&mut self, signal_id: &Self::SignalId, value: TraceValue) -> io::Result<()>;
58}