Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Non stream mode required #17

Open
raczben opened this issue Aug 11, 2020 · 5 comments
Open

Non stream mode required #17

raczben opened this issue Aug 11, 2020 · 5 comments

Comments

@raczben
Copy link

raczben commented Aug 11, 2020

I like this stream reader behavior, but it is overkill when the whole file is available. I just want a method, which gives back the fully parsed file, with all of the value changes.

I need a similar behavior to this, (just, that has some bug...)

@drom
Copy link
Member

drom commented Aug 17, 2020

You can totally feed this parser with a single chunk. That will make it non-streaming.
Example: https://github.com/wavedrom/vcd/blob/master/test/basic.js#L44
About ALL value changes. How would you imagine the result data structure that you want to see?

@raczben
Copy link
Author

raczben commented Aug 18, 2020

That example does not checks the value changes...

Let's see this example:

'use strict';

const vcd = require('vcd-stream');

const inst = vcd.parser();
inst.on("$enddefinitions", () => {
console.log(inst.info.wires)
// {
  // top: { clock: '"}G', leaf: { counter: '{u' }, fruit: { point: 'u)' } }
// }

});

inst.change.on('"}G', (time, cmd) => {
    console.log(`change: "}G  @${time}  cmd: ${cmd}`)  // < < < < < < What is the meaning of cmd?
});
inst.change.on('u)', (time, cmd) => {
    console.log(`change: u)  @${time}  cmd: ${cmd}`)
});
inst.change.on('{u', (time, cmd) => {
    console.log(`change: {u  @${time}  cmd: ${cmd}`)
});

inst.write(`
$version Generated by VerilatedVcd $end
$date Wed Sep 18 22:59:07 2019
 $end
$timescale   1ns $end

  $scope   module   top    $end
    $var wire  1 "}G clock $end
    $scope module leaf $end
      $var wire 64 {u counter [63:0] $end
    $upscope $end
    $scope module fruit $end
      $var wire 4 u) point [3:0] $end
    $upscope $end
  $upscope $end

  $enddefinitions $end
`
);

inst.write(`
#1
0"}G
#2
1"}G
#300
0"}G
b1111000000000000 {u
#301
b0000111100000000 {u
#302
b0000000011110000 {u
#303
b0000000000001111 {u
`
);

This prints out:

{
  top: { clock: '"}G', leaf: { counter: '{u' }, fruit: { point: 'u)' } }
}
change: "}G  @1  cmd: 14
change: "}G  @2  cmd: 15
change: "}G  @300  cmd: 14
change: {u  @300  cmd: 19
change: {u  @301  cmd: 19
change: {u  @302  cmd: 19
change: {u  @303  cmd: 19

What is the meaning of cmd?
Where is the new value?

@drom
Copy link
Member

drom commented Sep 13, 2020

cmd is enum: https://github.com/wavedrom/vcd/blob/master/bin/build.js#L87

{
  14: 0,
  15: 1,
  19: binary string starts with `b`
}

@drom
Copy link
Member

drom commented Sep 13, 2020

I like this stream reader behavior, but it is overkill when the whole file is available. I just want a method, which gives back the fully parsed file, with all of the value changes.

I need a similar behavior to this, (just, that has some bug...)

The format from from ahmed-agiza/vcd-parser is very verbose and will eat all memory very quickly. Maybe we should come up with a better format?

@drom
Copy link
Member

drom commented Sep 13, 2020

I think we have to discuss the format of the data on cmd=19, 20 here #16

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants