Skip to content

Commit

Permalink
wip: reals support
Browse files Browse the repository at this point in the history
  • Loading branch information
ekiwi committed Nov 10, 2023
1 parent 790362d commit 8e58eea
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 3 deletions.
1 change: 1 addition & 0 deletions src/hierarchy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -613,6 +613,7 @@ impl HierarchyBuilder {
}
}

#[allow(dead_code)]
pub fn print_statistics(&self) {
println!("Duplicate strings: {}", self.duplicate_string_count);
println!(
Expand Down
2 changes: 1 addition & 1 deletion src/vcd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -562,7 +562,7 @@ fn read_single_stream_of_values<'a>(
loop {
if let Some((pos, cmd)) = reader.next() {
if (pos + offset) > stop_pos {
if let BodyCmd::Time(value) = cmd {
if let BodyCmd::Time(_) = cmd {
break; // stop before the next time value when we go beyond the stop position
}
}
Expand Down
14 changes: 13 additions & 1 deletion src/wavemem.rs
Original file line number Diff line number Diff line change
Expand Up @@ -640,7 +640,19 @@ impl SignalEncoder {
self.data.extend_from_slice(&value[1..]);
}
SignalType::Real => {
todo!("Implement real!")
assert!(
matches!(value[0], b'r' | b'R'),
"expected a real, not {}",
String::from_utf8_lossy(value)
);
// parse float
let float_value = std::str::from_utf8(&value[1..])
.unwrap()
.parse::<f64>()
.unwrap();
// write var-length time index + fixed little endian float bytes
leb128::write::unsigned(&mut self.data, time_idx_delta as u64).unwrap();
self.data.extend_from_slice(&float_value.to_le_bytes());
}
}
self.prev_time_idx = time_index;
Expand Down
2 changes: 1 addition & 1 deletion tests/diff_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -354,7 +354,7 @@ fn diff_model_sim_cpu_design() {
}

#[test]
#[ignore] // TODO: add real support
#[ignore] // TODO: this file declares a `real` signal and then emits strings ... :(
fn diff_my_hdl_sigmoid_tb() {
run_diff_test(
"inputs/my-hdl/sigmoid_tb.vcd",
Expand Down

0 comments on commit 8e58eea

Please sign in to comment.