New parser #2

Merged
ThePerfectComputer merged 51 commits from new_parser into main 2022-08-01 21:00:00 +00:00
4 changed files with 44 additions and 5 deletions
Showing only changes of commit 24622c71c2 - Show all commits

View file

@ -8,7 +8,7 @@ PROPRIETARY - Copyright - Yehowshua Immanuel
- loads 400MB of VCD waveform per second on an 8 core 2017 desktop CPU with NVMe storage
- consumes roughly between 10 - 50MB of memory per GB of waveform
## Planed Features
## Planned Features
- elegant/pretty UI
- can be easily ported to work in browser via webassembly
- allows high-performance custom Rust plugins to manipulate and
@ -27,7 +27,8 @@ The first build of the program may take some time.
You can run all the tests with ``cargo test``
# TODO
- [ ] support parsing dates with commas
- [ ] make a custon date parser for possibly up to 18 different versions(that
is, for each possible tool).
- [ ] Fix warning especially usage and restriction warnings once I'm
able to successfully parse all sample VCDs.
- [ ] Should be able to load waveform whilst viewing it live.
@ -40,5 +41,9 @@ You can run all the tests with ``cargo test``
- [ ] Take a look at GTKWave parser to compare effificiency.
- [ ] Send survey to community channel.
# Questions to Answer
- [ ] Is it safe to assume that we may treat any values before the first
non-zero timestamp as having occured on `#0`?
# Probably No Longer Needed
- [ ] Should insert nodes in BFS order

View file

@ -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)
}

View file

@ -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)
}

View file

@ -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>}