From 01c4e20712274637079ea0b41bb7e88cb34c5b7b Mon Sep 17 00:00:00 2001 From: Aliaksei Chapyzhenka Date: Sat, 19 Oct 2019 23:58:39 -0700 Subject: [PATCH] added simulation time --- bin/build.js | 11 ++++++++++- vcd.c | 2 +- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/bin/build.js b/bin/build.js index b825c77..3dbd6c6 100755 --- a/bin/build.js +++ b/bin/build.js @@ -17,6 +17,7 @@ const inDeclaration = p.node('inDeclaration'); const enddefinitions = p.node('inDeclarationEnd'); const simulation = p.node('simulation'); const inSimulation = p.node('inSimulation'); +const simulationTime = p.node('simulationTime'); declaration .match([' ', '\n', '\t'], declaration) @@ -40,15 +41,23 @@ enddefinitions simulation .match([' ', '\n', '\t'], simulation) .select({ - '$dumpall': 101, '$dumpoff': 102, '$dumpon': 103, '$dumpvars': 104, + '$dumpall': 8, '$dumpoff': 9, '$dumpon': 10, '$dumpvars': 11, '$comment': 1 }, p.invoke(p.code.store('command'), commandSpan.start(inSimulation))) + .select({'#': 12}, p.invoke(p.code.store('command'), commandSpan.start(simulationTime))) + .select({'0': 13}, p.invoke(p.code.store('command'), commandSpan.start(simulationTime))) + .select({'1': 14}, p.invoke(p.code.store('command'), commandSpan.start(simulationTime))) .otherwise(p.error(2, 'Expected simulation command')); inSimulation .match('$end', commandSpan.end(simulation)) .skipTo(inSimulation); +simulationTime + .match([' ', '\n', '\r', '\t'], commandSpan.end(simulation)) + .skipTo(simulationTime); + + // Build const artifacts = p.build(declaration); diff --git a/vcd.c b/vcd.c index 57b6e08..020ed38 100644 --- a/vcd.c +++ b/vcd.c @@ -142,7 +142,7 @@ napi_value Init(napi_env env, napi_value exports) { } int commandSpan(vcd_parser_t* s, const unsigned char* p, const unsigned char* endp) { - printf("%d:%.*s\n", s->command, (int)(endp - p - 4), p); + printf("(%d)%.*s\n", s->command, (int)(endp - p), p); return 0; };