Skip to content

Commit

Permalink
add more scope types
Browse files Browse the repository at this point in the history
  • Loading branch information
ekiwi committed Nov 10, 2023
1 parent f40e269 commit 0a88d03
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 9 deletions.
4 changes: 2 additions & 2 deletions src/fst.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,14 +75,14 @@ impl<R: BufRead + Seek> SignalSource for FstWaveDatabase<R> {
fn convert_scope_tpe(tpe: FstScopeType) -> ScopeType {
match tpe {
FstScopeType::Module => ScopeType::Module,
_ => ScopeType::Todo,
other => panic!("Unsupported scope type: {:?}", other),
}
}

fn convert_var_tpe(tpe: FstVarType) -> VarType {
match tpe {
FstVarType::Wire => VarType::Wire,
_ => VarType::Todo,
other => panic!("Unsupported var type: {:?}", other),
}
}

Expand Down
6 changes: 4 additions & 2 deletions src/hierarchy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,10 @@ impl HierarchyStringId {
#[derive(Debug, Clone, Copy)]
pub enum ScopeType {
Module,
Todo, // placeholder tpe
Task,
Function,
Begin,
Fork,
}

#[derive(Debug, Clone, Copy)]
Expand All @@ -126,7 +129,6 @@ pub enum VarType {
Parameter,
Integer,
String,
Todo, // placeholder tpe
}

#[derive(Debug, Clone, Copy)]
Expand Down
6 changes: 5 additions & 1 deletion src/vcd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,11 @@ fn convert_timescale_unit(name: &[u8]) -> TimescaleUnit {
fn convert_scope_tpe(tpe: &[u8]) -> ScopeType {
match tpe {
b"module" => ScopeType::Module,
_ => ScopeType::Todo,
b"task" => ScopeType::Task,
b"function" => ScopeType::Function,
b"begin" => ScopeType::Begin,
b"fork" => ScopeType::Fork,
_ => panic!("TODO: convert {}", String::from_utf8_lossy(tpe)),
}
}

Expand Down
23 changes: 19 additions & 4 deletions tests/diff_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,10 @@ fn diff_meta(ours: &Hierarchy, ref_header: &vcd::Header) {
fn waveform_scope_type_to_string(tpe: ScopeType) -> &'static str {
match tpe {
ScopeType::Module => "module",
ScopeType::Todo => "todo",
ScopeType::Task => "task",
ScopeType::Function => "function",
ScopeType::Begin => "begin",
ScopeType::Fork => "fork",
}
}

Expand All @@ -83,7 +86,6 @@ fn waveform_var_type_to_string(tpe: VarType) -> &'static str {
VarType::Parameter => "parameter",
VarType::Integer => "integer",
VarType::String => "string",
VarType::Todo => "todo",
}
}

Expand Down Expand Up @@ -247,7 +249,7 @@ fn id_to_int(id: &[u8]) -> Option<u64> {

#[test]
#[ignore] // TODO: this file has a delta cycle, i.e. the same signal (`/`) changes twice in the same cycle (35185000)
fn diff_aldec_SPI_Write() {
fn diff_aldec_spi_write() {
run_diff_test(
"inputs/aldec/SPI_Write.vcd",
"inputs/aldec/SPI_Write.vcd.fst",
Expand Down Expand Up @@ -288,10 +290,23 @@ fn diff_gtkwave_perm_current() {
}

#[test]
fn diff_icarus_CPU() {
fn diff_icarus_cpu() {
run_diff_test("inputs/icarus/CPU.vcd", "inputs/icarus/CPU.vcd.fst");
}

#[test]
fn diff_icarus_rv32_soc_tb() {
run_diff_test(
"inputs/icarus/rv32_soc_TB.vcd",
"inputs/icarus/rv32_soc_TB.vcd.fst",
);
}

#[test]
fn diff_icarus_test1() {
run_diff_test("inputs/icarus/test1.vcd", "inputs/icarus/test1.vcd.fst");
}

#[test]
fn diff_treadle_gcd() {
run_diff_test("inputs/treadle/GCD.vcd", "inputs/treadle/GCD.vcd.fst");
Expand Down

0 comments on commit 0a88d03

Please sign in to comment.