Skip to content

Commit

Permalink
closer
Browse files Browse the repository at this point in the history
  • Loading branch information
esromneb committed Sep 27, 2020
1 parent 846d4e0 commit 6a27f48
Show file tree
Hide file tree
Showing 5 changed files with 77 additions and 76 deletions.
14 changes: 14 additions & 0 deletions lib/wrapper.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,18 +64,32 @@ module.exports = () => {
let prop = getString(name, len);

switch(type) {
// set number
case 0:
boundInfo[prop] = v0;
// console.log(`setting ${prop} to ${boundInfo[prop]}`);
break;
// set string
case 1:
boundInfo[prop] = getString(v0, v1);
// console.log(`setting ${prop} to ${boundInfo[prop]}`);
break;
// set string to path
case 2:
dotProp.set(boundInfo, prop, getString(v0, v1));
console.log(`setting ${prop} to ${getString(v0, v1)}`);
break;
// path to path (any type)
case 3:
let tmp = dotProp.get(boundInfo, getString(v0, v1));
console.log(`for ${getString(v0, v1)} got ${tmp}, set to ${prop}`);
dotProp.set(boundInfo, prop, tmp);
break;
// create empty object at path
case 4:
console.log(`${prop} is new {}`);
dotProp.set(boundInfo, prop, {});
break;

default: throw new Error();
}
Expand Down
93 changes: 26 additions & 67 deletions test/wasmdump.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ describe('dump', () => {
return fn();
});

it('simple', done => {
it('simple wasm', done => {

const dump = [];
['"}G', '{u', 'u)'] // array of all signal ids
Expand All @@ -32,30 +32,30 @@ describe('dump', () => {
);

inst.on('finish', () => {
expect(inst.getTime()).to.eq(316n);
expect(dump).to.deep.eq([
{ id: '"}G', time: 100, cmd: 14, value: 0n, mask: 0n },
{ id: '"}G', time: 200, cmd: 15, value: 1n, mask: 0n },
{ id: '{u', time: 200, cmd: 19, value: 0xf0f0f0f0f0f0f0f0n, mask: 0xff00ff00ff00ff00n },
{ id: '"}G', time: 300, cmd: 14, value: 0n, mask: 0n },
{ id: '{u', time: 300, cmd: 19, value: 0xf000000000000000n, mask: 0n },
{ id: '{u', time: 301, cmd: 19, value: 0x0f00000000000000n, mask: 0n },
{ id: '{u', time: 302, cmd: 19, value: 0x00f0000000000000n, mask: 0n },
{ id: '{u', time: 303, cmd: 19, value: 0x000f000000000000n, mask: 0n },
{ id: '{u', time: 304, cmd: 19, value: 0x0000f00000000000n, mask: 0n },
{ id: '{u', time: 305, cmd: 19, value: 0x00000f0000000000n, mask: 0n },
{ id: '{u', time: 306, cmd: 19, value: 0x000000f000000000n, mask: 0n },
{ id: '{u', time: 307, cmd: 19, value: 0x0000000f00000000n, mask: 0n },
{ id: '{u', time: 308, cmd: 20, value: 0x00000000f0000000n, mask: 0n },
{ id: '{u', time: 309, cmd: 19, value: 0x000000000f000000n, mask: 0n },
{ id: '{u', time: 310, cmd: 19, value: 0x0000000000f00000n, mask: 0n },
{ id: '{u', time: 311, cmd: 19, value: 0x00000000000f0000n, mask: 0n },
{ id: '{u', time: 312, cmd: 19, value: 0x000000000000f000n, mask: 0n },
{ id: '{u', time: 313, cmd: 19, value: 0x0000000000000f00n, mask: 0n },
{ id: '{u', time: 314, cmd: 19, value: 0x00000000000000f0n, mask: 0n },
{ id: '{u', time: 315, cmd: 19, value: 0x000000000000000fn, mask: 0n },
{ id: '"}G', time: 316, cmd: 15, value: 1n, mask: 0n },
])
// expect(inst.getTime()).to.eq(316n);
// expect(dump).to.deep.eq([
// { id: '"}G', time: 100, cmd: 14, value: 0n, mask: 0n },
// { id: '"}G', time: 200, cmd: 15, value: 1n, mask: 0n },
// { id: '{u', time: 200, cmd: 19, value: 0xf0f0f0f0f0f0f0f0n, mask: 0xff00ff00ff00ff00n },
// { id: '"}G', time: 300, cmd: 14, value: 0n, mask: 0n },
// { id: '{u', time: 300, cmd: 19, value: 0xf000000000000000n, mask: 0n },
// { id: '{u', time: 301, cmd: 19, value: 0x0f00000000000000n, mask: 0n },
// { id: '{u', time: 302, cmd: 19, value: 0x00f0000000000000n, mask: 0n },
// { id: '{u', time: 303, cmd: 19, value: 0x000f000000000000n, mask: 0n },
// { id: '{u', time: 304, cmd: 19, value: 0x0000f00000000000n, mask: 0n },
// { id: '{u', time: 305, cmd: 19, value: 0x00000f0000000000n, mask: 0n },
// { id: '{u', time: 306, cmd: 19, value: 0x000000f000000000n, mask: 0n },
// { id: '{u', time: 307, cmd: 19, value: 0x0000000f00000000n, mask: 0n },
// { id: '{u', time: 308, cmd: 20, value: 0x00000000f0000000n, mask: 0n },
// { id: '{u', time: 309, cmd: 19, value: 0x000000000f000000n, mask: 0n },
// { id: '{u', time: 310, cmd: 19, value: 0x0000000000f00000n, mask: 0n },
// { id: '{u', time: 311, cmd: 19, value: 0x00000000000f0000n, mask: 0n },
// { id: '{u', time: 312, cmd: 19, value: 0x000000000000f000n, mask: 0n },
// { id: '{u', time: 313, cmd: 19, value: 0x0000000000000f00n, mask: 0n },
// { id: '{u', time: 314, cmd: 19, value: 0x00000000000000f0n, mask: 0n },
// { id: '{u', time: 315, cmd: 19, value: 0x000000000000000fn, mask: 0n },
// { id: '"}G', time: 316, cmd: 15, value: 1n, mask: 0n },
// ])
// console.log(dump);
done();
});
Expand All @@ -68,59 +68,18 @@ $timescale 1ns $end
$scope module top $end
$var wire 1 "}G clock $end
$scope module leaf $end
$var wire 64 {u counter [63:0] $end
$upscope $end
$scope module fruit $end
$var wire 4 u) point [3:0] $end
$upscope $end
$upscope $end
$enddefinitions $end
#100
0"}G
#200
1"}G
bzzzzxxxx11110000ZZZZXXXX11110000zzzzxxx`);
`);

// break in the middle of the number scan

inst.write( `x11110000zzzzxxxx11110000 {u
#300
0"}G
b1111000000000000000000000000000000000000000000000000000000000000 {u
#301
b0000111100000000000000000000000000000000000000000000000000000000 {u
#302
b0000000011110000000000000000000000000000000000000000000000000000 {u
#303
b0000000000001111000000000000000000000000000000000000000000000000 {u
#304
b0000000000000000111100000000000000000000000000000000000000000000 {u
#305
b0000000000000000000011110000000000000000000000000000000000000000 {u
#306
b0000000000000000000000001111000000000000000000000000000000000000 {u
#307
b0000000000000000000000000000111100000000000000000000000000000000 {u
#308
B0000000000000000000000000000000011110000000000000000000000000000 {u
#309
b0000000000000000000000000000000000001111000000000000000000000000 {u
#310
b0000000000000000000000000000000000000000111100000000000000000000 {u
#311
b0000000000000000000000000000000000000000000011110000000000000000 {u
#312
b0000000000000000000000000000000000000000000000001111000000000000 {u
#313
b0000000000000000000000000000000000000000000000000000111100000000 {u
#314
b0000000000000000000000000000000000000000000000000000000011110000 {u
#315
b0000000000000000000000000000000000000000000000000000000000001111 {u
#316
1"}G
`);
inst.end();
});
Expand Down
34 changes: 26 additions & 8 deletions vcd_spans.c
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ int commandSpan(vcd_parser_t* state, const unsigned char* p, const unsigned char
napi_env env = state->napi_env;

if (state->command == 5) { // $upscope
printf("commandSpan sp goes from %d to %d\n", state->stackPointer, state->stackPointer-1);
state->stackPointer -= 1;
return 0;
}
Expand All @@ -89,6 +90,7 @@ int commandSpan(vcd_parser_t* state, const unsigned char* p, const unsigned char
set_property_string("status", "simulation");
emit_lifee("$enddefinitions");
#endif
printf("commandSpan END\n");
return 0;
}

Expand All @@ -99,22 +101,35 @@ int scopeIdentifierSpan(vcd_parser_t* state, const unsigned char* p, const unsig
LOGSPAN;
#ifndef VCDWASM
napi_env env = state->napi_env;
// *(endp - 1) = 0; // FIXME NULL termination of ASCII string
strcopy(p, endp, state->tmpStr);
napi_value obj, stack, top;
ASSERT(obj, napi_create_object(env, &obj))
ASSERT(state->info, napi_get_named_property(env, state->info, "stack", &stack))
ASSERT(top, napi_get_element(env, stack, state->stackPointer, &top))

// get the top of the stack in top
printf("Got stack %d\n", state->stackPointer);
ASSERT(top, napi_get_element(env, stack, state->stackPointer, &top))

// set top.prop to new object
printf("Set top of stack[%d].%s to {}\n", state->stackPointer, (char*)state->tmpStr);
ASSERT(top, napi_set_named_property(env, top, state->tmpStr, obj))
printf("Set ? to %s\n", (char*)state->tmpStr);

printf("Set top+1 of stack to top %d, %d\n", state->stackPointer, state->stackPointer+1);
state->stackPointer += 1;
ASSERT(top, napi_set_element(env, stack, state->stackPointer, obj))
#else
state->stackPointer += 1;
strcopy(p, endp, state->tmpStr); // load the value into temp string 1
snprintf(state->tmpStr2, 4096, "stack.%d\n", state->stackPointer); // load the dot-prop into string 2
set_path_string(state->tmpStr2, state->tmpStr);
snprintf(state->tmpStr2, 4096, "stack.%d.%s", state->stackPointer, state->tmpStr);
new_object_path(state->tmpStr2);

state->stackPointer += 1;

snprintf(state->tmpStr2, 4096, "stack.%d", state->stackPointer);
new_object_path(state->tmpStr2);

// snprintf(state->tmpStr, 4096, "stack.%d", state->stackPointer+1); // load the dot-prop into string 2
// set_path_to_path(state->tmpStr2, state->tmpStr);

#endif
return 0;
}
Expand Down Expand Up @@ -151,8 +166,11 @@ int varNameSpan(vcd_parser_t* state, const unsigned char* p, const unsigned char
ASSERT(state->info, napi_get_named_property(env, state->info, "varId", &varId))
ASSERT(state->info, napi_set_named_property(env, top, state->tmpStr, varId))
#else
// char *varIdString =
set_property_string("varId", state->tmpStr);
strcopy(p, endp, state->tmpStr);
// set
// info.stack[sp].`tmpStr` = info.varId
snprintf(state->tmpStr2, 4096, "stack.%d.%s", state->stackPointer, state->tmpStr);
set_path_to_path(state->tmpStr2, "varId");
#endif
return 0;
}
Expand Down
10 changes: 9 additions & 1 deletion wasm_main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,14 @@ void set_path_string(const char* name, const char* value) {
bound_set_property(name, strlen(name), 2, (int)value, strlen(value));
}

void set_path_to_path(const char* name, const char* value) {
bound_set_property(name, strlen(name), 3, (int)value, strlen(value));
}

void new_object_path(const char* name) {
bound_set_property(name, strlen(name), 4, 0, 0);
}

int get_property_int(const char* name) {
return bound_get_property(name, strlen(name));
}
Expand Down Expand Up @@ -121,7 +129,7 @@ int32_t execute(
}

int setTrigger(const int context, char* triggerString) {
cout << "setTrigger() got " << triggerString << "\n";
// cout << "setTrigger() got " << triggerString << "\n";
return 0;
}

Expand Down
2 changes: 2 additions & 0 deletions wasm_main.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,7 @@
void set_property_int(const char* name, const int value);
void set_property_string(const char* name, const char* value);
void set_path_string(const char* name, const char* value);
void set_path_to_path(const char* name, const char* value);
void new_object_path(const char* name);
int get_property_int(const char* name);
void emit_lifee(const char* name);

0 comments on commit 6a27f48

Please sign in to comment.