fix some errors/typos and prep for refactoring
This commit is contained in:
parent
d5db622db3
commit
6abcd7ce32
|
@ -6,8 +6,6 @@ use std::fs::File;
|
||||||
|
|
||||||
use fastwave_backend::*;
|
use fastwave_backend::*;
|
||||||
|
|
||||||
use num::{BigUint};
|
|
||||||
|
|
||||||
fn indented_print(indent : u8, name : &String) {
|
fn indented_print(indent : u8, name : &String) {
|
||||||
for _ in 0..indent {print!(" |");}
|
for _ in 0..indent {print!(" |");}
|
||||||
print!("---");
|
print!("---");
|
||||||
|
@ -19,7 +17,15 @@ fn print_root_scope_tree(root_idx: ScopeIdx, vcd: &VCD, indent : u8) {
|
||||||
} else {
|
} else {
|
||||||
for child_scope_idx in vcd.child_scopes_by_idx(root_idx) {
|
for child_scope_idx in vcd.child_scopes_by_idx(root_idx) {
|
||||||
indented_print(indent, vcd.scope_name_by_idx(child_scope_idx));
|
indented_print(indent, vcd.scope_name_by_idx(child_scope_idx));
|
||||||
let ScopeIdx(idx) = child_scope_idx;
|
// for signal_idx in vcd.get_children_signal_idxs(child_scope_idx) {
|
||||||
|
// let signal = vcd.try_signal_idx_to_signal(signal_idx).unwrap();
|
||||||
|
// match signal {
|
||||||
|
// Signal::Data {..} => {}
|
||||||
|
// Signal::Alias {..} => {}
|
||||||
|
// }
|
||||||
|
// // let to_print = format!("{},{}", signal.name(), )
|
||||||
|
// }
|
||||||
|
// vcd.try_signal_idx_to_signal(idx)
|
||||||
print_root_scope_tree(child_scope_idx, vcd.clone(), indent + 1);
|
print_root_scope_tree(child_scope_idx, vcd.clone(), indent + 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -47,7 +53,11 @@ fn main() -> std::io::Result<()> {
|
||||||
ui_all_scopes(&vcd);
|
ui_all_scopes(&vcd);
|
||||||
|
|
||||||
|
|
||||||
// let state_signal = vcd.
|
let file_path = "tests/vcd-files/amaranth/up_counter.vcd";
|
||||||
|
let file = File::open(file_path)?;
|
||||||
|
let vcd = parse_vcd(file).unwrap();
|
||||||
|
// let state_signal = vcd.all_si
|
||||||
|
// for signal_idx in vcd.si
|
||||||
// let name = state_signal.name();
|
// let name = state_signal.name();
|
||||||
// let time = BigUint::from(57760000u32);
|
// let time = BigUint::from(57760000u32);
|
||||||
// let val = state_signal
|
// let val = state_signal
|
||||||
|
|
|
@ -2,7 +2,6 @@
|
||||||
// This program is distributed under both the GPLV3 license
|
// This program is distributed under both the GPLV3 license
|
||||||
// and the YEHOWSHUA license, both of which can be found at
|
// and the YEHOWSHUA license, both of which can be found at
|
||||||
// the root of the folder containing the sources for this program.
|
// the root of the folder containing the sources for this program.
|
||||||
use num::Zero;
|
|
||||||
|
|
||||||
use super::*;
|
use super::*;
|
||||||
|
|
||||||
|
@ -13,7 +12,6 @@ pub(super) fn parse_events<'a>(
|
||||||
) -> Result<(), String> {
|
) -> Result<(), String> {
|
||||||
let mut curr_tmstmp_lsb_idx = 0u32;
|
let mut curr_tmstmp_lsb_idx = 0u32;
|
||||||
let mut curr_tmstmp_len_u8 = 0u8;
|
let mut curr_tmstmp_len_u8 = 0u8;
|
||||||
let mut curr_time = BigUint::zero();
|
|
||||||
loop {
|
loop {
|
||||||
let next_word = word_reader.next_word();
|
let next_word = word_reader.next_word();
|
||||||
|
|
||||||
|
@ -42,7 +40,6 @@ pub(super) fn parse_events<'a>(
|
||||||
"Error near {f}:{l}. Failed to parse {value} as BigInt at {cursor:?}"
|
"Error near {f}:{l}. Failed to parse {value} as BigInt at {cursor:?}"
|
||||||
)
|
)
|
||||||
})?;
|
})?;
|
||||||
curr_time = value.clone();
|
|
||||||
let mut value = value.to_bytes_le();
|
let mut value = value.to_bytes_le();
|
||||||
// TODO : u32 helps with less memory, but should ideally likely be
|
// TODO : u32 helps with less memory, but should ideally likely be
|
||||||
// configurable.
|
// configurable.
|
||||||
|
@ -422,7 +419,6 @@ pub(super) fn parse_events<'a>(
|
||||||
ref mut signal_error,
|
ref mut signal_error,
|
||||||
num_bits,
|
num_bits,
|
||||||
string_vals,
|
string_vals,
|
||||||
byte_len_of_num_tmstmp_vals_on_tmln,
|
|
||||||
byte_len_of_string_tmstmp_vals_on_tmln,
|
byte_len_of_string_tmstmp_vals_on_tmln,
|
||||||
lsb_indxs_of_string_tmstmp_vals_on_tmln,
|
lsb_indxs_of_string_tmstmp_vals_on_tmln,
|
||||||
..
|
..
|
||||||
|
@ -497,12 +493,8 @@ pub(super) fn parse_events<'a>(
|
||||||
|
|
||||||
match signal {
|
match signal {
|
||||||
Signal::Data {
|
Signal::Data {
|
||||||
name,
|
|
||||||
sig_type,
|
|
||||||
ref mut signal_error,
|
ref mut signal_error,
|
||||||
num_bits,
|
|
||||||
string_vals,
|
string_vals,
|
||||||
byte_len_of_num_tmstmp_vals_on_tmln,
|
|
||||||
byte_len_of_string_tmstmp_vals_on_tmln,
|
byte_len_of_string_tmstmp_vals_on_tmln,
|
||||||
lsb_indxs_of_string_tmstmp_vals_on_tmln,
|
lsb_indxs_of_string_tmstmp_vals_on_tmln,
|
||||||
..
|
..
|
||||||
|
|
|
@ -28,6 +28,7 @@ pub(super) enum TimelineQueryResults {
|
||||||
String(String),
|
String(String),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub enum Signal {
|
pub enum Signal {
|
||||||
Data {
|
Data {
|
||||||
|
@ -100,18 +101,6 @@ type SignalValNum = BigUint;
|
||||||
|
|
||||||
// getter functions
|
// getter functions
|
||||||
impl Signal {
|
impl Signal {
|
||||||
pub fn self_idx(&self) -> Result<SignalIdx, String> {
|
|
||||||
match self {
|
|
||||||
Signal::Data { self_idx, ..} => {return Ok(self_idx.clone())},
|
|
||||||
Signal::Alias { .. } => Err(format!(
|
|
||||||
"Error near {}:{}. A signal alias shouldn't \
|
|
||||||
point to a signal alias.",
|
|
||||||
file!(),
|
|
||||||
line!()
|
|
||||||
)),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn name(&self) -> String {
|
pub fn name(&self) -> String {
|
||||||
match self {
|
match self {
|
||||||
Signal::Data { name, ..} => name,
|
Signal::Data { name, ..} => name,
|
||||||
|
|
|
@ -72,6 +72,11 @@ impl VCD {
|
||||||
let scope = &self.all_scopes[idx];
|
let scope = &self.all_scopes[idx];
|
||||||
scope.child_scopes.clone()
|
scope.child_scopes.clone()
|
||||||
}
|
}
|
||||||
|
pub fn get_children_signal_idxs(&self, scope_idx: ScopeIdx) -> Vec<SignalIdx> {
|
||||||
|
let ScopeIdx(idx) = scope_idx;
|
||||||
|
let scope = &self.all_scopes[idx];
|
||||||
|
scope.child_signals.clone()
|
||||||
|
}
|
||||||
pub fn scope_name_by_idx(&self, scope_idx: ScopeIdx) -> &String {
|
pub fn scope_name_by_idx(&self, scope_idx: ScopeIdx) -> &String {
|
||||||
let ScopeIdx(idx) = scope_idx;
|
let ScopeIdx(idx) = scope_idx;
|
||||||
let scope = &self.all_scopes[idx];
|
let scope = &self.all_scopes[idx];
|
||||||
|
@ -109,40 +114,20 @@ impl VCD {
|
||||||
)),
|
)),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
pub(super) fn dealiasing_signal_idx_to_signal_lookup<'a>(
|
/// Takes a signal_idx as input and returns the corresponding signal if the
|
||||||
&'a self,
|
/// corresponding signal is of the Signal::Data variant, else the function the
|
||||||
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 { 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!()
|
|
||||||
)),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
/// Takes a signal as input and returns the signal if the signal is of the
|
|
||||||
/// Signal::Data variant, else the function follows follows the uses the
|
|
||||||
/// SignalIdx in the signal_alias field of Signal::Alias variant to index
|
/// SignalIdx in the signal_alias field of Signal::Alias variant to index
|
||||||
/// into the signal arena in the all_signals field of the vcd, and returns
|
/// into the signal arena in the all_signals field of the vcd, and returns
|
||||||
/// the resulting signal if that signal is a Signal::Data variant, else,
|
/// the resulting signal if that signal is a Signal::Data variant, else,
|
||||||
/// this function returns an Err.
|
/// this function returns an Err.
|
||||||
pub fn dealiasing_signal_lookup<'a>(&'a self, signal: &Signal) -> Result<&'a Signal, String> {
|
pub fn try_signal_idx_to_signal<'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
|
// dereference signal if Signal::Alias, or keep idx if Signal::Data
|
||||||
let signal_idx = match signal {
|
let signal_idx = match signal {
|
||||||
Signal::Data { self_idx, .. } => *self_idx,
|
Signal::Data { self_idx, .. } => *self_idx,
|
||||||
|
|
Loading…
Reference in a new issue