fixed some reference errors
This commit is contained in:
parent
15a2564f13
commit
e2c02316af
|
@ -191,7 +191,7 @@ pub(super) fn parse_events<'a>(
|
||||||
// so that we end up storing all values
|
// so that we end up storing all values
|
||||||
// of a particular signal in a consistent
|
// of a particular signal in a consistent
|
||||||
// amount of bytes
|
// amount of bytes
|
||||||
let bytes_required = signal.bytes_required()?;
|
let bytes_required = Signal::bytes_required(num_bits, name)?;
|
||||||
|
|
||||||
while curr_num_bytes < bytes_required {
|
while curr_num_bytes < bytes_required {
|
||||||
// TODO: remove once library is known to be stable
|
// TODO: remove once library is known to be stable
|
||||||
|
|
|
@ -58,6 +58,14 @@ pub(super) fn parse_var<'a>(
|
||||||
| SigType::Tri1
|
| SigType::Tri1
|
||||||
| SigType::Time => {
|
| SigType::Time => {
|
||||||
let no_bits = word.parse::<usize>().expect(parse_err.as_str());
|
let no_bits = word.parse::<usize>().expect(parse_err.as_str());
|
||||||
|
let no_bits = u16::try_from(no_bits).map_err(|_| {
|
||||||
|
format!(
|
||||||
|
"Error near {}:{} while parsing vcd file at {cursor:?}. \
|
||||||
|
This signal has {no_bits} > 2^16 - 1 bits.",
|
||||||
|
file!(),
|
||||||
|
line!()
|
||||||
|
)
|
||||||
|
})?;
|
||||||
Some(no_bits)
|
Some(no_bits)
|
||||||
}
|
}
|
||||||
// for strings, we don't really care what the number of bits is
|
// for strings, we don't really care what the number of bits is
|
||||||
|
@ -100,7 +108,7 @@ pub(super) fn parse_var<'a>(
|
||||||
name: full_signal_name,
|
name: full_signal_name,
|
||||||
sig_type: var_type,
|
sig_type: var_type,
|
||||||
signal_error: None,
|
signal_error: None,
|
||||||
num_bits: None,
|
num_bits: no_bits,
|
||||||
self_idx: signal_idx,
|
self_idx: signal_idx,
|
||||||
nums_encoded_as_fixed_width_le_u8: vec![],
|
nums_encoded_as_fixed_width_le_u8: vec![],
|
||||||
string_vals: vec![],
|
string_vals: vec![],
|
||||||
|
|
|
@ -92,51 +92,9 @@ impl Signal {
|
||||||
)),
|
)),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// pub(super) fn try_dereference_alias_mut<'a>(
|
pub(super) fn bytes_required(num_bits: &Option<u16>, name: &String) -> Result<u8, String> {
|
||||||
// &'a self,
|
let num_bits = num_bits
|
||||||
// signals: &'a mut Vec<Signal>,
|
.ok_or_else(|| format!("Error near {}:{}. num_bits empty.", file!(), line!()))?;
|
||||||
// ) -> Result<&mut Signal, String> {
|
|
||||||
// // dereference a signal if we need to and return a signal, else return
|
|
||||||
// // the signal itself
|
|
||||||
// let signal = match self {
|
|
||||||
// Signal::Data {
|
|
||||||
// name,
|
|
||||||
// sig_type,
|
|
||||||
// signal_error,
|
|
||||||
// num_bits,
|
|
||||||
// self_idx,
|
|
||||||
// ..
|
|
||||||
// } => {
|
|
||||||
// let SignalIdx(idx) = self_idx;
|
|
||||||
// signals.get(*idx).unwrap()
|
|
||||||
// }
|
|
||||||
// Signal::Alias { name, signal_alias } => {
|
|
||||||
// let SignalIdx(idx) = signal_alias;
|
|
||||||
// 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!()
|
|
||||||
// )),
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
pub(super) fn bytes_required(&self) -> Result<u8, String> {
|
|
||||||
match self {
|
|
||||||
Signal::Data {
|
|
||||||
name,
|
|
||||||
sig_type,
|
|
||||||
signal_error,
|
|
||||||
num_bits,
|
|
||||||
..
|
|
||||||
} => {
|
|
||||||
let num_bits = num_bits.ok_or_else(|| {
|
|
||||||
format!("Error near {}:{}. num_bits empty.", file!(), line!())
|
|
||||||
})?;
|
|
||||||
let bytes_required = (num_bits / 8) + if (num_bits % 8) > 0 { 1 } else { 0 };
|
let bytes_required = (num_bits / 8) + if (num_bits % 8) > 0 { 1 } else { 0 };
|
||||||
let bytes_required = u8::try_from(bytes_required).map_err(|_| {
|
let bytes_required = u8::try_from(bytes_required).map_err(|_| {
|
||||||
format!(
|
format!(
|
||||||
|
@ -148,37 +106,6 @@ impl Signal {
|
||||||
})?;
|
})?;
|
||||||
Ok(bytes_required)
|
Ok(bytes_required)
|
||||||
}
|
}
|
||||||
Signal::Alias { name, signal_alias } => {
|
|
||||||
let msg = format!(
|
|
||||||
"Error near {}:{}. Bytes required should not be called on the signal alias {name}",
|
|
||||||
file!(),
|
|
||||||
line!()
|
|
||||||
);
|
|
||||||
Err(msg)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// let bytes_required = (num_bits / 8) + if (num_bits % 8) > 0 { 1 } else { 0 };
|
|
||||||
}
|
|
||||||
// fn u8_tmstmp_to_biguint(&self, idx: usize) -> BigUint {
|
|
||||||
// // let lsb_idx = self.
|
|
||||||
// match self {
|
|
||||||
// Signal::Data {
|
|
||||||
// name,
|
|
||||||
// sig_type,
|
|
||||||
// signal_error,
|
|
||||||
// num_bits,
|
|
||||||
// self_idx,
|
|
||||||
// nums_encoded_as_fixed_width_le_u8,
|
|
||||||
// string_vals,
|
|
||||||
// lsb_indxs_of_num_tmstmp_vals_on_tmln,
|
|
||||||
// byte_len_of_num_tmstmp_vals_on_tmln,
|
|
||||||
// lsb_indxs_of_string_tmstmp_vals_on_tmln,
|
|
||||||
// byte_len_of_string_tmstmp_vals_on_tmln,
|
|
||||||
// scope_parent,
|
|
||||||
// } => {}
|
|
||||||
// }
|
|
||||||
// BigUint::zero()
|
|
||||||
// }
|
|
||||||
pub(super) fn query_value(&self, time: BigUint) -> Result<TimelineQueryResults, String> {
|
pub(super) fn query_value(&self, time: BigUint) -> Result<TimelineQueryResults, String> {
|
||||||
// match
|
// match
|
||||||
// assert
|
// assert
|
||||||
|
|
|
@ -61,10 +61,10 @@ pub struct VCD {
|
||||||
|
|
||||||
impl VCD {
|
impl VCD {
|
||||||
/// We take in a Signal and attempt to dereference that signal if it is of
|
/// We take in a Signal and attempt to dereference that signal if it is of
|
||||||
/// variant Signal::Alias. If it is of variant Signal::Alias and points to
|
/// variant ``Signal::Alias``. If it is of variant ``Signal::Alias`` and points to
|
||||||
/// another alias, that's an error. Otherwise, we return the Signal::Data
|
/// another alias, that's an error. Otherwise, we return the ``Signal::Data``
|
||||||
/// pointed to by the Signal::Alias.
|
/// pointed to by the ``Signal::Alias``.
|
||||||
/// If the Signal is of varint Signal::Data, then that can be returned directly.
|
/// If the Signal is of varint ``Signal::Data``, then that can be returned directly.
|
||||||
pub(super) fn try_dereference_alias_mut<'a>(
|
pub(super) fn try_dereference_alias_mut<'a>(
|
||||||
&'a mut self,
|
&'a mut self,
|
||||||
idx: &SignalIdx,
|
idx: &SignalIdx,
|
||||||
|
|
Loading…
Reference in a new issue