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
|
||||
// of a particular signal in a consistent
|
||||
// amount of bytes
|
||||
let bytes_required = signal.bytes_required()?;
|
||||
let bytes_required = Signal::bytes_required(num_bits, name)?;
|
||||
|
||||
while curr_num_bytes < bytes_required {
|
||||
// TODO: remove once library is known to be stable
|
||||
|
|
|
@ -58,6 +58,14 @@ pub(super) fn parse_var<'a>(
|
|||
| SigType::Tri1
|
||||
| SigType::Time => {
|
||||
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)
|
||||
}
|
||||
// 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,
|
||||
sig_type: var_type,
|
||||
signal_error: None,
|
||||
num_bits: None,
|
||||
num_bits: no_bits,
|
||||
self_idx: signal_idx,
|
||||
nums_encoded_as_fixed_width_le_u8: vec![],
|
||||
string_vals: vec![],
|
||||
|
|
|
@ -92,93 +92,20 @@ impl Signal {
|
|||
)),
|
||||
}
|
||||
}
|
||||
// pub(super) fn try_dereference_alias_mut<'a>(
|
||||
// &'a self,
|
||||
// signals: &'a mut Vec<Signal>,
|
||||
// ) -> 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 = u8::try_from(bytes_required).map_err(|_| {
|
||||
format!(
|
||||
"Error near {}:{}. Signal {name} of length num_bits requires \
|
||||
pub(super) fn bytes_required(num_bits: &Option<u16>, name: &String) -> Result<u8, String> {
|
||||
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 = u8::try_from(bytes_required).map_err(|_| {
|
||||
format!(
|
||||
"Error near {}:{}. Signal {name} of length num_bits requires \
|
||||
{bytes_required} > 256 bytes.",
|
||||
file!(),
|
||||
line!()
|
||||
)
|
||||
})?;
|
||||
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 };
|
||||
file!(),
|
||||
line!()
|
||||
)
|
||||
})?;
|
||||
Ok(bytes_required)
|
||||
}
|
||||
// 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> {
|
||||
// match
|
||||
// assert
|
||||
|
|
|
@ -61,10 +61,10 @@ pub struct VCD {
|
|||
|
||||
impl VCD {
|
||||
/// 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
|
||||
/// another alias, that's an error. Otherwise, we return the Signal::Data
|
||||
/// pointed to by the Signal::Alias.
|
||||
/// If the Signal is of varint Signal::Data, then that can be returned directly.
|
||||
/// 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``
|
||||
/// pointed to by the ``Signal::Alias``.
|
||||
/// If the Signal is of varint ``Signal::Data``, then that can be returned directly.
|
||||
pub(super) fn try_dereference_alias_mut<'a>(
|
||||
&'a mut self,
|
||||
idx: &SignalIdx,
|
||||
|
|
Loading…
Reference in a new issue