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