1
0
mirror of https://github.com/sehugg/8bitworkshop.git synced 2024-11-29 14:51:17 +00:00

verilog: genModuleSync (for testing)

This commit is contained in:
Steven Hugg 2021-07-24 09:40:28 -05:00
parent 565d7d947c
commit f634007e51
2 changed files with 22 additions and 11 deletions

View File

@ -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 {

View File

@ -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);