Skip to content

Commit

Permalink
add vcd_reg_dump example
Browse files Browse the repository at this point in the history
  • Loading branch information
hellow554 committed Nov 26, 2018
1 parent 6a377a0 commit 97a8cc3
Showing 1 changed file with 44 additions and 0 deletions.
44 changes: 44 additions & 0 deletions examples/vcd_reg_dump.rs
Original file line number Diff line number Diff line change
@@ -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();
}

0 comments on commit 97a8cc3

Please sign in to comment.