- moved dereferencing alias to VCD impl
- added function to help with reconstructing timestamps and numerical signal values
This commit is contained in:
parent
ea6701f104
commit
8dab46a0cb
3 changed files with 257 additions and 143 deletions
|
@ -99,4 +99,38 @@ impl VCD {
|
|||
)),
|
||||
}
|
||||
}
|
||||
pub(super) fn try_dereference_alias<'a>(
|
||||
&'a self,
|
||||
idx: &SignalIdx,
|
||||
) -> Result<&'a Signal, String> {
|
||||
// get the signal pointed to be SignalIdx from the arena
|
||||
let SignalIdx(idx) = idx;
|
||||
let signal = &self.all_signals[*idx];
|
||||
|
||||
// dereference signal if Signal::Alias, or keep idx if Signal::Data
|
||||
let signal_idx = match signal {
|
||||
Signal::Data {
|
||||
name,
|
||||
sig_type,
|
||||
signal_error,
|
||||
num_bits,
|
||||
self_idx,
|
||||
..
|
||||
} => *self_idx,
|
||||
Signal::Alias { name, signal_alias } => *signal_alias,
|
||||
};
|
||||
|
||||
// Should now point to Signal::Data variant, or else there's an error
|
||||
let SignalIdx(idx) = signal_idx;
|
||||
let signal = self.all_signals.get(idx).unwrap();
|
||||
match signal {
|
||||
Signal::Data { .. } => Ok(signal),
|
||||
Signal::Alias { .. } => Err(format!(
|
||||
"Error near {}:{}. A signal alias shouldn't \
|
||||
point to a signal alias.",
|
||||
file!(),
|
||||
line!()
|
||||
)),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Reference in a new issue