now parsing single bit 0|1|x|z|u
This commit is contained in:
parent
e2c02316af
commit
ea6701f104
|
@ -185,7 +185,6 @@ pub(super) fn parse_events<'a>(
|
||||||
})?;
|
})?;
|
||||||
lsb_indxs_of_num_tmstmp_vals_on_tmln
|
lsb_indxs_of_num_tmstmp_vals_on_tmln
|
||||||
.push(LsbIdxOfTmstmpValOnTmln(curr_tmstmp_lsb_idx));
|
.push(LsbIdxOfTmstmpValOnTmln(curr_tmstmp_lsb_idx));
|
||||||
byte_len_of_num_tmstmp_vals_on_tmln.push(curr_num_bytes);
|
|
||||||
|
|
||||||
// we may need to zero extend values
|
// we may need to zero extend values
|
||||||
// so that we end up storing all values
|
// so that we end up storing all values
|
||||||
|
@ -194,19 +193,10 @@ pub(super) fn parse_events<'a>(
|
||||||
let bytes_required = Signal::bytes_required(num_bits, name)?;
|
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
|
nums_encoded_as_fixed_width_le_u8.push(0u8);
|
||||||
// useful for debugging
|
|
||||||
// let err = format!("Error at {cursor:?}.\
|
|
||||||
// num_bits = {num_bits}, \
|
|
||||||
// observed_bits = {observed_num_bits}, \
|
|
||||||
// curr_num_bytes = {curr_num_bytes}, \
|
|
||||||
// bytes_required = {bytes_required} \
|
|
||||||
// for signal {name}");
|
|
||||||
// Err(err)?;
|
|
||||||
|
|
||||||
byte_len_of_num_tmstmp_vals_on_tmln.push(0u8);
|
|
||||||
curr_num_bytes += 1;
|
curr_num_bytes += 1;
|
||||||
}
|
}
|
||||||
|
byte_len_of_num_tmstmp_vals_on_tmln.push(curr_num_bytes);
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -221,288 +211,243 @@ pub(super) fn parse_events<'a>(
|
||||||
}
|
}
|
||||||
|
|
||||||
// handle the case of a one bit signal whose value is set to `0`
|
// handle the case of a one bit signal whose value is set to `0`
|
||||||
// "0" => {
|
"0" => {
|
||||||
// // lookup signal idx
|
// lookup signal idx
|
||||||
// let hash = &word[1..];
|
let hash = &word[1..];
|
||||||
// let SignalIdx(ref signal_idx) = signal_map.get(hash).ok_or(()).map_err(|_| {
|
let signal_idx = signal_map.get(hash).ok_or(()).map_err(|_| {
|
||||||
// format!(
|
format!(
|
||||||
// "Error near {}:{}. Failed to lookup signal {hash} at {cursor:?}",
|
"Error near {}:{}. Failed to lookup signal {hash} at {cursor:?}",
|
||||||
// file!(),
|
file!(),
|
||||||
// line!()
|
line!()
|
||||||
// )
|
)
|
||||||
// })?;
|
})?;
|
||||||
|
|
||||||
// // account for fact that signal idx could be an alias, so there
|
let signal = vcd.try_dereference_alias_mut(signal_idx)?;
|
||||||
// // could be one step of indirection
|
|
||||||
// let signal_idx = {
|
|
||||||
// let signal = vcd.all_signals.get(*signal_idx).unwrap();
|
|
||||||
// match signal {
|
|
||||||
// Signal::Data { .. } => *signal_idx,
|
|
||||||
// Signal::Alias { signal_alias, .. } => {
|
|
||||||
// let SignalIdx(ref signal_idx) = signal_alias;
|
|
||||||
// signal_idx.clone()
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// };
|
|
||||||
|
|
||||||
// // after handling potential indirection, go ahead and update the timeline
|
match signal {
|
||||||
// // of the signal signal_idx references
|
Signal::Data {
|
||||||
// let signal = vcd.all_signals.get_mut(signal_idx).unwrap();
|
name,
|
||||||
// match signal {
|
sig_type,
|
||||||
// Signal::Data {
|
ref mut signal_error,
|
||||||
// name,
|
num_bits,
|
||||||
// sig_type,
|
self_idx,
|
||||||
// ref mut signal_error,
|
nums_encoded_as_fixed_width_le_u8,
|
||||||
// num_bits,
|
string_vals,
|
||||||
// u8_timeline,
|
lsb_indxs_of_num_tmstmp_vals_on_tmln,
|
||||||
// u8_timeline_markers,
|
byte_len_of_num_tmstmp_vals_on_tmln,
|
||||||
// ..
|
lsb_indxs_of_string_tmstmp_vals_on_tmln,
|
||||||
// } => {
|
byte_len_of_string_tmstmp_vals_on_tmln,
|
||||||
// // if this is a bad signal, go ahead and skip it
|
scope_parent,
|
||||||
// if signal_error.is_some() {
|
} => {
|
||||||
// continue;
|
// if this is a bad signal, go ahead and skip it
|
||||||
// }
|
if signal_error.is_some() {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
// // Get bitwidth and verify that it is 1.
|
// Get bitwidth and verify that it is 1.
|
||||||
// // Also account for the error case of a bitwidth of `None`
|
// Also account for the error case of a bitwidth of `None`
|
||||||
// match num_bits {
|
match num_bits {
|
||||||
// Some(ref num_bits) => {
|
Some(ref num_bits) => {
|
||||||
// if *num_bits != 1 {
|
if *num_bits != 1 {
|
||||||
// let (f, l) = (file!(), line!());
|
let (f, l) = (file!(), line!());
|
||||||
// let msg = format!(
|
let msg = format!(
|
||||||
// "\
|
"\
|
||||||
// Error near {f}:{l}. The bitwidth for signal {name} \
|
Error near {f}:{l}. The bitwidth for signal {name} \
|
||||||
// of sig_type {sig_type:?} is expected to be `1` not \
|
of sig_type {sig_type:?} is expected to be `1` not \
|
||||||
// `{num_bits}`. \
|
`{num_bits}`. \
|
||||||
// This error occurred while parsing the vcd file at \
|
This error occurred while parsing the vcd file at \
|
||||||
// {cursor:?}"
|
{cursor:?}"
|
||||||
// );
|
);
|
||||||
// *signal_error = Some(msg);
|
*signal_error = Some(msg);
|
||||||
// continue;
|
continue;
|
||||||
// }
|
}
|
||||||
// }
|
}
|
||||||
// None => {
|
None => {
|
||||||
// let (f, l) = (file!(), line!());
|
let (f, l) = (file!(), line!());
|
||||||
// let msg = format!(
|
let msg = format!(
|
||||||
// "\
|
"\
|
||||||
// Error near {f}:{l}. The bitwidth for signal {name} \
|
Error near {f}:{l}. The bitwidth for signal {name} \
|
||||||
// must be specified for a signal of type {sig_type:?}. \
|
must be specified for a signal of type {sig_type:?}. \
|
||||||
// This error occurred while parsing the vcd file at \
|
This error occurred while parsing the vcd file at \
|
||||||
// {cursor:?}"
|
{cursor:?}"
|
||||||
// );
|
);
|
||||||
// Err(msg)?;
|
Err(msg)?;
|
||||||
// }
|
}
|
||||||
// };
|
};
|
||||||
|
nums_encoded_as_fixed_width_le_u8.push(0u8);
|
||||||
|
lsb_indxs_of_num_tmstmp_vals_on_tmln
|
||||||
|
.push(LsbIdxOfTmstmpValOnTmln(curr_tmstmp_lsb_idx));
|
||||||
|
byte_len_of_num_tmstmp_vals_on_tmln.push(1u8);
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
Signal::Alias { .. } => {
|
||||||
|
let (f, l) = (file!(), line!());
|
||||||
|
let msg = format!(
|
||||||
|
"Error near {f}:{l}, a signal alias should not point to a signal alias.\n\
|
||||||
|
This error occurred while parsing vcd file at {cursor:?}");
|
||||||
|
Err(msg)
|
||||||
|
}
|
||||||
|
}?;
|
||||||
|
}
|
||||||
|
|
||||||
// let (f, l) = (file!(), line!());
|
"1" => {
|
||||||
// let timeline_idx = u32::try_from(vcd.tmstmps_encoded_as_u8s.len())
|
// lokup signal idx
|
||||||
// .map_err(|_| {
|
let hash = &word[1..];
|
||||||
// format!("Error near {f}:{l}. Failed to convert from usize to u32.")
|
let signal_idx = signal_map.get(hash).ok_or(()).map_err(|_| {
|
||||||
// })?;
|
format!(
|
||||||
// let timeline_idx = TimelineIdx(timeline_idx);
|
"Error near {}:{}. Failed to lookup signal {hash} at {cursor:?}",
|
||||||
|
file!(),
|
||||||
|
line!()
|
||||||
|
)
|
||||||
|
})?;
|
||||||
|
|
||||||
// u8_timeline_markers.push(timeline_idx);
|
let signal = vcd.try_dereference_alias_mut(signal_idx)?;
|
||||||
// u8_timeline.push(0u8);
|
|
||||||
// Ok(())
|
|
||||||
// }
|
|
||||||
// Signal::Alias { .. } => {
|
|
||||||
// let (f, l) = (file!(), line!());
|
|
||||||
// let msg = format!(
|
|
||||||
// "Error near {f}:{l}, a signal alias should not point to a signal alias.\n\
|
|
||||||
// This error occurred while parsing vcd file at {cursor:?}");
|
|
||||||
// Err(msg)
|
|
||||||
// }
|
|
||||||
// }?;
|
|
||||||
// }
|
|
||||||
|
|
||||||
// "1" => {
|
match signal {
|
||||||
// // lokup signal idx
|
Signal::Data {
|
||||||
// let hash = &word[1..];
|
name,
|
||||||
// let SignalIdx(ref signal_idx) = signal_map.get(hash).ok_or(()).map_err(|_| {
|
sig_type,
|
||||||
// format!(
|
ref mut signal_error,
|
||||||
// "Error near {}:{}. Failed to lookup signal {hash} at {cursor:?}",
|
num_bits,
|
||||||
// file!(),
|
self_idx,
|
||||||
// line!()
|
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,
|
||||||
|
} => {
|
||||||
|
// if this is a bad signal, go ahead and skip it
|
||||||
|
if signal_error.is_some() {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
// // account for fact that signal idx could be an alias, so there
|
// Get bitwidth and verify that it is 1.
|
||||||
// // could be one step of indirection
|
// Also account for the error case of a bitwidth of `None`
|
||||||
// let signal_idx = {
|
match num_bits {
|
||||||
// let signal = vcd.all_signals.get(*signal_idx).unwrap();
|
Some(ref num_bits) => {
|
||||||
// match signal {
|
if *num_bits != 1 {
|
||||||
// Signal::Data { .. } => *signal_idx,
|
let (f, l) = (file!(), line!());
|
||||||
// Signal::Alias { signal_alias, .. } => {
|
let msg = format!(
|
||||||
// let SignalIdx(ref signal_idx) = signal_alias;
|
"\
|
||||||
// signal_idx.clone()
|
Error near {f}:{l}. The bitwidth for signal {name} \
|
||||||
// }
|
of sig_type {sig_type:?} is expected to be `1` not \
|
||||||
// }
|
`{num_bits}`. \
|
||||||
// };
|
This error occurred while parsing the vcd file at \
|
||||||
|
{cursor:?}"
|
||||||
|
);
|
||||||
|
*signal_error = Some(msg);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
None => {
|
||||||
|
let (f, l) = (file!(), line!());
|
||||||
|
let msg = format!(
|
||||||
|
"\
|
||||||
|
Error near {f}:{l}. The bitwidth for signal {name} \
|
||||||
|
must be specified for a signal of type {sig_type:?}. \
|
||||||
|
This error occurred while parsing the vcd file at \
|
||||||
|
{cursor:?}"
|
||||||
|
);
|
||||||
|
Err(msg)?;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
nums_encoded_as_fixed_width_le_u8.push(1u8);
|
||||||
|
lsb_indxs_of_num_tmstmp_vals_on_tmln
|
||||||
|
.push(LsbIdxOfTmstmpValOnTmln(curr_tmstmp_lsb_idx));
|
||||||
|
byte_len_of_num_tmstmp_vals_on_tmln.push(1u8);
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
Signal::Alias { .. } => {
|
||||||
|
let (f, l) = (file!(), line!());
|
||||||
|
let msg = format!(
|
||||||
|
"Error near {f}:{l}, a signal alias should not point to a signal alias.\n\
|
||||||
|
This error occurred while parsing vcd file at {cursor:?}");
|
||||||
|
Err(msg)
|
||||||
|
}
|
||||||
|
}?;
|
||||||
|
}
|
||||||
|
|
||||||
// // after handling potential indirection, go ahead and update the timeline
|
// other one bit cases
|
||||||
// // of the signal signal_idx references
|
"x" | "X" | "z" | "Z" | "u" | "U" => {
|
||||||
// let signal = vcd.all_signals.get_mut(signal_idx).unwrap();
|
let val = word.to_string();
|
||||||
// match signal {
|
// lokup signal idx
|
||||||
// Signal::Data {
|
let hash = &word[1..];
|
||||||
// name,
|
let signal_idx = signal_map.get(hash).ok_or(()).map_err(|_| {
|
||||||
// sig_type,
|
format!(
|
||||||
// ref mut signal_error,
|
"Error near {}:{}. Failed to lookup signal {hash} at {cursor:?}",
|
||||||
// num_bits,
|
file!(),
|
||||||
// u8_timeline,
|
line!()
|
||||||
// u8_timeline_markers,
|
)
|
||||||
// ..
|
})?;
|
||||||
// } => {
|
|
||||||
// // if this is a bad signal, go ahead and skip it
|
|
||||||
// if signal_error.is_some() {
|
|
||||||
// continue;
|
|
||||||
// }
|
|
||||||
|
|
||||||
// // Get bitwidth and verify that it is 1.
|
let signal = vcd.try_dereference_alias_mut(signal_idx)?;
|
||||||
// // Also account for the error case of a bitwidth of `None`
|
|
||||||
// match num_bits {
|
|
||||||
// Some(ref num_bits) => {
|
|
||||||
// if *num_bits != 1 {
|
|
||||||
// let (f, l) = (file!(), line!());
|
|
||||||
// let msg = format!(
|
|
||||||
// "\
|
|
||||||
// Error near {f}:{l}. The bitwidth for signal {name} \
|
|
||||||
// of sig_type {sig_type:?} is expected to be `1` not \
|
|
||||||
// `{num_bits}`. \
|
|
||||||
// This error occurred while parsing the vcd file at \
|
|
||||||
// {cursor:?}"
|
|
||||||
// );
|
|
||||||
// *signal_error = Some(msg);
|
|
||||||
// continue;
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// None => {
|
|
||||||
// let (f, l) = (file!(), line!());
|
|
||||||
// let msg = format!(
|
|
||||||
// "\
|
|
||||||
// Error near {f}:{l}. The bitwidth for signal {name} \
|
|
||||||
// must be specified for a signal of type {sig_type:?}. \
|
|
||||||
// This error occurred while parsing the vcd file at \
|
|
||||||
// {cursor:?}"
|
|
||||||
// );
|
|
||||||
// Err(msg)?;
|
|
||||||
// }
|
|
||||||
// };
|
|
||||||
|
|
||||||
// let (f, l) = (file!(), line!());
|
match signal {
|
||||||
// let timeline_idx = u32::try_from(vcd.tmstmps_encoded_as_u8s.len())
|
Signal::Data {
|
||||||
// .map_err(|_| {
|
name,
|
||||||
// format!("Error near {f}:{l}. Failed to convert from usize to u32.")
|
sig_type,
|
||||||
// })?;
|
ref mut signal_error,
|
||||||
// let timeline_idx = TimelineIdx(timeline_idx);
|
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,
|
||||||
|
} => {
|
||||||
|
// if this is a bad signal, go ahead and skip it
|
||||||
|
if signal_error.is_some() {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
// u8_timeline_markers.push(timeline_idx);
|
// Get bitwidth and verify that it is 1.
|
||||||
// u8_timeline.push(1u8);
|
// Also account for the error case of a bitwidth of `None`
|
||||||
// Ok(())
|
match num_bits {
|
||||||
// }
|
Some(ref num_bits) => {
|
||||||
// Signal::Alias { .. } => {
|
if *num_bits != 1 {
|
||||||
// let (f, l) = (file!(), line!());
|
let (f, l) = (file!(), line!());
|
||||||
// let msg = format!(
|
let msg = format!(
|
||||||
// "Error near {f}:{l}, a signal alias should not point to a signal alias.\n\
|
"\
|
||||||
// This error occurred while parsing vcd file at {cursor:?}");
|
Error near {f}:{l}. The bitwidth for signal {name} \
|
||||||
// Err(msg)
|
of sig_type {sig_type:?} is expected to be `1` not \
|
||||||
// }
|
`{num_bits}`. \
|
||||||
// }?;
|
This error occurred while parsing the vcd file at \
|
||||||
// }
|
{cursor:?}"
|
||||||
// // other one bit cases
|
);
|
||||||
// "x" | "X" | "z" | "Z" | "u" | "U" => {
|
*signal_error = Some(msg);
|
||||||
// let val = word.to_string();
|
continue;
|
||||||
// // lokup signal idx
|
}
|
||||||
// let hash = &word[1..];
|
}
|
||||||
// let SignalIdx(ref signal_idx) = signal_map.get(hash).ok_or(()).map_err(|_| {
|
None => {
|
||||||
// format!(
|
let (f, l) = (file!(), line!());
|
||||||
// "Error near {}:{}. Failed to lookup signal {hash} at {cursor:?}",
|
let msg = format!(
|
||||||
// file!(),
|
"\
|
||||||
// line!()
|
Error near {f}:{l}. The bitwidth for signal {name} \
|
||||||
// )
|
must be specified for a signal of type {sig_type:?}. \
|
||||||
// })?;
|
This error occurred while parsing the vcd file at \
|
||||||
|
{cursor:?}"
|
||||||
// // account for fact that signal idx could be an alias, so there
|
);
|
||||||
// // could be one step of indirection
|
Err(msg)?;
|
||||||
// let signal_idx = {
|
}
|
||||||
// let signal = vcd.all_signals.get(*signal_idx).unwrap();
|
};
|
||||||
// match signal {
|
string_vals.push(val);
|
||||||
// Signal::Data { .. } => *signal_idx,
|
lsb_indxs_of_string_tmstmp_vals_on_tmln
|
||||||
// Signal::Alias { signal_alias, .. } => {
|
.push(LsbIdxOfTmstmpValOnTmln(curr_tmstmp_lsb_idx));
|
||||||
// let SignalIdx(ref signal_idx) = signal_alias;
|
Ok(())
|
||||||
// signal_idx.clone()
|
}
|
||||||
// }
|
Signal::Alias { .. } => {
|
||||||
// }
|
let (f, l) = (file!(), line!());
|
||||||
// };
|
let msg = format!(
|
||||||
|
"Error near {f}:{l}, a signal alias should not point to a signal alias.\n\
|
||||||
// // after handling potential indirection, go ahead and update the timeline
|
This error occurred while parsing vcd file at {cursor:?}");
|
||||||
// // of the signal signal_idx references
|
Err(msg)
|
||||||
// let signal = vcd.all_signals.get_mut(signal_idx).unwrap();
|
}
|
||||||
// match signal {
|
}?;
|
||||||
// Signal::Data {
|
}
|
||||||
// name,
|
|
||||||
// sig_type,
|
|
||||||
// ref mut signal_error,
|
|
||||||
// num_bits,
|
|
||||||
// string_timeline,
|
|
||||||
// string_timeline_markers,
|
|
||||||
// ..
|
|
||||||
// } => {
|
|
||||||
// // if this is a bad signal, go ahead and skip it
|
|
||||||
// if signal_error.is_some() {
|
|
||||||
// continue;
|
|
||||||
// }
|
|
||||||
|
|
||||||
// // Get bitwidth and verify that it is 1.
|
|
||||||
// // Also account for the error case of a bitwidth of `None`
|
|
||||||
// match num_bits {
|
|
||||||
// Some(ref num_bits) => {
|
|
||||||
// if *num_bits != 1 {
|
|
||||||
// let (f, l) = (file!(), line!());
|
|
||||||
// let msg = format!(
|
|
||||||
// "\
|
|
||||||
// Error near {f}:{l}. The bitwidth for signal {name} \
|
|
||||||
// of sig_type {sig_type:?} is expected to be `1` not \
|
|
||||||
// `{num_bits}`. \
|
|
||||||
// This error occurred while parsing the vcd file at \
|
|
||||||
// {cursor:?}"
|
|
||||||
// );
|
|
||||||
// *signal_error = Some(msg);
|
|
||||||
// continue;
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// None => {
|
|
||||||
// let (f, l) = (file!(), line!());
|
|
||||||
// let msg = format!(
|
|
||||||
// "\
|
|
||||||
// Error near {f}:{l}. The bitwidth for signal {name} \
|
|
||||||
// must be specified for a signal of type {sig_type:?}. \
|
|
||||||
// This error occurred while parsing the vcd file at \
|
|
||||||
// {cursor:?}"
|
|
||||||
// );
|
|
||||||
// Err(msg)?;
|
|
||||||
// }
|
|
||||||
// };
|
|
||||||
|
|
||||||
// let (f, l) = (file!(), line!());
|
|
||||||
// let timeline_idx = u32::try_from(vcd.tmstmps_encoded_as_u8s.len())
|
|
||||||
// .map_err(|_| {
|
|
||||||
// format!("Error near {f}:{l}. Failed to convert from usize to u32.")
|
|
||||||
// })?;
|
|
||||||
// let timeline_idx = TimelineIdx(timeline_idx);
|
|
||||||
|
|
||||||
// string_timeline_markers.push(timeline_idx);
|
|
||||||
// string_timeline.push(val);
|
|
||||||
// Ok(())
|
|
||||||
// }
|
|
||||||
// Signal::Alias { .. } => {
|
|
||||||
// let (f, l) = (file!(), line!());
|
|
||||||
// let msg = format!(
|
|
||||||
// "Error near {f}:{l}, a signal alias should not point to a signal alias.\n\
|
|
||||||
// This error occurred while parsing vcd file at {cursor:?}");
|
|
||||||
// Err(msg)
|
|
||||||
// }
|
|
||||||
// }?;
|
|
||||||
// }
|
|
||||||
_ => {}
|
_ => {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue