support for $comment, $date, $timescale, $version

This commit is contained in:
Aliaksei Chapyzhenka 2020-09-29 11:21:39 -07:00
parent e1c5f08747
commit 54332dfef3
5 changed files with 39 additions and 1 deletions

View File

@ -32,6 +32,7 @@ describe('basic', () => {
' \n $comment some text $end $comment more text $end ???'
))).to.eq(true);
expect(inst.info).to.deep.eq({
comment: ' more text ',
stack: [{}],
status: 'declaration',
wires: {}
@ -81,6 +82,9 @@ b0000000000001111 {u
expect(inst.info).to.deep.eq({
status: 'simulation',
date: ' Wed Sep 18 22:59:07 2019\n ',
version: ' Generated by VerilatedVcd ',
timescale: ' 1ns ',
varId: 'u)',
wires: {
top: {

View File

@ -10,6 +10,9 @@ describe('events', () => {
inst.on('$enddefinitions', () => {
expect(inst.info).to.deep.eq({
status: 'simulation',
date: ' Wed Sep 18 22:59:07 2019\n ',
version: ' Generated by VerilatedVcd ',
timescale: ' 1ns ',
varId: 'u)',
wires: {
top: {

View File

@ -31,6 +31,7 @@ describe('wasm basic', () => {
' \n $comment some text $end $comment more text $end ???'
))).to.eq(true);
expect(inst.info).to.deep.eq({
comment: ' more text ',
stack: [{}],
status: 'declaration',
wires: {}
@ -79,6 +80,9 @@ b0000000000001111 {u
expect(inst.info).to.deep.eq({
status: 'simulation',
date: ' Wed Sep 18 22:59:07 2019\n ',
version: ' Generated by VerilatedVcd ',
timescale: ' 1ns ',
varId: 'u)',
wires: {
top: {

View File

@ -14,10 +14,13 @@ describe('wasm events', () => {
});
it('$enddefinitions', done => {
inst.on('$enddefinitions', () => {
expect(inst.info).to.deep.eq({
status: 'simulation',
timescale: ' 1ns ',
date: ' Wed Sep 18 22:59:07 2019\n ',
version: ' Generated by VerilatedVcd ',
varId: 'u)',
wires: {
top: {

View File

@ -74,6 +74,30 @@ int commandSpan(vcd_parser_t* state, const unsigned char* p, const unsigned char
return 0;
}
if (
(state->command == 1) || // $comment
(state->command == 2) || // $date
(state->command == 4) || // $timescale
(state->command == 7) // $version
) {
char* key;
switch(state->command) {
case 1: key = "comment"; break;
case 2: key = "date"; break;
case 4: key = "timescale"; break;
case 7: key = "version"; break;
}
#ifndef VCDWASM
napi_value val;
ASSERT(val, napi_create_string_latin1(env, (char*)p, (endp - p - 4), &val))
ASSERT(state->info, napi_set_named_property(env, state->info, key, val))
#else
strcopy(p, endp - 3, state->tmpStr);
set_property_string(key, state->tmpStr);
#endif
return 0;
}
if (state->command == 8) { // $enddefinitions
#ifndef VCDWASM
napi_value status, undefined, eventName, eventPayload, return_val;