getting started on parsing timeline events
This commit is contained in:
parent
932250e416
commit
24622c71c2
4 changed files with 44 additions and 5 deletions
|
@ -1,5 +1,7 @@
|
|||
use std::{fs::File};
|
||||
use std::collections::{BTreeMap, HashMap};
|
||||
use std::collections::HashMap;
|
||||
use num::BigInt;
|
||||
use num::bigint::ToBigInt;
|
||||
|
||||
use super::*;
|
||||
|
||||
|
@ -15,6 +17,32 @@ use metadata::*;
|
|||
mod scopes;
|
||||
use scopes::*;
|
||||
|
||||
use function_name::named;
|
||||
|
||||
#[named]
|
||||
fn parse_events<'a>(
|
||||
word_reader : &mut WordReader,
|
||||
vcd : &'a mut VCD,
|
||||
signal_map : &mut HashMap<String, Signal_Idx>
|
||||
) -> Result<(), String> {
|
||||
|
||||
loop {
|
||||
let next_word = word_reader.next_word();
|
||||
// if we've reached the end of the file, then there is obviously
|
||||
// nothing left to do...
|
||||
if next_word.is_none() {break};
|
||||
|
||||
let (word, cursor) = next_word.unwrap();
|
||||
match &word[0..1] {
|
||||
"$" => {continue}
|
||||
"#" => {continue}
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub fn parse_vcd(file : File) -> Result<VCD, String> {
|
||||
let mut word_gen = WordReader::new(file);
|
||||
|
||||
|
@ -24,12 +52,14 @@ pub fn parse_vcd(file : File) -> Result<VCD, String> {
|
|||
|
||||
let mut vcd = VCD{
|
||||
metadata : header,
|
||||
cursor : 0.to_bigint().unwrap(),
|
||||
all_signals: vec![],
|
||||
all_scopes : vec![],
|
||||
scope_roots: vec![],
|
||||
};
|
||||
|
||||
parse_scopes(&mut word_gen, None, &mut vcd, &mut signal_map)?;
|
||||
// parse_events(&mut word_gen, &mut vcd, &mut signal_map)?;
|
||||
|
||||
Ok(vcd)
|
||||
}
|
||||
|
|
|
@ -84,7 +84,7 @@ pub(super) fn parse_var<'a>(
|
|||
sig_type: var_type,
|
||||
num_bits: no_bits,
|
||||
self_idx: signal_idx,
|
||||
timeline: BTreeMap::new(),
|
||||
timeline: vec![],
|
||||
scope_parent: parent_scope_idx };
|
||||
(signal, signal_idx)
|
||||
}
|
||||
|
|
|
@ -23,6 +23,9 @@ pub(super) struct Signal_Idx(pub(super) usize);
|
|||
#[derive(Debug)]
|
||||
pub(super) enum Sig_Type {Integer, Parameter, Real, Reg, Str, Wire, Tri1, Time}
|
||||
|
||||
#[derive(Debug)]
|
||||
pub(super) struct TimeStamp(BigInt);
|
||||
|
||||
#[derive(Debug)]
|
||||
pub(super) enum Sig_Value {
|
||||
Numeric(BigInt),
|
||||
|
@ -36,7 +39,7 @@ pub(super) enum Signal{
|
|||
num_bits : Option<usize>,
|
||||
// TODO : may be able to remove self_idx
|
||||
self_idx : Signal_Idx,
|
||||
timeline : BTreeMap<BigInt, Sig_Value>,
|
||||
timeline : Vec<(TimeStamp, Sig_Value)>,
|
||||
scope_parent : Scope_Idx},
|
||||
Alias{
|
||||
name : String,
|
||||
|
@ -58,6 +61,7 @@ pub(super) struct Scope {
|
|||
#[derive(Debug)]
|
||||
pub struct VCD {
|
||||
pub(super) metadata : Metadata,
|
||||
pub(super) cursor : BigInt,
|
||||
pub(super) all_signals : Vec<Signal>,
|
||||
pub(super) all_scopes : Vec<Scope>,
|
||||
pub(super) scope_roots : Vec<Scope_Idx>}
|
||||
|
|
Reference in a new issue