diff --git a/examples/vcd_reg_dump.rs b/examples/vcd_reg_dump.rs new file mode 100644 index 0000000..dcf8efa --- /dev/null +++ b/examples/vcd_reg_dump.rs @@ -0,0 +1,44 @@ +use logical::dump::Vcd; +use logical::{Ieee1164, LogicVector}; + +fn main() { + let v = LogicVector::with_value(5, 8).unwrap(); + assert_eq!(v.width(), 8); + assert_eq!(v, 5); + + let mut dumper = Vcd::new("VCD Example"); + let mut foo: LogicVector; + + foo = vec![Ieee1164::_Z; 16].into(); + dumper.serialize_logivector("foo", &foo); + dumper.tick(); + + foo = vec![Ieee1164::_U; 16].into(); + dumper.serialize_logivector("foo", &foo); + dumper.tick(); + + foo = vec![Ieee1164::_X; 16].into(); + dumper.serialize_logivector("foo", &foo); + dumper.tick(); + + foo = vec![Ieee1164::_W; 16].into(); + dumper.serialize_logivector("foo", &foo); + dumper.tick(); + + foo = vec![Ieee1164::_D; 16].into(); + dumper.serialize_logivector("foo", &foo); + dumper.tick(); + + foo = vec![Ieee1164::_1; 16].into(); + dumper.serialize_logivector("foo", &foo); + dumper.tick(); + + let one = LogicVector::with_value(1, 16).unwrap(); + for _ in 0..90 { + dumper.serialize_logivector("foo", &foo); + dumper.tick(); + foo = (foo + &one).unwrap(); + } + + dumper.dump("/home/marcel/b.vcd").unwrap(); +}