From f634007e51a54a3540a8cc3ecadce46b62b19057 Mon Sep 17 00:00:00 2001 From: Steven Hugg Date: Sat, 24 Jul 2021 09:40:28 -0500 Subject: [PATCH] verilog: genModuleSync (for testing) --- src/common/hdl/fuzz.ts | 16 ++++++---------- src/common/hdl/hdlwasm.ts | 17 ++++++++++++++++- 2 files changed, 22 insertions(+), 11 deletions(-) diff --git a/src/common/hdl/fuzz.ts b/src/common/hdl/fuzz.ts index d6c666e1..ba6bbac1 100644 --- a/src/common/hdl/fuzz.ts +++ b/src/common/hdl/fuzz.ts @@ -1,6 +1,6 @@ //import binaryen = require('binaryen'); -import { fn } from "jquery"; +//import { fn } from "jquery"; import { HDLError, HDLModuleJS } from "./hdlruntime"; import { HDLModuleWASM } from "./hdlwasm"; import { CompileError, VerilogXMLParser } from "./vxmlparser"; @@ -14,19 +14,15 @@ export function fuzz(buf) { if (e instanceof CompileError) return; throw e; } - /* - if (0) { + if (1) { var wmod = new HDLModuleWASM(parser.modules['TOP'], parser.modules['@CONST-POOL@']); wmod.traceBufferSize = 0x8000; wmod.maxMemoryMB = 0.25; - wmod.init().then(() => { - wmod.powercycle(); - wmod.tick2(10000); - wmod.dispose(); - }) + wmod.initSync(); + wmod.powercycle(); + wmod.tick2(10000); } - */ - if (1) { + if (0) { var jmod = new HDLModuleJS(parser.modules['TOP'], parser.modules['@CONST-POOL@']); jmod.init(); try { diff --git a/src/common/hdl/hdlwasm.ts b/src/common/hdl/hdlwasm.ts index 0512d8bc..9ae25175 100644 --- a/src/common/hdl/hdlwasm.ts +++ b/src/common/hdl/hdlwasm.ts @@ -2,7 +2,6 @@ import binaryen = require('binaryen'); import { hasDataType, HDLBinop, HDLBlock, HDLConstant, HDLDataType, HDLDataTypeObject, HDLExpr, HDLExtendop, HDLFuncCall, HDLModuleDef, HDLModuleRunner, HDLSourceLocation, HDLSourceObject, HDLTriop, HDLUnop, HDLValue, HDLVariableDef, HDLVarRef, HDLWhileOp, isArrayItem, isArrayType, isBigConstExpr, isBinop, isBlock, isConstExpr, isFuncCall, isLogicType, isTriop, isUnop, isVarDecl, isVarRef, isWhileop } from "./hdltypes"; import { HDLError } from "./hdlruntime"; -import { EmuHalt } from '../emu'; const VERILATOR_UNIT_FUNCTIONS = [ "_ctor_var_reset", @@ -214,6 +213,13 @@ export class HDLModuleWASM implements HDLModuleRunner { async init() { await this.genModule(); + this.genStateInterface(); + this.enableTracing(); + } + + initSync() { + this.genModuleSync(); + this.genStateInterface(); this.enableTracing(); } @@ -444,6 +450,15 @@ export class HDLModuleWASM implements HDLModuleRunner { var wasmData = this.bmod.emitBinary(); var compiled = await WebAssembly.compile(wasmData); this.instance = await WebAssembly.instantiate(compiled, this.getImportObject()); + } + + private genModuleSync() { + var wasmData = this.bmod.emitBinary(); + var compiled = new WebAssembly.Module(wasmData); + this.instance = new WebAssembly.Instance(compiled, this.getImportObject()); + } + + private genStateInterface() { this.databuf = (this.instance.exports[MEMORY] as any).buffer; this.data8 = new Uint8Array(this.databuf); this.data16 = new Uint16Array(this.databuf);