dump initial timestamp "t0"

This commit is contained in:
Aliaksei Chapyzhenka 2020-09-29 13:11:09 -07:00
parent baa48eeee0
commit 51296f30b8
5 changed files with 22 additions and 4 deletions

View File

@ -85,6 +85,7 @@ b0000000000001111 {u
date: ' Wed Sep 18 22:59:07 2019\n ',
version: ' Generated by VerilatedVcd ',
timescale: ' 1ns ',
t0: 1,
varId: 'u)',
wires: {
top: {

View File

@ -83,6 +83,7 @@ b0000000000001111 {u
date: ' Wed Sep 18 22:59:07 2019\n ',
version: ' Generated by VerilatedVcd ',
timescale: ' 1ns ',
t0: 1,
varId: 'u)',
wires: {
top: {

2
vcd.c
View File

@ -1,5 +1,6 @@
#define NAPI_VERSION 1
#include <stdio.h>
#include <limits.h>
#include <stdlib.h>
#include "vcd_parser.h"
#include <node_api.h>
@ -135,6 +136,7 @@ METHOD(init) {
state->tmpStr2 = tmpStr2;
state->value = valueBuf;
state->mask = maskBuf;
state->time = UINT64_MAX;
state->digitCount = 0;
napi_value status;

View File

@ -1,6 +1,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <limits.h>
#include "vcd_parser.h"
#ifndef VCDWASM
@ -261,6 +262,17 @@ int onDigit(
}
int timeSpan(vcd_parser_t* state, const unsigned char* p, const unsigned char* endp) {
state->time = strtoul((const char *)p, (char **)&endp, 10);
int64_t time = strtoul((const char *)p, (char **)&endp, 10);
if (state->time == UINT64_MAX) {
#ifndef VCDWASM
napi_env env = state->napi_env;
napi_value val;
ASSERT(val, napi_create_int32(env, time, &val))
ASSERT(state->info, napi_set_named_property(env, state->info, "t0", val))
#else
set_property_int("t0", time);
#endif
}
state->time = time;
return 0;
}

View File

@ -1,6 +1,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <limits.h>
#include <iostream>
#include "vcd_parser.h"
@ -119,6 +120,7 @@ int init(
state->value = valueBuf;
state->mask = maskBuf;
state->digitCount = 0;
state->time = UINT64_MAX;
set_property_string("status", "declaration");