Skip to content

Commit

Permalink
dump initial timestamp "t0"
Browse files Browse the repository at this point in the history
  • Loading branch information
drom committed Sep 29, 2020
1 parent baa48ee commit 51296f3
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 4 deletions.
1 change: 1 addition & 0 deletions test/basic.js
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand Down
1 change: 1 addition & 0 deletions test/wasm_basic.js
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand Down
2 changes: 2 additions & 0 deletions vcd.c
Original file line number Diff line number Diff line change
@@ -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>
Expand Down Expand Up @@ -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;
Expand Down
14 changes: 13 additions & 1 deletion vcd_spans.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <limits.h>
#include "vcd_parser.h"

#ifndef VCDWASM
Expand Down Expand Up @@ -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;
}
8 changes: 5 additions & 3 deletions wasm_main.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <limits.h>
#include <iostream>
#include "vcd_parser.h"

Expand Down Expand Up @@ -87,7 +88,7 @@ int init(
externalJsSetProperty* sfn,
externalJsGetProperty* gfn
) {


state = (struct vcd_parser_s*) malloc(sizeof *state);

Expand Down Expand Up @@ -119,6 +120,7 @@ int init(
state->value = valueBuf;
state->mask = maskBuf;
state->digitCount = 0;
state->time = UINT64_MAX;

set_property_string("status", "declaration");

Expand Down Expand Up @@ -185,7 +187,7 @@ uint64_t getTime(const int context) {
// externalOne = f1;

// set_property_int("foo", 10);


// int got = get_property_int("bar");

Expand All @@ -199,4 +201,4 @@ int main(void) {
}


} // extern C
} // extern C

0 comments on commit 51296f3

Please sign in to comment.