recovery from broken VCD
This commit is contained in:
parent
8aea87dec5
commit
b8d2f2ec1f
45
bin/build.js
45
bin/build.js
@ -43,6 +43,9 @@ const properties = {
|
||||
napi_env: 'ptr'
|
||||
};
|
||||
|
||||
const spaces = [' ', '\n', '\r', '\t'];
|
||||
const lineSpaces = [' ', '\t'];
|
||||
|
||||
const generate = (cb) => {
|
||||
// const llparseDot = require('llparse-dot');
|
||||
|
||||
@ -79,7 +82,7 @@ const generate = (cb) => {
|
||||
simulation,
|
||||
inSimulation,
|
||||
simulationTime,
|
||||
simulationVector, simulationVectorEnd,
|
||||
simulationVector, simulationVectorEnd, simulationVectorRecovery,
|
||||
simulationId
|
||||
} = `
|
||||
declaration
|
||||
@ -93,7 +96,7 @@ const generate = (cb) => {
|
||||
simulation
|
||||
inSimulation
|
||||
simulationTime
|
||||
simulationVector simulationVectorEnd
|
||||
simulationVector simulationVectorEnd simulationVectorRecovery
|
||||
simulationId
|
||||
`
|
||||
.trim().split(/\s+/)
|
||||
@ -101,8 +104,6 @@ const generate = (cb) => {
|
||||
|
||||
const enddefinitions = p.node('inDeclarationEnd');
|
||||
|
||||
const spaces = [' ', '\n', '\r', '\t'];
|
||||
|
||||
const cmd = objection({
|
||||
$comment: 1,
|
||||
$date: 2,
|
||||
@ -147,7 +148,22 @@ const generate = (cb) => {
|
||||
.otherwise(scopeTypeEnd);
|
||||
|
||||
scopeTypeEnd
|
||||
.select({begin: 1, fork: 2, function: 3, module: 4, task: 5},
|
||||
.select(
|
||||
{
|
||||
module: 0,
|
||||
task: 1,
|
||||
function: 2,
|
||||
begin: 3,
|
||||
fork: 4,
|
||||
// extra scopes from Verilator
|
||||
generate: 5,
|
||||
struct: 6,
|
||||
union: 7,
|
||||
class: 8,
|
||||
interface: 9,
|
||||
package: 10,
|
||||
program: 11
|
||||
},
|
||||
p.invoke(p.code.store('type'), scopeIdentifier))
|
||||
.otherwise(p.error(2, 'Expected scope type'));
|
||||
|
||||
@ -258,15 +274,28 @@ const generate = (cb) => {
|
||||
p.invoke(
|
||||
// p.code.mulAdd('value', {base: 2, signed: false}),
|
||||
p.code.value('onDigit'),
|
||||
{1: p.error(1, 'Content-Length overflow')},
|
||||
{1: p.error(5, 'Content-Length overflow')},
|
||||
simulationVector
|
||||
)
|
||||
)
|
||||
.otherwise(simulationVectorEnd);
|
||||
|
||||
simulationVectorEnd
|
||||
.match(spaces, idSpan.start(simulationId))
|
||||
.skipTo(simulationVectorEnd);
|
||||
.match(lineSpaces, idSpan.start(simulationId))
|
||||
.skipTo(simulationVectorRecovery);
|
||||
|
||||
simulationVectorRecovery
|
||||
.select(
|
||||
{
|
||||
'\n': 1, '\r': 1
|
||||
},
|
||||
p.invoke(
|
||||
p.code.value('onRecover'),
|
||||
{1: p.error(6, 'recover')},
|
||||
simulation
|
||||
)
|
||||
)
|
||||
.skipTo(simulationVectorRecovery);
|
||||
|
||||
simulationId
|
||||
.match(spaces, idSpan.end(simulation))
|
||||
|
BIN
out/vcd.wasm
BIN
out/vcd.wasm
Binary file not shown.
@ -1,12 +1,12 @@
|
||||
'use strict';
|
||||
|
||||
const expect = require('chai').expect;
|
||||
const lib = require('../lib/index.js');
|
||||
const parser = require('../lib/parser.js');
|
||||
|
||||
describe('any', () => {
|
||||
|
||||
it('simple', done => {
|
||||
const inst = lib.parser();
|
||||
const inst = parser();
|
||||
const dump = [];
|
||||
inst.change.any((id, time, cmd, value, mask) => {
|
||||
dump.push({
|
||||
@ -46,6 +46,7 @@ $enddefinitions $end
|
||||
0XyZ
|
||||
#400
|
||||
b1010101010101010101010101010101010101010101010101010101010101010 64b
|
||||
b0001010101010xx010101000000ggg
|
||||
b10101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010 128b
|
||||
b1010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010 256b
|
||||
b10101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010 512b
|
||||
|
@ -1,22 +1,22 @@
|
||||
'use strict';
|
||||
|
||||
const expect = require('chai').expect;
|
||||
const lib = require('../lib/index.js');
|
||||
const parser = require('../lib/parser.js');
|
||||
|
||||
describe('basic', () => {
|
||||
|
||||
it('typeof vcd', done => {
|
||||
expect(lib.parser).to.be.an('function');
|
||||
expect(parser).to.be.an('function');
|
||||
done();
|
||||
});
|
||||
|
||||
it('typeof vcd instance', done => {
|
||||
expect(lib.parser()).to.be.an('object');
|
||||
expect(parser()).to.be.an('object');
|
||||
done();
|
||||
});
|
||||
|
||||
it('fail: foo bar', done => {
|
||||
const inst = lib.parser();
|
||||
const inst = parser();
|
||||
expect(inst.write(Buffer.from(' foo bar ???'))).to.eq(true);
|
||||
expect(inst.info).to.deep.eq({
|
||||
stack: [{}],
|
||||
@ -27,7 +27,7 @@ describe('basic', () => {
|
||||
});
|
||||
|
||||
it('$comment', done => {
|
||||
const inst = lib.parser();
|
||||
const inst = parser();
|
||||
expect(inst.write(Buffer.from(
|
||||
' \n $comment some text $end $comment more text $end ???'
|
||||
))).to.eq(true);
|
||||
@ -41,7 +41,7 @@ describe('basic', () => {
|
||||
});
|
||||
|
||||
it('$version', done => {
|
||||
const inst = lib.parser();
|
||||
const inst = parser();
|
||||
expect(inst.write(`
|
||||
$version Generated by VerilatedVcd $end
|
||||
$date Wed Sep 18 22:59:07 2019
|
||||
|
@ -1,12 +1,12 @@
|
||||
'use strict';
|
||||
|
||||
const expect = require('chai').expect;
|
||||
const lib = require('../lib/index.js');
|
||||
const parser = require('../lib/parser.js');
|
||||
|
||||
describe('dump', () => {
|
||||
|
||||
it('simple', done => {
|
||||
const inst = lib.parser();
|
||||
const inst = parser();
|
||||
const dump = [];
|
||||
['"}G', '{u', 'u)'] // array of all signal ids
|
||||
.map(id =>
|
||||
|
@ -1,12 +1,12 @@
|
||||
'use strict';
|
||||
|
||||
const expect = require('chai').expect;
|
||||
const lib = require('../lib/index.js');
|
||||
const parser = require('../lib/parser.js');
|
||||
|
||||
describe('events', () => {
|
||||
|
||||
it('$enddefinitions', done => {
|
||||
const inst = lib.parser();
|
||||
const inst = parser();
|
||||
inst.on('$enddefinitions', () => {
|
||||
expect(inst.info).to.deep.eq({
|
||||
status: 'simulation',
|
||||
|
@ -49,6 +49,7 @@ $enddefinitions $end
|
||||
0XyZ
|
||||
#400
|
||||
b1010101010101010101010101010101010101010101010101010101010101010 64b
|
||||
b0001010101010xx010101000000ggg
|
||||
b10101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010 128b
|
||||
b1010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010 256b
|
||||
b10101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010 512b
|
||||
|
10
vcd_spans.c
10
vcd_spans.c
@ -260,6 +260,16 @@ int onDigit(
|
||||
return 0;
|
||||
}
|
||||
|
||||
int onRecover(
|
||||
vcd_parser_t* state,
|
||||
const unsigned char* p,
|
||||
const unsigned char* endp,
|
||||
int digit
|
||||
) {
|
||||
state->digitCount = 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int timeSpan(vcd_parser_t* state, const unsigned char* p, const unsigned char* endp) {
|
||||
int64_t time = strtoul((const char *)p, (char **)&endp, 10);
|
||||
if (state->time == INT64_MAX) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user